pax_global_header 0000666 0000000 0000000 00000000064 15202152077 0014513 g ustar 00root root 0000000 0000000 52 comment=60d089e439279cd3c7705187ae6092b998a3fe71
fsdsfdsfdsfdsf-5.13.8/ 0000775 0000000 0000000 00000000000 15202152077 0014605 5 ustar 00root root 0000000 0000000 fsdsfdsfdsfdsf-5.13.8/.gitignore 0000664 0000000 0000000 00000000510 15202152077 0016571 0 ustar 00root root 0000000 0000000 # Compiled sibs files
sibs-build/
compile_commands.json
tests/sibs-build/
tests/compile_commands.json
**/xdg-output-unstable-v1-client-protocol.h
**/xdg-output-unstable-v1-protocol.c
.clangd/
.cache/
.vscode/
build/
debug-build/
*.o
gpu-screen-recorder
gsr-kms-server
*.mp4
*.flv
*.mkv
*.mov
*.webm
*.ts
*.jpg
*.jpeg
*.png
fsdsfdsfdsfdsf-5.13.8/LICENSE 0000664 0000000 0000000 00000104515 15202152077 0015620 0 ustar 00root root 0000000 0000000 GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
Copyright (C)
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
.
fsdsfdsfdsfdsf-5.13.8/README.md 0000664 0000000 0000000 00000070151 15202152077 0016070 0 ustar 00root root 0000000 0000000 
# GPU Screen Recorder
This is a screen recorder that has minimal impact on system performance by recording your monitor using the GPU only,
similar to shadowplay on windows. This is the fastest screen recording tool for Linux.
This screen recorder can be used for recording your desktop offline, for live streaming and for nvidia shadowplay-like instant replay,
where only the last few minutes are saved.
This software can also take screenshots.
This is a cli-only tool, if you want an UI for this check out [GPU Screen Recorder GTK](https://git.dec05eba.com/gpu-screen-recorder-gtk/) or if you prefer a ShadowPlay-like UI then check out [GPU Screen Recorder UI](https://git.dec05eba.com/gpu-screen-recorder-ui/).
Supported video codecs:
* H264 (default)
* HEVC (Optionally with HDR)
* AV1 (Optionally with HDR. Not currently supported on NVIDIA in the flatpak version of GPU Screen Recorder)
* VP8
* VP9
Supported audio codecs:
* Opus (default)
* AAC
Supported image formats:
* JPEG
* PNG
This software works on X11 and Wayland on AMD, Intel and NVIDIA.
# Installation
If you are running an Arch Linux based distro then you can find gpu screen recorder in the official repositories under the name gpu-screen-recorder (`sudo pacman -S gpu-screen-recorder`).\
If you are running another distro then you can run `sudo ./install.sh`, but you need to manually install the dependencies, as described below.\
You can also install gpu screen recorder ([the ui version](https://git.dec05eba.com/gpu-screen-recorder-gtk/)) from [flathub](https://flathub.org/apps/details/com.dec05eba.gpu_screen_recorder), which is the easiest method
to install GPU Screen Recorder on non-arch based distros.\
If you install GPU Screen Recorder flatpak, which is the gtk gui version then you can still run GPU Screen Recorder command line by using the flatpak command option, for example `flatpak run --command=gpu-screen-recorder com.dec05eba.gpu_screen_recorder -w screen -f 60 -o video.mp4`. Note that if you want to record your monitor on AMD/Intel then you need to install the flatpak system-wide (like so: `flatpak install --system com.dec05eba.gpu_screen_recorder`).
## Unofficial install methods
The only official ways to install GPU Screen Recorder is either from source, arch linux extra repository or flathub. Other sources may be out of date and missing features or may not work correctly.\
If you install GPU Screen Recorder from somewhere else and have an issue then try installing it from one of the official sources before reporting it as an issue.\
If you still prefer to install GPU Screen Recorder with a package manager instead of from source or as a flatpak then you may be able to find a package for your distro.\
Here are some known unofficial packages:
* Debian/Ubuntu: [Pacstall](https://pacstall.dev/packages/gpu-screen-recorder)
* Nix: [NixOS wiki](https://wiki.nixos.org/wiki/Gpu-screen-recorder)
* openSUSE: [openSUSE software repository](https://software.opensuse.org/package/gpu-screen-recorder)
* Fedora, CentOS: [Copr](https://copr.fedorainfracloud.org/coprs/brycensranch/gpu-screen-recorder-git/)
* OpenMandriva: [gpu-screen-recorder](https://github.com/OpenMandrivaAssociation/gpu-screen-recorder)
* Solus: [gpu-screen-recorder](https://github.com/getsolus/packages/tree/main/packages/g/gpu-screen-recorder)
* Nobara: [Nobara wiki](https://wiki.nobaraproject.org/en/general-usage/additional-software/GPU-Screen-Recorder)
* AppImage [AppImage GitHub releases](https://github.com/pkgforge-dev/gpu-screen-recorder-AppImage/releases)
* Void Linux: [gpu-screen-recorder](https://github.com/cherrybtw/gsr4xbps)
# Dependencies
GPU Screen Recorder uses meson build system so you need to install `meson` to build GPU Screen Recorder.
## Build dependencies
These are the dependencies needed to build GPU Screen Recorder:
* x11 (libx11, libxcomposite, libxrandr, libxfixes, libxdamage)
* wayland (wayland-client, wayland-egl, wayland-scanner)
* ffmpeg (libavcodec, libavformat, libavutil, libswresample, libavfilter)
* libva (and libva-drm)
* libpulse
* libdrm
* libcap
* vulkan-headers
* linux-api-headers
## Optional dependencies
When building GPU Screen Recorder with portal support (`-Dportal=true` meson option, which is enabled by default) these dependencies are also needed:
* libdbus
* libpipewire (and libspa which is usually part of libpipewire)
## Runtime dependencies
* libglvnd (which provides libgl, libglx and libegl) is needed. Your system needs to support at least OpenGL ES 3.0 (released in 2012)
* vulkan-icd-loader (which provides the runtime vulkan library. This is only needed if vulkan video encoding option is used)
* libturbojpeg (aka libjpeg-turbo) is needed when capturing camera with mjpeg pixel format option
There are also additional dependencies needed at runtime depending on your GPU vendor:
### AMD
* mesa
* vaapi (libva-mesa-driver)
### Intel
* mesa
* vaapi (intel-media-driver/libva-intel-driver/linux-firmware-intel, depending on which intel GPU you have)
### NVIDIA
* cuda runtime (libcuda.so.1) (libnvidia-compute)
* nvenc (libnvidia-encode)
* nvfbc (libnvidia-fbc1, when recording the screen on x11)
# How to use
Run `gpu-screen-recorder --help` to see all options and run `man gpu-screen-recorder` to see more detailed explanations for the options and also examples.\
There is also a gui for the gpu screen recorder called [GPU Screen Recorder GTK](https://git.dec05eba.com/gpu-screen-recorder-gtk/).\
There is also a new alternative UI for GPU Screen Recorder in the style of ShadowPlay called [GPU Screen Recorder UI](https://git.dec05eba.com/gpu-screen-recorder-ui/).
## Recording
Here is an example of how to record your monitor and the default audio output: `gpu-screen-recorder -w screen -f 60 -a default_output -o ~/Videos/test_video.mp4`.
Yyou can stop and save the recording with `Ctrl+C` or by running `pkill -SIGINT -f "^gpu-screen-recorder"`.
You can see a list of capture options to record if you run `gpu-screen-recorder --list-capture-options`. This will list possible capture options and monitor names, for example:\
```
window
DP-1|1920x1080
```
in this case you could record a window or a monitor with the name `DP-1`.\
To list available audio devices that you can use you can run `gpu-screen-recorder --list-audio-devices` and the name to use is on the left size of the `|`.\
To list available audio application names that you can use you can run `gpu-screen-recorder --list-application-audio`.\
You can run `gpu-screen-recorder --info` to list more information about the system, such as the device that is used for capture and video encoding and supported codecs. These commands can be parsed by scripts/programs.
## Replay mode
Run `gpu-screen-recorder` with the `-c mp4` and `-r` option, for example: `gpu-screen-recorder -w screen -f 60 -r 30 -c mp4 -o ~/Videos`. Note that in this case, `-o` should point to a directory.\
If `-df yes` is set, replays are save in folders based on the date.
The file path to the saved replay is output to stdout. All other output from GPU Screen Recorder are output to stderr.
You can also use the `-sc` option to specify a script that should be run (asynchronously) when the video has been saved and the script will have access to the location of the saved file as its first argument.
This can be used for example to show a notification when a replay has been saved, to rename the video with a title that matches the game played (see `scripts/record-save-application-name.sh` as an example on how to do this on X11) or to re-encode the video.
The replay buffer is stored in ram (as encoded video) by default, so don't use a too large replay time and/or video quality unless you have enough ram to store it.\
You can use the `-replay-storage disk` option to store the replay buffer on disk instead of ram (in the same location as the output video).\
By default videos are recorded with constant quality, but with replay mode you might want to record in constant bitrate mode instead for consistent ram/disk usage in high motion scenes. You can do that by using the `-bm cbr` option (along with `-q` option, for example `-bm cbr -q 20000`).
## Streaming
Streaming works the same way as recording, but the `-o` argument should be path to the live streaming service you want to use (including your live streaming key). Take a look at `scripts/twitch-stream.sh` to see an example of how to stream to twitch.\
GPU Screen Recorder uses Ffmpeg so GPU Screen Recorder supports all protocols that Ffmpeg supports.\
If you want to reduce latency one thing you can do is to use the `-keyint` option, for example `-keyint 0.5`. Lower value means lower latency at the cost of increased bitrate/decreased quality.
## Recording while using replay/streaming
You can record a regular video while using replay/streaming by launching GPU Screen Recorder with the `-ro` option to specify a directory where to save the recording (for example: `gpu-screen-recorder -w screen -c mp4 -r 60 -o "$HOME/Videos/replays" -ro "$HOME/Videos/recordings"`).\
To start/stop (and save) recording use the SIGRTMIN signal, for example `pkill -SIGRTMIN -f "^gpu-screen-recorder"`. The path to the video will be displayed in stdout when saving the video.\
This way of recording while using replay/streaming is more efficient than running GPU Screen Recorder multiple times since this way it only records the screen and encodes the video once.
## Controlling GPU Screen Recorder remotely
To save a video in replay mode, you need to send signal SIGUSR1 to gpu screen recorder. You can do this by running `pkill -SIGUSR1 -f "^gpu-screen-recorder"`.\
To stop recording send SIGINT to gpu screen recorder. You can do this by running `pkill -SIGINT -f "^gpu-screen-recorder"` or pressing `Ctrl-C` in the terminal that runs gpu screen recorder. When recording a regular non-replay video this will also save the video.\
To pause/unpause recording send SIGUSR2 to gpu screen recorder. You can do this by running `pkill -SIGUSR2 -f "^gpu-screen-recorder"`. This is only applicable and useful when recording (not streaming nor replay).\
There are more signals to control GPU Screen Recorder. Run `gpu-screen-recorder --help` to list them all (under `NOTES` section).
## Simple way to run replay without gui
Run the script `scripts/start-replay.sh` to start replay and then `scripts/save-replay.sh` to save a replay and `scripts/stop-replay.sh` to stop the replay. The videos are saved to `$HOME/Videos`.
You can use these scripts to start replay at system startup if you add `scripts/start-replay.sh` to startup (this can be done differently depending on your desktop environment / window manager) and then go into
hotkey settings on your system and choose a hotkey to run the script `scripts/save-replay.sh`. Modify `scripts/start-replay.sh` if you want to use other replay options.
## Run replay on system startup
If you installed GPU Screen Recorder from AUR or from source and you are running a distro that uses systemd then you will have a systemd service installed that can be started with `systemctl enable --now --user gpu-screen-recorder`. This systemd service runs GPU Screen Recorder on system startup.\
It's configured with `$HOME/.config/gpu-screen-recorder/gpu-screen-recorder.env` (create it if it doesn't exist). You can look at [extra/gpu-screen-recorder.env](https://git.dec05eba.com/gpu-screen-recorder/plain/extra/gpu-screen-recorder.env) to see an example.
You can see which variables that you can use in the `gpu-screen-recorder.env` file by looking at the `extra/gpu-screen-recorder.service` file. Note that all of the variables are optional, you only have to set the ones that are you interested in.
You can use the `scripts/save-replay.sh` script to save a replay and by default the systemd service saves videos in `$HOME/Videos`.
## Run a script when a video is saved
Run `gpu-screen-recorder` with the `-sc` option to specify a script that should be run when a recording/replay a saved, for example `gpu-screen-recorder -w screen -sc ./script.sh -o video.mp4`.\
The first argument to the script is the file path to the saved video. The second argument is either "regular" for regular recordings, "replay" for replays or "screenshot" for screenshots.\
This can be used to for example showing a notification with the name of video or moving a video to a folder based on the name of the game that was recorded.
## Plugins
GPU Screen Recorder supports plugins for rendering additional graphics on top of the monitor/window capture. The plugin interface is defined in `plugin/plugin.h` and it gets installed to `gsr/plugin.h` in the systems include directory (usually `/usr/include`).
An example plugin can be found at `plugin/examples/hello_triangle`.\
Run `gpu-screen-recorder` with the `-p` option to specify a plugin to load, for example `gpu-screen-recorder -w screen -p ./triangle.so -o video.mp4`.
`-p` can be specified multiple times to load multiple plugins.\
Build GPU Screen Recorder with the `-Dplugin_examples=true` meson option to build plugin examples.
## Smoother recording
If you record at your monitors refresh rate and enabled vsync in a game then there might be a desync between the game updating a frame and GPU Screen Recorder capturing a frame.
This is an issue in some games.
If you experience this issue then you might want to either disable vsync in the game or use the `-fm content` option to sync capture to the content on the screen. For example: `gpu-screen-recorder -w screen -fm content -o video.mp4`.\
Note that this option is currently only available on X11, or with desktop portal capture on Wayland (`-w portal`).
# Performance
On a system with an i5 4690k CPU and a GTX 1080 GPU:\
When recording Legend of Zelda Breath of the Wild at 4k, fps drops from 30 to 7 when using OBS Studio + nvenc, however when using this screen recorder the fps remains at 30.\
When recording GTA V at 4k on highest settings, fps drops from 60 to 23 when using obs-nvfbc + nvenc, however when using this screen recorder the fps only drops to 58.\
On a system with an AMD Ryzen 9 5900X CPU and an RX 7800XT GPU I don't see any fps drop at all, even when recording at 4k 60fps with AV1 codec with 10-bit colors.\
GPU Screen Recorder also produces much smoother videos than OBS when GPU utilization is close to 100%, see comparison here: [https://www.youtube.com/watch?v=zfj4sNVLLLg](https://www.youtube.com/watch?v=zfj4sNVLLLg) and [https://www.youtube.com/watch?v=aK67RSZw2ZQ](https://www.youtube.com/watch?v=aK67RSZw2ZQ).\
GPU Screen Recorder has much better performance than OBS Studio even with version 30.2 that does "zero-copy" recording and encoding, see: [https://www.youtube.com/watch?v=jdroRjibsDw](https://www.youtube.com/watch?v=jdroRjibsDw).\
It is recommended to save the video to a SSD because of the large file size, which a slow HDD might not be fast enough to handle. Using variable framerate mode (-fm vfr) which is the default is also recommended as this reduces encoding load. Ultra quality is also overkill most of the time, very high (the default) or lower quality is usually enough.\
Note that for best performance you should close other screen recorders such as OBS Studio when using GPU Screen Recorder even if they are not recording, since they can affect performance even when idle. This is the case with OBS Studio.
## Note about optimal performance on NVIDIA
NVIDIA driver has a "feature" (read: bug) where it will downclock memory transfer rate when a program uses cuda (or nvenc, which uses cuda), such as GPU Screen Recorder. This can affect game performance.
GPU Screen Recorder installs an NVIDIA profile on the system (`~/.nv/nvidia-application-profiles-rc.d/10-gsr-cuda-no-stable-perf-limit`) to get around this issue but this requires a relatively
new NVIDIA driver version (580+). If you have an older NVIDIA driver then you can choose to record with vulkan video encoding instead as it doesn't have this issue.
You can use vulkan video encoding by adding `_vulkan` at the end of the video codec option, for example: `-k h264_vulkan` or a full command example: `gpu-screen-recorder -w screen -k h264_vulkan -o video.mp4`.
Vulkan video encoding in GPU Screen Recorder supports `h264`, `hevc` and `av1` (along with `hdr` and `10bit` options), assuming your gpu drivers, ffmpeg and vulkan is up to date.
Note: vulkan video encoding support is experimental and you may experience GPU Screen Recorder or gpu driver bugs with it.
# Issues
## NVIDIA
NVIDIA drivers have an issue where CUDA breaks if CUDA is running when suspend/hibernation happens, and it remains broken until you reload the nvidia driver. `extra/gsr-nvidia.conf` will be installed by default when you install GPU Screen Recorder and that should fix this issue. If this doesn't fix the issue for you then your distro may use a different path for modprobe files. In that case you have to install that `extra/gsr-nvidia.conf` yourself into that location.
You have to reboot your computer after installing GPU Screen Recorder for the first time for the fix to have any effect.
Note: this issue doesn't happen when you using the vulkan video encoding option (for example when using `-k h264_vulkan`).
## TEMPORARY ISSUES
1) Videos are in variable framerate format. Use MPV to play such videos, otherwise you might experience stuttering in the video if you are using a buggy video player. You can try saving the video into a .mkv file instead as some software may have better support for .mkv files (such as kdenlive). You can use the "-fm cfr" option to to use constant framerate mode.
2) FLAC audio codec is disabled at the moment because of temporary issues.
# Examples
Look at the [scripts](https://git.dec05eba.com/gpu-screen-recorder/tree/scripts) directory for script examples. For example if you want to automatically save a recording/replay into a folder with the same name as the game you are recording.
# AMD/Intel/Wayland root permission
When recording a window or when using the `-w portal` option no special user permission is required,
however when recording a monitor the program needs root permission (to access KMS).\
This is safe in GPU Screen Recorder as the part that needs root access has been moved to its own small program that only does one thing.\
For you as a user this only means that if you installed GPU Screen Recorder as a flatpak then a prompt asking for root password will show up once when you start recording.
# VRR/G-SYNC
This should work fine on AMD/Intel X11 or Wayland. On Nvidia X11 G-SYNC only works with the -w screen-direct option, but because of bugs in the Nvidia driver this option is not always recommended.
For example it can cause your computer to freeze when recording certain games.
# License
This software is licensed under GPL-3.0-only, see the LICENSE file for more information.
# Reporting bugs, contributing patches, questions or donation
See [https://git.dec05eba.com/?p=about](https://git.dec05eba.com/?p=about).
# Demo
[](https://www.youtube.com/watch?v=n5tm0g01n6A)
# FAQ
## It tells me that my AMD/Intel GPU is not supported or that my GPU doesn't support h264/hevc, but that's not true!
Some linux distros (such as manjaro and fedora) disable hardware accelerated h264/hevc on AMD/Intel because of "patent license issues". If you are using an arch-based distro then you can install mesa-git instead of mesa and if you are using another distro then you may have to switch to a better distro. On fedora based distros you can follow this: [Hardware Accelerated Codec](https://rpmfusion.org/Howto/Multimedia).\
You can alternatively install the flatpak version of GPU Screen Recorder from [flathub](https://flathub.org/apps/details/com.dec05eba.gpu_screen_recorder) which doesn't have this issue on any distro.
## I have an old nvidia GPU that supports nvenc but I get a cuda error when trying to record
Newer ffmpeg versions don't support older nvidia cards. Try installing GPU Screen Recorder flatpak from [flathub](https://flathub.org/apps/details/com.dec05eba.gpu_screen_recorder) instead. It comes with an older ffmpeg version which might work for your GPU.
## I get a black screen/glitches while live streaming
It seems like ffmpeg earlier than version 6.1 has some type of bug. Install ffmpeg version 6.1 or later and then reinstall GPU Screen Recorder to fix this issue. The flatpak version of GPU Screen Recorder comes with a newer version of ffmpeg so no extra steps are needed.
## I can't play the video in my browser directly or in discord
Browsers and discord don't support hevc video codec at the moment. You can instead choose h264 video codec with the -k h264 option or av1 video codec with the -k av1 option.
Note that websites such as youtube support hevc so there is no need to choose h264 video codec if you intend to upload the video to youtube or if you want to play the video locally or if you intend to
edit the video with a video editor. Hevc allows for better video quality (especially at lower file sizes) so hevc (or av1) is recommended for source videos.
## I get a black bar/distorted colors on the sides in the video
This is mostly an issue on AMD. For av1 it's a hardware issue, see: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9185. For hevc it's a software issue in ffmpeg that was fixed in ffmpeg version 8.\
If your ffmpeg version is older than 8 then you can use the flatpak version of GPU Screen Recorder which comes with ffmpeg version >= 8.\
Alternatively you can record with h264 codec (-k h264, which is also the default codec) to workaround this issue.
## The video doesn't display or has a green/yellow overlay
This can happen if your video player is missing the H264/HEVC video codecs. Either install the codecs or use mpv.
## I get stutter in the video
Try recording to an SSD and make sure it's not using NTFS file system. Also try recording with "content" framerate mode (`-fm content`).
## The colors look washed out when recording a monitor with HDR enabled
You have to either record in hdr mode (-k `hevc_hdr` or -k `av1_hdr` option) to record a HDR video or record with desktop portal option (`-w portal`) to turn the HDR recording into SDR.
## GPU Screen Recorder records night light when recording in HDR mode
You can record with desktop portal option (`-w portal`) instead which ignores night light, if you are ok with recording without HDR.
## Kdenlive says that the video is not usable for editing because it has variable frame rate
To fix this you can either just press cancel, which will allow you to continue or record the video in .mkv format or constant frame rate (-fm cfr). I recommend recording the video in .mkv format and variable frame rate (-fm vfr).
## Colors look incorrect when recording HDR (with hevc_hdr/av1_hdr) or using an ICC profile
KDE Plasma version 6.2 broke HDR and ICC profiles for screen recorders. This was changed in KDE plasma version 6.3 and recording HDR works now, as long as you set HDR brightness to 100% (which means setting "Maximum SDR Brightness" in KDE plasma display settings to 203) and set color accuracy to "Prefer color accuracy". If you want to convert HDR to SDR then record with desktop portal option (`-w portal`) instead.
I don't know how well recording HDR works in wayland compositors other than KDE plasma.
## GPU Screen Recorder starts lagging after 30-40 minutes when launching GPU Screen Recorder from steam command launcher
This is a [steam issue](https://github.com/ValveSoftware/steam-for-linux/issues/11446). Prepend the gpu-screen-recorder command with `LD_PREFIX=""`, for example `LD_PREFIX="" gpu-screen-recorder -w screen -o video.mp4`.
## How do I apply audio effects, such as noise suppression?
You have to use external software for that, such as Easy Effects or NoiseTorch.
## How do I choose which GPU to record/encode with?
It's not really possible except in some cases. You can only record with the GPU that is displaying the graphics on your monitor.\
Some laptops have display adapters that connect external monitors directly to the external GPU (if you have one)
and on Wayland the external GPU will display the graphics for that monitor.
In that case you can record the monitor with the external GPU by launching GPU Screen Recorder with [prime-run or by setting the DRI_PRIME environment variable](https://wiki.archlinux.org/title/PRIME) depending on your GPU brand.
Alternatively you can capture with the desktop portal option (`-w portal`), which should allow you to capture any monitor.\
However if you really want to change which GPU you want to record and encode with with then you can instead configure your display server (Xorg or Wayland compositor) to run with that GPU,
then GPU Screen Recorder will automatically use that same GPU for recording and encoding.
## The rotation of the video is incorrect when the monitor is rotated when using desktop portal capture
This is a bug in kde plasma wayland. When using desktop portal capture and the monitor is rotated and a window is made fullscreen kde plasma wayland will give incorrect rotation to GPU Screen Recorder.
This also affects other screen recording software such as obs studio.\
Capture a monitor directly instead to workaround this issue until kde plasma devs fix it, or use another wayland compositor that doesn't have this issue.
## System notifications get disabled when recording with desktop portal option
Some desktop environments such as KDE Plasma turn off notifications when you record the screen with the desktop portal option. You can disable this by going into KDE Plasma settings -> search for notifications and then under "Do Not Disturb mode" untick "During screen sharing".
## The recorded video lags or I get dropped frames in the video
This is likely not an issue in the recorded video itself, but the video player you use. GPU Screen Recorder doesn't record by dropping frames. Some video players don't play videos with hardware acceleration by default,
especially if you record with HEVC/AV1 video codec. In such cases it's recommended to play the video with mpv instead with hardware acceleration enabled (for example: `mpv --vo=gpu --hwdec=auto video.mp4`).
Some corporate distros such as Fedora (or some Fedora based distros) also disable hardware accelerated video codecs on AMD/Intel GPUs, so you might need to install mpv (or another video player) with flathub instead, which bypasses this restriction.
## My cursor is flickering in the recorded video
This is likely an AMD gpu driver issue. It only happens to certain generations of AMD GPUs. On Wayland you can record with the desktop portal option (`-w portal`) to workaround this issue.
This issue hasn't been observed on X11 yet, but if you do observe it you can either record a window (`-w $(xdotool selectwindow)`) or change your xorg config to use software cursor instead (Add `Option "SWcursor" "true"` under modesetting "Device" section in your xorg config file).
## Password prompt shows up when I try to record my screen
If GPU Screen Recorder is installed with -Dcapabilities=true (which is the default option) then `gsr-kms-server` is installed with admin capabilities.
This removes a password prompt when recording a monitor with the `-w monitor` option (for example `-w screen`). However if the root user is disabled on the system then the password prompt will show up anyways.
If the root user is disabled on your system then you can instead record with `-w focused` or `-w window_id` on X11 or `-w portal` on Wayland.
## CPU/GPU usage is high
CPU/GPU usage can be misleading. CPUs/GPUs have multiple power/performance levels and the CPU/GPU usage reported on the system may be the CPU/GPU usage at the current performance level.
The performance level changes depending on the CPU/GPU load, so it may say that CPU/GPU usage is 80%, but the actual total CPU/GPU usage may be 5%.
The only way to properly test the performance of GPU Screen Recorder is to use it while recording a game and seeing the effect on the games framerate.
## The video is too dark when capturing full-range video or 10-bit video
This is an issue in some broken video players such as vlc. Play the video with a video player such as mpv (or a mpv frontend such as celluloid) or a browser instead.
## The video has glitches
This may be caused by buggy GPU drivers. Try recording with HEVC video codec instead (`-k hevc`).
## The quality is low when recording my desktop
Color gradients encode badly, especially with h264 video codec. You can increase the bitrate, for example by using `-bm cbr -q 30000` or by using hevc (`-k hevc`) and increasing the quality (`-q ultra`).
fsdsfdsfdsfdsf-5.13.8/TODO 0000664 0000000 0000000 00000076743 15202152077 0015316 0 ustar 00root root 0000000 0000000 Check for reparent.
Quickly changing workspace and back while recording under i3 breaks the screen recorder. i3 probably unmaps windows in other workspaces.
See https://trac.ffmpeg.org/wiki/EncodingForStreamingSites for optimizing streaming.
Look at VK_EXT_external_memory_dma_buf.
Use mov+faststart.
Allow recording all monitors/selected monitor without nvfbc by recording the compositor proxy window and only recording the part that matches the monitor(s).
Disable flipping on nvidia? this might fix some stuttering issues on some setups. See NvCtrlGetAttribute/NvCtrlSetAttributeAndGetStatus NV_CTRL_SYNC_TO_VBLANK https://github.com/NVIDIA/nvidia-settings/blob/d5f022976368cbceb2f20b838ddb0bf992f0cfb9/src/gtk%2B-2.x/ctkopengl.c.
Cleanup unused gl/egl functions, macro, etc.
Reverse engineer nvapi so we can disable "force p2 state" on linux too (nvapi profile api with the settings id 0x50166c5e).
Support yuv444p on amd/intel.
fix yuv444 for hevc.
Do not allow streaming if yuv444.
Re-enable yuv444 and allow yuv444 for software encoding. Good for remote desktop. But for remote desktop its more ideal to use yuv420 and when the image is not moving then send a png image instead, for clear image when the image is static.
Support 10 bit output because of better gradients. May even be smaller file size. Better supported on hevc (not supported at all on h264 on my gpu).
Add nvidia/(amd/intel) specific install script for ubuntu. User should run install_ubuntu.sh but it should run different install dep script depending on if /proc/driver/nvidia/version exists or not. But what about switchable graphics setup?
Test different combinations of switchable graphics. Intel hybrid mode (running intel but possible to run specific applications with prime-run), running pure intel. Detect switchable graphics.
https://web.archive.org/web/20210306020203/https://forums.developer.nvidia.com/t/performance-power-management-problem-on-shared-vgpu/161986
https://djdallmann.github.io/GamingPCSetup/CONTENT/RESEARCH/FINDINGS/registrykeys_displayadapter_class_4d36e968-e325-11ce-bfc1-08002be10318.txt
The video output will be black if if the system is suspended on nvidia and NVreg_PreserveVideoMemoryAllocations is not set to 1. This happens because I think that the driver invalidates textures/cuda buffers? To fix this we could try and recreate gsr capture when gsr_capture_capture fails (with timeout to retry again).
NVreg_RegistryDwords.
Window capture doesn't work properly in _control_ game after going from pause menu to in-game (and back to pause menu). There might be some x11 event we need to catch. Same for vr-video-player.
Monitor capture on steam deck is slightly below the game fps, but only when capturing on the steam deck screen. If capturing on another monitor, there is no issue.
Is this related to the dma buf rotation issue? different modifier being slow? does this always happen?
Intel is a bit weird with monitor capture and multiple monitors. If one of the monitors is rotated then all the kms will be rotated as well.
Is that only the case when the primary monitor is rotated? Also the primary monitor becomes position 0, 0 so crtc (x11 randr) position doesn't match the drm pos. Maybe get monitor position and size from drm instead.
How about if multiple monitors are rotated?
Support screen (all monitors) capture on amd/intel and nvidia wayland when no combined plane is found. Right now screen just takes the first output.
Use separate plane (which has offset and pitch) from combined plane instead of the combined plane.
Both twitch and youtube support variable bitrate but twitch recommends constant bitrate to reduce stream buffering/dropped frames when going from low motion to high motion: https://help.twitch.tv/s/article/broadcasting-guidelines?language=en_US. Info for youtube: https://support.google.com/youtube/answer/2853702?hl=en#zippy=%2Cvariable-bitrate-with-custom-stream-keys-in-live-control-room%2Ck-p-fps%2Cp-fps.
On nvidia some games apparently causes the game to appear to stutter (without dropping fps) when recording a monitor but not using
when using direct screen capture. Observed in Deus Ex and Apex Legends.
Capture is broken on amd on wlroots. It's disabled at the moment and instead uses kms capture. Find out why we get a black screen in wlroots.
Support vulkan video encoding. That might workaround forced p2 state nvidia driver "bug". Ffmpeg supports vulkan video encoding if it's encoding with --enable-vulkan
It may be possible to improve color conversion rgb->yuv shader for color edges by biasing colors to an edge, instead of letting color overlaying with bilinear filtering handle it.
When webcam is supported mention that nvidia_drm.modeset=1 must be set on nvidia x11 (it's required on wayland so it's not needed there. Or does eglstream work without it??). Check if this really is the case.
Support green screen removal, cropping, shader effects in general (circle mask, rounded corners, etc).
Preset is set to p5 for now but it should ideally be p6 or p7.
This change is needed because for certain sizes of a window (or monitor?) such as 971x780 causes encoding to freeze
when using h264 codec. This is a new(?) nvidia driver bug.
Maybe dont choose p6 or p7 again? it causes micro stutter for some users (?).
For low latency, see https://developer.download.nvidia.com/compute/nvenc/v4.0/NVENC_VideoEncoder_API_ProgGuide.pdf (section 7.1).
Remove follow focused option.
Exit if X11/Wayland killed (if drm plane dead or something?)
Test if p2 state can be worked around by using pure nvenc api and overwriting cuInit/cuCtxCreate* to not do anything. Cuda might be loaded when using nvenc but it might not be used, with certain record options? (such as h264 p5).
nvenc uses cuda when using b frames and rgb->yuv conversion, so convert the image ourselves instead.-
Drop frames if live streaming cant keep up with target fps, or dynamically change resolution/quality.
Instead of sending a big list of drm data back to kms client, send the monitor we want to record to kms server and the server should respond with only the matching monitor, and cursor.
Tonemap hdr to sdr when hdr is enabled and when hevc_hdr/av1_hdr is not used.
Rotate cursor texture properly (around top left origin).
Modify ffmpeg to accept opengl texture for nvenc encoding. Removes extra buffers and copies.
When vulkan encode is added, mention minimum nvidia driver required. (550.54.14?).
Investigate if there is a way to do gpu->gpu copy directly without touching system ram to enable video encoding on a different gpu. On nvidia this is possible with cudaMemcpyPeer, but how about from an intel/amd gpu to an nvidia gpu or the other way around or any combination of iGPU and dedicated GPU?
Maybe something with clEnqueueMigrateMemObjects? on AMD something with DirectGMA maybe?
Use lanczos resampling for better scaling quality. Lanczos resampling can also be used for YUV chroma for better color quality on small text.
Flac is disabled because the frame sizes are too large which causes big audio/video desync.
Enable b-frames.
Support vfr matching games exact fps all the time. On x11 use damage tracking, on wayland? maybe there is drm plane damage tracking. But that may not be accurate as the compositor may update it every monitor hz anyways. On wayland maybe only support it for desktop portal + pipewire capture.
Another method to track damage that works regardless of the display server would be to do a diff between frames with a shader.
A 1x1 texture could be created and then write to the texture with imageStore in glsl.
Multiple textures aren't needed for diff, the diff between the color conversion output can be done by using it as an input
as well, which would diff it against the previous frame.
Support selecting which gpu to use. This can be done in egl with eglQueryDevicesEXT and then eglGetPlatformDisplayEXT. This will automatically work on AMD and Intel as vaapi uses the same device. On nvidia we need to use eglQueryDeviceAttribEXT with EGL_CUDA_DEVICE_NV.
Maybe on glx (nvidia x11 nvfbc) we need to use __NV_PRIME_RENDER_OFFLOAD, __NV_PRIME_RENDER_OFFLOAD_PROVIDER, __GLX_VENDOR_LIBRARY_NAME, __VK_LAYER_NV_optimus, VK_ICD_FILENAMES instead. Just look at prime-run /usr/bin/prime-run.
Add option to send video to another computer.
New gpu screen recorder gui should have the option to cut the video directly, maybe running an ffmpeg command or implementing that ourselves. Only support gpu screen recorder video files.
Check if is software renderer by using eglQueryDisplayAttribEXT(egl_display, EGL_DEVICE_EXT..) eglQueryDeviceStringEXT(egl_device, EGL_EXTENSIONS) and check for "EGL_MESA_device_software".
Use MapTexture2DINTEL for software encoding on intel.
To test vulkan encode on amd set the environment variable RADV_PERFTEST=video_encode before running a program that uses vulkan encode (or queries for it, such as vulkaninfo).
Support hevc/av1 for software encoder and hdr support at the same time. Need support for yuv420p shader for that. Use libx265 for hevc and libsvtav1 for av1 (libsvtav1 is the fastest software av1 video encoder). Also support vp8/vp9 since we are not limited by hardware.
Cleanup pipewire code and add more error checks.
Make dbus code and pipewire setup non blocking.
Support portal (pipewire) hdr capture when pipewire adds support for it. Maybe use the result of SelectSources and then query the hdr metadata with drm.
HDR support on x11?
Move most kms data to kms client. We dont need root access for everything that is server from kms server right now, such as hdr metadata and drm plane properties. Only the drm plane fd really needs root access.
Show rotated window size in monitor list when using incorrect monitor name.
Desktop portal capture on kde plasma makes notifications not show up unless the notification is set as urgent. How to fix this? do we have to make our own notification system?
Explicit sync is done with the drm property IN_FENCE_FD (see https://drmdb.emersion.fr/properties/4008636142/IN_FENCE_FD). Check if this needs to be used on wayland (especially on nvidia) when capturing a monitor directly without desktop portal.
The update fps appear to be lower when recording a monitor instead of using portal on intel. Does this reflect in game framerate?
Fix glitches when using prime-run with desktop portal. It happens when moving a window around. It's probably a syncing issue.
Allow prime-run on x11 if monitor capture and the prime gpu is not nvidia.
Enable 2-pass encoding.
Restart replay/update video resolution if monitor resolution changes.
Use nvidia low latency options for better encoding times.
Test ideal async_depth value. Increasing async_depth also increased gpu memory usage a lot (from 100mb to 500mb when moving from async_depth 2 to 16) at 4k resolution. Setting it to 8 increases it by 200mb which might be ok.
Replace -encoder cpu with -k h264_software?
Change vp8/vp9 quality options, right now the file size is too large (for vp9 at least at very_high quality).
Support recording while in replay mode. This will be needed when enabling replay on system startup with systemd service and wanting to record a video besides that.
The harder and more bloat solution for this would be to make an IPC.
The simple solution would be to use SIGUSR2 for starting/stopping recording since SIGUSR2 is unused for replays. That would mean SIGUSR2 for pausing recording would be ignored.
It also means that the video will be created in the same directory as the replay (or have option to specify another location for that) but the filename would have to be generated automatically.
To rename the file you would have to use -sc to rename it with a script, or add an option to provide a template for the name.
Dynamically change bitrate/resolution to match desired fps. This would be helpful when streaming for example, where the encode output speed also depends on upload speed to the streaming service.
Implement opengl injection to capture texture. This fixes VRR without having to use NvFBC direct capture and also allows perfect frame timing.
Always use direct capture with NvFBC once the capture issue in mpv fullscreen has been resolved (maybe detect if direct capture fails in nvfbc and switch to non-direct recording. NvFBC says if direct capture fails).
Support ROI (AV_FRAME_DATA_REGIONS_OF_INTEREST).
Default to hevc if capture size is larger than 4096 in width or height.
Set low latency mode on vulkan encoding.
Support recording/replay/livestreaming at the same time by allowing commands to be run on an existing gpu screen recorder instance.
Test if `xrandr --output DP-1 --scale 1.5` captures correct size on nvidia.
Fix cursor position and scale when scaling x11 display.
Support application audio recording without pipewire combined sink.
Support transposing (rotating) with vaapi. This isn't supported on many devices with rgb buffer, but its supported with nv12 buffer (on intel at least).
Cleanup pipewire_audio.c (proper error handling and memory cleanup of proxies).
Hide application audio module-null-sink by using sink_properties=media.class="Audio/Sink/Internal".
Improve software encoding performance.
Add option to record audio from the recorded window only.
Add option to automatically select best video codec available. Add -k best, -k best_10bit and -k best_hdr.
Use wayland color management protocol when it's available: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/14.
Use different exit codes for different errors. Use one for invalid -w option, another one for invalid -a option for audio devices, etc. This is to make UI error reporting better.
Document these exit codes in an exit code .md file, or finally create a manpage where this can be documented.
Use opengl compute shader instead of graphics shader. This might allow for better performance when games are using 100% of graphics unit which might fix issue with 100% gpu usage causing gpu screen recorder to run slow when not using vaapi to convert rgb to nv12(?).
Always disable prime run/dri prime and list all monitors to record from from all cards.
Do this instead of adding an option to choose which gpu to use.
On X11 the primary gpu will always have the framebuffer for all monitors combined.
Use randr to list all monitors and always record and encode with the primary gpu.
On Wayland each gpu will have its own list of monitors with framebuffers.
Iterate through all cards with drm and list all monitors with associated framebuffers and when choosing a monitor to record
automatically use the associated gpu card.
Allow flv av1 if recent ffmpeg version and streaming to youtube (and twitch?) and for custom services.
Use explicit sync in pipewire video code: https://docs.pipewire.org/page_dma_buf.html.
Replay (and recording?) fails to save properly sometimes (especially for long videos). This is noticable with mp4 files since they get corrupt and become unplayable.
The entire video does seem to get saved (it's a large video file) and it seems to have the correct headers but it's not playable.
Make it possible to save a shorter replay clip remotely. Maybe implement ipc first, to then also allow starting recording/stream while a replay is running.
Add an option to pass http headers when streaming. Some streaming services require streaming keys to be passed in a http header instead of in the url as a parameter.
When adding vulkan video support add VK_VIDEO_ENCODE_TUNING_MODE_LOW_LATENCY_KHR.
Implement screenshot without invoking opengl (which is slow to start on some systems).
Automatically use desktop portal on wayland when hdr is enabled (or night light) by checking if kms hdr metadata exists, if hdr video codec is not used.
Or maybe do this in the ui?
Detect if cached portal session token is no longer valid (this can happen if the user switches to another wayland compositor).
Support reconnecting (and setting things up again) if the audio server is restarted (for both device recording and app recording).
Find out how nvidia-smi fixes nvenc not working on opensuse and do that ourselves instead of relying on nvidia-smi that is not always installed.
Pulseaudio code: add "running" variable to loops to allow stopping the running code when quitting.
Scale screenshot frame libswscale or implement lanczos shader for improved scaline for video as well.
Support high quality scaling with -s by using lanczos.
Support spanning multiple monitors with region capture. This would also allow the user to record multiple monitors at the same time, the same way screen-direct works on nvidia x11.
When webcam support is added also support v4l2loopback? this is done by using avdevice_register_all(); and -c v4l2 -o /dev/video0; but it needs to output raw data as well instead of h264 and possibly yuv420p. Maybe add a -k yuv420p option to do that or -k rgb.
This would be implemented by outputting the raw data directly into the output file, without using the video encoder.
Do proper exit, to call gsr_capture_destroy which will properly stop gsr-kms-server. Otherwise there can be zombie gsr-kms-server on error.
Cursor position might be slightly wrong on rotated monitor.
External texture doesn't work on nvidia x11, probably because of glx context (requires gles es). External texture is not used on nvidia x11 right now so it's not an issue.
Add option to save replay buffer on disk instead of ram.
nvfbc capture cursor with cursor.h instead and composite that on top. This allows us to also always get a cursor in direct capture mode. This could possible give better performance as well.
Maybe remove external shader code and make a simple external to internal texture converter (compute shader), to reduce texture sampling. Maybe this is faster?
Fix opengl context broken after suspend on nvidia by using this: https://registry.khronos.org/OpenGL/extensions/NV/NV_robustness_video_memory_purge.txt requires glx context creation flags and GetGraphicsResetStatusARB() == PURGED_CONTEXT_RESET_NV check to recreate all graphics.
HDR looks incorrect, brightest point gets cut off.
Make "screen" capture the preferred monitor.
When webcam support is added add the option to add it as a second video track, to make it easier to edit in video editors.
Fix constant framerate not working properly on amd/intel because capture framerate gets locked to the same framerate as
game framerate, which doesn't work well when you need to encode multiple duplicate frames (AMD/Intel is slow at encoding!).
It also appears to skip audio frames on nvidia wayland? why? that should be fine, but it causes video stuttering because of audio/video sync.
Add option to pass a fd (from socketpair) to use for rpc. In the rpc have a common header, with protocol version, data type and data in an enum.
Add the option to set audio track name, for example with -a "track-name:blabla|device:default_output|app:firefox"
Maybe disable qp/vbr for replay. In that case we can preallocate all replay data (for both ram and disk) and write to that directly when receiving packet (dont do that when also recording at the same time).
That could improve performance/disk write optimization and maybe even reduce ram usage because of less blocks/fragmentation.
When rpc is added add the option to add/remove audio devices/app audio and also overlays (from new capture sources). It should also be possible to save a replay of any duration (below duration set with -r).
Have an rpc info/status command that just returns the status. This is to check if gpu screen recorder is running.
Support hdr screenshot.
Recreate opengl context on loss. This can happen if there is a gpu driver bug, causing context to need to be recreated. This is a nice improvement to not break recording even with buggy driver.
Support saving video with surround sound. Surround sound audio capture does work, but it gets downmixed to stereo.
Add (render) plugin support. To simplify it (and possibly best performance) create one rgba texture (with the size of the output video) that is used across all plugins.
Create a framebuffer and set this texture and the target and set the framebuffer as active before calling the plugins.
Then the plugins can render simply by doing simple opengl draw functions.
Maybe send some metadata to the plugin, such as video (and framebuffer) size. Although this data can be retrieved from the active framebuffer.
Either support webcam support with raw yuyv, mapping the buffer directly to opengl. Or use mjpeg, mapping the buffer directly to vaapi jpeg decoder and then get then map the decoded buffer to opengl.
Some webcams dont support raw yuyv and many webcams support higher framerates for mjpeg.
Allow medium, high, very_high and ultra quality for -bm cbr. If that is used then it will automatically estimate the best bitrate for that quality based on resolution and fps.
Maybe do this in the ui instead (or both?), to show estimated file size.
Maybe remove shader compute code. It doesn't seem necessary anymore now that glSwapBuffer/glFinish isn't used. dbus server isn't needed anymore either, the code can be moved back to the gpu screen recorder process.
Add proper check if opengl functions are supported. dlsym for the symbol will return a no-op function if it's not supported, so it silently fails if used.
Colors are offset to bottom left by 1 pixel or so on steam deck in landscape mode.
When constant framerate is used (and for audio) multiple frames need to be encoded after resuming from suspend.
The clock jumps forward by around 2-3 seconds (on my machine). Is there a way to make sure the clock doesn't jump forward?
Colors are correct, but they look incorrect for thin elements, such as colored text. This can be improved by sampling neighbor pixels for color average.
Record first video/audio frame immediately.
Disable GL_DEPTH_TEST, GL_CULL_FACE.
kde plasma portal capture for screenshot doesn't work well because the portal ui is still visible when taking a screenshot because of its animation.
We can use dri2connect/dri3open to get the /dev/dri/card device. Note that this doesn't work on nvidia x11.
Add support for QVBR (QP with target bitrate). Maybe use VBR instead, since nvidia doesn't support QVBR and neither does vulkan.
KDE Plasma Wayland seems to use overlay planes now in non-fullscreen mode(limited to 1 overlay plane per gpu). Check if this is the case in the latest kde on arch linux.
If it is, then support it in kms capture.
Check if pipewire audio link-factory is available before attempting to use app audio or merging audio with pipewire.
Also do the same in supports_app_audio check in gpu-screen-recorder --info output.
Move region capture to an option in the color conversion instead of having the region code in kms capture code. This would make it cleaner and make it work with all capture methods.
-w region would just be an option for selecting the monitor and -region would work with all capture methods (-w).
Set top level window argument for portal capture. Same for gpu-screen-recorder-gtk global shortcuts.
Remove unix domain socket code from kms-client/server and use socketpair directly. To make this possible always execute the kms server permission setup in flatpak, before starting recording (in gpu-screen-recorder-gtk).
Add -k best/best_hdr/best_10bit option, to automatically choose the best codec (prefer av1, then hevc and then h264. For webm files choose vp9 and then vp8).
Check if region capture works properly with fractional scaling on wayland.
Add option to specify medium/high/very high/ultra for -bm cbr as well, which should automatically pick bitrate based on resolution and framerate.
This should also be reflected in gsr ui.
After adding rpc, making recording while in replay/streaming work differently. Start recording should take audio as an argument, to optionally specify different audio for recording than replay/stream.
After adding rpc, make it possible to add/remove audio and video. The same number of audio tracks should remain, but the audio devices/app should be possible to configure. You should be able to configure the capture sources however you want.
It takes a while to shutdown gpu screen recorder when using replay with a long replay time (when the replay buffer is for example 6gb). Maybe this has to do with cleaning up so much memory. Try if _exit(0) is faster, ignoring cleanup of anything (assuming the gpu driver is happy with that, nvidia doesn't like such things. GPU drivers are often buggy when it comes to automatic cleanup).
Support desktop portal hdr capture when this gets merged: https://invent.kde.org/plasma/kwin/-/merge_requests/8293 note that it only works with pipewire >= 1.5.81. If codec is set to non-hdr codec when use desktop portal without hdr (convert to sdr, remove the code that forces non-hdr equivalent of the codec). Update gsr-gtk and gsr-ui accordingly.
Add option to save screenshot as .qoi. Use that then in gsr-ui for the background for the window (capture the monitor that the ui is going to show on). Do that on cosmic and hyprland, which are unable to display things behind the fullscreen window.
Support pausing recording when recording while replay/streaming.
Maybe use VK_VALVE_video_encode_rgb_conversion with vulkan encoding for shader-less rgb to yuv conversion. That would allow screen capture with no gpu processing.
Cursor sometimes doesn't have color when capturing region scaled (on kde plasma wayland at least).
Remove drm_monitor_get_display_server_data and do that work in the drm monitor query.
In gpu screen recorder --info output codec max resolutions. This allows for better error messages in ui frontends and easier and better error handling.
Set minimum fps for live stream or piping or always.
Support youtube sso.
Remove -fm content (support it but remove it from documentation and output deprecation notice when its used) and use it when using -fm vbr (which is the default option).
But first -fm content needs to be support on wayland as well, by checking if there is a difference between frames (checksum the frame content).
-fm content also needs to have a minimum fps to prevent live stream from timing out when nothing changes on the screen.
There is a leak in nvfbc. When a monitor is turned off and then on there will be an x11 display leak inside nvfbc. This seems to be a bug in nvfbc.
Right now a mitigation has been added to not try to recreate the nvfbc session if the capture target (monitor) isn't connected (predict if nvfbc session create will fail).
One possible reason this happens is because bExternallyManagedContext is set to true.
This also means that nvfbc leaks connection when destroying nvfbc, even if the monitor is connected (this is not an issue right now because exit is done, but if gsr was turned into a library it would be).
Add option to set audio source volume, maybe by doing for example: -a "default_input|app:firefox;volume=50"
Optimize v4l2 mjpeg by decompressing to yuv (tjDecompressToYUV) instead of rgb. This would allow removing the yuv to rgb conversion on cpu step (and rgb to yuv on the gpu as well) as well as reducing the cpu->gpu image data bandwidth as yuv is compressed.
Do jpeg decoding on the gpu for v4l2 mjpeg capture (see https://github.com/negge/jpeg_gpu). Or use jpeg decoding from vaapi/nvdec.
Support other v4l2 pixel formats, such as h264 and rgb/bgr. High-end cameras use h264 for high resolution high framerate option (4k 60fps or higher).
AV1 medium quality on nvidia seems to be very high quality. The quality needs to be rescaled. Need to test on nvidia av1 gpu, but I dont have any such gpu.
Support multiple -w, to record different sources to different video tracks. For example gameplay to video track 1 and webcam to video track 2.
Update man page with info about v4l2 and new region capture format. Mention that -region is deprecated.
Make multiple -w portal work with -restore-portal-session.
Play with DRM_FORMAT_MOD_LINEAR or other linear formats to avoid cuda copy. If it's already in linear format then instead check the format of the target texture and use the same format.
Give early error when using invalid v4l2 path like with monitor. Use gsr_capture_v4l2_list_devices for query. Or maybe remove the early error for monitor to simplify the code.
Support camera capture with pipewire to support multiple applications recording camera at the same time. Might not be as efficient as V4L2.
Taking a screenshot of camera with mjpeg doesn't work correctly because it updates buffer asynchronously. v4l2 capture should only return 0 if the copy of the data to the texture has finished.
Make capture from multiple sources work on nvidia x11 when capturing monitor + window. It doesn't work right now because monitor requires glx (nvfbc) while window requires egl.
Support v4l2 mplane on devices where it's supported (where it's more efficient). My camera doesn't support mplane.
Implement v4l2 yuyv nvidia capture by capturing rg88 yuyv to rgb as is done now for screenshot, but also do that for video by creating an intermediate rgb texture for the camera. Then render that rgb texture to the video texture.
This is needed to properly scale the yuyv texture without messing it up (the texture indexing).
Set v4l2 camera fps to video output fps (if lower than the camera fps) and the same for resolution.
Support camera controls, such as white balance. Otherwise tell user to use cameractrl software.
Camera capture doesn't work perfectly. The image gets glitched, need to properly wait for image to be done.
Use one pipewire connection (pipewire video) instead of multiple ones when recording with portal multiple times (multiple sources).
Close pipewire links or maybe there are file descriptor leaks?
Make multiple capture sources work properly in regards to size. The size of the video should be the region size of each capture source.
Support hdr camera capture.
Return the max resolution of each codec in --info to display an error in the UI before capture starts. Right now its fine since the UI will report bad resolution after capture starts and fails but it doesn't say what the max resolution is.
Should -low-power option also use vaapi/vulkan low power, if available?
Should capture option x=bla;y=bla be scaled by -s (output resolution scale)? width and height is.
Add option to capture all monitors automatically.
Make -w optional, to only capture audio.
Use GL_RGBA16F or GL_RGBA32F for hdr, that allows color values to be outside the 0.0 to 1.0 range.
https://registry.khronos.org/EGL/extensions/EXT/EGL_EXT_surface_SMPTE2086_metadata.txt
Doesn't work: sibs run --args -w "/dev/video0;camera_width=800;camera_height=600;pixfmt=yuyv" -fm content -o video.mp4
Delay adding audio data until 1 frames time has passed.
Allow av1 in the flatpak. Do that by patching ffmpeg to support multiple nvenc codepaths by using header versions, the same way gsr does in the nvenc query.
Increase qp on av1 non-nvidia, decrease qp on h264 nvidia. For vulkan.
Check if the vulkan codec query works on nvidia x11.
Fix webcam capture on nvidia x11. It doesn't work when capturing a webcam at the same time as capturing the monitor (nvfbc) because nvfbc requires glx context active (in older nvfbc version, works with egl in newer version)
while v4l2 requires egl. All other capture methods require egl so they cant be used together with nvfbc.
Make -fm content the default, but first make it record at no lower than 2 fps if nothing updates. This is to make sure live streaming works and seeking in video player doesn't get messed up.
Fix camera capture on nvidia x11. It doesn't work with mjpeg either now because external shader compilation fails.
Revert the revert of improving pipewire capture, for better cursor capture. It caused glitches for some, especially in kde plasma when hdr is enabled. Try marking test and moving the cursor and see.
fsdsfdsfdsfdsf-5.13.8/external/ 0000775 0000000 0000000 00000000000 15202152077 0016427 5 ustar 00root root 0000000 0000000 fsdsfdsfdsfdsf-5.13.8/external/NvFBC.h 0000664 0000000 0000000 00000206246 15202152077 0017510 0 ustar 00root root 0000000 0000000 /*!
* \file
*
* This file contains the interface constants, structure definitions and
* function prototypes defining the NvFBC API for Linux.
*
* Copyright (c) 2013-2020, NVIDIA CORPORATION. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#ifndef _NVFBC_H_
#define _NVFBC_H_
#include
/*!
* \mainpage NVIDIA Framebuffer Capture (NvFBC) for Linux.
*
* NvFBC is a high performance, low latency API to capture the framebuffer of
* an X server screen.
*
* The output from NvFBC captures everything that would be visible if we were
* directly looking at the monitor. This includes window manager decoration,
* mouse cursor, overlay, etc.
*
* It is ideally suited to desktop or fullscreen application capture and
* remoting.
*/
/*!
* \defgroup FBC_REQ Requirements
*
* The following requirements are provided by the regular NVIDIA Display Driver
* package:
*
* - OpenGL core >= 4.2:
* Required. NvFBC relies on OpenGL to perform frame capture and
* post-processing.
*
* - Vulkan 1.1:
* Required.
*
* - libcuda.so.1 >= 5.5:
* Optional. Used for capture to video memory with CUDA interop.
*
* The following requirements must be installed separately depending on the
* Linux distribution being used:
*
* - XRandR extension >= 1.2:
* Optional. Used for RandR output tracking.
*
* - libX11-xcb.so.1 >= 1.2:
* Required. NvFBC uses a mix of Xlib and XCB. Xlib is needed to use GLX,
* XCB is needed to make NvFBC more resilient against X server terminations
* while a capture session is active.
*
* - libxcb.so.1 >= 1.3:
* Required. See above.
*
* - xorg-server >= 1.3:
* Optional. Required for push model to work properly.
*
* Note that all optional dependencies are dlopen()'d at runtime. Failure to
* load an optional library is not fatal.
*/
/*!
* \defgroup FBC_CHANGES ChangeLog
*
* NvFBC Linux API version 0.1
* - Initial BETA release.
*
* NvFBC Linux API version 0.2
* - Added 'bEnableMSE' field to NVFBC_H264_HW_ENC_CONFIG.
* - Added 'dwMSE' field to NVFBC_TOH264_GRAB_FRAME_PARAMS.
* - Added 'bEnableAQ' field to NVFBC_H264_HW_ENC_CONFIG.
* - Added 'NVFBC_H264_PRESET_LOSSLESS_HP' enum to NVFBC_H264_PRESET.
* - Added 'NVFBC_BUFFER_FORMAT_YUV444P' enum to NVFBC_BUFFER_FORMAT.
* - Added 'eInputBufferFormat' field to NVFBC_H264_HW_ENC_CONFIG.
* - Added '0' and '244' values for NVFBC_H264_HW_ENC_CONFIG::dwProfile.
*
* NvFBC Linux API version 0.3
* - Improved multi-threaded support by implementing an API locking mechanism.
* - Added 'nvFBCBindContext' API entry point.
* - Added 'nvFBCReleaseContext' API entry point.
*
* NvFBC Linux API version 1.0
* - Added codec agnostic interface for HW encoding.
* - Deprecated H.264 interface.
* - Added support for H.265/HEVC HW encoding.
*
* NvFBC Linux API version 1.1
* - Added 'nvFBCToHwGetCaps' API entry point.
* - Added 'dwDiffMapScalingFactor' field to NVFBC_TOSYS_SETUP_PARAMS.
*
* NvFBC Linux API version 1.2
* - Deprecated ToHwEnc interface.
* - Added ToGL interface that captures frames to an OpenGL texture in video
* memory.
* - Added 'bDisableAutoModesetRecovery' field to
* NVFBC_CREATE_CAPTURE_SESSION_PARAMS.
* - Added 'bExternallyManagedContext' field to NVFBC_CREATE_HANDLE_PARAMS.
*
* NvFBC Linux API version 1.3
* - Added NVFBC_BUFFER_FORMAT_RGBA
* - Added 'dwTimeoutMs' field to NVFBC_TOSYS_GRAB_FRAME_PARAMS,
* NVFBC_TOCUDA_GRAB_FRAME_PARAMS, and NVFBC_TOGL_GRAB_FRAME_PARAMS.
*
* NvFBC Linux API version 1.4
* - Clarified that NVFBC_BUFFER_FORMAT_{ARGB,RGB,RGBA} are byte-order formats.
* - Renamed NVFBC_BUFFER_FORMAT_YUV420P to NVFBC_BUFFER_FORMAT_NV12.
* - Added new requirements.
* - Made NvFBC more resilient against the X server terminating during an active
* capture session. See new comments for ::NVFBC_ERR_X.
* - Relaxed requirement that 'frameSize' must have a width being a multiple of
* 4 and a height being a multiple of 2.
* - Added 'bRoundFrameSize' field to NVFBC_CREATE_CAPTURE_SESSION_PARAMS.
* - Relaxed requirement that the scaling factor for differential maps must be
* a multiple of the size of the frame.
* - Added 'diffMapSize' field to NVFBC_TOSYS_SETUP_PARAMS and
* NVFBC_TOGL_SETUP_PARAMS.
*
* NvFBC Linux API version 1.5
* - Added NVFBC_BUFFER_FORMAT_BGRA
*
* NvFBC Linux API version 1.6
* - Added the 'NVFBC_TOSYS_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY',
* 'NVFBC_TOCUDA_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY', and
* 'NVFBC_TOGL_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY' capture flags.
* - Exposed debug and performance logs through the NVFBC_LOG_LEVEL environment
* variable. Setting it to "1" enables performance logs, setting it to "2"
* enables debugging logs, setting it to "3" enables both.
* - Logs are printed to stdout or to the file pointed by the NVFBC_LOG_FILE
* environment variable.
* - Added 'ulTimestampUs' to NVFBC_FRAME_GRAB_INFO.
* - Added 'dwSamplingRateMs' to NVFBC_CREATE_CAPTURE_SESSION_PARAMS.
* - Added 'bPushModel' to NVFBC_CREATE_CAPTURE_SESSION_PARAMS.
*
* NvFBC Linux API version 1.7
* - Retired the NVFBC_CAPTURE_TO_HW_ENCODER interface.
* This interface has been deprecated since NvFBC 1.2 and has received no
* updates or new features since. We recommend using the NVIDIA Video Codec
* SDK to encode NvFBC frames.
* See: https://developer.nvidia.com/nvidia-video-codec-sdk
* - Added a 'Capture Modes' section to those headers.
* - Added a 'Post Processing' section to those headers.
* - Added an 'Environment Variables' section to those headers.
* - Added 'bInModeset' to NVFBC_GET_STATUS_PARAMS.
* - Added 'bAllowDirectCapture' to NVFBC_CREATE_CAPTURE_SESSION_PARAMS.
* - Added 'bDirectCaptured' to NVFBC_FRAME_GRAB_INFO.
* - Added 'bRequiredPostProcessing' to NVFBC_FRAME_GRAB_INFO.
*/
/*!
* \defgroup FBC_MODES Capture Modes
*
* When creating a capture session, NvFBC instantiates a capture subsystem
* living in the NVIDIA X driver.
*
* This subsystem listens for damage events coming from applications then
* generates (composites) frames for NvFBC when new content is available.
*
* This capture server can operate on a timer where it periodically checks if
* there are any pending damage events, or it can generate frames as soon as it
* receives a new damage event.
* See NVFBC_CREATE_CAPTURE_SESSION_PARAMS::dwSamplingRateMs,
* and NVFBC_CREATE_CAPTURE_SESSION_PARAMS::bPushModel.
*
* NvFBC can also attach itself to a fullscreen unoccluded application and have
* it copy its frames directly into a buffer owned by NvFBC upon present. This
* mode bypasses the X server.
* See NVFBC_CREATE_CAPTURE_SESSION_PARAMS::bAllowDirectCapture.
*
* NvFBC is designed to capture frames with as few copies as possible. The
* NVIDIA X driver composites frames directly into the NvFBC buffers, and
* direct capture copies frames directly into these buffers as well.
*
* Depending on the configuration of a capture session, an extra copy (rendering
* pass) may be needed. See the 'Post Processing' section.
*/
/*!
* \defgroup FBC_PP Post Processing
*
* Depending on the configuration of a capture session, NvFBC might require to
* do post processing on frames.
*
* Post processing is required for the following reasons:
* - NvFBC needs to do a pixel format conversion.
* - Diffmaps are requested.
* - Capture to system memory is requested.
*
* NvFBC needs to do a conversion if the requested pixel format does not match
* the native format. The native format is NVFBC_BUFFER_FORMAT_BGRA.
*
* Note: post processing is *not* required for frame scaling and frame cropping.
*
* Skipping post processing can reduce capture latency. An application can know
* whether post processing was required by checking
* NVFBC_FRAME_GRAB_INFO::bRequiredPostProcessing.
*/
/*!
* \defgroup FBC_ENVVAR Environment Variables
*
* Below are the environment variables supported by NvFBC:
*
* - NVFBC_LOG_LEVEL
* Bitfield where the first bit enables debug logs and the second bit enables
* performance logs. Both can be enabled by setting this envvar to 3.
*
* - NVFBC_LOG_FILE
* Write all NvFBC logs to the given file.
*
* - NVFBC_FORCE_ALLOW_DIRECT_CAPTURE
* Used to override NVFBC_CREATE_CAPTURE_SESSION_PARAMS::bAllowDirectCapture.
*
* - NVFBC_FORCE_POST_PROCESSING
* Used to force the post processing step, even if it could be skipped.
* See the 'Post Processing' section.
*/
/*!
* \defgroup FBC_STRUCT Structure Definition
*
* @{
*/
#ifdef __cplusplus
extern "C" {
#endif
/*!
* Calling convention.
*/
#define NVFBCAPI
/*!
* NvFBC API major version.
*/
#define NVFBC_VERSION_MAJOR 1
/*!
* NvFBC API minor version.
*/
#define NVFBC_VERSION_MINOR 7
/*!
* NvFBC API version.
*/
#define NVFBC_VERSION (uint32_t) (NVFBC_VERSION_MINOR | (NVFBC_VERSION_MAJOR << 8))
/*!
* Creates a version number for structure parameters.
*/
#define NVFBC_STRUCT_VERSION(typeName, ver) \
(uint32_t) (sizeof(typeName) | ((ver) << 16) | (NVFBC_VERSION << 24))
/*!
* Defines error codes.
*
* \see NvFBCGetLastErrorStr
*/
typedef enum _NVFBCSTATUS
{
/*!
* This indicates that the API call returned with no errors.
*/
NVFBC_SUCCESS = 0,
/*!
* This indicates that the API version between the client and the library
* is not compatible.
*/
NVFBC_ERR_API_VERSION = 1,
/*!
* An internal error occurred.
*/
NVFBC_ERR_INTERNAL = 2,
/*!
* This indicates that one or more of the parameter passed to the API call
* is invalid.
*/
NVFBC_ERR_INVALID_PARAM = 3,
/*!
* This indicates that one or more of the pointers passed to the API call
* is invalid.
*/
NVFBC_ERR_INVALID_PTR = 4,
/*!
* This indicates that the handle passed to the API call to identify the
* client is invalid.
*/
NVFBC_ERR_INVALID_HANDLE = 5,
/*!
* This indicates that the maximum number of threaded clients of the same
* process has been reached. The limit is 10 threads per process.
* There is no limit on the number of process.
*/
NVFBC_ERR_MAX_CLIENTS = 6,
/*!
* This indicates that the requested feature is not currently supported
* by the library.
*/
NVFBC_ERR_UNSUPPORTED = 7,
/*!
* This indicates that the API call failed because it was unable to allocate
* enough memory to perform the requested operation.
*/
NVFBC_ERR_OUT_OF_MEMORY = 8,
/*!
* This indicates that the API call was not expected. This happens when
* API calls are performed in a wrong order, such as trying to capture
* a frame prior to creating a new capture session; or trying to set up
* a capture to video memory although a capture session to system memory
* was created.
*/
NVFBC_ERR_BAD_REQUEST = 9,
/*!
* This indicates an X error, most likely meaning that the X server has
* been terminated. When this error is returned, the only resort is to
* create another FBC handle using NvFBCCreateHandle().
*
* The previous handle should still be freed with NvFBCDestroyHandle(), but
* it might leak resources, in particular X, GLX, and GL resources since
* it is no longer possible to communicate with an X server to free them
* through the driver.
*
* The best course of action to eliminate this potential leak is to close
* the OpenGL driver, close the forked process running the capture, or
* restart the application.
*/
NVFBC_ERR_X = 10,
/*!
* This indicates a GLX error.
*/
NVFBC_ERR_GLX = 11,
/*!
* This indicates an OpenGL error.
*/
NVFBC_ERR_GL = 12,
/*!
* This indicates a CUDA error.
*/
NVFBC_ERR_CUDA = 13,
/*!
* This indicates a HW encoder error.
*/
NVFBC_ERR_ENCODER = 14,
/*!
* This indicates an NvFBC context error.
*/
NVFBC_ERR_CONTEXT = 15,
/*!
* This indicates that the application must recreate the capture session.
*
* This error can be returned if a modeset event occurred while capturing
* frames, and NVFBC_CREATE_HANDLE_PARAMS::bDisableAutoModesetRecovery
* was set to NVFBC_TRUE.
*/
NVFBC_ERR_MUST_RECREATE = 16,
/*!
* This indicates a Vulkan error.
*/
NVFBC_ERR_VULKAN = 17,
} NVFBCSTATUS;
/*!
* Defines boolean values.
*/
typedef enum _NVFBC_BOOL
{
/*!
* False value.
*/
NVFBC_FALSE = 0,
/*!
* True value.
*/
NVFBC_TRUE,
} NVFBC_BOOL;
/*!
* Maximum size in bytes of an error string.
*/
#define NVFBC_ERR_STR_LEN 512
/*!
* Capture type.
*/
typedef enum _NVFBC_CAPTURE_TYPE
{
/*!
* Capture frames to a buffer in system memory.
*/
NVFBC_CAPTURE_TO_SYS = 0,
/*!
* Capture frames to a CUDA device in video memory.
*
* Specifying this will dlopen() libcuda.so.1 and fail if not available.
*/
NVFBC_CAPTURE_SHARED_CUDA,
/*!
* Retired. Do not use.
*/
/* NVFBC_CAPTURE_TO_HW_ENCODER, */
/*!
* Capture frames to an OpenGL buffer in video memory.
*/
NVFBC_CAPTURE_TO_GL = 3,
} NVFBC_CAPTURE_TYPE;
/*!
* Tracking type.
*
* NvFBC can track a specific region of the framebuffer to capture.
*
* An X screen corresponds to the entire framebuffer.
*
* An RandR CRTC is a component of the GPU that reads pixels from a region of
* the X screen and sends them through a pipeline to an RandR output.
* A physical monitor can be connected to an RandR output. Tracking an RandR
* output captures the region of the X screen that the RandR CRTC is sending to
* the RandR output.
*/
typedef enum
{
/*!
* By default, NvFBC tries to track a connected primary output. If none is
* found, then it tries to track the first connected output. If none is
* found then it tracks the entire X screen.
*
* If the XRandR extension is not available, this option has the same effect
* as ::NVFBC_TRACKING_SCREEN.
*
* This default behavior might be subject to changes in the future.
*/
NVFBC_TRACKING_DEFAULT = 0,
/*!
* Track an RandR output specified by its ID in the appropriate field.
*
* The list of connected outputs can be queried via NvFBCGetStatus().
* This list can also be obtained using e.g., xrandr(1).
*
* If the XRandR extension is not available, setting this option returns an
* error.
*/
NVFBC_TRACKING_OUTPUT,
/*!
* Track the entire X screen.
*/
NVFBC_TRACKING_SCREEN,
} NVFBC_TRACKING_TYPE;
/*!
* Buffer format.
*/
typedef enum _NVFBC_BUFFER_FORMAT
{
/*!
* Data will be converted to ARGB8888 byte-order format. 32 bpp.
*/
NVFBC_BUFFER_FORMAT_ARGB = 0,
/*!
* Data will be converted to RGB888 byte-order format. 24 bpp.
*/
NVFBC_BUFFER_FORMAT_RGB,
/*!
* Data will be converted to NV12 format using HDTV weights
* according to ITU-R BT.709. 12 bpp.
*/
NVFBC_BUFFER_FORMAT_NV12,
/*!
* Data will be converted to YUV 444 planar format using HDTV weights
* according to ITU-R BT.709. 24 bpp
*/
NVFBC_BUFFER_FORMAT_YUV444P,
/*!
* Data will be converted to RGBA8888 byte-order format. 32 bpp.
*/
NVFBC_BUFFER_FORMAT_RGBA,
/*!
* Native format. No pixel conversion needed.
* BGRA8888 byte-order format. 32 bpp.
*/
NVFBC_BUFFER_FORMAT_BGRA,
} NVFBC_BUFFER_FORMAT;
#define NVFBC_BUFFER_FORMAT_YUV420P NVFBC_BUFFER_FORMAT_NV12
/*!
* Handle used to identify an NvFBC session.
*/
typedef uint64_t NVFBC_SESSION_HANDLE;
/*!
* Box used to describe an area of the tracked region to capture.
*
* The coordinates are relative to the tracked region.
*
* E.g., if the size of the X screen is 3520x1200 and the tracked RandR output
* scans a region of 1600x1200+1920+0, then setting a capture box of
* 800x600+100+50 effectively captures a region of 800x600+2020+50 relative to
* the X screen.
*/
typedef struct _NVFBC_BOX
{
/*!
* [in] X offset of the box.
*/
uint32_t x;
/*!
* [in] Y offset of the box.
*/
uint32_t y;
/*!
* [in] Width of the box.
*/
uint32_t w;
/*!
* [in] Height of the box.
*/
uint32_t h;
} NVFBC_BOX;
/*!
* Size used to describe the size of a frame.
*/
typedef struct _NVFBC_SIZE
{
/*!
* [in] Width.
*/
uint32_t w;
/*!
* [in] Height.
*/
uint32_t h;
} NVFBC_SIZE;
/*!
* Describes information about a captured frame.
*/
typedef struct _NVFBC_FRAME_GRAB_INFO
{
/*!
* [out] Width of the captured frame.
*/
uint32_t dwWidth;
/*!
* [out] Height of the captured frame.
*/
uint32_t dwHeight;
/*!
* [out] Size of the frame in bytes.
*/
uint32_t dwByteSize;
/*!
* [out] Incremental ID of the current frame.
*
* This can be used to identify a frame.
*/
uint32_t dwCurrentFrame;
/*!
* [out] Whether the captured frame is a new frame.
*
* When using non blocking calls it is possible to capture a frame
* that was already captured before if the display server did not
* render a new frame in the meantime. In that case, this flag
* will be set to NVFBC_FALSE.
*
* When using blocking calls each captured frame will have
* this flag set to NVFBC_TRUE since the blocking mechanism waits for
* the display server to render a new frame.
*
* Note that this flag does not guarantee that the content of
* the frame will be different compared to the previous captured frame.
*
* In particular, some compositing managers report the entire
* framebuffer as damaged when an application refreshes its content.
*
* Consider a single X screen spanned across physical displays A and B
* and an NvFBC application tracking display A. Depending on the
* compositing manager, it is possible that an application refreshing
* itself on display B will trigger a frame capture on display A.
*
* Workarounds include:
* - Using separate X screens
* - Disabling the composite extension
* - Using a compositing manager that properly reports what regions
* are damaged
* - Using NvFBC's diffmaps to find out if the frame changed
*/
NVFBC_BOOL bIsNewFrame;
/*!
* [out] Frame timestamp
*
* Time in micro seconds when the display server started rendering the
* frame.
*
* This does not account for when the frame was captured. If capturing an
* old frame (e.g., bIsNewFrame is NVFBC_FALSE) the reported timestamp
* will reflect the time when the old frame was rendered by the display
* server.
*/
uint64_t ulTimestampUs;
/*
* [out] Number of frames generated since the last capture.
*
* This can help applications tell whether they missed frames or there
* were no frames generated by the server since the last capture.
*/
uint32_t dwMissedFrames;
/*
* [out] Whether the captured frame required post processing.
*
* See the 'Post Processing' section.
*/
NVFBC_BOOL bRequiredPostProcessing;
/*
* [out] Whether this frame was obtained via direct capture.
*
* See NVFBC_CREATE_CAPTURE_SESSION_PARAMS::bAllowDirectCapture.
*/
NVFBC_BOOL bDirectCapture;
} NVFBC_FRAME_GRAB_INFO;
/*!
* Defines parameters for the CreateHandle() API call.
*/
typedef struct _NVFBC_CREATE_HANDLE_PARAMS
{
/*!
* [in] Must be set to NVFBC_CREATE_HANDLE_PARAMS_VER
*/
uint32_t dwVersion;
/*!
* [in] Application specific private information passed to the NvFBC
* session.
*/
const void *privateData;
/*!
* [in] Size of the application specific private information passed to the
* NvFBC session.
*/
uint32_t privateDataSize;
/*!
* [in] Whether NvFBC should not create and manage its own graphics context
*
* NvFBC internally uses OpenGL to perfom graphics operations on the
* captured frames. By default, NvFBC will create and manage (e.g., make
* current, detect new threads, etc.) its own OpenGL context.
*
* If set to NVFBC_TRUE, NvFBC will use the application's context. It will
* be the application's responsibility to make sure that a context is
* current on the thread calling into the NvFBC API.
*/
NVFBC_BOOL bExternallyManagedContext;
/*!
* [in] GLX context
*
* GLX context that NvFBC should use internally to create pixmaps and
* make them current when creating a new capture session.
*
* Note: NvFBC expects a context created against a GLX_RGBA_TYPE render
* type.
*/
void *glxCtx;
/*!
* [in] GLX framebuffer configuration
*
* Framebuffer configuration that was used to create the GLX context, and
* that will be used to create pixmaps internally.
*
* Note: NvFBC expects a configuration having at least the following
* attributes:
* GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT
* GLX_BIND_TO_TEXTURE_RGBA_EXT, 1
* GLX_BIND_TO_TEXTURE_TARGETS_EXT, GLX_TEXTURE_2D_BIT_EXT
*/
void *glxFBConfig;
} NVFBC_CREATE_HANDLE_PARAMS;
/*!
* NVFBC_CREATE_HANDLE_PARAMS structure version.
*/
#define NVFBC_CREATE_HANDLE_PARAMS_VER NVFBC_STRUCT_VERSION(NVFBC_CREATE_HANDLE_PARAMS, 2)
/*!
* Defines parameters for the ::NvFBCDestroyHandle() API call.
*/
typedef struct _NVFBC_DESTROY_HANDLE_PARAMS
{
/*!
* [in] Must be set to NVFBC_DESTROY_HANDLE_PARAMS_VER
*/
uint32_t dwVersion;
} NVFBC_DESTROY_HANDLE_PARAMS;
/*!
* NVFBC_DESTROY_HANDLE_PARAMS structure version.
*/
#define NVFBC_DESTROY_HANDLE_PARAMS_VER NVFBC_STRUCT_VERSION(NVFBC_DESTROY_HANDLE_PARAMS, 1)
/*!
* Maximum number of connected RandR outputs to an X screen.
*/
#define NVFBC_OUTPUT_MAX 5
/*!
* Maximum size in bytes of an RandR output name.
*/
#define NVFBC_OUTPUT_NAME_LEN 128
/*!
* Describes an RandR output.
*
* Filling this structure relies on the XRandR extension. This feature cannot
* be used if the extension is missing or its version is below the requirements.
*
* \see Requirements
*/
typedef struct _NVFBC_OUTPUT
{
/*!
* Identifier of the RandR output.
*/
uint32_t dwId;
/*!
* Name of the RandR output, as reported by tools such as xrandr(1).
*
* Example: "DVI-I-0"
*/
char name[NVFBC_OUTPUT_NAME_LEN];
/*!
* Region of the X screen tracked by the RandR CRTC driving this RandR
* output.
*/
NVFBC_BOX trackedBox;
} NVFBC_RANDR_OUTPUT_INFO;
/*!
* Defines parameters for the ::NvFBCGetStatus() API call.
*/
typedef struct _NVFBC_GET_STATUS_PARAMS
{
/*!
* [in] Must be set to NVFBC_GET_STATUS_PARAMS_VER
*/
uint32_t dwVersion;
/*!
* [out] Whether or not framebuffer capture is supported by the graphics
* driver.
*/
NVFBC_BOOL bIsCapturePossible;
/*!
* [out] Whether or not there is already a capture session on this system.
*/
NVFBC_BOOL bCurrentlyCapturing;
/*!
* [out] Whether or not it is possible to create a capture session on this
* system.
*/
NVFBC_BOOL bCanCreateNow;
/*!
* [out] Size of the X screen (framebuffer).
*/
NVFBC_SIZE screenSize;
/*!
* [out] Whether the XRandR extension is available.
*
* If this extension is not available then it is not possible to have
* information about RandR outputs.
*/
NVFBC_BOOL bXRandRAvailable;
/*!
* [out] Array of outputs connected to the X screen.
*
* An application can track a specific output by specifying its ID when
* creating a capture session.
*
* Only if XRandR is available.
*/
NVFBC_RANDR_OUTPUT_INFO outputs[NVFBC_OUTPUT_MAX];
/*!
* [out] Number of outputs connected to the X screen.
*
* This must be used to parse the array of connected outputs.
*
* Only if XRandR is available.
*/
uint32_t dwOutputNum;
/*!
* [out] Version of the NvFBC library running on this system.
*/
uint32_t dwNvFBCVersion;
/*!
* [out] Whether the X server is currently in modeset.
*
* When the X server is in modeset, it must give up all its video
* memory allocations. It is not possible to create a capture
* session until the modeset is over.
*
* Note that VT-switches are considered modesets.
*/
NVFBC_BOOL bInModeset;
} NVFBC_GET_STATUS_PARAMS;
/*!
* NVFBC_GET_STATUS_PARAMS structure version.
*/
#define NVFBC_GET_STATUS_PARAMS_VER NVFBC_STRUCT_VERSION(NVFBC_GET_STATUS_PARAMS, 2)
/*!
* Defines parameters for the ::NvFBCCreateCaptureSession() API call.
*/
typedef struct _NVFBC_CREATE_CAPTURE_SESSION_PARAMS
{
/*!
* [in] Must be set to NVFBC_CREATE_CAPTURE_SESSION_PARAMS_VER
*/
uint32_t dwVersion;
/*!
* [in] Desired capture type.
*
* Note that when specyfing ::NVFBC_CAPTURE_SHARED_CUDA NvFBC will try to
* dlopen() the corresponding libraries. This means that NvFBC can run on
* a system without the CUDA library since it does not link against them.
*/
NVFBC_CAPTURE_TYPE eCaptureType;
/*!
* [in] What region of the framebuffer should be tracked.
*/
NVFBC_TRACKING_TYPE eTrackingType;
/*!
* [in] ID of the output to track if eTrackingType is set to
* ::NVFBC_TRACKING_OUTPUT.
*/
uint32_t dwOutputId;
/*!
* [in] Crop the tracked region.
*
* The coordinates are relative to the tracked region.
*
* It can be set to 0 to capture the entire tracked region.
*/
NVFBC_BOX captureBox;
/*!
* [in] Desired size of the captured frame.
*
* This parameter allow to scale the captured frame.
*
* It can be set to 0 to disable frame resizing.
*/
NVFBC_SIZE frameSize;
/*!
* [in] Whether the mouse cursor should be composited to the frame.
*
* Disabling the cursor will not generate new frames when only the cursor
* is moved.
*/
NVFBC_BOOL bWithCursor;
/*!
* [in] Whether NvFBC should not attempt to recover from modesets.
*
* NvFBC is able to detect when a modeset event occured and can automatically
* re-create a capture session with the same settings as before, then resume
* its frame capture session transparently.
*
* This option allows to disable this behavior. NVFBC_ERR_MUST_RECREATE
* will be returned in that case.
*
* It can be useful in the cases when an application needs to do some work
* between setting up a capture and grabbing the first frame.
*
* For example: an application using the ToGL interface needs to register
* resources with EncodeAPI prior to encoding frames.
*
* Note that during modeset recovery, NvFBC will try to re-create the
* capture session every second until it succeeds.
*/
NVFBC_BOOL bDisableAutoModesetRecovery;
/*!
* [in] Whether NvFBC should round the requested frameSize.
*
* When disabled, NvFBC will not attempt to round the requested resolution.
*
* However, some pixel formats have resolution requirements. E.g., YUV/NV
* formats must have a width being a multiple of 4, and a height being a
* multiple of 2. RGB formats don't have such requirements.
*
* If the resolution doesn't meet the requirements of the format, then NvFBC
* will fail at setup time.
*
* When enabled, NvFBC will round the requested width to the next multiple
* of 4 and the requested height to the next multiple of 2.
*
* In this case, requesting any resolution will always work with every
* format. However, an NvFBC client must be prepared to handle the case
* where the requested resolution is different than the captured resolution.
*
* NVFBC_FRAME_GRAB_INFO::dwWidth and NVFBC_FRAME_GRAB_INFO::dwHeight should
* always be used for getting information about captured frames.
*/
NVFBC_BOOL bRoundFrameSize;
/*!
* [in] Rate in ms at which the display server generates new frames
*
* This controls the frequency at which the display server will generate
* new frames if new content is available. This effectively controls the
* capture rate when using blocking calls.
*
* Note that lower values will increase the CPU and GPU loads.
*
* The default value is 16ms (~ 60 Hz).
*/
uint32_t dwSamplingRateMs;
/*!
* [in] Enable push model for frame capture
*
* When set to NVFBC_TRUE, the display server will generate frames whenever
* it receives a damage event from applications.
*
* Setting this to NVFBC_TRUE will ignore ::dwSamplingRateMs.
*
* Using push model with the NVFBC_*_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY
* capture flag should guarantee the shortest amount of time between an
* application rendering a frame and an NvFBC client capturing it, provided
* that the NvFBC client is able to process the frames quickly enough.
*
* Note that applications running at high frame rates will increase CPU and
* GPU loads.
*/
NVFBC_BOOL bPushModel;
/*!
* [in] Allow direct capture
*
* Direct capture allows NvFBC to attach itself to a fullscreen graphics
* application. Whenever that application presents a frame, it makes a copy
* of it directly into a buffer owned by NvFBC thus bypassing the X server.
*
* When direct capture is *not* enabled, the NVIDIA X driver generates a
* frame for NvFBC when it receives a damage event from an application if push
* model is enabled, or periodically checks if there are any pending damage
* events otherwise (see NVFBC_CREATE_CAPTURE_SESSION_PARAMS::dwSamplingRateMs).
*
* Direct capture is possible under the following conditions:
* - Direct capture is allowed
* - Push model is enabled (see NVFBC_CREATE_CAPTURE_SESSION_PARAMS::bPushModel)
* - The mouse cursor is not composited (see NVFBC_CREATE_CAPTURE_SESSION_PARAMS::bWithCursor)
* - No viewport transformation is required. This happens when the remote
* desktop is e.g. rotated.
*
* When direct capture is possible, NvFBC will automatically attach itself
* to a fullscreen unoccluded application, if such exists.
*
* Notes:
* - This includes compositing desktops such as GNOME (e.g., gnome-shell
* is the fullscreen unoccluded application).
* - There can be only one fullscreen unoccluded application at a time.
* - The NVIDIA X driver monitors which application qualifies or no
* longer qualifies.
*
* For example, if a fullscreen application is launched in GNOME, NvFBC will
* detach from gnome-shell and attach to that application.
*
* Attaching and detaching happens automatically from the perspective of an
* NvFBC client. When detaching from an application, the X driver will
* transparently resume generating frames for NvFBC.
*
* An application can know whether a given frame was obtained through
* direct capture by checking NVFBC_FRAME_GRAB_INFO::bDirectCapture.
*/
NVFBC_BOOL bAllowDirectCapture;
} NVFBC_CREATE_CAPTURE_SESSION_PARAMS;
/*!
* NVFBC_CREATE_CAPTURE_SESSION_PARAMS structure version.
*/
#define NVFBC_CREATE_CAPTURE_SESSION_PARAMS_VER NVFBC_STRUCT_VERSION(NVFBC_CREATE_CAPTURE_SESSION_PARAMS, 6)
/*!
* Defines parameters for the ::NvFBCDestroyCaptureSession() API call.
*/
typedef struct _NVFBC_DESTROY_CAPTURE_SESSION_PARAMS
{
/*!
* [in] Must be set to NVFBC_DESTROY_CAPTURE_SESSION_PARAMS_VER
*/
uint32_t dwVersion;
} NVFBC_DESTROY_CAPTURE_SESSION_PARAMS;
/*!
* NVFBC_DESTROY_CAPTURE_SESSION_PARAMS structure version.
*/
#define NVFBC_DESTROY_CAPTURE_SESSION_PARAMS_VER NVFBC_STRUCT_VERSION(NVFBC_DESTROY_CAPTURE_SESSION_PARAMS, 1)
/*!
* Defines parameters for the ::NvFBCBindContext() API call.
*/
typedef struct _NVFBC_BIND_CONTEXT_PARAMS
{
/*!
* [in] Must be set to NVFBC_BIND_CONTEXT_PARAMS_VER
*/
uint32_t dwVersion;
} NVFBC_BIND_CONTEXT_PARAMS;
/*!
* NVFBC_BIND_CONTEXT_PARAMS structure version.
*/
#define NVFBC_BIND_CONTEXT_PARAMS_VER NVFBC_STRUCT_VERSION(NVFBC_BIND_CONTEXT_PARAMS, 1)
/*!
* Defines parameters for the ::NvFBCReleaseContext() API call.
*/
typedef struct _NVFBC_RELEASE_CONTEXT_PARAMS
{
/*!
* [in] Must be set to NVFBC_RELEASE_CONTEXT_PARAMS_VER
*/
uint32_t dwVersion;
} NVFBC_RELEASE_CONTEXT_PARAMS;
/*!
* NVFBC_RELEASE_CONTEXT_PARAMS structure version.
*/
#define NVFBC_RELEASE_CONTEXT_PARAMS_VER NVFBC_STRUCT_VERSION(NVFBC_RELEASE_CONTEXT_PARAMS, 1)
/*!
* Defines flags that can be used when capturing to system memory.
*/
typedef enum
{
/*!
* Default, capturing waits for a new frame or mouse move.
*
* The default behavior of blocking grabs is to wait for a new frame until
* after the call was made. But it's possible that there is a frame already
* ready that the client hasn't seen.
* \see NVFBC_TOSYS_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY
*/
NVFBC_TOSYS_GRAB_FLAGS_NOFLAGS = 0,
/*!
* Capturing does not wait for a new frame nor a mouse move.
*
* It is therefore possible to capture the same frame multiple times.
* When this occurs, the dwCurrentFrame parameter of the
* NVFBC_FRAME_GRAB_INFO structure is not incremented.
*/
NVFBC_TOSYS_GRAB_FLAGS_NOWAIT = (1 << 0),
/*!
* Forces the destination buffer to be refreshed even if the frame has not
* changed since previous capture.
*
* By default, if the captured frame is identical to the previous one, NvFBC
* will omit one copy and not update the destination buffer.
*
* Setting that flag will prevent this behavior. This can be useful e.g.,
* if the application has modified the buffer in the meantime.
*/
NVFBC_TOSYS_GRAB_FLAGS_FORCE_REFRESH = (1 << 1),
/*!
* Similar to NVFBC_TOSYS_GRAB_FLAGS_NOFLAGS, except that the capture will
* not wait if there is already a frame available that the client has
* never seen yet.
*/
NVFBC_TOSYS_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY = (1 << 2),
} NVFBC_TOSYS_GRAB_FLAGS;
/*!
* Defines parameters for the ::NvFBCToSysSetUp() API call.
*/
typedef struct _NVFBC_TOSYS_SETUP_PARAMS
{
/*!
* [in] Must be set to NVFBC_TOSYS_SETUP_PARAMS_VER
*/
uint32_t dwVersion;
/*!
* [in] Desired buffer format.
*/
NVFBC_BUFFER_FORMAT eBufferFormat;
/*!
* [out] Pointer to a pointer to a buffer in system memory.
*
* This buffer contains the pixel value of the requested format. Refer to
* the description of the buffer formats to understand the memory layout.
*
* The application does not need to allocate memory for this buffer. It
* should not free this buffer either. This buffer is automatically
* re-allocated when needed (e.g., when the resolution changes).
*
* This buffer is allocated by the NvFBC library to the proper size. This
* size is returned in the dwByteSize field of the
* ::NVFBC_FRAME_GRAB_INFO structure.
*/
void **ppBuffer;
/*!
* [in] Whether differential maps should be generated.
*/
NVFBC_BOOL bWithDiffMap;
/*!
* [out] Pointer to a pointer to a buffer in system memory.
*
* This buffer contains the differential map of two frames. It must be read
* as an array of unsigned char. Each unsigned char is either 0 or
* non-zero. 0 means that the pixel value at the given location has not
* changed since the previous captured frame. Non-zero means that the pixel
* value has changed.
*
* The application does not need to allocate memory for this buffer. It
* should not free this buffer either. This buffer is automatically
* re-allocated when needed (e.g., when the resolution changes).
*
* This buffer is allocated by the NvFBC library to the proper size. The
* size of the differential map is returned in ::diffMapSize.
*
* This option is not compatible with the ::NVFBC_BUFFER_FORMAT_YUV420P and
* ::NVFBC_BUFFER_FORMAT_YUV444P buffer formats.
*/
void **ppDiffMap;
/*!
* [in] Scaling factor of the differential maps.
*
* For example, a scaling factor of 16 means that one pixel of the diffmap
* will represent 16x16 pixels of the original frames.
*
* If any of these 16x16 pixels is different between the current and the
* previous frame, then the corresponding pixel in the diffmap will be set
* to non-zero.
*
* The default scaling factor is 1. A dwDiffMapScalingFactor of 0 will be
* set to 1.
*/
uint32_t dwDiffMapScalingFactor;
/*!
* [out] Size of the differential map.
*
* Only set if bWithDiffMap is set to NVFBC_TRUE.
*/
NVFBC_SIZE diffMapSize;
} NVFBC_TOSYS_SETUP_PARAMS;
/*!
* NVFBC_TOSYS_SETUP_PARAMS structure version.
*/
#define NVFBC_TOSYS_SETUP_PARAMS_VER NVFBC_STRUCT_VERSION(NVFBC_TOSYS_SETUP_PARAMS, 3)
/*!
* Defines parameters for the ::NvFBCToSysGrabFrame() API call.
*/
typedef struct _NVFBC_TOSYS_GRAB_FRAME_PARAMS
{
/*!
* [in] Must be set to NVFBC_TOSYS_GRAB_FRAME_PARAMS_VER
*/
uint32_t dwVersion;
/*!
* [in] Flags defining the behavior of this frame capture.
*/
uint32_t dwFlags;
/*!
* [out] Information about the captured frame.
*
* Can be NULL.
*/
NVFBC_FRAME_GRAB_INFO *pFrameGrabInfo;
/*!
* [in] Wait timeout in milliseconds.
*
* When capturing frames with the NVFBC_TOSYS_GRAB_FLAGS_NOFLAGS or
* NVFBC_TOSYS_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY flags,
* NvFBC will wait for a new frame or mouse move until the below timer
* expires.
*
* When timing out, the last captured frame will be returned. Note that as
* long as the NVFBC_TOSYS_GRAB_FLAGS_FORCE_REFRESH flag is not set,
* returning an old frame will incur no performance penalty.
*
* NvFBC clients can use the return value of the grab frame operation to
* find out whether a new frame was captured, or the timer expired.
*
* Note that the behavior of blocking calls is to wait for a new frame
* *after* the call has been made. When using timeouts, it is possible
* that NvFBC will return a new frame (e.g., it has never been captured
* before) even though no new frame was generated after the grab call.
*
* For the precise definition of what constitutes a new frame, see
* ::bIsNewFrame.
*
* Set to 0 to disable timeouts.
*/
uint32_t dwTimeoutMs;
} NVFBC_TOSYS_GRAB_FRAME_PARAMS;
/*!
* NVFBC_TOSYS_GRAB_FRAME_PARAMS structure version.
*/
#define NVFBC_TOSYS_GRAB_FRAME_PARAMS_VER NVFBC_STRUCT_VERSION(NVFBC_TOSYS_GRAB_FRAME_PARAMS, 2)
/*!
* Defines flags that can be used when capturing to a CUDA buffer in video memory.
*/
typedef enum
{
/*!
* Default, capturing waits for a new frame or mouse move.
*
* The default behavior of blocking grabs is to wait for a new frame until
* after the call was made. But it's possible that there is a frame already
* ready that the client hasn't seen.
* \see NVFBC_TOCUDA_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY
*/
NVFBC_TOCUDA_GRAB_FLAGS_NOFLAGS = 0,
/*!
* Capturing does not wait for a new frame nor a mouse move.
*
* It is therefore possible to capture the same frame multiple times.
* When this occurs, the dwCurrentFrame parameter of the
* NVFBC_FRAME_GRAB_INFO structure is not incremented.
*/
NVFBC_TOCUDA_GRAB_FLAGS_NOWAIT = (1 << 0),
/*!
* [in] Forces the destination buffer to be refreshed even if the frame
* has not changed since previous capture.
*
* By default, if the captured frame is identical to the previous one, NvFBC
* will omit one copy and not update the destination buffer.
*
* Setting that flag will prevent this behavior. This can be useful e.g.,
* if the application has modified the buffer in the meantime.
*/
NVFBC_TOCUDA_GRAB_FLAGS_FORCE_REFRESH = (1 << 1),
/*!
* Similar to NVFBC_TOCUDA_GRAB_FLAGS_NOFLAGS, except that the capture will
* not wait if there is already a frame available that the client has
* never seen yet.
*/
NVFBC_TOCUDA_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY = (1 << 2),
} NVFBC_TOCUDA_FLAGS;
/*!
* Defines parameters for the ::NvFBCToCudaSetUp() API call.
*/
typedef struct _NVFBC_TOCUDA_SETUP_PARAMS
{
/*!
* [in] Must be set to NVFBC_TOCUDA_SETUP_PARAMS_VER
*/
uint32_t dwVersion;
/*!
* [in] Desired buffer format.
*/
NVFBC_BUFFER_FORMAT eBufferFormat;
} NVFBC_TOCUDA_SETUP_PARAMS;
/*!
* NVFBC_TOCUDA_SETUP_PARAMS structure version.
*/
#define NVFBC_TOCUDA_SETUP_PARAMS_VER NVFBC_STRUCT_VERSION(NVFBC_TOCUDA_SETUP_PARAMS, 1)
/*!
* Defines parameters for the ::NvFBCToCudaGrabFrame() API call.
*/
typedef struct _NVFBC_TOCUDA_GRAB_FRAME_PARAMS
{
/*!
* [in] Must be set to NVFBC_TOCUDA_GRAB_FRAME_PARAMS_VER.
*/
uint32_t dwVersion;
/*!
* [in] Flags defining the behavior of this frame capture.
*/
uint32_t dwFlags;
/*!
* [out] Pointer to a ::CUdeviceptr
*
* The application does not need to allocate memory for this CUDA device.
*
* The application does need to create its own CUDA context to use this
* CUDA device.
*
* This ::CUdeviceptr will be mapped to a segment in video memory containing
* the frame. It is not possible to process a CUDA device while capturing
* a new frame. If the application wants to do so, it must copy the CUDA
* device using ::cuMemcpyDtoD or ::cuMemcpyDtoH beforehand.
*/
void *pCUDADeviceBuffer;
/*!
* [out] Information about the captured frame.
*
* Can be NULL.
*/
NVFBC_FRAME_GRAB_INFO *pFrameGrabInfo;
/*!
* [in] Wait timeout in milliseconds.
*
* When capturing frames with the NVFBC_TOCUDA_GRAB_FLAGS_NOFLAGS or
* NVFBC_TOCUDA_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY flags,
* NvFBC will wait for a new frame or mouse move until the below timer
* expires.
*
* When timing out, the last captured frame will be returned. Note that as
* long as the NVFBC_TOCUDA_GRAB_FLAGS_FORCE_REFRESH flag is not set,
* returning an old frame will incur no performance penalty.
*
* NvFBC clients can use the return value of the grab frame operation to
* find out whether a new frame was captured, or the timer expired.
*
* Note that the behavior of blocking calls is to wait for a new frame
* *after* the call has been made. When using timeouts, it is possible
* that NvFBC will return a new frame (e.g., it has never been captured
* before) even though no new frame was generated after the grab call.
*
* For the precise definition of what constitutes a new frame, see
* ::bIsNewFrame.
*
* Set to 0 to disable timeouts.
*/
uint32_t dwTimeoutMs;
} NVFBC_TOCUDA_GRAB_FRAME_PARAMS;
/*!
* NVFBC_TOCUDA_GRAB_FRAME_PARAMS structure version.
*/
#define NVFBC_TOCUDA_GRAB_FRAME_PARAMS_VER NVFBC_STRUCT_VERSION(NVFBC_TOCUDA_GRAB_FRAME_PARAMS, 2)
/*!
* Defines flags that can be used when capturing to an OpenGL buffer in video memory.
*/
typedef enum
{
/*!
* Default, capturing waits for a new frame or mouse move.
*
* The default behavior of blocking grabs is to wait for a new frame until
* after the call was made. But it's possible that there is a frame already
* ready that the client hasn't seen.
* \see NVFBC_TOGL_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY
*/
NVFBC_TOGL_GRAB_FLAGS_NOFLAGS = 0,
/*!
* Capturing does not wait for a new frame nor a mouse move.
*
* It is therefore possible to capture the same frame multiple times.
* When this occurs, the dwCurrentFrame parameter of the
* NVFBC_FRAME_GRAB_INFO structure is not incremented.
*/
NVFBC_TOGL_GRAB_FLAGS_NOWAIT = (1 << 0),
/*!
* [in] Forces the destination buffer to be refreshed even if the frame
* has not changed since previous capture.
*
* By default, if the captured frame is identical to the previous one, NvFBC
* will omit one copy and not update the destination buffer.
*
* Setting that flag will prevent this behavior. This can be useful e.g.,
* if the application has modified the buffer in the meantime.
*/
NVFBC_TOGL_GRAB_FLAGS_FORCE_REFRESH = (1 << 1),
/*!
* Similar to NVFBC_TOGL_GRAB_FLAGS_NOFLAGS, except that the capture will
* not wait if there is already a frame available that the client has
* never seen yet.
*/
NVFBC_TOGL_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY = (1 << 2),
} NVFBC_TOGL_FLAGS;
/*!
* Maximum number of GL textures that can be used to store frames.
*/
#define NVFBC_TOGL_TEXTURES_MAX 2
/*!
* Defines parameters for the ::NvFBCToGLSetUp() API call.
*/
typedef struct _NVFBC_TOGL_SETUP_PARAMS
{
/*!
* [in] Must be set to NVFBC_TOGL_SETUP_PARAMS_VER
*/
uint32_t dwVersion;
/*!
* [in] Desired buffer format.
*/
NVFBC_BUFFER_FORMAT eBufferFormat;
/*!
* [in] Whether differential maps should be generated.
*/
NVFBC_BOOL bWithDiffMap;
/*!
* [out] Pointer to a pointer to a buffer in system memory.
*
* \see NVFBC_TOSYS_SETUP_PARAMS::ppDiffMap
*/
void **ppDiffMap;
/*!
* [in] Scaling factor of the differential maps.
*
* \see NVFBC_TOSYS_SETUP_PARAMS::dwDiffMapScalingFactor
*/
uint32_t dwDiffMapScalingFactor;
/*!
* [out] List of GL textures that will store the captured frames.
*
* This array is 0 terminated. The number of textures varies depending on
* the capture settings (such as whether diffmaps are enabled).
*
* An application wishing to interop with, for example, EncodeAPI will need
* to register these textures prior to start encoding frames.
*
* After each frame capture, the texture holding the current frame will be
* returned in NVFBC_TOGL_GRAB_FRAME_PARAMS::dwTexture.
*/
uint32_t dwTextures[NVFBC_TOGL_TEXTURES_MAX];
/*!
* [out] GL target to which the texture should be bound.
*/
uint32_t dwTexTarget;
/*!
* [out] GL format of the textures.
*/
uint32_t dwTexFormat;
/*!
* [out] GL type of the textures.
*/
uint32_t dwTexType;
/*!
* [out] Size of the differential map.
*
* Only set if bWithDiffMap is set to NVFBC_TRUE.
*/
NVFBC_SIZE diffMapSize;
} NVFBC_TOGL_SETUP_PARAMS;
/*!
* NVFBC_TOGL_SETUP_PARAMS structure version.
*/
#define NVFBC_TOGL_SETUP_PARAMS_VER NVFBC_STRUCT_VERSION(NVFBC_TOGL_SETUP_PARAMS, 2)
/*!
* Defines parameters for the ::NvFBCToGLGrabFrame() API call.
*/
typedef struct _NVFBC_TOGL_GRAB_FRAME_PARAMS
{
/*!
* [in] Must be set to NVFBC_TOGL_GRAB_FRAME_PARAMS_VER.
*/
uint32_t dwVersion;
/*!
* [in] Flags defining the behavior of this frame capture.
*/
uint32_t dwFlags;
/*!
* [out] Index of the texture storing the current frame.
*
* This is an index in the NVFBC_TOGL_SETUP_PARAMS::dwTextures array.
*/
uint32_t dwTextureIndex;
/*!
* [out] Information about the captured frame.
*
* Can be NULL.
*/
NVFBC_FRAME_GRAB_INFO *pFrameGrabInfo;
/*!
* [in] Wait timeout in milliseconds.
*
* When capturing frames with the NVFBC_TOGL_GRAB_FLAGS_NOFLAGS or
* NVFBC_TOGL_GRAB_FLAGS_NOWAIT_IF_NEW_FRAME_READY flags,
* NvFBC will wait for a new frame or mouse move until the below timer
* expires.
*
* When timing out, the last captured frame will be returned. Note that as
* long as the NVFBC_TOGL_GRAB_FLAGS_FORCE_REFRESH flag is not set,
* returning an old frame will incur no performance penalty.
*
* NvFBC clients can use the return value of the grab frame operation to
* find out whether a new frame was captured, or the timer expired.
*
* Note that the behavior of blocking calls is to wait for a new frame
* *after* the call has been made. When using timeouts, it is possible
* that NvFBC will return a new frame (e.g., it has never been captured
* before) even though no new frame was generated after the grab call.
*
* For the precise definition of what constitutes a new frame, see
* ::bIsNewFrame.
*
* Set to 0 to disable timeouts.
*/
uint32_t dwTimeoutMs;
} NVFBC_TOGL_GRAB_FRAME_PARAMS;
/*!
* NVFBC_TOGL_GRAB_FRAME_PARAMS structure version.
*/
#define NVFBC_TOGL_GRAB_FRAME_PARAMS_VER NVFBC_STRUCT_VERSION(NVFBC_TOGL_GRAB_FRAME_PARAMS, 2)
/*! @} FBC_STRUCT */
/*!
* \defgroup FBC_FUNC API Entry Points
*
* Entry points are thread-safe and can be called concurrently.
*
* The locking model includes a global lock that protects session handle
* management (\see NvFBCCreateHandle, \see NvFBCDestroyHandle).
*
* Each NvFBC session uses a local lock to protect other entry points. Note
* that in certain cases, a thread can hold the local lock for an undefined
* amount of time, such as grabbing a frame using a blocking call.
*
* Note that a context is associated with each session. NvFBC clients wishing
* to share a session between different threads are expected to release and
* bind the context appropriately (\see NvFBCBindContext,
* \see NvFBCReleaseContext). This is not required when each thread uses its
* own NvFBC session.
*
* @{
*/
/*!
* Gets the last error message that got recorded for a client.
*
* When NvFBC returns an error, it will save an error message that can be
* queried through this API call. Only the last message is saved.
* The message and the return code should give enough information about
* what went wrong.
*
* \param [in] sessionHandle
* Handle to the NvFBC client.
* \return
* A NULL terminated error message, or an empty string. Its maximum length
* is NVFBC_ERROR_STR_LEN.
*/
const char* NVFBCAPI NvFBCGetLastErrorStr(const NVFBC_SESSION_HANDLE sessionHandle);
/*!
* \brief Allocates a new handle for an NvFBC client.
*
* This function allocates a session handle used to identify an FBC client.
*
* This function implicitly calls NvFBCBindContext().
*
* \param [out] pSessionHandle
* Pointer that will hold the allocated session handle.
* \param [in] pParams
* ::NVFBC_CREATE_HANDLE_PARAMS
*
* \return
* ::NVFBC_SUCCESS \n
* ::NVFBC_ERR_INVALID_PTR \n
* ::NVFBC_ERR_API_VERSION \n
* ::NVFBC_ERR_INTERNAL \n
* ::NVFBC_ERR_OUT_OF_MEMORY \n
* ::NVFBC_ERR_MAX_CLIENTS \n
* ::NVFBC_ERR_X \n
* ::NVFBC_ERR_GLX \n
* ::NVFBC_ERR_GL
*
*/
NVFBCSTATUS NVFBCAPI NvFBCCreateHandle(NVFBC_SESSION_HANDLE *pSessionHandle, NVFBC_CREATE_HANDLE_PARAMS *pParams);
/*!
* \brief Destroys the handle of an NvFBC client.
*
* This function uninitializes an FBC client.
*
* This function implicitly calls NvFBCReleaseContext().
*
* After this fucntion returns, it is not possible to use this session handle
* for any further API call.
*
* \param [in] sessionHandle
* FBC session handle.
* \param [in] pParams
* ::NVFBC_DESTROY_HANDLE_PARAMS
*
* \return
* ::NVFBC_SUCCESS \n
* ::NVFBC_ERR_INVALID_HANDLE \n
* ::NVFBC_ERR_API_VERSION \n
* ::NVFBC_ERR_BAD_REQUEST \n
* ::NVFBC_ERR_INTERNAL \n
* ::NVFBC_ERR_CONTEXT \n
* ::NVFBC_ERR_X
*/
NVFBCSTATUS NVFBCAPI NvFBCDestroyHandle(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_DESTROY_HANDLE_PARAMS *pParams);
/*!
* \brief Gets the current status of the display driver.
*
* This function queries the display driver for various information.
*
* \param [in] sessionHandle
* FBC session handle.
* \param [in] pParams
* ::NVFBC_GET_STATUS_PARAMS
*
* \return
* ::NVFBC_SUCCESS \n
* ::NVFBC_ERR_INVALID_HANDLE \n
* ::NVFBC_ERR_API_VERSION \n
* ::NVFBC_ERR_INTERNAL \n
* ::NVFBC_ERR_X
*/
NVFBCSTATUS NVFBCAPI NvFBCGetStatus(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_GET_STATUS_PARAMS *pParams);
/*!
* \brief Binds the FBC context to the calling thread.
*
* The NvFBC library internally relies on objects that must be bound to a
* thread. Such objects are OpenGL contexts and CUDA contexts.
*
* This function binds these objects to the calling thread.
*
* The FBC context must be bound to the calling thread for most NvFBC entry
* points, otherwise ::NVFBC_ERR_CONTEXT is returned.
*
* If the FBC context is already bound to a different thread,
* ::NVFBC_ERR_CONTEXT is returned. The other thread must release the context
* first by calling the ReleaseContext() entry point.
*
* If the FBC context is already bound to the current thread, this function has
* no effects.
*
* \param [in] sessionHandle
* FBC session handle.
* \param [in] pParams
* ::NVFBC_DESTROY_CAPTURE_SESSION_PARAMS
*
* \return
* ::NVFBC_SUCCESS \n
* ::NVFBC_ERR_INVALID_HANDLE \n
* ::NVFBC_ERR_API_VERSION \n
* ::NVFBC_ERR_BAD_REQUEST \n
* ::NVFBC_ERR_CONTEXT \n
* ::NVFBC_ERR_INTERNAL \n
* ::NVFBC_ERR_X
*/
NVFBCSTATUS NVFBCAPI NvFBCBindContext(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_BIND_CONTEXT_PARAMS *pParams);
/*!
* \brief Releases the FBC context from the calling thread.
*
* If the FBC context is bound to a different thread, ::NVFBC_ERR_CONTEXT is
* returned.
*
* If the FBC context is already released, this functino has no effects.
*
* \param [in] sessionHandle
* FBC session handle.
* \param [in] pParams
* ::NVFBC_SUCCESS \n
* ::NVFBC_ERR_INVALID_HANDLE \n
* ::NVFBC_ERR_API_VERSION \n
* ::NVFBC_ERR_BAD_REQUEST \n
* ::NVFBC_ERR_CONTEXT \n
* ::NVFBC_ERR_INTERNAL \n
* ::NVFBC_ERR_X
*/
NVFBCSTATUS NVFBCAPI NvFBCReleaseContext(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_RELEASE_CONTEXT_PARAMS *pParams);
/*!
* \brief Creates a capture session for an FBC client.
*
* This function starts a capture session of the desired type (system memory,
* video memory with CUDA interop, or H.264 compressed frames in system memory).
*
* Not all types are supported on all systems. Also, it is possible to use
* NvFBC without having the CUDA library. In this case, requesting a capture
* session of the concerned type will return an error.
*
* After this function returns, the display driver will start generating frames
* that can be captured using the corresponding API call.
*
* \param [in] sessionHandle
* FBC session handle.
* \param [in] pParams
* ::NVFBC_CREATE_CAPTURE_SESSION_PARAMS
*
* \return
* ::NVFBC_SUCCESS \n
* ::NVFBC_ERR_INVALID_HANDLE \n
* ::NVFBC_ERR_API_VERSION \n
* ::NVFBC_ERR_BAD_REQUEST \n
* ::NVFBC_ERR_CONTEXT \n
* ::NVFBC_ERR_INVALID_PARAM \n
* ::NVFBC_ERR_OUT_OF_MEMORY \n
* ::NVFBC_ERR_X \n
* ::NVFBC_ERR_GLX \n
* ::NVFBC_ERR_GL \n
* ::NVFBC_ERR_CUDA \n
* ::NVFBC_ERR_MUST_RECREATE \n
* ::NVFBC_ERR_INTERNAL
*/
NVFBCSTATUS NVFBCAPI NvFBCCreateCaptureSession(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_CREATE_CAPTURE_SESSION_PARAMS *pParams);
/*!
* \brief Destroys a capture session for an FBC client.
*
* This function stops a capture session and frees allocated objects.
*
* After this function returns, it is possible to create another capture
* session using the corresponding API call.
*
* \param [in] sessionHandle
* FBC session handle.
* \param [in] pParams
* ::NVFBC_DESTROY_CAPTURE_SESSION_PARAMS
*
* \return
* ::NVFBC_SUCCESS \n
* ::NVFBC_ERR_INVALID_HANDLE \n
* ::NVFBC_ERR_API_VERSION \n
* ::NVFBC_ERR_BAD_REQUEST \n
* ::NVFBC_ERR_CONTEXT \n
* ::NVFBC_ERR_INTERNAL \n
* ::NVFBC_ERR_X
*/
NVFBCSTATUS NVFBCAPI NvFBCDestroyCaptureSession(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_DESTROY_CAPTURE_SESSION_PARAMS *pParams);
/*!
* \brief Sets up a capture to system memory session.
*
* This function configures how the capture to system memory should behave. It
* can be called anytime and several times after the capture session has been
* created. However, it must be called at least once prior to start capturing
* frames.
*
* This function allocates the buffer that will contain the captured frame.
* The application does not need to free this buffer. The size of this buffer
* is returned in the ::NVFBC_FRAME_GRAB_INFO structure.
*
* \param [in] sessionHandle
* FBC session handle.
* \param [in] pParams
* ::NVFBC_TOSYS_SETUP_PARAMS
*
* \return
* ::NVFBC_SUCCESS \n
* ::NVFBC_ERR_INVALID_HANDLE \n
* ::NVFBC_ERR_API_VERSION \n
* ::NVFBC_ERR_BAD_REQUEST \n
* ::NVFBC_ERR_INTERNAL \n
* ::NVFBC_ERR_CONTEXT \n
* ::NVFBC_ERR_UNSUPPORTED \n
* ::NVFBC_ERR_INVALID_PTR \n
* ::NVFBC_ERR_INVALID_PARAM \n
* ::NVFBC_ERR_OUT_OF_MEMORY \n
* ::NVFBC_ERR_X
*/
NVFBCSTATUS NVFBCAPI NvFBCToSysSetUp(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_TOSYS_SETUP_PARAMS *pParams);
/*!
* \brief Captures a frame to a buffer in system memory.
*
* This function triggers a frame capture to a buffer in system memory that was
* registered with the ToSysSetUp() API call.
*
* Note that it is possible that the resolution of the desktop changes while
* capturing frames. This should be transparent for the application.
*
* When the resolution changes, the capture session is recreated using the same
* parameters, and necessary buffers are re-allocated. The frame counter is not
* reset.
*
* An application can detect that the resolution changed by comparing the
* dwByteSize member of the ::NVFBC_FRAME_GRAB_INFO against a previous
* frame and/or dwWidth and dwHeight.
*
* During a change of resolution the capture is paused even in asynchronous
* mode.
*
* \param [in] sessionHandle
* FBC session handle.
* \param [in] pParams
* ::NVFBC_TOSYS_GRAB_FRAME_PARAMS
*
* \return
* ::NVFBC_SUCCESS \n
* ::NVFBC_ERR_INVALID_HANDLE \n
* ::NVFBC_ERR_API_VERSION \n
* ::NVFBC_ERR_BAD_REQUEST \n
* ::NVFBC_ERR_CONTEXT \n
* ::NVFBC_ERR_INVALID_PTR \n
* ::NVFBC_ERR_INTERNAL \n
* ::NVFBC_ERR_X \n
* ::NVFBC_ERR_MUST_RECREATE \n
* \see NvFBCCreateCaptureSession \n
* \see NvFBCToSysSetUp
*/
NVFBCSTATUS NVFBCAPI NvFBCToSysGrabFrame(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_TOSYS_GRAB_FRAME_PARAMS *pParams);
/*!
* \brief Sets up a capture to video memory session.
*
* This function configures how the capture to video memory with CUDA interop
* should behave. It can be called anytime and several times after the capture
* session has been created. However, it must be called at least once prior
* to start capturing frames.
*
* \param [in] sessionHandle
* FBC session handle.
*
* \param [in] pParams
* ::NVFBC_TOCUDA_SETUP_PARAMS
*
* \return
* ::NVFBC_SUCCESS \n
* ::NVFBC_ERR_INVALID_HANDLE \n
* ::NVFBC_ERR_API_VERSION \n
* ::NVFBC_ERR_BAD_REQUEST \n
* ::NVFBC_ERR_INTERNAL \n
* ::NVFBC_ERR_CONTEXT \n
* ::NVFBC_ERR_UNSUPPORTED \n
* ::NVFBC_ERR_GL \n
* ::NVFBC_ERR_X
*/
NVFBCSTATUS NVFBCAPI NvFBCToCudaSetUp(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_TOCUDA_SETUP_PARAMS *pParams);
/*!
* \brief Captures a frame to a CUDA device in video memory.
*
* This function triggers a frame capture to a CUDA device in video memory.
*
* Note about changes of resolution: \see NvFBCToSysGrabFrame
*
* \param [in] sessionHandle
* FBC session handle.
*
* \param [in] pParams
* ::NVFBC_TOCUDA_GRAB_FRAME_PARAMS
*
* \return
* ::NVFBC_SUCCESS \n
* ::NVFBC_ERR_INVALID_HANDLE \n
* ::NVFBC_ERR_API_VERSION \n
* ::NVFBC_ERR_BAD_REQUEST \n
* ::NVFBC_ERR_CONTEXT \n
* ::NVFBC_ERR_INVALID_PTR \n
* ::NVFBC_ERR_CUDA \n
* ::NVFBC_ERR_INTERNAL \n
* ::NVFBC_ERR_X \n
* ::NVFBC_ERR_MUST_RECREATE \n
* \see NvFBCCreateCaptureSession \n
* \see NvFBCToCudaSetUp
*/
NVFBCSTATUS NVFBCAPI NvFBCToCudaGrabFrame(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_TOCUDA_GRAB_FRAME_PARAMS *pParams);
/*!
* \brief Sets up a capture to OpenGL buffer in video memory session.
*
* This function configures how the capture to video memory should behave.
* It can be called anytime and several times after the capture session has been
* created. However, it must be called at least once prior to start capturing
* frames.
*
* \param [in] sessionHandle
* FBC session handle.
*
* \param [in] pParams
* ::NVFBC_TOGL_SETUP_PARAMS
*
* \return
* ::NVFBC_SUCCESS \n
* ::NVFBC_ERR_INVALID_HANDLE \n
* ::NVFBC_ERR_API_VERSION \n
* ::NVFBC_ERR_BAD_REQUEST \n
* ::NVFBC_ERR_INTERNAL \n
* ::NVFBC_ERR_CONTEXT \n
* ::NVFBC_ERR_UNSUPPORTED \n
* ::NVFBC_ERR_GL \n
* ::NVFBC_ERR_X
*/
NVFBCSTATUS NVFBCAPI NvFBCToGLSetUp(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_TOGL_SETUP_PARAMS *pParams);
/*!
* \brief Captures a frame to an OpenGL buffer in video memory.
*
* This function triggers a frame capture to a selected resource in video memory.
*
* Note about changes of resolution: \see NvFBCToSysGrabFrame
*
* \param [in] sessionHandle
* FBC session handle.
*
* \param [in] pParams
* ::NVFBC_TOGL_GRAB_FRAME_PARAMS
*
* \return
* ::NVFBC_SUCCESS \n
* ::NVFBC_ERR_INVALID_HANDLE \n
* ::NVFBC_ERR_API_VERSION \n
* ::NVFBC_ERR_BAD_REQUEST \n
* ::NVFBC_ERR_CONTEXT \n
* ::NVFBC_ERR_INVALID_PTR \n
* ::NVFBC_ERR_INTERNAL \n
* ::NVFBC_ERR_X \n
* ::NVFBC_ERR_MUST_RECREATE \n
* \see NvFBCCreateCaptureSession \n
* \see NvFBCToCudaSetUp
*/
NVFBCSTATUS NVFBCAPI NvFBCToGLGrabFrame(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_TOGL_GRAB_FRAME_PARAMS *pParams);
/*!
* \cond FBC_PFN
*
* Defines API function pointers
*/
typedef const char* (NVFBCAPI* PNVFBCGETLASTERRORSTR)(const NVFBC_SESSION_HANDLE sessionHandle);
typedef NVFBCSTATUS (NVFBCAPI* PNVFBCCREATEHANDLE)(NVFBC_SESSION_HANDLE *pSessionHandle, NVFBC_CREATE_HANDLE_PARAMS *pParams);
typedef NVFBCSTATUS (NVFBCAPI* PNVFBCDESTROYHANDLE)(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_DESTROY_HANDLE_PARAMS *pParams);
typedef NVFBCSTATUS (NVFBCAPI* PNVFBCBINDCONTEXT)(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_BIND_CONTEXT_PARAMS *pParams);
typedef NVFBCSTATUS (NVFBCAPI* PNVFBCRELEASECONTEXT)(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_RELEASE_CONTEXT_PARAMS *pParams);
typedef NVFBCSTATUS (NVFBCAPI* PNVFBCGETSTATUS)(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_GET_STATUS_PARAMS *pParams);
typedef NVFBCSTATUS (NVFBCAPI* PNVFBCCREATECAPTURESESSION)(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_CREATE_CAPTURE_SESSION_PARAMS *pParams);
typedef NVFBCSTATUS (NVFBCAPI* PNVFBCDESTROYCAPTURESESSION)(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_DESTROY_CAPTURE_SESSION_PARAMS *pParams);
typedef NVFBCSTATUS (NVFBCAPI* PNVFBCTOSYSSETUP)(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_TOSYS_SETUP_PARAMS *pParams);
typedef NVFBCSTATUS (NVFBCAPI* PNVFBCTOSYSGRABFRAME)(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_TOSYS_GRAB_FRAME_PARAMS *pParams);
typedef NVFBCSTATUS (NVFBCAPI* PNVFBCTOCUDASETUP)(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_TOCUDA_SETUP_PARAMS *pParams);
typedef NVFBCSTATUS (NVFBCAPI* PNVFBCTOCUDAGRABFRAME)(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_TOCUDA_GRAB_FRAME_PARAMS *pParams);
typedef NVFBCSTATUS (NVFBCAPI* PNVFBCTOGLSETUP)(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_TOGL_SETUP_PARAMS *pParams);
typedef NVFBCSTATUS (NVFBCAPI* PNVFBCTOGLGRABFRAME)(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_TOGL_GRAB_FRAME_PARAMS *pParams);
/// \endcond
/*! @} FBC_FUNC */
/*!
* \ingroup FBC_STRUCT
*
* Structure populated with API function pointers.
*/
typedef struct
{
uint32_t dwVersion; //!< [in] Must be set to NVFBC_VERSION.
PNVFBCGETLASTERRORSTR nvFBCGetLastErrorStr; //!< [out] Pointer to ::NvFBCGetLastErrorStr().
PNVFBCCREATEHANDLE nvFBCCreateHandle; //!< [out] Pointer to ::NvFBCCreateHandle().
PNVFBCDESTROYHANDLE nvFBCDestroyHandle; //!< [out] Pointer to ::NvFBCDestroyHandle().
PNVFBCGETSTATUS nvFBCGetStatus; //!< [out] Pointer to ::NvFBCGetStatus().
PNVFBCCREATECAPTURESESSION nvFBCCreateCaptureSession; //!< [out] Pointer to ::NvFBCCreateCaptureSession().
PNVFBCDESTROYCAPTURESESSION nvFBCDestroyCaptureSession; //!< [out] Pointer to ::NvFBCDestroyCaptureSession().
PNVFBCTOSYSSETUP nvFBCToSysSetUp; //!< [out] Pointer to ::NvFBCToSysSetUp().
PNVFBCTOSYSGRABFRAME nvFBCToSysGrabFrame; //!< [out] Pointer to ::NvFBCToSysGrabFrame().
PNVFBCTOCUDASETUP nvFBCToCudaSetUp; //!< [out] Pointer to ::NvFBCToCudaSetUp().
PNVFBCTOCUDAGRABFRAME nvFBCToCudaGrabFrame; //!< [out] Pointer to ::NvFBCToCudaGrabFrame().
void* pad1; //!< [out] Retired. Do not use.
void* pad2; //!< [out] Retired. Do not use.
void* pad3; //!< [out] Retired. Do not use.
PNVFBCBINDCONTEXT nvFBCBindContext; //!< [out] Pointer to ::NvFBCBindContext().
PNVFBCRELEASECONTEXT nvFBCReleaseContext; //!< [out] Pointer to ::NvFBCReleaseContext().
void* pad4; //!< [out] Retired. Do not use.
void* pad5; //!< [out] Retired. Do not use.
void* pad6; //!< [out] Retired. Do not use.
void* pad7; //!< [out] Retired. Do not use.
PNVFBCTOGLSETUP nvFBCToGLSetUp; //!< [out] Pointer to ::nvFBCToGLSetup().
PNVFBCTOGLGRABFRAME nvFBCToGLGrabFrame; //!< [out] Pointer to ::nvFBCToGLGrabFrame().
} NVFBC_API_FUNCTION_LIST;
/*!
* \ingroup FBC_FUNC
*
* \brief Entry Points to the NvFBC interface.
*
* Creates an instance of the NvFBC interface, and populates the
* pFunctionList with function pointers to the API routines implemented by
* the NvFBC interface.
*
* \param [out] pFunctionList
*
* \return
* ::NVFBC_SUCCESS \n
* ::NVFBC_ERR_INVALID_PTR \n
* ::NVFBC_ERR_API_VERSION
*/
NVFBCSTATUS NVFBCAPI NvFBCCreateInstance(NVFBC_API_FUNCTION_LIST *pFunctionList);
/*!
* \ingroup FBC_FUNC
*
* Defines function pointer for the ::NvFBCCreateInstance() API call.
*/
typedef NVFBCSTATUS (NVFBCAPI* PNVFBCCREATEINSTANCE)(NVFBC_API_FUNCTION_LIST *pFunctionList);
#ifdef __cplusplus
}
#endif
#endif // _NVFBC_H_
fsdsfdsfdsfdsf-5.13.8/external/nvEncodeAPI.h 0000664 0000000 0000000 00001037415 15202152077 0020706 0 ustar 00root root 0000000 0000000 /*
* This copyright notice applies to this header file only:
*
* Copyright (c) 2010-2022 NVIDIA Corporation
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the software, and to permit persons to whom the
* software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file nvEncodeAPI.h
* NVIDIA GPUs - beginning with the Kepler generation - contain a hardware-based encoder
* (referred to as NVENC) which provides fully-accelerated hardware-based video encoding.
* NvEncodeAPI provides the interface for NVIDIA video encoder (NVENC).
* \date 2011-2022
* This file contains the interface constants, structure definitions and function prototypes.
*/
#ifndef _NV_ENCODEAPI_H_
#define _NV_ENCODEAPI_H_
#include
#ifdef _WIN32
#include
#endif
#ifdef _MSC_VER
#ifndef _STDINT
typedef __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef short int16_t;
typedef unsigned short uint16_t;
#endif
#else
#include
#endif
#ifdef __cplusplus
extern "C" {
#endif
/**
* \addtogroup ENCODER_STRUCTURE NvEncodeAPI Data structures
* @{
*/
#if defined(_WIN32) || defined(__CYGWIN__)
#define NVENCAPI __stdcall
#else
#define NVENCAPI
#endif
#ifdef _WIN32
typedef RECT NVENC_RECT;
#else
#define NVENCAPI
// =========================================================================================
#if !defined(GUID) && !defined(GUID_DEFINED)
#define GUID_DEFINED
/*!
* \struct GUID
* Abstracts the GUID structure for non-windows platforms.
*/
// =========================================================================================
typedef struct _GUID
{
uint32_t Data1; /**< [in]: Specifies the first 8 hexadecimal digits of the GUID. */
uint16_t Data2; /**< [in]: Specifies the first group of 4 hexadecimal digits. */
uint16_t Data3; /**< [in]: Specifies the second group of 4 hexadecimal digits. */
uint8_t Data4[8]; /**< [in]: Array of 8 bytes. The first 2 bytes contain the third group of 4 hexadecimal digits.
The remaining 6 bytes contain the final 12 hexadecimal digits. */
} GUID, *LPGUID;
#endif // GUID
/**
* \struct _NVENC_RECT
* Defines a Rectangle. Used in ::NV_ENC_PREPROCESS_FRAME.
*/
typedef struct _NVENC_RECT
{
uint32_t left; /**< [in]: X coordinate of the upper left corner of rectangular area to be specified. */
uint32_t top; /**< [in]: Y coordinate of the upper left corner of the rectangular area to be specified. */
uint32_t right; /**< [in]: X coordinate of the bottom right corner of the rectangular area to be specified. */
uint32_t bottom; /**< [in]: Y coordinate of the bottom right corner of the rectangular area to be specified. */
} NVENC_RECT;
#endif // _WIN32
/** @} */ /* End of GUID and NVENC_RECT structure grouping*/
typedef void* NV_ENC_INPUT_PTR; /**< NVENCODE API input buffer */
typedef void* NV_ENC_OUTPUT_PTR; /**< NVENCODE API output buffer*/
typedef void* NV_ENC_REGISTERED_PTR; /**< A Resource that has been registered with NVENCODE API*/
typedef void* NV_ENC_CUSTREAM_PTR; /**< Pointer to CUstream*/
#define NVENCAPI_MAJOR_VERSION 12
#define NVENCAPI_MINOR_VERSION 0
#define NVENCAPI_VERSION (NVENCAPI_MAJOR_VERSION | (NVENCAPI_MINOR_VERSION << 24))
/**
* Macro to generate per-structure version for use with API.
*/
#define NVENCAPI_STRUCT_VERSION(ver) ((uint32_t)NVENCAPI_VERSION | ((ver)<<16) | (0x7 << 28))
#define NVENC_INFINITE_GOPLENGTH 0xffffffff
#define NV_MAX_SEQ_HDR_LEN (512)
#ifdef __GNUC__
#define NV_ENC_DEPRECATED __attribute__ ((deprecated("WILL BE REMOVED IN A FUTURE VIDEO CODEC SDK VERSION")))
#elif defined(_MSC_VER)
#define NV_ENC_DEPRECATED __declspec(deprecated("WILL BE REMOVED IN A FUTURE VIDEO CODEC SDK VERSION"))
#endif
// =========================================================================================
// Encode Codec GUIDS supported by the NvEncodeAPI interface.
// =========================================================================================
// {6BC82762-4E63-4ca4-AA85-1E50F321F6BF}
static const GUID NV_ENC_CODEC_H264_GUID =
{ 0x6bc82762, 0x4e63, 0x4ca4, { 0xaa, 0x85, 0x1e, 0x50, 0xf3, 0x21, 0xf6, 0xbf } };
// {790CDC88-4522-4d7b-9425-BDA9975F7603}
static const GUID NV_ENC_CODEC_HEVC_GUID =
{ 0x790cdc88, 0x4522, 0x4d7b, { 0x94, 0x25, 0xbd, 0xa9, 0x97, 0x5f, 0x76, 0x3 } };
// {0A352289-0AA7-4759-862D-5D15CD16D254}
static const GUID NV_ENC_CODEC_AV1_GUID =
{ 0x0a352289, 0x0aa7, 0x4759, { 0x86, 0x2d, 0x5d, 0x15, 0xcd, 0x16, 0xd2, 0x54 } };
// =========================================================================================
// * Encode Profile GUIDS supported by the NvEncodeAPI interface.
// =========================================================================================
// {BFD6F8E7-233C-4341-8B3E-4818523803F4}
static const GUID NV_ENC_CODEC_PROFILE_AUTOSELECT_GUID =
{ 0xbfd6f8e7, 0x233c, 0x4341, { 0x8b, 0x3e, 0x48, 0x18, 0x52, 0x38, 0x3, 0xf4 } };
// {0727BCAA-78C4-4c83-8C2F-EF3DFF267C6A}
static const GUID NV_ENC_H264_PROFILE_BASELINE_GUID =
{ 0x727bcaa, 0x78c4, 0x4c83, { 0x8c, 0x2f, 0xef, 0x3d, 0xff, 0x26, 0x7c, 0x6a } };
// {60B5C1D4-67FE-4790-94D5-C4726D7B6E6D}
static const GUID NV_ENC_H264_PROFILE_MAIN_GUID =
{ 0x60b5c1d4, 0x67fe, 0x4790, { 0x94, 0xd5, 0xc4, 0x72, 0x6d, 0x7b, 0x6e, 0x6d } };
// {E7CBC309-4F7A-4b89-AF2A-D537C92BE310}
static const GUID NV_ENC_H264_PROFILE_HIGH_GUID =
{ 0xe7cbc309, 0x4f7a, 0x4b89, { 0xaf, 0x2a, 0xd5, 0x37, 0xc9, 0x2b, 0xe3, 0x10 } };
// {7AC663CB-A598-4960-B844-339B261A7D52}
static const GUID NV_ENC_H264_PROFILE_HIGH_444_GUID =
{ 0x7ac663cb, 0xa598, 0x4960, { 0xb8, 0x44, 0x33, 0x9b, 0x26, 0x1a, 0x7d, 0x52 } };
// {40847BF5-33F7-4601-9084-E8FE3C1DB8B7}
static const GUID NV_ENC_H264_PROFILE_STEREO_GUID =
{ 0x40847bf5, 0x33f7, 0x4601, { 0x90, 0x84, 0xe8, 0xfe, 0x3c, 0x1d, 0xb8, 0xb7 } };
// {B405AFAC-F32B-417B-89C4-9ABEED3E5978}
static const GUID NV_ENC_H264_PROFILE_PROGRESSIVE_HIGH_GUID =
{ 0xb405afac, 0xf32b, 0x417b, { 0x89, 0xc4, 0x9a, 0xbe, 0xed, 0x3e, 0x59, 0x78 } };
// {AEC1BD87-E85B-48f2-84C3-98BCA6285072}
static const GUID NV_ENC_H264_PROFILE_CONSTRAINED_HIGH_GUID =
{ 0xaec1bd87, 0xe85b, 0x48f2, { 0x84, 0xc3, 0x98, 0xbc, 0xa6, 0x28, 0x50, 0x72 } };
// {B514C39A-B55B-40fa-878F-F1253B4DFDEC}
static const GUID NV_ENC_HEVC_PROFILE_MAIN_GUID =
{ 0xb514c39a, 0xb55b, 0x40fa, { 0x87, 0x8f, 0xf1, 0x25, 0x3b, 0x4d, 0xfd, 0xec } };
// {fa4d2b6c-3a5b-411a-8018-0a3f5e3c9be5}
static const GUID NV_ENC_HEVC_PROFILE_MAIN10_GUID =
{ 0xfa4d2b6c, 0x3a5b, 0x411a, { 0x80, 0x18, 0x0a, 0x3f, 0x5e, 0x3c, 0x9b, 0xe5 } };
// For HEVC Main 444 8 bit and HEVC Main 444 10 bit profiles only
// {51ec32b5-1b4c-453c-9cbd-b616bd621341}
static const GUID NV_ENC_HEVC_PROFILE_FREXT_GUID =
{ 0x51ec32b5, 0x1b4c, 0x453c, { 0x9c, 0xbd, 0xb6, 0x16, 0xbd, 0x62, 0x13, 0x41 } };
// {5f2a39f5-f14e-4f95-9a9e-b76d568fcf97}
static const GUID NV_ENC_AV1_PROFILE_MAIN_GUID =
{ 0x5f2a39f5, 0xf14e, 0x4f95, { 0x9a, 0x9e, 0xb7, 0x6d, 0x56, 0x8f, 0xcf, 0x97 } };
// =========================================================================================
// * Preset GUIDS supported by the NvEncodeAPI interface.
// =========================================================================================
// {B2DFB705-4EBD-4C49-9B5F-24A777D3E587}
NV_ENC_DEPRECATED static const GUID NV_ENC_PRESET_DEFAULT_GUID =
{ 0xb2dfb705, 0x4ebd, 0x4c49, { 0x9b, 0x5f, 0x24, 0xa7, 0x77, 0xd3, 0xe5, 0x87 } };
// {60E4C59F-E846-4484-A56D-CD45BE9FDDF6}
NV_ENC_DEPRECATED static const GUID NV_ENC_PRESET_HP_GUID =
{ 0x60e4c59f, 0xe846, 0x4484, { 0xa5, 0x6d, 0xcd, 0x45, 0xbe, 0x9f, 0xdd, 0xf6 } };
// {34DBA71D-A77B-4B8F-9C3E-B6D5DA24C012}
NV_ENC_DEPRECATED static const GUID NV_ENC_PRESET_HQ_GUID =
{ 0x34dba71d, 0xa77b, 0x4b8f, { 0x9c, 0x3e, 0xb6, 0xd5, 0xda, 0x24, 0xc0, 0x12 } };
// {82E3E450-BDBB-4e40-989C-82A90DF9EF32}
NV_ENC_DEPRECATED static const GUID NV_ENC_PRESET_BD_GUID =
{ 0x82e3e450, 0xbdbb, 0x4e40, { 0x98, 0x9c, 0x82, 0xa9, 0xd, 0xf9, 0xef, 0x32 } };
// {49DF21C5-6DFA-4feb-9787-6ACC9EFFB726}
NV_ENC_DEPRECATED static const GUID NV_ENC_PRESET_LOW_LATENCY_DEFAULT_GUID =
{ 0x49df21c5, 0x6dfa, 0x4feb, { 0x97, 0x87, 0x6a, 0xcc, 0x9e, 0xff, 0xb7, 0x26 } };
// {C5F733B9-EA97-4cf9-BEC2-BF78A74FD105}
NV_ENC_DEPRECATED static const GUID NV_ENC_PRESET_LOW_LATENCY_HQ_GUID =
{ 0xc5f733b9, 0xea97, 0x4cf9, { 0xbe, 0xc2, 0xbf, 0x78, 0xa7, 0x4f, 0xd1, 0x5 } };
// {67082A44-4BAD-48FA-98EA-93056D150A58}
NV_ENC_DEPRECATED static const GUID NV_ENC_PRESET_LOW_LATENCY_HP_GUID =
{ 0x67082a44, 0x4bad, 0x48fa, { 0x98, 0xea, 0x93, 0x5, 0x6d, 0x15, 0xa, 0x58 } };
// {D5BFB716-C604-44e7-9BB8-DEA5510FC3AC}
NV_ENC_DEPRECATED static const GUID NV_ENC_PRESET_LOSSLESS_DEFAULT_GUID =
{ 0xd5bfb716, 0xc604, 0x44e7, { 0x9b, 0xb8, 0xde, 0xa5, 0x51, 0xf, 0xc3, 0xac } };
// {149998E7-2364-411d-82EF-179888093409}
NV_ENC_DEPRECATED static const GUID NV_ENC_PRESET_LOSSLESS_HP_GUID =
{ 0x149998e7, 0x2364, 0x411d, { 0x82, 0xef, 0x17, 0x98, 0x88, 0x9, 0x34, 0x9 } };
// Performance degrades and quality improves as we move from P1 to P7. Presets P3 to P7 for H264 and Presets P2 to P7 for HEVC have B frames enabled by default
// for HIGH_QUALITY and LOSSLESS tuning info, and will not work with Weighted Prediction enabled. In case Weighted Prediction is required, disable B frames by
// setting frameIntervalP = 1
// {FC0A8D3E-45F8-4CF8-80C7-298871590EBF}
static const GUID NV_ENC_PRESET_P1_GUID =
{ 0xfc0a8d3e, 0x45f8, 0x4cf8, { 0x80, 0xc7, 0x29, 0x88, 0x71, 0x59, 0xe, 0xbf } };
// {F581CFB8-88D6-4381-93F0-DF13F9C27DAB}
static const GUID NV_ENC_PRESET_P2_GUID =
{ 0xf581cfb8, 0x88d6, 0x4381, { 0x93, 0xf0, 0xdf, 0x13, 0xf9, 0xc2, 0x7d, 0xab } };
// {36850110-3A07-441F-94D5-3670631F91F6}
static const GUID NV_ENC_PRESET_P3_GUID =
{ 0x36850110, 0x3a07, 0x441f, { 0x94, 0xd5, 0x36, 0x70, 0x63, 0x1f, 0x91, 0xf6 } };
// {90A7B826-DF06-4862-B9D2-CD6D73A08681}
static const GUID NV_ENC_PRESET_P4_GUID =
{ 0x90a7b826, 0xdf06, 0x4862, { 0xb9, 0xd2, 0xcd, 0x6d, 0x73, 0xa0, 0x86, 0x81 } };
// {21C6E6B4-297A-4CBA-998F-B6CBDE72ADE3}
static const GUID NV_ENC_PRESET_P5_GUID =
{ 0x21c6e6b4, 0x297a, 0x4cba, { 0x99, 0x8f, 0xb6, 0xcb, 0xde, 0x72, 0xad, 0xe3 } };
// {8E75C279-6299-4AB6-8302-0B215A335CF5}
static const GUID NV_ENC_PRESET_P6_GUID =
{ 0x8e75c279, 0x6299, 0x4ab6, { 0x83, 0x2, 0xb, 0x21, 0x5a, 0x33, 0x5c, 0xf5 } };
// {84848C12-6F71-4C13-931B-53E283F57974}
static const GUID NV_ENC_PRESET_P7_GUID =
{ 0x84848c12, 0x6f71, 0x4c13, { 0x93, 0x1b, 0x53, 0xe2, 0x83, 0xf5, 0x79, 0x74 } };
/**
* \addtogroup ENCODER_STRUCTURE NvEncodeAPI Data structures
* @{
*/
/**
* Input frame encode modes
*/
typedef enum _NV_ENC_PARAMS_FRAME_FIELD_MODE
{
NV_ENC_PARAMS_FRAME_FIELD_MODE_FRAME = 0x01, /**< Frame mode */
NV_ENC_PARAMS_FRAME_FIELD_MODE_FIELD = 0x02, /**< Field mode */
NV_ENC_PARAMS_FRAME_FIELD_MODE_MBAFF = 0x03 /**< MB adaptive frame/field */
} NV_ENC_PARAMS_FRAME_FIELD_MODE;
/**
* Rate Control Modes
*/
typedef enum _NV_ENC_PARAMS_RC_MODE
{
NV_ENC_PARAMS_RC_CONSTQP = 0x0, /**< Constant QP mode */
NV_ENC_PARAMS_RC_VBR = 0x1, /**< Variable bitrate mode */
NV_ENC_PARAMS_RC_CBR = 0x2, /**< Constant bitrate mode */
NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ = 0x8, /**< Deprecated, use NV_ENC_PARAMS_RC_CBR + NV_ENC_TWO_PASS_QUARTER_RESOLUTION / NV_ENC_TWO_PASS_FULL_RESOLUTION +
lowDelayKeyFrameScale=1 */
NV_ENC_PARAMS_RC_CBR_HQ = 0x10, /**< Deprecated, use NV_ENC_PARAMS_RC_CBR + NV_ENC_TWO_PASS_QUARTER_RESOLUTION / NV_ENC_TWO_PASS_FULL_RESOLUTION */
NV_ENC_PARAMS_RC_VBR_HQ = 0x20 /**< Deprecated, use NV_ENC_PARAMS_RC_VBR + NV_ENC_TWO_PASS_QUARTER_RESOLUTION / NV_ENC_TWO_PASS_FULL_RESOLUTION */
} NV_ENC_PARAMS_RC_MODE;
/**
* Multi Pass encoding
*/
typedef enum _NV_ENC_MULTI_PASS
{
NV_ENC_MULTI_PASS_DISABLED = 0x0, /**< Single Pass */
NV_ENC_TWO_PASS_QUARTER_RESOLUTION = 0x1, /**< Two Pass encoding is enabled where first Pass is quarter resolution */
NV_ENC_TWO_PASS_FULL_RESOLUTION = 0x2, /**< Two Pass encoding is enabled where first Pass is full resolution */
} NV_ENC_MULTI_PASS;
/**
* Emphasis Levels
*/
typedef enum _NV_ENC_EMPHASIS_MAP_LEVEL
{
NV_ENC_EMPHASIS_MAP_LEVEL_0 = 0x0, /**< Emphasis Map Level 0, for zero Delta QP value */
NV_ENC_EMPHASIS_MAP_LEVEL_1 = 0x1, /**< Emphasis Map Level 1, for very low Delta QP value */
NV_ENC_EMPHASIS_MAP_LEVEL_2 = 0x2, /**< Emphasis Map Level 2, for low Delta QP value */
NV_ENC_EMPHASIS_MAP_LEVEL_3 = 0x3, /**< Emphasis Map Level 3, for medium Delta QP value */
NV_ENC_EMPHASIS_MAP_LEVEL_4 = 0x4, /**< Emphasis Map Level 4, for high Delta QP value */
NV_ENC_EMPHASIS_MAP_LEVEL_5 = 0x5 /**< Emphasis Map Level 5, for very high Delta QP value */
} NV_ENC_EMPHASIS_MAP_LEVEL;
/**
* QP MAP MODE
*/
typedef enum _NV_ENC_QP_MAP_MODE
{
NV_ENC_QP_MAP_DISABLED = 0x0, /**< Value in NV_ENC_PIC_PARAMS::qpDeltaMap have no effect. */
NV_ENC_QP_MAP_EMPHASIS = 0x1, /**< Value in NV_ENC_PIC_PARAMS::qpDeltaMap will be treated as Emphasis level. Currently this is only supported for H264 */
NV_ENC_QP_MAP_DELTA = 0x2, /**< Value in NV_ENC_PIC_PARAMS::qpDeltaMap will be treated as QP delta map. */
NV_ENC_QP_MAP = 0x3, /**< Currently This is not supported. Value in NV_ENC_PIC_PARAMS::qpDeltaMap will be treated as QP value. */
} NV_ENC_QP_MAP_MODE;
#define NV_ENC_PARAMS_RC_VBR_MINQP (NV_ENC_PARAMS_RC_MODE)0x4 /**< Deprecated */
#define NV_ENC_PARAMS_RC_2_PASS_QUALITY NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ /**< Deprecated */
#define NV_ENC_PARAMS_RC_2_PASS_FRAMESIZE_CAP NV_ENC_PARAMS_RC_CBR_HQ /**< Deprecated */
#define NV_ENC_PARAMS_RC_2_PASS_VBR NV_ENC_PARAMS_RC_VBR_HQ /**< Deprecated */
#define NV_ENC_PARAMS_RC_CBR2 NV_ENC_PARAMS_RC_CBR /**< Deprecated */
/**
* Input picture structure
*/
typedef enum _NV_ENC_PIC_STRUCT
{
NV_ENC_PIC_STRUCT_FRAME = 0x01, /**< Progressive frame */
NV_ENC_PIC_STRUCT_FIELD_TOP_BOTTOM = 0x02, /**< Field encoding top field first */
NV_ENC_PIC_STRUCT_FIELD_BOTTOM_TOP = 0x03 /**< Field encoding bottom field first */
} NV_ENC_PIC_STRUCT;
/**
* Display picture structure
* Currently, this enum is only used for deciding the number of clock timestamp sets in Picture Timing SEI / Time Code SEI
* Otherwise, this has no impact on encoder behavior
*/
typedef enum _NV_ENC_DISPLAY_PIC_STRUCT
{
NV_ENC_PIC_STRUCT_DISPLAY_FRAME = 0x00, /**< Field encoding top field first */
NV_ENC_PIC_STRUCT_DISPLAY_FIELD_TOP_BOTTOM = 0x01, /**< Field encoding top field first */
NV_ENC_PIC_STRUCT_DISPLAY_FIELD_BOTTOM_TOP = 0x02, /**< Field encoding bottom field first */
NV_ENC_PIC_STRUCT_DISPLAY_FRAME_DOUBLING = 0x03, /**< Frame doubling */
NV_ENC_PIC_STRUCT_DISPLAY_FRAME_TRIPLING = 0x04 /**< Field tripling */
} NV_ENC_DISPLAY_PIC_STRUCT;
/**
* Input picture type
*/
typedef enum _NV_ENC_PIC_TYPE
{
NV_ENC_PIC_TYPE_P = 0x0, /**< Forward predicted */
NV_ENC_PIC_TYPE_B = 0x01, /**< Bi-directionally predicted picture */
NV_ENC_PIC_TYPE_I = 0x02, /**< Intra predicted picture */
NV_ENC_PIC_TYPE_IDR = 0x03, /**< IDR picture */
NV_ENC_PIC_TYPE_BI = 0x04, /**< Bi-directionally predicted with only Intra MBs */
NV_ENC_PIC_TYPE_SKIPPED = 0x05, /**< Picture is skipped */
NV_ENC_PIC_TYPE_INTRA_REFRESH = 0x06, /**< First picture in intra refresh cycle */
NV_ENC_PIC_TYPE_NONREF_P = 0x07, /**< Non reference P picture */
NV_ENC_PIC_TYPE_UNKNOWN = 0xFF /**< Picture type unknown */
} NV_ENC_PIC_TYPE;
/**
* Motion vector precisions
*/
typedef enum _NV_ENC_MV_PRECISION
{
NV_ENC_MV_PRECISION_DEFAULT = 0x0, /**< Driver selects Quarter-Pel motion vector precision by default */
NV_ENC_MV_PRECISION_FULL_PEL = 0x01, /**< Full-Pel motion vector precision */
NV_ENC_MV_PRECISION_HALF_PEL = 0x02, /**< Half-Pel motion vector precision */
NV_ENC_MV_PRECISION_QUARTER_PEL = 0x03 /**< Quarter-Pel motion vector precision */
} NV_ENC_MV_PRECISION;
/**
* Input buffer formats
*/
typedef enum _NV_ENC_BUFFER_FORMAT
{
NV_ENC_BUFFER_FORMAT_UNDEFINED = 0x00000000, /**< Undefined buffer format */
NV_ENC_BUFFER_FORMAT_NV12 = 0x00000001, /**< Semi-Planar YUV [Y plane followed by interleaved UV plane] */
NV_ENC_BUFFER_FORMAT_YV12 = 0x00000010, /**< Planar YUV [Y plane followed by V and U planes] */
NV_ENC_BUFFER_FORMAT_IYUV = 0x00000100, /**< Planar YUV [Y plane followed by U and V planes] */
NV_ENC_BUFFER_FORMAT_YUV444 = 0x00001000, /**< Planar YUV [Y plane followed by U and V planes] */
NV_ENC_BUFFER_FORMAT_YUV420_10BIT = 0x00010000, /**< 10 bit Semi-Planar YUV [Y plane followed by interleaved UV plane]. Each pixel of size 2 bytes. Most Significant 10 bits contain pixel data. */
NV_ENC_BUFFER_FORMAT_YUV444_10BIT = 0x00100000, /**< 10 bit Planar YUV444 [Y plane followed by U and V planes]. Each pixel of size 2 bytes. Most Significant 10 bits contain pixel data. */
NV_ENC_BUFFER_FORMAT_ARGB = 0x01000000, /**< 8 bit Packed A8R8G8B8. This is a word-ordered format
where a pixel is represented by a 32-bit word with B
in the lowest 8 bits, G in the next 8 bits, R in the
8 bits after that and A in the highest 8 bits. */
NV_ENC_BUFFER_FORMAT_ARGB10 = 0x02000000, /**< 10 bit Packed A2R10G10B10. This is a word-ordered format
where a pixel is represented by a 32-bit word with B
in the lowest 10 bits, G in the next 10 bits, R in the
10 bits after that and A in the highest 2 bits. */
NV_ENC_BUFFER_FORMAT_AYUV = 0x04000000, /**< 8 bit Packed A8Y8U8V8. This is a word-ordered format
where a pixel is represented by a 32-bit word with V
in the lowest 8 bits, U in the next 8 bits, Y in the
8 bits after that and A in the highest 8 bits. */
NV_ENC_BUFFER_FORMAT_ABGR = 0x10000000, /**< 8 bit Packed A8B8G8R8. This is a word-ordered format
where a pixel is represented by a 32-bit word with R
in the lowest 8 bits, G in the next 8 bits, B in the
8 bits after that and A in the highest 8 bits. */
NV_ENC_BUFFER_FORMAT_ABGR10 = 0x20000000, /**< 10 bit Packed A2B10G10R10. This is a word-ordered format
where a pixel is represented by a 32-bit word with R
in the lowest 10 bits, G in the next 10 bits, B in the
10 bits after that and A in the highest 2 bits. */
NV_ENC_BUFFER_FORMAT_U8 = 0x40000000, /**< Buffer format representing one-dimensional buffer.
This format should be used only when registering the
resource as output buffer, which will be used to write
the encoded bit stream or H.264 ME only mode output. */
} NV_ENC_BUFFER_FORMAT;
#define NV_ENC_BUFFER_FORMAT_NV12_PL NV_ENC_BUFFER_FORMAT_NV12
#define NV_ENC_BUFFER_FORMAT_YV12_PL NV_ENC_BUFFER_FORMAT_YV12
#define NV_ENC_BUFFER_FORMAT_IYUV_PL NV_ENC_BUFFER_FORMAT_IYUV
#define NV_ENC_BUFFER_FORMAT_YUV444_PL NV_ENC_BUFFER_FORMAT_YUV444
/**
* Encoding levels
*/
typedef enum _NV_ENC_LEVEL
{
NV_ENC_LEVEL_AUTOSELECT = 0,
NV_ENC_LEVEL_H264_1 = 10,
NV_ENC_LEVEL_H264_1b = 9,
NV_ENC_LEVEL_H264_11 = 11,
NV_ENC_LEVEL_H264_12 = 12,
NV_ENC_LEVEL_H264_13 = 13,
NV_ENC_LEVEL_H264_2 = 20,
NV_ENC_LEVEL_H264_21 = 21,
NV_ENC_LEVEL_H264_22 = 22,
NV_ENC_LEVEL_H264_3 = 30,
NV_ENC_LEVEL_H264_31 = 31,
NV_ENC_LEVEL_H264_32 = 32,
NV_ENC_LEVEL_H264_4 = 40,
NV_ENC_LEVEL_H264_41 = 41,
NV_ENC_LEVEL_H264_42 = 42,
NV_ENC_LEVEL_H264_5 = 50,
NV_ENC_LEVEL_H264_51 = 51,
NV_ENC_LEVEL_H264_52 = 52,
NV_ENC_LEVEL_H264_60 = 60,
NV_ENC_LEVEL_H264_61 = 61,
NV_ENC_LEVEL_H264_62 = 62,
NV_ENC_LEVEL_HEVC_1 = 30,
NV_ENC_LEVEL_HEVC_2 = 60,
NV_ENC_LEVEL_HEVC_21 = 63,
NV_ENC_LEVEL_HEVC_3 = 90,
NV_ENC_LEVEL_HEVC_31 = 93,
NV_ENC_LEVEL_HEVC_4 = 120,
NV_ENC_LEVEL_HEVC_41 = 123,
NV_ENC_LEVEL_HEVC_5 = 150,
NV_ENC_LEVEL_HEVC_51 = 153,
NV_ENC_LEVEL_HEVC_52 = 156,
NV_ENC_LEVEL_HEVC_6 = 180,
NV_ENC_LEVEL_HEVC_61 = 183,
NV_ENC_LEVEL_HEVC_62 = 186,
NV_ENC_TIER_HEVC_MAIN = 0,
NV_ENC_TIER_HEVC_HIGH = 1,
NV_ENC_LEVEL_AV1_2 = 0,
NV_ENC_LEVEL_AV1_21 = 1,
NV_ENC_LEVEL_AV1_22 = 2,
NV_ENC_LEVEL_AV1_23 = 3,
NV_ENC_LEVEL_AV1_3 = 4,
NV_ENC_LEVEL_AV1_31 = 5,
NV_ENC_LEVEL_AV1_32 = 6,
NV_ENC_LEVEL_AV1_33 = 7,
NV_ENC_LEVEL_AV1_4 = 8,
NV_ENC_LEVEL_AV1_41 = 9,
NV_ENC_LEVEL_AV1_42 = 10,
NV_ENC_LEVEL_AV1_43 = 11,
NV_ENC_LEVEL_AV1_5 = 12,
NV_ENC_LEVEL_AV1_51 = 13,
NV_ENC_LEVEL_AV1_52 = 14,
NV_ENC_LEVEL_AV1_53 = 15,
NV_ENC_LEVEL_AV1_6 = 16,
NV_ENC_LEVEL_AV1_61 = 17,
NV_ENC_LEVEL_AV1_62 = 18,
NV_ENC_LEVEL_AV1_63 = 19,
NV_ENC_LEVEL_AV1_7 = 20,
NV_ENC_LEVEL_AV1_71 = 21,
NV_ENC_LEVEL_AV1_72 = 22,
NV_ENC_LEVEL_AV1_73 = 23,
NV_ENC_LEVEL_AV1_AUTOSELECT ,
NV_ENC_TIER_AV1_0 = 0,
NV_ENC_TIER_AV1_1 = 1
} NV_ENC_LEVEL;
/**
* Error Codes
*/
typedef enum _NVENCSTATUS
{
/**
* This indicates that API call returned with no errors.
*/
NV_ENC_SUCCESS,
/**
* This indicates that no encode capable devices were detected.
*/
NV_ENC_ERR_NO_ENCODE_DEVICE,
/**
* This indicates that devices pass by the client is not supported.
*/
NV_ENC_ERR_UNSUPPORTED_DEVICE,
/**
* This indicates that the encoder device supplied by the client is not
* valid.
*/
NV_ENC_ERR_INVALID_ENCODERDEVICE,
/**
* This indicates that device passed to the API call is invalid.
*/
NV_ENC_ERR_INVALID_DEVICE,
/**
* This indicates that device passed to the API call is no longer available and
* needs to be reinitialized. The clients need to destroy the current encoder
* session by freeing the allocated input output buffers and destroying the device
* and create a new encoding session.
*/
NV_ENC_ERR_DEVICE_NOT_EXIST,
/**
* This indicates that one or more of the pointers passed to the API call
* is invalid.
*/
NV_ENC_ERR_INVALID_PTR,
/**
* This indicates that completion event passed in ::NvEncEncodePicture() call
* is invalid.
*/
NV_ENC_ERR_INVALID_EVENT,
/**
* This indicates that one or more of the parameter passed to the API call
* is invalid.
*/
NV_ENC_ERR_INVALID_PARAM,
/**
* This indicates that an API call was made in wrong sequence/order.
*/
NV_ENC_ERR_INVALID_CALL,
/**
* This indicates that the API call failed because it was unable to allocate
* enough memory to perform the requested operation.
*/
NV_ENC_ERR_OUT_OF_MEMORY,
/**
* This indicates that the encoder has not been initialized with
* ::NvEncInitializeEncoder() or that initialization has failed.
* The client cannot allocate input or output buffers or do any encoding
* related operation before successfully initializing the encoder.
*/
NV_ENC_ERR_ENCODER_NOT_INITIALIZED,
/**
* This indicates that an unsupported parameter was passed by the client.
*/
NV_ENC_ERR_UNSUPPORTED_PARAM,
/**
* This indicates that the ::NvEncLockBitstream() failed to lock the output
* buffer. This happens when the client makes a non blocking lock call to
* access the output bitstream by passing NV_ENC_LOCK_BITSTREAM::doNotWait flag.
* This is not a fatal error and client should retry the same operation after
* few milliseconds.
*/
NV_ENC_ERR_LOCK_BUSY,
/**
* This indicates that the size of the user buffer passed by the client is
* insufficient for the requested operation.
*/
NV_ENC_ERR_NOT_ENOUGH_BUFFER,
/**
* This indicates that an invalid struct version was used by the client.
*/
NV_ENC_ERR_INVALID_VERSION,
/**
* This indicates that ::NvEncMapInputResource() API failed to map the client
* provided input resource.
*/
NV_ENC_ERR_MAP_FAILED,
/**
* This indicates encode driver requires more input buffers to produce an output
* bitstream. If this error is returned from ::NvEncEncodePicture() API, this
* is not a fatal error. If the client is encoding with B frames then,
* ::NvEncEncodePicture() API might be buffering the input frame for re-ordering.
*
* A client operating in synchronous mode cannot call ::NvEncLockBitstream()
* API on the output bitstream buffer if ::NvEncEncodePicture() returned the
* ::NV_ENC_ERR_NEED_MORE_INPUT error code.
* The client must continue providing input frames until encode driver returns
* ::NV_ENC_SUCCESS. After receiving ::NV_ENC_SUCCESS status the client can call
* ::NvEncLockBitstream() API on the output buffers in the same order in which
* it has called ::NvEncEncodePicture().
*/
NV_ENC_ERR_NEED_MORE_INPUT,
/**
* This indicates that the HW encoder is busy encoding and is unable to encode
* the input. The client should call ::NvEncEncodePicture() again after few
* milliseconds.
*/
NV_ENC_ERR_ENCODER_BUSY,
/**
* This indicates that the completion event passed in ::NvEncEncodePicture()
* API has not been registered with encoder driver using ::NvEncRegisterAsyncEvent().
*/
NV_ENC_ERR_EVENT_NOT_REGISTERD,
/**
* This indicates that an unknown internal error has occurred.
*/
NV_ENC_ERR_GENERIC,
/**
* This indicates that the client is attempting to use a feature
* that is not available for the license type for the current system.
*/
NV_ENC_ERR_INCOMPATIBLE_CLIENT_KEY,
/**
* This indicates that the client is attempting to use a feature
* that is not implemented for the current version.
*/
NV_ENC_ERR_UNIMPLEMENTED,
/**
* This indicates that the ::NvEncRegisterResource API failed to register the resource.
*/
NV_ENC_ERR_RESOURCE_REGISTER_FAILED,
/**
* This indicates that the client is attempting to unregister a resource
* that has not been successfully registered.
*/
NV_ENC_ERR_RESOURCE_NOT_REGISTERED,
/**
* This indicates that the client is attempting to unmap a resource
* that has not been successfully mapped.
*/
NV_ENC_ERR_RESOURCE_NOT_MAPPED,
} NVENCSTATUS;
/**
* Encode Picture encode flags.
*/
typedef enum _NV_ENC_PIC_FLAGS
{
NV_ENC_PIC_FLAG_FORCEINTRA = 0x1, /**< Encode the current picture as an Intra picture */
NV_ENC_PIC_FLAG_FORCEIDR = 0x2, /**< Encode the current picture as an IDR picture.
This flag is only valid when Picture type decision is taken by the Encoder
[_NV_ENC_INITIALIZE_PARAMS::enablePTD == 1]. */
NV_ENC_PIC_FLAG_OUTPUT_SPSPPS = 0x4, /**< Write the sequence and picture header in encoded bitstream of the current picture */
NV_ENC_PIC_FLAG_EOS = 0x8, /**< Indicates end of the input stream */
} NV_ENC_PIC_FLAGS;
/**
* Memory heap to allocate input and output buffers.
*/
typedef enum _NV_ENC_MEMORY_HEAP
{
NV_ENC_MEMORY_HEAP_AUTOSELECT = 0, /**< Memory heap to be decided by the encoder driver based on the usage */
NV_ENC_MEMORY_HEAP_VID = 1, /**< Memory heap is in local video memory */
NV_ENC_MEMORY_HEAP_SYSMEM_CACHED = 2, /**< Memory heap is in cached system memory */
NV_ENC_MEMORY_HEAP_SYSMEM_UNCACHED = 3 /**< Memory heap is in uncached system memory */
} NV_ENC_MEMORY_HEAP;
/**
* B-frame used as reference modes
*/
typedef enum _NV_ENC_BFRAME_REF_MODE
{
NV_ENC_BFRAME_REF_MODE_DISABLED = 0x0, /**< B frame is not used for reference */
NV_ENC_BFRAME_REF_MODE_EACH = 0x1, /**< Each B-frame will be used for reference */
NV_ENC_BFRAME_REF_MODE_MIDDLE = 0x2, /**< Only(Number of B-frame)/2 th B-frame will be used for reference */
} NV_ENC_BFRAME_REF_MODE;
/**
* H.264 entropy coding modes.
*/
typedef enum _NV_ENC_H264_ENTROPY_CODING_MODE
{
NV_ENC_H264_ENTROPY_CODING_MODE_AUTOSELECT = 0x0, /**< Entropy coding mode is auto selected by the encoder driver */
NV_ENC_H264_ENTROPY_CODING_MODE_CABAC = 0x1, /**< Entropy coding mode is CABAC */
NV_ENC_H264_ENTROPY_CODING_MODE_CAVLC = 0x2 /**< Entropy coding mode is CAVLC */
} NV_ENC_H264_ENTROPY_CODING_MODE;
/**
* H.264 specific BDirect modes
*/
typedef enum _NV_ENC_H264_BDIRECT_MODE
{
NV_ENC_H264_BDIRECT_MODE_AUTOSELECT = 0x0, /**< BDirect mode is auto selected by the encoder driver */
NV_ENC_H264_BDIRECT_MODE_DISABLE = 0x1, /**< Disable BDirect mode */
NV_ENC_H264_BDIRECT_MODE_TEMPORAL = 0x2, /**< Temporal BDirect mode */
NV_ENC_H264_BDIRECT_MODE_SPATIAL = 0x3 /**< Spatial BDirect mode */
} NV_ENC_H264_BDIRECT_MODE;
/**
* H.264 specific FMO usage
*/
typedef enum _NV_ENC_H264_FMO_MODE
{
NV_ENC_H264_FMO_AUTOSELECT = 0x0, /**< FMO usage is auto selected by the encoder driver */
NV_ENC_H264_FMO_ENABLE = 0x1, /**< Enable FMO */
NV_ENC_H264_FMO_DISABLE = 0x2, /**< Disable FMO */
} NV_ENC_H264_FMO_MODE;
/**
* H.264 specific Adaptive Transform modes
*/
typedef enum _NV_ENC_H264_ADAPTIVE_TRANSFORM_MODE
{
NV_ENC_H264_ADAPTIVE_TRANSFORM_AUTOSELECT = 0x0, /**< Adaptive Transform 8x8 mode is auto selected by the encoder driver*/
NV_ENC_H264_ADAPTIVE_TRANSFORM_DISABLE = 0x1, /**< Adaptive Transform 8x8 mode disabled */
NV_ENC_H264_ADAPTIVE_TRANSFORM_ENABLE = 0x2, /**< Adaptive Transform 8x8 mode should be used */
} NV_ENC_H264_ADAPTIVE_TRANSFORM_MODE;
/**
* Stereo frame packing modes.
*/
typedef enum _NV_ENC_STEREO_PACKING_MODE
{
NV_ENC_STEREO_PACKING_MODE_NONE = 0x0, /**< No Stereo packing required */
NV_ENC_STEREO_PACKING_MODE_CHECKERBOARD = 0x1, /**< Checkerboard mode for packing stereo frames */
NV_ENC_STEREO_PACKING_MODE_COLINTERLEAVE = 0x2, /**< Column Interleave mode for packing stereo frames */
NV_ENC_STEREO_PACKING_MODE_ROWINTERLEAVE = 0x3, /**< Row Interleave mode for packing stereo frames */
NV_ENC_STEREO_PACKING_MODE_SIDEBYSIDE = 0x4, /**< Side-by-side mode for packing stereo frames */
NV_ENC_STEREO_PACKING_MODE_TOPBOTTOM = 0x5, /**< Top-Bottom mode for packing stereo frames */
NV_ENC_STEREO_PACKING_MODE_FRAMESEQ = 0x6 /**< Frame Sequential mode for packing stereo frames */
} NV_ENC_STEREO_PACKING_MODE;
/**
* Input Resource type
*/
typedef enum _NV_ENC_INPUT_RESOURCE_TYPE
{
NV_ENC_INPUT_RESOURCE_TYPE_DIRECTX = 0x0, /**< input resource type is a directx9 surface*/
NV_ENC_INPUT_RESOURCE_TYPE_CUDADEVICEPTR = 0x1, /**< input resource type is a cuda device pointer surface*/
NV_ENC_INPUT_RESOURCE_TYPE_CUDAARRAY = 0x2, /**< input resource type is a cuda array surface.
This array must be a 2D array and the CUDA_ARRAY3D_SURFACE_LDST
flag must have been specified when creating it. */
NV_ENC_INPUT_RESOURCE_TYPE_OPENGL_TEX = 0x3 /**< input resource type is an OpenGL texture */
} NV_ENC_INPUT_RESOURCE_TYPE;
/**
* Buffer usage
*/
typedef enum _NV_ENC_BUFFER_USAGE
{
NV_ENC_INPUT_IMAGE = 0x0, /**< Registered surface will be used for input image */
NV_ENC_OUTPUT_MOTION_VECTOR = 0x1, /**< Registered surface will be used for output of H.264 ME only mode.
This buffer usage type is not supported for HEVC ME only mode. */
NV_ENC_OUTPUT_BITSTREAM = 0x2, /**< Registered surface will be used for output bitstream in encoding */
} NV_ENC_BUFFER_USAGE;
/**
* Encoder Device type
*/
typedef enum _NV_ENC_DEVICE_TYPE
{
NV_ENC_DEVICE_TYPE_DIRECTX = 0x0, /**< encode device type is a directx9 device */
NV_ENC_DEVICE_TYPE_CUDA = 0x1, /**< encode device type is a cuda device */
NV_ENC_DEVICE_TYPE_OPENGL = 0x2 /**< encode device type is an OpenGL device.
Use of this device type is supported only on Linux */
} NV_ENC_DEVICE_TYPE;
/**
* Number of reference frames
*/
typedef enum _NV_ENC_NUM_REF_FRAMES
{
NV_ENC_NUM_REF_FRAMES_AUTOSELECT = 0x0, /**< Number of reference frames is auto selected by the encoder driver */
NV_ENC_NUM_REF_FRAMES_1 = 0x1, /**< Number of reference frames equal to 1 */
NV_ENC_NUM_REF_FRAMES_2 = 0x2, /**< Number of reference frames equal to 2 */
NV_ENC_NUM_REF_FRAMES_3 = 0x3, /**< Number of reference frames equal to 3 */
NV_ENC_NUM_REF_FRAMES_4 = 0x4, /**< Number of reference frames equal to 4 */
NV_ENC_NUM_REF_FRAMES_5 = 0x5, /**< Number of reference frames equal to 5 */
NV_ENC_NUM_REF_FRAMES_6 = 0x6, /**< Number of reference frames equal to 6 */
NV_ENC_NUM_REF_FRAMES_7 = 0x7 /**< Number of reference frames equal to 7 */
} NV_ENC_NUM_REF_FRAMES;
/**
* Encoder capabilities enumeration.
*/
typedef enum _NV_ENC_CAPS
{
/**
* Maximum number of B-Frames supported.
*/
NV_ENC_CAPS_NUM_MAX_BFRAMES,
/**
* Rate control modes supported.
* \n The API return value is a bitmask of the values in NV_ENC_PARAMS_RC_MODE.
*/
NV_ENC_CAPS_SUPPORTED_RATECONTROL_MODES,
/**
* Indicates HW support for field mode encoding.
* \n 0 : Interlaced mode encoding is not supported.
* \n 1 : Interlaced field mode encoding is supported.
* \n 2 : Interlaced frame encoding and field mode encoding are both supported.
*/
NV_ENC_CAPS_SUPPORT_FIELD_ENCODING,
/**
* Indicates HW support for monochrome mode encoding.
* \n 0 : Monochrome mode not supported.
* \n 1 : Monochrome mode supported.
*/
NV_ENC_CAPS_SUPPORT_MONOCHROME,
/**
* Indicates HW support for FMO.
* \n 0 : FMO not supported.
* \n 1 : FMO supported.
*/
NV_ENC_CAPS_SUPPORT_FMO,
/**
* Indicates HW capability for Quarter pel motion estimation.
* \n 0 : Quarter-Pel Motion Estimation not supported.
* \n 1 : Quarter-Pel Motion Estimation supported.
*/
NV_ENC_CAPS_SUPPORT_QPELMV,
/**
* H.264 specific. Indicates HW support for BDirect modes.
* \n 0 : BDirect mode encoding not supported.
* \n 1 : BDirect mode encoding supported.
*/
NV_ENC_CAPS_SUPPORT_BDIRECT_MODE,
/**
* H264 specific. Indicates HW support for CABAC entropy coding mode.
* \n 0 : CABAC entropy coding not supported.
* \n 1 : CABAC entropy coding supported.
*/
NV_ENC_CAPS_SUPPORT_CABAC,
/**
* Indicates HW support for Adaptive Transform.
* \n 0 : Adaptive Transform not supported.
* \n 1 : Adaptive Transform supported.
*/
NV_ENC_CAPS_SUPPORT_ADAPTIVE_TRANSFORM,
/**
* Indicates HW support for Multi View Coding.
* \n 0 : Multi View Coding not supported.
* \n 1 : Multi View Coding supported.
*/
NV_ENC_CAPS_SUPPORT_STEREO_MVC,
/**
* Indicates HW support for encoding Temporal layers.
* \n 0 : Encoding Temporal layers not supported.
* \n 1 : Encoding Temporal layers supported.
*/
NV_ENC_CAPS_NUM_MAX_TEMPORAL_LAYERS,
/**
* Indicates HW support for Hierarchical P frames.
* \n 0 : Hierarchical P frames not supported.
* \n 1 : Hierarchical P frames supported.
*/
NV_ENC_CAPS_SUPPORT_HIERARCHICAL_PFRAMES,
/**
* Indicates HW support for Hierarchical B frames.
* \n 0 : Hierarchical B frames not supported.
* \n 1 : Hierarchical B frames supported.
*/
NV_ENC_CAPS_SUPPORT_HIERARCHICAL_BFRAMES,
/**
* Maximum Encoding level supported (See ::NV_ENC_LEVEL for details).
*/
NV_ENC_CAPS_LEVEL_MAX,
/**
* Minimum Encoding level supported (See ::NV_ENC_LEVEL for details).
*/
NV_ENC_CAPS_LEVEL_MIN,
/**
* Indicates HW support for separate colour plane encoding.
* \n 0 : Separate colour plane encoding not supported.
* \n 1 : Separate colour plane encoding supported.
*/
NV_ENC_CAPS_SEPARATE_COLOUR_PLANE,
/**
* Maximum output width supported.
*/
NV_ENC_CAPS_WIDTH_MAX,
/**
* Maximum output height supported.
*/
NV_ENC_CAPS_HEIGHT_MAX,
/**
* Indicates Temporal Scalability Support.
* \n 0 : Temporal SVC encoding not supported.
* \n 1 : Temporal SVC encoding supported.
*/
NV_ENC_CAPS_SUPPORT_TEMPORAL_SVC,
/**
* Indicates Dynamic Encode Resolution Change Support.
* Support added from NvEncodeAPI version 2.0.
* \n 0 : Dynamic Encode Resolution Change not supported.
* \n 1 : Dynamic Encode Resolution Change supported.
*/
NV_ENC_CAPS_SUPPORT_DYN_RES_CHANGE,
/**
* Indicates Dynamic Encode Bitrate Change Support.
* Support added from NvEncodeAPI version 2.0.
* \n 0 : Dynamic Encode bitrate change not supported.
* \n 1 : Dynamic Encode bitrate change supported.
*/
NV_ENC_CAPS_SUPPORT_DYN_BITRATE_CHANGE,
/**
* Indicates Forcing Constant QP On The Fly Support.
* Support added from NvEncodeAPI version 2.0.
* \n 0 : Forcing constant QP on the fly not supported.
* \n 1 : Forcing constant QP on the fly supported.
*/
NV_ENC_CAPS_SUPPORT_DYN_FORCE_CONSTQP,
/**
* Indicates Dynamic rate control mode Change Support.
* \n 0 : Dynamic rate control mode change not supported.
* \n 1 : Dynamic rate control mode change supported.
*/
NV_ENC_CAPS_SUPPORT_DYN_RCMODE_CHANGE,
/**
* Indicates Subframe readback support for slice-based encoding. If this feature is supported, it can be enabled by setting enableSubFrameWrite = 1.
* \n 0 : Subframe readback not supported.
* \n 1 : Subframe readback supported.
*/
NV_ENC_CAPS_SUPPORT_SUBFRAME_READBACK,
/**
* Indicates Constrained Encoding mode support.
* Support added from NvEncodeAPI version 2.0.
* \n 0 : Constrained encoding mode not supported.
* \n 1 : Constrained encoding mode supported.
* If this mode is supported client can enable this during initialization.
* Client can then force a picture to be coded as constrained picture where
* in-loop filtering is disabled across slice boundaries and prediction vectors for inter
* macroblocks in each slice will be restricted to the slice region.
*/
NV_ENC_CAPS_SUPPORT_CONSTRAINED_ENCODING,
/**
* Indicates Intra Refresh Mode Support.
* Support added from NvEncodeAPI version 2.0.
* \n 0 : Intra Refresh Mode not supported.
* \n 1 : Intra Refresh Mode supported.
*/
NV_ENC_CAPS_SUPPORT_INTRA_REFRESH,
/**
* Indicates Custom VBV Buffer Size support. It can be used for capping frame size.
* Support added from NvEncodeAPI version 2.0.
* \n 0 : Custom VBV buffer size specification from client, not supported.
* \n 1 : Custom VBV buffer size specification from client, supported.
*/
NV_ENC_CAPS_SUPPORT_CUSTOM_VBV_BUF_SIZE,
/**
* Indicates Dynamic Slice Mode Support.
* Support added from NvEncodeAPI version 2.0.
* \n 0 : Dynamic Slice Mode not supported.
* \n 1 : Dynamic Slice Mode supported.
*/
NV_ENC_CAPS_SUPPORT_DYNAMIC_SLICE_MODE,
/**
* Indicates Reference Picture Invalidation Support.
* Support added from NvEncodeAPI version 2.0.
* \n 0 : Reference Picture Invalidation not supported.
* \n 1 : Reference Picture Invalidation supported.
*/
NV_ENC_CAPS_SUPPORT_REF_PIC_INVALIDATION,
/**
* Indicates support for Pre-Processing.
* The API return value is a bitmask of the values defined in ::NV_ENC_PREPROC_FLAGS
*/
NV_ENC_CAPS_PREPROC_SUPPORT,
/**
* Indicates support Async mode.
* \n 0 : Async Encode mode not supported.
* \n 1 : Async Encode mode supported.
*/
NV_ENC_CAPS_ASYNC_ENCODE_SUPPORT,
/**
* Maximum MBs per frame supported.
*/
NV_ENC_CAPS_MB_NUM_MAX,
/**
* Maximum aggregate throughput in MBs per sec.
*/
NV_ENC_CAPS_MB_PER_SEC_MAX,
/**
* Indicates HW support for YUV444 mode encoding.
* \n 0 : YUV444 mode encoding not supported.
* \n 1 : YUV444 mode encoding supported.
*/
NV_ENC_CAPS_SUPPORT_YUV444_ENCODE,
/**
* Indicates HW support for lossless encoding.
* \n 0 : lossless encoding not supported.
* \n 1 : lossless encoding supported.
*/
NV_ENC_CAPS_SUPPORT_LOSSLESS_ENCODE,
/**
* Indicates HW support for Sample Adaptive Offset.
* \n 0 : SAO not supported.
* \n 1 : SAO encoding supported.
*/
NV_ENC_CAPS_SUPPORT_SAO,
/**
* Indicates HW support for Motion Estimation Only Mode.
* \n 0 : MEOnly Mode not supported.
* \n 1 : MEOnly Mode supported for I and P frames.
* \n 2 : MEOnly Mode supported for I, P and B frames.
*/
NV_ENC_CAPS_SUPPORT_MEONLY_MODE,
/**
* Indicates HW support for lookahead encoding (enableLookahead=1).
* \n 0 : Lookahead not supported.
* \n 1 : Lookahead supported.
*/
NV_ENC_CAPS_SUPPORT_LOOKAHEAD,
/**
* Indicates HW support for temporal AQ encoding (enableTemporalAQ=1).
* \n 0 : Temporal AQ not supported.
* \n 1 : Temporal AQ supported.
*/
NV_ENC_CAPS_SUPPORT_TEMPORAL_AQ,
/**
* Indicates HW support for 10 bit encoding.
* \n 0 : 10 bit encoding not supported.
* \n 1 : 10 bit encoding supported.
*/
NV_ENC_CAPS_SUPPORT_10BIT_ENCODE,
/**
* Maximum number of Long Term Reference frames supported
*/
NV_ENC_CAPS_NUM_MAX_LTR_FRAMES,
/**
* Indicates HW support for Weighted Prediction.
* \n 0 : Weighted Prediction not supported.
* \n 1 : Weighted Prediction supported.
*/
NV_ENC_CAPS_SUPPORT_WEIGHTED_PREDICTION,
/**
* On managed (vGPU) platforms (Windows only), this API, in conjunction with other GRID Management APIs, can be used
* to estimate the residual capacity of the hardware encoder on the GPU as a percentage of the total available encoder capacity.
* This API can be called at any time; i.e. during the encode session or before opening the encode session.
* If the available encoder capacity is returned as zero, applications may choose to switch to software encoding
* and continue to call this API (e.g. polling once per second) until capacity becomes available.
*
* On bare metal (non-virtualized GPU) and linux platforms, this API always returns 100.
*/
NV_ENC_CAPS_DYNAMIC_QUERY_ENCODER_CAPACITY,
/**
* Indicates B as reference support.
* \n 0 : B as reference is not supported.
* \n 1 : each B-Frame as reference is supported.
* \n 2 : only Middle B-frame as reference is supported.
*/
NV_ENC_CAPS_SUPPORT_BFRAME_REF_MODE,
/**
* Indicates HW support for Emphasis Level Map based delta QP computation.
* \n 0 : Emphasis Level Map based delta QP not supported.
* \n 1 : Emphasis Level Map based delta QP is supported.
*/
NV_ENC_CAPS_SUPPORT_EMPHASIS_LEVEL_MAP,
/**
* Minimum input width supported.
*/
NV_ENC_CAPS_WIDTH_MIN,
/**
* Minimum input height supported.
*/
NV_ENC_CAPS_HEIGHT_MIN,
/**
* Indicates HW support for multiple reference frames.
*/
NV_ENC_CAPS_SUPPORT_MULTIPLE_REF_FRAMES,
/**
* Indicates HW support for HEVC with alpha encoding.
* \n 0 : HEVC with alpha encoding not supported.
* \n 1 : HEVC with alpha encoding is supported.
*/
NV_ENC_CAPS_SUPPORT_ALPHA_LAYER_ENCODING,
/**
* Indicates number of Encoding engines present on GPU.
*/
NV_ENC_CAPS_NUM_ENCODER_ENGINES,
/**
* Indicates single slice intra refresh support.
*/
NV_ENC_CAPS_SINGLE_SLICE_INTRA_REFRESH,
/**
* Reserved - Not to be used by clients.
*/
NV_ENC_CAPS_EXPOSED_COUNT
} NV_ENC_CAPS;
/**
* HEVC CU SIZE
*/
typedef enum _NV_ENC_HEVC_CUSIZE
{
NV_ENC_HEVC_CUSIZE_AUTOSELECT = 0,
NV_ENC_HEVC_CUSIZE_8x8 = 1,
NV_ENC_HEVC_CUSIZE_16x16 = 2,
NV_ENC_HEVC_CUSIZE_32x32 = 3,
NV_ENC_HEVC_CUSIZE_64x64 = 4,
}NV_ENC_HEVC_CUSIZE;
/**
* AV1 PART SIZE
*/
typedef enum _NV_ENC_AV1_PART_SIZE
{
NV_ENC_AV1_PART_SIZE_AUTOSELECT = 0,
NV_ENC_AV1_PART_SIZE_4x4 = 1,
NV_ENC_AV1_PART_SIZE_8x8 = 2,
NV_ENC_AV1_PART_SIZE_16x16 = 3,
NV_ENC_AV1_PART_SIZE_32x32 = 4,
NV_ENC_AV1_PART_SIZE_64x64 = 5,
}NV_ENC_AV1_PART_SIZE;
/**
* Enums related to fields in VUI parameters.
*/
typedef enum _NV_ENC_VUI_VIDEO_FORMAT
{
NV_ENC_VUI_VIDEO_FORMAT_COMPONENT = 0,
NV_ENC_VUI_VIDEO_FORMAT_PAL = 1,
NV_ENC_VUI_VIDEO_FORMAT_NTSC = 2,
NV_ENC_VUI_VIDEO_FORMAT_SECAM = 3,
NV_ENC_VUI_VIDEO_FORMAT_MAC = 4,
NV_ENC_VUI_VIDEO_FORMAT_UNSPECIFIED = 5,
}NV_ENC_VUI_VIDEO_FORMAT;
typedef enum _NV_ENC_VUI_COLOR_PRIMARIES
{
NV_ENC_VUI_COLOR_PRIMARIES_UNDEFINED = 0,
NV_ENC_VUI_COLOR_PRIMARIES_BT709 = 1,
NV_ENC_VUI_COLOR_PRIMARIES_UNSPECIFIED = 2,
NV_ENC_VUI_COLOR_PRIMARIES_RESERVED = 3,
NV_ENC_VUI_COLOR_PRIMARIES_BT470M = 4,
NV_ENC_VUI_COLOR_PRIMARIES_BT470BG = 5,
NV_ENC_VUI_COLOR_PRIMARIES_SMPTE170M = 6,
NV_ENC_VUI_COLOR_PRIMARIES_SMPTE240M = 7,
NV_ENC_VUI_COLOR_PRIMARIES_FILM = 8,
NV_ENC_VUI_COLOR_PRIMARIES_BT2020 = 9,
NV_ENC_VUI_COLOR_PRIMARIES_SMPTE428 = 10,
NV_ENC_VUI_COLOR_PRIMARIES_SMPTE431 = 11,
NV_ENC_VUI_COLOR_PRIMARIES_SMPTE432 = 12,
NV_ENC_VUI_COLOR_PRIMARIES_JEDEC_P22 = 22,
}NV_ENC_VUI_COLOR_PRIMARIES;
typedef enum _NV_ENC_VUI_TRANSFER_CHARACTERISTIC
{
NV_ENC_VUI_TRANSFER_CHARACTERISTIC_UNDEFINED = 0,
NV_ENC_VUI_TRANSFER_CHARACTERISTIC_BT709 = 1,
NV_ENC_VUI_TRANSFER_CHARACTERISTIC_UNSPECIFIED = 2,
NV_ENC_VUI_TRANSFER_CHARACTERISTIC_RESERVED = 3,
NV_ENC_VUI_TRANSFER_CHARACTERISTIC_BT470M = 4,
NV_ENC_VUI_TRANSFER_CHARACTERISTIC_BT470BG = 5,
NV_ENC_VUI_TRANSFER_CHARACTERISTIC_SMPTE170M = 6,
NV_ENC_VUI_TRANSFER_CHARACTERISTIC_SMPTE240M = 7,
NV_ENC_VUI_TRANSFER_CHARACTERISTIC_LINEAR = 8,
NV_ENC_VUI_TRANSFER_CHARACTERISTIC_LOG = 9,
NV_ENC_VUI_TRANSFER_CHARACTERISTIC_LOG_SQRT = 10,
NV_ENC_VUI_TRANSFER_CHARACTERISTIC_IEC61966_2_4 = 11,
NV_ENC_VUI_TRANSFER_CHARACTERISTIC_BT1361_ECG = 12,
NV_ENC_VUI_TRANSFER_CHARACTERISTIC_SRGB = 13,
NV_ENC_VUI_TRANSFER_CHARACTERISTIC_BT2020_10 = 14,
NV_ENC_VUI_TRANSFER_CHARACTERISTIC_BT2020_12 = 15,
NV_ENC_VUI_TRANSFER_CHARACTERISTIC_SMPTE2084 = 16,
NV_ENC_VUI_TRANSFER_CHARACTERISTIC_SMPTE428 = 17,
NV_ENC_VUI_TRANSFER_CHARACTERISTIC_ARIB_STD_B67 = 18,
}NV_ENC_VUI_TRANSFER_CHARACTERISTIC;
typedef enum _NV_ENC_VUI_MATRIX_COEFFS
{
NV_ENC_VUI_MATRIX_COEFFS_RGB = 0,
NV_ENC_VUI_MATRIX_COEFFS_BT709 = 1,
NV_ENC_VUI_MATRIX_COEFFS_UNSPECIFIED = 2,
NV_ENC_VUI_MATRIX_COEFFS_RESERVED = 3,
NV_ENC_VUI_MATRIX_COEFFS_FCC = 4,
NV_ENC_VUI_MATRIX_COEFFS_BT470BG = 5,
NV_ENC_VUI_MATRIX_COEFFS_SMPTE170M = 6,
NV_ENC_VUI_MATRIX_COEFFS_SMPTE240M = 7,
NV_ENC_VUI_MATRIX_COEFFS_YCGCO = 8,
NV_ENC_VUI_MATRIX_COEFFS_BT2020_NCL = 9,
NV_ENC_VUI_MATRIX_COEFFS_BT2020_CL = 10,
NV_ENC_VUI_MATRIX_COEFFS_SMPTE2085 = 11,
}NV_ENC_VUI_MATRIX_COEFFS;
/**
* Input struct for querying Encoding capabilities.
*/
typedef struct _NV_ENC_CAPS_PARAM
{
uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_CAPS_PARAM_VER */
NV_ENC_CAPS capsToQuery; /**< [in]: Specifies the encode capability to be queried. Client should pass a member for ::NV_ENC_CAPS enum. */
uint32_t reserved[62]; /**< [in]: Reserved and must be set to 0 */
} NV_ENC_CAPS_PARAM;
/** NV_ENC_CAPS_PARAM struct version. */
#define NV_ENC_CAPS_PARAM_VER NVENCAPI_STRUCT_VERSION(1)
/**
* Encoder Output parameters
*/
typedef struct _NV_ENC_ENCODE_OUT_PARAMS
{
uint32_t version; /**< [out]: Struct version. */
uint32_t bitstreamSizeInBytes; /**< [out]: Encoded bitstream size in bytes */
uint32_t reserved[62]; /**< [out]: Reserved and must be set to 0 */
} NV_ENC_ENCODE_OUT_PARAMS;
/** NV_ENC_ENCODE_OUT_PARAMS struct version. */
#define NV_ENC_ENCODE_OUT_PARAMS_VER NVENCAPI_STRUCT_VERSION(1)
/**
* Creation parameters for input buffer.
*/
typedef struct _NV_ENC_CREATE_INPUT_BUFFER
{
uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_CREATE_INPUT_BUFFER_VER */
uint32_t width; /**< [in]: Input frame width */
uint32_t height; /**< [in]: Input frame height */
NV_ENC_MEMORY_HEAP memoryHeap; /**< [in]: Deprecated. Do not use */
NV_ENC_BUFFER_FORMAT bufferFmt; /**< [in]: Input buffer format */
uint32_t reserved; /**< [in]: Reserved and must be set to 0 */
NV_ENC_INPUT_PTR inputBuffer; /**< [out]: Pointer to input buffer */
void* pSysMemBuffer; /**< [in]: Pointer to existing system memory buffer */
uint32_t reserved1[57]; /**< [in]: Reserved and must be set to 0 */
void* reserved2[63]; /**< [in]: Reserved and must be set to NULL */
} NV_ENC_CREATE_INPUT_BUFFER;
/** NV_ENC_CREATE_INPUT_BUFFER struct version. */
#define NV_ENC_CREATE_INPUT_BUFFER_VER NVENCAPI_STRUCT_VERSION(1)
/**
* Creation parameters for output bitstream buffer.
*/
typedef struct _NV_ENC_CREATE_BITSTREAM_BUFFER
{
uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_CREATE_BITSTREAM_BUFFER_VER */
uint32_t size; /**< [in]: Deprecated. Do not use */
NV_ENC_MEMORY_HEAP memoryHeap; /**< [in]: Deprecated. Do not use */
uint32_t reserved; /**< [in]: Reserved and must be set to 0 */
NV_ENC_OUTPUT_PTR bitstreamBuffer; /**< [out]: Pointer to the output bitstream buffer */
void* bitstreamBufferPtr; /**< [out]: Reserved and should not be used */
uint32_t reserved1[58]; /**< [in]: Reserved and should be set to 0 */
void* reserved2[64]; /**< [in]: Reserved and should be set to NULL */
} NV_ENC_CREATE_BITSTREAM_BUFFER;
/** NV_ENC_CREATE_BITSTREAM_BUFFER struct version. */
#define NV_ENC_CREATE_BITSTREAM_BUFFER_VER NVENCAPI_STRUCT_VERSION(1)
/**
* Structs needed for ME only mode.
*/
typedef struct _NV_ENC_MVECTOR
{
int16_t mvx; /**< the x component of MV in quarter-pel units */
int16_t mvy; /**< the y component of MV in quarter-pel units */
} NV_ENC_MVECTOR;
/**
* Motion vector structure per macroblock for H264 motion estimation.
*/
typedef struct _NV_ENC_H264_MV_DATA
{
NV_ENC_MVECTOR mv[4]; /**< up to 4 vectors for 8x8 partition */
uint8_t mbType; /**< 0 (I), 1 (P), 2 (IPCM), 3 (B) */
uint8_t partitionType; /**< Specifies the block partition type. 0:16x16, 1:8x8, 2:16x8, 3:8x16 */
uint16_t reserved; /**< reserved padding for alignment */
uint32_t mbCost;
} NV_ENC_H264_MV_DATA;
/**
* Motion vector structure per CU for HEVC motion estimation.
*/
typedef struct _NV_ENC_HEVC_MV_DATA
{
NV_ENC_MVECTOR mv[4]; /**< up to 4 vectors within a CU */
uint8_t cuType; /**< 0 (I), 1(P) */
uint8_t cuSize; /**< 0: 8x8, 1: 16x16, 2: 32x32, 3: 64x64 */
uint8_t partitionMode; /**< The CU partition mode
0 (2Nx2N), 1 (2NxN), 2(Nx2N), 3 (NxN),
4 (2NxnU), 5 (2NxnD), 6(nLx2N), 7 (nRx2N) */
uint8_t lastCUInCTB; /**< Marker to separate CUs in the current CTB from CUs in the next CTB */
} NV_ENC_HEVC_MV_DATA;
/**
* Creation parameters for output motion vector buffer for ME only mode.
*/
typedef struct _NV_ENC_CREATE_MV_BUFFER
{
uint32_t version; /**< [in]: Struct version. Must be set to NV_ENC_CREATE_MV_BUFFER_VER */
NV_ENC_OUTPUT_PTR mvBuffer; /**< [out]: Pointer to the output motion vector buffer */
uint32_t reserved1[255]; /**< [in]: Reserved and should be set to 0 */
void* reserved2[63]; /**< [in]: Reserved and should be set to NULL */
} NV_ENC_CREATE_MV_BUFFER;
/** NV_ENC_CREATE_MV_BUFFER struct version*/
#define NV_ENC_CREATE_MV_BUFFER_VER NVENCAPI_STRUCT_VERSION(1)
/**
* QP value for frames
*/
typedef struct _NV_ENC_QP
{
uint32_t qpInterP; /**< [in]: Specifies QP value for P-frame. Even though this field is uint32_t for legacy reasons, the client should treat this as a signed parameter(int32_t) for cases in which negative QP values are to be specified. */
uint32_t qpInterB; /**< [in]: Specifies QP value for B-frame. Even though this field is uint32_t for legacy reasons, the client should treat this as a signed parameter(int32_t) for cases in which negative QP values are to be specified. */
uint32_t qpIntra; /**< [in]: Specifies QP value for Intra Frame. Even though this field is uint32_t for legacy reasons, the client should treat this as a signed parameter(int32_t) for cases in which negative QP values are to be specified. */
} NV_ENC_QP;
/**
* Rate Control Configuration Parameters
*/
typedef struct _NV_ENC_RC_PARAMS
{
uint32_t version;
NV_ENC_PARAMS_RC_MODE rateControlMode; /**< [in]: Specifies the rate control mode. Check support for various rate control modes using ::NV_ENC_CAPS_SUPPORTED_RATECONTROL_MODES caps. */
NV_ENC_QP constQP; /**< [in]: Specifies the initial QP to be used for encoding, these values would be used for all frames if in Constant QP mode. */
uint32_t averageBitRate; /**< [in]: Specifies the average bitrate(in bits/sec) used for encoding. */
uint32_t maxBitRate; /**< [in]: Specifies the maximum bitrate for the encoded output. This is used for VBR and ignored for CBR mode. */
uint32_t vbvBufferSize; /**< [in]: Specifies the VBV(HRD) buffer size. in bits. Set 0 to use the default VBV buffer size. */
uint32_t vbvInitialDelay; /**< [in]: Specifies the VBV(HRD) initial delay in bits. Set 0 to use the default VBV initial delay .*/
uint32_t enableMinQP :1; /**< [in]: Set this to 1 if minimum QP used for rate control. */
uint32_t enableMaxQP :1; /**< [in]: Set this to 1 if maximum QP used for rate control. */
uint32_t enableInitialRCQP :1; /**< [in]: Set this to 1 if user supplied initial QP is used for rate control. */
uint32_t enableAQ :1; /**< [in]: Set this to 1 to enable adaptive quantization (Spatial). */
uint32_t reservedBitField1 :1; /**< [in]: Reserved bitfields and must be set to 0. */
uint32_t enableLookahead :1; /**< [in]: Set this to 1 to enable lookahead with depth (if lookahead is enabled, input frames must remain available to the encoder until encode completion) */
uint32_t disableIadapt :1; /**< [in]: Set this to 1 to disable adaptive I-frame insertion at scene cuts (only has an effect when lookahead is enabled) */
uint32_t disableBadapt :1; /**< [in]: Set this to 1 to disable adaptive B-frame decision (only has an effect when lookahead is enabled) */
uint32_t enableTemporalAQ :1; /**< [in]: Set this to 1 to enable temporal AQ */
uint32_t zeroReorderDelay :1; /**< [in]: Set this to 1 to indicate zero latency operation (no reordering delay, num_reorder_frames=0) */
uint32_t enableNonRefP :1; /**< [in]: Set this to 1 to enable automatic insertion of non-reference P-frames (no effect if enablePTD=0) */
uint32_t strictGOPTarget :1; /**< [in]: Set this to 1 to minimize GOP-to-GOP rate fluctuations */
uint32_t aqStrength :4; /**< [in]: When AQ (Spatial) is enabled (i.e. NV_ENC_RC_PARAMS::enableAQ is set), this field is used to specify AQ strength. AQ strength scale is from 1 (low) - 15 (aggressive).
If not set, strength is auto selected by driver. */
uint32_t reservedBitFields :16; /**< [in]: Reserved bitfields and must be set to 0 */
NV_ENC_QP minQP; /**< [in]: Specifies the minimum QP used for rate control. Client must set NV_ENC_CONFIG::enableMinQP to 1. */
NV_ENC_QP maxQP; /**< [in]: Specifies the maximum QP used for rate control. Client must set NV_ENC_CONFIG::enableMaxQP to 1. */
NV_ENC_QP initialRCQP; /**< [in]: Specifies the initial QP used for rate control. Client must set NV_ENC_CONFIG::enableInitialRCQP to 1. */
uint32_t temporallayerIdxMask; /**< [in]: Specifies the temporal layers (as a bitmask) whose QPs have changed. Valid max bitmask is [2^NV_ENC_CAPS_NUM_MAX_TEMPORAL_LAYERS - 1].
Applicable only for constant QP mode (NV_ENC_RC_PARAMS::rateControlMode = NV_ENC_PARAMS_RC_CONSTQP). */
uint8_t temporalLayerQP[8]; /**< [in]: Specifies the temporal layer QPs used for rate control. Temporal layer index is used as the array index.
Applicable only for constant QP mode (NV_ENC_RC_PARAMS::rateControlMode = NV_ENC_PARAMS_RC_CONSTQP). */
uint8_t targetQuality; /**< [in]: Target CQ (Constant Quality) level for VBR mode (range 0-51 with 0-automatic) */
uint8_t targetQualityLSB; /**< [in]: Fractional part of target quality (as 8.8 fixed point format) */
uint16_t lookaheadDepth; /**< [in]: Maximum depth of lookahead with range 0-(31 - number of B frames).
lookaheadDepth is only used if enableLookahead=1.*/
uint8_t lowDelayKeyFrameScale; /**< [in]: Specifies the ratio of I frame bits to P frame bits in case of single frame VBV and CBR rate control mode,
is set to 2 by default for low latency tuning info and 1 by default for ultra low latency tuning info */
int8_t yDcQPIndexOffset; /**< [in]: Specifies the value of 'deltaQ_y_dc' in AV1.*/
int8_t uDcQPIndexOffset; /**< [in]: Specifies the value of 'deltaQ_u_dc' in AV1.*/
int8_t vDcQPIndexOffset; /**< [in]: Specifies the value of 'deltaQ_v_dc' in AV1 (for future use only - deltaQ_v_dc is currently always internally set to same value as deltaQ_u_dc). */
NV_ENC_QP_MAP_MODE qpMapMode; /**< [in]: This flag is used to interpret values in array specified by NV_ENC_PIC_PARAMS::qpDeltaMap.
Set this to NV_ENC_QP_MAP_EMPHASIS to treat values specified by NV_ENC_PIC_PARAMS::qpDeltaMap as Emphasis Level Map.
Emphasis Level can be assigned any value specified in enum NV_ENC_EMPHASIS_MAP_LEVEL.
Emphasis Level Map is used to specify regions to be encoded at varying levels of quality.
The hardware encoder adjusts the quantization within the image as per the provided emphasis map,
by adjusting the quantization parameter (QP) assigned to each macroblock. This adjustment is commonly called "Delta QP".
The adjustment depends on the absolute QP decided by the rate control algorithm, and is applied after the rate control has decided each macroblock's QP.
Since the Delta QP overrides rate control, enabling Emphasis Level Map may violate bitrate and VBV buffer size constraints.
Emphasis Level Map is useful in situations where client has a priori knowledge of the image complexity (e.g. via use of NVFBC's Classification feature) and encoding those high-complexity areas at higher quality (lower QP) is important, even at the possible cost of violating bitrate/VBV buffer size constraints
This feature is not supported when AQ( Spatial/Temporal) is enabled.
This feature is only supported for H264 codec currently.
Set this to NV_ENC_QP_MAP_DELTA to treat values specified by NV_ENC_PIC_PARAMS::qpDeltaMap as QP Delta. This specifies QP modifier to be applied on top of the QP chosen by rate control
Set this to NV_ENC_QP_MAP_DISABLED to ignore NV_ENC_PIC_PARAMS::qpDeltaMap values. In this case, qpDeltaMap should be set to NULL.
Other values are reserved for future use.*/
NV_ENC_MULTI_PASS multiPass; /**< [in]: This flag is used to enable multi-pass encoding for a given ::NV_ENC_PARAMS_RC_MODE. This flag is not valid for H264 and HEVC MEOnly mode */
uint32_t alphaLayerBitrateRatio; /**< [in]: Specifies the ratio in which bitrate should be split between base and alpha layer. A value 'x' for this field will split the target bitrate in a ratio of x : 1 between base and alpha layer.
The default split ratio is 15.*/
int8_t cbQPIndexOffset; /**< [in]: Specifies the value of 'chroma_qp_index_offset' in H264 / 'pps_cb_qp_offset' in HEVC / 'deltaQ_u_ac' in AV1.*/
int8_t crQPIndexOffset; /**< [in]: Specifies the value of 'second_chroma_qp_index_offset' in H264 / 'pps_cr_qp_offset' in HEVC / 'deltaQ_v_ac' in AV1 (for future use only - deltaQ_v_ac is currently always internally set to same value as deltaQ_u_ac). */
uint16_t reserved2;
uint32_t reserved[4];
} NV_ENC_RC_PARAMS;
/** macro for constructing the version field of ::_NV_ENC_RC_PARAMS */
#define NV_ENC_RC_PARAMS_VER NVENCAPI_STRUCT_VERSION(1)
#define MAX_NUM_CLOCK_TS 3
/**
* Clock Timestamp set parameters
* For H264, this structure is used to populate Picture Timing SEI when NV_ENC_CONFIG_H264::enableTimeCode is set to 1.
* For HEVC, this structure is used to populate Time Code SEI when NV_ENC_CONFIG_HEVC::enableTimeCodeSEI is set to 1.
* For more details, refer to Annex D of ITU-T Specification.
*/
typedef struct _NV_ENC_CLOCK_TIMESTAMP_SET
{
uint32_t countingType : 1; /**< [in] Specifies the 'counting_type' */
uint32_t discontinuityFlag : 1; /**< [in] Specifies the 'discontinuity_flag' */
uint32_t cntDroppedFrames : 1; /**< [in] Specifies the 'cnt_dropped_flag' */
uint32_t nFrames : 8; /**< [in] Specifies the value of 'n_frames' */
uint32_t secondsValue : 6; /**< [in] Specifies the 'seconds_value' */
uint32_t minutesValue : 6; /**< [in] Specifies the 'minutes_value' */
uint32_t hoursValue : 5; /**< [in] Specifies the 'hours_value' */
uint32_t reserved2 : 4; /**< [in] Reserved and must be set to 0 */
uint32_t timeOffset; /**< [in] Specifies the 'time_offset_value' */
} NV_ENC_CLOCK_TIMESTAMP_SET;
typedef struct _NV_ENC_TIME_CODE
{
NV_ENC_DISPLAY_PIC_STRUCT displayPicStruct; /**< [in] Display picStruct */
NV_ENC_CLOCK_TIMESTAMP_SET clockTimestamp[MAX_NUM_CLOCK_TS]; /**< [in] Clock Timestamp set */
} NV_ENC_TIME_CODE;
/**
* \struct _NV_ENC_CONFIG_H264_VUI_PARAMETERS
* H264 Video Usability Info parameters
*/
typedef struct _NV_ENC_CONFIG_H264_VUI_PARAMETERS
{
uint32_t overscanInfoPresentFlag; /**< [in]: If set to 1 , it specifies that the overscanInfo is present */
uint32_t overscanInfo; /**< [in]: Specifies the overscan info(as defined in Annex E of the ITU-T Specification). */
uint32_t videoSignalTypePresentFlag; /**< [in]: If set to 1, it specifies that the videoFormat, videoFullRangeFlag and colourDescriptionPresentFlag are present. */
NV_ENC_VUI_VIDEO_FORMAT videoFormat; /**< [in]: Specifies the source video format(as defined in Annex E of the ITU-T Specification).*/
uint32_t videoFullRangeFlag; /**< [in]: Specifies the output range of the luma and chroma samples(as defined in Annex E of the ITU-T Specification). */
uint32_t colourDescriptionPresentFlag; /**< [in]: If set to 1, it specifies that the colourPrimaries, transferCharacteristics and colourMatrix are present. */
NV_ENC_VUI_COLOR_PRIMARIES colourPrimaries; /**< [in]: Specifies color primaries for converting to RGB(as defined in Annex E of the ITU-T Specification) */
NV_ENC_VUI_TRANSFER_CHARACTERISTIC transferCharacteristics; /**< [in]: Specifies the opto-electronic transfer characteristics to use (as defined in Annex E of the ITU-T Specification) */
NV_ENC_VUI_MATRIX_COEFFS colourMatrix; /**< [in]: Specifies the matrix coefficients used in deriving the luma and chroma from the RGB primaries (as defined in Annex E of the ITU-T Specification). */
uint32_t chromaSampleLocationFlag; /**< [in]: If set to 1 , it specifies that the chromaSampleLocationTop and chromaSampleLocationBot are present.*/
uint32_t chromaSampleLocationTop; /**< [in]: Specifies the chroma sample location for top field(as defined in Annex E of the ITU-T Specification) */
uint32_t chromaSampleLocationBot; /**< [in]: Specifies the chroma sample location for bottom field(as defined in Annex E of the ITU-T Specification) */
uint32_t bitstreamRestrictionFlag; /**< [in]: If set to 1, it specifies the bitstream restriction parameters are present in the bitstream.*/
uint32_t timingInfoPresentFlag; /**< [in]: If set to 1, it specifies that the timingInfo is present and the 'numUnitInTicks' and 'timeScale' fields are specified by the application. */
/**< [in]: If not set, the timingInfo may still be present with timing related fields calculated internally basedon the frame rate specified by the application. */
uint32_t numUnitInTicks; /**< [in]: Specifies the number of time units of the clock(as defined in Annex E of the ITU-T Specification). */
uint32_t timeScale; /**< [in]: Specifies the frquency of the clock(as defined in Annex E of the ITU-T Specification). */
uint32_t reserved[12]; /**< [in]: Reserved and must be set to 0 */
}NV_ENC_CONFIG_H264_VUI_PARAMETERS;
typedef NV_ENC_CONFIG_H264_VUI_PARAMETERS NV_ENC_CONFIG_HEVC_VUI_PARAMETERS;
/**
* \struct _NVENC_EXTERNAL_ME_HINT_COUNTS_PER_BLOCKTYPE
* External motion vector hint counts per block type.
* H264 and AV1 support multiple hint while HEVC supports one hint for each valid candidate.
*/
typedef struct _NVENC_EXTERNAL_ME_HINT_COUNTS_PER_BLOCKTYPE
{
uint32_t numCandsPerBlk16x16 : 4; /**< [in]: Supported for H264, HEVC. It Specifies the number of candidates per 16x16 block. */
uint32_t numCandsPerBlk16x8 : 4; /**< [in]: Supported for H264 only. Specifies the number of candidates per 16x8 block. */
uint32_t numCandsPerBlk8x16 : 4; /**< [in]: Supported for H264 only. Specifies the number of candidates per 8x16 block. */
uint32_t numCandsPerBlk8x8 : 4; /**< [in]: Supported for H264, HEVC. Specifies the number of candidates per 8x8 block. */
uint32_t numCandsPerSb : 8; /**< [in]: Supported for AV1 only. Specifies the number of candidates per SB. */
uint32_t reserved : 8; /**< [in]: Reserved for padding. */
uint32_t reserved1[3]; /**< [in]: Reserved for future use. */
} NVENC_EXTERNAL_ME_HINT_COUNTS_PER_BLOCKTYPE;
/**
* \struct _NVENC_EXTERNAL_ME_HINT
* External Motion Vector hint structure for H264 and HEVC.
*/
typedef struct _NVENC_EXTERNAL_ME_HINT
{
int32_t mvx : 12; /**< [in]: Specifies the x component of integer pixel MV (relative to current MB) S12.0. */
int32_t mvy : 10; /**< [in]: Specifies the y component of integer pixel MV (relative to current MB) S10.0 .*/
int32_t refidx : 5; /**< [in]: Specifies the reference index (31=invalid). Current we support only 1 reference frame per direction for external hints, so \p refidx must be 0. */
int32_t dir : 1; /**< [in]: Specifies the direction of motion estimation . 0=L0 1=L1.*/
int32_t partType : 2; /**< [in]: Specifies the block partition type.0=16x16 1=16x8 2=8x16 3=8x8 (blocks in partition must be consecutive).*/
int32_t lastofPart : 1; /**< [in]: Set to 1 for the last MV of (sub) partition */
int32_t lastOfMB : 1; /**< [in]: Set to 1 for the last MV of macroblock. */
} NVENC_EXTERNAL_ME_HINT;
/**
* \struct _NVENC_EXTERNAL_ME_SB_HINT
* External Motion Vector SB hint structure for AV1
*/
typedef struct _NVENC_EXTERNAL_ME_SB_HINT
{
int16_t refidx : 5; /**< [in]: Specifies the reference index (31=invalid) */
int16_t direction : 1; /**< [in]: Specifies the direction of motion estimation . 0=L0 1=L1.*/
int16_t bi : 1; /**< [in]: Specifies reference mode 0=single mv, 1=compound mv */
int16_t partition_type : 3; /**< [in]: Specifies the partition type: 0: 2NX2N, 1:2NxN, 2:Nx2N. reserved 3bits for future modes */
int16_t x8 : 3; /**< [in]: Specifies the current partition's top left x position in 8 pixel unit */
int16_t last_of_cu : 1; /**< [in]: Set to 1 for the last MV current CU */
int16_t last_of_sb : 1; /**< [in]: Set to 1 for the last MV of current SB */
int16_t reserved0 : 1; /**< [in]: Reserved and must be set to 0 */
int16_t mvx : 14; /**< [in]: Specifies the x component of integer pixel MV (relative to current MB) S12.2. */
int16_t cu_size : 2; /**< [in]: Specifies the CU size: 0: 8x8, 1: 16x16, 2:32x32, 3:64x64 */
int16_t mvy : 12; /**< [in]: Specifies the y component of integer pixel MV (relative to current MB) S10.2 .*/
int16_t y8 : 3; /**< [in]: Specifies the current partition's top left y position in 8 pixel unit */
int16_t reserved1 : 1; /**< [in]: Reserved and must be set to 0 */
} NVENC_EXTERNAL_ME_SB_HINT;
/**
* \struct _NV_ENC_CONFIG_H264
* H264 encoder configuration parameters
*/
typedef struct _NV_ENC_CONFIG_H264
{
uint32_t enableTemporalSVC :1; /**< [in]: Set to 1 to enable SVC temporal*/
uint32_t enableStereoMVC :1; /**< [in]: Set to 1 to enable stereo MVC*/
uint32_t hierarchicalPFrames :1; /**< [in]: Set to 1 to enable hierarchical P Frames */
uint32_t hierarchicalBFrames :1; /**< [in]: Set to 1 to enable hierarchical B Frames */
uint32_t outputBufferingPeriodSEI :1; /**< [in]: Set to 1 to write SEI buffering period syntax in the bitstream */
uint32_t outputPictureTimingSEI :1; /**< [in]: Set to 1 to write SEI picture timing syntax in the bitstream. */
uint32_t outputAUD :1; /**< [in]: Set to 1 to write access unit delimiter syntax in bitstream */
uint32_t disableSPSPPS :1; /**< [in]: Set to 1 to disable writing of Sequence and Picture parameter info in bitstream */
uint32_t outputFramePackingSEI :1; /**< [in]: Set to 1 to enable writing of frame packing arrangement SEI messages to bitstream */
uint32_t outputRecoveryPointSEI :1; /**< [in]: Set to 1 to enable writing of recovery point SEI message */
uint32_t enableIntraRefresh :1; /**< [in]: Set to 1 to enable gradual decoder refresh or intra refresh. If the GOP structure uses B frames this will be ignored */
uint32_t enableConstrainedEncoding :1; /**< [in]: Set this to 1 to enable constrainedFrame encoding where each slice in the constrained picture is independent of other slices.
Constrained encoding works only with rectangular slices.
Check support for constrained encoding using ::NV_ENC_CAPS_SUPPORT_CONSTRAINED_ENCODING caps. */
uint32_t repeatSPSPPS :1; /**< [in]: Set to 1 to enable writing of Sequence and Picture parameter for every IDR frame */
uint32_t enableVFR :1; /**< [in]: Setting enableVFR=1 currently only sets the fixed_frame_rate_flag=0 in the VUI but otherwise
has no impact on the encoder behavior. For more details please refer to E.1 VUI syntax of H.264 standard. Note, however, that NVENC does not support VFR encoding and rate control. */
uint32_t enableLTR :1; /**< [in]: Set to 1 to enable LTR (Long Term Reference) frame support. LTR can be used in two modes: "LTR Trust" mode and "LTR Per Picture" mode.
LTR Trust mode: In this mode, ltrNumFrames pictures after IDR are automatically marked as LTR. This mode is enabled by setting ltrTrustMode = 1.
Use of LTR Trust mode is strongly discouraged as this mode may be deprecated in future.
LTR Per Picture mode: In this mode, client can control whether the current picture should be marked as LTR. Enable this mode by setting
ltrTrustMode = 0 and ltrMarkFrame = 1 for the picture to be marked as LTR. This is the preferred mode
for using LTR.
Note that LTRs are not supported if encoding session is configured with B-frames */
uint32_t qpPrimeYZeroTransformBypassFlag :1; /**< [in]: To enable lossless encode set this to 1, set QP to 0 and RC_mode to NV_ENC_PARAMS_RC_CONSTQP and profile to HIGH_444_PREDICTIVE_PROFILE.
Check support for lossless encoding using ::NV_ENC_CAPS_SUPPORT_LOSSLESS_ENCODE caps. */
uint32_t useConstrainedIntraPred :1; /**< [in]: Set 1 to enable constrained intra prediction. */
uint32_t enableFillerDataInsertion :1; /**< [in]: Set to 1 to enable insertion of filler data in the bitstream.
This flag will take effect only when one of the CBR rate
control modes (NV_ENC_PARAMS_RC_CBR, NV_ENC_PARAMS_RC_CBR_HQ,
NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ) is in use and both
NV_ENC_INITIALIZE_PARAMS::frameRateNum and
NV_ENC_INITIALIZE_PARAMS::frameRateDen are set to non-zero
values. Setting this field when
NV_ENC_INITIALIZE_PARAMS::enableOutputInVidmem is also set
is currently not supported and will make ::NvEncInitializeEncoder()
return an error. */
uint32_t disableSVCPrefixNalu :1; /**< [in]: Set to 1 to disable writing of SVC Prefix NALU preceding each slice in bitstream.
Applicable only when temporal SVC is enabled (NV_ENC_CONFIG_H264::enableTemporalSVC = 1). */
uint32_t enableScalabilityInfoSEI :1; /**< [in]: Set to 1 to enable writing of Scalability Information SEI message preceding each IDR picture in bitstream
Applicable only when temporal SVC is enabled (NV_ENC_CONFIG_H264::enableTemporalSVC = 1). */
uint32_t singleSliceIntraRefresh :1; /**< [in]: Set to 1 to maintain single slice in frames during intra refresh.
Check support for single slice intra refresh using ::NV_ENC_CAPS_SINGLE_SLICE_INTRA_REFRESH caps.
This flag will be ignored if the value returned for ::NV_ENC_CAPS_SINGLE_SLICE_INTRA_REFRESH caps is false. */
uint32_t enableTimeCode :1; /**< [in]: Set to 1 to enable writing of clock timestamp sets in picture timing SEI. Note that this flag will be ignored for D3D12 interface. */
uint32_t reservedBitFields :10; /**< [in]: Reserved bitfields and must be set to 0 */
uint32_t level; /**< [in]: Specifies the encoding level. Client is recommended to set this to NV_ENC_LEVEL_AUTOSELECT in order to enable the NvEncodeAPI interface to select the correct level. */
uint32_t idrPeriod; /**< [in]: Specifies the IDR interval. If not set, this is made equal to gopLength in NV_ENC_CONFIG.Low latency application client can set IDR interval to NVENC_INFINITE_GOPLENGTH so that IDR frames are not inserted automatically. */
uint32_t separateColourPlaneFlag; /**< [in]: Set to 1 to enable 4:4:4 separate colour planes */
uint32_t disableDeblockingFilterIDC; /**< [in]: Specifies the deblocking filter mode. Permissible value range: [0,2]. This flag corresponds
to the flag disable_deblocking_filter_idc specified in section 7.4.3 of H.264 specification,
which specifies whether the operation of the deblocking filter shall be disabled across some
block edges of the slice and specifies for which edges the filtering is disabled. See section
7.4.3 of H.264 specification for more details.*/
uint32_t numTemporalLayers; /**< [in]: Specifies number of temporal layers to be used for hierarchical coding / temporal SVC. Valid value range is [1,::NV_ENC_CAPS_NUM_MAX_TEMPORAL_LAYERS] */
uint32_t spsId; /**< [in]: Specifies the SPS id of the sequence header */
uint32_t ppsId; /**< [in]: Specifies the PPS id of the picture header */
NV_ENC_H264_ADAPTIVE_TRANSFORM_MODE adaptiveTransformMode; /**< [in]: Specifies the AdaptiveTransform Mode. Check support for AdaptiveTransform mode using ::NV_ENC_CAPS_SUPPORT_ADAPTIVE_TRANSFORM caps. */
NV_ENC_H264_FMO_MODE fmoMode; /**< [in]: Specified the FMO Mode. Check support for FMO using ::NV_ENC_CAPS_SUPPORT_FMO caps. */
NV_ENC_H264_BDIRECT_MODE bdirectMode; /**< [in]: Specifies the BDirect mode. Check support for BDirect mode using ::NV_ENC_CAPS_SUPPORT_BDIRECT_MODE caps.*/
NV_ENC_H264_ENTROPY_CODING_MODE entropyCodingMode; /**< [in]: Specifies the entropy coding mode. Check support for CABAC mode using ::NV_ENC_CAPS_SUPPORT_CABAC caps. */
NV_ENC_STEREO_PACKING_MODE stereoMode; /**< [in]: Specifies the stereo frame packing mode which is to be signaled in frame packing arrangement SEI */
uint32_t intraRefreshPeriod; /**< [in]: Specifies the interval between successive intra refresh if enableIntrarefresh is set. Requires enableIntraRefresh to be set.
Will be disabled if NV_ENC_CONFIG::gopLength is not set to NVENC_INFINITE_GOPLENGTH. */
uint32_t intraRefreshCnt; /**< [in]: Specifies the length of intra refresh in number of frames for periodic intra refresh. This value should be smaller than intraRefreshPeriod */
uint32_t maxNumRefFrames; /**< [in]: Specifies the DPB size used for encoding. Setting it to 0 will let driver use the default DPB size.
The low latency application which wants to invalidate reference frame as an error resilience tool
is recommended to use a large DPB size so that the encoder can keep old reference frames which can be used if recent
frames are invalidated. */
uint32_t sliceMode; /**< [in]: This parameter in conjunction with sliceModeData specifies the way in which the picture is divided into slices
sliceMode = 0 MB based slices, sliceMode = 1 Byte based slices, sliceMode = 2 MB row based slices, sliceMode = 3 numSlices in Picture.
When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting
When sliceMode == 0 and sliceModeData == 0 whole picture will be coded with one slice */
uint32_t sliceModeData; /**< [in]: Specifies the parameter needed for sliceMode. For:
sliceMode = 0, sliceModeData specifies # of MBs in each slice (except last slice)
sliceMode = 1, sliceModeData specifies maximum # of bytes in each slice (except last slice)
sliceMode = 2, sliceModeData specifies # of MB rows in each slice (except last slice)
sliceMode = 3, sliceModeData specifies number of slices in the picture. Driver will divide picture into slices optimally */
NV_ENC_CONFIG_H264_VUI_PARAMETERS h264VUIParameters; /**< [in]: Specifies the H264 video usability info parameters */
uint32_t ltrNumFrames; /**< [in]: Specifies the number of LTR frames. This parameter has different meaning in two LTR modes.
In "LTR Trust" mode (ltrTrustMode = 1), encoder will mark the first ltrNumFrames base layer reference frames within each IDR interval as LTR.
In "LTR Per Picture" mode (ltrTrustMode = 0 and ltrMarkFrame = 1), ltrNumFrames specifies maximum number of LTR frames in DPB. */
uint32_t ltrTrustMode; /**< [in]: Specifies the LTR operating mode. See comments near NV_ENC_CONFIG_H264::enableLTR for description of the two modes.
Set to 1 to use "LTR Trust" mode of LTR operation. Clients are discouraged to use "LTR Trust" mode as this mode may
be deprecated in future releases.
Set to 0 when using "LTR Per Picture" mode of LTR operation. */
uint32_t chromaFormatIDC; /**< [in]: Specifies the chroma format. Should be set to 1 for yuv420 input, 3 for yuv444 input.
Check support for YUV444 encoding using ::NV_ENC_CAPS_SUPPORT_YUV444_ENCODE caps.*/
uint32_t maxTemporalLayers; /**< [in]: Specifies the max temporal layer used for temporal SVC / hierarchical coding.
Defaut value of this field is NV_ENC_CAPS::NV_ENC_CAPS_NUM_MAX_TEMPORAL_LAYERS. Note that the value NV_ENC_CONFIG_H264::maxNumRefFrames should
be greater than or equal to (NV_ENC_CONFIG_H264::maxTemporalLayers - 2) * 2, for NV_ENC_CONFIG_H264::maxTemporalLayers >= 2.*/
NV_ENC_BFRAME_REF_MODE useBFramesAsRef; /**< [in]: Specifies the B-Frame as reference mode. Check support for useBFramesAsRef mode using ::NV_ENC_CAPS_SUPPORT_BFRAME_REF_MODE caps.*/
NV_ENC_NUM_REF_FRAMES numRefL0; /**< [in]: Specifies max number of reference frames in reference picture list L0, that can be used by hardware for prediction of a frame.
Check support for numRefL0 using ::NV_ENC_CAPS_SUPPORT_MULTIPLE_REF_FRAMES caps. */
NV_ENC_NUM_REF_FRAMES numRefL1; /**< [in]: Specifies max number of reference frames in reference picture list L1, that can be used by hardware for prediction of a frame.
Check support for numRefL1 using ::NV_ENC_CAPS_SUPPORT_MULTIPLE_REF_FRAMES caps. */
uint32_t reserved1[267]; /**< [in]: Reserved and must be set to 0 */
void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
} NV_ENC_CONFIG_H264;
/**
* \struct _NV_ENC_CONFIG_HEVC
* HEVC encoder configuration parameters to be set during initialization.
*/
typedef struct _NV_ENC_CONFIG_HEVC
{
uint32_t level; /**< [in]: Specifies the level of the encoded bitstream.*/
uint32_t tier; /**< [in]: Specifies the level tier of the encoded bitstream.*/
NV_ENC_HEVC_CUSIZE minCUSize; /**< [in]: Specifies the minimum size of luma coding unit.*/
NV_ENC_HEVC_CUSIZE maxCUSize; /**< [in]: Specifies the maximum size of luma coding unit. Currently NVENC SDK only supports maxCUSize equal to NV_ENC_HEVC_CUSIZE_32x32.*/
uint32_t useConstrainedIntraPred :1; /**< [in]: Set 1 to enable constrained intra prediction. */
uint32_t disableDeblockAcrossSliceBoundary :1; /**< [in]: Set 1 to disable in loop filtering across slice boundary.*/
uint32_t outputBufferingPeriodSEI :1; /**< [in]: Set 1 to write SEI buffering period syntax in the bitstream */
uint32_t outputPictureTimingSEI :1; /**< [in]: Set 1 to write SEI picture timing syntax in the bitstream */
uint32_t outputAUD :1; /**< [in]: Set 1 to write Access Unit Delimiter syntax. */
uint32_t enableLTR :1; /**< [in]: Set to 1 to enable LTR (Long Term Reference) frame support. LTR can be used in two modes: "LTR Trust" mode and "LTR Per Picture" mode.
LTR Trust mode: In this mode, ltrNumFrames pictures after IDR are automatically marked as LTR. This mode is enabled by setting ltrTrustMode = 1.
Use of LTR Trust mode is strongly discouraged as this mode may be deprecated in future releases.
LTR Per Picture mode: In this mode, client can control whether the current picture should be marked as LTR. Enable this mode by setting
ltrTrustMode = 0 and ltrMarkFrame = 1 for the picture to be marked as LTR. This is the preferred mode
for using LTR.
Note that LTRs are not supported if encoding session is configured with B-frames */
uint32_t disableSPSPPS :1; /**< [in]: Set 1 to disable VPS, SPS and PPS signaling in the bitstream. */
uint32_t repeatSPSPPS :1; /**< [in]: Set 1 to output VPS,SPS and PPS for every IDR frame.*/
uint32_t enableIntraRefresh :1; /**< [in]: Set 1 to enable gradual decoder refresh or intra refresh. If the GOP structure uses B frames this will be ignored */
uint32_t chromaFormatIDC :2; /**< [in]: Specifies the chroma format. Should be set to 1 for yuv420 input, 3 for yuv444 input.*/
uint32_t pixelBitDepthMinus8 :3; /**< [in]: Specifies pixel bit depth minus 8. Should be set to 0 for 8 bit input, 2 for 10 bit input.*/
uint32_t enableFillerDataInsertion :1; /**< [in]: Set to 1 to enable insertion of filler data in the bitstream.
This flag will take effect only when one of the CBR rate
control modes (NV_ENC_PARAMS_RC_CBR, NV_ENC_PARAMS_RC_CBR_HQ,
NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ) is in use and both
NV_ENC_INITIALIZE_PARAMS::frameRateNum and
NV_ENC_INITIALIZE_PARAMS::frameRateDen are set to non-zero
values. Setting this field when
NV_ENC_INITIALIZE_PARAMS::enableOutputInVidmem is also set
is currently not supported and will make ::NvEncInitializeEncoder()
return an error. */
uint32_t enableConstrainedEncoding :1; /**< [in]: Set this to 1 to enable constrainedFrame encoding where each slice in the constrained picture is independent of other slices.
Constrained encoding works only with rectangular slices.
Check support for constrained encoding using ::NV_ENC_CAPS_SUPPORT_CONSTRAINED_ENCODING caps. */
uint32_t enableAlphaLayerEncoding :1; /**< [in]: Set this to 1 to enable HEVC encode with alpha layer. */
uint32_t singleSliceIntraRefresh :1; /**< [in]: Set this to 1 to maintain single slice frames during intra refresh.
Check support for single slice intra refresh using ::NV_ENC_CAPS_SINGLE_SLICE_INTRA_REFRESH caps.
This flag will be ignored if the value returned for ::NV_ENC_CAPS_SINGLE_SLICE_INTRA_REFRESH caps is false. */
uint32_t outputRecoveryPointSEI :1; /**< [in]: Set to 1 to enable writing of recovery point SEI message */
uint32_t outputTimeCodeSEI :1; /**< [in]: Set 1 to write SEI time code syntax in the bitstream. Note that this flag will be ignored for D3D12 interface.*/
uint32_t reserved :12; /**< [in]: Reserved bitfields.*/
uint32_t idrPeriod; /**< [in]: Specifies the IDR interval. If not set, this is made equal to gopLength in NV_ENC_CONFIG. Low latency application client can set IDR interval to NVENC_INFINITE_GOPLENGTH so that IDR frames are not inserted automatically. */
uint32_t intraRefreshPeriod; /**< [in]: Specifies the interval between successive intra refresh if enableIntrarefresh is set. Requires enableIntraRefresh to be set.
Will be disabled if NV_ENC_CONFIG::gopLength is not set to NVENC_INFINITE_GOPLENGTH. */
uint32_t intraRefreshCnt; /**< [in]: Specifies the length of intra refresh in number of frames for periodic intra refresh. This value should be smaller than intraRefreshPeriod */
uint32_t maxNumRefFramesInDPB; /**< [in]: Specifies the maximum number of references frames in the DPB.*/
uint32_t ltrNumFrames; /**< [in]: This parameter has different meaning in two LTR modes.
In "LTR Trust" mode (ltrTrustMode = 1), encoder will mark the first ltrNumFrames base layer reference frames within each IDR interval as LTR.
In "LTR Per Picture" mode (ltrTrustMode = 0 and ltrMarkFrame = 1), ltrNumFrames specifies maximum number of LTR frames in DPB.
These ltrNumFrames acts as a guidance to the encoder and are not necessarily honored. To achieve a right balance between the encoding
quality and keeping LTR frames in the DPB queue, the encoder can internally limit the number of LTR frames.
The number of LTR frames actually used depends upon the encoding preset being used; Faster encoding presets will use fewer LTR frames.*/
uint32_t vpsId; /**< [in]: Specifies the VPS id of the video parameter set */
uint32_t spsId; /**< [in]: Specifies the SPS id of the sequence header */
uint32_t ppsId; /**< [in]: Specifies the PPS id of the picture header */
uint32_t sliceMode; /**< [in]: This parameter in conjunction with sliceModeData specifies the way in which the picture is divided into slices
sliceMode = 0 CTU based slices, sliceMode = 1 Byte based slices, sliceMode = 2 CTU row based slices, sliceMode = 3, numSlices in Picture
When sliceMode == 0 and sliceModeData == 0 whole picture will be coded with one slice */
uint32_t sliceModeData; /**< [in]: Specifies the parameter needed for sliceMode. For:
sliceMode = 0, sliceModeData specifies # of CTUs in each slice (except last slice)
sliceMode = 1, sliceModeData specifies maximum # of bytes in each slice (except last slice)
sliceMode = 2, sliceModeData specifies # of CTU rows in each slice (except last slice)
sliceMode = 3, sliceModeData specifies number of slices in the picture. Driver will divide picture into slices optimally */
uint32_t maxTemporalLayersMinus1; /**< [in]: Specifies the max temporal layer used for hierarchical coding. */
NV_ENC_CONFIG_HEVC_VUI_PARAMETERS hevcVUIParameters; /**< [in]: Specifies the HEVC video usability info parameters */
uint32_t ltrTrustMode; /**< [in]: Specifies the LTR operating mode. See comments near NV_ENC_CONFIG_HEVC::enableLTR for description of the two modes.
Set to 1 to use "LTR Trust" mode of LTR operation. Clients are discouraged to use "LTR Trust" mode as this mode may
be deprecated in future releases.
Set to 0 when using "LTR Per Picture" mode of LTR operation. */
NV_ENC_BFRAME_REF_MODE useBFramesAsRef; /**< [in]: Specifies the B-Frame as reference mode. Check support for useBFramesAsRef mode using ::NV_ENC_CAPS_SUPPORT_BFRAME_REF_MODE caps.*/
NV_ENC_NUM_REF_FRAMES numRefL0; /**< [in]: Specifies max number of reference frames in reference picture list L0, that can be used by hardware for prediction of a frame.
Check support for numRefL0 using ::NV_ENC_CAPS_SUPPORT_MULTIPLE_REF_FRAMES caps. */
NV_ENC_NUM_REF_FRAMES numRefL1; /**< [in]: Specifies max number of reference frames in reference picture list L1, that can be used by hardware for prediction of a frame.
Check support for numRefL1 using ::NV_ENC_CAPS_SUPPORT_MULTIPLE_REF_FRAMES caps. */
uint32_t reserved1[214]; /**< [in]: Reserved and must be set to 0.*/
void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
} NV_ENC_CONFIG_HEVC;
#define NV_MAX_TILE_COLS_AV1 64
#define NV_MAX_TILE_ROWS_AV1 64
/**
* \struct _NV_ENC_FILM_GRAIN_PARAMS_AV1
* AV1 Film Grain Parameters structure
*/
typedef struct _NV_ENC_FILM_GRAIN_PARAMS_AV1
{
uint32_t applyGrain :1; /**< [in]: Set to 1 to specify film grain should be added to frame */
uint32_t chromaScalingFromLuma :1; /**< [in]: Set to 1 to specify the chroma scaling is inferred from luma scaling */
uint32_t overlapFlag :1; /**< [in]: Set to 1 to indicate that overlap between film grain blocks should be applied*/
uint32_t clipToRestrictedRange :1; /**< [in]: Set to 1 to clip values to restricted (studio) range after adding film grain */
uint32_t grainScalingMinus8 :2; /**< [in]: Represents the shift - 8 applied to the values of the chroma component */
uint32_t arCoeffLag :2; /**< [in]: Specifies the number of auto-regressive coefficients for luma and chroma */
uint32_t numYPoints :4; /**< [in]: Specifies the number of points for the piecewise linear scaling function of the luma component */
uint32_t numCbPoints :4; /**< [in]: Specifies the number of points for the piecewise linear scaling function of the cb component */
uint32_t numCrPoints :4; /**< [in]: Specifies the number of points for the piecewise linear scaling function of the cr component */
uint32_t arCoeffShiftMinus6 :2; /**< [in]: specifies the range of the auto-regressive coefficients */
uint32_t grainScaleShift :2; /**< [in]: Specifies how much the Gaussian random numbers should be scaled down during the grain synthesi process */
uint32_t reserved1 :8; /**< [in]: Reserved bits field - should be set to 0 */
uint8_t pointYValue[14]; /**< [in]: pointYValue[i]: x coordinate for i-th point of luma piecewise linear scaling function. Values on a scale of 0...255 */
uint8_t pointYScaling[14]; /**< [in]: pointYScaling[i]: i-th point output value of luma piecewise linear scaling function */
uint8_t pointCbValue[10]; /**< [in]: pointCbValue[i]: x coordinate for i-th point of cb piecewise linear scaling function. Values on a scale of 0...255 */
uint8_t pointCbScaling[10]; /**< [in]: pointCbScaling[i]: i-th point output value of cb piecewise linear scaling function */
uint8_t pointCrValue[10]; /**< [in]: pointCrValue[i]: x coordinate for i-th point of cr piecewise linear scaling function. Values on a scale of 0...255 */
uint8_t pointCrScaling[10]; /**< [in]: pointCrScaling[i]: i-th point output value of cr piecewise linear scaling function */
uint8_t arCoeffsYPlus128[24]; /**< [in]: Specifies auto-regressive coefficients used for the Y plane */
uint8_t arCoeffsCbPlus128[25]; /**< [in]: Specifies auto-regressive coefficients used for the U plane */
uint8_t arCoeffsCrPlus128[25]; /**< [in]: Specifies auto-regressive coefficients used for the V plane */
uint8_t reserved2[2]; /**< [in]: Reserved bytes - should be set to 0 */
uint8_t cbMult; /**< [in]: Represents a multiplier for the cb component used in derivation of the input index to the cb component scaling function */
uint8_t cbLumaMult; /**< [in]: represents a multiplier for the average luma component used in derivation of the input index to the cb component scaling function. */
uint16_t cbOffset; /**< [in]: Represents an offset used in derivation of the input index to the cb component scaling function */
uint8_t crMult; /**< [in]: Represents a multiplier for the cr component used in derivation of the input index to the cr component scaling function */
uint8_t crLumaMult; /**< [in]: represents a multiplier for the average luma component used in derivation of the input index to the cr component scaling function. */
uint16_t crOffset; /**< [in]: Represents an offset used in derivation of the input index to the cr component scaling function */
} NV_ENC_FILM_GRAIN_PARAMS_AV1;
/**
* \struct _NV_ENC_CONFIG_AV1
* AV1 encoder configuration parameters to be set during initialization.
*/
typedef struct _NV_ENC_CONFIG_AV1
{
uint32_t level; /**< [in]: Specifies the level of the encoded bitstream.*/
uint32_t tier; /**< [in]: Specifies the level tier of the encoded bitstream.*/
NV_ENC_AV1_PART_SIZE minPartSize; /**< [in]: Specifies the minimum size of luma coding block partition.*/
NV_ENC_AV1_PART_SIZE maxPartSize; /**< [in]: Specifies the maximum size of luma coding block partition.*/
uint32_t outputAnnexBFormat : 1; /**< [in]: Set 1 to use Annex B format for bitstream output.*/
uint32_t enableTimingInfo : 1; /**< [in]: Set 1 to write Timing Info into sequence/frame headers */
uint32_t enableDecoderModelInfo : 1; /**< [in]: Set 1 to write Decoder Model Info into sequence/frame headers */
uint32_t enableFrameIdNumbers : 1; /**< [in]: Set 1 to write Frame id numbers in bitstream */
uint32_t disableSeqHdr : 1; /**< [in]: Set 1 to disable Sequence Header signaling in the bitstream. */
uint32_t repeatSeqHdr : 1; /**< [in]: Set 1 to output Sequence Header for every Key frame.*/
uint32_t enableIntraRefresh : 1; /**< [in]: Set 1 to enable gradual decoder refresh or intra refresh. If the GOP structure uses B frames this will be ignored */
uint32_t chromaFormatIDC : 2; /**< [in]: Specifies the chroma format. Should be set to 1 for yuv420 input (yuv444 input currently not supported).*/
uint32_t enableBitstreamPadding : 1; /**< [in]: Set 1 to enable bitstream padding. */
uint32_t enableCustomTileConfig : 1; /**< [in]: Set 1 to enable custom tile configuration: numTileColumns and numTileRows must have non zero values and tileWidths and tileHeights must point to a valid address */
uint32_t enableFilmGrainParams : 1; /**< [in]: Set 1 to enable custom film grain parameters: filmGrainParams must point to a valid address */
uint32_t inputPixelBitDepthMinus8 : 3; /**< [in]: Specifies pixel bit depth minus 8 of video input. Should be set to 0 for 8 bit input, 2 for 10 bit input.*/
uint32_t pixelBitDepthMinus8 : 3; /**< [in]: Specifies pixel bit depth minus 8 of encoded video. Should be set to 0 for 8 bit, 2 for 10 bit.
HW will do the bitdepth conversion internally from inputPixelBitDepthMinus8 -> pixelBitDepthMinus8 if bit dpeths differ
Support for 8 bit input to 10 bit encode conversion only */
uint32_t reserved : 14; /**< [in]: Reserved bitfields.*/
uint32_t idrPeriod; /**< [in]: Specifies the IDR/Key frame interval. If not set, this is made equal to gopLength in NV_ENC_CONFIG.Low latency application client can set IDR interval to NVENC_INFINITE_GOPLENGTH so that IDR frames are not inserted automatically. */
uint32_t intraRefreshPeriod; /**< [in]: Specifies the interval between successive intra refresh if enableIntrarefresh is set. Requires enableIntraRefresh to be set.
Will be disabled if NV_ENC_CONFIG::gopLength is not set to NVENC_INFINITE_GOPLENGTH. */
uint32_t intraRefreshCnt; /**< [in]: Specifies the length of intra refresh in number of frames for periodic intra refresh. This value should be smaller than intraRefreshPeriod */
uint32_t maxNumRefFramesInDPB; /**< [in]: Specifies the maximum number of references frames in the DPB.*/
uint32_t numTileColumns; /**< [in]: This parameter in conjunction with the flag enableCustomTileConfig and the array tileWidths[] specifies the way in which the picture is divided into tile columns.
When enableCustomTileConfig == 0, the picture will be uniformly divided into numTileColumns tile columns. If numTileColumns is not a power of 2,
it will be rounded down to the next power of 2 value. If numTileColumns == 0, the picture will be coded with the smallest number of vertical tiles as allowed by standard.
When enableCustomTileConfig == 1, numTileColumns must be > 0 and <= NV_MAX_TILE_COLS_AV1 and tileWidths must point to a valid array of numTileColumns entries.
Entry i specifies the width in 64x64 CTU unit of tile colum i. The sum of all the entries should be equal to the picture width in 64x64 CTU units. */
uint32_t numTileRows; /**< [in]: This parameter in conjunction with the flag enableCustomTileConfig and the array tileHeights[] specifies the way in which the picture is divided into tiles rows
When enableCustomTileConfig == 0, the picture will be uniformly divided into numTileRows tile rows. If numTileRows is not a power of 2,
it will be rounded down to the next power of 2 value. If numTileRows == 0, the picture will be coded with the smallest number of horizontal tiles as allowed by standard.
When enableCustomTileConfig == 1, numTileRows must be > 0 and <= NV_MAX_TILE_ROWS_AV1 and tileHeights must point to a valid array of numTileRows entries.
Entry i specifies the height in 64x64 CTU unit of tile row i. The sum of all the entries should be equal to the picture hieght in 64x64 CTU units. */
uint32_t *tileWidths; /**< [in]: If enableCustomTileConfig == 1, tileWidths[i] specifies the width of tile column i in 64x64 CTU unit, with 0 <= i <= numTileColumns -1. */
uint32_t *tileHeights; /**< [in]: If enableCustomTileConfig == 1, tileHeights[i] specifies the height of tile row i in 64x64 CTU unit, with 0 <= i <= numTileRows -1. */
uint32_t maxTemporalLayersMinus1; /**< [in]: Specifies the max temporal layer used for hierarchical coding. */
NV_ENC_VUI_COLOR_PRIMARIES colorPrimaries; /**< [in]: as defined in section of ISO/IEC 23091-4/ITU-T H.273 */
NV_ENC_VUI_TRANSFER_CHARACTERISTIC transferCharacteristics; /**< [in]: as defined in section of ISO/IEC 23091-4/ITU-T H.273 */
NV_ENC_VUI_MATRIX_COEFFS matrixCoefficients; /**< [in]: as defined in section of ISO/IEC 23091-4/ITU-T H.273 */
uint32_t colorRange; /**< [in]: 0: studio swing representation - 1: full swing representation */
uint32_t chromaSamplePosition; /**< [in]: 0: unknown
1: Horizontally collocated with luma (0,0) sample, between two vertical samples
2: Co-located with luma (0,0) sample */
NV_ENC_BFRAME_REF_MODE useBFramesAsRef; /**< [in]: Specifies the B-Frame as reference mode. Check support for useBFramesAsRef mode using ::NV_ENC_CAPS_SUPPORT_BFRAME_REF_MODE caps.*/
NV_ENC_FILM_GRAIN_PARAMS_AV1 *filmGrainParams; /**< [in]: If enableFilmGrainParams == 1, filmGrainParams must point to a valid NV_ENC_FILM_GRAIN_PARAMS_AV1 structure */
NV_ENC_NUM_REF_FRAMES numFwdRefs; /**< [in]: Specifies max number of forward reference frame used for prediction of a frame. It must be in range 1-4 (Last, Last2, last3 and Golden). It's a suggestive value not necessarily be honored always. */
NV_ENC_NUM_REF_FRAMES numBwdRefs; /**< [in]: Specifies max number of L1 list reference frame used for prediction of a frame. It must be in range 1-3 (Backward, Altref2, Altref). It's a suggestive value not necessarily be honored always. */
uint32_t reserved1[235]; /**< [in]: Reserved and must be set to 0.*/
void* reserved2[62]; /**< [in]: Reserved and must be set to NULL */
} NV_ENC_CONFIG_AV1;
/**
* \struct _NV_ENC_CONFIG_H264_MEONLY
* H264 encoder configuration parameters for ME only Mode
*
*/
typedef struct _NV_ENC_CONFIG_H264_MEONLY
{
uint32_t disablePartition16x16 :1; /**< [in]: Disable Motion Estimation on 16x16 blocks*/
uint32_t disablePartition8x16 :1; /**< [in]: Disable Motion Estimation on 8x16 blocks*/
uint32_t disablePartition16x8 :1; /**< [in]: Disable Motion Estimation on 16x8 blocks*/
uint32_t disablePartition8x8 :1; /**< [in]: Disable Motion Estimation on 8x8 blocks*/
uint32_t disableIntraSearch :1; /**< [in]: Disable Intra search during Motion Estimation*/
uint32_t bStereoEnable :1; /**< [in]: Enable Stereo Mode for Motion Estimation where each view is independently executed*/
uint32_t reserved :26; /**< [in]: Reserved and must be set to 0 */
uint32_t reserved1 [255]; /**< [in]: Reserved and must be set to 0 */
void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
} NV_ENC_CONFIG_H264_MEONLY;
/**
* \struct _NV_ENC_CONFIG_HEVC_MEONLY
* HEVC encoder configuration parameters for ME only Mode
*
*/
typedef struct _NV_ENC_CONFIG_HEVC_MEONLY
{
uint32_t reserved [256]; /**< [in]: Reserved and must be set to 0 */
void* reserved1[64]; /**< [in]: Reserved and must be set to NULL */
} NV_ENC_CONFIG_HEVC_MEONLY;
/**
* \struct _NV_ENC_CODEC_CONFIG
* Codec-specific encoder configuration parameters to be set during initialization.
*/
typedef union _NV_ENC_CODEC_CONFIG
{
NV_ENC_CONFIG_H264 h264Config; /**< [in]: Specifies the H.264-specific encoder configuration. */
NV_ENC_CONFIG_HEVC hevcConfig; /**< [in]: Specifies the HEVC-specific encoder configuration. */
NV_ENC_CONFIG_AV1 av1Config; /**< [in]: Specifies the AV1-specific encoder configuration. */
NV_ENC_CONFIG_H264_MEONLY h264MeOnlyConfig; /**< [in]: Specifies the H.264-specific ME only encoder configuration. */
NV_ENC_CONFIG_HEVC_MEONLY hevcMeOnlyConfig; /**< [in]: Specifies the HEVC-specific ME only encoder configuration. */
uint32_t reserved[320]; /**< [in]: Reserved and must be set to 0 */
} NV_ENC_CODEC_CONFIG;
/**
* \struct _NV_ENC_CONFIG
* Encoder configuration parameters to be set during initialization.
*/
typedef struct _NV_ENC_CONFIG
{
uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_CONFIG_VER. */
GUID profileGUID; /**< [in]: Specifies the codec profile GUID. If client specifies \p NV_ENC_CODEC_PROFILE_AUTOSELECT_GUID the NvEncodeAPI interface will select the appropriate codec profile. */
uint32_t gopLength; /**< [in]: Specifies the number of pictures in one GOP. Low latency application client can set goplength to NVENC_INFINITE_GOPLENGTH so that keyframes are not inserted automatically. */
int32_t frameIntervalP; /**< [in]: Specifies the GOP pattern as follows: \p frameIntervalP = 0: I, 1: IPP, 2: IBP, 3: IBBP If goplength is set to NVENC_INFINITE_GOPLENGTH \p frameIntervalP should be set to 1. */
uint32_t monoChromeEncoding; /**< [in]: Set this to 1 to enable monochrome encoding for this session. */
NV_ENC_PARAMS_FRAME_FIELD_MODE frameFieldMode; /**< [in]: Specifies the frame/field mode.
Check support for field encoding using ::NV_ENC_CAPS_SUPPORT_FIELD_ENCODING caps.
Using a frameFieldMode other than NV_ENC_PARAMS_FRAME_FIELD_MODE_FRAME for RGB input is not supported. */
NV_ENC_MV_PRECISION mvPrecision; /**< [in]: Specifies the desired motion vector prediction precision. */
NV_ENC_RC_PARAMS rcParams; /**< [in]: Specifies the rate control parameters for the current encoding session. */
NV_ENC_CODEC_CONFIG encodeCodecConfig; /**< [in]: Specifies the codec specific config parameters through this union. */
uint32_t reserved [278]; /**< [in]: Reserved and must be set to 0 */
void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
} NV_ENC_CONFIG;
/** macro for constructing the version field of ::_NV_ENC_CONFIG */
#define NV_ENC_CONFIG_VER (NVENCAPI_STRUCT_VERSION(8) | ( 1u<<31 ))
/**
* Tuning information of NVENC encoding (TuningInfo is not applicable to H264 and HEVC MEOnly mode).
*/
typedef enum NV_ENC_TUNING_INFO
{
NV_ENC_TUNING_INFO_UNDEFINED = 0, /**< Undefined tuningInfo. Invalid value for encoding. */
NV_ENC_TUNING_INFO_HIGH_QUALITY = 1, /**< Tune presets for latency tolerant encoding.*/
NV_ENC_TUNING_INFO_LOW_LATENCY = 2, /**< Tune presets for low latency streaming.*/
NV_ENC_TUNING_INFO_ULTRA_LOW_LATENCY = 3, /**< Tune presets for ultra low latency streaming.*/
NV_ENC_TUNING_INFO_LOSSLESS = 4, /**< Tune presets for lossless encoding.*/
NV_ENC_TUNING_INFO_COUNT /**< Count number of tuningInfos. Invalid value. */
}NV_ENC_TUNING_INFO;
/**
* \struct _NV_ENC_INITIALIZE_PARAMS
* Encode Session Initialization parameters.
*/
typedef struct _NV_ENC_INITIALIZE_PARAMS
{
uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_INITIALIZE_PARAMS_VER. */
GUID encodeGUID; /**< [in]: Specifies the Encode GUID for which the encoder is being created. ::NvEncInitializeEncoder() API will fail if this is not set, or set to unsupported value. */
GUID presetGUID; /**< [in]: Specifies the preset for encoding. If the preset GUID is set then , the preset configuration will be applied before any other parameter. */
uint32_t encodeWidth; /**< [in]: Specifies the encode width. If not set ::NvEncInitializeEncoder() API will fail. */
uint32_t encodeHeight; /**< [in]: Specifies the encode height. If not set ::NvEncInitializeEncoder() API will fail. */
uint32_t darWidth; /**< [in]: Specifies the display aspect ratio width (H264/HEVC) or the render width (AV1). */
uint32_t darHeight; /**< [in]: Specifies the display aspect ratio height (H264/HEVC) or the render height (AV1). */
uint32_t frameRateNum; /**< [in]: Specifies the numerator for frame rate used for encoding in frames per second ( Frame rate = frameRateNum / frameRateDen ). */
uint32_t frameRateDen; /**< [in]: Specifies the denominator for frame rate used for encoding in frames per second ( Frame rate = frameRateNum / frameRateDen ). */
uint32_t enableEncodeAsync; /**< [in]: Set this to 1 to enable asynchronous mode and is expected to use events to get picture completion notification. */
uint32_t enablePTD; /**< [in]: Set this to 1 to enable the Picture Type Decision is be taken by the NvEncodeAPI interface. */
uint32_t reportSliceOffsets :1; /**< [in]: Set this to 1 to enable reporting slice offsets in ::_NV_ENC_LOCK_BITSTREAM. NV_ENC_INITIALIZE_PARAMS::enableEncodeAsync must be set to 0 to use this feature. Client must set this to 0 if NV_ENC_CONFIG_H264::sliceMode is 1 on Kepler GPUs */
uint32_t enableSubFrameWrite :1; /**< [in]: Set this to 1 to write out available bitstream to memory at subframe intervals.
If enableSubFrameWrite = 1, then the hardware encoder returns data as soon as a slice (H264/HEVC) or tile (AV1) has completed encoding.
This results in better encoding latency, but the downside is that the application has to keep polling via a call to nvEncLockBitstream API continuously to see if any encoded slice/tile data is available.
Use this mode if you feel that the marginal reduction in latency from sub-frame encoding is worth the increase in complexity due to CPU-based polling. */
uint32_t enableExternalMEHints :1; /**< [in]: Set to 1 to enable external ME hints for the current frame. For NV_ENC_INITIALIZE_PARAMS::enablePTD=1 with B frames, programming L1 hints is optional for B frames since Client doesn't know internal GOP structure.
NV_ENC_PIC_PARAMS::meHintRefPicDist should preferably be set with enablePTD=1. */
uint32_t enableMEOnlyMode :1; /**< [in]: Set to 1 to enable ME Only Mode .*/
uint32_t enableWeightedPrediction :1; /**< [in]: Set this to 1 to enable weighted prediction. Not supported if encode session is configured for B-Frames (i.e. NV_ENC_CONFIG::frameIntervalP > 1 or preset >=P3 when tuningInfo = ::NV_ENC_TUNING_INFO_HIGH_QUALITY or
tuningInfo = ::NV_ENC_TUNING_INFO_LOSSLESS. This is because preset >=p3 internally enables B frames when tuningInfo = ::NV_ENC_TUNING_INFO_HIGH_QUALITY or ::NV_ENC_TUNING_INFO_LOSSLESS). */
uint32_t enableOutputInVidmem :1; /**< [in]: Set this to 1 to enable output of NVENC in video memory buffer created by application. This feature is not supported for HEVC ME only mode. */
uint32_t reservedBitFields :26; /**< [in]: Reserved bitfields and must be set to 0 */
uint32_t privDataSize; /**< [in]: Reserved private data buffer size and must be set to 0 */
void* privData; /**< [in]: Reserved private data buffer and must be set to NULL */
NV_ENC_CONFIG* encodeConfig; /**< [in]: Specifies the advanced codec specific structure. If client has sent a valid codec config structure, it will override parameters set by the NV_ENC_INITIALIZE_PARAMS::presetGUID parameter. If set to NULL the NvEncodeAPI interface will use the NV_ENC_INITIALIZE_PARAMS::presetGUID to set the codec specific parameters.
Client can also optionally query the NvEncodeAPI interface to get codec specific parameters for a presetGUID using ::NvEncGetEncodePresetConfig() API. It can then modify (if required) some of the codec config parameters and send down a custom config structure as part of ::_NV_ENC_INITIALIZE_PARAMS.
Even in this case client is recommended to pass the same preset guid it has used in ::NvEncGetEncodePresetConfig() API to query the config structure; as NV_ENC_INITIALIZE_PARAMS::presetGUID. This will not override the custom config structure but will be used to determine other Encoder HW specific parameters not exposed in the API. */
uint32_t maxEncodeWidth; /**< [in]: Maximum encode width to be used for current Encode session.
Client should allocate output buffers according to this dimension for dynamic resolution change. If set to 0, Encoder will not allow dynamic resolution change. */
uint32_t maxEncodeHeight; /**< [in]: Maximum encode height to be allowed for current Encode session.
Client should allocate output buffers according to this dimension for dynamic resolution change. If set to 0, Encode will not allow dynamic resolution change. */
NVENC_EXTERNAL_ME_HINT_COUNTS_PER_BLOCKTYPE maxMEHintCountsPerBlock[2]; /**< [in]: If Client wants to pass external motion vectors in NV_ENC_PIC_PARAMS::meExternalHints buffer it must specify the maximum number of hint candidates per block per direction for the encode session.
The NV_ENC_INITIALIZE_PARAMS::maxMEHintCountsPerBlock[0] is for L0 predictors and NV_ENC_INITIALIZE_PARAMS::maxMEHintCountsPerBlock[1] is for L1 predictors.
This client must also set NV_ENC_INITIALIZE_PARAMS::enableExternalMEHints to 1. */
NV_ENC_TUNING_INFO tuningInfo; /**< [in]: Tuning Info of NVENC encoding(TuningInfo is not applicable to H264 and HEVC meonly mode). */
NV_ENC_BUFFER_FORMAT bufferFormat; /**< [in]: Input buffer format. Used only when DX12 interface type is used */
uint32_t reserved [287]; /**< [in]: Reserved and must be set to 0 */
void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
} NV_ENC_INITIALIZE_PARAMS;
/** macro for constructing the version field of ::_NV_ENC_INITIALIZE_PARAMS */
#define NV_ENC_INITIALIZE_PARAMS_VER (NVENCAPI_STRUCT_VERSION(5) | ( 1u<<31 ))
/**
* \struct _NV_ENC_RECONFIGURE_PARAMS
* Encode Session Reconfigured parameters.
*/
typedef struct _NV_ENC_RECONFIGURE_PARAMS
{
uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_RECONFIGURE_PARAMS_VER. */
NV_ENC_INITIALIZE_PARAMS reInitEncodeParams; /**< [in]: Encoder session re-initialization parameters.
If reInitEncodeParams.encodeConfig is NULL and
reInitEncodeParams.presetGUID is the same as the preset
GUID specified on the call to NvEncInitializeEncoder(),
EncodeAPI will continue to use the existing encode
configuration.
If reInitEncodeParams.encodeConfig is NULL and
reInitEncodeParams.presetGUID is different from the preset
GUID specified on the call to NvEncInitializeEncoder(),
EncodeAPI will try to use the default configuration for
the preset specified by reInitEncodeParams.presetGUID.
In this case, reconfiguration may fail if the new
configuration is incompatible with the existing
configuration (e.g. the new configuration results in
a change in the GOP structure). */
uint32_t resetEncoder :1; /**< [in]: This resets the rate control states and other internal encoder states. This should be used only with an IDR frame.
If NV_ENC_INITIALIZE_PARAMS::enablePTD is set to 1, encoder will force the frame type to IDR */
uint32_t forceIDR :1; /**< [in]: Encode the current picture as an IDR picture. This flag is only valid when Picture type decision is taken by the Encoder
[_NV_ENC_INITIALIZE_PARAMS::enablePTD == 1]. */
uint32_t reserved :30;
}NV_ENC_RECONFIGURE_PARAMS;
/** macro for constructing the version field of ::_NV_ENC_RECONFIGURE_PARAMS */
#define NV_ENC_RECONFIGURE_PARAMS_VER (NVENCAPI_STRUCT_VERSION(1) | ( 1u<<31 ))
/**
* \struct _NV_ENC_PRESET_CONFIG
* Encoder preset config
*/
typedef struct _NV_ENC_PRESET_CONFIG
{
uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_PRESET_CONFIG_VER. */
NV_ENC_CONFIG presetCfg; /**< [out]: preset config returned by the Nvidia Video Encoder interface. */
uint32_t reserved1[255]; /**< [in]: Reserved and must be set to 0 */
void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
}NV_ENC_PRESET_CONFIG;
/** macro for constructing the version field of ::_NV_ENC_PRESET_CONFIG */
#define NV_ENC_PRESET_CONFIG_VER (NVENCAPI_STRUCT_VERSION(4) | ( 1u<<31 ))
/**
* \struct _NV_ENC_PIC_PARAMS_MVC
* MVC-specific parameters to be sent on a per-frame basis.
*/
typedef struct _NV_ENC_PIC_PARAMS_MVC
{
uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_PIC_PARAMS_MVC_VER. */
uint32_t viewID; /**< [in]: Specifies the view ID associated with the current input view. */
uint32_t temporalID; /**< [in]: Specifies the temporal ID associated with the current input view. */
uint32_t priorityID; /**< [in]: Specifies the priority ID associated with the current input view. Reserved and ignored by the NvEncodeAPI interface. */
uint32_t reserved1[12]; /**< [in]: Reserved and must be set to 0. */
void* reserved2[8]; /**< [in]: Reserved and must be set to NULL. */
}NV_ENC_PIC_PARAMS_MVC;
/** macro for constructing the version field of ::_NV_ENC_PIC_PARAMS_MVC */
#define NV_ENC_PIC_PARAMS_MVC_VER NVENCAPI_STRUCT_VERSION(1)
/**
* \union _NV_ENC_PIC_PARAMS_H264_EXT
* H264 extension picture parameters
*/
typedef union _NV_ENC_PIC_PARAMS_H264_EXT
{
NV_ENC_PIC_PARAMS_MVC mvcPicParams; /**< [in]: Specifies the MVC picture parameters. */
uint32_t reserved1[32]; /**< [in]: Reserved and must be set to 0. */
}NV_ENC_PIC_PARAMS_H264_EXT;
/**
* \struct _NV_ENC_SEI_PAYLOAD
* User SEI message
*/
typedef struct _NV_ENC_SEI_PAYLOAD
{
uint32_t payloadSize; /**< [in] SEI payload size in bytes. SEI payload must be byte aligned, as described in Annex D */
uint32_t payloadType; /**< [in] SEI payload types and syntax can be found in Annex D of the H.264 Specification. */
uint8_t *payload; /**< [in] pointer to user data */
} NV_ENC_SEI_PAYLOAD;
#define NV_ENC_H264_SEI_PAYLOAD NV_ENC_SEI_PAYLOAD
/**
* \struct _NV_ENC_PIC_PARAMS_H264
* H264 specific enc pic params. sent on a per frame basis.
*/
typedef struct _NV_ENC_PIC_PARAMS_H264
{
uint32_t displayPOCSyntax; /**< [in]: Specifies the display POC syntax This is required to be set if client is handling the picture type decision. */
uint32_t reserved3; /**< [in]: Reserved and must be set to 0 */
uint32_t refPicFlag; /**< [in]: Set to 1 for a reference picture. This is ignored if NV_ENC_INITIALIZE_PARAMS::enablePTD is set to 1. */
uint32_t colourPlaneId; /**< [in]: Specifies the colour plane ID associated with the current input. */
uint32_t forceIntraRefreshWithFrameCnt; /**< [in]: Forces an intra refresh with duration equal to intraRefreshFrameCnt.
When outputRecoveryPointSEI is set this is value is used for recovery_frame_cnt in recovery point SEI message
forceIntraRefreshWithFrameCnt cannot be used if B frames are used in the GOP structure specified */
uint32_t constrainedFrame :1; /**< [in]: Set to 1 if client wants to encode this frame with each slice completely independent of other slices in the frame.
NV_ENC_INITIALIZE_PARAMS::enableConstrainedEncoding should be set to 1 */
uint32_t sliceModeDataUpdate :1; /**< [in]: Set to 1 if client wants to change the sliceModeData field to specify new sliceSize Parameter
When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting */
uint32_t ltrMarkFrame :1; /**< [in]: Set to 1 if client wants to mark this frame as LTR */
uint32_t ltrUseFrames :1; /**< [in]: Set to 1 if client allows encoding this frame using the LTR frames specified in ltrFrameBitmap */
uint32_t reservedBitFields :28; /**< [in]: Reserved bit fields and must be set to 0 */
uint8_t* sliceTypeData; /**< [in]: Deprecated. */
uint32_t sliceTypeArrayCnt; /**< [in]: Deprecated. */
uint32_t seiPayloadArrayCnt; /**< [in]: Specifies the number of elements allocated in seiPayloadArray array. */
NV_ENC_SEI_PAYLOAD* seiPayloadArray; /**< [in]: Array of SEI payloads which will be inserted for this frame. */
uint32_t sliceMode; /**< [in]: This parameter in conjunction with sliceModeData specifies the way in which the picture is divided into slices
sliceMode = 0 MB based slices, sliceMode = 1 Byte based slices, sliceMode = 2 MB row based slices, sliceMode = 3, numSlices in Picture
When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting
When sliceMode == 0 and sliceModeData == 0 whole picture will be coded with one slice */
uint32_t sliceModeData; /**< [in]: Specifies the parameter needed for sliceMode. For:
sliceMode = 0, sliceModeData specifies # of MBs in each slice (except last slice)
sliceMode = 1, sliceModeData specifies maximum # of bytes in each slice (except last slice)
sliceMode = 2, sliceModeData specifies # of MB rows in each slice (except last slice)
sliceMode = 3, sliceModeData specifies number of slices in the picture. Driver will divide picture into slices optimally */
uint32_t ltrMarkFrameIdx; /**< [in]: Specifies the long term referenceframe index to use for marking this frame as LTR.*/
uint32_t ltrUseFrameBitmap; /**< [in]: Specifies the associated bitmap of LTR frame indices to use when encoding this frame. */
uint32_t ltrUsageMode; /**< [in]: Not supported. Reserved for future use and must be set to 0. */
uint32_t forceIntraSliceCount; /**< [in]: Specifies the number of slices to be forced to Intra in the current picture.
This option along with forceIntraSliceIdx[] array needs to be used with sliceMode = 3 only */
uint32_t *forceIntraSliceIdx; /**< [in]: Slice indices to be forced to intra in the current picture. Each slice index should be <= num_slices_in_picture -1. Index starts from 0 for first slice.
The number of entries in this array should be equal to forceIntraSliceCount */
NV_ENC_PIC_PARAMS_H264_EXT h264ExtPicParams; /**< [in]: Specifies the H264 extension config parameters using this config. */
NV_ENC_TIME_CODE timeCode; /**< [in]: Specifies the clock timestamp sets used in picture timing SEI. Applicable only when NV_ENC_CONFIG_H264::enableTimeCode is set to 1. */
uint32_t reserved [203]; /**< [in]: Reserved and must be set to 0. */
void* reserved2[61]; /**< [in]: Reserved and must be set to NULL. */
} NV_ENC_PIC_PARAMS_H264;
/**
* \struct _NV_ENC_PIC_PARAMS_HEVC
* HEVC specific enc pic params. sent on a per frame basis.
*/
typedef struct _NV_ENC_PIC_PARAMS_HEVC
{
uint32_t displayPOCSyntax; /**< [in]: Specifies the display POC syntax This is required to be set if client is handling the picture type decision. */
uint32_t refPicFlag; /**< [in]: Set to 1 for a reference picture. This is ignored if NV_ENC_INITIALIZE_PARAMS::enablePTD is set to 1. */
uint32_t temporalId; /**< [in]: Specifies the temporal id of the picture */
uint32_t forceIntraRefreshWithFrameCnt; /**< [in]: Forces an intra refresh with duration equal to intraRefreshFrameCnt.
When outputRecoveryPointSEI is set this is value is used for recovery_frame_cnt in recovery point SEI message
forceIntraRefreshWithFrameCnt cannot be used if B frames are used in the GOP structure specified */
uint32_t constrainedFrame :1; /**< [in]: Set to 1 if client wants to encode this frame with each slice completely independent of other slices in the frame.
NV_ENC_INITIALIZE_PARAMS::enableConstrainedEncoding should be set to 1 */
uint32_t sliceModeDataUpdate :1; /**< [in]: Set to 1 if client wants to change the sliceModeData field to specify new sliceSize Parameter
When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting */
uint32_t ltrMarkFrame :1; /**< [in]: Set to 1 if client wants to mark this frame as LTR */
uint32_t ltrUseFrames :1; /**< [in]: Set to 1 if client allows encoding this frame using the LTR frames specified in ltrFrameBitmap */
uint32_t reservedBitFields :28; /**< [in]: Reserved bit fields and must be set to 0 */
uint8_t* sliceTypeData; /**< [in]: Array which specifies the slice type used to force intra slice for a particular slice. Currently supported only for NV_ENC_CONFIG_H264::sliceMode == 3.
Client should allocate array of size sliceModeData where sliceModeData is specified in field of ::_NV_ENC_CONFIG_H264
Array element with index n corresponds to nth slice. To force a particular slice to intra client should set corresponding array element to NV_ENC_SLICE_TYPE_I
all other array elements should be set to NV_ENC_SLICE_TYPE_DEFAULT */
uint32_t sliceTypeArrayCnt; /**< [in]: Client should set this to the number of elements allocated in sliceTypeData array. If sliceTypeData is NULL then this should be set to 0 */
uint32_t sliceMode; /**< [in]: This parameter in conjunction with sliceModeData specifies the way in which the picture is divided into slices
sliceMode = 0 CTU based slices, sliceMode = 1 Byte based slices, sliceMode = 2 CTU row based slices, sliceMode = 3, numSlices in Picture
When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting
When sliceMode == 0 and sliceModeData == 0 whole picture will be coded with one slice */
uint32_t sliceModeData; /**< [in]: Specifies the parameter needed for sliceMode. For:
sliceMode = 0, sliceModeData specifies # of CTUs in each slice (except last slice)
sliceMode = 1, sliceModeData specifies maximum # of bytes in each slice (except last slice)
sliceMode = 2, sliceModeData specifies # of CTU rows in each slice (except last slice)
sliceMode = 3, sliceModeData specifies number of slices in the picture. Driver will divide picture into slices optimally */
uint32_t ltrMarkFrameIdx; /**< [in]: Specifies the long term reference frame index to use for marking this frame as LTR.*/
uint32_t ltrUseFrameBitmap; /**< [in]: Specifies the associated bitmap of LTR frame indices to use when encoding this frame. */
uint32_t ltrUsageMode; /**< [in]: Not supported. Reserved for future use and must be set to 0. */
uint32_t seiPayloadArrayCnt; /**< [in]: Specifies the number of elements allocated in seiPayloadArray array. */
uint32_t reserved; /**< [in]: Reserved and must be set to 0. */
NV_ENC_SEI_PAYLOAD* seiPayloadArray; /**< [in]: Array of SEI payloads which will be inserted for this frame. */
NV_ENC_TIME_CODE timeCode; /**< [in]: Specifies the clock timestamp sets used in time code SEI. Applicable only when NV_ENC_CONFIG_HEVC::enableTimeCodeSEI is set to 1. */
uint32_t reserved2 [237]; /**< [in]: Reserved and must be set to 0. */
void* reserved3[61]; /**< [in]: Reserved and must be set to NULL. */
} NV_ENC_PIC_PARAMS_HEVC;
#define NV_ENC_AV1_OBU_PAYLOAD NV_ENC_SEI_PAYLOAD
/**
* \struct _NV_ENC_PIC_PARAMS_AV1
* AV1 specific enc pic params. sent on a per frame basis.
*/
typedef struct _NV_ENC_PIC_PARAMS_AV1
{
uint32_t displayPOCSyntax; /**< [in]: Specifies the display POC syntax This is required to be set if client is handling the picture type decision. */
uint32_t refPicFlag; /**< [in]: Set to 1 for a reference picture. This is ignored if NV_ENC_INITIALIZE_PARAMS::enablePTD is set to 1. */
uint32_t temporalId; /**< [in]: Specifies the temporal id of the picture */
uint32_t forceIntraRefreshWithFrameCnt; /**< [in]: Forces an intra refresh with duration equal to intraRefreshFrameCnt.
forceIntraRefreshWithFrameCnt cannot be used if B frames are used in the GOP structure specified */
uint32_t goldenFrameFlag : 1; /**< [in]: Encode frame as Golden Frame. This is ignored if NV_ENC_INITIALIZE_PARAMS::enablePTD is set to 1. */
uint32_t arfFrameFlag : 1; /**< [in]: Encode frame as Alternate Reference Frame. This is ignored if NV_ENC_INITIALIZE_PARAMS::enablePTD is set to 1. */
uint32_t arf2FrameFlag : 1; /**< [in]: Encode frame as Alternate Reference 2 Frame. This is ignored if NV_ENC_INITIALIZE_PARAMS::enablePTD is set to 1. */
uint32_t bwdFrameFlag : 1; /**< [in]: Encode frame as Backward Reference Frame. This is ignored if NV_ENC_INITIALIZE_PARAMS::enablePTD is set to 1. */
uint32_t overlayFrameFlag : 1; /**< [in]: Encode frame as overlay frame. A previously encoded frame with the same displayPOCSyntax value should be present in reference frame buffer.
This is ignored if NV_ENC_INITIALIZE_PARAMS::enablePTD is set to 1. */
uint32_t showExistingFrameFlag : 1; /**< [in]: When ovelayFrameFlag is set to 1, this flag controls the value of the show_existing_frame syntax element associated with the overlay frame.
This flag is added to the interface as a placeholder. Its value is ignored for now and always assumed to be set to 1.
This is ignored if NV_ENC_INITIALIZE_PARAMS::enablePTD is set to 1. */
uint32_t errorResilientModeFlag : 1; /**< [in]: encode frame independently from previously encoded frames */
uint32_t tileConfigUpdate : 1; /**< [in]: Set to 1 if client wants to overwrite the default tile configuration with the tile parameters specified below
When forceIntraRefreshWithFrameCnt is set it will have priority over tileConfigUpdate setting */
uint32_t enableCustomTileConfig : 1; /**< [in]: Set 1 to enable custom tile configuration: numTileColumns and numTileRows must have non zero values and tileWidths and tileHeights must point to a valid address */
uint32_t filmGrainParamsUpdate : 1; /**< [in]: Set to 1 if client wants to update previous film grain parameters: filmGrainParams must point to a valid address and encoder must have been configured with film grain enabled */
uint32_t reservedBitFields : 22; /**< [in]: Reserved bitfields and must be set to 0 */
uint32_t numTileColumns; /**< [in]: This parameter in conjunction with the flag enableCustomTileConfig and the array tileWidths[] specifies the way in which the picture is divided into tile columns.
When enableCustomTileConfig == 0, the picture will be uniformly divided into numTileColumns tile columns. If numTileColumns is not a power of 2,
it will be rounded down to the next power of 2 value. If numTileColumns == 0, the picture will be coded with the smallest number of vertical tiles as allowed by standard.
When enableCustomTileConfig == 1, numTileColumns must be > 0 and <= NV_MAX_TILE_COLS_AV1 and tileWidths must point to a valid array of numTileColumns entries.
Entry i specifies the width in 64x64 CTU unit of tile colum i. The sum of all the entries should be equal to the picture width in 64x64 CTU units. */
uint32_t numTileRows; /**< [in]: This parameter in conjunction with the flag enableCustomTileConfig and the array tileHeights[] specifies the way in which the picture is divided into tiles rows
When enableCustomTileConfig == 0, the picture will be uniformly divided into numTileRows tile rows. If numTileRows is not a power of 2,
it will be rounded down to the next power of 2 value. If numTileRows == 0, the picture will be coded with the smallest number of horizontal tiles as allowed by standard.
When enableCustomTileConfig == 1, numTileRows must be > 0 and <= NV_MAX_TILE_ROWS_AV1 and tileHeights must point to a valid array of numTileRows entries.
Entry i specifies the height in 64x64 CTU unit of tile row i. The sum of all the entries should be equal to the picture hieght in 64x64 CTU units. */
uint32_t *tileWidths; /**< [in]: If enableCustomTileConfig == 1, tileWidths[i] specifies the width of tile column i in 64x64 CTU unit, with 0 <= i <= numTileColumns -1. */
uint32_t *tileHeights; /**< [in]: If enableCustomTileConfig == 1, tileHeights[i] specifies the height of tile row i in 64x64 CTU unit, with 0 <= i <= numTileRows -1. */
uint32_t obuPayloadArrayCnt; /**< [in]: Specifies the number of elements allocated in obuPayloadArray array. */
uint32_t reserved; /**< [in]: Reserved and must be set to 0. */
NV_ENC_AV1_OBU_PAYLOAD* obuPayloadArray; /**< [in]: Array of OBU payloads which will be inserted for this frame. */
NV_ENC_FILM_GRAIN_PARAMS_AV1 *filmGrainParams; /**< [in]: If filmGrainParamsUpdate == 1, filmGrainParams must point to a valid NV_ENC_FILM_GRAIN_PARAMS_AV1 structure */
uint32_t reserved2[247]; /**< [in]: Reserved and must be set to 0. */
void* reserved3[61]; /**< [in]: Reserved and must be set to NULL. */
} NV_ENC_PIC_PARAMS_AV1;
/**
* Codec specific per-picture encoding parameters.
*/
typedef union _NV_ENC_CODEC_PIC_PARAMS
{
NV_ENC_PIC_PARAMS_H264 h264PicParams; /**< [in]: H264 encode picture params. */
NV_ENC_PIC_PARAMS_HEVC hevcPicParams; /**< [in]: HEVC encode picture params. */
NV_ENC_PIC_PARAMS_AV1 av1PicParams; /**< [in]: AV1 encode picture params. */
uint32_t reserved[256]; /**< [in]: Reserved and must be set to 0. */
} NV_ENC_CODEC_PIC_PARAMS;
/**
* \struct _NV_ENC_PIC_PARAMS
* Encoding parameters that need to be sent on a per frame basis.
*/
typedef struct _NV_ENC_PIC_PARAMS
{
uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_PIC_PARAMS_VER. */
uint32_t inputWidth; /**< [in]: Specifies the input frame width */
uint32_t inputHeight; /**< [in]: Specifies the input frame height */
uint32_t inputPitch; /**< [in]: Specifies the input buffer pitch. If pitch value is not known, set this to inputWidth. */
uint32_t encodePicFlags; /**< [in]: Specifies bit-wise OR of encode picture flags. See ::NV_ENC_PIC_FLAGS enum. */
uint32_t frameIdx; /**< [in]: Specifies the frame index associated with the input frame [optional]. */
uint64_t inputTimeStamp; /**< [in]: Specifies opaque data which is associated with the encoded frame, but not actually encoded in the output bitstream.
This opaque data can be used later to uniquely refer to the corresponding encoded frame. For example, it can be used
for identifying the frame to be invalidated in the reference picture buffer, if lost at the client. */
uint64_t inputDuration; /**< [in]: Specifies duration of the input picture */
NV_ENC_INPUT_PTR inputBuffer; /**< [in]: Specifies the input buffer pointer. Client must use a pointer obtained from ::NvEncCreateInputBuffer() or ::NvEncMapInputResource() APIs.*/
NV_ENC_OUTPUT_PTR outputBitstream; /**< [in]: Specifies the output buffer pointer.
If NV_ENC_INITIALIZE_PARAMS::enableOutputInVidmem is set to 0, specifies the pointer to output buffer. Client should use a pointer obtained from ::NvEncCreateBitstreamBuffer() API.
If NV_ENC_INITIALIZE_PARAMS::enableOutputInVidmem is set to 1, client should allocate buffer in video memory for NV_ENC_ENCODE_OUT_PARAMS struct and encoded bitstream data. Client
should use a pointer obtained from ::NvEncMapInputResource() API, when mapping this output buffer and assign it to NV_ENC_PIC_PARAMS::outputBitstream.
First 256 bytes of this buffer should be interpreted as NV_ENC_ENCODE_OUT_PARAMS struct followed by encoded bitstream data. Recommended size for output buffer is sum of size of
NV_ENC_ENCODE_OUT_PARAMS struct and twice the input frame size for lower resolution eg. CIF and 1.5 times the input frame size for higher resolutions. If encoded bitstream size is
greater than the allocated buffer size for encoded bitstream, then the output buffer will have encoded bitstream data equal to buffer size. All CUDA operations on this buffer must use
the default stream. */
void* completionEvent; /**< [in]: Specifies an event to be signaled on completion of encoding of this Frame [only if operating in Asynchronous mode]. Each output buffer should be associated with a distinct event pointer. */
NV_ENC_BUFFER_FORMAT bufferFmt; /**< [in]: Specifies the input buffer format. */
NV_ENC_PIC_STRUCT pictureStruct; /**< [in]: Specifies structure of the input picture. */
NV_ENC_PIC_TYPE pictureType; /**< [in]: Specifies input picture type. Client required to be set explicitly by the client if the client has not set NV_ENC_INITALIZE_PARAMS::enablePTD to 1 while calling NvInitializeEncoder. */
NV_ENC_CODEC_PIC_PARAMS codecPicParams; /**< [in]: Specifies the codec specific per-picture encoding parameters. */
NVENC_EXTERNAL_ME_HINT_COUNTS_PER_BLOCKTYPE meHintCountsPerBlock[2]; /**< [in]: For H264 and Hevc, specifies the number of hint candidates per block per direction for the current frame. meHintCountsPerBlock[0] is for L0 predictors and meHintCountsPerBlock[1] is for L1 predictors.
The candidate count in NV_ENC_PIC_PARAMS::meHintCountsPerBlock[lx] must never exceed NV_ENC_INITIALIZE_PARAMS::maxMEHintCountsPerBlock[lx] provided during encoder initialization. */
NVENC_EXTERNAL_ME_HINT *meExternalHints; /**< [in]: For H264 and Hevc, Specifies the pointer to ME external hints for the current frame. The size of ME hint buffer should be equal to number of macroblocks * the total number of candidates per macroblock.
The total number of candidates per MB per direction = 1*meHintCountsPerBlock[Lx].numCandsPerBlk16x16 + 2*meHintCountsPerBlock[Lx].numCandsPerBlk16x8 + 2*meHintCountsPerBlock[Lx].numCandsPerBlk8x8
+ 4*meHintCountsPerBlock[Lx].numCandsPerBlk8x8. For frames using bidirectional ME , the total number of candidates for single macroblock is sum of total number of candidates per MB for each direction (L0 and L1) */
uint32_t reserved1[6]; /**< [in]: Reserved and must be set to 0 */
void* reserved2[2]; /**< [in]: Reserved and must be set to NULL */
int8_t *qpDeltaMap; /**< [in]: Specifies the pointer to signed byte array containing value per MB for H264, per CTB for HEVC and per SB for AV1 in raster scan order for the current picture, which will be interpreted depending on NV_ENC_RC_PARAMS::qpMapMode.
If NV_ENC_RC_PARAMS::qpMapMode is NV_ENC_QP_MAP_DELTA, qpDeltaMap specifies QP modifier per MB for H264, per CTB for HEVC and per SB for AV1. This QP modifier will be applied on top of the QP chosen by rate control.
If NV_ENC_RC_PARAMS::qpMapMode is NV_ENC_QP_MAP_EMPHASIS, qpDeltaMap specifies Emphasis Level Map per MB for H264. This level value along with QP chosen by rate control is used to
compute the QP modifier, which in turn is applied on top of QP chosen by rate control.
If NV_ENC_RC_PARAMS::qpMapMode is NV_ENC_QP_MAP_DISABLED, value in qpDeltaMap will be ignored.*/
uint32_t qpDeltaMapSize; /**< [in]: Specifies the size in bytes of qpDeltaMap surface allocated by client and pointed to by NV_ENC_PIC_PARAMS::qpDeltaMap. Surface (array) should be picWidthInMbs * picHeightInMbs for H264, picWidthInCtbs * picHeightInCtbs for HEVC and
picWidthInSbs * picHeightInSbs for AV1 */
uint32_t reservedBitFields; /**< [in]: Reserved bitfields and must be set to 0 */
uint16_t meHintRefPicDist[2]; /**< [in]: Specifies temporal distance for reference picture (NVENC_EXTERNAL_ME_HINT::refidx = 0) used during external ME with NV_ENC_INITALIZE_PARAMS::enablePTD = 1 . meHintRefPicDist[0] is for L0 hints and meHintRefPicDist[1] is for L1 hints.
If not set, will internally infer distance of 1. Ignored for NV_ENC_INITALIZE_PARAMS::enablePTD = 0 */
NV_ENC_INPUT_PTR alphaBuffer; /**< [in]: Specifies the input alpha buffer pointer. Client must use a pointer obtained from ::NvEncCreateInputBuffer() or ::NvEncMapInputResource() APIs.
Applicable only when encoding hevc with alpha layer is enabled. */
NVENC_EXTERNAL_ME_SB_HINT *meExternalSbHints; /**< [in]: For AV1,Specifies the pointer to ME external SB hints for the current frame. The size of ME hint buffer should be equal to meSbHintsCount. */
uint32_t meSbHintsCount; /**< [in]: For AV1, specifies the total number of external ME SB hint candidates for the frame
NV_ENC_PIC_PARAMS::meSbHintsCount must never exceed the total number of SBs in frame * the max number of candidates per SB provided during encoder initialization.
The max number of candidates per SB is maxMeHintCountsPerBlock[0].numCandsPerSb + maxMeHintCountsPerBlock[1].numCandsPerSb */
uint32_t reserved3[285]; /**< [in]: Reserved and must be set to 0 */
void* reserved4[58]; /**< [in]: Reserved and must be set to NULL */
} NV_ENC_PIC_PARAMS;
/** Macro for constructing the version field of ::_NV_ENC_PIC_PARAMS */
#define NV_ENC_PIC_PARAMS_VER (NVENCAPI_STRUCT_VERSION(6) | ( 1u<<31 ))
/**
* \struct _NV_ENC_MEONLY_PARAMS
* MEOnly parameters that need to be sent on a per motion estimation basis.
* NV_ENC_MEONLY_PARAMS::meExternalHints is supported for H264 only.
*/
typedef struct _NV_ENC_MEONLY_PARAMS
{
uint32_t version; /**< [in]: Struct version. Must be set to NV_ENC_MEONLY_PARAMS_VER.*/
uint32_t inputWidth; /**< [in]: Specifies the input frame width */
uint32_t inputHeight; /**< [in]: Specifies the input frame height */
NV_ENC_INPUT_PTR inputBuffer; /**< [in]: Specifies the input buffer pointer. Client must use a pointer obtained from NvEncCreateInputBuffer() or NvEncMapInputResource() APIs. */
NV_ENC_INPUT_PTR referenceFrame; /**< [in]: Specifies the reference frame pointer */
NV_ENC_OUTPUT_PTR mvBuffer; /**< [in]: Specifies the output buffer pointer.
If NV_ENC_INITIALIZE_PARAMS::enableOutputInVidmem is set to 0, specifies the pointer to motion vector data buffer allocated by NvEncCreateMVBuffer.
Client must lock mvBuffer using ::NvEncLockBitstream() API to get the motion vector data.
If NV_ENC_INITIALIZE_PARAMS::enableOutputInVidmem is set to 1, client should allocate buffer in video memory for storing the motion vector data. The size of this buffer must
be equal to total number of macroblocks multiplied by size of NV_ENC_H264_MV_DATA struct. Client should use a pointer obtained from ::NvEncMapInputResource() API, when mapping this
output buffer and assign it to NV_ENC_MEONLY_PARAMS::mvBuffer. All CUDA operations on this buffer must use the default stream. */
NV_ENC_BUFFER_FORMAT bufferFmt; /**< [in]: Specifies the input buffer format. */
void* completionEvent; /**< [in]: Specifies an event to be signaled on completion of motion estimation
of this Frame [only if operating in Asynchronous mode].
Each output buffer should be associated with a distinct event pointer. */
uint32_t viewID; /**< [in]: Specifies left or right viewID if NV_ENC_CONFIG_H264_MEONLY::bStereoEnable is set.
viewID can be 0,1 if bStereoEnable is set, 0 otherwise. */
NVENC_EXTERNAL_ME_HINT_COUNTS_PER_BLOCKTYPE
meHintCountsPerBlock[2]; /**< [in]: Specifies the number of hint candidates per block for the current frame. meHintCountsPerBlock[0] is for L0 predictors.
The candidate count in NV_ENC_PIC_PARAMS::meHintCountsPerBlock[lx] must never exceed NV_ENC_INITIALIZE_PARAMS::maxMEHintCountsPerBlock[lx] provided during encoder initialization. */
NVENC_EXTERNAL_ME_HINT *meExternalHints; /**< [in]: Specifies the pointer to ME external hints for the current frame. The size of ME hint buffer should be equal to number of macroblocks * the total number of candidates per macroblock.
The total number of candidates per MB per direction = 1*meHintCountsPerBlock[Lx].numCandsPerBlk16x16 + 2*meHintCountsPerBlock[Lx].numCandsPerBlk16x8 + 2*meHintCountsPerBlock[Lx].numCandsPerBlk8x8
+ 4*meHintCountsPerBlock[Lx].numCandsPerBlk8x8. For frames using bidirectional ME , the total number of candidates for single macroblock is sum of total number of candidates per MB for each direction (L0 and L1) */
uint32_t reserved1[243]; /**< [in]: Reserved and must be set to 0 */
void* reserved2[59]; /**< [in]: Reserved and must be set to NULL */
} NV_ENC_MEONLY_PARAMS;
/** NV_ENC_MEONLY_PARAMS struct version*/
#define NV_ENC_MEONLY_PARAMS_VER NVENCAPI_STRUCT_VERSION(3)
/**
* \struct _NV_ENC_LOCK_BITSTREAM
* Bitstream buffer lock parameters.
*/
typedef struct _NV_ENC_LOCK_BITSTREAM
{
uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_LOCK_BITSTREAM_VER. */
uint32_t doNotWait :1; /**< [in]: If this flag is set, the NvEncodeAPI interface will return buffer pointer even if operation is not completed. If not set, the call will block until operation completes. */
uint32_t ltrFrame :1; /**< [out]: Flag indicating this frame is marked as LTR frame */
uint32_t getRCStats :1; /**< [in]: If this flag is set then lockBitstream call will add additional intra-inter MB count and average MVX, MVY */
uint32_t reservedBitFields :29; /**< [in]: Reserved bit fields and must be set to 0 */
void* outputBitstream; /**< [in]: Pointer to the bitstream buffer being locked. */
uint32_t* sliceOffsets; /**< [in, out]: Array which receives the slice (H264/HEVC) or tile (AV1) offsets. This is not supported if NV_ENC_CONFIG_H264::sliceMode is 1 on Kepler GPUs. Array size must be equal to size of frame in MBs. */
uint32_t frameIdx; /**< [out]: Frame no. for which the bitstream is being retrieved. */
uint32_t hwEncodeStatus; /**< [out]: The NvEncodeAPI interface status for the locked picture. */
uint32_t numSlices; /**< [out]: Number of slices (H264/HEVC) or tiles (AV1) in the encoded picture. Will be reported only if NV_ENC_INITIALIZE_PARAMS::reportSliceOffsets set to 1. */
uint32_t bitstreamSizeInBytes; /**< [out]: Actual number of bytes generated and copied to the memory pointed by bitstreamBufferPtr.
When HEVC alpha layer encoding is enabled, this field reports the total encoded size in bytes i.e it is the encoded size of the base plus the alpha layer.
For AV1 when enablePTD is set, this field reports the total encoded size in bytes of all the encoded frames packed into the current output surface i.e. show frame plus all preceding no-show frames */
uint64_t outputTimeStamp; /**< [out]: Presentation timestamp associated with the encoded output. */
uint64_t outputDuration; /**< [out]: Presentation duration associates with the encoded output. */
void* bitstreamBufferPtr; /**< [out]: Pointer to the generated output bitstream.
For MEOnly mode _NV_ENC_LOCK_BITSTREAM::bitstreamBufferPtr should be typecast to
NV_ENC_H264_MV_DATA/NV_ENC_HEVC_MV_DATA pointer respectively for H264/HEVC */
NV_ENC_PIC_TYPE pictureType; /**< [out]: Picture type of the encoded picture. */
NV_ENC_PIC_STRUCT pictureStruct; /**< [out]: Structure of the generated output picture. */
uint32_t frameAvgQP; /**< [out]: Average QP of the frame. */
uint32_t frameSatd; /**< [out]: Total SATD cost for whole frame. */
uint32_t ltrFrameIdx; /**< [out]: Frame index associated with this LTR frame. */
uint32_t ltrFrameBitmap; /**< [out]: Bitmap of LTR frames indices which were used for encoding this frame. Value of 0 if no LTR frames were used. */
uint32_t temporalId; /**< [out]: TemporalId value of the frame when using temporalSVC encoding */
uint32_t reserved[12]; /**< [in]: Reserved and must be set to 0 */
uint32_t intraMBCount; /**< [out]: For H264, Number of Intra MBs in the encoded frame. For HEVC, Number of Intra CTBs in the encoded frame. For AV1, Number of Intra SBs in the encoded show frame. Supported only if _NV_ENC_LOCK_BITSTREAM::getRCStats set to 1. */
uint32_t interMBCount; /**< [out]: For H264, Number of Inter MBs in the encoded frame, includes skip MBs. For HEVC, Number of Inter CTBs in the encoded frame. For AV1, Number of Inter SBs in the encoded show frame. Supported only if _NV_ENC_LOCK_BITSTREAM::getRCStats set to 1. */
int32_t averageMVX; /**< [out]: Average Motion Vector in X direction for the encoded frame. Supported only if _NV_ENC_LOCK_BITSTREAM::getRCStats set to 1. */
int32_t averageMVY; /**< [out]: Average Motion Vector in y direction for the encoded frame. Supported only if _NV_ENC_LOCK_BITSTREAM::getRCStats set to 1. */
uint32_t alphaLayerSizeInBytes; /**< [out]: Number of bytes generated for the alpha layer in the encoded output. Applicable only when HEVC with alpha encoding is enabled. */
uint32_t reserved1[218]; /**< [in]: Reserved and must be set to 0 */
void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
} NV_ENC_LOCK_BITSTREAM;
/** Macro for constructing the version field of ::_NV_ENC_LOCK_BITSTREAM */
#define NV_ENC_LOCK_BITSTREAM_VER NVENCAPI_STRUCT_VERSION(2)
/**
* \struct _NV_ENC_LOCK_INPUT_BUFFER
* Uncompressed Input Buffer lock parameters.
*/
typedef struct _NV_ENC_LOCK_INPUT_BUFFER
{
uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_LOCK_INPUT_BUFFER_VER. */
uint32_t doNotWait :1; /**< [in]: Set to 1 to make ::NvEncLockInputBuffer() a unblocking call. If the encoding is not completed, driver will return ::NV_ENC_ERR_ENCODER_BUSY error code. */
uint32_t reservedBitFields :31; /**< [in]: Reserved bitfields and must be set to 0 */
NV_ENC_INPUT_PTR inputBuffer; /**< [in]: Pointer to the input buffer to be locked, client should pass the pointer obtained from ::NvEncCreateInputBuffer() or ::NvEncMapInputResource API. */
void* bufferDataPtr; /**< [out]: Pointed to the locked input buffer data. Client can only access input buffer using the \p bufferDataPtr. */
uint32_t pitch; /**< [out]: Pitch of the locked input buffer. */
uint32_t reserved1[251]; /**< [in]: Reserved and must be set to 0 */
void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
} NV_ENC_LOCK_INPUT_BUFFER;
/** Macro for constructing the version field of ::_NV_ENC_LOCK_INPUT_BUFFER */
#define NV_ENC_LOCK_INPUT_BUFFER_VER NVENCAPI_STRUCT_VERSION(1)
/**
* \struct _NV_ENC_MAP_INPUT_RESOURCE
* Map an input resource to a Nvidia Encoder Input Buffer
*/
typedef struct _NV_ENC_MAP_INPUT_RESOURCE
{
uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_MAP_INPUT_RESOURCE_VER. */
uint32_t subResourceIndex; /**< [in]: Deprecated. Do not use. */
void* inputResource; /**< [in]: Deprecated. Do not use. */
NV_ENC_REGISTERED_PTR registeredResource; /**< [in]: The Registered resource handle obtained by calling NvEncRegisterInputResource. */
NV_ENC_INPUT_PTR mappedResource; /**< [out]: Mapped pointer corresponding to the registeredResource. This pointer must be used in NV_ENC_PIC_PARAMS::inputBuffer parameter in ::NvEncEncodePicture() API. */
NV_ENC_BUFFER_FORMAT mappedBufferFmt; /**< [out]: Buffer format of the outputResource. This buffer format must be used in NV_ENC_PIC_PARAMS::bufferFmt if client using the above mapped resource pointer. */
uint32_t reserved1[251]; /**< [in]: Reserved and must be set to 0. */
void* reserved2[63]; /**< [in]: Reserved and must be set to NULL */
} NV_ENC_MAP_INPUT_RESOURCE;
/** Macro for constructing the version field of ::_NV_ENC_MAP_INPUT_RESOURCE */
#define NV_ENC_MAP_INPUT_RESOURCE_VER NVENCAPI_STRUCT_VERSION(4)
/**
* \struct _NV_ENC_INPUT_RESOURCE_OPENGL_TEX
* NV_ENC_REGISTER_RESOURCE::resourceToRegister must be a pointer to a variable of this type,
* when NV_ENC_REGISTER_RESOURCE::resourceType is NV_ENC_INPUT_RESOURCE_TYPE_OPENGL_TEX
*/
typedef struct _NV_ENC_INPUT_RESOURCE_OPENGL_TEX
{
uint32_t texture; /**< [in]: The name of the texture to be used. */
uint32_t target; /**< [in]: Accepted values are GL_TEXTURE_RECTANGLE and GL_TEXTURE_2D. */
} NV_ENC_INPUT_RESOURCE_OPENGL_TEX;
/** \struct NV_ENC_FENCE_POINT_D3D12
* Fence and fence value for synchronization.
*/
typedef struct _NV_ENC_FENCE_POINT_D3D12
{
uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_FENCE_POINT_D3D12_VER. */
uint32_t reserved; /**< [in]: Reserved and must be set to 0. */
void* pFence; /**< [in]: Pointer to ID3D12Fence. This fence object is used for synchronization. */
uint64_t waitValue; /**< [in]: Fence value to reach or exceed before the GPU operation. */
uint64_t signalValue; /**< [in]: Fence value to set the fence to, after the GPU operation. */
uint32_t bWait:1; /**< [in]: Wait on 'waitValue' if bWait is set to 1, before starting GPU operation. */
uint32_t bSignal:1; /**< [in]: Signal on 'signalValue' if bSignal is set to 1, after GPU operation is complete. */
uint32_t reservedBitField:30; /**< [in]: Reserved and must be set to 0. */
uint32_t reserved1[7]; /**< [in]: Reserved and must be set to 0. */
} NV_ENC_FENCE_POINT_D3D12;
#define NV_ENC_FENCE_POINT_D3D12_VER NVENCAPI_STRUCT_VERSION(1)
/**
* \struct _NV_ENC_INPUT_RESOURCE_D3D12
* NV_ENC_PIC_PARAMS::inputBuffer and NV_ENC_PIC_PARAMS::alphaBuffer must be a pointer to a struct of this type,
* when D3D12 interface is used
*/
typedef struct _NV_ENC_INPUT_RESOURCE_D3D12
{
uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_INPUT_RESOURCE_D3D12_VER. */
uint32_t reserved; /**< [in]: Reserved and must be set to 0. */
NV_ENC_INPUT_PTR pInputBuffer; /**< [in]: Specifies the input surface pointer. Client must use a pointer obtained from NvEncMapInputResource() in NV_ENC_MAP_INPUT_RESOURCE::mappedResource
when mapping the input surface. */
NV_ENC_FENCE_POINT_D3D12 inputFencePoint; /**< [in]: Specifies the fence and corresponding fence values to do GPU wait and signal. */
uint32_t reserved1[16]; /**< [in]: Reserved and must be set to 0. */
void* reserved2[16]; /**< [in]: Reserved and must be set to NULL. */
} NV_ENC_INPUT_RESOURCE_D3D12;
#define NV_ENC_INPUT_RESOURCE_D3D12_VER NVENCAPI_STRUCT_VERSION(1)
/**
* \struct _NV_ENC_OUTPUT_RESOURCE_D3D12
* NV_ENC_PIC_PARAMS::outputBitstream and NV_ENC_LOCK_BITSTREAM::outputBitstream must be a pointer to a struct of this type,
* when D3D12 interface is used
*/
typedef struct _NV_ENC_OUTPUT_RESOURCE_D3D12
{
uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_OUTPUT_RESOURCE_D3D12_VER. */
uint32_t reserved; /**< [in]: Reserved and must be set to 0. */
NV_ENC_INPUT_PTR pOutputBuffer; /**< [in]: Specifies the output buffer pointer. Client must use a pointer obtained from NvEncMapInputResource() in NV_ENC_MAP_INPUT_RESOURCE::mappedResource
when mapping output bitstream buffer */
NV_ENC_FENCE_POINT_D3D12 outputFencePoint; /**< [in]: Specifies the fence and corresponding fence values to do GPU wait and signal.*/
uint32_t reserved1[16]; /**< [in]: Reserved and must be set to 0. */
void* reserved2[16]; /**< [in]: Reserved and must be set to NULL. */
} NV_ENC_OUTPUT_RESOURCE_D3D12;
#define NV_ENC_OUTPUT_RESOURCE_D3D12_VER NVENCAPI_STRUCT_VERSION(1)
/**
* \struct _NV_ENC_REGISTER_RESOURCE
* Register a resource for future use with the Nvidia Video Encoder Interface.
*/
typedef struct _NV_ENC_REGISTER_RESOURCE
{
uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_REGISTER_RESOURCE_VER. */
NV_ENC_INPUT_RESOURCE_TYPE resourceType; /**< [in]: Specifies the type of resource to be registered.
Supported values are
::NV_ENC_INPUT_RESOURCE_TYPE_DIRECTX,
::NV_ENC_INPUT_RESOURCE_TYPE_CUDADEVICEPTR,
::NV_ENC_INPUT_RESOURCE_TYPE_OPENGL_TEX */
uint32_t width; /**< [in]: Input frame width. */
uint32_t height; /**< [in]: Input frame height. */
uint32_t pitch; /**< [in]: Input buffer pitch.
For ::NV_ENC_INPUT_RESOURCE_TYPE_DIRECTX resources, set this to 0.
For ::NV_ENC_INPUT_RESOURCE_TYPE_CUDADEVICEPTR resources, set this to
the pitch as obtained from cuMemAllocPitch(), or to the width in
bytes (if this resource was created by using cuMemAlloc()). This
value must be a multiple of 4.
For ::NV_ENC_INPUT_RESOURCE_TYPE_CUDAARRAY resources, set this to the
width of the allocation in bytes (i.e.
CUDA_ARRAY3D_DESCRIPTOR::Width * CUDA_ARRAY3D_DESCRIPTOR::NumChannels).
For ::NV_ENC_INPUT_RESOURCE_TYPE_OPENGL_TEX resources, set this to the
texture width multiplied by the number of components in the texture
format. */
uint32_t subResourceIndex; /**< [in]: Subresource Index of the DirectX resource to be registered. Should be set to 0 for other interfaces. */
void* resourceToRegister; /**< [in]: Handle to the resource that is being registered. */
NV_ENC_REGISTERED_PTR registeredResource; /**< [out]: Registered resource handle. This should be used in future interactions with the Nvidia Video Encoder Interface. */
NV_ENC_BUFFER_FORMAT bufferFormat; /**< [in]: Buffer format of resource to be registered. */
NV_ENC_BUFFER_USAGE bufferUsage; /**< [in]: Usage of resource to be registered. */
NV_ENC_FENCE_POINT_D3D12* pInputFencePoint; /**< [in]: Specifies the input fence and corresponding fence values to do GPU wait and signal.
To be used only when NV_ENC_REGISTER_RESOURCE::resourceToRegister represents D3D12 surface and
NV_ENC_BUFFER_USAGE::bufferUsage is NV_ENC_INPUT_IMAGE.
The fence NV_ENC_FENCE_POINT_D3D12::pFence and NV_ENC_FENCE_POINT_D3D12::waitValue will be used to do GPU wait
before starting GPU operation, if NV_ENC_FENCE_POINT_D3D12::bWait is set.
The fence NV_ENC_FENCE_POINT_D3D12::pFence and NV_ENC_FENCE_POINT_D3D12::signalValue will be used to do GPU signal
when GPU operation finishes, if NV_ENC_FENCE_POINT_D3D12::bSignal is set. */
uint32_t reserved1[247]; /**< [in]: Reserved and must be set to 0. */
void* reserved2[61]; /**< [in]: Reserved and must be set to NULL. */
} NV_ENC_REGISTER_RESOURCE;
/** Macro for constructing the version field of ::_NV_ENC_REGISTER_RESOURCE */
#define NV_ENC_REGISTER_RESOURCE_VER NVENCAPI_STRUCT_VERSION(4)
/**
* \struct _NV_ENC_STAT
* Encode Stats structure.
*/
typedef struct _NV_ENC_STAT
{
uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_STAT_VER. */
uint32_t reserved; /**< [in]: Reserved and must be set to 0 */
NV_ENC_OUTPUT_PTR outputBitStream; /**< [out]: Specifies the pointer to output bitstream. */
uint32_t bitStreamSize; /**< [out]: Size of generated bitstream in bytes. */
uint32_t picType; /**< [out]: Picture type of encoded picture. See ::NV_ENC_PIC_TYPE. */
uint32_t lastValidByteOffset; /**< [out]: Offset of last valid bytes of completed bitstream */
uint32_t sliceOffsets[16]; /**< [out]: Offsets of each slice */
uint32_t picIdx; /**< [out]: Picture number */
uint32_t frameAvgQP; /**< [out]: Average QP of the frame. */
uint32_t ltrFrame :1; /**< [out]: Flag indicating this frame is marked as LTR frame */
uint32_t reservedBitFields :31; /**< [in]: Reserved bit fields and must be set to 0 */
uint32_t ltrFrameIdx; /**< [out]: Frame index associated with this LTR frame. */
uint32_t intraMBCount; /**< [out]: For H264, Number of Intra MBs in the encoded frame. For HEVC, Number of Intra CTBs in the encoded frame. */
uint32_t interMBCount; /**< [out]: For H264, Number of Inter MBs in the encoded frame, includes skip MBs. For HEVC, Number of Inter CTBs in the encoded frame. */
int32_t averageMVX; /**< [out]: Average Motion Vector in X direction for the encoded frame. */
int32_t averageMVY; /**< [out]: Average Motion Vector in y direction for the encoded frame. */
uint32_t reserved1[226]; /**< [in]: Reserved and must be set to 0 */
void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
} NV_ENC_STAT;
/** Macro for constructing the version field of ::_NV_ENC_STAT */
#define NV_ENC_STAT_VER NVENCAPI_STRUCT_VERSION(1)
/**
* \struct _NV_ENC_SEQUENCE_PARAM_PAYLOAD
* Sequence and picture paramaters payload.
*/
typedef struct _NV_ENC_SEQUENCE_PARAM_PAYLOAD
{
uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_INITIALIZE_PARAMS_VER. */
uint32_t inBufferSize; /**< [in]: Specifies the size of the spsppsBuffer provided by the client */
uint32_t spsId; /**< [in]: Specifies the SPS id to be used in sequence header. Default value is 0. */
uint32_t ppsId; /**< [in]: Specifies the PPS id to be used in picture header. Default value is 0. */
void* spsppsBuffer; /**< [in]: Specifies bitstream header pointer of size NV_ENC_SEQUENCE_PARAM_PAYLOAD::inBufferSize.
It is the client's responsibility to manage this memory. */
uint32_t* outSPSPPSPayloadSize; /**< [out]: Size of the sequence and picture header in bytes. */
uint32_t reserved [250]; /**< [in]: Reserved and must be set to 0 */
void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
} NV_ENC_SEQUENCE_PARAM_PAYLOAD;
/** Macro for constructing the version field of ::_NV_ENC_SEQUENCE_PARAM_PAYLOAD */
#define NV_ENC_SEQUENCE_PARAM_PAYLOAD_VER NVENCAPI_STRUCT_VERSION(1)
/**
* Event registration/unregistration parameters.
*/
typedef struct _NV_ENC_EVENT_PARAMS
{
uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_EVENT_PARAMS_VER. */
uint32_t reserved; /**< [in]: Reserved and must be set to 0 */
void* completionEvent; /**< [in]: Handle to event to be registered/unregistered with the NvEncodeAPI interface. */
uint32_t reserved1[253]; /**< [in]: Reserved and must be set to 0 */
void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
} NV_ENC_EVENT_PARAMS;
/** Macro for constructing the version field of ::_NV_ENC_EVENT_PARAMS */
#define NV_ENC_EVENT_PARAMS_VER NVENCAPI_STRUCT_VERSION(1)
/**
* Encoder Session Creation parameters
*/
typedef struct _NV_ENC_OPEN_ENCODE_SESSIONEX_PARAMS
{
uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS_VER. */
NV_ENC_DEVICE_TYPE deviceType; /**< [in]: Specified the device Type */
void* device; /**< [in]: Pointer to client device. */
void* reserved; /**< [in]: Reserved and must be set to 0. */
uint32_t apiVersion; /**< [in]: API version. Should be set to NVENCAPI_VERSION. */
uint32_t reserved1[253]; /**< [in]: Reserved and must be set to 0 */
void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
} NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS;
/** Macro for constructing the version field of ::_NV_ENC_OPEN_ENCODE_SESSIONEX_PARAMS */
#define NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS_VER NVENCAPI_STRUCT_VERSION(1)
/** @} */ /* END ENCODER_STRUCTURE */
/**
* \addtogroup ENCODE_FUNC NvEncodeAPI Functions
* @{
*/
// NvEncOpenEncodeSession
/**
* \brief Opens an encoding session.
*
* Deprecated.
*
* \return
* ::NV_ENC_ERR_INVALID_CALL\n
*
*/
NVENCSTATUS NVENCAPI NvEncOpenEncodeSession (void* device, uint32_t deviceType, void** encoder);
// NvEncGetEncodeGuidCount
/**
* \brief Retrieves the number of supported encode GUIDs.
*
* The function returns the number of codec GUIDs supported by the NvEncodeAPI
* interface.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [out] encodeGUIDCount
* Number of supported encode GUIDs.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncGetEncodeGUIDCount (void* encoder, uint32_t* encodeGUIDCount);
// NvEncGetEncodeGUIDs
/**
* \brief Retrieves an array of supported encoder codec GUIDs.
*
* The function returns an array of codec GUIDs supported by the NvEncodeAPI interface.
* The client must allocate an array where the NvEncodeAPI interface can
* fill the supported GUIDs and pass the pointer in \p *GUIDs parameter.
* The size of the array can be determined by using ::NvEncGetEncodeGUIDCount() API.
* The Nvidia Encoding interface returns the number of codec GUIDs it has actually
* filled in the GUID array in the \p GUIDCount parameter.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in] guidArraySize
* Number of GUIDs to retrieved. Should be set to the number retrieved using
* ::NvEncGetEncodeGUIDCount.
* \param [out] GUIDs
* Array of supported Encode GUIDs.
* \param [out] GUIDCount
* Number of supported Encode GUIDs.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncGetEncodeGUIDs (void* encoder, GUID* GUIDs, uint32_t guidArraySize, uint32_t* GUIDCount);
// NvEncGetEncodeProfileGuidCount
/**
* \brief Retrieves the number of supported profile GUIDs.
*
* The function returns the number of profile GUIDs supported for a given codec.
* The client must first enumerate the codec GUIDs supported by the NvEncodeAPI
* interface. After determining the codec GUID, it can query the NvEncodeAPI
* interface to determine the number of profile GUIDs supported for a particular
* codec GUID.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in] encodeGUID
* The codec GUID for which the profile GUIDs are being enumerated.
* \param [out] encodeProfileGUIDCount
* Number of encode profiles supported for the given encodeGUID.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncGetEncodeProfileGUIDCount (void* encoder, GUID encodeGUID, uint32_t* encodeProfileGUIDCount);
// NvEncGetEncodeProfileGUIDs
/**
* \brief Retrieves an array of supported encode profile GUIDs.
*
* The function returns an array of supported profile GUIDs for a particular
* codec GUID. The client must allocate an array where the NvEncodeAPI interface
* can populate the profile GUIDs. The client can determine the array size using
* ::NvEncGetEncodeProfileGUIDCount() API. The client must also validiate that the
* NvEncodeAPI interface supports the GUID the client wants to pass as \p encodeGUID
* parameter.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in] encodeGUID
* The encode GUID whose profile GUIDs are being enumerated.
* \param [in] guidArraySize
* Number of GUIDs to be retrieved. Should be set to the number retrieved using
* ::NvEncGetEncodeProfileGUIDCount.
* \param [out] profileGUIDs
* Array of supported Encode Profile GUIDs
* \param [out] GUIDCount
* Number of valid encode profile GUIDs in \p profileGUIDs array.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncGetEncodeProfileGUIDs (void* encoder, GUID encodeGUID, GUID* profileGUIDs, uint32_t guidArraySize, uint32_t* GUIDCount);
// NvEncGetInputFormatCount
/**
* \brief Retrieve the number of supported Input formats.
*
* The function returns the number of supported input formats. The client must
* query the NvEncodeAPI interface to determine the supported input formats
* before creating the input surfaces.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in] encodeGUID
* Encode GUID, corresponding to which the number of supported input formats
* is to be retrieved.
* \param [out] inputFmtCount
* Number of input formats supported for specified Encode GUID.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_GENERIC \n
*/
NVENCSTATUS NVENCAPI NvEncGetInputFormatCount (void* encoder, GUID encodeGUID, uint32_t* inputFmtCount);
// NvEncGetInputFormats
/**
* \brief Retrieves an array of supported Input formats
*
* Returns an array of supported input formats The client must use the input
* format to create input surface using ::NvEncCreateInputBuffer() API.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in] encodeGUID
* Encode GUID, corresponding to which the number of supported input formats
* is to be retrieved.
*\param [in] inputFmtArraySize
* Size input format count array passed in \p inputFmts.
*\param [out] inputFmts
* Array of input formats supported for this Encode GUID.
*\param [out] inputFmtCount
* The number of valid input format types returned by the NvEncodeAPI
* interface in \p inputFmts array.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncGetInputFormats (void* encoder, GUID encodeGUID, NV_ENC_BUFFER_FORMAT* inputFmts, uint32_t inputFmtArraySize, uint32_t* inputFmtCount);
// NvEncGetEncodeCaps
/**
* \brief Retrieves the capability value for a specified encoder attribute.
*
* The function returns the capability value for a given encoder attribute. The
* client must validate the encodeGUID using ::NvEncGetEncodeGUIDs() API before
* calling this function. The encoder attribute being queried are enumerated in
* ::NV_ENC_CAPS_PARAM enum.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in] encodeGUID
* Encode GUID, corresponding to which the capability attribute is to be retrieved.
* \param [in] capsParam
* Used to specify attribute being queried. Refer ::NV_ENC_CAPS_PARAM for more
* details.
* \param [out] capsVal
* The value corresponding to the capability attribute being queried.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_GENERIC \n
*/
NVENCSTATUS NVENCAPI NvEncGetEncodeCaps (void* encoder, GUID encodeGUID, NV_ENC_CAPS_PARAM* capsParam, int* capsVal);
// NvEncGetEncodePresetCount
/**
* \brief Retrieves the number of supported preset GUIDs.
*
* The function returns the number of preset GUIDs available for a given codec.
* The client must validate the codec GUID using ::NvEncGetEncodeGUIDs() API
* before calling this function.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in] encodeGUID
* Encode GUID, corresponding to which the number of supported presets is to
* be retrieved.
* \param [out] encodePresetGUIDCount
* Receives the number of supported preset GUIDs.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncGetEncodePresetCount (void* encoder, GUID encodeGUID, uint32_t* encodePresetGUIDCount);
// NvEncGetEncodePresetGUIDs
/**
* \brief Receives an array of supported encoder preset GUIDs.
*
* The function returns an array of encode preset GUIDs available for a given codec.
* The client can directly use one of the preset GUIDs based upon the use case
* or target device. The preset GUID chosen can be directly used in
* NV_ENC_INITIALIZE_PARAMS::presetGUID parameter to ::NvEncEncodePicture() API.
* Alternately client can also use the preset GUID to retrieve the encoding config
* parameters being used by NvEncodeAPI interface for that given preset, using
* ::NvEncGetEncodePresetConfig() API. It can then modify preset config parameters
* as per its use case and send it to NvEncodeAPI interface as part of
* NV_ENC_INITIALIZE_PARAMS::encodeConfig parameter for NvEncInitializeEncoder()
* API.
*
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in] encodeGUID
* Encode GUID, corresponding to which the list of supported presets is to be
* retrieved.
* \param [in] guidArraySize
* Size of array of preset GUIDs passed in \p preset GUIDs
* \param [out] presetGUIDs
* Array of supported Encode preset GUIDs from the NvEncodeAPI interface
* to client.
* \param [out] encodePresetGUIDCount
* Receives the number of preset GUIDs returned by the NvEncodeAPI
* interface.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncGetEncodePresetGUIDs (void* encoder, GUID encodeGUID, GUID* presetGUIDs, uint32_t guidArraySize, uint32_t* encodePresetGUIDCount);
// NvEncGetEncodePresetConfig
/**
* \brief Returns a preset config structure supported for given preset GUID.
*
* The function returns a preset config structure for a given preset GUID.
* NvEncGetEncodePresetConfig() API is not applicable to AV1.
* Before using this function the client must enumerate the preset GUIDs available for
* a given codec. The preset config structure can be modified by the client depending
* upon its use case and can be then used to initialize the encoder using
* ::NvEncInitializeEncoder() API. The client can use this function only if it
* wants to modify the NvEncodeAPI preset configuration, otherwise it can
* directly use the preset GUID.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in] encodeGUID
* Encode GUID, corresponding to which the list of supported presets is to be
* retrieved.
* \param [in] presetGUID
* Preset GUID, corresponding to which the Encoding configurations is to be
* retrieved.
* \param [out] presetConfig
* The requested Preset Encoder Attribute set. Refer ::_NV_ENC_CONFIG for
* more details.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_INVALID_VERSION \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncGetEncodePresetConfig (void* encoder, GUID encodeGUID, GUID presetGUID, NV_ENC_PRESET_CONFIG* presetConfig);
// NvEncGetEncodePresetConfigEx
/**
* \brief Returns a preset config structure supported for given preset GUID.
*
* The function returns a preset config structure for a given preset GUID and tuning info.
* NvEncGetEncodePresetConfigEx() API is not applicable to H264 and HEVC meonly mode.
* Before using this function the client must enumerate the preset GUIDs available for
* a given codec. The preset config structure can be modified by the client depending
* upon its use case and can be then used to initialize the encoder using
* ::NvEncInitializeEncoder() API. The client can use this function only if it
* wants to modify the NvEncodeAPI preset configuration, otherwise it can
* directly use the preset GUID.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in] encodeGUID
* Encode GUID, corresponding to which the list of supported presets is to be
* retrieved.
* \param [in] presetGUID
* Preset GUID, corresponding to which the Encoding configurations is to be
* retrieved.
* \param [in] tuningInfo
* tuning info, corresponding to which the Encoding configurations is to be
* retrieved.
* \param [out] presetConfig
* The requested Preset Encoder Attribute set. Refer ::_NV_ENC_CONFIG for
* more details.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_INVALID_VERSION \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncGetEncodePresetConfigEx (void* encoder, GUID encodeGUID, GUID presetGUID, NV_ENC_TUNING_INFO tuningInfo, NV_ENC_PRESET_CONFIG* presetConfig);
// NvEncInitializeEncoder
/**
* \brief Initialize the encoder.
*
* This API must be used to initialize the encoder. The initialization parameter
* is passed using \p *createEncodeParams The client must send the following
* fields of the _NV_ENC_INITIALIZE_PARAMS structure with a valid value.
* - NV_ENC_INITIALIZE_PARAMS::encodeGUID
* - NV_ENC_INITIALIZE_PARAMS::encodeWidth
* - NV_ENC_INITIALIZE_PARAMS::encodeHeight
*
* The client can pass a preset GUID directly to the NvEncodeAPI interface using
* NV_ENC_INITIALIZE_PARAMS::presetGUID field. If the client doesn't pass
* NV_ENC_INITIALIZE_PARAMS::encodeConfig structure, the codec specific parameters
* will be selected based on the preset GUID. The preset GUID must have been
* validated by the client using ::NvEncGetEncodePresetGUIDs() API.
* If the client passes a custom ::_NV_ENC_CONFIG structure through
* NV_ENC_INITIALIZE_PARAMS::encodeConfig , it will override the codec specific parameters
* based on the preset GUID. It is recommended that even if the client passes a custom config,
* it should also send a preset GUID. In this case, the preset GUID passed by the client
* will not override any of the custom config parameters programmed by the client,
* it is only used as a hint by the NvEncodeAPI interface to determine certain encoder parameters
* which are not exposed to the client.
*
* There are two modes of operation for the encoder namely:
* - Asynchronous mode
* - Synchronous mode
*
* The client can select asynchronous or synchronous mode by setting the \p
* enableEncodeAsync field in ::_NV_ENC_INITIALIZE_PARAMS to 1 or 0 respectively.
*\par Asynchronous mode of operation:
* The Asynchronous mode can be enabled by setting NV_ENC_INITIALIZE_PARAMS::enableEncodeAsync to 1.
* The client operating in asynchronous mode must allocate completion event object
* for each output buffer and pass the completion event object in the
* ::NvEncEncodePicture() API. The client can create another thread and wait on
* the event object to be signaled by NvEncodeAPI interface on completion of the
* encoding process for the output frame. This should unblock the main thread from
* submitting work to the encoder. When the event is signaled the client can call
* NvEncodeAPI interfaces to copy the bitstream data using ::NvEncLockBitstream()
* API. This is the preferred mode of operation.
*
* NOTE: Asynchronous mode is not supported on Linux.
*
*\par Synchronous mode of operation:
* The client can select synchronous mode by setting NV_ENC_INITIALIZE_PARAMS::enableEncodeAsync to 0.
* The client working in synchronous mode can work in a single threaded or multi
* threaded mode. The client need not allocate any event objects. The client can
* only lock the bitstream data after NvEncodeAPI interface has returned
* ::NV_ENC_SUCCESS from encode picture. The NvEncodeAPI interface can return
* ::NV_ENC_ERR_NEED_MORE_INPUT error code from ::NvEncEncodePicture() API. The
* client must not lock the output buffer in such case but should send the next
* frame for encoding. The client must keep on calling ::NvEncEncodePicture() API
* until it returns ::NV_ENC_SUCCESS. \n
* The client must always lock the bitstream data in order in which it has submitted.
* This is true for both asynchronous and synchronous mode.
*
*\par Picture type decision:
* If the client is taking the picture type decision and it must disable the picture
* type decision module in NvEncodeAPI by setting NV_ENC_INITIALIZE_PARAMS::enablePTD
* to 0. In this case the client is required to send the picture in encoding
* order to NvEncodeAPI by doing the re-ordering for B frames. \n
* If the client doesn't want to take the picture type decision it can enable
* picture type decision module in the NvEncodeAPI interface by setting
* NV_ENC_INITIALIZE_PARAMS::enablePTD to 1 and send the input pictures in display
* order.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in] createEncodeParams
* Refer ::_NV_ENC_INITIALIZE_PARAMS for details.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_INVALID_VERSION \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncInitializeEncoder (void* encoder, NV_ENC_INITIALIZE_PARAMS* createEncodeParams);
// NvEncCreateInputBuffer
/**
* \brief Allocates Input buffer.
*
* This function is used to allocate an input buffer. The client must enumerate
* the input buffer format before allocating the input buffer resources. The
* NV_ENC_INPUT_PTR returned by the NvEncodeAPI interface in the
* NV_ENC_CREATE_INPUT_BUFFER::inputBuffer field can be directly used in
* ::NvEncEncodePicture() API. The number of input buffers to be allocated by the
* client must be at least 4 more than the number of B frames being used for encoding.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in,out] createInputBufferParams
* Pointer to the ::NV_ENC_CREATE_INPUT_BUFFER structure.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_INVALID_VERSION \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncCreateInputBuffer (void* encoder, NV_ENC_CREATE_INPUT_BUFFER* createInputBufferParams);
// NvEncDestroyInputBuffer
/**
* \brief Release an input buffers.
*
* This function is used to free an input buffer. If the client has allocated
* any input buffer using ::NvEncCreateInputBuffer() API, it must free those
* input buffers by calling this function. The client must release the input
* buffers before destroying the encoder using ::NvEncDestroyEncoder() API.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in] inputBuffer
* Pointer to the input buffer to be released.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_INVALID_VERSION \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncDestroyInputBuffer (void* encoder, NV_ENC_INPUT_PTR inputBuffer);
// NvEncSetIOCudaStreams
/**
* \brief Set input and output CUDA stream for specified encoder attribute.
*
* Encoding may involve CUDA pre-processing on the input and post-processing on encoded output.
* This function is used to set input and output CUDA streams to pipeline the CUDA pre-processing
* and post-processing tasks. Clients should call this function before the call to
* NvEncUnlockInputBuffer(). If this function is not called, the default CUDA stream is used for
* input and output processing. After a successful call to this function, the streams specified
* in that call will replace the previously-used streams.
* This API is supported for NVCUVID interface only.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in] inputStream
* Pointer to CUstream which is used to process ::NV_ENC_PIC_PARAMS::inputFrame for encode.
* In case of ME-only mode, inputStream is used to process ::NV_ENC_MEONLY_PARAMS::inputBuffer and
* ::NV_ENC_MEONLY_PARAMS::referenceFrame
* \param [in] outputStream
* Pointer to CUstream which is used to process ::NV_ENC_PIC_PARAMS::outputBuffer for encode.
* In case of ME-only mode, outputStream is used to process ::NV_ENC_MEONLY_PARAMS::mvBuffer
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_INVALID_VERSION \n
* ::NV_ENC_ERR_GENERIC \n
*/
NVENCSTATUS NVENCAPI NvEncSetIOCudaStreams (void* encoder, NV_ENC_CUSTREAM_PTR inputStream, NV_ENC_CUSTREAM_PTR outputStream);
// NvEncCreateBitstreamBuffer
/**
* \brief Allocates an output bitstream buffer
*
* This function is used to allocate an output bitstream buffer and returns a
* NV_ENC_OUTPUT_PTR to bitstream buffer to the client in the
* NV_ENC_CREATE_BITSTREAM_BUFFER::bitstreamBuffer field.
* The client can only call this function after the encoder session has been
* initialized using ::NvEncInitializeEncoder() API. The minimum number of output
* buffers allocated by the client must be at least 4 more than the number of B
* B frames being used for encoding. The client can only access the output
* bitstream data by locking the \p bitstreamBuffer using the ::NvEncLockBitstream()
* function.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in,out] createBitstreamBufferParams
* Pointer ::NV_ENC_CREATE_BITSTREAM_BUFFER for details.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_INVALID_VERSION \n
* ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncCreateBitstreamBuffer (void* encoder, NV_ENC_CREATE_BITSTREAM_BUFFER* createBitstreamBufferParams);
// NvEncDestroyBitstreamBuffer
/**
* \brief Release a bitstream buffer.
*
* This function is used to release the output bitstream buffer allocated using
* the ::NvEncCreateBitstreamBuffer() function. The client must release the output
* bitstreamBuffer using this function before destroying the encoder session.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in] bitstreamBuffer
* Pointer to the bitstream buffer being released.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_INVALID_VERSION \n
* ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncDestroyBitstreamBuffer (void* encoder, NV_ENC_OUTPUT_PTR bitstreamBuffer);
// NvEncEncodePicture
/**
* \brief Submit an input picture for encoding.
*
* This function is used to submit an input picture buffer for encoding. The
* encoding parameters are passed using \p *encodePicParams which is a pointer
* to the ::_NV_ENC_PIC_PARAMS structure.
*
* If the client has set NV_ENC_INITIALIZE_PARAMS::enablePTD to 0, then it must
* send a valid value for the following fields.
* - NV_ENC_PIC_PARAMS::pictureType
* - NV_ENC_PIC_PARAMS_H264::displayPOCSyntax (H264 only)
* - NV_ENC_PIC_PARAMS_H264::frameNumSyntax(H264 only)
* - NV_ENC_PIC_PARAMS_H264::refPicFlag(H264 only)
*
*\par MVC Encoding:
* For MVC encoding the client must call encode picture API for each view separately
* and must pass valid view id in NV_ENC_PIC_PARAMS_MVC::viewID field. Currently
* NvEncodeAPI only support stereo MVC so client must send viewID as 0 for base
* view and view ID as 1 for dependent view.
*
*\par Asynchronous Encoding
* If the client has enabled asynchronous mode of encoding by setting
* NV_ENC_INITIALIZE_PARAMS::enableEncodeAsync to 1 in the ::NvEncInitializeEncoder()
* API ,then the client must send a valid NV_ENC_PIC_PARAMS::completionEvent.
* Incase of asynchronous mode of operation, client can queue the ::NvEncEncodePicture()
* API commands from the main thread and then queue output buffers to be processed
* to a secondary worker thread. Before the locking the output buffers in the
* secondary thread , the client must wait on NV_ENC_PIC_PARAMS::completionEvent
* it has queued in ::NvEncEncodePicture() API call. The client must always process
* completion event and the output buffer in the same order in which they have been
* submitted for encoding. The NvEncodeAPI interface is responsible for any
* re-ordering required for B frames and will always ensure that encoded bitstream
* data is written in the same order in which output buffer is submitted.
* The NvEncodeAPI interface may return ::NV_ENC_ERR_NEED_MORE_INPUT error code for
* some ::NvEncEncodePicture() API calls but the client must not treat it as a fatal error.
* The NvEncodeAPI interface might not be able to submit an input picture buffer for encoding
* immediately due to re-ordering for B frames.
*\code
The below example shows how asynchronous encoding in case of 1 B frames
------------------------------------------------------------------------
Suppose the client allocated 4 input buffers(I1,I2..), 4 output buffers(O1,O2..)
and 4 completion events(E1, E2, ...). The NvEncodeAPI interface will need to
keep a copy of the input buffers for re-ordering and it allocates following
internal buffers (NvI1, NvI2...). These internal buffers are managed by NvEncodeAPI
and the client is not responsible for the allocating or freeing the memory of
the internal buffers.
a) The client main thread will queue the following encode frame calls.
Note the picture type is unknown to the client, the decision is being taken by
NvEncodeAPI interface. The client should pass ::_NV_ENC_PIC_PARAMS parameter
consisting of allocated input buffer, output buffer and output events in successive
::NvEncEncodePicture() API calls along with other required encode picture params.
For example:
1st EncodePicture parameters - (I1, O1, E1)
2nd EncodePicture parameters - (I2, O2, E2)
3rd EncodePicture parameters - (I3, O3, E3)
b) NvEncodeAPI SW will receive the following encode Commands from the client.
The left side shows input from client in the form (Input buffer, Output Buffer,
Output Event). The right hand side shows a possible picture type decision take by
the NvEncodeAPI interface.
(I1, O1, E1) ---P1 Frame
(I2, O2, E2) ---B2 Frame
(I3, O3, E3) ---P3 Frame
c) NvEncodeAPI interface will make a copy of the input buffers to its internal
buffers for re-ordering. These copies are done as part of nvEncEncodePicture
function call from the client and NvEncodeAPI interface is responsible for
synchronization of copy operation with the actual encoding operation.
I1 --> NvI1
I2 --> NvI2
I3 --> NvI3
d) The NvEncodeAPI encodes I1 as P frame and submits I1 to encoder HW and returns ::NV_ENC_SUCCESS.
The NvEncodeAPI tries to encode I2 as B frame and fails with ::NV_ENC_ERR_NEED_MORE_INPUT error code.
The error is not fatal and it notifies client that I2 is not submitted to encoder immediately.
The NvEncodeAPI encodes I3 as P frame and submits I3 for encoding which will be used as backward
reference frame for I2. The NvEncodeAPI then submits I2 for encoding and returns ::NV_ENC_SUCESS.
Both the submission are part of the same ::NvEncEncodePicture() function call.
e) After returning from ::NvEncEncodePicture() call , the client must queue the output
bitstream processing work to the secondary thread. The output bitstream processing
for asynchronous mode consist of first waiting on completion event(E1, E2..)
and then locking the output bitstream buffer(O1, O2..) for reading the encoded
data. The work queued to the secondary thread by the client is in the following order
(I1, O1, E1)
(I2, O2, E2)
(I3, O3, E3)
Note they are in the same order in which client calls ::NvEncEncodePicture() API
in \p step a).
f) NvEncodeAPI interface will do the re-ordering such that Encoder HW will receive
the following encode commands:
(NvI1, O1, E1) ---P1 Frame
(NvI3, O2, E2) ---P3 Frame
(NvI2, O3, E3) ---B2 frame
g) After the encoding operations are completed, the events will be signaled
by NvEncodeAPI interface in the following order :
(O1, E1) ---P1 Frame ,output bitstream copied to O1 and event E1 signaled.
(O2, E2) ---P3 Frame ,output bitstream copied to O2 and event E2 signaled.
(O3, E3) ---B2 Frame ,output bitstream copied to O3 and event E3 signaled.
h) The client must lock the bitstream data using ::NvEncLockBitstream() API in
the order O1,O2,O3 to read the encoded data, after waiting for the events
to be signaled in the same order i.e E1, E2 and E3.The output processing is
done in the secondary thread in the following order:
Waits on E1, copies encoded bitstream from O1
Waits on E2, copies encoded bitstream from O2
Waits on E3, copies encoded bitstream from O3
-Note the client will receive the events signaling and output buffer in the
same order in which they have submitted for encoding.
-Note the LockBitstream will have picture type field which will notify the
output picture type to the clients.
-Note the input, output buffer and the output completion event are free to be
reused once NvEncodeAPI interfaced has signaled the event and the client has
copied the data from the output buffer.
* \endcode
*
*\par Synchronous Encoding
* The client can enable synchronous mode of encoding by setting
* NV_ENC_INITIALIZE_PARAMS::enableEncodeAsync to 0 in ::NvEncInitializeEncoder() API.
* The NvEncodeAPI interface may return ::NV_ENC_ERR_NEED_MORE_INPUT error code for
* some ::NvEncEncodePicture() API calls when NV_ENC_INITIALIZE_PARAMS::enablePTD
* is set to 1, but the client must not treat it as a fatal error. The NvEncodeAPI
* interface might not be able to submit an input picture buffer for encoding
* immediately due to re-ordering for B frames. The NvEncodeAPI interface cannot
* submit the input picture which is decided to be encoded as B frame as it waits
* for backward reference from temporally subsequent frames. This input picture
* is buffered internally and waits for more input picture to arrive. The client
* must not call ::NvEncLockBitstream() API on the output buffers whose
* ::NvEncEncodePicture() API returns ::NV_ENC_ERR_NEED_MORE_INPUT. The client must
* wait for the NvEncodeAPI interface to return ::NV_ENC_SUCCESS before locking the
* output bitstreams to read the encoded bitstream data. The following example
* explains the scenario with synchronous encoding with 2 B frames.
*\code
The below example shows how synchronous encoding works in case of 1 B frames
-----------------------------------------------------------------------------
Suppose the client allocated 4 input buffers(I1,I2..), 4 output buffers(O1,O2..)
and 4 completion events(E1, E2, ...). The NvEncodeAPI interface will need to
keep a copy of the input buffers for re-ordering and it allocates following
internal buffers (NvI1, NvI2...). These internal buffers are managed by NvEncodeAPI
and the client is not responsible for the allocating or freeing the memory of
the internal buffers.
The client calls ::NvEncEncodePicture() API with input buffer I1 and output buffer O1.
The NvEncodeAPI decides to encode I1 as P frame and submits it to encoder
HW and returns ::NV_ENC_SUCCESS.
The client can now read the encoded data by locking the output O1 by calling
NvEncLockBitstream API.
The client calls ::NvEncEncodePicture() API with input buffer I2 and output buffer O2.
The NvEncodeAPI decides to encode I2 as B frame and buffers I2 by copying it
to internal buffer and returns ::NV_ENC_ERR_NEED_MORE_INPUT.
The error is not fatal and it notifies client that it cannot read the encoded
data by locking the output O2 by calling ::NvEncLockBitstream() API without submitting
more work to the NvEncodeAPI interface.
The client calls ::NvEncEncodePicture() with input buffer I3 and output buffer O3.
The NvEncodeAPI decides to encode I3 as P frame and it first submits I3 for
encoding which will be used as backward reference frame for I2.
The NvEncodeAPI then submits I2 for encoding and returns ::NV_ENC_SUCESS. Both
the submission are part of the same ::NvEncEncodePicture() function call.
The client can now read the encoded data for both the frames by locking the output
O2 followed by O3 ,by calling ::NvEncLockBitstream() API.
The client must always lock the output in the same order in which it has submitted
to receive the encoded bitstream in correct encoding order.
* \endcode
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in,out] encodePicParams
* Pointer to the ::_NV_ENC_PIC_PARAMS structure.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_INVALID_VERSION \n
* ::NV_ENC_ERR_ENCODER_BUSY \n
* ::NV_ENC_ERR_NEED_MORE_INPUT \n
* ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncEncodePicture (void* encoder, NV_ENC_PIC_PARAMS* encodePicParams);
// NvEncLockBitstream
/**
* \brief Lock output bitstream buffer
*
* This function is used to lock the bitstream buffer to read the encoded data.
* The client can only access the encoded data by calling this function.
* The pointer to client accessible encoded data is returned in the
* NV_ENC_LOCK_BITSTREAM::bitstreamBufferPtr field. The size of the encoded data
* in the output buffer is returned in the NV_ENC_LOCK_BITSTREAM::bitstreamSizeInBytes
* The NvEncodeAPI interface also returns the output picture type and picture structure
* of the encoded frame in NV_ENC_LOCK_BITSTREAM::pictureType and
* NV_ENC_LOCK_BITSTREAM::pictureStruct fields respectively. If the client has
* set NV_ENC_LOCK_BITSTREAM::doNotWait to 1, the function might return
* ::NV_ENC_ERR_LOCK_BUSY if client is operating in synchronous mode. This is not
* a fatal failure if NV_ENC_LOCK_BITSTREAM::doNotWait is set to 1. In the above case the client can
* retry the function after few milliseconds.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in,out] lockBitstreamBufferParams
* Pointer to the ::_NV_ENC_LOCK_BITSTREAM structure.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_INVALID_VERSION \n
* ::NV_ENC_ERR_LOCK_BUSY \n
* ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncLockBitstream (void* encoder, NV_ENC_LOCK_BITSTREAM* lockBitstreamBufferParams);
// NvEncUnlockBitstream
/**
* \brief Unlock the output bitstream buffer
*
* This function is used to unlock the output bitstream buffer after the client
* has read the encoded data from output buffer. The client must call this function
* to unlock the output buffer which it has previously locked using ::NvEncLockBitstream()
* function. Using a locked bitstream buffer in ::NvEncEncodePicture() API will cause
* the function to fail.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in,out] bitstreamBuffer
* bitstream buffer pointer being unlocked
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncUnlockBitstream (void* encoder, NV_ENC_OUTPUT_PTR bitstreamBuffer);
// NvLockInputBuffer
/**
* \brief Locks an input buffer
*
* This function is used to lock the input buffer to load the uncompressed YUV
* pixel data into input buffer memory. The client must pass the NV_ENC_INPUT_PTR
* it had previously allocated using ::NvEncCreateInputBuffer()in the
* NV_ENC_LOCK_INPUT_BUFFER::inputBuffer field.
* The NvEncodeAPI interface returns pointer to client accessible input buffer
* memory in NV_ENC_LOCK_INPUT_BUFFER::bufferDataPtr field.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in,out] lockInputBufferParams
* Pointer to the ::_NV_ENC_LOCK_INPUT_BUFFER structure
*
* \return
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_INVALID_VERSION \n
* ::NV_ENC_ERR_LOCK_BUSY \n
* ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncLockInputBuffer (void* encoder, NV_ENC_LOCK_INPUT_BUFFER* lockInputBufferParams);
// NvUnlockInputBuffer
/**
* \brief Unlocks the input buffer
*
* This function is used to unlock the input buffer memory previously locked for
* uploading YUV pixel data. The input buffer must be unlocked before being used
* again for encoding, otherwise NvEncodeAPI will fail the ::NvEncEncodePicture()
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in] inputBuffer
* Pointer to the input buffer that is being unlocked.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_VERSION \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
* ::NV_ENC_ERR_GENERIC \n
*
*
*/
NVENCSTATUS NVENCAPI NvEncUnlockInputBuffer (void* encoder, NV_ENC_INPUT_PTR inputBuffer);
// NvEncGetEncodeStats
/**
* \brief Get encoding statistics.
*
* This function is used to retrieve the encoding statistics.
* This API is not supported when encode device type is CUDA.
* Note that this API will be removed in future Video Codec SDK release.
* Clients should use NvEncLockBitstream() API to retrieve the encoding statistics.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in,out] encodeStats
* Pointer to the ::_NV_ENC_STAT structure.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncGetEncodeStats (void* encoder, NV_ENC_STAT* encodeStats);
// NvEncGetSequenceParams
/**
* \brief Get encoded sequence and picture header.
*
* This function can be used to retrieve the sequence and picture header out of
* band. The client must call this function only after the encoder has been
* initialized using ::NvEncInitializeEncoder() function. The client must
* allocate the memory where the NvEncodeAPI interface can copy the bitstream
* header and pass the pointer to the memory in NV_ENC_SEQUENCE_PARAM_PAYLOAD::spsppsBuffer.
* The size of buffer is passed in the field NV_ENC_SEQUENCE_PARAM_PAYLOAD::inBufferSize.
* The NvEncodeAPI interface will copy the bitstream header payload and returns
* the actual size of the bitstream header in the field
* NV_ENC_SEQUENCE_PARAM_PAYLOAD::outSPSPPSPayloadSize.
* The client must call ::NvEncGetSequenceParams() function from the same thread which is
* being used to call ::NvEncEncodePicture() function.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in,out] sequenceParamPayload
* Pointer to the ::_NV_ENC_SEQUENCE_PARAM_PAYLOAD structure.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_VERSION \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncGetSequenceParams (void* encoder, NV_ENC_SEQUENCE_PARAM_PAYLOAD* sequenceParamPayload);
// NvEncGetSequenceParamEx
/**
* \brief Get sequence and picture header.
*
* This function can be used to retrieve the sequence and picture header out of band, even when
* encoder has not been initialized using ::NvEncInitializeEncoder() function.
* The client must allocate the memory where the NvEncodeAPI interface can copy the bitstream
* header and pass the pointer to the memory in NV_ENC_SEQUENCE_PARAM_PAYLOAD::spsppsBuffer.
* The size of buffer is passed in the field NV_ENC_SEQUENCE_PARAM_PAYLOAD::inBufferSize.
* If encoder has not been initialized using ::NvEncInitializeEncoder() function, client must
* send NV_ENC_INITIALIZE_PARAMS as input. The NV_ENC_INITIALIZE_PARAMS passed must be same as the
* one which will be used for initializing encoder using ::NvEncInitializeEncoder() function later.
* If encoder is already initialized using ::NvEncInitializeEncoder() function, the provided
* NV_ENC_INITIALIZE_PARAMS structure is ignored. The NvEncodeAPI interface will copy the bitstream
* header payload and returns the actual size of the bitstream header in the field
* NV_ENC_SEQUENCE_PARAM_PAYLOAD::outSPSPPSPayloadSize. The client must call ::NvEncGetSequenceParamsEx()
* function from the same thread which is being used to call ::NvEncEncodePicture() function.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in] encInitParams
* Pointer to the _NV_ENC_INITIALIZE_PARAMS structure.
* \param [in,out] sequenceParamPayload
* Pointer to the ::_NV_ENC_SEQUENCE_PARAM_PAYLOAD structure.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_VERSION \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncGetSequenceParamEx (void* encoder, NV_ENC_INITIALIZE_PARAMS* encInitParams, NV_ENC_SEQUENCE_PARAM_PAYLOAD* sequenceParamPayload);
// NvEncRegisterAsyncEvent
/**
* \brief Register event for notification to encoding completion.
*
* This function is used to register the completion event with NvEncodeAPI
* interface. The event is required when the client has configured the encoder to
* work in asynchronous mode. In this mode the client needs to send a completion
* event with every output buffer. The NvEncodeAPI interface will signal the
* completion of the encoding process using this event. Only after the event is
* signaled the client can get the encoded data using ::NvEncLockBitstream() function.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in] eventParams
* Pointer to the ::_NV_ENC_EVENT_PARAMS structure.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_VERSION \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncRegisterAsyncEvent (void* encoder, NV_ENC_EVENT_PARAMS* eventParams);
// NvEncUnregisterAsyncEvent
/**
* \brief Unregister completion event.
*
* This function is used to unregister completion event which has been previously
* registered using ::NvEncRegisterAsyncEvent() function. The client must unregister
* all events before destroying the encoder using ::NvEncDestroyEncoder() function.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in] eventParams
* Pointer to the ::_NV_ENC_EVENT_PARAMS structure.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_VERSION \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncUnregisterAsyncEvent (void* encoder, NV_ENC_EVENT_PARAMS* eventParams);
// NvEncMapInputResource
/**
* \brief Map an externally created input resource pointer for encoding.
*
* Maps an externally allocated input resource [using and returns a NV_ENC_INPUT_PTR
* which can be used for encoding in the ::NvEncEncodePicture() function. The
* mapped resource is returned in the field NV_ENC_MAP_INPUT_RESOURCE::outputResourcePtr.
* The NvEncodeAPI interface also returns the buffer format of the mapped resource
* in the field NV_ENC_MAP_INPUT_RESOURCE::outbufferFmt.
* This function provides synchronization guarantee that any graphics work submitted
* on the input buffer is completed before the buffer is used for encoding. This is
* also true for compute (i.e. CUDA) work, provided that the previous workload using
* the input resource was submitted to the default stream.
* The client should not access any input buffer while they are mapped by the encoder.
* For D3D12 interface type, this function does not provide synchronization guarantee.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in,out] mapInputResParams
* Pointer to the ::_NV_ENC_MAP_INPUT_RESOURCE structure.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_VERSION \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
* ::NV_ENC_ERR_RESOURCE_NOT_REGISTERED \n
* ::NV_ENC_ERR_MAP_FAILED \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncMapInputResource (void* encoder, NV_ENC_MAP_INPUT_RESOURCE* mapInputResParams);
// NvEncUnmapInputResource
/**
* \brief UnMaps a NV_ENC_INPUT_PTR which was mapped for encoding
*
*
* UnMaps an input buffer which was previously mapped using ::NvEncMapInputResource()
* API. The mapping created using ::NvEncMapInputResource() should be invalidated
* using this API before the external resource is destroyed by the client. The client
* must unmap the buffer after ::NvEncLockBitstream() API returns successfully for encode
* work submitted using the mapped input buffer.
*
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in] mappedInputBuffer
* Pointer to the NV_ENC_INPUT_PTR
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_VERSION \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
* ::NV_ENC_ERR_RESOURCE_NOT_REGISTERED \n
* ::NV_ENC_ERR_RESOURCE_NOT_MAPPED \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncUnmapInputResource (void* encoder, NV_ENC_INPUT_PTR mappedInputBuffer);
// NvEncDestroyEncoder
/**
* \brief Destroy Encoding Session
*
* Destroys the encoder session previously created using ::NvEncOpenEncodeSession()
* function. The client must flush the encoder before freeing any resources. In order
* to flush the encoder the client must pass a NULL encode picture packet and either
* wait for the ::NvEncEncodePicture() function to return in synchronous mode or wait
* for the flush event to be signaled by the encoder in asynchronous mode.
* The client must free all the input and output resources created using the
* NvEncodeAPI interface before destroying the encoder. If the client is operating
* in asynchronous mode, it must also unregister the completion events previously
* registered.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncDestroyEncoder (void* encoder);
// NvEncInvalidateRefFrames
/**
* \brief Invalidate reference frames
*
* Invalidates reference frame based on the time stamp provided by the client.
* The encoder marks any reference frames or any frames which have been reconstructed
* using the corrupt frame as invalid for motion estimation and uses older reference
* frames for motion estimation. The encoder forces the current frame to be encoded
* as an intra frame if no reference frames are left after invalidation process.
* This is useful for low latency application for error resiliency. The client
* is recommended to set NV_ENC_CONFIG_H264::maxNumRefFrames to a large value so
* that encoder can keep a backup of older reference frames in the DPB and can use them
* for motion estimation when the newer reference frames have been invalidated.
* This API can be called multiple times.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in] invalidRefFrameTimeStamp
* Timestamp of the invalid reference frames which needs to be invalidated.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncInvalidateRefFrames(void* encoder, uint64_t invalidRefFrameTimeStamp);
// NvEncOpenEncodeSessionEx
/**
* \brief Opens an encoding session.
*
* Opens an encoding session and returns a pointer to the encoder interface in
* the \p **encoder parameter. The client should start encoding process by calling
* this API first.
* The client must pass a pointer to IDirect3DDevice9 device or CUDA context in the \p *device parameter.
* For the OpenGL interface, \p device must be NULL. An OpenGL context must be current when
* calling all NvEncodeAPI functions.
* If the creation of encoder session fails, the client must call ::NvEncDestroyEncoder API
* before exiting.
*
* \param [in] openSessionExParams
* Pointer to a ::NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS structure.
* \param [out] encoder
* Encode Session pointer to the NvEncodeAPI interface.
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_NO_ENCODE_DEVICE \n
* ::NV_ENC_ERR_UNSUPPORTED_DEVICE \n
* ::NV_ENC_ERR_INVALID_DEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncOpenEncodeSessionEx (NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS *openSessionExParams, void** encoder);
// NvEncRegisterResource
/**
* \brief Registers a resource with the Nvidia Video Encoder Interface.
*
* Registers a resource with the Nvidia Video Encoder Interface for book keeping.
* The client is expected to pass the registered resource handle as well, while calling ::NvEncMapInputResource API.
*
* \param [in] encoder
* Pointer to the NVEncodeAPI interface.
*
* \param [in] registerResParams
* Pointer to a ::_NV_ENC_REGISTER_RESOURCE structure
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_VERSION \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
* ::NV_ENC_ERR_RESOURCE_REGISTER_FAILED \n
* ::NV_ENC_ERR_GENERIC \n
* ::NV_ENC_ERR_UNIMPLEMENTED \n
*
*/
NVENCSTATUS NVENCAPI NvEncRegisterResource (void* encoder, NV_ENC_REGISTER_RESOURCE* registerResParams);
// NvEncUnregisterResource
/**
* \brief Unregisters a resource previously registered with the Nvidia Video Encoder Interface.
*
* Unregisters a resource previously registered with the Nvidia Video Encoder Interface.
* The client is expected to unregister any resource that it has registered with the
* Nvidia Video Encoder Interface before destroying the resource.
*
* \param [in] encoder
* Pointer to the NVEncodeAPI interface.
*
* \param [in] registeredResource
* The registered resource pointer that was returned in ::NvEncRegisterResource.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_VERSION \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
* ::NV_ENC_ERR_RESOURCE_NOT_REGISTERED \n
* ::NV_ENC_ERR_GENERIC \n
* ::NV_ENC_ERR_UNIMPLEMENTED \n
*
*/
NVENCSTATUS NVENCAPI NvEncUnregisterResource (void* encoder, NV_ENC_REGISTERED_PTR registeredResource);
// NvEncReconfigureEncoder
/**
* \brief Reconfigure an existing encoding session.
*
* Reconfigure an existing encoding session.
* The client should call this API to change/reconfigure the parameter passed during
* NvEncInitializeEncoder API call.
* Currently Reconfiguration of following are not supported.
* Change in GOP structure.
* Change in sync-Async mode.
* Change in MaxWidth & MaxHeight.
* Change in PTD mode.
*
* Resolution change is possible only if maxEncodeWidth & maxEncodeHeight of NV_ENC_INITIALIZE_PARAMS
* is set while creating encoder session.
*
* \param [in] encoder
* Pointer to the NVEncodeAPI interface.
*
* \param [in] reInitEncodeParams
* Pointer to a ::NV_ENC_RECONFIGURE_PARAMS structure.
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_NO_ENCODE_DEVICE \n
* ::NV_ENC_ERR_UNSUPPORTED_DEVICE \n
* ::NV_ENC_ERR_INVALID_DEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncReconfigureEncoder (void *encoder, NV_ENC_RECONFIGURE_PARAMS* reInitEncodeParams);
// NvEncCreateMVBuffer
/**
* \brief Allocates output MV buffer for ME only mode.
*
* This function is used to allocate an output MV buffer. The size of the mvBuffer is
* dependent on the frame height and width of the last ::NvEncCreateInputBuffer() call.
* The NV_ENC_OUTPUT_PTR returned by the NvEncodeAPI interface in the
* ::NV_ENC_CREATE_MV_BUFFER::mvBuffer field should be used in
* ::NvEncRunMotionEstimationOnly() API.
* Client must lock ::NV_ENC_CREATE_MV_BUFFER::mvBuffer using ::NvEncLockBitstream() API to get the motion vector data.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in,out] createMVBufferParams
* Pointer to the ::NV_ENC_CREATE_MV_BUFFER structure.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_INVALID_VERSION \n
* ::NV_ENC_ERR_GENERIC \n
*/
NVENCSTATUS NVENCAPI NvEncCreateMVBuffer (void* encoder, NV_ENC_CREATE_MV_BUFFER* createMVBufferParams);
// NvEncDestroyMVBuffer
/**
* \brief Release an output MV buffer for ME only mode.
*
* This function is used to release the output MV buffer allocated using
* the ::NvEncCreateMVBuffer() function. The client must release the output
* mvBuffer using this function before destroying the encoder session.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in] mvBuffer
* Pointer to the mvBuffer being released.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_INVALID_VERSION \n
* ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
* ::NV_ENC_ERR_GENERIC \n
*/
NVENCSTATUS NVENCAPI NvEncDestroyMVBuffer (void* encoder, NV_ENC_OUTPUT_PTR mvBuffer);
// NvEncRunMotionEstimationOnly
/**
* \brief Submit an input picture and reference frame for motion estimation in ME only mode.
*
* This function is used to submit the input frame and reference frame for motion
* estimation. The ME parameters are passed using *meOnlyParams which is a pointer
* to ::_NV_ENC_MEONLY_PARAMS structure.
* Client must lock ::NV_ENC_CREATE_MV_BUFFER::mvBuffer using ::NvEncLockBitstream() API to get the motion vector data.
* to get motion vector data.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in] meOnlyParams
* Pointer to the ::_NV_ENC_MEONLY_PARAMS structure.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_INVALID_VERSION \n
* ::NV_ENC_ERR_NEED_MORE_INPUT \n
* ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
* ::NV_ENC_ERR_GENERIC \n
*/
NVENCSTATUS NVENCAPI NvEncRunMotionEstimationOnly (void* encoder, NV_ENC_MEONLY_PARAMS* meOnlyParams);
// NvEncodeAPIGetMaxSupportedVersion
/**
* \brief Get the largest NvEncodeAPI version supported by the driver.
*
* This function can be used by clients to determine if the driver supports
* the NvEncodeAPI header the application was compiled with.
*
* \param [out] version
* Pointer to the requested value. The 4 least significant bits in the returned
* indicate the minor version and the rest of the bits indicate the major
* version of the largest supported version.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
*/
NVENCSTATUS NVENCAPI NvEncodeAPIGetMaxSupportedVersion (uint32_t* version);
// NvEncGetLastErrorString
/**
* \brief Get the description of the last error reported by the API.
*
* This function returns a null-terminated string that can be used by clients to better understand the reason
* for failure of a previous API call.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
*
* \return
* Pointer to buffer containing the details of the last error encountered by the API.
*/
const char * NVENCAPI NvEncGetLastErrorString (void* encoder);
/// \cond API PFN
/*
* Defines API function pointers
*/
typedef NVENCSTATUS (NVENCAPI* PNVENCOPENENCODESESSION) (void* device, uint32_t deviceType, void** encoder);
typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEGUIDCOUNT) (void* encoder, uint32_t* encodeGUIDCount);
typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEGUIDS) (void* encoder, GUID* GUIDs, uint32_t guidArraySize, uint32_t* GUIDCount);
typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEPROFILEGUIDCOUNT) (void* encoder, GUID encodeGUID, uint32_t* encodeProfileGUIDCount);
typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEPROFILEGUIDS) (void* encoder, GUID encodeGUID, GUID* profileGUIDs, uint32_t guidArraySize, uint32_t* GUIDCount);
typedef NVENCSTATUS (NVENCAPI* PNVENCGETINPUTFORMATCOUNT) (void* encoder, GUID encodeGUID, uint32_t* inputFmtCount);
typedef NVENCSTATUS (NVENCAPI* PNVENCGETINPUTFORMATS) (void* encoder, GUID encodeGUID, NV_ENC_BUFFER_FORMAT* inputFmts, uint32_t inputFmtArraySize, uint32_t* inputFmtCount);
typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODECAPS) (void* encoder, GUID encodeGUID, NV_ENC_CAPS_PARAM* capsParam, int* capsVal);
typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEPRESETCOUNT) (void* encoder, GUID encodeGUID, uint32_t* encodePresetGUIDCount);
typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEPRESETGUIDS) (void* encoder, GUID encodeGUID, GUID* presetGUIDs, uint32_t guidArraySize, uint32_t* encodePresetGUIDCount);
typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEPRESETCONFIG) (void* encoder, GUID encodeGUID, GUID presetGUID, NV_ENC_PRESET_CONFIG* presetConfig);
typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEPRESETCONFIGEX) (void* encoder, GUID encodeGUID, GUID presetGUID, NV_ENC_TUNING_INFO tuningInfo, NV_ENC_PRESET_CONFIG* presetConfig);
typedef NVENCSTATUS (NVENCAPI* PNVENCINITIALIZEENCODER) (void* encoder, NV_ENC_INITIALIZE_PARAMS* createEncodeParams);
typedef NVENCSTATUS (NVENCAPI* PNVENCCREATEINPUTBUFFER) (void* encoder, NV_ENC_CREATE_INPUT_BUFFER* createInputBufferParams);
typedef NVENCSTATUS (NVENCAPI* PNVENCDESTROYINPUTBUFFER) (void* encoder, NV_ENC_INPUT_PTR inputBuffer);
typedef NVENCSTATUS (NVENCAPI* PNVENCCREATEBITSTREAMBUFFER) (void* encoder, NV_ENC_CREATE_BITSTREAM_BUFFER* createBitstreamBufferParams);
typedef NVENCSTATUS (NVENCAPI* PNVENCDESTROYBITSTREAMBUFFER) (void* encoder, NV_ENC_OUTPUT_PTR bitstreamBuffer);
typedef NVENCSTATUS (NVENCAPI* PNVENCENCODEPICTURE) (void* encoder, NV_ENC_PIC_PARAMS* encodePicParams);
typedef NVENCSTATUS (NVENCAPI* PNVENCLOCKBITSTREAM) (void* encoder, NV_ENC_LOCK_BITSTREAM* lockBitstreamBufferParams);
typedef NVENCSTATUS (NVENCAPI* PNVENCUNLOCKBITSTREAM) (void* encoder, NV_ENC_OUTPUT_PTR bitstreamBuffer);
typedef NVENCSTATUS (NVENCAPI* PNVENCLOCKINPUTBUFFER) (void* encoder, NV_ENC_LOCK_INPUT_BUFFER* lockInputBufferParams);
typedef NVENCSTATUS (NVENCAPI* PNVENCUNLOCKINPUTBUFFER) (void* encoder, NV_ENC_INPUT_PTR inputBuffer);
typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODESTATS) (void* encoder, NV_ENC_STAT* encodeStats);
typedef NVENCSTATUS (NVENCAPI* PNVENCGETSEQUENCEPARAMS) (void* encoder, NV_ENC_SEQUENCE_PARAM_PAYLOAD* sequenceParamPayload);
typedef NVENCSTATUS (NVENCAPI* PNVENCREGISTERASYNCEVENT) (void* encoder, NV_ENC_EVENT_PARAMS* eventParams);
typedef NVENCSTATUS (NVENCAPI* PNVENCUNREGISTERASYNCEVENT) (void* encoder, NV_ENC_EVENT_PARAMS* eventParams);
typedef NVENCSTATUS (NVENCAPI* PNVENCMAPINPUTRESOURCE) (void* encoder, NV_ENC_MAP_INPUT_RESOURCE* mapInputResParams);
typedef NVENCSTATUS (NVENCAPI* PNVENCUNMAPINPUTRESOURCE) (void* encoder, NV_ENC_INPUT_PTR mappedInputBuffer);
typedef NVENCSTATUS (NVENCAPI* PNVENCDESTROYENCODER) (void* encoder);
typedef NVENCSTATUS (NVENCAPI* PNVENCINVALIDATEREFFRAMES) (void* encoder, uint64_t invalidRefFrameTimeStamp);
typedef NVENCSTATUS (NVENCAPI* PNVENCOPENENCODESESSIONEX) (NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS *openSessionExParams, void** encoder);
typedef NVENCSTATUS (NVENCAPI* PNVENCREGISTERRESOURCE) (void* encoder, NV_ENC_REGISTER_RESOURCE* registerResParams);
typedef NVENCSTATUS (NVENCAPI* PNVENCUNREGISTERRESOURCE) (void* encoder, NV_ENC_REGISTERED_PTR registeredRes);
typedef NVENCSTATUS (NVENCAPI* PNVENCRECONFIGUREENCODER) (void* encoder, NV_ENC_RECONFIGURE_PARAMS* reInitEncodeParams);
typedef NVENCSTATUS (NVENCAPI* PNVENCCREATEMVBUFFER) (void* encoder, NV_ENC_CREATE_MV_BUFFER* createMVBufferParams);
typedef NVENCSTATUS (NVENCAPI* PNVENCDESTROYMVBUFFER) (void* encoder, NV_ENC_OUTPUT_PTR mvBuffer);
typedef NVENCSTATUS (NVENCAPI* PNVENCRUNMOTIONESTIMATIONONLY) (void* encoder, NV_ENC_MEONLY_PARAMS* meOnlyParams);
typedef const char * (NVENCAPI* PNVENCGETLASTERROR) (void* encoder);
typedef NVENCSTATUS (NVENCAPI* PNVENCSETIOCUDASTREAMS) (void* encoder, NV_ENC_CUSTREAM_PTR inputStream, NV_ENC_CUSTREAM_PTR outputStream);
typedef NVENCSTATUS (NVENCAPI* PNVENCGETSEQUENCEPARAMEX) (void* encoder, NV_ENC_INITIALIZE_PARAMS* encInitParams, NV_ENC_SEQUENCE_PARAM_PAYLOAD* sequenceParamPayload);
/// \endcond
/** @} */ /* END ENCODE_FUNC */
/**
* \ingroup ENCODER_STRUCTURE
* NV_ENCODE_API_FUNCTION_LIST
*/
typedef struct _NV_ENCODE_API_FUNCTION_LIST
{
uint32_t version; /**< [in]: Client should pass NV_ENCODE_API_FUNCTION_LIST_VER. */
uint32_t reserved; /**< [in]: Reserved and should be set to 0. */
PNVENCOPENENCODESESSION nvEncOpenEncodeSession; /**< [out]: Client should access ::NvEncOpenEncodeSession() API through this pointer. */
PNVENCGETENCODEGUIDCOUNT nvEncGetEncodeGUIDCount; /**< [out]: Client should access ::NvEncGetEncodeGUIDCount() API through this pointer. */
PNVENCGETENCODEPRESETCOUNT nvEncGetEncodeProfileGUIDCount; /**< [out]: Client should access ::NvEncGetEncodeProfileGUIDCount() API through this pointer.*/
PNVENCGETENCODEPRESETGUIDS nvEncGetEncodeProfileGUIDs; /**< [out]: Client should access ::NvEncGetEncodeProfileGUIDs() API through this pointer. */
PNVENCGETENCODEGUIDS nvEncGetEncodeGUIDs; /**< [out]: Client should access ::NvEncGetEncodeGUIDs() API through this pointer. */
PNVENCGETINPUTFORMATCOUNT nvEncGetInputFormatCount; /**< [out]: Client should access ::NvEncGetInputFormatCount() API through this pointer. */
PNVENCGETINPUTFORMATS nvEncGetInputFormats; /**< [out]: Client should access ::NvEncGetInputFormats() API through this pointer. */
PNVENCGETENCODECAPS nvEncGetEncodeCaps; /**< [out]: Client should access ::NvEncGetEncodeCaps() API through this pointer. */
PNVENCGETENCODEPRESETCOUNT nvEncGetEncodePresetCount; /**< [out]: Client should access ::NvEncGetEncodePresetCount() API through this pointer. */
PNVENCGETENCODEPRESETGUIDS nvEncGetEncodePresetGUIDs; /**< [out]: Client should access ::NvEncGetEncodePresetGUIDs() API through this pointer. */
PNVENCGETENCODEPRESETCONFIG nvEncGetEncodePresetConfig; /**< [out]: Client should access ::NvEncGetEncodePresetConfig() API through this pointer. */
PNVENCINITIALIZEENCODER nvEncInitializeEncoder; /**< [out]: Client should access ::NvEncInitializeEncoder() API through this pointer. */
PNVENCCREATEINPUTBUFFER nvEncCreateInputBuffer; /**< [out]: Client should access ::NvEncCreateInputBuffer() API through this pointer. */
PNVENCDESTROYINPUTBUFFER nvEncDestroyInputBuffer; /**< [out]: Client should access ::NvEncDestroyInputBuffer() API through this pointer. */
PNVENCCREATEBITSTREAMBUFFER nvEncCreateBitstreamBuffer; /**< [out]: Client should access ::NvEncCreateBitstreamBuffer() API through this pointer. */
PNVENCDESTROYBITSTREAMBUFFER nvEncDestroyBitstreamBuffer; /**< [out]: Client should access ::NvEncDestroyBitstreamBuffer() API through this pointer. */
PNVENCENCODEPICTURE nvEncEncodePicture; /**< [out]: Client should access ::NvEncEncodePicture() API through this pointer. */
PNVENCLOCKBITSTREAM nvEncLockBitstream; /**< [out]: Client should access ::NvEncLockBitstream() API through this pointer. */
PNVENCUNLOCKBITSTREAM nvEncUnlockBitstream; /**< [out]: Client should access ::NvEncUnlockBitstream() API through this pointer. */
PNVENCLOCKINPUTBUFFER nvEncLockInputBuffer; /**< [out]: Client should access ::NvEncLockInputBuffer() API through this pointer. */
PNVENCUNLOCKINPUTBUFFER nvEncUnlockInputBuffer; /**< [out]: Client should access ::NvEncUnlockInputBuffer() API through this pointer. */
PNVENCGETENCODESTATS nvEncGetEncodeStats; /**< [out]: Client should access ::NvEncGetEncodeStats() API through this pointer. */
PNVENCGETSEQUENCEPARAMS nvEncGetSequenceParams; /**< [out]: Client should access ::NvEncGetSequenceParams() API through this pointer. */
PNVENCREGISTERASYNCEVENT nvEncRegisterAsyncEvent; /**< [out]: Client should access ::NvEncRegisterAsyncEvent() API through this pointer. */
PNVENCUNREGISTERASYNCEVENT nvEncUnregisterAsyncEvent; /**< [out]: Client should access ::NvEncUnregisterAsyncEvent() API through this pointer. */
PNVENCMAPINPUTRESOURCE nvEncMapInputResource; /**< [out]: Client should access ::NvEncMapInputResource() API through this pointer. */
PNVENCUNMAPINPUTRESOURCE nvEncUnmapInputResource; /**< [out]: Client should access ::NvEncUnmapInputResource() API through this pointer. */
PNVENCDESTROYENCODER nvEncDestroyEncoder; /**< [out]: Client should access ::NvEncDestroyEncoder() API through this pointer. */
PNVENCINVALIDATEREFFRAMES nvEncInvalidateRefFrames; /**< [out]: Client should access ::NvEncInvalidateRefFrames() API through this pointer. */
PNVENCOPENENCODESESSIONEX nvEncOpenEncodeSessionEx; /**< [out]: Client should access ::NvEncOpenEncodeSession() API through this pointer. */
PNVENCREGISTERRESOURCE nvEncRegisterResource; /**< [out]: Client should access ::NvEncRegisterResource() API through this pointer. */
PNVENCUNREGISTERRESOURCE nvEncUnregisterResource; /**< [out]: Client should access ::NvEncUnregisterResource() API through this pointer. */
PNVENCRECONFIGUREENCODER nvEncReconfigureEncoder; /**< [out]: Client should access ::NvEncReconfigureEncoder() API through this pointer. */
void* reserved1;
PNVENCCREATEMVBUFFER nvEncCreateMVBuffer; /**< [out]: Client should access ::NvEncCreateMVBuffer API through this pointer. */
PNVENCDESTROYMVBUFFER nvEncDestroyMVBuffer; /**< [out]: Client should access ::NvEncDestroyMVBuffer API through this pointer. */
PNVENCRUNMOTIONESTIMATIONONLY nvEncRunMotionEstimationOnly; /**< [out]: Client should access ::NvEncRunMotionEstimationOnly API through this pointer. */
PNVENCGETLASTERROR nvEncGetLastErrorString; /**< [out]: Client should access ::nvEncGetLastErrorString API through this pointer. */
PNVENCSETIOCUDASTREAMS nvEncSetIOCudaStreams; /**< [out]: Client should access ::nvEncSetIOCudaStreams API through this pointer. */
PNVENCGETENCODEPRESETCONFIGEX nvEncGetEncodePresetConfigEx; /**< [out]: Client should access ::NvEncGetEncodePresetConfigEx() API through this pointer. */
PNVENCGETSEQUENCEPARAMEX nvEncGetSequenceParamEx; /**< [out]: Client should access ::NvEncGetSequenceParamEx() API through this pointer. */
void* reserved2[277]; /**< [in]: Reserved and must be set to NULL */
} NV_ENCODE_API_FUNCTION_LIST;
/** Macro for constructing the version field of ::_NV_ENCODEAPI_FUNCTION_LIST. */
#define NV_ENCODE_API_FUNCTION_LIST_VER NVENCAPI_STRUCT_VERSION(2)
// NvEncodeAPICreateInstance
/**
* \ingroup ENCODE_FUNC
* Entry Point to the NvEncodeAPI interface.
*
* Creates an instance of the NvEncodeAPI interface, and populates the
* pFunctionList with function pointers to the API routines implemented by the
* NvEncodeAPI interface.
*
* \param [out] functionList
*
* \return
* ::NV_ENC_SUCCESS
* ::NV_ENC_ERR_INVALID_PTR
*/
NVENCSTATUS NVENCAPI NvEncodeAPICreateInstance(NV_ENCODE_API_FUNCTION_LIST *functionList);
#ifdef __cplusplus
}
#endif
#endif
fsdsfdsfdsfdsf-5.13.8/external/stb_image_write.h 0000664 0000000 0000000 00000213065 15202152077 0021753 0 ustar 00root root 0000000 0000000 /* stb_image_write - v1.16 - public domain - http://nothings.org/stb
writes out PNG/BMP/TGA/JPEG/HDR images to C stdio - Sean Barrett 2010-2015
no warranty implied; use at your own risk
Before #including,
#define STB_IMAGE_WRITE_IMPLEMENTATION
in the file that you want to have the implementation.
Will probably not work correctly with strict-aliasing optimizations.
ABOUT:
This header file is a library for writing images to C stdio or a callback.
The PNG output is not optimal; it is 20-50% larger than the file
written by a decent optimizing implementation; though providing a custom
zlib compress function (see STBIW_ZLIB_COMPRESS) can mitigate that.
This library is designed for source code compactness and simplicity,
not optimal image file size or run-time performance.
BUILDING:
You can #define STBIW_ASSERT(x) before the #include to avoid using assert.h.
You can #define STBIW_MALLOC(), STBIW_REALLOC(), and STBIW_FREE() to replace
malloc,realloc,free.
You can #define STBIW_MEMMOVE() to replace memmove()
You can #define STBIW_ZLIB_COMPRESS to use a custom zlib-style compress function
for PNG compression (instead of the builtin one), it must have the following signature:
unsigned char * my_compress(unsigned char *data, int data_len, int *out_len, int quality);
The returned data will be freed with STBIW_FREE() (free() by default),
so it must be heap allocated with STBIW_MALLOC() (malloc() by default),
UNICODE:
If compiling for Windows and you wish to use Unicode filenames, compile
with
#define STBIW_WINDOWS_UTF8
and pass utf8-encoded filenames. Call stbiw_convert_wchar_to_utf8 to convert
Windows wchar_t filenames to utf8.
USAGE:
There are five functions, one for each image file format:
int stbi_write_png(char const *filename, int w, int h, int comp, const void *data, int stride_in_bytes);
int stbi_write_bmp(char const *filename, int w, int h, int comp, const void *data);
int stbi_write_tga(char const *filename, int w, int h, int comp, const void *data);
int stbi_write_jpg(char const *filename, int w, int h, int comp, const void *data, int quality);
int stbi_write_hdr(char const *filename, int w, int h, int comp, const float *data);
void stbi_flip_vertically_on_write(int flag); // flag is non-zero to flip data vertically
There are also five equivalent functions that use an arbitrary write function. You are
expected to open/close your file-equivalent before and after calling these:
int stbi_write_png_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data, int stride_in_bytes);
int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data);
int stbi_write_tga_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data);
int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const float *data);
int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int quality);
where the callback is:
void stbi_write_func(void *context, void *data, int size);
You can configure it with these global variables:
int stbi_write_tga_with_rle; // defaults to true; set to 0 to disable RLE
int stbi_write_png_compression_level; // defaults to 8; set to higher for more compression
int stbi_write_force_png_filter; // defaults to -1; set to 0..5 to force a filter mode
You can define STBI_WRITE_NO_STDIO to disable the file variant of these
functions, so the library will not use stdio.h at all. However, this will
also disable HDR writing, because it requires stdio for formatted output.
Each function returns 0 on failure and non-0 on success.
The functions create an image file defined by the parameters. The image
is a rectangle of pixels stored from left-to-right, top-to-bottom.
Each pixel contains 'comp' channels of data stored interleaved with 8-bits
per channel, in the following order: 1=Y, 2=YA, 3=RGB, 4=RGBA. (Y is
monochrome color.) The rectangle is 'w' pixels wide and 'h' pixels tall.
The *data pointer points to the first byte of the top-left-most pixel.
For PNG, "stride_in_bytes" is the distance in bytes from the first byte of
a row of pixels to the first byte of the next row of pixels.
PNG creates output files with the same number of components as the input.
The BMP format expands Y to RGB in the file format and does not
output alpha.
PNG supports writing rectangles of data even when the bytes storing rows of
data are not consecutive in memory (e.g. sub-rectangles of a larger image),
by supplying the stride between the beginning of adjacent rows. The other
formats do not. (Thus you cannot write a native-format BMP through the BMP
writer, both because it is in BGR order and because it may have padding
at the end of the line.)
PNG allows you to set the deflate compression level by setting the global
variable 'stbi_write_png_compression_level' (it defaults to 8).
HDR expects linear float data. Since the format is always 32-bit rgb(e)
data, alpha (if provided) is discarded, and for monochrome data it is
replicated across all three channels.
TGA supports RLE or non-RLE compressed data. To use non-RLE-compressed
data, set the global variable 'stbi_write_tga_with_rle' to 0.
JPEG does ignore alpha channels in input data; quality is between 1 and 100.
Higher quality looks better but results in a bigger image.
JPEG baseline (no JPEG progressive).
CREDITS:
Sean Barrett - PNG/BMP/TGA
Baldur Karlsson - HDR
Jean-Sebastien Guay - TGA monochrome
Tim Kelsey - misc enhancements
Alan Hickman - TGA RLE
Emmanuel Julien - initial file IO callback implementation
Jon Olick - original jo_jpeg.cpp code
Daniel Gibson - integrate JPEG, allow external zlib
Aarni Koskela - allow choosing PNG filter
bugfixes:
github:Chribba
Guillaume Chereau
github:jry2
github:romigrou
Sergio Gonzalez
Jonas Karlsson
Filip Wasil
Thatcher Ulrich
github:poppolopoppo
Patrick Boettcher
github:xeekworx
Cap Petschulat
Simon Rodriguez
Ivan Tikhonov
github:ignotion
Adam Schackart
Andrew Kensler
LICENSE
See end of file for license information.
*/
#ifndef INCLUDE_STB_IMAGE_WRITE_H
#define INCLUDE_STB_IMAGE_WRITE_H
#include
// if STB_IMAGE_WRITE_STATIC causes problems, try defining STBIWDEF to 'inline' or 'static inline'
#ifndef STBIWDEF
#ifdef STB_IMAGE_WRITE_STATIC
#define STBIWDEF static
#else
#ifdef __cplusplus
#define STBIWDEF extern "C"
#else
#define STBIWDEF extern
#endif
#endif
#endif
#ifndef STB_IMAGE_WRITE_STATIC // C++ forbids static forward declarations
STBIWDEF int stbi_write_tga_with_rle;
STBIWDEF int stbi_write_png_compression_level;
STBIWDEF int stbi_write_force_png_filter;
#endif
#ifndef STBI_WRITE_NO_STDIO
STBIWDEF int stbi_write_png(char const *filename, int w, int h, int comp, const void *data, int stride_in_bytes);
STBIWDEF int stbi_write_bmp(char const *filename, int w, int h, int comp, const void *data);
STBIWDEF int stbi_write_tga(char const *filename, int w, int h, int comp, const void *data);
STBIWDEF int stbi_write_hdr(char const *filename, int w, int h, int comp, const float *data);
STBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const void *data, int quality);
#ifdef STBIW_WINDOWS_UTF8
STBIWDEF int stbiw_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input);
#endif
#endif
typedef void stbi_write_func(void *context, void *data, int size);
STBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data, int stride_in_bytes);
STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data);
STBIWDEF int stbi_write_tga_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data);
STBIWDEF int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const float *data);
STBIWDEF int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int quality);
STBIWDEF void stbi_flip_vertically_on_write(int flip_boolean);
#endif//INCLUDE_STB_IMAGE_WRITE_H
#ifdef STB_IMAGE_WRITE_IMPLEMENTATION
#ifdef _WIN32
#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#endif
#ifndef _CRT_NONSTDC_NO_DEPRECATE
#define _CRT_NONSTDC_NO_DEPRECATE
#endif
#endif
#ifndef STBI_WRITE_NO_STDIO
#include
#endif // STBI_WRITE_NO_STDIO
#include
#include
#include
#include
#if defined(STBIW_MALLOC) && defined(STBIW_FREE) && (defined(STBIW_REALLOC) || defined(STBIW_REALLOC_SIZED))
// ok
#elif !defined(STBIW_MALLOC) && !defined(STBIW_FREE) && !defined(STBIW_REALLOC) && !defined(STBIW_REALLOC_SIZED)
// ok
#else
#error "Must define all or none of STBIW_MALLOC, STBIW_FREE, and STBIW_REALLOC (or STBIW_REALLOC_SIZED)."
#endif
#ifndef STBIW_MALLOC
#define STBIW_MALLOC(sz) malloc(sz)
#define STBIW_REALLOC(p,newsz) realloc(p,newsz)
#define STBIW_FREE(p) free(p)
#endif
#ifndef STBIW_REALLOC_SIZED
#define STBIW_REALLOC_SIZED(p,oldsz,newsz) STBIW_REALLOC(p,newsz)
#endif
#ifndef STBIW_MEMMOVE
#define STBIW_MEMMOVE(a,b,sz) memmove(a,b,sz)
#endif
#ifndef STBIW_ASSERT
#include
#define STBIW_ASSERT(x) assert(x)
#endif
#define STBIW_UCHAR(x) (unsigned char) ((x) & 0xff)
#ifdef STB_IMAGE_WRITE_STATIC
static int stbi_write_png_compression_level = 8;
static int stbi_write_tga_with_rle = 1;
static int stbi_write_force_png_filter = -1;
#else
int stbi_write_png_compression_level = 8;
int stbi_write_tga_with_rle = 1;
int stbi_write_force_png_filter = -1;
#endif
static int stbi__flip_vertically_on_write = 0;
STBIWDEF void stbi_flip_vertically_on_write(int flag)
{
stbi__flip_vertically_on_write = flag;
}
typedef struct
{
stbi_write_func *func;
void *context;
unsigned char buffer[64];
int buf_used;
} stbi__write_context;
// initialize a callback-based context
static void stbi__start_write_callbacks(stbi__write_context *s, stbi_write_func *c, void *context)
{
s->func = c;
s->context = context;
}
#ifndef STBI_WRITE_NO_STDIO
static void stbi__stdio_write(void *context, void *data, int size)
{
fwrite(data,1,size,(FILE*) context);
}
#if defined(_WIN32) && defined(STBIW_WINDOWS_UTF8)
#ifdef __cplusplus
#define STBIW_EXTERN extern "C"
#else
#define STBIW_EXTERN extern
#endif
STBIW_EXTERN __declspec(dllimport) int __stdcall MultiByteToWideChar(unsigned int cp, unsigned long flags, const char *str, int cbmb, wchar_t *widestr, int cchwide);
STBIW_EXTERN __declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int cp, unsigned long flags, const wchar_t *widestr, int cchwide, char *str, int cbmb, const char *defchar, int *used_default);
STBIWDEF int stbiw_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input)
{
return WideCharToMultiByte(65001 /* UTF8 */, 0, input, -1, buffer, (int) bufferlen, NULL, NULL);
}
#endif
static FILE *stbiw__fopen(char const *filename, char const *mode)
{
FILE *f;
#if defined(_WIN32) && defined(STBIW_WINDOWS_UTF8)
wchar_t wMode[64];
wchar_t wFilename[1024];
if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, filename, -1, wFilename, sizeof(wFilename)/sizeof(*wFilename)))
return 0;
if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, mode, -1, wMode, sizeof(wMode)/sizeof(*wMode)))
return 0;
#if defined(_MSC_VER) && _MSC_VER >= 1400
if (0 != _wfopen_s(&f, wFilename, wMode))
f = 0;
#else
f = _wfopen(wFilename, wMode);
#endif
#elif defined(_MSC_VER) && _MSC_VER >= 1400
if (0 != fopen_s(&f, filename, mode))
f=0;
#else
f = fopen(filename, mode);
#endif
return f;
}
static int stbi__start_write_file(stbi__write_context *s, const char *filename)
{
FILE *f = stbiw__fopen(filename, "wb");
stbi__start_write_callbacks(s, stbi__stdio_write, (void *) f);
return f != NULL;
}
static void stbi__end_write_file(stbi__write_context *s)
{
fclose((FILE *)s->context);
}
#endif // !STBI_WRITE_NO_STDIO
typedef unsigned int stbiw_uint32;
typedef int stb_image_write_test[sizeof(stbiw_uint32)==4 ? 1 : -1];
static void stbiw__writefv(stbi__write_context *s, const char *fmt, va_list v)
{
while (*fmt) {
switch (*fmt++) {
case ' ': break;
case '1': { unsigned char x = STBIW_UCHAR(va_arg(v, int));
s->func(s->context,&x,1);
break; }
case '2': { int x = va_arg(v,int);
unsigned char b[2];
b[0] = STBIW_UCHAR(x);
b[1] = STBIW_UCHAR(x>>8);
s->func(s->context,b,2);
break; }
case '4': { stbiw_uint32 x = va_arg(v,int);
unsigned char b[4];
b[0]=STBIW_UCHAR(x);
b[1]=STBIW_UCHAR(x>>8);
b[2]=STBIW_UCHAR(x>>16);
b[3]=STBIW_UCHAR(x>>24);
s->func(s->context,b,4);
break; }
default:
STBIW_ASSERT(0);
return;
}
}
}
static void stbiw__writef(stbi__write_context *s, const char *fmt, ...)
{
va_list v;
va_start(v, fmt);
stbiw__writefv(s, fmt, v);
va_end(v);
}
static void stbiw__write_flush(stbi__write_context *s)
{
if (s->buf_used) {
s->func(s->context, &s->buffer, s->buf_used);
s->buf_used = 0;
}
}
static void stbiw__putc(stbi__write_context *s, unsigned char c)
{
s->func(s->context, &c, 1);
}
static void stbiw__write1(stbi__write_context *s, unsigned char a)
{
if ((size_t)s->buf_used + 1 > sizeof(s->buffer))
stbiw__write_flush(s);
s->buffer[s->buf_used++] = a;
}
static void stbiw__write3(stbi__write_context *s, unsigned char a, unsigned char b, unsigned char c)
{
int n;
if ((size_t)s->buf_used + 3 > sizeof(s->buffer))
stbiw__write_flush(s);
n = s->buf_used;
s->buf_used = n+3;
s->buffer[n+0] = a;
s->buffer[n+1] = b;
s->buffer[n+2] = c;
}
static void stbiw__write_pixel(stbi__write_context *s, int rgb_dir, int comp, int write_alpha, int expand_mono, unsigned char *d)
{
unsigned char bg[3] = { 255, 0, 255}, px[3];
int k;
if (write_alpha < 0)
stbiw__write1(s, d[comp - 1]);
switch (comp) {
case 2: // 2 pixels = mono + alpha, alpha is written separately, so same as 1-channel case
case 1:
if (expand_mono)
stbiw__write3(s, d[0], d[0], d[0]); // monochrome bmp
else
stbiw__write1(s, d[0]); // monochrome TGA
break;
case 4:
if (!write_alpha) {
// composite against pink background
for (k = 0; k < 3; ++k)
px[k] = bg[k] + ((d[k] - bg[k]) * d[3]) / 255;
stbiw__write3(s, px[1 - rgb_dir], px[1], px[1 + rgb_dir]);
break;
}
/* FALLTHROUGH */
case 3:
stbiw__write3(s, d[1 - rgb_dir], d[1], d[1 + rgb_dir]);
break;
}
if (write_alpha > 0)
stbiw__write1(s, d[comp - 1]);
}
static void stbiw__write_pixels(stbi__write_context *s, int rgb_dir, int vdir, int x, int y, int comp, void *data, int write_alpha, int scanline_pad, int expand_mono)
{
stbiw_uint32 zero = 0;
int i,j, j_end;
if (y <= 0)
return;
if (stbi__flip_vertically_on_write)
vdir *= -1;
if (vdir < 0) {
j_end = -1; j = y-1;
} else {
j_end = y; j = 0;
}
for (; j != j_end; j += vdir) {
for (i=0; i < x; ++i) {
unsigned char *d = (unsigned char *) data + (j*x+i)*comp;
stbiw__write_pixel(s, rgb_dir, comp, write_alpha, expand_mono, d);
}
stbiw__write_flush(s);
s->func(s->context, &zero, scanline_pad);
}
}
static int stbiw__outfile(stbi__write_context *s, int rgb_dir, int vdir, int x, int y, int comp, int expand_mono, void *data, int alpha, int pad, const char *fmt, ...)
{
if (y < 0 || x < 0) {
return 0;
} else {
va_list v;
va_start(v, fmt);
stbiw__writefv(s, fmt, v);
va_end(v);
stbiw__write_pixels(s,rgb_dir,vdir,x,y,comp,data,alpha,pad, expand_mono);
return 1;
}
}
static int stbi_write_bmp_core(stbi__write_context *s, int x, int y, int comp, const void *data)
{
if (comp != 4) {
// write RGB bitmap
int pad = (-x*3) & 3;
return stbiw__outfile(s,-1,-1,x,y,comp,1,(void *) data,0,pad,
"11 4 22 4" "4 44 22 444444",
'B', 'M', 14+40+(x*3+pad)*y, 0,0, 14+40, // file header
40, x,y, 1,24, 0,0,0,0,0,0); // bitmap header
} else {
// RGBA bitmaps need a v4 header
// use BI_BITFIELDS mode with 32bpp and alpha mask
// (straight BI_RGB with alpha mask doesn't work in most readers)
return stbiw__outfile(s,-1,-1,x,y,comp,1,(void *)data,1,0,
"11 4 22 4" "4 44 22 444444 4444 4 444 444 444 444",
'B', 'M', 14+108+x*y*4, 0, 0, 14+108, // file header
108, x,y, 1,32, 3,0,0,0,0,0, 0xff0000,0xff00,0xff,0xff000000u, 0, 0,0,0, 0,0,0, 0,0,0, 0,0,0); // bitmap V4 header
}
}
STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data)
{
stbi__write_context s = { 0 };
stbi__start_write_callbacks(&s, func, context);
return stbi_write_bmp_core(&s, x, y, comp, data);
}
#ifndef STBI_WRITE_NO_STDIO
STBIWDEF int stbi_write_bmp(char const *filename, int x, int y, int comp, const void *data)
{
stbi__write_context s = { 0 };
if (stbi__start_write_file(&s,filename)) {
int r = stbi_write_bmp_core(&s, x, y, comp, data);
stbi__end_write_file(&s);
return r;
} else
return 0;
}
#endif //!STBI_WRITE_NO_STDIO
static int stbi_write_tga_core(stbi__write_context *s, int x, int y, int comp, void *data)
{
int has_alpha = (comp == 2 || comp == 4);
int colorbytes = has_alpha ? comp-1 : comp;
int format = colorbytes < 2 ? 3 : 2; // 3 color channels (RGB/RGBA) = 2, 1 color channel (Y/YA) = 3
if (y < 0 || x < 0)
return 0;
if (!stbi_write_tga_with_rle) {
return stbiw__outfile(s, -1, -1, x, y, comp, 0, (void *) data, has_alpha, 0,
"111 221 2222 11", 0, 0, format, 0, 0, 0, 0, 0, x, y, (colorbytes + has_alpha) * 8, has_alpha * 8);
} else {
int i,j,k;
int jend, jdir;
stbiw__writef(s, "111 221 2222 11", 0,0,format+8, 0,0,0, 0,0,x,y, (colorbytes + has_alpha) * 8, has_alpha * 8);
if (stbi__flip_vertically_on_write) {
j = 0;
jend = y;
jdir = 1;
} else {
j = y-1;
jend = -1;
jdir = -1;
}
for (; j != jend; j += jdir) {
unsigned char *row = (unsigned char *) data + j * x * comp;
int len;
for (i = 0; i < x; i += len) {
unsigned char *begin = row + i * comp;
int diff = 1;
len = 1;
if (i < x - 1) {
++len;
diff = memcmp(begin, row + (i + 1) * comp, comp);
if (diff) {
const unsigned char *prev = begin;
for (k = i + 2; k < x && len < 128; ++k) {
if (memcmp(prev, row + k * comp, comp)) {
prev += comp;
++len;
} else {
--len;
break;
}
}
} else {
for (k = i + 2; k < x && len < 128; ++k) {
if (!memcmp(begin, row + k * comp, comp)) {
++len;
} else {
break;
}
}
}
}
if (diff) {
unsigned char header = STBIW_UCHAR(len - 1);
stbiw__write1(s, header);
for (k = 0; k < len; ++k) {
stbiw__write_pixel(s, -1, comp, has_alpha, 0, begin + k * comp);
}
} else {
unsigned char header = STBIW_UCHAR(len - 129);
stbiw__write1(s, header);
stbiw__write_pixel(s, -1, comp, has_alpha, 0, begin);
}
}
}
stbiw__write_flush(s);
}
return 1;
}
STBIWDEF int stbi_write_tga_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data)
{
stbi__write_context s = { 0 };
stbi__start_write_callbacks(&s, func, context);
return stbi_write_tga_core(&s, x, y, comp, (void *) data);
}
#ifndef STBI_WRITE_NO_STDIO
STBIWDEF int stbi_write_tga(char const *filename, int x, int y, int comp, const void *data)
{
stbi__write_context s = { 0 };
if (stbi__start_write_file(&s,filename)) {
int r = stbi_write_tga_core(&s, x, y, comp, (void *) data);
stbi__end_write_file(&s);
return r;
} else
return 0;
}
#endif
// *************************************************************************************************
// Radiance RGBE HDR writer
// by Baldur Karlsson
#define stbiw__max(a, b) ((a) > (b) ? (a) : (b))
#ifndef STBI_WRITE_NO_STDIO
static void stbiw__linear_to_rgbe(unsigned char *rgbe, float *linear)
{
int exponent;
float maxcomp = stbiw__max(linear[0], stbiw__max(linear[1], linear[2]));
if (maxcomp < 1e-32f) {
rgbe[0] = rgbe[1] = rgbe[2] = rgbe[3] = 0;
} else {
float normalize = (float) frexp(maxcomp, &exponent) * 256.0f/maxcomp;
rgbe[0] = (unsigned char)(linear[0] * normalize);
rgbe[1] = (unsigned char)(linear[1] * normalize);
rgbe[2] = (unsigned char)(linear[2] * normalize);
rgbe[3] = (unsigned char)(exponent + 128);
}
}
static void stbiw__write_run_data(stbi__write_context *s, int length, unsigned char databyte)
{
unsigned char lengthbyte = STBIW_UCHAR(length+128);
STBIW_ASSERT(length+128 <= 255);
s->func(s->context, &lengthbyte, 1);
s->func(s->context, &databyte, 1);
}
static void stbiw__write_dump_data(stbi__write_context *s, int length, unsigned char *data)
{
unsigned char lengthbyte = STBIW_UCHAR(length);
STBIW_ASSERT(length <= 128); // inconsistent with spec but consistent with official code
s->func(s->context, &lengthbyte, 1);
s->func(s->context, data, length);
}
static void stbiw__write_hdr_scanline(stbi__write_context *s, int width, int ncomp, unsigned char *scratch, float *scanline)
{
unsigned char scanlineheader[4] = { 2, 2, 0, 0 };
unsigned char rgbe[4];
float linear[3];
int x;
scanlineheader[2] = (width&0xff00)>>8;
scanlineheader[3] = (width&0x00ff);
/* skip RLE for images too small or large */
if (width < 8 || width >= 32768) {
for (x=0; x < width; x++) {
switch (ncomp) {
case 4: /* fallthrough */
case 3: linear[2] = scanline[x*ncomp + 2];
linear[1] = scanline[x*ncomp + 1];
linear[0] = scanline[x*ncomp + 0];
break;
default:
linear[0] = linear[1] = linear[2] = scanline[x*ncomp + 0];
break;
}
stbiw__linear_to_rgbe(rgbe, linear);
s->func(s->context, rgbe, 4);
}
} else {
int c,r;
/* encode into scratch buffer */
for (x=0; x < width; x++) {
switch(ncomp) {
case 4: /* fallthrough */
case 3: linear[2] = scanline[x*ncomp + 2];
linear[1] = scanline[x*ncomp + 1];
linear[0] = scanline[x*ncomp + 0];
break;
default:
linear[0] = linear[1] = linear[2] = scanline[x*ncomp + 0];
break;
}
stbiw__linear_to_rgbe(rgbe, linear);
scratch[x + width*0] = rgbe[0];
scratch[x + width*1] = rgbe[1];
scratch[x + width*2] = rgbe[2];
scratch[x + width*3] = rgbe[3];
}
s->func(s->context, scanlineheader, 4);
/* RLE each component separately */
for (c=0; c < 4; c++) {
unsigned char *comp = &scratch[width*c];
x = 0;
while (x < width) {
// find first run
r = x;
while (r+2 < width) {
if (comp[r] == comp[r+1] && comp[r] == comp[r+2])
break;
++r;
}
if (r+2 >= width)
r = width;
// dump up to first run
while (x < r) {
int len = r-x;
if (len > 128) len = 128;
stbiw__write_dump_data(s, len, &comp[x]);
x += len;
}
// if there's a run, output it
if (r+2 < width) { // same test as what we break out of in search loop, so only true if we break'd
// find next byte after run
while (r < width && comp[r] == comp[x])
++r;
// output run up to r
while (x < r) {
int len = r-x;
if (len > 127) len = 127;
stbiw__write_run_data(s, len, comp[x]);
x += len;
}
}
}
}
}
}
static int stbi_write_hdr_core(stbi__write_context *s, int x, int y, int comp, float *data)
{
if (y <= 0 || x <= 0 || data == NULL)
return 0;
else {
// Each component is stored separately. Allocate scratch space for full output scanline.
unsigned char *scratch = (unsigned char *) STBIW_MALLOC(x*4);
int i, len;
char buffer[128];
char header[] = "#?RADIANCE\n# Written by stb_image_write.h\nFORMAT=32-bit_rle_rgbe\n";
s->func(s->context, header, sizeof(header)-1);
#ifdef __STDC_LIB_EXT1__
len = sprintf_s(buffer, sizeof(buffer), "EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x);
#else
len = sprintf(buffer, "EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x);
#endif
s->func(s->context, buffer, len);
for(i=0; i < y; i++)
stbiw__write_hdr_scanline(s, x, comp, scratch, data + comp*x*(stbi__flip_vertically_on_write ? y-1-i : i));
STBIW_FREE(scratch);
return 1;
}
}
STBIWDEF int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const float *data)
{
stbi__write_context s = { 0 };
stbi__start_write_callbacks(&s, func, context);
return stbi_write_hdr_core(&s, x, y, comp, (float *) data);
}
STBIWDEF int stbi_write_hdr(char const *filename, int x, int y, int comp, const float *data)
{
stbi__write_context s = { 0 };
if (stbi__start_write_file(&s,filename)) {
int r = stbi_write_hdr_core(&s, x, y, comp, (float *) data);
stbi__end_write_file(&s);
return r;
} else
return 0;
}
#endif // STBI_WRITE_NO_STDIO
//////////////////////////////////////////////////////////////////////////////
//
// PNG writer
//
#ifndef STBIW_ZLIB_COMPRESS
// stretchy buffer; stbiw__sbpush() == vector<>::push_back() -- stbiw__sbcount() == vector<>::size()
#define stbiw__sbraw(a) ((int *) (void *) (a) - 2)
#define stbiw__sbm(a) stbiw__sbraw(a)[0]
#define stbiw__sbn(a) stbiw__sbraw(a)[1]
#define stbiw__sbneedgrow(a,n) ((a)==0 || stbiw__sbn(a)+n >= stbiw__sbm(a))
#define stbiw__sbmaybegrow(a,n) (stbiw__sbneedgrow(a,(n)) ? stbiw__sbgrow(a,n) : 0)
#define stbiw__sbgrow(a,n) stbiw__sbgrowf((void **) &(a), (n), sizeof(*(a)))
#define stbiw__sbpush(a, v) (stbiw__sbmaybegrow(a,1), (a)[stbiw__sbn(a)++] = (v))
#define stbiw__sbcount(a) ((a) ? stbiw__sbn(a) : 0)
#define stbiw__sbfree(a) ((a) ? STBIW_FREE(stbiw__sbraw(a)),0 : 0)
static void *stbiw__sbgrowf(void **arr, int increment, int itemsize)
{
int m = *arr ? 2*stbiw__sbm(*arr)+increment : increment+1;
void *p = STBIW_REALLOC_SIZED(*arr ? stbiw__sbraw(*arr) : 0, *arr ? (stbiw__sbm(*arr)*itemsize + sizeof(int)*2) : 0, itemsize * m + sizeof(int)*2);
STBIW_ASSERT(p);
if (p) {
if (!*arr) ((int *) p)[1] = 0;
*arr = (void *) ((int *) p + 2);
stbiw__sbm(*arr) = m;
}
return *arr;
}
static unsigned char *stbiw__zlib_flushf(unsigned char *data, unsigned int *bitbuffer, int *bitcount)
{
while (*bitcount >= 8) {
stbiw__sbpush(data, STBIW_UCHAR(*bitbuffer));
*bitbuffer >>= 8;
*bitcount -= 8;
}
return data;
}
static int stbiw__zlib_bitrev(int code, int codebits)
{
int res=0;
while (codebits--) {
res = (res << 1) | (code & 1);
code >>= 1;
}
return res;
}
static unsigned int stbiw__zlib_countm(unsigned char *a, unsigned char *b, int limit)
{
int i;
for (i=0; i < limit && i < 258; ++i)
if (a[i] != b[i]) break;
return i;
}
static unsigned int stbiw__zhash(unsigned char *data)
{
stbiw_uint32 hash = data[0] + (data[1] << 8) + (data[2] << 16);
hash ^= hash << 3;
hash += hash >> 5;
hash ^= hash << 4;
hash += hash >> 17;
hash ^= hash << 25;
hash += hash >> 6;
return hash;
}
#define stbiw__zlib_flush() (out = stbiw__zlib_flushf(out, &bitbuf, &bitcount))
#define stbiw__zlib_add(code,codebits) \
(bitbuf |= (code) << bitcount, bitcount += (codebits), stbiw__zlib_flush())
#define stbiw__zlib_huffa(b,c) stbiw__zlib_add(stbiw__zlib_bitrev(b,c),c)
// default huffman tables
#define stbiw__zlib_huff1(n) stbiw__zlib_huffa(0x30 + (n), 8)
#define stbiw__zlib_huff2(n) stbiw__zlib_huffa(0x190 + (n)-144, 9)
#define stbiw__zlib_huff3(n) stbiw__zlib_huffa(0 + (n)-256,7)
#define stbiw__zlib_huff4(n) stbiw__zlib_huffa(0xc0 + (n)-280,8)
#define stbiw__zlib_huff(n) ((n) <= 143 ? stbiw__zlib_huff1(n) : (n) <= 255 ? stbiw__zlib_huff2(n) : (n) <= 279 ? stbiw__zlib_huff3(n) : stbiw__zlib_huff4(n))
#define stbiw__zlib_huffb(n) ((n) <= 143 ? stbiw__zlib_huff1(n) : stbiw__zlib_huff2(n))
#define stbiw__ZHASH 16384
#endif // STBIW_ZLIB_COMPRESS
STBIWDEF unsigned char * stbi_zlib_compress(unsigned char *data, int data_len, int *out_len, int quality)
{
#ifdef STBIW_ZLIB_COMPRESS
// user provided a zlib compress implementation, use that
return STBIW_ZLIB_COMPRESS(data, data_len, out_len, quality);
#else // use builtin
static unsigned short lengthc[] = { 3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258, 259 };
static unsigned char lengtheb[]= { 0,0,0,0,0,0,0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0 };
static unsigned short distc[] = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577, 32768 };
static unsigned char disteb[] = { 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13 };
unsigned int bitbuf=0;
int i,j, bitcount=0;
unsigned char *out = NULL;
unsigned char ***hash_table = (unsigned char***) STBIW_MALLOC(stbiw__ZHASH * sizeof(unsigned char**));
if (hash_table == NULL)
return NULL;
if (quality < 5) quality = 5;
stbiw__sbpush(out, 0x78); // DEFLATE 32K window
stbiw__sbpush(out, 0x5e); // FLEVEL = 1
stbiw__zlib_add(1,1); // BFINAL = 1
stbiw__zlib_add(1,2); // BTYPE = 1 -- fixed huffman
for (i=0; i < stbiw__ZHASH; ++i)
hash_table[i] = NULL;
i=0;
while (i < data_len-3) {
// hash next 3 bytes of data to be compressed
int h = stbiw__zhash(data+i)&(stbiw__ZHASH-1), best=3;
unsigned char *bestloc = 0;
unsigned char **hlist = hash_table[h];
int n = stbiw__sbcount(hlist);
for (j=0; j < n; ++j) {
if (hlist[j]-data > i-32768) { // if entry lies within window
int d = stbiw__zlib_countm(hlist[j], data+i, data_len-i);
if (d >= best) { best=d; bestloc=hlist[j]; }
}
}
// when hash table entry is too long, delete half the entries
if (hash_table[h] && stbiw__sbn(hash_table[h]) == 2*quality) {
STBIW_MEMMOVE(hash_table[h], hash_table[h]+quality, sizeof(hash_table[h][0])*quality);
stbiw__sbn(hash_table[h]) = quality;
}
stbiw__sbpush(hash_table[h],data+i);
if (bestloc) {
// "lazy matching" - check match at *next* byte, and if it's better, do cur byte as literal
h = stbiw__zhash(data+i+1)&(stbiw__ZHASH-1);
hlist = hash_table[h];
n = stbiw__sbcount(hlist);
for (j=0; j < n; ++j) {
if (hlist[j]-data > i-32767) {
int e = stbiw__zlib_countm(hlist[j], data+i+1, data_len-i-1);
if (e > best) { // if next match is better, bail on current match
bestloc = NULL;
break;
}
}
}
}
if (bestloc) {
int d = (int) (data+i - bestloc); // distance back
STBIW_ASSERT(d <= 32767 && best <= 258);
for (j=0; best > lengthc[j+1]-1; ++j);
stbiw__zlib_huff(j+257);
if (lengtheb[j]) stbiw__zlib_add(best - lengthc[j], lengtheb[j]);
for (j=0; d > distc[j+1]-1; ++j);
stbiw__zlib_add(stbiw__zlib_bitrev(j,5),5);
if (disteb[j]) stbiw__zlib_add(d - distc[j], disteb[j]);
i += best;
} else {
stbiw__zlib_huffb(data[i]);
++i;
}
}
// write out final bytes
for (;i < data_len; ++i)
stbiw__zlib_huffb(data[i]);
stbiw__zlib_huff(256); // end of block
// pad with 0 bits to byte boundary
while (bitcount)
stbiw__zlib_add(0,1);
for (i=0; i < stbiw__ZHASH; ++i)
(void) stbiw__sbfree(hash_table[i]);
STBIW_FREE(hash_table);
// store uncompressed instead if compression was worse
if (stbiw__sbn(out) > data_len + 2 + ((data_len+32766)/32767)*5) {
stbiw__sbn(out) = 2; // truncate to DEFLATE 32K window and FLEVEL = 1
for (j = 0; j < data_len;) {
int blocklen = data_len - j;
if (blocklen > 32767) blocklen = 32767;
stbiw__sbpush(out, data_len - j == blocklen); // BFINAL = ?, BTYPE = 0 -- no compression
stbiw__sbpush(out, STBIW_UCHAR(blocklen)); // LEN
stbiw__sbpush(out, STBIW_UCHAR(blocklen >> 8));
stbiw__sbpush(out, STBIW_UCHAR(~blocklen)); // NLEN
stbiw__sbpush(out, STBIW_UCHAR(~blocklen >> 8));
memcpy(out+stbiw__sbn(out), data+j, blocklen);
stbiw__sbn(out) += blocklen;
j += blocklen;
}
}
{
// compute adler32 on input
unsigned int s1=1, s2=0;
int blocklen = (int) (data_len % 5552);
j=0;
while (j < data_len) {
for (i=0; i < blocklen; ++i) { s1 += data[j+i]; s2 += s1; }
s1 %= 65521; s2 %= 65521;
j += blocklen;
blocklen = 5552;
}
stbiw__sbpush(out, STBIW_UCHAR(s2 >> 8));
stbiw__sbpush(out, STBIW_UCHAR(s2));
stbiw__sbpush(out, STBIW_UCHAR(s1 >> 8));
stbiw__sbpush(out, STBIW_UCHAR(s1));
}
*out_len = stbiw__sbn(out);
// make returned pointer freeable
STBIW_MEMMOVE(stbiw__sbraw(out), out, *out_len);
return (unsigned char *) stbiw__sbraw(out);
#endif // STBIW_ZLIB_COMPRESS
}
static unsigned int stbiw__crc32(unsigned char *buffer, int len)
{
#ifdef STBIW_CRC32
return STBIW_CRC32(buffer, len);
#else
static unsigned int crc_table[256] =
{
0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,
0x0eDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,
0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,
0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,
0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,
0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,
0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,
0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457,
0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB,
0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,
0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,
0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,
0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,
0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,
0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,
0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,
0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,
0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,
0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,
0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB,
0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,
0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
};
unsigned int crc = ~0u;
int i;
for (i=0; i < len; ++i)
crc = (crc >> 8) ^ crc_table[buffer[i] ^ (crc & 0xff)];
return ~crc;
#endif
}
#define stbiw__wpng4(o,a,b,c,d) ((o)[0]=STBIW_UCHAR(a),(o)[1]=STBIW_UCHAR(b),(o)[2]=STBIW_UCHAR(c),(o)[3]=STBIW_UCHAR(d),(o)+=4)
#define stbiw__wp32(data,v) stbiw__wpng4(data, (v)>>24,(v)>>16,(v)>>8,(v));
#define stbiw__wptag(data,s) stbiw__wpng4(data, s[0],s[1],s[2],s[3])
static void stbiw__wpcrc(unsigned char **data, int len)
{
unsigned int crc = stbiw__crc32(*data - len - 4, len+4);
stbiw__wp32(*data, crc);
}
static unsigned char stbiw__paeth(int a, int b, int c)
{
int p = a + b - c, pa = abs(p-a), pb = abs(p-b), pc = abs(p-c);
if (pa <= pb && pa <= pc) return STBIW_UCHAR(a);
if (pb <= pc) return STBIW_UCHAR(b);
return STBIW_UCHAR(c);
}
// @OPTIMIZE: provide an option that always forces left-predict or paeth predict
static void stbiw__encode_png_line(unsigned char *pixels, int stride_bytes, int width, int height, int y, int n, int filter_type, signed char *line_buffer)
{
static int mapping[] = { 0,1,2,3,4 };
static int firstmap[] = { 0,1,0,5,6 };
int *mymap = (y != 0) ? mapping : firstmap;
int i;
int type = mymap[filter_type];
unsigned char *z = pixels + stride_bytes * (stbi__flip_vertically_on_write ? height-1-y : y);
int signed_stride = stbi__flip_vertically_on_write ? -stride_bytes : stride_bytes;
if (type==0) {
memcpy(line_buffer, z, width*n);
return;
}
// first loop isn't optimized since it's just one pixel
for (i = 0; i < n; ++i) {
switch (type) {
case 1: line_buffer[i] = z[i]; break;
case 2: line_buffer[i] = z[i] - z[i-signed_stride]; break;
case 3: line_buffer[i] = z[i] - (z[i-signed_stride]>>1); break;
case 4: line_buffer[i] = (signed char) (z[i] - stbiw__paeth(0,z[i-signed_stride],0)); break;
case 5: line_buffer[i] = z[i]; break;
case 6: line_buffer[i] = z[i]; break;
}
}
switch (type) {
case 1: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - z[i-n]; break;
case 2: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - z[i-signed_stride]; break;
case 3: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - ((z[i-n] + z[i-signed_stride])>>1); break;
case 4: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - stbiw__paeth(z[i-n], z[i-signed_stride], z[i-signed_stride-n]); break;
case 5: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - (z[i-n]>>1); break;
case 6: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - stbiw__paeth(z[i-n], 0,0); break;
}
}
STBIWDEF unsigned char *stbi_write_png_to_mem(const unsigned char *pixels, int stride_bytes, int x, int y, int n, int *out_len)
{
int force_filter = stbi_write_force_png_filter;
int ctype[5] = { -1, 0, 4, 2, 6 };
unsigned char sig[8] = { 137,80,78,71,13,10,26,10 };
unsigned char *out,*o, *filt, *zlib;
signed char *line_buffer;
int j,zlen;
if (stride_bytes == 0)
stride_bytes = x * n;
if (force_filter >= 5) {
force_filter = -1;
}
filt = (unsigned char *) STBIW_MALLOC((x*n+1) * y); if (!filt) return 0;
line_buffer = (signed char *) STBIW_MALLOC(x * n); if (!line_buffer) { STBIW_FREE(filt); return 0; }
for (j=0; j < y; ++j) {
int filter_type;
if (force_filter > -1) {
filter_type = force_filter;
stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, force_filter, line_buffer);
} else { // Estimate the best filter by running through all of them:
int best_filter = 0, best_filter_val = 0x7fffffff, est, i;
for (filter_type = 0; filter_type < 5; filter_type++) {
stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, filter_type, line_buffer);
// Estimate the entropy of the line using this filter; the less, the better.
est = 0;
for (i = 0; i < x*n; ++i) {
est += abs((signed char) line_buffer[i]);
}
if (est < best_filter_val) {
best_filter_val = est;
best_filter = filter_type;
}
}
if (filter_type != best_filter) { // If the last iteration already got us the best filter, don't redo it
stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, best_filter, line_buffer);
filter_type = best_filter;
}
}
// when we get here, filter_type contains the filter type, and line_buffer contains the data
filt[j*(x*n+1)] = (unsigned char) filter_type;
STBIW_MEMMOVE(filt+j*(x*n+1)+1, line_buffer, x*n);
}
STBIW_FREE(line_buffer);
zlib = stbi_zlib_compress(filt, y*( x*n+1), &zlen, stbi_write_png_compression_level);
STBIW_FREE(filt);
if (!zlib) return 0;
// each tag requires 12 bytes of overhead
out = (unsigned char *) STBIW_MALLOC(8 + 12+13 + 12+zlen + 12);
if (!out) return 0;
*out_len = 8 + 12+13 + 12+zlen + 12;
o=out;
STBIW_MEMMOVE(o,sig,8); o+= 8;
stbiw__wp32(o, 13); // header length
stbiw__wptag(o, "IHDR");
stbiw__wp32(o, x);
stbiw__wp32(o, y);
*o++ = 8;
*o++ = STBIW_UCHAR(ctype[n]);
*o++ = 0;
*o++ = 0;
*o++ = 0;
stbiw__wpcrc(&o,13);
stbiw__wp32(o, zlen);
stbiw__wptag(o, "IDAT");
STBIW_MEMMOVE(o, zlib, zlen);
o += zlen;
STBIW_FREE(zlib);
stbiw__wpcrc(&o, zlen);
stbiw__wp32(o,0);
stbiw__wptag(o, "IEND");
stbiw__wpcrc(&o,0);
STBIW_ASSERT(o == out + *out_len);
return out;
}
#ifndef STBI_WRITE_NO_STDIO
STBIWDEF int stbi_write_png(char const *filename, int x, int y, int comp, const void *data, int stride_bytes)
{
FILE *f;
int len;
unsigned char *png = stbi_write_png_to_mem((const unsigned char *) data, stride_bytes, x, y, comp, &len);
if (png == NULL) return 0;
f = stbiw__fopen(filename, "wb");
if (!f) { STBIW_FREE(png); return 0; }
fwrite(png, 1, len, f);
fclose(f);
STBIW_FREE(png);
return 1;
}
#endif
STBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int stride_bytes)
{
int len;
unsigned char *png = stbi_write_png_to_mem((const unsigned char *) data, stride_bytes, x, y, comp, &len);
if (png == NULL) return 0;
func(context, png, len);
STBIW_FREE(png);
return 1;
}
/* ***************************************************************************
*
* JPEG writer
*
* This is based on Jon Olick's jo_jpeg.cpp:
* public domain Simple, Minimalistic JPEG writer - http://www.jonolick.com/code.html
*/
static const unsigned char stbiw__jpg_ZigZag[] = { 0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18,
24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63 };
static void stbiw__jpg_writeBits(stbi__write_context *s, int *bitBufP, int *bitCntP, const unsigned short *bs) {
int bitBuf = *bitBufP, bitCnt = *bitCntP;
bitCnt += bs[1];
bitBuf |= bs[0] << (24 - bitCnt);
while(bitCnt >= 8) {
unsigned char c = (bitBuf >> 16) & 255;
stbiw__putc(s, c);
if(c == 255) {
stbiw__putc(s, 0);
}
bitBuf <<= 8;
bitCnt -= 8;
}
*bitBufP = bitBuf;
*bitCntP = bitCnt;
}
static void stbiw__jpg_DCT(float *d0p, float *d1p, float *d2p, float *d3p, float *d4p, float *d5p, float *d6p, float *d7p) {
float d0 = *d0p, d1 = *d1p, d2 = *d2p, d3 = *d3p, d4 = *d4p, d5 = *d5p, d6 = *d6p, d7 = *d7p;
float z1, z2, z3, z4, z5, z11, z13;
float tmp0 = d0 + d7;
float tmp7 = d0 - d7;
float tmp1 = d1 + d6;
float tmp6 = d1 - d6;
float tmp2 = d2 + d5;
float tmp5 = d2 - d5;
float tmp3 = d3 + d4;
float tmp4 = d3 - d4;
// Even part
float tmp10 = tmp0 + tmp3; // phase 2
float tmp13 = tmp0 - tmp3;
float tmp11 = tmp1 + tmp2;
float tmp12 = tmp1 - tmp2;
d0 = tmp10 + tmp11; // phase 3
d4 = tmp10 - tmp11;
z1 = (tmp12 + tmp13) * 0.707106781f; // c4
d2 = tmp13 + z1; // phase 5
d6 = tmp13 - z1;
// Odd part
tmp10 = tmp4 + tmp5; // phase 2
tmp11 = tmp5 + tmp6;
tmp12 = tmp6 + tmp7;
// The rotator is modified from fig 4-8 to avoid extra negations.
z5 = (tmp10 - tmp12) * 0.382683433f; // c6
z2 = tmp10 * 0.541196100f + z5; // c2-c6
z4 = tmp12 * 1.306562965f + z5; // c2+c6
z3 = tmp11 * 0.707106781f; // c4
z11 = tmp7 + z3; // phase 5
z13 = tmp7 - z3;
*d5p = z13 + z2; // phase 6
*d3p = z13 - z2;
*d1p = z11 + z4;
*d7p = z11 - z4;
*d0p = d0; *d2p = d2; *d4p = d4; *d6p = d6;
}
static void stbiw__jpg_calcBits(int val, unsigned short bits[2]) {
int tmp1 = val < 0 ? -val : val;
val = val < 0 ? val-1 : val;
bits[1] = 1;
while(tmp1 >>= 1) {
++bits[1];
}
bits[0] = val & ((1<0)&&(DU[end0pos]==0); --end0pos) {
}
// end0pos = first element in reverse order !=0
if(end0pos == 0) {
stbiw__jpg_writeBits(s, bitBuf, bitCnt, EOB);
return DU[0];
}
for(i = 1; i <= end0pos; ++i) {
int startpos = i;
int nrzeroes;
unsigned short bits[2];
for (; DU[i]==0 && i<=end0pos; ++i) {
}
nrzeroes = i-startpos;
if ( nrzeroes >= 16 ) {
int lng = nrzeroes>>4;
int nrmarker;
for (nrmarker=1; nrmarker <= lng; ++nrmarker)
stbiw__jpg_writeBits(s, bitBuf, bitCnt, M16zeroes);
nrzeroes &= 15;
}
stbiw__jpg_calcBits(DU[i], bits);
stbiw__jpg_writeBits(s, bitBuf, bitCnt, HTAC[(nrzeroes<<4)+bits[1]]);
stbiw__jpg_writeBits(s, bitBuf, bitCnt, bits);
}
if(end0pos != 63) {
stbiw__jpg_writeBits(s, bitBuf, bitCnt, EOB);
}
return DU[0];
}
static int stbi_write_jpg_core(stbi__write_context *s, int width, int height, int comp, const void* data, int quality) {
// Constants that don't pollute global namespace
static const unsigned char std_dc_luminance_nrcodes[] = {0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0};
static const unsigned char std_dc_luminance_values[] = {0,1,2,3,4,5,6,7,8,9,10,11};
static const unsigned char std_ac_luminance_nrcodes[] = {0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,0x7d};
static const unsigned char std_ac_luminance_values[] = {
0x01,0x02,0x03,0x00,0x04,0x11,0x05,0x12,0x21,0x31,0x41,0x06,0x13,0x51,0x61,0x07,0x22,0x71,0x14,0x32,0x81,0x91,0xa1,0x08,
0x23,0x42,0xb1,0xc1,0x15,0x52,0xd1,0xf0,0x24,0x33,0x62,0x72,0x82,0x09,0x0a,0x16,0x17,0x18,0x19,0x1a,0x25,0x26,0x27,0x28,
0x29,0x2a,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x53,0x54,0x55,0x56,0x57,0x58,0x59,
0x5a,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x83,0x84,0x85,0x86,0x87,0x88,0x89,
0x8a,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xb2,0xb3,0xb4,0xb5,0xb6,
0xb7,0xb8,0xb9,0xba,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xe1,0xe2,
0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa
};
static const unsigned char std_dc_chrominance_nrcodes[] = {0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0};
static const unsigned char std_dc_chrominance_values[] = {0,1,2,3,4,5,6,7,8,9,10,11};
static const unsigned char std_ac_chrominance_nrcodes[] = {0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,0x77};
static const unsigned char std_ac_chrominance_values[] = {
0x00,0x01,0x02,0x03,0x11,0x04,0x05,0x21,0x31,0x06,0x12,0x41,0x51,0x07,0x61,0x71,0x13,0x22,0x32,0x81,0x08,0x14,0x42,0x91,
0xa1,0xb1,0xc1,0x09,0x23,0x33,0x52,0xf0,0x15,0x62,0x72,0xd1,0x0a,0x16,0x24,0x34,0xe1,0x25,0xf1,0x17,0x18,0x19,0x1a,0x26,
0x27,0x28,0x29,0x2a,0x35,0x36,0x37,0x38,0x39,0x3a,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x53,0x54,0x55,0x56,0x57,0x58,
0x59,0x5a,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x82,0x83,0x84,0x85,0x86,0x87,
0x88,0x89,0x8a,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xb2,0xb3,0xb4,
0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,
0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa
};
// Huffman tables
static const unsigned short YDC_HT[256][2] = { {0,2},{2,3},{3,3},{4,3},{5,3},{6,3},{14,4},{30,5},{62,6},{126,7},{254,8},{510,9}};
static const unsigned short UVDC_HT[256][2] = { {0,2},{1,2},{2,2},{6,3},{14,4},{30,5},{62,6},{126,7},{254,8},{510,9},{1022,10},{2046,11}};
static const unsigned short YAC_HT[256][2] = {
{10,4},{0,2},{1,2},{4,3},{11,4},{26,5},{120,7},{248,8},{1014,10},{65410,16},{65411,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
{12,4},{27,5},{121,7},{502,9},{2038,11},{65412,16},{65413,16},{65414,16},{65415,16},{65416,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
{28,5},{249,8},{1015,10},{4084,12},{65417,16},{65418,16},{65419,16},{65420,16},{65421,16},{65422,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
{58,6},{503,9},{4085,12},{65423,16},{65424,16},{65425,16},{65426,16},{65427,16},{65428,16},{65429,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
{59,6},{1016,10},{65430,16},{65431,16},{65432,16},{65433,16},{65434,16},{65435,16},{65436,16},{65437,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
{122,7},{2039,11},{65438,16},{65439,16},{65440,16},{65441,16},{65442,16},{65443,16},{65444,16},{65445,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
{123,7},{4086,12},{65446,16},{65447,16},{65448,16},{65449,16},{65450,16},{65451,16},{65452,16},{65453,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
{250,8},{4087,12},{65454,16},{65455,16},{65456,16},{65457,16},{65458,16},{65459,16},{65460,16},{65461,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
{504,9},{32704,15},{65462,16},{65463,16},{65464,16},{65465,16},{65466,16},{65467,16},{65468,16},{65469,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
{505,9},{65470,16},{65471,16},{65472,16},{65473,16},{65474,16},{65475,16},{65476,16},{65477,16},{65478,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
{506,9},{65479,16},{65480,16},{65481,16},{65482,16},{65483,16},{65484,16},{65485,16},{65486,16},{65487,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
{1017,10},{65488,16},{65489,16},{65490,16},{65491,16},{65492,16},{65493,16},{65494,16},{65495,16},{65496,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
{1018,10},{65497,16},{65498,16},{65499,16},{65500,16},{65501,16},{65502,16},{65503,16},{65504,16},{65505,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
{2040,11},{65506,16},{65507,16},{65508,16},{65509,16},{65510,16},{65511,16},{65512,16},{65513,16},{65514,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
{65515,16},{65516,16},{65517,16},{65518,16},{65519,16},{65520,16},{65521,16},{65522,16},{65523,16},{65524,16},{0,0},{0,0},{0,0},{0,0},{0,0},
{2041,11},{65525,16},{65526,16},{65527,16},{65528,16},{65529,16},{65530,16},{65531,16},{65532,16},{65533,16},{65534,16},{0,0},{0,0},{0,0},{0,0},{0,0}
};
static const unsigned short UVAC_HT[256][2] = {
{0,2},{1,2},{4,3},{10,4},{24,5},{25,5},{56,6},{120,7},{500,9},{1014,10},{4084,12},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
{11,4},{57,6},{246,8},{501,9},{2038,11},{4085,12},{65416,16},{65417,16},{65418,16},{65419,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
{26,5},{247,8},{1015,10},{4086,12},{32706,15},{65420,16},{65421,16},{65422,16},{65423,16},{65424,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
{27,5},{248,8},{1016,10},{4087,12},{65425,16},{65426,16},{65427,16},{65428,16},{65429,16},{65430,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
{58,6},{502,9},{65431,16},{65432,16},{65433,16},{65434,16},{65435,16},{65436,16},{65437,16},{65438,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
{59,6},{1017,10},{65439,16},{65440,16},{65441,16},{65442,16},{65443,16},{65444,16},{65445,16},{65446,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
{121,7},{2039,11},{65447,16},{65448,16},{65449,16},{65450,16},{65451,16},{65452,16},{65453,16},{65454,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
{122,7},{2040,11},{65455,16},{65456,16},{65457,16},{65458,16},{65459,16},{65460,16},{65461,16},{65462,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
{249,8},{65463,16},{65464,16},{65465,16},{65466,16},{65467,16},{65468,16},{65469,16},{65470,16},{65471,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
{503,9},{65472,16},{65473,16},{65474,16},{65475,16},{65476,16},{65477,16},{65478,16},{65479,16},{65480,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
{504,9},{65481,16},{65482,16},{65483,16},{65484,16},{65485,16},{65486,16},{65487,16},{65488,16},{65489,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
{505,9},{65490,16},{65491,16},{65492,16},{65493,16},{65494,16},{65495,16},{65496,16},{65497,16},{65498,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
{506,9},{65499,16},{65500,16},{65501,16},{65502,16},{65503,16},{65504,16},{65505,16},{65506,16},{65507,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
{2041,11},{65508,16},{65509,16},{65510,16},{65511,16},{65512,16},{65513,16},{65514,16},{65515,16},{65516,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
{16352,14},{65517,16},{65518,16},{65519,16},{65520,16},{65521,16},{65522,16},{65523,16},{65524,16},{65525,16},{0,0},{0,0},{0,0},{0,0},{0,0},
{1018,10},{32707,15},{65526,16},{65527,16},{65528,16},{65529,16},{65530,16},{65531,16},{65532,16},{65533,16},{65534,16},{0,0},{0,0},{0,0},{0,0},{0,0}
};
static const int YQT[] = {16,11,10,16,24,40,51,61,12,12,14,19,26,58,60,55,14,13,16,24,40,57,69,56,14,17,22,29,51,87,80,62,18,22,
37,56,68,109,103,77,24,35,55,64,81,104,113,92,49,64,78,87,103,121,120,101,72,92,95,98,112,100,103,99};
static const int UVQT[] = {17,18,24,47,99,99,99,99,18,21,26,66,99,99,99,99,24,26,56,99,99,99,99,99,47,66,99,99,99,99,99,99,
99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99};
static const float aasf[] = { 1.0f * 2.828427125f, 1.387039845f * 2.828427125f, 1.306562965f * 2.828427125f, 1.175875602f * 2.828427125f,
1.0f * 2.828427125f, 0.785694958f * 2.828427125f, 0.541196100f * 2.828427125f, 0.275899379f * 2.828427125f };
int row, col, i, k, subsample;
float fdtbl_Y[64], fdtbl_UV[64];
unsigned char YTable[64], UVTable[64];
if(!data || !width || !height || comp > 4 || comp < 1) {
return 0;
}
quality = quality ? quality : 90;
subsample = quality <= 90 ? 1 : 0;
quality = quality < 1 ? 1 : quality > 100 ? 100 : quality;
quality = quality < 50 ? 5000 / quality : 200 - quality * 2;
for(i = 0; i < 64; ++i) {
int uvti, yti = (YQT[i]*quality+50)/100;
YTable[stbiw__jpg_ZigZag[i]] = (unsigned char) (yti < 1 ? 1 : yti > 255 ? 255 : yti);
uvti = (UVQT[i]*quality+50)/100;
UVTable[stbiw__jpg_ZigZag[i]] = (unsigned char) (uvti < 1 ? 1 : uvti > 255 ? 255 : uvti);
}
for(row = 0, k = 0; row < 8; ++row) {
for(col = 0; col < 8; ++col, ++k) {
fdtbl_Y[k] = 1 / (YTable [stbiw__jpg_ZigZag[k]] * aasf[row] * aasf[col]);
fdtbl_UV[k] = 1 / (UVTable[stbiw__jpg_ZigZag[k]] * aasf[row] * aasf[col]);
}
}
// Write Headers
{
static const unsigned char head0[] = { 0xFF,0xD8,0xFF,0xE0,0,0x10,'J','F','I','F',0,1,1,0,0,1,0,1,0,0,0xFF,0xDB,0,0x84,0 };
static const unsigned char head2[] = { 0xFF,0xDA,0,0xC,3,1,0,2,0x11,3,0x11,0,0x3F,0 };
const unsigned char head1[] = { 0xFF,0xC0,0,0x11,8,(unsigned char)(height>>8),STBIW_UCHAR(height),(unsigned char)(width>>8),STBIW_UCHAR(width),
3,1,(unsigned char)(subsample?0x22:0x11),0,2,0x11,1,3,0x11,1,0xFF,0xC4,0x01,0xA2,0 };
s->func(s->context, (void*)head0, sizeof(head0));
s->func(s->context, (void*)YTable, sizeof(YTable));
stbiw__putc(s, 1);
s->func(s->context, UVTable, sizeof(UVTable));
s->func(s->context, (void*)head1, sizeof(head1));
s->func(s->context, (void*)(std_dc_luminance_nrcodes+1), sizeof(std_dc_luminance_nrcodes)-1);
s->func(s->context, (void*)std_dc_luminance_values, sizeof(std_dc_luminance_values));
stbiw__putc(s, 0x10); // HTYACinfo
s->func(s->context, (void*)(std_ac_luminance_nrcodes+1), sizeof(std_ac_luminance_nrcodes)-1);
s->func(s->context, (void*)std_ac_luminance_values, sizeof(std_ac_luminance_values));
stbiw__putc(s, 1); // HTUDCinfo
s->func(s->context, (void*)(std_dc_chrominance_nrcodes+1), sizeof(std_dc_chrominance_nrcodes)-1);
s->func(s->context, (void*)std_dc_chrominance_values, sizeof(std_dc_chrominance_values));
stbiw__putc(s, 0x11); // HTUACinfo
s->func(s->context, (void*)(std_ac_chrominance_nrcodes+1), sizeof(std_ac_chrominance_nrcodes)-1);
s->func(s->context, (void*)std_ac_chrominance_values, sizeof(std_ac_chrominance_values));
s->func(s->context, (void*)head2, sizeof(head2));
}
// Encode 8x8 macroblocks
{
static const unsigned short fillBits[] = {0x7F, 7};
int DCY=0, DCU=0, DCV=0;
int bitBuf=0, bitCnt=0;
// comp == 2 is grey+alpha (alpha is ignored)
int ofsG = comp > 2 ? 1 : 0, ofsB = comp > 2 ? 2 : 0;
const unsigned char *dataR = (const unsigned char *)data;
const unsigned char *dataG = dataR + ofsG;
const unsigned char *dataB = dataR + ofsB;
int x, y, pos;
if(subsample) {
for(y = 0; y < height; y += 16) {
for(x = 0; x < width; x += 16) {
float Y[256], U[256], V[256];
for(row = y, pos = 0; row < y+16; ++row) {
// row >= height => use last input row
int clamped_row = (row < height) ? row : height - 1;
int base_p = (stbi__flip_vertically_on_write ? (height-1-clamped_row) : clamped_row)*width*comp;
for(col = x; col < x+16; ++col, ++pos) {
// if col >= width => use pixel from last input column
int p = base_p + ((col < width) ? col : (width-1))*comp;
float r = dataR[p], g = dataG[p], b = dataB[p];
Y[pos]= +0.29900f*r + 0.58700f*g + 0.11400f*b - 128;
U[pos]= -0.16874f*r - 0.33126f*g + 0.50000f*b;
V[pos]= +0.50000f*r - 0.41869f*g - 0.08131f*b;
}
}
DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+0, 16, fdtbl_Y, DCY, YDC_HT, YAC_HT);
DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+8, 16, fdtbl_Y, DCY, YDC_HT, YAC_HT);
DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+128, 16, fdtbl_Y, DCY, YDC_HT, YAC_HT);
DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+136, 16, fdtbl_Y, DCY, YDC_HT, YAC_HT);
// subsample U,V
{
float subU[64], subV[64];
int yy, xx;
for(yy = 0, pos = 0; yy < 8; ++yy) {
for(xx = 0; xx < 8; ++xx, ++pos) {
int j = yy*32+xx*2;
subU[pos] = (U[j+0] + U[j+1] + U[j+16] + U[j+17]) * 0.25f;
subV[pos] = (V[j+0] + V[j+1] + V[j+16] + V[j+17]) * 0.25f;
}
}
DCU = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, subU, 8, fdtbl_UV, DCU, UVDC_HT, UVAC_HT);
DCV = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, subV, 8, fdtbl_UV, DCV, UVDC_HT, UVAC_HT);
}
}
}
} else {
for(y = 0; y < height; y += 8) {
for(x = 0; x < width; x += 8) {
float Y[64], U[64], V[64];
for(row = y, pos = 0; row < y+8; ++row) {
// row >= height => use last input row
int clamped_row = (row < height) ? row : height - 1;
int base_p = (stbi__flip_vertically_on_write ? (height-1-clamped_row) : clamped_row)*width*comp;
for(col = x; col < x+8; ++col, ++pos) {
// if col >= width => use pixel from last input column
int p = base_p + ((col < width) ? col : (width-1))*comp;
float r = dataR[p], g = dataG[p], b = dataB[p];
Y[pos]= +0.29900f*r + 0.58700f*g + 0.11400f*b - 128;
U[pos]= -0.16874f*r - 0.33126f*g + 0.50000f*b;
V[pos]= +0.50000f*r - 0.41869f*g - 0.08131f*b;
}
}
DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y, 8, fdtbl_Y, DCY, YDC_HT, YAC_HT);
DCU = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, U, 8, fdtbl_UV, DCU, UVDC_HT, UVAC_HT);
DCV = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, V, 8, fdtbl_UV, DCV, UVDC_HT, UVAC_HT);
}
}
}
// Do the bit alignment of the EOI marker
stbiw__jpg_writeBits(s, &bitBuf, &bitCnt, fillBits);
}
// EOI
stbiw__putc(s, 0xFF);
stbiw__putc(s, 0xD9);
return 1;
}
STBIWDEF int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int quality)
{
stbi__write_context s = { 0 };
stbi__start_write_callbacks(&s, func, context);
return stbi_write_jpg_core(&s, x, y, comp, (void *) data, quality);
}
#ifndef STBI_WRITE_NO_STDIO
STBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const void *data, int quality)
{
stbi__write_context s = { 0 };
if (stbi__start_write_file(&s,filename)) {
int r = stbi_write_jpg_core(&s, x, y, comp, data, quality);
stbi__end_write_file(&s);
return r;
} else
return 0;
}
#endif
#endif // STB_IMAGE_WRITE_IMPLEMENTATION
/* Revision history
1.16 (2021-07-11)
make Deflate code emit uncompressed blocks when it would otherwise expand
support writing BMPs with alpha channel
1.15 (2020-07-13) unknown
1.14 (2020-02-02) updated JPEG writer to downsample chroma channels
1.13
1.12
1.11 (2019-08-11)
1.10 (2019-02-07)
support utf8 filenames in Windows; fix warnings and platform ifdefs
1.09 (2018-02-11)
fix typo in zlib quality API, improve STB_I_W_STATIC in C++
1.08 (2018-01-29)
add stbi__flip_vertically_on_write, external zlib, zlib quality, choose PNG filter
1.07 (2017-07-24)
doc fix
1.06 (2017-07-23)
writing JPEG (using Jon Olick's code)
1.05 ???
1.04 (2017-03-03)
monochrome BMP expansion
1.03 ???
1.02 (2016-04-02)
avoid allocating large structures on the stack
1.01 (2016-01-16)
STBIW_REALLOC_SIZED: support allocators with no realloc support
avoid race-condition in crc initialization
minor compile issues
1.00 (2015-09-14)
installable file IO function
0.99 (2015-09-13)
warning fixes; TGA rle support
0.98 (2015-04-08)
added STBIW_MALLOC, STBIW_ASSERT etc
0.97 (2015-01-18)
fixed HDR asserts, rewrote HDR rle logic
0.96 (2015-01-17)
add HDR output
fix monochrome BMP
0.95 (2014-08-17)
add monochrome TGA output
0.94 (2014-05-31)
rename private functions to avoid conflicts with stb_image.h
0.93 (2014-05-27)
warning fixes
0.92 (2010-08-01)
casts to unsigned char to fix warnings
0.91 (2010-07-17)
first public release
0.90 first internal release
*/
/*
------------------------------------------------------------------------------
This software is available under 2 licenses -- choose whichever you prefer.
------------------------------------------------------------------------------
ALTERNATIVE A - MIT License
Copyright (c) 2017 Sean Barrett
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
------------------------------------------------------------------------------
ALTERNATIVE B - Public Domain (www.unlicense.org)
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
software, either in source code form or as a compiled binary, for any purpose,
commercial or non-commercial, and by any means.
In jurisdictions that recognize copyright laws, the author or authors of this
software dedicate any and all copyright interest in the software to the public
domain. We make this dedication for the benefit of the public at large and to
the detriment of our heirs and successors. We intend this dedication to be an
overt act of relinquishment in perpetuity of all present and future rights to
this software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
------------------------------------------------------------------------------
*/
fsdsfdsfdsfdsf-5.13.8/extra/ 0000775 0000000 0000000 00000000000 15202152077 0015730 5 ustar 00root root 0000000 0000000 fsdsfdsfdsfdsf-5.13.8/extra/gpu-screen-recorder.env 0000664 0000000 0000000 00000000370 15202152077 0022315 0 ustar 00root root 0000000 0000000 WINDOW=screen
CONTAINER=mp4
CODEC=h264
AUDIO_CODEC=opus
AUDIO_DEVICE=default_output
SECONDARY_AUDIO_DEVICE=default_input
FRAMERATE=60
REPLAYDURATION=60
OUTPUTDIR=/run/media/dec05eba/SSD1TB/Videos/aaaa
KEYINT=2
ENCODER=gpu
RESTORE_PORTAL_SESSION=yes fsdsfdsfdsfdsf-5.13.8/extra/gpu-screen-recorder.service 0000664 0000000 0000000 00000002314 15202152077 0023165 0 ustar 00root root 0000000 0000000 [Unit]
Description=GPU Screen Recorder Service
[Service]
EnvironmentFile=-%h/.config/gpu-screen-recorder.env
EnvironmentFile=-%h/.config/gpu-screen-recorder/gpu-screen-recorder.env
Environment=WINDOW=screen
Environment=CONTAINER=mp4
Environment=QUALITY=40000
Environment=BITRATE_MODE=cbr
Environment=CODEC=auto
Environment=AUDIO_CODEC=opus
Environment=AUDIO_DEVICE=default_output
Environment=SECONDARY_AUDIO_DEVICE=
Environment=FRAMERATE=60
Environment=REPLAYDURATION=60
Environment=OUTPUTDIR=%h/Videos
Environment=MAKEFOLDERS=no
Environment=COLOR_RANGE=limited
Environment=KEYINT=2
Environment=ENCODER=gpu
Environment=RESTORE_PORTAL_SESSION=yes
Environment=OUTPUT_RESOLUTION=0x0
Environment=ADDITIONAL_ARGS=
ExecStart=gpu-screen-recorder -v no -w "${WINDOW}" -s "${OUTPUT_RESOLUTION}" -c "${CONTAINER}" -q "${QUALITY}" -k "${CODEC}" -ac "${AUDIO_CODEC}" -a "${AUDIO_DEVICE}" -a "${SECONDARY_AUDIO_DEVICE}" -f "${FRAMERATE}" -r "${REPLAYDURATION}" -o "${OUTPUTDIR}" -df "${MAKEFOLDERS}" $ADDITIONAL_ARGS -cr "${COLOR_RANGE}" -keyint "${KEYINT}" -restore-portal-session "${RESTORE_PORTAL_SESSION}" -encoder "${ENCODER}" -bm "${BITRATE_MODE}"
KillSignal=SIGINT
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=default.target
fsdsfdsfdsfdsf-5.13.8/extra/gsr-nvidia.conf 0000664 0000000 0000000 00000000066 15202152077 0020644 0 ustar 00root root 0000000 0000000 options nvidia NVreg_PreserveVideoMemoryAllocations=1
fsdsfdsfdsfdsf-5.13.8/extra/meson_post_install.sh 0000775 0000000 0000000 00000000421 15202152077 0022200 0 ustar 00root root 0000000 0000000 #!/bin/sh
# Needed to remove password prompt when recording a monitor (without desktop portal option) on amd/intel or nvidia wayland
/usr/sbin/setcap cap_sys_admin+ep ${MESON_INSTALL_DESTDIR_PREFIX}/bin/gsr-kms-server \
|| echo "\n!!! Please re-run install as root\n"
fsdsfdsfdsfdsf-5.13.8/gpu-screen-recorder.1 0000664 0000000 0000000 00000041056 15202152077 0020550 0 ustar 00root root 0000000 0000000 .TH GPU-SCREEN-RECORDER 1 "2026-05-07" "5.13.4" "GPU Screen Recorder Manual"
.SH NAME
gpu-screen-recorder \- The fastest screen recording tool for Linux
.SH SYNOPSIS
.B gpu-screen-recorder
.B \-w
.I window_id|monitor|focused|portal|region|v4l2_device_path
.RI [ options ]
.B \-o
.I output_file
.PP
.B gpu-screen-recorder
.B \-\-help
|
.B \-\-version
|
.B \-\-info
|
.B \-\-list\-capture\-options
|
.B \-\-list\-monitors
|
.B \-\-list\-v4l2\-devices
|
.B \-\-list\-audio\-devices
|
.B \-\-list\-application\-audio
.SH DESCRIPTION
.B gpu-screen-recorder
is the fastest screen recording tool for Linux. It uses the GPU
only to record the screen to minimize system performance impact. It supports recording,
live streaming, instant replay (similar to NVIDIA ShadowPlay), and
screenshot capture. The tool works on both X11 and Wayland with AMD,
Intel, and NVIDIA graphics cards.
.PP
Key features include:
.RS
.IP \(bu 3
GPU-accelerated encoding using H264, HEVC, AV1, VP8, or VP9 codecs
.IP \(bu 3
Support for HDR recording (HEVC HDR and AV1 HDR)
.IP \(bu 3
Instant replay buffer (last N seconds recording)
.IP \(bu 3
Live streaming capabilities
.IP \(bu 3
Audio recording from devices and applications (PipeWire required for app audio)
.IP \(bu 3
Plugin system for custom graphics overlay
.IP \(bu 3
Minimal performance impact compared to traditional screen recorders
.RE
.SH OPTIONS
.SS Capture Options
.TP
.BI \-w " window_id|monitor|focused|portal|region|v4l2_device_path"
Specify what to record.
Formats:
.RS
.IP \(bu 3
.B window
- Record a specific window (use window ID) (X11 only)
.IP \(bu 3
.B screen
- Record the first monitor found
.IP \(bu 3
.B screen\-direct
- NVIDIA X11 only, for VRR/G-SYNC support (not recommended due to driver issues)
.IP \(bu 3
.B focused
- Record the currently focused window (X11 only) (use with -s option)
.IP \(bu 3
.B portal
- Use xdg-desktop-portal with PipeWire (Wayland only)
.IP \(bu 3
.B region
- Record a specific region (use with
.B \-region
option)
.IP \(bu 3
Monitor name (e.g.,
.BR DP\-1 )
- Record specific monitor
.IP \(bu 3
V4L2 device path (e.g.,
.BR /dev/video0 )
- Record camera device (V4L2).
Other applications can't use the camera when GPU Screen Recorder is using the camera and GPU Screen Recorder may not be able to use the camera if another application is already using the camera
.IP \(bu 3
Combine sources with | (e.g.,
.BR "monitor:screen|v4l2:/dev/video0" )
.RE
.PP
Run
.B \-\-list\-capture\-options
to list available capture sources.
.PP
Additional options can be passed to each capture source by splitting capture source with
.B ;
for example
.BR "screen;x=50;y=50".
.br
These are the available options for all capture sources (optional):
.RS
.IP \(bu 3
.B x
- The X position in pixels. If the number ends with % then this sets the X position relative to the video width (integer percentage where 100 = 100%)
.IP \(bu 3
.B y
- The Y position in pixels. If the number ends with % then this sets the Y position relative to the video height (integer percentage where 100 = 100%)
.IP \(bu 3
.B width
- The width in pixels. If the number ends with % then this sets the width relative to the video width (integer percentage where 100 = 100%).
A value of 0 means to not scale the capture source and instead use the original width.
.IP \(bu 3
.B height
- The height in pixels. If the number ends with % then this sets the height relative to the video height (integer percentage where 100 = 100%).
A value of 0 means to not scale the capture source and instead use the original height.
.IP \(bu 3
.B halign
- The horizontal alignment, should be either
.BR "start",
.B center
or
.BR "end".
Set to
.B center
by default when using one capture source, otherwise it's set to
.B start
by default.
.IP \(bu 3
.B valign
- The vertical alignment, should be either
.BR "start",
.B center
or
.BR "end".
Set to
.B center
by default when using one capture source, otherwise it's set to
.B start
by default.
.IP \(bu 3
.B hflip
- If the source should be flipped horizontally, should be either
.B "true"
or
.BR "false".
Set to
.B false
by default
.IP \(bu 3
.B vflip
- If the source should be flipped vertically, should be either
.B "true"
or
.BR "false".
Set to
.B false
by default
.RE
.PP
These are the additional options available for camera (V4L2) sources (optional):
.RS
.IP \(bu 3
.B pixfmt
- The pixel format, should be either
.BR "auto",
.B yuyv
or
.BR "mjpeg".
Set to
.B auto
by default
.IP \(bu 3
.B camera_fps
- The camera fps. Has to match a camera fps returned in
.B --info
or
.B --list-v4l2-devices
for the device.
A value of 0 means to use the best option available.
.IP \(bu 3
.B camera_width
- The camera width in pixels. Has to match a camera width returned in
.B --info
or
.B --list-v4l2-devices
for the device.
A value of 0 means to use the best option available.
.IP \(bu 3
.B camera_height
- The camera height in pixels. Has to match a camera height returned in
.B --info
or
.B --list-v4l2-devices
for the device.
A value of 0 means to use the best option available.
.RE
.TP
.BI \-region " WxH+X+Y"
Specify region to capture when using
.BR \-w " region."
Format is width x height + X offset + Y offset. Set width and height to 0 to capture the whole monitor that contains the position.
It is compatible with tools such as slop (X11) and slurp (Wayland).
.TP
.BI \-c " container_format"
Container format (mp4, mkv, flv, webm). Defaults to extension from
.B \-o
filename.
.TP
.BI \-s " WxH"
Output resolution limit (e.g., 1920x1080). Use 0x0 for original resolution.
Required for
.BR \-w " focused."
.TP
.BI \-f " fps"
Frame rate (default: 60). For variable frame rate mode, this is maximum FPS.
.TP
.BI \-cursor " yes|no"
Record cursor (default: yes).
.TP
.BI \-restore\-portal\-session " yes|no"
Restore previous portal session (used with -w portal option, default: no).
.SS Audio Options
.TP
.BI \-a " audio_source"
Audio device or application to record. Can be specified multiple times.
Formats:
.RS
.IP \(bu 3
.B default_output
- Default output device
.IP \(bu 3
.B default_input
- Default input device
.IP \(bu 3
.B device:name
- Specific device
.IP \(bu 3
.B app:name
- Application audio (case-insensitive)
.IP \(bu 3
.B app\-inverse:name
- All applications except specified
.IP \(bu 3
Combine sources with | (e.g.,
.BR "default_output|app:firefox" )
.RE
.PP
Run
.B \-\-list\-audio\-devices
to list available audio devices.
.br
Run
.B \-\-list\-application\-audio
to list available applications for audio capture.
.TP
.BI \-ac " aac|opus|flac"
Audio codec (default: opus for mp4/mkv, aac otherwise). FLAC temporarily disabled.
.TP
.BI \-ab " bitrate"
Audio bitrate in kbps (default: 128 for opus/flac, 160 for aac). 0 = automatic.
.SS Video Quality Options
.TP
.BI \-k " codec"
Video codec:
.BR auto ", " h264 ", " hevc ", " av1 ", " vp8 ", " vp9 ", " hevc_hdr ", " av1_hdr ", " hevc_10bit ", " av1_10bit ", " h264_vulkan ", " hevc_vulkan ", " hevc_10bit_vulkan ", " av1_vulkan ", " av1_hdr_vulkan ", " av1_10bit_vulkan
HDR options not available on X11 or portal capture. 10-bit capture reduces banding but may not be supported properly by all video players.
.br
Vulkan codec options are experimental. They may not work properly on your system because of GPU driver issues.
.br
Using vulkan codecs may result in better gaming performance with older NVIDIA gpu drivers, as vulkan video encoding doesn't suffer from an issue known as "cuda p2 state"
.br
where the GPU gets downclocked when using nvenc (regular video codecs on NVIDIA).
(default: auto → h264).
.TP
.BI \-q " quality"
Quality preset (medium, high, very_high, ultra) for QP/VBR mode, or bitrate (kbps) for CBR mode (default: very_high).
.TP
.BI \-bm " auto|qp|vbr|cbr"
Bitrate mode (default: auto → qp). CBR recommended for replay buffer and live streaming.
QP means to capture with constant quality, even in motion, while VBR and CBR means to capture with constant size.
.TP
.BI \-fm " cfr|vfr|content"
Frame rate mode: cfr (constant), vfr (variable), or content (match content) (default: vfr). Content mode is only available on X11 or portal.
Content mode syncs video to the captured content and is recommended for smoothest video when the game is running
at the same frame rate or lower than what you are trying to record at.
.TP
.BI \-cr " limited|full"
Color range (default: limited). Full range may cause issues with some video players/websites.
.TP
.BI \-tune " performance|quality"
Encoding tune (default: performance). Currently NVIDIA only.
.TP
.BI \-keyint " seconds"
Keyframe interval in seconds (default: 2.0). Affects seeking precision.
.TP
.BI \-encoder " gpu|cpu"
Encoding device (default: gpu). CPU encoding only for H264.
.TP
.BI \-fallback\-cpu\-encoding " yes|no"
Fallback to CPU if GPU encoding unavailable (default: no).
.SS Replay Buffer Options
.TP
.BI \-r " seconds"
Replay buffer duration (2-86400 seconds). When set, only saves on command.
.TP
.BI \-replay\-storage " ram|disk"
Buffer storage location (default: ram). Disk mode may reduce SSD lifespan.
.TP
.BI \-restart\-replay\-on\-save " yes|no"
Clear buffer after saving replay (default: no).
.TP
.BI \-df " yes|no"
Organize replays in date-based folders (default: no).
.SS Advanced Options
.TP
.BI \-p " plugin.so"
Load plugin (.so file). Can be specified multiple times.
.TP
.BI \-sc " script_path"
Script to run after saving video. Receives filepath and type ("regular", "replay", "screenshot").
.TP
.BI \-portal\-session\-token\-filepath " path"
Portal session token file (default: ~/.config/gpu-screen-recorder/restore_token).
.TP
.BI \-ffmpeg-opts " options"
Additional arguments to pass to FFmpeg for the file in a list of key-values pairs in the format "key=value;key=value",
.br
for example: -ffmpeg-opts "hls_list_size=3;hls_time=1;hls_flags=delete_segments".
.br
Note: this overwrites options set by GPU Screen Recorder with the same name.
.TP
.BI \-ffmpeg-video-opts " options"
Additional arguments to pass to FFmpeg for the video in a list of key-values pairs in the format "key=value;key=value",
.br
for example: -ffmpeg-video-opts "codec=cabac;rc_mode=CQP;qp=16".
.br
Note: this overwrites options set by GPU Screen Recorder with the same name.
.TP
.BI \-ffmpeg-audio-opts " options"
Additional arguments to pass to FFmpeg for the audio in a list of key-values pairs in the format "key=value;key=value",
.br
for example: -ffmpeg-audio-opts "aac_coder=fast;aac_pce=true".
.br
Note: this overwrites options set by GPU Screen Recorder with the same name.
.TP
.BI \-gl\-debug " yes|no"
OpenGL debug output (default: no).
.TP
.BI \-v " yes|no"
Print FPS and damage info (default: yes).
.TP
.BI \-low-power " yes|no"
Run in low power mode. This currently has only an affect on AMD (as it's only an issue on AMD) and allows the GPU to go into a lower power mode when recording (default: no).
.br
Setting this to
.B yes
might not always be ideal because of AMD driver issues where after playing a video with VAAPI on the system the video encoding performance
also reduces, which affects GPU Screen Recorder.
.br
It's recommended to also use the option
.B -fm content
when this is set to
.B yes
to only encode frames when the screen content updates to lower GPU and video encoding usage when the system is idle.
.TP
.BI \-write\-first\-frame\-ts " yes|no"
When enabled, writes a timestamp file with extra extension \fI.ts\fR next to the output video containing:
.nf
monotonic_microsec realtime_microsec
.fi
(default: no). Ignored for live streaming and when output is piped.
.SS Output Options
.TP
.BI \-o " output"
Output file path (or directory for replay mode). Required except when outputting to stdout.
.TP
.BI \-ro " directory"
Output directory for regular recordings during replay/streaming mode.
.SS Information Commands
.TP
.B \-\-help
Show help message.
.TP
.B \-\-version
Show version (5.10.2).
.TP
.B \-\-info
Show system info (codecs, capture options).
.TP
.B \-\-list\-capture\-options
List available capture sources (window, monitors, portal, v4l2 device path).
.TP
.B \-\-list\-monitors
List available monitors.
.TP
.B \-\-list\-v4l2\-devices
List available cameras devices (V4L2).
.TP
.B \-\-list\-audio\-devices
List available audio devices.
.TP
.B \-\-list\-application\-audio
List available applications for audio capture.
.SH SIGNALS
GPU Screen Recorder can be controlled via signals:
.TP
.B SIGINT (Ctrl+C)
Stop and save recording (stop without save in replay mode).
.TP
.B SIGUSR1
Save replay (replay mode only).
.TP
.B SIGUSR2
Pause/unpause recording (not for streaming/replay).
.TP
.B SIGRTMIN
Start/stop regular recording during replay/streaming.
.TP
.B SIGRTMIN+1
Save last 10 seconds (replay mode).
.TP
.B SIGRTMIN+2
Save last 30 seconds (replay mode).
.TP
.B SIGRTMIN+3
Save last 60 seconds (replay mode).
.TP
.B SIGRTMIN+4
Save last 5 minutes (replay mode).
.TP
.B SIGRTMIN+5
Save last 10 minutes (replay mode).
.TP
.B SIGRTMIN+6
Save last 30 minutes (replay mode).
.PP
Use
.B pkill
to send signals (e.g.,
.BR "pkill -SIGUSR1 -f ""^gpu-screen-recorder""" ).
.SH EXAMPLES
Record monitor at 60 FPS with desktop audio:
.PP
.nf
.RS
gpu-screen-recorder -w screen -f 60 -a default_output -o video.mp4
.RE
.fi
.PP
Record monitor at 60 FPS with desktop audio and microphone:
.PP
.nf
.RS
gpu-screen-recorder -w screen -f 60 -a "default_output|default_input" -o video.mp4
.RE
.fi
.PP
Record specific window (X11 only):
.PP
.nf
.RS
gpu-screen-recorder -w $(xdotool selectwindow) -f 60 -o video.mp4
.RE
.fi
.PP
Instant replay (last 60 seconds):
.PP
.nf
.RS
gpu-screen-recorder -w screen -c mkv -r 60 -o ~/Videos
.RE
.fi
.PP
Record region using slop:
.PP
.nf
.RS
gpu-screen-recorder -w $(slop) -o video.mp4
.RE
.fi
.PP
Record region using slurp:
.PP
.nf
.RS
gpu-screen-recorder -w $(slurp -f "%wx%h+%x+%y") -o video.mp4
.RE
.fi
.PP
Instant replay and launch a script when saving replay:
.PP
.nf
.RS
gpu-screen-recorder -w screen -c mkv -r 60 -sc ./script.sh -o ~/Videos
.RE
.fi
.PP
Stream to Twitch with constant bitrate mode:
.PP
.nf
.RS
gpu-screen-recorder -w screen -c flv -a default_output -bm cbr -q 8000 -o "rtmp://live.twitch.tv/app/stream_key"
.RE
.fi
.PP
Take screenshot:
.PP
.nf
.RS
gpu-screen-recorder -w screen -o screenshot.jpg
.PP
.RE
.fi
Record screen and camera:
.PP
.nf
.RS
gpu-screen-recorder -w "screen|/dev/video0" -o video.mp4
.PP
.RE
.fi
Record screen and camera. The camera is located at the bottom right and flipped horizontally:
.PP
.nf
.RS
gpu-screen-recorder -w "screen|/dev/video0;halign=end;valign=end;hflip=true;width=30%;height=30%" -o video.mp4
.PP
.RE
.fi
Record two monitors, side by side (assuming the first monitor has a resolution of 1920x1080)
.PP
.nf
.RS
gpu-screen-recorder -w "DP-1|DP-2;x=1920" -o video.mp4
.RE
.fi
.SH FILES
.TP
.I ~/.config/gpu-screen-recorder/gpu-screen-recorder.env
Environment variables for systemd service (optional).
.TP
.I /usr/lib/modprobe.d/gsr-nvidia.conf
NVIDIA suspend/resume fix.
.TP
.I ~/.config/gpu-screen-recorder/restore_token
Portal session token storage (default location).
.SH TIPS
.IP \(bu 3
Some video editors don't support videos in variable frame rate mode.
Change video container to .mkv or capture in constant frame rate mode instead to workaround this issue
.IP \(bu 3
Variable frame rate may cause issues in some video players (use MPV)
.IP \(bu 3
H.265/HEVC not supported in browsers/Discord (use H264 for sharing)
.IP \(bu 3
Some distros disable hardware codecs (use Flatpak version)
.IP \(bu 3
Use CBR mode (
.B \-bm cbr
) for replay buffer to control RAM usage
.SH PERFORMANCE TIPS
.IP \(bu 3
Save to SSD (HDD may be too slow)
.IP \(bu 3
Close other screen recorders (including idle OBS)
.SH KNOWN ISSUES
.IP \(bu 3
NVIDIA: CUDA breaks after suspend (install gsr-nvidia.conf fix)
.IP \(bu 3
AMD: Possible black bars in output video with HEVC/AV1 (use H264 or FFmpeg >=8)
.SH AUTHORS
Developed by dec05eba and contributors.
.SH REPORTING BUGS
Report bugs to:
.UR mailto:dec05eba@protonmail.com
dec05eba@protonmail.com
.UE .
.br
See more information about reporting bugs at the gpu-screen-recorder website:
.UR https://git.dec05eba.com/?p=about
https://git.dec05eba.com/?p=about
.UE .
.br
Please take a look at the FAQ part of the README before reporting a bug:
.UR https://git.dec05eba.com/gpu-screen-recorder/about/
https://git.dec05eba.com/gpu-screen-recorder/about/
.UE .
.br
The bug may have been previously reported or may not be related to gpu-screen-recorder (such as a driver issue).
.SH COPYRIGHT
Copyright © dec05eba. Licensed under GPL3-only.
.SH SEE ALSO
.UR https://git.dec05eba.com/gpu-screen-recorder
Project homepage
.UE
.br
.UR https://git.dec05eba.com/gpu-screen-recorder/about
Project readme, with more information
.UE
.br
.UR https://git.dec05eba.com/gpu-screen-recorder-gtk
GTK GUI version (deprecated)
.UE
.br
.UR https://git.dec05eba.com/gpu-screen-recorder-ui
ShadowPlay-style UI
.UE
.br
.BR xdotool (1),
.BR slop (1),
.BR slurp (1), fsdsfdsfdsfdsf-5.13.8/gsr-kms-server.1 0000664 0000000 0000000 00000005027 15202152077 0017562 0 ustar 00root root 0000000 0000000 .TH GSR\-KMS\-SERVER 1 "2026-05-07" "5.13.4" "GPU Screen Recorder KMS Server Manual"
.SH NAME
gsr\-kms\-server \- KMS (Kernel Mode Setting) server for GPU Screen Recorder
.SH SYNOPSIS
.B gsr\-kms\-server
<\fIdomain_socket_path\fR> <\fIcard_path\fR>
.SH DESCRIPTION
\fBgsr\-kms\-server\fR is a companion daemon for GPU Screen Recorder that provides
Kernel Mode Setting (KMS) access for screen capture in environments where
direct DRM access is required. It acts as a local server that communicates
via a Unix domain socket, allowing GPU Screen Recorder to capture screen
content through the KMS interface.
.PP
This component is typically used when GPU Screen Recorder needs to access
display hardware directly, bypassing the windowing system for more efficient
or lower-level capture. It runs as a separate process and communicates with
the main GPU Screen Recorder instance.
.SH ARGUMENTS
.TP
.B \fIdomain_socket_path\fR
Path to the Unix domain socket that the server will create and listen on.
This socket is used for communication between GPU Screen Recorder and the
KMS server. The path should be in a location where both processes have
appropriate permissions to read and write.
.TP
.B \fIcard_path\fR
Path to the DRM device file (typically \fI/dev/dri/cardX\fR) that the server
will use for KMS operations. This corresponds to a specific graphics card
in the system.
.SH EXAMPLES
Start the KMS server using card0 and create socket at /tmp/gsr-kms.sock:
.RS
.B gsr\-kms\-server /tmp/gsr\-kms.sock /dev/dri/card0
.RE
.PP
Start the KMS server using card1 and create socket in a user-specific location:
.RS
.B gsr\-kms\-server ~/.cache/gsr\-kms.sock /dev/dri/card1
.RE
.SH NOTES
.IP \(bu 3
The \fBgsr-kms-server\fR typically runs with elevated permissions to access
DRM devices, which requires root permission.
.IP \(bu 3
Only one instance should run per DRM card at a time.
.IP \(bu 3
The server will exit when the client disconnects or when terminated by a signal.
.IP \(bu 3
The socket file is created by the server and removed when the server exits.
.SH FILES
.TP
.B /dev/dri/card*
DRM device files for graphics cards
.TP
.B /tmp/gsr-kms.sock
Typical location for the domain socket (user-configurable)
.SH AUTHORS
gsr\-kms\-server was written by the GPU Screen Recorder contributors.
.SH REPORTING BUGS
Report bugs to:
.UR mailto:dec05eba@protonmail.com
dec05eba@protonmail.com
.UE .
.SH COPYRIGHT
Copyright © dec05eba. Licensed under GPL3-only.
.SH SEE ALSO
.BR gpu\-screen\-recorder (1),
.BR drm (4)
.PP
Project homepage: