nvEncodeAPI.h 175 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219
  1. /*
  2. * This copyright notice applies to this header file only:
  3. *
  4. * Copyright (c) 2010-2015 NVIDIA Corporation
  5. *
  6. * Permission is hereby granted, free of charge, to any person
  7. * obtaining a copy of this software and associated documentation
  8. * files (the "Software"), to deal in the Software without
  9. * restriction, including without limitation the rights to use,
  10. * copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. * copies of the software, and to permit persons to whom the
  12. * software is furnished to do so, subject to the following
  13. * conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be
  16. * included in all copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  19. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  20. * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  21. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  22. * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  23. * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  24. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  25. * OTHER DEALINGS IN THE SOFTWARE.
  26. */
  27. /**
  28. * \file nvEncodeAPI.h
  29. * NvEncodeAPI provides a NVENC Video Encoding interface to NVIDIA GPU devices based on the Kepler architecture.
  30. * \date 2011-2016
  31. * This file contains the interface constants, structure definitions and function prototypes.
  32. */
  33. #ifndef _NV_ENCODEAPI_H_
  34. #define _NV_ENCODEAPI_H_
  35. #include <stdlib.h>
  36. #ifdef _WIN32
  37. #include <windows.h>
  38. #endif
  39. #ifdef _MSC_VER
  40. #ifndef _STDINT
  41. typedef __int32 int32_t;
  42. typedef unsigned __int32 uint32_t;
  43. typedef __int64 int64_t;
  44. typedef unsigned __int64 uint64_t;
  45. typedef signed char int8_t;
  46. typedef unsigned char uint8_t;
  47. typedef short int16_t;
  48. typedef unsigned short uint16_t;
  49. #endif
  50. #else
  51. #include <stdint.h>
  52. #endif
  53. #ifdef __cplusplus
  54. extern "C" {
  55. #endif
  56. /**
  57. * \addtogroup ENCODER_STRUCTURE NvEncodeAPI Data structures
  58. * @{
  59. */
  60. #if defined(_WIN32) || defined(__CYGWIN__)
  61. #define NVENCAPI __stdcall
  62. #else
  63. #define NVENCAPI
  64. #endif
  65. #ifdef _WIN32
  66. typedef RECT NVENC_RECT;
  67. #else
  68. // =========================================================================================
  69. #ifndef GUID
  70. /*!
  71. * \struct GUID
  72. * Abstracts the GUID structure for non-windows platforms.
  73. */
  74. // =========================================================================================
  75. typedef struct
  76. {
  77. uint32_t Data1; /**< [in]: Specifies the first 8 hexadecimal digits of the GUID. */
  78. uint16_t Data2; /**< [in]: Specifies the first group of 4 hexadecimal digits. */
  79. uint16_t Data3; /**< [in]: Specifies the second group of 4 hexadecimal digits. */
  80. uint8_t Data4[8]; /**< [in]: Array of 8 bytes. The first 2 bytes contain the third group of 4 hexadecimal digits.
  81. The remaining 6 bytes contain the final 12 hexadecimal digits. */
  82. } GUID;
  83. #endif // GUID
  84. /**
  85. * \struct _NVENC_RECT
  86. * Defines a Rectangle. Used in ::NV_ENC_PREPROCESS_FRAME.
  87. */
  88. typedef struct _NVENC_RECT
  89. {
  90. uint32_t left; /**< [in]: X coordinate of the upper left corner of rectangular area to be specified. */
  91. uint32_t top; /**< [in]: Y coordinate of the upper left corner of the rectangular area to be specified. */
  92. uint32_t right; /**< [in]: X coordinate of the bottom right corner of the rectangular area to be specified. */
  93. uint32_t bottom; /**< [in]: Y coordinate of the bottom right corner of the rectangular area to be specified. */
  94. } NVENC_RECT;
  95. #endif // _WIN32
  96. /** @} */ /* End of GUID and NVENC_RECT structure grouping*/
  97. typedef void* NV_ENC_INPUT_PTR; /**< NVENCODE API input buffer */
  98. typedef void* NV_ENC_OUTPUT_PTR; /**< NVENCODE API output buffer*/
  99. typedef void* NV_ENC_REGISTERED_PTR; /**< A Resource that has been registered with NVENCODE API*/
  100. #define NVENCAPI_MAJOR_VERSION 7
  101. #define NVENCAPI_MINOR_VERSION 0
  102. #define NVENCAPI_VERSION (NVENCAPI_MAJOR_VERSION | (NVENCAPI_MINOR_VERSION << 24))
  103. /**
  104. * Macro to generate per-structure version for use with API.
  105. */
  106. #define NVENCAPI_STRUCT_VERSION(ver) ((uint32_t)NVENCAPI_VERSION | ((ver)<<16) | (0x7 << 28))
  107. #define NVENC_INFINITE_GOPLENGTH 0xffffffff
  108. #define NV_MAX_SEQ_HDR_LEN (512)
  109. // =========================================================================================
  110. // Encode Codec GUIDS supported by the NvEncodeAPI interface.
  111. // =========================================================================================
  112. // {6BC82762-4E63-4ca4-AA85-1E50F321F6BF}
  113. static const GUID NV_ENC_CODEC_H264_GUID =
  114. { 0x6bc82762, 0x4e63, 0x4ca4, { 0xaa, 0x85, 0x1e, 0x50, 0xf3, 0x21, 0xf6, 0xbf } };
  115. // {790CDC88-4522-4d7b-9425-BDA9975F7603}
  116. static const GUID NV_ENC_CODEC_HEVC_GUID =
  117. { 0x790cdc88, 0x4522, 0x4d7b, { 0x94, 0x25, 0xbd, 0xa9, 0x97, 0x5f, 0x76, 0x3 } };
  118. // =========================================================================================
  119. // * Encode Profile GUIDS supported by the NvEncodeAPI interface.
  120. // =========================================================================================
  121. // {BFD6F8E7-233C-4341-8B3E-4818523803F4}
  122. static const GUID NV_ENC_CODEC_PROFILE_AUTOSELECT_GUID =
  123. { 0xbfd6f8e7, 0x233c, 0x4341, { 0x8b, 0x3e, 0x48, 0x18, 0x52, 0x38, 0x3, 0xf4 } };
  124. // {0727BCAA-78C4-4c83-8C2F-EF3DFF267C6A}
  125. static const GUID NV_ENC_H264_PROFILE_BASELINE_GUID =
  126. { 0x727bcaa, 0x78c4, 0x4c83, { 0x8c, 0x2f, 0xef, 0x3d, 0xff, 0x26, 0x7c, 0x6a } };
  127. // {60B5C1D4-67FE-4790-94D5-C4726D7B6E6D}
  128. static const GUID NV_ENC_H264_PROFILE_MAIN_GUID =
  129. { 0x60b5c1d4, 0x67fe, 0x4790, { 0x94, 0xd5, 0xc4, 0x72, 0x6d, 0x7b, 0x6e, 0x6d } };
  130. // {E7CBC309-4F7A-4b89-AF2A-D537C92BE310}
  131. static const GUID NV_ENC_H264_PROFILE_HIGH_GUID =
  132. { 0xe7cbc309, 0x4f7a, 0x4b89, { 0xaf, 0x2a, 0xd5, 0x37, 0xc9, 0x2b, 0xe3, 0x10 } };
  133. // {7AC663CB-A598-4960-B844-339B261A7D52}
  134. static const GUID NV_ENC_H264_PROFILE_HIGH_444_GUID =
  135. { 0x7ac663cb, 0xa598, 0x4960, { 0xb8, 0x44, 0x33, 0x9b, 0x26, 0x1a, 0x7d, 0x52 } };
  136. // {40847BF5-33F7-4601-9084-E8FE3C1DB8B7}
  137. static const GUID NV_ENC_H264_PROFILE_STEREO_GUID =
  138. { 0x40847bf5, 0x33f7, 0x4601, { 0x90, 0x84, 0xe8, 0xfe, 0x3c, 0x1d, 0xb8, 0xb7 } };
  139. // {CE788D20-AAA9-4318-92BB-AC7E858C8D36}
  140. static const GUID NV_ENC_H264_PROFILE_SVC_TEMPORAL_SCALABILTY =
  141. { 0xce788d20, 0xaaa9, 0x4318, { 0x92, 0xbb, 0xac, 0x7e, 0x85, 0x8c, 0x8d, 0x36 } };
  142. // {B405AFAC-F32B-417B-89C4-9ABEED3E5978}
  143. static const GUID NV_ENC_H264_PROFILE_PROGRESSIVE_HIGH_GUID =
  144. { 0xb405afac, 0xf32b, 0x417b, { 0x89, 0xc4, 0x9a, 0xbe, 0xed, 0x3e, 0x59, 0x78 } };
  145. // {AEC1BD87-E85B-48f2-84C3-98BCA6285072}
  146. static const GUID NV_ENC_H264_PROFILE_CONSTRAINED_HIGH_GUID =
  147. { 0xaec1bd87, 0xe85b, 0x48f2, { 0x84, 0xc3, 0x98, 0xbc, 0xa6, 0x28, 0x50, 0x72 } };
  148. // {B514C39A-B55B-40fa-878F-F1253B4DFDEC}
  149. static const GUID NV_ENC_HEVC_PROFILE_MAIN_GUID =
  150. { 0xb514c39a, 0xb55b, 0x40fa, { 0x87, 0x8f, 0xf1, 0x25, 0x3b, 0x4d, 0xfd, 0xec } };
  151. // {fa4d2b6c-3a5b-411a-8018-0a3f5e3c9be5}
  152. static const GUID NV_ENC_HEVC_PROFILE_MAIN10_GUID =
  153. { 0xfa4d2b6c, 0x3a5b, 0x411a, { 0x80, 0x18, 0x0a, 0x3f, 0x5e, 0x3c, 0x9b, 0xe5 } };
  154. // For HEVC Main 444 8 bit and HEVC Main 444 10 bit profiles only
  155. // {51ec32b5-1b4c-453c-9cbd-b616bd621341}
  156. static const GUID NV_ENC_HEVC_PROFILE_FREXT_GUID =
  157. { 0x51ec32b5, 0x1b4c, 0x453c, { 0x9c, 0xbd, 0xb6, 0x16, 0xbd, 0x62, 0x13, 0x41 } };
  158. // =========================================================================================
  159. // * Preset GUIDS supported by the NvEncodeAPI interface.
  160. // =========================================================================================
  161. // {B2DFB705-4EBD-4C49-9B5F-24A777D3E587}
  162. static const GUID NV_ENC_PRESET_DEFAULT_GUID =
  163. { 0xb2dfb705, 0x4ebd, 0x4c49, { 0x9b, 0x5f, 0x24, 0xa7, 0x77, 0xd3, 0xe5, 0x87 } };
  164. // {60E4C59F-E846-4484-A56D-CD45BE9FDDF6}
  165. static const GUID NV_ENC_PRESET_HP_GUID =
  166. { 0x60e4c59f, 0xe846, 0x4484, { 0xa5, 0x6d, 0xcd, 0x45, 0xbe, 0x9f, 0xdd, 0xf6 } };
  167. // {34DBA71D-A77B-4B8F-9C3E-B6D5DA24C012}
  168. static const GUID NV_ENC_PRESET_HQ_GUID =
  169. { 0x34dba71d, 0xa77b, 0x4b8f, { 0x9c, 0x3e, 0xb6, 0xd5, 0xda, 0x24, 0xc0, 0x12 } };
  170. // {82E3E450-BDBB-4e40-989C-82A90DF9EF32}
  171. static const GUID NV_ENC_PRESET_BD_GUID =
  172. { 0x82e3e450, 0xbdbb, 0x4e40, { 0x98, 0x9c, 0x82, 0xa9, 0xd, 0xf9, 0xef, 0x32 } };
  173. // {49DF21C5-6DFA-4feb-9787-6ACC9EFFB726}
  174. static const GUID NV_ENC_PRESET_LOW_LATENCY_DEFAULT_GUID =
  175. { 0x49df21c5, 0x6dfa, 0x4feb, { 0x97, 0x87, 0x6a, 0xcc, 0x9e, 0xff, 0xb7, 0x26 } };
  176. // {C5F733B9-EA97-4cf9-BEC2-BF78A74FD105}
  177. static const GUID NV_ENC_PRESET_LOW_LATENCY_HQ_GUID =
  178. { 0xc5f733b9, 0xea97, 0x4cf9, { 0xbe, 0xc2, 0xbf, 0x78, 0xa7, 0x4f, 0xd1, 0x5 } };
  179. // {67082A44-4BAD-48FA-98EA-93056D150A58}
  180. static const GUID NV_ENC_PRESET_LOW_LATENCY_HP_GUID =
  181. { 0x67082a44, 0x4bad, 0x48fa, { 0x98, 0xea, 0x93, 0x5, 0x6d, 0x15, 0xa, 0x58 } };
  182. // {D5BFB716-C604-44e7-9BB8-DEA5510FC3AC}
  183. static const GUID NV_ENC_PRESET_LOSSLESS_DEFAULT_GUID =
  184. { 0xd5bfb716, 0xc604, 0x44e7, { 0x9b, 0xb8, 0xde, 0xa5, 0x51, 0xf, 0xc3, 0xac } };
  185. // {149998E7-2364-411d-82EF-179888093409}
  186. static const GUID NV_ENC_PRESET_LOSSLESS_HP_GUID =
  187. { 0x149998e7, 0x2364, 0x411d, { 0x82, 0xef, 0x17, 0x98, 0x88, 0x9, 0x34, 0x9 } };
  188. /**
  189. * \addtogroup ENCODER_STRUCTURE NvEncodeAPI Data structures
  190. * @{
  191. */
  192. /**
  193. * Input frame encode modes
  194. */
  195. typedef enum _NV_ENC_PARAMS_FRAME_FIELD_MODE
  196. {
  197. NV_ENC_PARAMS_FRAME_FIELD_MODE_FRAME = 0x01, /**< Frame mode */
  198. NV_ENC_PARAMS_FRAME_FIELD_MODE_FIELD = 0x02, /**< Field mode */
  199. NV_ENC_PARAMS_FRAME_FIELD_MODE_MBAFF = 0x03 /**< MB adaptive frame/field */
  200. } NV_ENC_PARAMS_FRAME_FIELD_MODE;
  201. /**
  202. * Rate Control Modes
  203. */
  204. typedef enum _NV_ENC_PARAMS_RC_MODE
  205. {
  206. NV_ENC_PARAMS_RC_CONSTQP = 0x0, /**< Constant QP mode */
  207. NV_ENC_PARAMS_RC_VBR = 0x1, /**< Variable bitrate mode */
  208. NV_ENC_PARAMS_RC_CBR = 0x2, /**< Constant bitrate mode */
  209. NV_ENC_PARAMS_RC_VBR_MINQP = 0x4, /**< Variable bitrate mode with MinQP */
  210. NV_ENC_PARAMS_RC_2_PASS_QUALITY = 0x8, /**< Multi pass encoding optimized for image quality and works only with low latency mode */
  211. NV_ENC_PARAMS_RC_2_PASS_FRAMESIZE_CAP = 0x10, /**< Multi pass encoding optimized for maintaining frame size and works only with low latency mode */
  212. NV_ENC_PARAMS_RC_2_PASS_VBR = 0x20 /**< Multi pass VBR */
  213. } NV_ENC_PARAMS_RC_MODE;
  214. #define NV_ENC_PARAMS_RC_CBR2 NV_ENC_PARAMS_RC_CBR /**< Deprecated */
  215. /**
  216. * Input picture structure
  217. */
  218. typedef enum _NV_ENC_PIC_STRUCT
  219. {
  220. NV_ENC_PIC_STRUCT_FRAME = 0x01, /**< Progressive frame */
  221. NV_ENC_PIC_STRUCT_FIELD_TOP_BOTTOM = 0x02, /**< Field encoding top field first */
  222. NV_ENC_PIC_STRUCT_FIELD_BOTTOM_TOP = 0x03 /**< Field encoding bottom field first */
  223. } NV_ENC_PIC_STRUCT;
  224. /**
  225. * Input picture type
  226. */
  227. typedef enum _NV_ENC_PIC_TYPE
  228. {
  229. NV_ENC_PIC_TYPE_P = 0x0, /**< Forward predicted */
  230. NV_ENC_PIC_TYPE_B = 0x01, /**< Bi-directionally predicted picture */
  231. NV_ENC_PIC_TYPE_I = 0x02, /**< Intra predicted picture */
  232. NV_ENC_PIC_TYPE_IDR = 0x03, /**< IDR picture */
  233. NV_ENC_PIC_TYPE_BI = 0x04, /**< Bi-directionally predicted with only Intra MBs */
  234. NV_ENC_PIC_TYPE_SKIPPED = 0x05, /**< Picture is skipped */
  235. NV_ENC_PIC_TYPE_INTRA_REFRESH = 0x06, /**< First picture in intra refresh cycle */
  236. NV_ENC_PIC_TYPE_UNKNOWN = 0xFF /**< Picture type unknown */
  237. } NV_ENC_PIC_TYPE;
  238. /**
  239. * Motion vector precisions
  240. */
  241. typedef enum _NV_ENC_MV_PRECISION
  242. {
  243. NV_ENC_MV_PRECISION_DEFAULT = 0x0, /**<Driver selects QuarterPel motion vector precision by default*/
  244. NV_ENC_MV_PRECISION_FULL_PEL = 0x01, /**< FullPel motion vector precision */
  245. NV_ENC_MV_PRECISION_HALF_PEL = 0x02, /**< HalfPel motion vector precision */
  246. NV_ENC_MV_PRECISION_QUARTER_PEL = 0x03 /**< QuarterPel motion vector precision */
  247. } NV_ENC_MV_PRECISION;
  248. /**
  249. * Input buffer formats
  250. */
  251. typedef enum _NV_ENC_BUFFER_FORMAT
  252. {
  253. NV_ENC_BUFFER_FORMAT_UNDEFINED = 0x00000000, /**< Undefined buffer format */
  254. NV_ENC_BUFFER_FORMAT_NV12 = 0x00000001, /**< Semi-Planar YUV [Y plane followed by interleaved UV plane] */
  255. NV_ENC_BUFFER_FORMAT_YV12 = 0x00000010, /**< Planar YUV [Y plane followed by V and U planes] */
  256. NV_ENC_BUFFER_FORMAT_IYUV = 0x00000100, /**< Planar YUV [Y plane followed by U and V planes] */
  257. NV_ENC_BUFFER_FORMAT_YUV444 = 0x00001000, /**< Planar YUV [Y plane followed by U and V planes] */
  258. 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. */
  259. 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. */
  260. NV_ENC_BUFFER_FORMAT_ARGB = 0x01000000, /**< 8 bit Packed A8R8G8B8 */
  261. NV_ENC_BUFFER_FORMAT_ARGB10 = 0x02000000, /**< 10 bit Packed A2R10G10B10. Each pixel of size 2 bytes. Most Significant 10 bits contain pixel data. */
  262. NV_ENC_BUFFER_FORMAT_AYUV = 0x04000000, /**< 8 bit Packed A8Y8U8V8 */
  263. NV_ENC_BUFFER_FORMAT_ABGR = 0x10000000, /**< 8 bit Packed A8B8G8R8 */
  264. NV_ENC_BUFFER_FORMAT_ABGR10 = 0x20000000, /**< 10 bit Packed A2B10G10R10. Each pixel of size 2 bytes. Most Significant 10 bits contain pixel data. */
  265. } NV_ENC_BUFFER_FORMAT;
  266. #define NV_ENC_BUFFER_FORMAT_NV12_PL NV_ENC_BUFFER_FORMAT_NV12
  267. #define NV_ENC_BUFFER_FORMAT_YV12_PL NV_ENC_BUFFER_FORMAT_YV12
  268. #define NV_ENC_BUFFER_FORMAT_IYUV_PL NV_ENC_BUFFER_FORMAT_IYUV
  269. #define NV_ENC_BUFFER_FORMAT_YUV444_PL NV_ENC_BUFFER_FORMAT_YUV444
  270. /**
  271. * Encoding levels
  272. */
  273. typedef enum _NV_ENC_LEVEL
  274. {
  275. NV_ENC_LEVEL_AUTOSELECT = 0,
  276. NV_ENC_LEVEL_H264_1 = 10,
  277. NV_ENC_LEVEL_H264_1b = 9,
  278. NV_ENC_LEVEL_H264_11 = 11,
  279. NV_ENC_LEVEL_H264_12 = 12,
  280. NV_ENC_LEVEL_H264_13 = 13,
  281. NV_ENC_LEVEL_H264_2 = 20,
  282. NV_ENC_LEVEL_H264_21 = 21,
  283. NV_ENC_LEVEL_H264_22 = 22,
  284. NV_ENC_LEVEL_H264_3 = 30,
  285. NV_ENC_LEVEL_H264_31 = 31,
  286. NV_ENC_LEVEL_H264_32 = 32,
  287. NV_ENC_LEVEL_H264_4 = 40,
  288. NV_ENC_LEVEL_H264_41 = 41,
  289. NV_ENC_LEVEL_H264_42 = 42,
  290. NV_ENC_LEVEL_H264_5 = 50,
  291. NV_ENC_LEVEL_H264_51 = 51,
  292. NV_ENC_LEVEL_H264_52 = 52,
  293. NV_ENC_LEVEL_HEVC_1 = 30,
  294. NV_ENC_LEVEL_HEVC_2 = 60,
  295. NV_ENC_LEVEL_HEVC_21 = 63,
  296. NV_ENC_LEVEL_HEVC_3 = 90,
  297. NV_ENC_LEVEL_HEVC_31 = 93,
  298. NV_ENC_LEVEL_HEVC_4 = 120,
  299. NV_ENC_LEVEL_HEVC_41 = 123,
  300. NV_ENC_LEVEL_HEVC_5 = 150,
  301. NV_ENC_LEVEL_HEVC_51 = 153,
  302. NV_ENC_LEVEL_HEVC_52 = 156,
  303. NV_ENC_LEVEL_HEVC_6 = 180,
  304. NV_ENC_LEVEL_HEVC_61 = 183,
  305. NV_ENC_LEVEL_HEVC_62 = 186,
  306. NV_ENC_TIER_HEVC_MAIN = 0,
  307. NV_ENC_TIER_HEVC_HIGH = 1
  308. } NV_ENC_LEVEL;
  309. /**
  310. * Error Codes
  311. */
  312. typedef enum _NVENCSTATUS
  313. {
  314. /**
  315. * This indicates that API call returned with no errors.
  316. */
  317. NV_ENC_SUCCESS,
  318. /**
  319. * This indicates that no encode capable devices were detected.
  320. */
  321. NV_ENC_ERR_NO_ENCODE_DEVICE,
  322. /**
  323. * This indicates that devices pass by the client is not supported.
  324. */
  325. NV_ENC_ERR_UNSUPPORTED_DEVICE,
  326. /**
  327. * This indicates that the encoder device supplied by the client is not
  328. * valid.
  329. */
  330. NV_ENC_ERR_INVALID_ENCODERDEVICE,
  331. /**
  332. * This indicates that device passed to the API call is invalid.
  333. */
  334. NV_ENC_ERR_INVALID_DEVICE,
  335. /**
  336. * This indicates that device passed to the API call is no longer available and
  337. * needs to be reinitialized. The clients need to destroy the current encoder
  338. * session by freeing the allocated input output buffers and destroying the device
  339. * and create a new encoding session.
  340. */
  341. NV_ENC_ERR_DEVICE_NOT_EXIST,
  342. /**
  343. * This indicates that one or more of the pointers passed to the API call
  344. * is invalid.
  345. */
  346. NV_ENC_ERR_INVALID_PTR,
  347. /**
  348. * This indicates that completion event passed in ::NvEncEncodePicture() call
  349. * is invalid.
  350. */
  351. NV_ENC_ERR_INVALID_EVENT,
  352. /**
  353. * This indicates that one or more of the parameter passed to the API call
  354. * is invalid.
  355. */
  356. NV_ENC_ERR_INVALID_PARAM,
  357. /**
  358. * This indicates that an API call was made in wrong sequence/order.
  359. */
  360. NV_ENC_ERR_INVALID_CALL,
  361. /**
  362. * This indicates that the API call failed because it was unable to allocate
  363. * enough memory to perform the requested operation.
  364. */
  365. NV_ENC_ERR_OUT_OF_MEMORY,
  366. /**
  367. * This indicates that the encoder has not been initialized with
  368. * ::NvEncInitializeEncoder() or that initialization has failed.
  369. * The client cannot allocate input or output buffers or do any encoding
  370. * related operation before successfully initializing the encoder.
  371. */
  372. NV_ENC_ERR_ENCODER_NOT_INITIALIZED,
  373. /**
  374. * This indicates that an unsupported parameter was passed by the client.
  375. */
  376. NV_ENC_ERR_UNSUPPORTED_PARAM,
  377. /**
  378. * This indicates that the ::NvEncLockBitstream() failed to lock the output
  379. * buffer. This happens when the client makes a non blocking lock call to
  380. * access the output bitstream by passing NV_ENC_LOCK_BITSTREAM::doNotWait flag.
  381. * This is not a fatal error and client should retry the same operation after
  382. * few milliseconds.
  383. */
  384. NV_ENC_ERR_LOCK_BUSY,
  385. /**
  386. * This indicates that the size of the user buffer passed by the client is
  387. * insufficient for the requested operation.
  388. */
  389. NV_ENC_ERR_NOT_ENOUGH_BUFFER,
  390. /**
  391. * This indicates that an invalid struct version was used by the client.
  392. */
  393. NV_ENC_ERR_INVALID_VERSION,
  394. /**
  395. * This indicates that ::NvEncMapInputResource() API failed to map the client
  396. * provided input resource.
  397. */
  398. NV_ENC_ERR_MAP_FAILED,
  399. /**
  400. * This indicates encode driver requires more input buffers to produce an output
  401. * bitstream. If this error is returned from ::NvEncEncodePicture() API, this
  402. * is not a fatal error. If the client is encoding with B frames then,
  403. * ::NvEncEncodePicture() API might be buffering the input frame for re-ordering.
  404. *
  405. * A client operating in synchronous mode cannot call ::NvEncLockBitstream()
  406. * API on the output bitstream buffer if ::NvEncEncodePicture() returned the
  407. * ::NV_ENC_ERR_NEED_MORE_INPUT error code.
  408. * The client must continue providing input frames until encode driver returns
  409. * ::NV_ENC_SUCCESS. After receiving ::NV_ENC_SUCCESS status the client can call
  410. * ::NvEncLockBitstream() API on the output buffers in the same order in which
  411. * it has called ::NvEncEncodePicture().
  412. */
  413. NV_ENC_ERR_NEED_MORE_INPUT,
  414. /**
  415. * This indicates that the HW encoder is busy encoding and is unable to encode
  416. * the input. The client should call ::NvEncEncodePicture() again after few
  417. * milliseconds.
  418. */
  419. NV_ENC_ERR_ENCODER_BUSY,
  420. /**
  421. * This indicates that the completion event passed in ::NvEncEncodePicture()
  422. * API has not been registered with encoder driver using ::NvEncRegisterAsyncEvent().
  423. */
  424. NV_ENC_ERR_EVENT_NOT_REGISTERD,
  425. /**
  426. * This indicates that an unknown internal error has occurred.
  427. */
  428. NV_ENC_ERR_GENERIC,
  429. /**
  430. * This indicates that the client is attempting to use a feature
  431. * that is not available for the license type for the current system.
  432. */
  433. NV_ENC_ERR_INCOMPATIBLE_CLIENT_KEY,
  434. /**
  435. * This indicates that the client is attempting to use a feature
  436. * that is not implemented for the current version.
  437. */
  438. NV_ENC_ERR_UNIMPLEMENTED,
  439. /**
  440. * This indicates that the ::NvEncRegisterResource API failed to register the resource.
  441. */
  442. NV_ENC_ERR_RESOURCE_REGISTER_FAILED,
  443. /**
  444. * This indicates that the client is attempting to unregister a resource
  445. * that has not been successfully registered.
  446. */
  447. NV_ENC_ERR_RESOURCE_NOT_REGISTERED,
  448. /**
  449. * This indicates that the client is attempting to unmap a resource
  450. * that has not been successfully mapped.
  451. */
  452. NV_ENC_ERR_RESOURCE_NOT_MAPPED,
  453. } NVENCSTATUS;
  454. /**
  455. * Encode Picture encode flags.
  456. */
  457. typedef enum _NV_ENC_PIC_FLAGS
  458. {
  459. NV_ENC_PIC_FLAG_FORCEINTRA = 0x1, /**< Encode the current picture as an Intra picture */
  460. NV_ENC_PIC_FLAG_FORCEIDR = 0x2, /**< Encode the current picture as an IDR picture.
  461. This flag is only valid when Picture type decision is taken by the Encoder
  462. [_NV_ENC_INITIALIZE_PARAMS::enablePTD == 1]. */
  463. NV_ENC_PIC_FLAG_OUTPUT_SPSPPS = 0x4, /**< Write the sequence and picture header in encoded bitstream of the current picture */
  464. NV_ENC_PIC_FLAG_EOS = 0x8, /**< Indicates end of the input stream */
  465. } NV_ENC_PIC_FLAGS;
  466. /**
  467. * Memory heap to allocate input and output buffers.
  468. */
  469. typedef enum _NV_ENC_MEMORY_HEAP
  470. {
  471. NV_ENC_MEMORY_HEAP_AUTOSELECT = 0, /**< Memory heap to be decided by the encoder driver based on the usage */
  472. NV_ENC_MEMORY_HEAP_VID = 1, /**< Memory heap is in local video memory */
  473. NV_ENC_MEMORY_HEAP_SYSMEM_CACHED = 2, /**< Memory heap is in cached system memory */
  474. NV_ENC_MEMORY_HEAP_SYSMEM_UNCACHED = 3 /**< Memory heap is in uncached system memory */
  475. } NV_ENC_MEMORY_HEAP;
  476. /**
  477. * H.264 entropy coding modes.
  478. */
  479. typedef enum _NV_ENC_H264_ENTROPY_CODING_MODE
  480. {
  481. NV_ENC_H264_ENTROPY_CODING_MODE_AUTOSELECT = 0x0, /**< Entropy coding mode is auto selected by the encoder driver */
  482. NV_ENC_H264_ENTROPY_CODING_MODE_CABAC = 0x1, /**< Entropy coding mode is CABAC */
  483. NV_ENC_H264_ENTROPY_CODING_MODE_CAVLC = 0x2 /**< Entropy coding mode is CAVLC */
  484. } NV_ENC_H264_ENTROPY_CODING_MODE;
  485. /**
  486. * H.264 specific Bdirect modes
  487. */
  488. typedef enum _NV_ENC_H264_BDIRECT_MODE
  489. {
  490. NV_ENC_H264_BDIRECT_MODE_AUTOSELECT = 0x0, /**< BDirect mode is auto selected by the encoder driver */
  491. NV_ENC_H264_BDIRECT_MODE_DISABLE = 0x1, /**< Disable BDirect mode */
  492. NV_ENC_H264_BDIRECT_MODE_TEMPORAL = 0x2, /**< Temporal BDirect mode */
  493. NV_ENC_H264_BDIRECT_MODE_SPATIAL = 0x3 /**< Spatial BDirect mode */
  494. } NV_ENC_H264_BDIRECT_MODE;
  495. /**
  496. * H.264 specific FMO usage
  497. */
  498. typedef enum _NV_ENC_H264_FMO_MODE
  499. {
  500. NV_ENC_H264_FMO_AUTOSELECT = 0x0, /**< FMO usage is auto selected by the encoder driver */
  501. NV_ENC_H264_FMO_ENABLE = 0x1, /**< Enable FMO */
  502. NV_ENC_H264_FMO_DISABLE = 0x2, /**< Disble FMO */
  503. } NV_ENC_H264_FMO_MODE;
  504. /**
  505. * H.264 specific Adaptive Transform modes
  506. */
  507. typedef enum _NV_ENC_H264_ADAPTIVE_TRANSFORM_MODE
  508. {
  509. NV_ENC_H264_ADAPTIVE_TRANSFORM_AUTOSELECT = 0x0, /**< Adaptive Transform 8x8 mode is auto selected by the encoder driver*/
  510. NV_ENC_H264_ADAPTIVE_TRANSFORM_DISABLE = 0x1, /**< Adaptive Transform 8x8 mode disabled */
  511. NV_ENC_H264_ADAPTIVE_TRANSFORM_ENABLE = 0x2, /**< Adaptive Transform 8x8 mode should be used */
  512. } NV_ENC_H264_ADAPTIVE_TRANSFORM_MODE;
  513. /**
  514. * Stereo frame packing modes.
  515. */
  516. typedef enum _NV_ENC_STEREO_PACKING_MODE
  517. {
  518. NV_ENC_STEREO_PACKING_MODE_NONE = 0x0, /**< No Stereo packing required */
  519. NV_ENC_STEREO_PACKING_MODE_CHECKERBOARD = 0x1, /**< Checkerboard mode for packing stereo frames */
  520. NV_ENC_STEREO_PACKING_MODE_COLINTERLEAVE = 0x2, /**< Column Interleave mode for packing stereo frames */
  521. NV_ENC_STEREO_PACKING_MODE_ROWINTERLEAVE = 0x3, /**< Row Interleave mode for packing stereo frames */
  522. NV_ENC_STEREO_PACKING_MODE_SIDEBYSIDE = 0x4, /**< Side-by-side mode for packing stereo frames */
  523. NV_ENC_STEREO_PACKING_MODE_TOPBOTTOM = 0x5, /**< Top-Bottom mode for packing stereo frames */
  524. NV_ENC_STEREO_PACKING_MODE_FRAMESEQ = 0x6 /**< Frame Sequential mode for packing stereo frames */
  525. } NV_ENC_STEREO_PACKING_MODE;
  526. /**
  527. * Input Resource type
  528. */
  529. typedef enum _NV_ENC_INPUT_RESOURCE_TYPE
  530. {
  531. NV_ENC_INPUT_RESOURCE_TYPE_DIRECTX = 0x0, /**< input resource type is a directx9 surface*/
  532. NV_ENC_INPUT_RESOURCE_TYPE_CUDADEVICEPTR = 0x1, /**< input resource type is a cuda device pointer surface*/
  533. NV_ENC_INPUT_RESOURCE_TYPE_CUDAARRAY = 0x2, /**< input resource type is a cuda array surface */
  534. } NV_ENC_INPUT_RESOURCE_TYPE;
  535. /**
  536. * Encoder Device type
  537. */
  538. typedef enum _NV_ENC_DEVICE_TYPE
  539. {
  540. NV_ENC_DEVICE_TYPE_DIRECTX = 0x0, /**< encode device type is a directx9 device */
  541. NV_ENC_DEVICE_TYPE_CUDA = 0x1, /**< encode device type is a cuda device */
  542. } NV_ENC_DEVICE_TYPE;
  543. /**
  544. * Encoder capabilities enumeration.
  545. */
  546. typedef enum _NV_ENC_CAPS
  547. {
  548. /**
  549. * Maximum number of B-Frames supported.
  550. */
  551. NV_ENC_CAPS_NUM_MAX_BFRAMES,
  552. /**
  553. * Rate control modes supported.
  554. * \n The API return value is a bitmask of the values in NV_ENC_PARAMS_RC_MODE.
  555. */
  556. NV_ENC_CAPS_SUPPORTED_RATECONTROL_MODES,
  557. /**
  558. * Indicates HW support for field mode encoding.
  559. * \n 0 : Interlaced mode encoding is not supported.
  560. * \n 1 : Interlaced field mode encoding is supported.
  561. * \n 2 : Interlaced frame encoding and field mode encoding are both supported.
  562. */
  563. NV_ENC_CAPS_SUPPORT_FIELD_ENCODING,
  564. /**
  565. * Indicates HW support for monochrome mode encoding.
  566. * \n 0 : Monochrome mode not supported.
  567. * \n 1 : Monochrome mode supported.
  568. */
  569. NV_ENC_CAPS_SUPPORT_MONOCHROME,
  570. /**
  571. * Indicates HW support for FMO.
  572. * \n 0 : FMO not supported.
  573. * \n 1 : FMO supported.
  574. */
  575. NV_ENC_CAPS_SUPPORT_FMO,
  576. /**
  577. * Indicates HW capability for Quarter pel motion estimation.
  578. * \n 0 : QuarterPel Motion Estimation not supported.
  579. * \n 1 : QuarterPel Motion Estimation supported.
  580. */
  581. NV_ENC_CAPS_SUPPORT_QPELMV,
  582. /**
  583. * H.264 specific. Indicates HW support for BDirect modes.
  584. * \n 0 : BDirect mode encoding not supported.
  585. * \n 1 : BDirect mode encoding supported.
  586. */
  587. NV_ENC_CAPS_SUPPORT_BDIRECT_MODE,
  588. /**
  589. * H264 specific. Indicates HW support for CABAC entropy coding mode.
  590. * \n 0 : CABAC entropy coding not supported.
  591. * \n 1 : CABAC entropy coding supported.
  592. */
  593. NV_ENC_CAPS_SUPPORT_CABAC,
  594. /**
  595. * Indicates HW support for Adaptive Transform.
  596. * \n 0 : Adaptive Transform not supported.
  597. * \n 1 : Adaptive Transform supported.
  598. */
  599. NV_ENC_CAPS_SUPPORT_ADAPTIVE_TRANSFORM,
  600. /**
  601. * Reserved enum field.
  602. */
  603. NV_ENC_CAPS_SUPPORT_RESERVED,
  604. /**
  605. * Indicates HW support for encoding Temporal layers.
  606. * \n 0 : Encoding Temporal layers not supported.
  607. * \n 1 : Encoding Temporal layers supported.
  608. */
  609. NV_ENC_CAPS_NUM_MAX_TEMPORAL_LAYERS,
  610. /**
  611. * Indicates HW support for Hierarchical P frames.
  612. * \n 0 : Hierarchical P frames not supported.
  613. * \n 1 : Hierarchical P frames supported.
  614. */
  615. NV_ENC_CAPS_SUPPORT_HIERARCHICAL_PFRAMES,
  616. /**
  617. * Indicates HW support for Hierarchical B frames.
  618. * \n 0 : Hierarchical B frames not supported.
  619. * \n 1 : Hierarchical B frames supported.
  620. */
  621. NV_ENC_CAPS_SUPPORT_HIERARCHICAL_BFRAMES,
  622. /**
  623. * Maximum Encoding level supported (See ::NV_ENC_LEVEL for details).
  624. */
  625. NV_ENC_CAPS_LEVEL_MAX,
  626. /**
  627. * Minimum Encoding level supported (See ::NV_ENC_LEVEL for details).
  628. */
  629. NV_ENC_CAPS_LEVEL_MIN,
  630. /**
  631. * Indicates HW support for separate colour plane encoding.
  632. * \n 0 : Separate colour plane encoding not supported.
  633. * \n 1 : Separate colour plane encoding supported.
  634. */
  635. NV_ENC_CAPS_SEPARATE_COLOUR_PLANE,
  636. /**
  637. * Maximum output width supported.
  638. */
  639. NV_ENC_CAPS_WIDTH_MAX,
  640. /**
  641. * Maximum output height supported.
  642. */
  643. NV_ENC_CAPS_HEIGHT_MAX,
  644. /**
  645. * Indicates Temporal Scalability Support.
  646. * \n 0 : Temporal SVC encoding not supported.
  647. * \n 1 : Temporal SVC encoding supported.
  648. */
  649. NV_ENC_CAPS_SUPPORT_TEMPORAL_SVC,
  650. /**
  651. * Indicates Dynamic Encode Resolution Change Support.
  652. * Support added from NvEncodeAPI version 2.0.
  653. * \n 0 : Dynamic Encode Resolution Change not supported.
  654. * \n 1 : Dynamic Encode Resolution Change supported.
  655. */
  656. NV_ENC_CAPS_SUPPORT_DYN_RES_CHANGE,
  657. /**
  658. * Indicates Dynamic Encode Bitrate Change Support.
  659. * Support added from NvEncodeAPI version 2.0.
  660. * \n 0 : Dynamic Encode bitrate change not supported.
  661. * \n 1 : Dynamic Encode bitrate change supported.
  662. */
  663. NV_ENC_CAPS_SUPPORT_DYN_BITRATE_CHANGE,
  664. /**
  665. * Indicates Forcing Constant QP On The Fly Support.
  666. * Support added from NvEncodeAPI version 2.0.
  667. * \n 0 : Forcing constant QP on the fly not supported.
  668. * \n 1 : Forcing constant QP on the fly supported.
  669. */
  670. NV_ENC_CAPS_SUPPORT_DYN_FORCE_CONSTQP,
  671. /**
  672. * Indicates Dynamic rate control mode Change Support.
  673. * \n 0 : Dynamic rate control mode change not supported.
  674. * \n 1 : Dynamic rate control mode change supported.
  675. */
  676. NV_ENC_CAPS_SUPPORT_DYN_RCMODE_CHANGE,
  677. /**
  678. * Indicates Subframe readback support for slice-based encoding.
  679. * \n 0 : Subframe readback not supported.
  680. * \n 1 : Subframe readback supported.
  681. */
  682. NV_ENC_CAPS_SUPPORT_SUBFRAME_READBACK,
  683. /**
  684. * Indicates Constrained Encoding mode support.
  685. * Support added from NvEncodeAPI version 2.0.
  686. * \n 0 : Constrained encoding mode not supported.
  687. * \n 1 : Constarined encoding mode supported.
  688. * If this mode is supported client can enable this during initialisation.
  689. * Client can then force a picture to be coded as constrained picture where
  690. * each slice in a constrained picture will have constrained_intra_pred_flag set to 1
  691. * and disable_deblocking_filter_idc will be set to 2 and prediction vectors for inter
  692. * macroblocks in each slice will be restricted to the slice region.
  693. */
  694. NV_ENC_CAPS_SUPPORT_CONSTRAINED_ENCODING,
  695. /**
  696. * Indicates Intra Refresh Mode Support.
  697. * Support added from NvEncodeAPI version 2.0.
  698. * \n 0 : Intra Refresh Mode not supported.
  699. * \n 1 : Intra Refresh Mode supported.
  700. */
  701. NV_ENC_CAPS_SUPPORT_INTRA_REFRESH,
  702. /**
  703. * Indicates Custom VBV Bufer Size support. It can be used for capping frame size.
  704. * Support added from NvEncodeAPI version 2.0.
  705. * \n 0 : Custom VBV buffer size specification from client, not supported.
  706. * \n 1 : Custom VBV buffer size specification from client, supported.
  707. */
  708. NV_ENC_CAPS_SUPPORT_CUSTOM_VBV_BUF_SIZE,
  709. /**
  710. * Indicates Dynamic Slice Mode Support.
  711. * Support added from NvEncodeAPI version 2.0.
  712. * \n 0 : Dynamic Slice Mode not supported.
  713. * \n 1 : Dynamic Slice Mode supported.
  714. */
  715. NV_ENC_CAPS_SUPPORT_DYNAMIC_SLICE_MODE,
  716. /**
  717. * Indicates Reference Picture Invalidation Support.
  718. * Support added from NvEncodeAPI version 2.0.
  719. * \n 0 : Reference Picture Invalidation not supported.
  720. * \n 1 : Reference Picture Invalidation supported.
  721. */
  722. NV_ENC_CAPS_SUPPORT_REF_PIC_INVALIDATION,
  723. /**
  724. * Indicates support for PreProcessing.
  725. * The API return value is a bitmask of the values defined in ::NV_ENC_PREPROC_FLAGS
  726. */
  727. NV_ENC_CAPS_PREPROC_SUPPORT,
  728. /**
  729. * Indicates support Async mode.
  730. * \n 0 : Async Encode mode not supported.
  731. * \n 1 : Async Encode mode supported.
  732. */
  733. NV_ENC_CAPS_ASYNC_ENCODE_SUPPORT,
  734. /**
  735. * Maximum MBs per frame supported.
  736. */
  737. NV_ENC_CAPS_MB_NUM_MAX,
  738. /**
  739. * Maximum aggregate throughput in MBs per sec.
  740. */
  741. NV_ENC_CAPS_MB_PER_SEC_MAX,
  742. /**
  743. * Indicates HW support for YUV444 mode encoding.
  744. * \n 0 : YUV444 mode encoding not supported.
  745. * \n 1 : YUV444 mode encoding supported.
  746. */
  747. NV_ENC_CAPS_SUPPORT_YUV444_ENCODE,
  748. /**
  749. * Indicates HW support for lossless encoding.
  750. * \n 0 : lossless encoding not supported.
  751. * \n 1 : lossless encoding supported.
  752. */
  753. NV_ENC_CAPS_SUPPORT_LOSSLESS_ENCODE,
  754. /**
  755. * Indicates HW support for Sample Adaptive Offset.
  756. * \n 0 : SAO not supported.
  757. * \n 1 : SAO encoding supported.
  758. */
  759. NV_ENC_CAPS_SUPPORT_SAO,
  760. /**
  761. * Indicates HW support for MEOnly Mode.
  762. * \n 0 : MEOnly Mode not supported.
  763. * \n 1 : MEOnly Mode supported.
  764. */
  765. NV_ENC_CAPS_SUPPORT_MEONLY_MODE,
  766. /**
  767. * Indicates HW support for lookahead encoding (enableLookahead=1).
  768. * \n 0 : Lookahead not supported.
  769. * \n 1 : Lookahead supported.
  770. */
  771. NV_ENC_CAPS_SUPPORT_LOOKAHEAD,
  772. /**
  773. * Indicates HW support for temporal AQ encoding (enableTemporalAQ=1).
  774. * \n 0 : Temporal AQ not supported.
  775. * \n 1 : Temporal AQ supported.
  776. */
  777. NV_ENC_CAPS_SUPPORT_TEMPORAL_AQ,
  778. /**
  779. * Indicates HW support for 10 bit encoding.
  780. * \n 0 : 10 bit encoding not supported.
  781. * \n 1 : 10 bit encoding supported.
  782. */
  783. NV_ENC_CAPS_SUPPORT_10BIT_ENCODE,
  784. /**
  785. * Reserved - Not to be used by clients.
  786. */
  787. NV_ENC_CAPS_EXPOSED_COUNT
  788. } NV_ENC_CAPS;
  789. /**
  790. * HEVC CU SIZE
  791. */
  792. typedef enum _NV_ENC_HEVC_CUSIZE
  793. {
  794. NV_ENC_HEVC_CUSIZE_AUTOSELECT = 0,
  795. NV_ENC_HEVC_CUSIZE_8x8 = 1,
  796. NV_ENC_HEVC_CUSIZE_16x16 = 2,
  797. NV_ENC_HEVC_CUSIZE_32x32 = 3,
  798. NV_ENC_HEVC_CUSIZE_64x64 = 4,
  799. }NV_ENC_HEVC_CUSIZE;
  800. /**
  801. * Input struct for querying Encoding capabilities.
  802. */
  803. typedef struct _NV_ENC_CAPS_PARAM
  804. {
  805. uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_CAPS_PARAM_VER */
  806. NV_ENC_CAPS capsToQuery; /**< [in]: Specifies the encode capability to be queried. Client should pass a member for ::NV_ENC_CAPS enum. */
  807. uint32_t reserved[62]; /**< [in]: Reserved and must be set to 0 */
  808. } NV_ENC_CAPS_PARAM;
  809. /** NV_ENC_CAPS_PARAM struct version. */
  810. #define NV_ENC_CAPS_PARAM_VER NVENCAPI_STRUCT_VERSION(1)
  811. /**
  812. * Creation parameters for input buffer.
  813. */
  814. typedef struct _NV_ENC_CREATE_INPUT_BUFFER
  815. {
  816. uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_CREATE_INPUT_BUFFER_VER */
  817. uint32_t width; /**< [in]: Input buffer width */
  818. uint32_t height; /**< [in]: Input buffer width */
  819. NV_ENC_MEMORY_HEAP memoryHeap; /**< [in]: Deprecated. Will be removed in sdk 8.0 */
  820. NV_ENC_BUFFER_FORMAT bufferFmt; /**< [in]: Input buffer format */
  821. uint32_t reserved; /**< [in]: Reserved and must be set to 0 */
  822. NV_ENC_INPUT_PTR inputBuffer; /**< [out]: Pointer to input buffer */
  823. void* pSysMemBuffer; /**< [in]: Pointer to existing sysmem buffer */
  824. uint32_t reserved1[57]; /**< [in]: Reserved and must be set to 0 */
  825. void* reserved2[63]; /**< [in]: Reserved and must be set to NULL */
  826. } NV_ENC_CREATE_INPUT_BUFFER;
  827. /** NV_ENC_CREATE_INPUT_BUFFER struct version. */
  828. #define NV_ENC_CREATE_INPUT_BUFFER_VER NVENCAPI_STRUCT_VERSION(1)
  829. /**
  830. * Creation parameters for output bitstream buffer.
  831. */
  832. typedef struct _NV_ENC_CREATE_BITSTREAM_BUFFER
  833. {
  834. uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_CREATE_BITSTREAM_BUFFER_VER */
  835. uint32_t size; /**< [in]: Size of the bitstream buffer to be created */
  836. NV_ENC_MEMORY_HEAP memoryHeap; /**< [in]: Deprecated. Will be removed in sdk 8.0 */
  837. uint32_t reserved; /**< [in]: Reserved and must be set to 0 */
  838. NV_ENC_OUTPUT_PTR bitstreamBuffer; /**< [out]: Pointer to the output bitstream buffer */
  839. void* bitstreamBufferPtr; /**< [out]: Reserved and should not be used */
  840. uint32_t reserved1[58]; /**< [in]: Reserved and should be set to 0 */
  841. void* reserved2[64]; /**< [in]: Reserved and should be set to NULL */
  842. } NV_ENC_CREATE_BITSTREAM_BUFFER;
  843. /** NV_ENC_CREATE_BITSTREAM_BUFFER struct version. */
  844. #define NV_ENC_CREATE_BITSTREAM_BUFFER_VER NVENCAPI_STRUCT_VERSION(1)
  845. /**
  846. * Structs needed for ME only mode.
  847. */
  848. typedef struct _NV_ENC_MVECTOR
  849. {
  850. int16_t mvx; /**< the x component of MV in qpel units */
  851. int16_t mvy; /**< the y component of MV in qpel units */
  852. } NV_ENC_MVECTOR;
  853. /**
  854. * Motion vector structure per macroblock for H264 motion estimation.
  855. */
  856. typedef struct _NV_ENC_H264_MV_DATA
  857. {
  858. NV_ENC_MVECTOR mv[4]; /**< up to 4 vectors for 8x8 partition */
  859. uint8_t mbType; /**< 0 (I), 1 (P), 2 (IPCM), 3 (B) */
  860. uint8_t partitionType; /**< Specifies the block partition type. 0:16x16, 1:8x8, 2:16x8, 3:8x16 */
  861. uint16_t reserved; /**< reserved padding for alignment */
  862. uint32_t mbCost;
  863. } NV_ENC_H264_MV_DATA;
  864. /**
  865. * Motion vector structure per CU for HEVC motion estimation.
  866. */
  867. typedef struct _NV_ENC_HEVC_MV_DATA
  868. {
  869. NV_ENC_MVECTOR mv[4]; /**< up to 4 vectors within a CU */
  870. uint8_t cuType; /**< 0 (I), 1(P), 2 (Skip) */
  871. uint8_t cuSize; /**< 0: 8x8, 1: 16x16, 2: 32x32, 3: 64x64 */
  872. uint8_t partitionMode; /**< The CU partition mode
  873. 0 (2Nx2N), 1 (2NxN), 2(Nx2N), 3 (NxN),
  874. 4 (2NxnU), 5 (2NxnD), 6(nLx2N), 7 (nRx2N) */
  875. uint8_t lastCUInCTB; /**< Marker to separate CUs in the current CTB from CUs in the next CTB */
  876. } NV_ENC_HEVC_MV_DATA;
  877. /**
  878. * Creation parameters for output motion vector buffer for ME only mode.
  879. */
  880. typedef struct _NV_ENC_CREATE_MV_BUFFER
  881. {
  882. uint32_t version; /**< [in]: Struct version. Must be set to NV_ENC_CREATE_MV_BUFFER_VER */
  883. NV_ENC_OUTPUT_PTR mvBuffer; /**< [out]: Pointer to the output motion vector buffer */
  884. uint32_t reserved1[255]; /**< [in]: Reserved and should be set to 0 */
  885. void* reserved2[63]; /**< [in]: Reserved and should be set to NULL */
  886. } NV_ENC_CREATE_MV_BUFFER;
  887. /** NV_ENC_CREATE_MV_BUFFER struct version*/
  888. #define NV_ENC_CREATE_MV_BUFFER_VER NVENCAPI_STRUCT_VERSION(1)
  889. /**
  890. * QP value for frames
  891. */
  892. typedef struct _NV_ENC_QP
  893. {
  894. uint32_t qpInterP;
  895. uint32_t qpInterB;
  896. uint32_t qpIntra;
  897. } NV_ENC_QP;
  898. /**
  899. * Rate Control Configuration Paramters
  900. */
  901. typedef struct _NV_ENC_RC_PARAMS
  902. {
  903. uint32_t version;
  904. 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. */
  905. 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. */
  906. uint32_t averageBitRate; /**< [in]: Specifies the average bitrate(in bits/sec) used for encoding. */
  907. uint32_t maxBitRate; /**< [in]: Specifies the maximum bitrate for the encoded output. This is used for VBR and ignored for CBR mode. */
  908. uint32_t vbvBufferSize; /**< [in]: Specifies the VBV(HRD) buffer size. in bits. Set 0 to use the default VBV buffer size. */
  909. uint32_t vbvInitialDelay; /**< [in]: Specifies the VBV(HRD) initial delay in bits. Set 0 to use the default VBV initial delay .*/
  910. uint32_t enableMinQP :1; /**< [in]: Set this to 1 if minimum QP used for rate control. */
  911. uint32_t enableMaxQP :1; /**< [in]: Set this to 1 if maximum QP used for rate control. */
  912. uint32_t enableInitialRCQP :1; /**< [in]: Set this to 1 if user suppplied initial QP is used for rate control. */
  913. uint32_t enableAQ :1; /**< [in]: Set this to 1 to enable adaptive quantization (Spatial). */
  914. uint32_t enableExtQPDeltaMap :1; /**< [in]: Set this to 1 to enable additional QP modifier for each MB supplied by client though signed byte array pointed to by NV_ENC_PIC_PARAMS::qpDeltaMap (Not Supported when AQ(Spatial/Temporal) is enabled) */
  915. uint32_t enableLookahead :1; /**< [in]: Set this to 1 to enable lookahead with depth <lookaheadDepth> (if lookahead is enabled, input frames must remain available to the encoder until encode completion) */
  916. 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) */
  917. uint32_t disableBadapt :1; /**< [in]: Set this to 1 to disable adaptive B-frame decision (only has an effect when lookahead is enabled) */
  918. uint32_t enableTemporalAQ :1; /**< [in]: Set this to 1 to enable temporal AQ for H.264 */
  919. uint32_t zeroReorderDelay :1; /**< [in]: Set this to 1 to indicate zero latency operation (no reordering delay, num_reorder_frames=0) */
  920. uint32_t enableNonRefP :1; /**< [in]: Set this to 1 to enable automatic insertion of non-reference P-frames (no effect if enablePTD=0) */
  921. uint32_t strictGOPTarget :1; /**< [in]: Set this to 1 to minimize GOP-to-GOP rate fluctuations */
  922. 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 autoselected by driver. Currently supported only with h264 */
  923. uint32_t reservedBitFields :16; /**< [in]: Reserved bitfields and must be set to 0 */
  924. NV_ENC_QP minQP; /**< [in]: Specifies the minimum QP used for rate control. Client must set NV_ENC_CONFIG::enableMinQP to 1. */
  925. NV_ENC_QP maxQP; /**< [in]: Specifies the maximum QP used for rate control. Client must set NV_ENC_CONFIG::enableMaxQP to 1. */
  926. NV_ENC_QP initialRCQP; /**< [in]: Specifies the initial QP used for rate control. Client must set NV_ENC_CONFIG::enableInitialRCQP to 1. */
  927. 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] */
  928. uint8_t temporalLayerQP[8]; /**< [in]: Specifies the temporal layer QPs used for rate control. Temporal layer index is used as as the array index */
  929. uint16_t targetQuality; /**< [in]: Target CQ (Constant Quality) level for VBR mode (range 0-51 with 0-automatic) */
  930. uint16_t lookaheadDepth; /**< [in]: Maximum depth of lookahead with range 0-32 (only used if enableLookahead=1) */
  931. uint32_t reserved[9];
  932. } NV_ENC_RC_PARAMS;
  933. /** macro for constructing the version field of ::_NV_ENC_RC_PARAMS */
  934. #define NV_ENC_RC_PARAMS_VER NVENCAPI_STRUCT_VERSION(1)
  935. /**
  936. * \struct _NV_ENC_CONFIG_H264_VUI_PARAMETERS
  937. * H264 Video Usability Info parameters
  938. */
  939. typedef struct _NV_ENC_CONFIG_H264_VUI_PARAMETERS
  940. {
  941. uint32_t overscanInfoPresentFlag; /**< [in]: if set to 1 , it specifies that the overscanInfo is present */
  942. uint32_t overscanInfo; /**< [in]: Specifies the overscan info(as defined in Annex E of the ITU-T Specification). */
  943. uint32_t videoSignalTypePresentFlag; /**< [in]: If set to 1, it specifies that the videoFormat, videoFullRangeFlag and colourDescriptionPresentFlag are present. */
  944. uint32_t videoFormat; /**< [in]: Specifies the source video format(as defined in Annex E of the ITU-T Specification).*/
  945. uint32_t videoFullRangeFlag; /**< [in]: Specifies the output range of the luma and chroma samples(as defined in Annex E of the ITU-T Specification). */
  946. uint32_t colourDescriptionPresentFlag; /**< [in]: If set to 1, it specifies that the colourPrimaries, transferCharacteristics and colourMatrix are present. */
  947. uint32_t colourPrimaries; /**< [in]: Specifies color primaries for converting to RGB(as defined in Annex E of the ITU-T Specification) */
  948. uint32_t transferCharacteristics; /**< [in]: Specifies the opto-electronic transfer characteristics to use (as defined in Annex E of the ITU-T Specification) */
  949. uint32_t 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). */
  950. uint32_t chromaSampleLocationFlag; /**< [in]: if set to 1 , it specifies that the chromaSampleLocationTop and chromaSampleLocationBot are present.*/
  951. uint32_t chromaSampleLocationTop; /**< [in]: Specifies the chroma sample location for top field(as defined in Annex E of the ITU-T Specification) */
  952. uint32_t chromaSampleLocationBot; /**< [in]: Specifies the chroma sample location for bottom field(as defined in Annex E of the ITU-T Specification) */
  953. uint32_t bitstreamRestrictionFlag; /**< [in]: if set to 1, it specifies the bitstream restriction parameters are present in the bitstream.*/
  954. uint32_t reserved[15];
  955. }NV_ENC_CONFIG_H264_VUI_PARAMETERS;
  956. typedef NV_ENC_CONFIG_H264_VUI_PARAMETERS NV_ENC_CONFIG_HEVC_VUI_PARAMETERS;
  957. /**
  958. * \struct _NVENC_EXTERNAL_ME_HINT_COUNTS_PER_BLOCKTYPE
  959. * External motion vector hint counts per block type.
  960. */
  961. typedef struct _NVENC_EXTERNAL_ME_HINT_COUNTS_PER_BLOCKTYPE
  962. {
  963. uint32_t numCandsPerBlk16x16 : 4; /**< [in]: Specifies the number of candidates per 16x16 block. */
  964. uint32_t numCandsPerBlk16x8 : 4; /**< [in]: Specifies the number of candidates per 16x8 block. */
  965. uint32_t numCandsPerBlk8x16 : 4; /**< [in]: Specifies the number of candidates per 8x16 block. */
  966. uint32_t numCandsPerBlk8x8 : 4; /**< [in]: Specifies the number of candidates per 8x8 block. */
  967. uint32_t reserved : 16; /**< [in]: Reserved for padding. */
  968. uint32_t reserved1[3]; /**< [in]: Reserved for future use. */
  969. } NVENC_EXTERNAL_ME_HINT_COUNTS_PER_BLOCKTYPE;
  970. /**
  971. * \struct _NVENC_EXTERNAL_ME_HINT
  972. * External Motion Vector hint structure.
  973. */
  974. typedef struct _NVENC_EXTERNAL_ME_HINT
  975. {
  976. int32_t mvx : 12; /**< [in]: Specifies the x component of integer pixel MV (relative to current MB) S12.0. */
  977. int32_t mvy : 10; /**< [in]: Specifies the y component of integer pixel MV (relative to current MB) S10.0 .*/
  978. 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. */
  979. int32_t dir : 1; /**< [in]: Specifies the direction of motion estimation . 0=L0 1=L1.*/
  980. int32_t partType : 2; /**< [in]: Specifies the block partition type.0=16x16 1=16x8 2=8x16 3=8x8 (blocks in partition must be consecutive).*/
  981. int32_t lastofPart : 1; /**< [in]: Set to 1 for the last MV of (sub) partition */
  982. int32_t lastOfMB : 1; /**< [in]: Set to 1 for the last MV of macroblock. */
  983. } NVENC_EXTERNAL_ME_HINT;
  984. /**
  985. * \struct _NV_ENC_CONFIG_H264
  986. * H264 encoder configuration parameters
  987. */
  988. typedef struct _NV_ENC_CONFIG_H264
  989. {
  990. uint32_t enableTemporalSVC :1; /**< [in]: Set to 1 to enable SVC temporal*/
  991. uint32_t enableStereoMVC :1; /**< [in]: Set to 1 to enable stereo MVC*/
  992. uint32_t hierarchicalPFrames :1; /**< [in]: Set to 1 to enable hierarchical PFrames */
  993. uint32_t hierarchicalBFrames :1; /**< [in]: Set to 1 to enable hierarchical BFrames */
  994. uint32_t outputBufferingPeriodSEI :1; /**< [in]: Set to 1 to write SEI buffering period syntax in the bitstream */
  995. uint32_t outputPictureTimingSEI :1; /**< [in]: Set to 1 to write SEI picture timing syntax in the bitstream */
  996. uint32_t outputAUD :1; /**< [in]: Set to 1 to write access unit delimiter syntax in bitstream */
  997. uint32_t disableSPSPPS :1; /**< [in]: Set to 1 to disable writing of Sequence and Picture parameter info in bitstream */
  998. uint32_t outputFramePackingSEI :1; /**< [in]: Set to 1 to enable writing of frame packing arrangement SEI messages to bitstream */
  999. uint32_t outputRecoveryPointSEI :1; /**< [in]: Set to 1 to enable writing of recovery point SEI message */
  1000. 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 */
  1001. uint32_t enableConstrainedEncoding :1; /**< [in]: Set this to 1 to enable constrainedFrame encoding where each slice in the constarined picture is independent of other slices
  1002. Check support for constrained encoding using ::NV_ENC_CAPS_SUPPORT_CONSTRAINED_ENCODING caps. */
  1003. uint32_t repeatSPSPPS :1; /**< [in]: Set to 1 to enable writing of Sequence and Picture parameter for every IDR frame */
  1004. uint32_t enableVFR :1; /**< [in]: Set to 1 to enable variable frame rate. */
  1005. uint32_t enableLTR :1; /**< [in]: Currently this feature is not available and must be set to 0. Set to 1 to enable LTR support and auto-mark the first */
  1006. 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.
  1007. Check support for lossless encoding using ::NV_ENC_CAPS_SUPPORT_LOSSLESS_ENCODE caps. */
  1008. uint32_t useConstrainedIntraPred :1; /**< [in]: Set 1 to enable constrained intra prediction. */
  1009. uint32_t reservedBitFields :15; /**< [in]: Reserved bitfields and must be set to 0 */
  1010. 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. */
  1011. 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. */
  1012. uint32_t separateColourPlaneFlag; /**< [in]: Set to 1 to enable 4:4:4 separate colour planes */
  1013. uint32_t disableDeblockingFilterIDC; /**< [in]: Specifies the deblocking filter mode. Permissible value range: [0,2] */
  1014. uint32_t numTemporalLayers; /**< [in]: Specifies max temporal layers to be used for hierarchical coding. Valid value range is [1,::NV_ENC_CAPS_NUM_MAX_TEMPORAL_LAYERS] */
  1015. uint32_t spsId; /**< [in]: Specifies the SPS id of the sequence header. Currently reserved and must be set to 0. */
  1016. uint32_t ppsId; /**< [in]: Specifies the PPS id of the picture header. Currently reserved and must be set to 0. */
  1017. 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. */
  1018. NV_ENC_H264_FMO_MODE fmoMode; /**< [in]: Specified the FMO Mode. Check support for FMO using ::NV_ENC_CAPS_SUPPORT_FMO caps. */
  1019. NV_ENC_H264_BDIRECT_MODE bdirectMode; /**< [in]: Specifies the BDirect mode. Check support for BDirect mode using ::NV_ENC_CAPS_SUPPORT_BDIRECT_MODE caps.*/
  1020. 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. */
  1021. NV_ENC_STEREO_PACKING_MODE stereoMode; /**< [in]: Specifies the stereo frame packing mode which is to be signalled in frame packing arrangement SEI */
  1022. uint32_t intraRefreshPeriod; /**< [in]: Specifies the interval between successive intra refresh if enableIntrarefresh is set. Requires enableIntraRefresh to be set.
  1023. Will be disabled if NV_ENC_CONFIG::gopLength is not set to NVENC_INFINITE_GOPLENGTH. */
  1024. 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 */
  1025. uint32_t maxNumRefFrames; /**< [in]: Specifies the DPB size used for encoding. Setting it to 0 will let driver use the default dpb size.
  1026. The low latency application which wants to invalidate reference frame as an error resilience tool
  1027. is recommended to use a large DPB size so that the encoder can keep old reference frames which can be used if recent
  1028. frames are invalidated. */
  1029. uint32_t sliceMode; /**< [in]: This parameter in conjunction with sliceModeData specifies the way in which the picture is divided into slices
  1030. sliceMode = 0 MB based slices, sliceMode = 1 Byte based slices, sliceMode = 2 MB row based slices, sliceMode = 3, numSlices in Picture
  1031. When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting
  1032. When sliceMode == 0 and sliceModeData == 0 whole picture will be coded with one slice */
  1033. uint32_t sliceModeData; /**< [in]: Specifies the parameter needed for sliceMode. For:
  1034. sliceMode = 0, sliceModeData specifies # of MBs in each slice (except last slice)
  1035. sliceMode = 1, sliceModeData specifies maximum # of bytes in each slice (except last slice)
  1036. sliceMode = 2, sliceModeData specifies # of MB rows in each slice (except last slice)
  1037. sliceMode = 3, sliceModeData specifies number of slices in the picture. Driver will divide picture into slices optimally */
  1038. NV_ENC_CONFIG_H264_VUI_PARAMETERS h264VUIParameters; /**< [in]: Specifies the H264 video usability info pamameters */
  1039. uint32_t ltrNumFrames; /**< [in]: Specifies the number of LTR frames used.
  1040. If ltrTrustMode=1, encoder will mark first numLTRFrames base layer reference frames within each IDR interval as LTR.
  1041. If ltrMarkFrame=1, ltrNumFrames specifies maximum number of ltr frames in DPB.
  1042. If ltrNumFrames value is more that DPB size(maxNumRefFrames) encoder will take decision on its own. */
  1043. uint32_t ltrTrustMode; /**< [in]: Specifies the LTR operating mode.
  1044. Set to 0 to disallow encoding using LTR frames until later specified.
  1045. Set to 1 to allow encoding using LTR frames unless later invalidated.*/
  1046. uint32_t chromaFormatIDC; /**< [in]: Specifies the chroma format. Should be set to 1 for yuv420 input, 3 for yuv444 input.
  1047. Check support for YUV444 encoding using ::NV_ENC_CAPS_SUPPORT_YUV444_ENCODE caps.*/
  1048. uint32_t maxTemporalLayers; /**< [in]: Specifies the max temporal layer used for hierarchical coding. */
  1049. uint32_t reserved1[270]; /**< [in]: Reserved and must be set to 0 */
  1050. void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
  1051. } NV_ENC_CONFIG_H264;
  1052. /**
  1053. * \struct _NV_ENC_CONFIG_HEVC
  1054. * HEVC encoder configuration parameters to be set during initialization.
  1055. */
  1056. typedef struct _NV_ENC_CONFIG_HEVC
  1057. {
  1058. uint32_t level; /**< [in]: Specifies the level of the encoded bitstream.*/
  1059. uint32_t tier; /**< [in]: Specifies the level tier of the encoded bitstream.*/
  1060. NV_ENC_HEVC_CUSIZE minCUSize; /**< [in]: Specifies the minimum size of luma coding unit.*/
  1061. 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.*/
  1062. uint32_t useConstrainedIntraPred :1; /**< [in]: Set 1 to enable constrained intra prediction. */
  1063. uint32_t disableDeblockAcrossSliceBoundary :1; /**< [in]: Set 1 to disable in loop filtering across slice boundary.*/
  1064. uint32_t outputBufferingPeriodSEI :1; /**< [in]: Set 1 to write SEI buffering period syntax in the bitstream */
  1065. uint32_t outputPictureTimingSEI :1; /**< [in]: Set 1 to write SEI picture timing syntax in the bitstream */
  1066. uint32_t outputAUD :1; /**< [in]: Set 1 to write Access Unit Delimiter syntax. */
  1067. uint32_t enableLTR :1; /**< [in]: Set 1 to enable use of long term reference pictures for inter prediction. */
  1068. uint32_t disableSPSPPS :1; /**< [in]: Set 1 to disable VPS,SPS and PPS signalling in the bitstream. */
  1069. uint32_t repeatSPSPPS :1; /**< [in]: Set 1 to output VPS,SPS and PPS for every IDR frame.*/
  1070. 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 */
  1071. uint32_t chromaFormatIDC :2; /**< [in]: Specifies the chroma format. Should be set to 1 for yuv420 input, 3 for yuv444 input.*/
  1072. 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.*/
  1073. uint32_t reserved :18; /**< [in]: Reserved bitfields.*/
  1074. 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. */
  1075. uint32_t intraRefreshPeriod; /**< [in]: Specifies the interval between successive intra refresh if enableIntrarefresh is set. Requires enableIntraRefresh to be set.
  1076. Will be disabled if NV_ENC_CONFIG::gopLength is not set to NVENC_INFINITE_GOPLENGTH. */
  1077. 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 */
  1078. uint32_t maxNumRefFramesInDPB; /**< [in]: Specifies the maximum number of references frames in the DPB.*/
  1079. uint32_t ltrNumFrames; /**< [in]: Specifies the number of LTR frames used.
  1080. If ltrTrustMode=1, encoder will mark first numLTRFrames base layer reference frames within each IDR interval as LTR.
  1081. If ltrMarkFrame=1, ltrNumFrames specifies maximum number of ltr frames in DPB.
  1082. If ltrNumFrames value is more that DPB size(maxNumRefFramesInDPB) encoder will take decision on its own. */
  1083. uint32_t vpsId; /**< [in]: Specifies the VPS id of the video parameter set. Currently reserved and must be set to 0. */
  1084. uint32_t spsId; /**< [in]: Specifies the SPS id of the sequence header. Currently reserved and must be set to 0. */
  1085. uint32_t ppsId; /**< [in]: Specifies the PPS id of the picture header. Currently reserved and must be set to 0. */
  1086. uint32_t sliceMode; /**< [in]: This parameter in conjunction with sliceModeData specifies the way in which the picture is divided into slices
  1087. sliceMode = 0 CTU based slices, sliceMode = 1 Byte based slices, sliceMode = 2 CTU row based slices, sliceMode = 3, numSlices in Picture
  1088. When sliceMode == 0 and sliceModeData == 0 whole picture will be coded with one slice */
  1089. uint32_t sliceModeData; /**< [in]: Specifies the parameter needed for sliceMode. For:
  1090. sliceMode = 0, sliceModeData specifies # of CTUs in each slice (except last slice)
  1091. sliceMode = 1, sliceModeData specifies maximum # of bytes in each slice (except last slice)
  1092. sliceMode = 2, sliceModeData specifies # of CTU rows in each slice (except last slice)
  1093. sliceMode = 3, sliceModeData specifies number of slices in the picture. Driver will divide picture into slices optimally */
  1094. uint32_t maxTemporalLayersMinus1; /**< [in]: Specifies the max temporal layer used for hierarchical coding. */
  1095. NV_ENC_CONFIG_HEVC_VUI_PARAMETERS hevcVUIParameters; /**< [in]: Specifies the HEVC video usability info pamameters */
  1096. uint32_t ltrTrustMode; /**< [in]: Specifies the LTR operating mode.
  1097. Set to 0 to disallow encoding using LTR frames until later specified.
  1098. Set to 1 to allow encoding using LTR frames unless later invalidated.*/
  1099. uint32_t reserved1[217]; /**< [in]: Reserved and must be set to 0.*/
  1100. void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
  1101. } NV_ENC_CONFIG_HEVC;
  1102. /**
  1103. * \struct _NV_ENC_CODEC_CONFIG
  1104. * Codec-specific encoder configuration parameters to be set during initialization.
  1105. */
  1106. typedef union _NV_ENC_CODEC_CONFIG
  1107. {
  1108. NV_ENC_CONFIG_H264 h264Config; /**< [in]: Specifies the H.264-specific encoder configuration. */
  1109. NV_ENC_CONFIG_HEVC hevcConfig; /**< [in]: Specifies the HEVC-specific encoder configuration. */
  1110. uint32_t reserved[256]; /**< [in]: Reserved and must be set to 0 */
  1111. } NV_ENC_CODEC_CONFIG;
  1112. /**
  1113. * \struct _NV_ENC_CONFIG
  1114. * Encoder configuration parameters to be set during initialization.
  1115. */
  1116. typedef struct _NV_ENC_CONFIG
  1117. {
  1118. uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_CONFIG_VER. */
  1119. 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. */
  1120. 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. */
  1121. 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. */
  1122. uint32_t monoChromeEncoding; /**< [in]: Set this to 1 to enable monochrome encoding for this session. */
  1123. NV_ENC_PARAMS_FRAME_FIELD_MODE frameFieldMode; /**< [in]: Specifies the frame/field mode.
  1124. Check support for field encoding using ::NV_ENC_CAPS_SUPPORT_FIELD_ENCODING caps.
  1125. Using a frameFieldMode other than NV_ENC_PARAMS_FRAME_FIELD_MODE_FRAME for RGB input is not supported. */
  1126. NV_ENC_MV_PRECISION mvPrecision; /**< [in]: Specifies the desired motion vector prediction precision. */
  1127. NV_ENC_RC_PARAMS rcParams; /**< [in]: Specifies the rate control parameters for the current encoding session. */
  1128. NV_ENC_CODEC_CONFIG encodeCodecConfig; /**< [in]: Specifies the codec specific config parameters through this union. */
  1129. uint32_t reserved [278]; /**< [in]: Reserved and must be set to 0 */
  1130. void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
  1131. } NV_ENC_CONFIG;
  1132. /** macro for constructing the version field of ::_NV_ENC_CONFIG */
  1133. #define NV_ENC_CONFIG_VER (NVENCAPI_STRUCT_VERSION(6) | ( 1<<31 ))
  1134. /**
  1135. * \struct _NV_ENC_INITIALIZE_PARAMS
  1136. * Encode Session Initialization parameters.
  1137. */
  1138. typedef struct _NV_ENC_INITIALIZE_PARAMS
  1139. {
  1140. uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_INITIALIZE_PARAMS_VER. */
  1141. 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. */
  1142. 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. */
  1143. uint32_t encodeWidth; /**< [in]: Specifies the encode width. If not set ::NvEncInitializeEncoder() API will fail. */
  1144. uint32_t encodeHeight; /**< [in]: Specifies the encode height. If not set ::NvEncInitializeEncoder() API will fail. */
  1145. uint32_t darWidth; /**< [in]: Specifies the display aspect ratio Width. */
  1146. uint32_t darHeight; /**< [in]: Specifies the display aspect ratio height. */
  1147. uint32_t frameRateNum; /**< [in]: Specifies the numerator for frame rate used for encoding in frames per second ( Frame rate = frameRateNum / frameRateDen ). */
  1148. uint32_t frameRateDen; /**< [in]: Specifies the denominator for frame rate used for encoding in frames per second ( Frame rate = frameRateNum / frameRateDen ). */
  1149. uint32_t enableEncodeAsync; /**< [in]: Set this to 1 to enable asynchronous mode and is expected to use events to get picture completion notification. */
  1150. uint32_t enablePTD; /**< [in]: Set this to 1 to enable the Picture Type Decision is be taken by the NvEncodeAPI interface. */
  1151. 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 */
  1152. uint32_t enableSubFrameWrite :1; /**< [in]: Set this to 1 to write out available bitstream to memory at subframe intervals */
  1153. 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.
  1154. NV_ENC_PIC_PARAMS::meHintRefPicDist should preferably be set with enablePTD=1. */
  1155. uint32_t enableMEOnlyMode :1; /**< [in]: Set to 1 to enable ME Only Mode .*/
  1156. uint32_t reservedBitFields :28; /**< [in]: Reserved bitfields and must be set to 0 */
  1157. uint32_t privDataSize; /**< [in]: Reserved private data buffer size and must be set to 0 */
  1158. void* privData; /**< [in]: Reserved private data buffer and must be set to NULL */
  1159. 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.
  1160. 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.
  1161. 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. */
  1162. uint32_t maxEncodeWidth; /**< [in]: Maximum encode width to be used for current Encode session.
  1163. Client should allocate output buffers according to this dimension for dynamic resolution change. If set to 0, Encoder will not allow dynamic resolution change. */
  1164. uint32_t maxEncodeHeight; /**< [in]: Maximum encode height to be allowed for current Encode session.
  1165. Client should allocate output buffers according to this dimension for dynamic resolution change. If set to 0, Encode will not allow dynamic resolution change. */
  1166. 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.
  1167. The NV_ENC_INITIALIZE_PARAMS::maxMEHintCountsPerBlock[0] is for L0 predictors and NV_ENC_INITIALIZE_PARAMS::maxMEHintCountsPerBlock[1] is for L1 predictors.
  1168. This client must also set NV_ENC_INITIALIZE_PARAMS::enableExternalMEHints to 1. */
  1169. uint32_t reserved [289]; /**< [in]: Reserved and must be set to 0 */
  1170. void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
  1171. } NV_ENC_INITIALIZE_PARAMS;
  1172. /** macro for constructing the version field of ::_NV_ENC_INITIALIZE_PARAMS */
  1173. #define NV_ENC_INITIALIZE_PARAMS_VER (NVENCAPI_STRUCT_VERSION(5) | ( 1<<31 ))
  1174. /**
  1175. * \struct _NV_ENC_RECONFIGURE_PARAMS
  1176. * Encode Session Reconfigured parameters.
  1177. */
  1178. typedef struct _NV_ENC_RECONFIGURE_PARAMS
  1179. {
  1180. uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_RECONFIGURE_PARAMS_VER. */
  1181. NV_ENC_INITIALIZE_PARAMS reInitEncodeParams; /**< [in]: Encoder session re-initialization parameters. */
  1182. 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.
  1183. If NV_ENC_INITIALIZE_PARAMS::enablePTD is set to 1, encoder will force the frame type to IDR */
  1184. 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
  1185. [_NV_ENC_INITIALIZE_PARAMS::enablePTD == 1]. */
  1186. uint32_t reserved :30;
  1187. }NV_ENC_RECONFIGURE_PARAMS;
  1188. /** macro for constructing the version field of ::_NV_ENC_RECONFIGURE_PARAMS */
  1189. #define NV_ENC_RECONFIGURE_PARAMS_VER (NVENCAPI_STRUCT_VERSION(1) | ( 1<<31 ))
  1190. /**
  1191. * \struct _NV_ENC_PRESET_CONFIG
  1192. * Encoder preset config
  1193. */
  1194. typedef struct _NV_ENC_PRESET_CONFIG
  1195. {
  1196. uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_PRESET_CONFIG_VER. */
  1197. NV_ENC_CONFIG presetCfg; /**< [out]: preset config returned by the Nvidia Video Encoder interface. */
  1198. uint32_t reserved1[255]; /**< [in]: Reserved and must be set to 0 */
  1199. void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
  1200. }NV_ENC_PRESET_CONFIG;
  1201. /** macro for constructing the version field of ::_NV_ENC_PRESET_CONFIG */
  1202. #define NV_ENC_PRESET_CONFIG_VER (NVENCAPI_STRUCT_VERSION(4) | ( 1<<31 ))
  1203. /**
  1204. * \struct _NV_ENC_SEI_PAYLOAD
  1205. * User SEI message
  1206. */
  1207. typedef struct _NV_ENC_SEI_PAYLOAD
  1208. {
  1209. uint32_t payloadSize; /**< [in] SEI payload size in bytes. SEI payload must be byte aligned, as described in Annex D */
  1210. uint32_t payloadType; /**< [in] SEI payload types and syntax can be found in Annex D of the H.264 Specification. */
  1211. uint8_t *payload; /**< [in] pointer to user data */
  1212. } NV_ENC_SEI_PAYLOAD;
  1213. #define NV_ENC_H264_SEI_PAYLOAD NV_ENC_SEI_PAYLOAD
  1214. /**
  1215. * \struct _NV_ENC_PIC_PARAMS_H264
  1216. * H264 specific enc pic params. sent on a per frame basis.
  1217. */
  1218. typedef struct _NV_ENC_PIC_PARAMS_H264
  1219. {
  1220. uint32_t displayPOCSyntax; /**< [in]: Specifies the display POC syntax This is required to be set if client is handling the picture type decision. */
  1221. uint32_t reserved3; /**< [in]: Reserved and must be set to 0 */
  1222. uint32_t refPicFlag; /**< [in]: Set to 1 for a reference picture. This is ignored if NV_ENC_INITIALIZE_PARAMS::enablePTD is set to 1. */
  1223. uint32_t colourPlaneId; /**< [in]: Specifies the colour plane ID associated with the current input. */
  1224. uint32_t forceIntraRefreshWithFrameCnt; /**< [in]: Forces an intra refresh with duration equal to intraRefreshFrameCnt.
  1225. When outputRecoveryPointSEI is set this is value is used for recovery_frame_cnt in recovery point SEI message
  1226. forceIntraRefreshWithFrameCnt cannot be used if B frames are used in the GOP structure specified */
  1227. 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.
  1228. NV_ENC_INITIALIZE_PARAMS::enableConstrainedEncoding should be set to 1 */
  1229. uint32_t sliceModeDataUpdate :1; /**< [in]: Set to 1 if client wants to change the sliceModeData field to specify new sliceSize Parameter
  1230. When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting */
  1231. uint32_t ltrMarkFrame :1; /**< [in]: Set to 1 if client wants to mark this frame as LTR */
  1232. uint32_t ltrUseFrames :1; /**< [in]: Set to 1 if client allows encoding this frame using the LTR frames specified in ltrFrameBitmap */
  1233. uint32_t reservedBitFields :28; /**< [in]: Reserved bit fields and must be set to 0 */
  1234. uint8_t* sliceTypeData; /**< [in]: Deprecated. */
  1235. uint32_t sliceTypeArrayCnt; /**< [in]: Deprecated. */
  1236. uint32_t seiPayloadArrayCnt; /**< [in]: Specifies the number of elements allocated in seiPayloadArray array. */
  1237. NV_ENC_SEI_PAYLOAD* seiPayloadArray; /**< [in]: Array of SEI payloads which will be inserted for this frame. */
  1238. uint32_t sliceMode; /**< [in]: This parameter in conjunction with sliceModeData specifies the way in which the picture is divided into slices
  1239. sliceMode = 0 MB based slices, sliceMode = 1 Byte based slices, sliceMode = 2 MB row based slices, sliceMode = 3, numSlices in Picture
  1240. When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting
  1241. When sliceMode == 0 and sliceModeData == 0 whole picture will be coded with one slice */
  1242. uint32_t sliceModeData; /**< [in]: Specifies the parameter needed for sliceMode. For:
  1243. sliceMode = 0, sliceModeData specifies # of MBs in each slice (except last slice)
  1244. sliceMode = 1, sliceModeData specifies maximum # of bytes in each slice (except last slice)
  1245. sliceMode = 2, sliceModeData specifies # of MB rows in each slice (except last slice)
  1246. sliceMode = 3, sliceModeData specifies number of slices in the picture. Driver will divide picture into slices optimally */
  1247. uint32_t ltrMarkFrameIdx; /**< [in]: Specifies the long term referenceframe index to use for marking this frame as LTR.*/
  1248. uint32_t ltrUseFrameBitmap; /**< [in]: Specifies the the associated bitmap of LTR frame indices when encoding this frame. */
  1249. uint32_t ltrUsageMode; /**< [in]: Specifies additional usage constraints for encoding using LTR frames from this point further. 0: no constraints, 1: no short term refs older than current, no previous LTR frames.*/
  1250. uint32_t reserved [243]; /**< [in]: Reserved and must be set to 0. */
  1251. void* reserved2[62]; /**< [in]: Reserved and must be set to NULL. */
  1252. } NV_ENC_PIC_PARAMS_H264;
  1253. /**
  1254. * \struct _NV_ENC_PIC_PARAMS_HEVC
  1255. * HEVC specific enc pic params. sent on a per frame basis.
  1256. */
  1257. typedef struct _NV_ENC_PIC_PARAMS_HEVC
  1258. {
  1259. uint32_t displayPOCSyntax; /**< [in]: Specifies the display POC syntax This is required to be set if client is handling the picture type decision. */
  1260. uint32_t refPicFlag; /**< [in]: Set to 1 for a reference picture. This is ignored if NV_ENC_INITIALIZE_PARAMS::enablePTD is set to 1. */
  1261. uint32_t temporalId; /**< [in]: Specifies the temporal id of the picture */
  1262. uint32_t forceIntraRefreshWithFrameCnt; /**< [in]: Forces an intra refresh with duration equal to intraRefreshFrameCnt.
  1263. When outputRecoveryPointSEI is set this is value is used for recovery_frame_cnt in recovery point SEI message
  1264. forceIntraRefreshWithFrameCnt cannot be used if B frames are used in the GOP structure specified */
  1265. 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.
  1266. NV_ENC_INITIALIZE_PARAMS::enableConstrainedEncoding should be set to 1 */
  1267. uint32_t sliceModeDataUpdate :1; /**< [in]: Set to 1 if client wants to change the sliceModeData field to specify new sliceSize Parameter
  1268. When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting */
  1269. uint32_t ltrMarkFrame :1; /**< [in]: Set to 1 if client wants to mark this frame as LTR */
  1270. uint32_t ltrUseFrames :1; /**< [in]: Set to 1 if client allows encoding this frame using the LTR frames specified in ltrFrameBitmap */
  1271. uint32_t reservedBitFields :28; /**< [in]: Reserved bit fields and must be set to 0 */
  1272. 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.
  1273. Client should allocate array of size sliceModeData where sliceModeData is specified in field of ::_NV_ENC_CONFIG_H264
  1274. 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
  1275. all other array elements should be set to NV_ENC_SLICE_TYPE_DEFAULT */
  1276. 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 */
  1277. uint32_t sliceMode; /**< [in]: This parameter in conjunction with sliceModeData specifies the way in which the picture is divided into slices
  1278. sliceMode = 0 CTU based slices, sliceMode = 1 Byte based slices, sliceMode = 2 CTU row based slices, sliceMode = 3, numSlices in Picture
  1279. When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting
  1280. When sliceMode == 0 and sliceModeData == 0 whole picture will be coded with one slice */
  1281. uint32_t sliceModeData; /**< [in]: Specifies the parameter needed for sliceMode. For:
  1282. sliceMode = 0, sliceModeData specifies # of CTUs in each slice (except last slice)
  1283. sliceMode = 1, sliceModeData specifies maximum # of bytes in each slice (except last slice)
  1284. sliceMode = 2, sliceModeData specifies # of CTU rows in each slice (except last slice)
  1285. sliceMode = 3, sliceModeData specifies number of slices in the picture. Driver will divide picture into slices optimally */
  1286. uint32_t ltrMarkFrameIdx; /**< [in]: Specifies the long term reference frame index to use for marking this frame as LTR.*/
  1287. uint32_t ltrUseFrameBitmap; /**< [in]: Specifies the associated bitmap of LTR frame indices when encoding this frame. */
  1288. uint32_t ltrUsageMode; /**< [in]: Specifies additional usage constraints for encoding using LTR frames from this point further. 0: no constraints, 1: no short term refs older than current, no previous LTR frames.*/
  1289. uint32_t seiPayloadArrayCnt; /**< [in]: Specifies the number of elements allocated in seiPayloadArray array. */
  1290. uint32_t reserved; /**< [in]: Reserved and must be set to 0. */
  1291. NV_ENC_SEI_PAYLOAD* seiPayloadArray; /**< [in]: Array of SEI payloads which will be inserted for this frame. */
  1292. uint32_t reserved2 [244]; /**< [in]: Reserved and must be set to 0. */
  1293. void* reserved3[61]; /**< [in]: Reserved and must be set to NULL. */
  1294. } NV_ENC_PIC_PARAMS_HEVC;
  1295. /**
  1296. * Codec specific per-picture encoding parameters.
  1297. */
  1298. typedef union _NV_ENC_CODEC_PIC_PARAMS
  1299. {
  1300. NV_ENC_PIC_PARAMS_H264 h264PicParams; /**< [in]: H264 encode picture params. */
  1301. NV_ENC_PIC_PARAMS_HEVC hevcPicParams; /**< [in]: HEVC encode picture params. Currently unsupported and must not to be used. */
  1302. uint32_t reserved[256]; /**< [in]: Reserved and must be set to 0. */
  1303. } NV_ENC_CODEC_PIC_PARAMS;
  1304. /**
  1305. * \struct _NV_ENC_PIC_PARAMS
  1306. * Encoding parameters that need to be sent on a per frame basis.
  1307. */
  1308. typedef struct _NV_ENC_PIC_PARAMS
  1309. {
  1310. uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_PIC_PARAMS_VER. */
  1311. uint32_t inputWidth; /**< [in]: Specifies the input buffer width */
  1312. uint32_t inputHeight; /**< [in]: Specifies the input buffer height */
  1313. uint32_t inputPitch; /**< [in]: Specifies the input buffer pitch. If pitch value is not known, set this to inputWidth. */
  1314. uint32_t encodePicFlags; /**< [in]: Specifies bit-wise OR`ed encode pic flags. See ::NV_ENC_PIC_FLAGS enum. */
  1315. uint32_t frameIdx; /**< [in]: Specifies the frame index associated with the input frame [optional]. */
  1316. uint64_t inputTimeStamp; /**< [in]: Specifies presentation timestamp associated with the input picture. */
  1317. uint64_t inputDuration; /**< [in]: Specifies duration of the input picture */
  1318. NV_ENC_INPUT_PTR inputBuffer; /**< [in]: Specifies the input buffer pointer. Client must use a pointer obtained from ::NvEncCreateInputBuffer() or ::NvEncMapInputResource() APIs.*/
  1319. NV_ENC_OUTPUT_PTR outputBitstream; /**< [in]: Specifies the pointer to output buffer. Client should use a pointer obtained from ::NvEncCreateBitstreamBuffer() API. */
  1320. void* completionEvent; /**< [in]: Specifies an event to be signalled on completion of encoding of this Frame [only if operating in Asynchronous mode]. Each output buffer should be associated with a distinct event pointer. */
  1321. NV_ENC_BUFFER_FORMAT bufferFmt; /**< [in]: Specifies the input buffer format. */
  1322. NV_ENC_PIC_STRUCT pictureStruct; /**< [in]: Specifies structure of the input picture. */
  1323. 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. */
  1324. NV_ENC_CODEC_PIC_PARAMS codecPicParams; /**< [in]: Specifies the codec specific per-picture encoding parameters. */
  1325. NVENC_EXTERNAL_ME_HINT_COUNTS_PER_BLOCKTYPE meHintCountsPerBlock[2]; /**< [in]: 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.
  1326. The candidate count in NV_ENC_PIC_PARAMS::meHintCountsPerBlock[lx] must never exceed NV_ENC_INITIALIZE_PARAMS::maxMEHintCountsPerBlock[lx] provided during encoder intialization. */
  1327. 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 multiplied by the total number of candidates per macroblock.
  1328. The total number of candidates per MB per direction = 1*meHintCountsPerBlock[Lx].numCandsPerBlk16x16 + 2*meHintCountsPerBlock[Lx].numCandsPerBlk16x8 + 2*meHintCountsPerBlock[Lx].numCandsPerBlk8x8
  1329. + 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) */
  1330. uint32_t reserved1[6]; /**< [in]: Reserved and must be set to 0 */
  1331. void* reserved2[2]; /**< [in]: Reserved and must be set to NULL */
  1332. int8_t *qpDeltaMap; /**< [in]: Specifies the pointer to signed byte array containing QP delta value per MB in raster scan order in the current picture. This QP modifier is applied on top of the QP chosen by rate control. */
  1333. 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 */
  1334. uint32_t reservedBitFields; /**< [in]: Reserved bitfields and must be set to 0 */
  1335. 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.
  1336. If not set, will internally infer distance of 1. Ignored for NV_ENC_INITALIZE_PARAMS::enablePTD = 0 */
  1337. uint32_t reserved3[286]; /**< [in]: Reserved and must be set to 0 */
  1338. void* reserved4[60]; /**< [in]: Reserved and must be set to NULL */
  1339. } NV_ENC_PIC_PARAMS;
  1340. /** Macro for constructing the version field of ::_NV_ENC_PIC_PARAMS */
  1341. #define NV_ENC_PIC_PARAMS_VER (NVENCAPI_STRUCT_VERSION(4) | ( 1<<31 ))
  1342. /**
  1343. * \struct _NV_ENC_MEONLY_PARAMS
  1344. * MEOnly parameters that need to be sent on a per motion estimation basis.
  1345. */
  1346. typedef struct _NV_ENC_MEONLY_PARAMS
  1347. {
  1348. uint32_t version; /**< [in]: Struct version. Must be set to NV_ENC_MEONLY_PARAMS_VER.*/
  1349. uint32_t inputWidth; /**< [in]: Specifies the input buffer width */
  1350. uint32_t inputHeight; /**< [in]: Specifies the input buffer height */
  1351. NV_ENC_INPUT_PTR inputBuffer; /**< [in]: Specifies the input buffer pointer. Client must use a pointer obtained from NvEncCreateInputBuffer() or NvEncMapInputResource() APIs. */
  1352. NV_ENC_INPUT_PTR referenceFrame; /**< [in]: Specifies the reference frame pointer */
  1353. NV_ENC_OUTPUT_PTR mvBuffer; /**< [in]: Specifies the pointer to motion vector data buffer allocated by NvEncCreateMVBuffer. Client must lock mvBuffer using ::NvEncLockBitstream() API to get the motion vector data. */
  1354. NV_ENC_BUFFER_FORMAT bufferFmt; /**< [in]: Specifies the input buffer format. */
  1355. void* completionEvent; /**< [in]: Specifies an event to be signalled on completion of motion estimation
  1356. of this Frame [only if operating in Asynchronous mode].
  1357. Each output buffer should be associated with a distinct event pointer. */
  1358. uint32_t reserved1[252]; /**< [in]: Reserved and must be set to 0 */
  1359. void* reserved2[60]; /**< [in]: Reserved and must be set to NULL */
  1360. } NV_ENC_MEONLY_PARAMS;
  1361. /** NV_ENC_MEONLY_PARAMS struct version*/
  1362. #define NV_ENC_MEONLY_PARAMS_VER NVENCAPI_STRUCT_VERSION(2)
  1363. /**
  1364. * \struct _NV_ENC_LOCK_BITSTREAM
  1365. * Bitstream buffer lock parameters.
  1366. */
  1367. typedef struct _NV_ENC_LOCK_BITSTREAM
  1368. {
  1369. uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_LOCK_BITSTREAM_VER. */
  1370. 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. */
  1371. uint32_t ltrFrame :1; /**< [out]: Flag indicating this frame is marked as LTR frame */
  1372. uint32_t reservedBitFields :30; /**< [in]: Reserved bit fields and must be set to 0 */
  1373. void* outputBitstream; /**< [in]: Pointer to the bitstream buffer being locked. */
  1374. uint32_t* sliceOffsets; /**< [in,out]: Array which receives the slice 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. */
  1375. uint32_t frameIdx; /**< [out]: Frame no. for which the bitstream is being retrieved. */
  1376. uint32_t hwEncodeStatus; /**< [out]: The NvEncodeAPI interface status for the locked picture. */
  1377. uint32_t numSlices; /**< [out]: Number of slices in the encoded picture. Will be reported only if NV_ENC_INITIALIZE_PARAMS::reportSliceOffsets set to 1. */
  1378. uint32_t bitstreamSizeInBytes; /**< [out]: Actual number of bytes generated and copied to the memory pointed by bitstreamBufferPtr. */
  1379. uint64_t outputTimeStamp; /**< [out]: Presentation timestamp associated with the encoded output. */
  1380. uint64_t outputDuration; /**< [out]: Presentation duration associates with the encoded output. */
  1381. void* bitstreamBufferPtr; /**< [out]: Pointer to the generated output bitstream.
  1382. For MEOnly mode _NV_ENC_LOCK_BITSTREAM::bitstreamBufferPtr should be typecast to
  1383. NV_ENC_H264_MV_DATA/NV_ENC_HEVC_MV_DATA pointer respectively for H264/HEVC */
  1384. NV_ENC_PIC_TYPE pictureType; /**< [out]: Picture type of the encoded picture. */
  1385. NV_ENC_PIC_STRUCT pictureStruct; /**< [out]: Structure of the generated output picture. */
  1386. uint32_t frameAvgQP; /**< [out]: Average QP of the frame. */
  1387. uint32_t frameSatd; /**< [out]: Total SATD cost for whole frame. */
  1388. uint32_t ltrFrameIdx; /**< [out]: Frame index associated with this LTR frame. */
  1389. 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. */
  1390. uint32_t reserved [236]; /**< [in]: Reserved and must be set to 0 */
  1391. void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
  1392. } NV_ENC_LOCK_BITSTREAM;
  1393. /** Macro for constructing the version field of ::_NV_ENC_LOCK_BITSTREAM */
  1394. #define NV_ENC_LOCK_BITSTREAM_VER NVENCAPI_STRUCT_VERSION(1)
  1395. /**
  1396. * \struct _NV_ENC_LOCK_INPUT_BUFFER
  1397. * Uncompressed Input Buffer lock parameters.
  1398. */
  1399. typedef struct _NV_ENC_LOCK_INPUT_BUFFER
  1400. {
  1401. uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_LOCK_INPUT_BUFFER_VER. */
  1402. 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. */
  1403. uint32_t reservedBitFields :31; /**< [in]: Reserved bitfields and must be set to 0 */
  1404. 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. */
  1405. void* bufferDataPtr; /**< [out]: Pointed to the locked input buffer data. Client can only access input buffer using the \p bufferDataPtr. */
  1406. uint32_t pitch; /**< [out]: Pitch of the locked input buffer. */
  1407. uint32_t reserved1[251]; /**< [in]: Reserved and must be set to 0 */
  1408. void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
  1409. } NV_ENC_LOCK_INPUT_BUFFER;
  1410. /** Macro for constructing the version field of ::_NV_ENC_LOCK_INPUT_BUFFER */
  1411. #define NV_ENC_LOCK_INPUT_BUFFER_VER NVENCAPI_STRUCT_VERSION(1)
  1412. /**
  1413. * \struct _NV_ENC_MAP_INPUT_RESOURCE
  1414. * Map an input resource to a Nvidia Encoder Input Buffer
  1415. */
  1416. typedef struct _NV_ENC_MAP_INPUT_RESOURCE
  1417. {
  1418. uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_MAP_INPUT_RESOURCE_VER. */
  1419. uint32_t subResourceIndex; /**< [in]: Deprecated. Do not use. */
  1420. void* inputResource; /**< [in]: Deprecated. Do not use. */
  1421. NV_ENC_REGISTERED_PTR registeredResource; /**< [in]: The Registered resource handle obtained by calling NvEncRegisterInputResource. */
  1422. 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. */
  1423. 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. */
  1424. uint32_t reserved1[251]; /**< [in]: Reserved and must be set to 0. */
  1425. void* reserved2[63]; /**< [in]: Reserved and must be set to NULL */
  1426. } NV_ENC_MAP_INPUT_RESOURCE;
  1427. /** Macro for constructing the version field of ::_NV_ENC_MAP_INPUT_RESOURCE */
  1428. #define NV_ENC_MAP_INPUT_RESOURCE_VER NVENCAPI_STRUCT_VERSION(4)
  1429. /**
  1430. * \struct _NV_ENC_REGISTER_RESOURCE
  1431. * Register a resource for future use with the Nvidia Video Encoder Interface.
  1432. */
  1433. typedef struct _NV_ENC_REGISTER_RESOURCE
  1434. {
  1435. uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_REGISTER_RESOURCE_VER. */
  1436. 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. */
  1437. uint32_t width; /**< [in]: Input buffer Width. */
  1438. uint32_t height; /**< [in]: Input buffer Height. */
  1439. uint32_t pitch; /**< [in]: Input buffer Pitch. */
  1440. uint32_t subResourceIndex; /**< [in]: Subresource Index of the DirectX resource to be registered. Should be set to 0 for other interfaces. */
  1441. void* resourceToRegister; /**< [in]: Handle to the resource that is being registered. */
  1442. NV_ENC_REGISTERED_PTR registeredResource; /**< [out]: Registered resource handle. This should be used in future interactions with the Nvidia Video Encoder Interface. */
  1443. NV_ENC_BUFFER_FORMAT bufferFormat; /**< [in]: Buffer format of resource to be registered. */
  1444. uint32_t reserved1[248]; /**< [in]: Reserved and must be set to 0. */
  1445. void* reserved2[62]; /**< [in]: Reserved and must be set to NULL. */
  1446. } NV_ENC_REGISTER_RESOURCE;
  1447. /** Macro for constructing the version field of ::_NV_ENC_REGISTER_RESOURCE */
  1448. #define NV_ENC_REGISTER_RESOURCE_VER NVENCAPI_STRUCT_VERSION(3)
  1449. /**
  1450. * \struct _NV_ENC_STAT
  1451. * Encode Stats structure.
  1452. */
  1453. typedef struct _NV_ENC_STAT
  1454. {
  1455. uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_STAT_VER. */
  1456. uint32_t reserved; /**< [in]: Reserved and must be set to 0 */
  1457. NV_ENC_OUTPUT_PTR outputBitStream; /**< [out]: Specifies the pointer to output bitstream. */
  1458. uint32_t bitStreamSize; /**< [out]: Size of generated bitstream in bytes. */
  1459. uint32_t picType; /**< [out]: Picture type of encoded picture. See ::NV_ENC_PIC_TYPE. */
  1460. uint32_t lastValidByteOffset; /**< [out]: Offset of last valid bytes of completed bitstream */
  1461. uint32_t sliceOffsets[16]; /**< [out]: Offsets of each slice */
  1462. uint32_t picIdx; /**< [out]: Picture number */
  1463. uint32_t reserved1[233]; /**< [in]: Reserved and must be set to 0 */
  1464. void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
  1465. } NV_ENC_STAT;
  1466. /** Macro for constructing the version field of ::_NV_ENC_STAT */
  1467. #define NV_ENC_STAT_VER NVENCAPI_STRUCT_VERSION(1)
  1468. /**
  1469. * \struct _NV_ENC_SEQUENCE_PARAM_PAYLOAD
  1470. * Sequence and picture paramaters payload.
  1471. */
  1472. typedef struct _NV_ENC_SEQUENCE_PARAM_PAYLOAD
  1473. {
  1474. uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_INITIALIZE_PARAMS_VER. */
  1475. uint32_t inBufferSize; /**< [in]: Specifies the size of the spsppsBuffer provied by the client */
  1476. uint32_t spsId; /**< [in]: Specifies the SPS id to be used in sequence header. Default value is 0. */
  1477. uint32_t ppsId; /**< [in]: Specifies the PPS id to be used in picture header. Default value is 0. */
  1478. 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. */
  1479. uint32_t* outSPSPPSPayloadSize; /**< [out]: Size of the sequence and picture header in bytes written by the NvEncodeAPI interface to the SPSPPSBuffer. */
  1480. uint32_t reserved [250]; /**< [in]: Reserved and must be set to 0 */
  1481. void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
  1482. } NV_ENC_SEQUENCE_PARAM_PAYLOAD;
  1483. /** Macro for constructing the version field of ::_NV_ENC_SEQUENCE_PARAM_PAYLOAD */
  1484. #define NV_ENC_SEQUENCE_PARAM_PAYLOAD_VER NVENCAPI_STRUCT_VERSION(1)
  1485. /**
  1486. * Event registration/unregistration parameters.
  1487. */
  1488. typedef struct _NV_ENC_EVENT_PARAMS
  1489. {
  1490. uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_EVENT_PARAMS_VER. */
  1491. uint32_t reserved; /**< [in]: Reserved and must be set to 0 */
  1492. void* completionEvent; /**< [in]: Handle to event to be registered/unregistered with the NvEncodeAPI interface. */
  1493. uint32_t reserved1[253]; /**< [in]: Reserved and must be set to 0 */
  1494. void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
  1495. } NV_ENC_EVENT_PARAMS;
  1496. /** Macro for constructing the version field of ::_NV_ENC_EVENT_PARAMS */
  1497. #define NV_ENC_EVENT_PARAMS_VER NVENCAPI_STRUCT_VERSION(1)
  1498. /**
  1499. * Encoder Session Creation parameters
  1500. */
  1501. typedef struct _NV_ENC_OPEN_ENCODE_SESSIONEX_PARAMS
  1502. {
  1503. uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS_VER. */
  1504. NV_ENC_DEVICE_TYPE deviceType; /**< [in]: Specified the device Type */
  1505. void* device; /**< [in]: Pointer to client device. */
  1506. void* reserved; /**< [in]: Reserved and must be set to 0. */
  1507. uint32_t apiVersion; /**< [in]: API version. Should be set to NVENCAPI_VERSION. */
  1508. uint32_t reserved1[253]; /**< [in]: Reserved and must be set to 0 */
  1509. void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
  1510. } NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS;
  1511. /** Macro for constructing the version field of ::_NV_ENC_OPEN_ENCODE_SESSIONEX_PARAMS */
  1512. #define NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS_VER NVENCAPI_STRUCT_VERSION(1)
  1513. /** @} */ /* END ENCODER_STRUCTURE */
  1514. /**
  1515. * \addtogroup ENCODE_FUNC NvEncodeAPI Functions
  1516. * @{
  1517. */
  1518. // NvEncOpenEncodeSession
  1519. /**
  1520. * \brief Opens an encoding session.
  1521. *
  1522. * Deprecated.
  1523. *
  1524. * \return
  1525. * ::NV_ENC_ERR_INVALID_CALL\n
  1526. *
  1527. */
  1528. NVENCSTATUS NVENCAPI NvEncOpenEncodeSession (void* device, uint32_t deviceType, void** encoder);
  1529. // NvEncGetEncodeGuidCount
  1530. /**
  1531. * \brief Retrieves the number of supported encode GUIDs.
  1532. *
  1533. * The function returns the number of codec guids supported by the NvEncodeAPI
  1534. * interface.
  1535. *
  1536. * \param [in] encoder
  1537. * Pointer to the NvEncodeAPI interface.
  1538. * \param [out] encodeGUIDCount
  1539. * Number of supported encode GUIDs.
  1540. *
  1541. * \return
  1542. * ::NV_ENC_SUCCESS \n
  1543. * ::NV_ENC_ERR_INVALID_PTR \n
  1544. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  1545. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  1546. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  1547. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  1548. * ::NV_ENC_ERR_INVALID_PARAM \n
  1549. * ::NV_ENC_ERR_GENERIC \n
  1550. *
  1551. */
  1552. NVENCSTATUS NVENCAPI NvEncGetEncodeGUIDCount (void* encoder, uint32_t* encodeGUIDCount);
  1553. // NvEncGetEncodeGUIDs
  1554. /**
  1555. * \brief Retrieves an array of supported encoder codec GUIDs.
  1556. *
  1557. * The function returns an array of codec guids supported by the NvEncodeAPI interface.
  1558. * The client must allocate an array where the NvEncodeAPI interface can
  1559. * fill the supported guids and pass the pointer in \p *GUIDs parameter.
  1560. * The size of the array can be determined by using ::NvEncGetEncodeGUIDCount() API.
  1561. * The Nvidia Encoding interface returns the number of codec guids it has actually
  1562. * filled in the guid array in the \p GUIDCount parameter.
  1563. *
  1564. * \param [in] encoder
  1565. * Pointer to the NvEncodeAPI interface.
  1566. * \param [in] guidArraySize
  1567. * Number of GUIDs to retrieved. Should be set to the number retrieved using
  1568. * ::NvEncGetEncodeGUIDCount.
  1569. * \param [out] GUIDs
  1570. * Array of supported Encode GUIDs.
  1571. * \param [out] GUIDCount
  1572. * Number of supported Encode GUIDs.
  1573. *
  1574. * \return
  1575. * ::NV_ENC_SUCCESS \n
  1576. * ::NV_ENC_ERR_INVALID_PTR \n
  1577. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  1578. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  1579. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  1580. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  1581. * ::NV_ENC_ERR_INVALID_PARAM \n
  1582. * ::NV_ENC_ERR_GENERIC \n
  1583. *
  1584. */
  1585. NVENCSTATUS NVENCAPI NvEncGetEncodeGUIDs (void* encoder, GUID* GUIDs, uint32_t guidArraySize, uint32_t* GUIDCount);
  1586. // NvEncGetEncodeProfileGuidCount
  1587. /**
  1588. * \brief Retrieves the number of supported profile GUIDs.
  1589. *
  1590. * The function returns the number of profile GUIDs supported for a given codec.
  1591. * The client must first enumerate the codec guids supported by the NvEncodeAPI
  1592. * interface. After determining the codec guid, it can query the NvEncodeAPI
  1593. * interface to determine the number of profile guids supported for a particular
  1594. * codec guid.
  1595. *
  1596. * \param [in] encoder
  1597. * Pointer to the NvEncodeAPI interface.
  1598. * \param [in] encodeGUID
  1599. * The codec guid for which the profile guids are being enumerated.
  1600. * \param [out] encodeProfileGUIDCount
  1601. * Number of encode profiles supported for the given encodeGUID.
  1602. *
  1603. * \return
  1604. * ::NV_ENC_SUCCESS \n
  1605. * ::NV_ENC_ERR_INVALID_PTR \n
  1606. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  1607. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  1608. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  1609. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  1610. * ::NV_ENC_ERR_INVALID_PARAM \n
  1611. * ::NV_ENC_ERR_GENERIC \n
  1612. *
  1613. */
  1614. NVENCSTATUS NVENCAPI NvEncGetEncodeProfileGUIDCount (void* encoder, GUID encodeGUID, uint32_t* encodeProfileGUIDCount);
  1615. // NvEncGetEncodeProfileGUIDs
  1616. /**
  1617. * \brief Retrieves an array of supported encode profile GUIDs.
  1618. *
  1619. * The function returns an array of supported profile guids for a particular
  1620. * codec guid. The client must allocate an array where the NvEncodeAPI interface
  1621. * can populate the profile guids. The client can determine the array size using
  1622. * ::NvEncGetEncodeProfileGUIDCount() API. The client must also validiate that the
  1623. * NvEncodeAPI interface supports the GUID the client wants to pass as \p encodeGUID
  1624. * parameter.
  1625. *
  1626. * \param [in] encoder
  1627. * Pointer to the NvEncodeAPI interface.
  1628. * \param [in] encodeGUID
  1629. * The encode guid whose profile guids are being enumerated.
  1630. * \param [in] guidArraySize
  1631. * Number of GUIDs to be retrieved. Should be set to the number retrieved using
  1632. * ::NvEncGetEncodeProfileGUIDCount.
  1633. * \param [out] profileGUIDs
  1634. * Array of supported Encode Profile GUIDs
  1635. * \param [out] GUIDCount
  1636. * Number of valid encode profile GUIDs in \p profileGUIDs array.
  1637. *
  1638. * \return
  1639. * ::NV_ENC_SUCCESS \n
  1640. * ::NV_ENC_ERR_INVALID_PTR \n
  1641. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  1642. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  1643. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  1644. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  1645. * ::NV_ENC_ERR_INVALID_PARAM \n
  1646. * ::NV_ENC_ERR_GENERIC \n
  1647. *
  1648. */
  1649. NVENCSTATUS NVENCAPI NvEncGetEncodeProfileGUIDs (void* encoder, GUID encodeGUID, GUID* profileGUIDs, uint32_t guidArraySize, uint32_t* GUIDCount);
  1650. // NvEncGetInputFormatCount
  1651. /**
  1652. * \brief Retrieve the number of supported Input formats.
  1653. *
  1654. * The function returns the number of supported input formats. The client must
  1655. * query the NvEncodeAPI interface to determine the supported input formats
  1656. * before creating the input surfaces.
  1657. *
  1658. * \param [in] encoder
  1659. * Pointer to the NvEncodeAPI interface.
  1660. * \param [in] encodeGUID
  1661. * Encode GUID, corresponding to which the number of supported input formats
  1662. * is to be retrieved.
  1663. * \param [out] inputFmtCount
  1664. * Number of input formats supported for specified Encode GUID.
  1665. *
  1666. * \return
  1667. * ::NV_ENC_SUCCESS \n
  1668. * ::NV_ENC_ERR_INVALID_PTR \n
  1669. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  1670. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  1671. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  1672. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  1673. * ::NV_ENC_ERR_INVALID_PARAM \n
  1674. * ::NV_ENC_ERR_GENERIC \n
  1675. */
  1676. NVENCSTATUS NVENCAPI NvEncGetInputFormatCount (void* encoder, GUID encodeGUID, uint32_t* inputFmtCount);
  1677. // NvEncGetInputFormats
  1678. /**
  1679. * \brief Retrieves an array of supported Input formats
  1680. *
  1681. * Returns an array of supported input formats The client must use the input
  1682. * format to create input surface using ::NvEncCreateInputBuffer() API.
  1683. *
  1684. * \param [in] encoder
  1685. * Pointer to the NvEncodeAPI interface.
  1686. * \param [in] encodeGUID
  1687. * Encode GUID, corresponding to which the number of supported input formats
  1688. * is to be retrieved.
  1689. *\param [in] inputFmtArraySize
  1690. * Size input format count array passed in \p inputFmts.
  1691. *\param [out] inputFmts
  1692. * Array of input formats supported for this Encode GUID.
  1693. *\param [out] inputFmtCount
  1694. * The number of valid input format types returned by the NvEncodeAPI
  1695. * interface in \p inputFmts array.
  1696. *
  1697. * \return
  1698. * ::NV_ENC_SUCCESS \n
  1699. * ::NV_ENC_ERR_INVALID_PTR \n
  1700. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  1701. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  1702. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  1703. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  1704. * ::NV_ENC_ERR_INVALID_PARAM \n
  1705. * ::NV_ENC_ERR_GENERIC \n
  1706. *
  1707. */
  1708. NVENCSTATUS NVENCAPI NvEncGetInputFormats (void* encoder, GUID encodeGUID, NV_ENC_BUFFER_FORMAT* inputFmts, uint32_t inputFmtArraySize, uint32_t* inputFmtCount);
  1709. // NvEncGetEncodeCaps
  1710. /**
  1711. * \brief Retrieves the capability value for a specified encoder attribute.
  1712. *
  1713. * The function returns the capability value for a given encoder attribute. The
  1714. * client must validate the encodeGUID using ::NvEncGetEncodeGUIDs() API before
  1715. * calling this function. The encoder attribute being queried are enumerated in
  1716. * ::NV_ENC_CAPS_PARAM enum.
  1717. *
  1718. * \param [in] encoder
  1719. * Pointer to the NvEncodeAPI interface.
  1720. * \param [in] encodeGUID
  1721. * Encode GUID, corresponding to which the capability attribute is to be retrieved.
  1722. * \param [in] capsParam
  1723. * Used to specify attribute being queried. Refer ::NV_ENC_CAPS_PARAM for more
  1724. * details.
  1725. * \param [out] capsVal
  1726. * The value corresponding to the capability attribute being queried.
  1727. *
  1728. * \return
  1729. * ::NV_ENC_SUCCESS \n
  1730. * ::NV_ENC_ERR_INVALID_PTR \n
  1731. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  1732. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  1733. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  1734. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  1735. * ::NV_ENC_ERR_INVALID_PARAM \n
  1736. * ::NV_ENC_ERR_GENERIC \n
  1737. */
  1738. NVENCSTATUS NVENCAPI NvEncGetEncodeCaps (void* encoder, GUID encodeGUID, NV_ENC_CAPS_PARAM* capsParam, int* capsVal);
  1739. // NvEncGetEncodePresetCount
  1740. /**
  1741. * \brief Retrieves the number of supported preset GUIDs.
  1742. *
  1743. * The function returns the number of preset GUIDs available for a given codec.
  1744. * The client must validate the codec guid using ::NvEncGetEncodeGUIDs() API
  1745. * before calling this function.
  1746. *
  1747. * \param [in] encoder
  1748. * Pointer to the NvEncodeAPI interface.
  1749. * \param [in] encodeGUID
  1750. * Encode GUID, corresponding to which the number of supported presets is to
  1751. * be retrieved.
  1752. * \param [out] encodePresetGUIDCount
  1753. * Receives the number of supported preset GUIDs.
  1754. *
  1755. * \return
  1756. * ::NV_ENC_SUCCESS \n
  1757. * ::NV_ENC_ERR_INVALID_PTR \n
  1758. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  1759. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  1760. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  1761. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  1762. * ::NV_ENC_ERR_INVALID_PARAM \n
  1763. * ::NV_ENC_ERR_GENERIC \n
  1764. *
  1765. */
  1766. NVENCSTATUS NVENCAPI NvEncGetEncodePresetCount (void* encoder, GUID encodeGUID, uint32_t* encodePresetGUIDCount);
  1767. // NvEncGetEncodePresetGUIDs
  1768. /**
  1769. * \brief Receives an array of supported encoder preset GUIDs.
  1770. *
  1771. * The function returns an array of encode preset guids available for a given codec.
  1772. * The client can directly use one of the preset guids based upon the use case
  1773. * or target device. The preset guid chosen can be directly used in
  1774. * NV_ENC_INITIALIZE_PARAMS::presetGUID parameter to ::NvEncEncodePicture() API.
  1775. * Alternately client can also use the preset guid to retrieve the encoding config
  1776. * parameters being used by NvEncodeAPI interface for that given preset, using
  1777. * ::NvEncGetEncodePresetConfig() API. It can then modify preset config parameters
  1778. * as per its use case and send it to NvEncodeAPI interface as part of
  1779. * NV_ENC_INITIALIZE_PARAMS::encodeConfig parameter for NvEncInitializeEncoder()
  1780. * API.
  1781. *
  1782. *
  1783. * \param [in] encoder
  1784. * Pointer to the NvEncodeAPI interface.
  1785. * \param [in] encodeGUID
  1786. * Encode GUID, corresponding to which the list of supported presets is to be
  1787. * retrieved.
  1788. * \param [in] guidArraySize
  1789. * Size of array of preset guids passed in \p preset GUIDs
  1790. * \param [out] presetGUIDs
  1791. * Array of supported Encode preset GUIDs from the NvEncodeAPI interface
  1792. * to client.
  1793. * \param [out] encodePresetGUIDCount
  1794. * Receives the number of preset GUIDs returned by the NvEncodeAPI
  1795. * interface.
  1796. *
  1797. * \return
  1798. * ::NV_ENC_SUCCESS \n
  1799. * ::NV_ENC_ERR_INVALID_PTR \n
  1800. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  1801. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  1802. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  1803. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  1804. * ::NV_ENC_ERR_INVALID_PARAM \n
  1805. * ::NV_ENC_ERR_GENERIC \n
  1806. *
  1807. */
  1808. NVENCSTATUS NVENCAPI NvEncGetEncodePresetGUIDs (void* encoder, GUID encodeGUID, GUID* presetGUIDs, uint32_t guidArraySize, uint32_t* encodePresetGUIDCount);
  1809. // NvEncGetEncodePresetConfig
  1810. /**
  1811. * \brief Returns a preset config structure supported for given preset GUID.
  1812. *
  1813. * The function returns a preset config structure for a given preset guid. Before
  1814. * using this function the client must enumerate the preset guids available for
  1815. * a given codec. The preset config structure can be modified by the client depending
  1816. * upon its use case and can be then used to initialize the encoder using
  1817. * ::NvEncInitializeEncoder() API. The client can use this function only if it
  1818. * wants to modify the NvEncodeAPI preset configuration, otherwise it can
  1819. * directly use the preset guid.
  1820. *
  1821. * \param [in] encoder
  1822. * Pointer to the NvEncodeAPI interface.
  1823. * \param [in] encodeGUID
  1824. * Encode GUID, corresponding to which the list of supported presets is to be
  1825. * retrieved.
  1826. * \param [in] presetGUID
  1827. * Preset GUID, corresponding to which the Encoding configurations is to be
  1828. * retrieved.
  1829. * \param [out] presetConfig
  1830. * The requested Preset Encoder Attribute set. Refer ::_NV_ENC_CONFIG for
  1831. * more details.
  1832. *
  1833. * \return
  1834. * ::NV_ENC_SUCCESS \n
  1835. * ::NV_ENC_ERR_INVALID_PTR \n
  1836. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  1837. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  1838. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  1839. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  1840. * ::NV_ENC_ERR_INVALID_PARAM \n
  1841. * ::NV_ENC_ERR_INVALID_VERSION \n
  1842. * ::NV_ENC_ERR_GENERIC \n
  1843. *
  1844. */
  1845. NVENCSTATUS NVENCAPI NvEncGetEncodePresetConfig (void* encoder, GUID encodeGUID, GUID presetGUID, NV_ENC_PRESET_CONFIG* presetConfig);
  1846. // NvEncInitializeEncoder
  1847. /**
  1848. * \brief Initialize the encoder.
  1849. *
  1850. * This API must be used to initialize the encoder. The initialization parameter
  1851. * is passed using \p *createEncodeParams The client must send the following
  1852. * fields of the _NV_ENC_INITIALIZE_PARAMS structure with a valid value.
  1853. * - NV_ENC_INITIALIZE_PARAMS::encodeGUID
  1854. * - NV_ENC_INITIALIZE_PARAMS::encodeWidth
  1855. * - NV_ENC_INITIALIZE_PARAMS::encodeHeight
  1856. *
  1857. * The client can pass a preset guid directly to the NvEncodeAPI interface using
  1858. * NV_ENC_INITIALIZE_PARAMS::presetGUID field. If the client doesn't pass
  1859. * NV_ENC_INITIALIZE_PARAMS::encodeConfig structure, the codec specific parameters
  1860. * will be selected based on the preset guid. The preset guid must have been
  1861. * validated by the client using ::NvEncGetEncodePresetGUIDs() API.
  1862. * If the client passes a custom ::_NV_ENC_CONFIG structure through
  1863. * NV_ENC_INITIALIZE_PARAMS::encodeConfig , it will override the codec specific parameters
  1864. * based on the preset guid. It is recommended that even if the client passes a custom config,
  1865. * it should also send a preset guid. In this case, the preset guid passed by the client
  1866. * will not override any of the custom config parameters programmed by the client,
  1867. * it is only used as a hint by the NvEncodeAPI interface to determine certain encoder parameters
  1868. * which are not exposed to the client.
  1869. *
  1870. * There are two modes of operation for the encoder namely:
  1871. * - Asynchronous mode
  1872. * - Synchronous mode
  1873. *
  1874. * The client can select asynchronous or synchronous mode by setting the \p
  1875. * enableEncodeAsync field in ::_NV_ENC_INITIALIZE_PARAMS to 1 or 0 respectively.
  1876. *\par Asynchronous mode of operation:
  1877. * The Asynchronous mode can be enabled by setting NV_ENC_INITIALIZE_PARAMS::enableEncodeAsync to 1.
  1878. * The client operating in asynchronous mode must allocate completion event object
  1879. * for each output buffer and pass the completion event object in the
  1880. * ::NvEncEncodePicture() API. The client can create another thread and wait on
  1881. * the event object to be signalled by NvEncodeAPI interface on completion of the
  1882. * encoding process for the output frame. This should unblock the main thread from
  1883. * submitting work to the encoder. When the event is signalled the client can call
  1884. * NvEncodeAPI interfaces to copy the bitstream data using ::NvEncLockBitstream()
  1885. * API. This is the preferred mode of operation.
  1886. *
  1887. * NOTE: Asynchronous mode is not supported on Linux.
  1888. *
  1889. *\par Synchronous mode of operation:
  1890. * The client can select synchronous mode by setting NV_ENC_INITIALIZE_PARAMS::enableEncodeAsync to 0.
  1891. * The client working in synchronous mode can work in a single threaded or multi
  1892. * threaded mode. The client need not allocate any event objects. The client can
  1893. * only lock the bitstream data after NvEncodeAPI interface has returned
  1894. * ::NV_ENC_SUCCESS from encode picture. The NvEncodeAPI interface can return
  1895. * ::NV_ENC_ERR_NEED_MORE_INPUT error code from ::NvEncEncodePicture() API. The
  1896. * client must not lock the output buffer in such case but should send the next
  1897. * frame for encoding. The client must keep on calling ::NvEncEncodePicture() API
  1898. * until it returns ::NV_ENC_SUCCESS. \n
  1899. * The client must always lock the bitstream data in order in which it has submitted.
  1900. * This is true for both asynchronous and synchronous mode.
  1901. *
  1902. *\par Picture type decision:
  1903. * If the client is taking the picture type decision and it must disable the picture
  1904. * type decision module in NvEncodeAPI by setting NV_ENC_INITIALIZE_PARAMS::enablePTD
  1905. * to 0. In this case the client is required to send the picture in encoding
  1906. * order to NvEncodeAPI by doing the re-ordering for B frames. \n
  1907. * If the client doesn't want to take the picture type decision it can enable
  1908. * picture type decision module in the NvEncodeAPI interface by setting
  1909. * NV_ENC_INITIALIZE_PARAMS::enablePTD to 1 and send the input pictures in display
  1910. * order.
  1911. *
  1912. * \param [in] encoder
  1913. * Pointer to the NvEncodeAPI interface.
  1914. * \param [in] createEncodeParams
  1915. * Refer ::_NV_ENC_INITIALIZE_PARAMS for details.
  1916. *
  1917. * \return
  1918. * ::NV_ENC_SUCCESS \n
  1919. * ::NV_ENC_ERR_INVALID_PTR \n
  1920. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  1921. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  1922. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  1923. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  1924. * ::NV_ENC_ERR_INVALID_PARAM \n
  1925. * ::NV_ENC_ERR_INVALID_VERSION \n
  1926. * ::NV_ENC_ERR_GENERIC \n
  1927. *
  1928. */
  1929. NVENCSTATUS NVENCAPI NvEncInitializeEncoder (void* encoder, NV_ENC_INITIALIZE_PARAMS* createEncodeParams);
  1930. // NvEncCreateInputBuffer
  1931. /**
  1932. * \brief Allocates Input buffer.
  1933. *
  1934. * This function is used to allocate an input buffer. The client must enumerate
  1935. * the input buffer format before allocating the input buffer resources. The
  1936. * NV_ENC_INPUT_PTR returned by the NvEncodeAPI interface in the
  1937. * NV_ENC_CREATE_INPUT_BUFFER::inputBuffer field can be directly used in
  1938. * ::NvEncEncodePicture() API. The number of input buffers to be allocated by the
  1939. * client must be at least 4 more than the number of B frames being used for encoding.
  1940. *
  1941. * \param [in] encoder
  1942. * Pointer to the NvEncodeAPI interface.
  1943. * \param [in,out] createInputBufferParams
  1944. * Pointer to the ::NV_ENC_CREATE_INPUT_BUFFER structure.
  1945. *
  1946. * \return
  1947. * ::NV_ENC_SUCCESS \n
  1948. * ::NV_ENC_ERR_INVALID_PTR \n
  1949. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  1950. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  1951. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  1952. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  1953. * ::NV_ENC_ERR_INVALID_PARAM \n
  1954. * ::NV_ENC_ERR_INVALID_VERSION \n
  1955. * ::NV_ENC_ERR_GENERIC \n
  1956. *
  1957. */
  1958. NVENCSTATUS NVENCAPI NvEncCreateInputBuffer (void* encoder, NV_ENC_CREATE_INPUT_BUFFER* createInputBufferParams);
  1959. // NvEncDestroyInputBuffer
  1960. /**
  1961. * \brief Release an input buffers.
  1962. *
  1963. * This function is used to free an input buffer. If the client has allocated
  1964. * any input buffer using ::NvEncCreateInputBuffer() API, it must free those
  1965. * input buffers by calling this function. The client must release the input
  1966. * buffers before destroying the encoder using ::NvEncDestroyEncoder() API.
  1967. *
  1968. * \param [in] encoder
  1969. * Pointer to the NvEncodeAPI interface.
  1970. * \param [in] inputBuffer
  1971. * Pointer to the input buffer to be released.
  1972. *
  1973. * \return
  1974. * ::NV_ENC_SUCCESS \n
  1975. * ::NV_ENC_ERR_INVALID_PTR \n
  1976. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  1977. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  1978. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  1979. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  1980. * ::NV_ENC_ERR_INVALID_PARAM \n
  1981. * ::NV_ENC_ERR_INVALID_VERSION \n
  1982. * ::NV_ENC_ERR_GENERIC \n
  1983. *
  1984. */
  1985. NVENCSTATUS NVENCAPI NvEncDestroyInputBuffer (void* encoder, NV_ENC_INPUT_PTR inputBuffer);
  1986. // NvEncCreateBitstreamBuffer
  1987. /**
  1988. * \brief Allocates an output bitstream buffer
  1989. *
  1990. * This function is used to allocate an output bitstream buffer and returns a
  1991. * NV_ENC_OUTPUT_PTR to bitstream buffer to the client in the
  1992. * NV_ENC_CREATE_BITSTREAM_BUFFER::bitstreamBuffer field.
  1993. * The client can only call this function after the encoder session has been
  1994. * initialized using ::NvEncInitializeEncoder() API. The minimum number of output
  1995. * buffers allocated by the client must be at least 4 more than the number of B
  1996. * B frames being used for encoding. The client can only access the output
  1997. * bitsteam data by locking the \p bitstreamBuffer using the ::NvEncLockBitstream()
  1998. * function.
  1999. *
  2000. * \param [in] encoder
  2001. * Pointer to the NvEncodeAPI interface.
  2002. * \param [in,out] createBitstreamBufferParams
  2003. * Pointer ::NV_ENC_CREATE_BITSTREAM_BUFFER for details.
  2004. *
  2005. * \return
  2006. * ::NV_ENC_SUCCESS \n
  2007. * ::NV_ENC_ERR_INVALID_PTR \n
  2008. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2009. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2010. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2011. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2012. * ::NV_ENC_ERR_INVALID_PARAM \n
  2013. * ::NV_ENC_ERR_INVALID_VERSION \n
  2014. * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  2015. * ::NV_ENC_ERR_GENERIC \n
  2016. *
  2017. */
  2018. NVENCSTATUS NVENCAPI NvEncCreateBitstreamBuffer (void* encoder, NV_ENC_CREATE_BITSTREAM_BUFFER* createBitstreamBufferParams);
  2019. // NvEncDestroyBitstreamBuffer
  2020. /**
  2021. * \brief Release a bitstream buffer.
  2022. *
  2023. * This function is used to release the output bitstream buffer allocated using
  2024. * the ::NvEncCreateBitstreamBuffer() function. The client must release the output
  2025. * bitstreamBuffer using this function before destroying the encoder session.
  2026. *
  2027. * \param [in] encoder
  2028. * Pointer to the NvEncodeAPI interface.
  2029. * \param [in] bitstreamBuffer
  2030. * Pointer to the bitstream buffer being released.
  2031. *
  2032. * \return
  2033. * ::NV_ENC_SUCCESS \n
  2034. * ::NV_ENC_ERR_INVALID_PTR \n
  2035. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2036. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2037. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2038. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2039. * ::NV_ENC_ERR_INVALID_PARAM \n
  2040. * ::NV_ENC_ERR_INVALID_VERSION \n
  2041. * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  2042. * ::NV_ENC_ERR_GENERIC \n
  2043. *
  2044. */
  2045. NVENCSTATUS NVENCAPI NvEncDestroyBitstreamBuffer (void* encoder, NV_ENC_OUTPUT_PTR bitstreamBuffer);
  2046. // NvEncEncodePicture
  2047. /**
  2048. * \brief Submit an input picture for encoding.
  2049. *
  2050. * This function is used to submit an input picture buffer for encoding. The
  2051. * encoding parameters are passed using \p *encodePicParams which is a pointer
  2052. * to the ::_NV_ENC_PIC_PARAMS structure.
  2053. *
  2054. * If the client has set NV_ENC_INITIALIZE_PARAMS::enablePTD to 0, then it must
  2055. * send a valid value for the following fields.
  2056. * - NV_ENC_PIC_PARAMS::pictureType
  2057. * - NV_ENC_PIC_PARAMS_H264::displayPOCSyntax (H264 only)
  2058. * - NV_ENC_PIC_PARAMS_H264::frameNumSyntax(H264 only)
  2059. * - NV_ENC_PIC_PARAMS_H264::refPicFlag(H264 only)
  2060. *
  2061. *
  2062. *\par Asynchronous Encoding
  2063. * If the client has enabled asynchronous mode of encoding by setting
  2064. * NV_ENC_INITIALIZE_PARAMS::enableEncodeAsync to 1 in the ::NvEncInitializeEncoder()
  2065. * API ,then the client must send a valid NV_ENC_PIC_PARAMS::completionEvent.
  2066. * Incase of asynchronous mode of operation, client can queue the ::NvEncEncodePicture()
  2067. * API commands from the main thread and then queue output buffers to be processed
  2068. * to a secondary worker thread. Before the locking the output buffers in the
  2069. * secondary thread , the client must wait on NV_ENC_PIC_PARAMS::completionEvent
  2070. * it has queued in ::NvEncEncodePicture() API call. The client must always process
  2071. * completion event and the output buffer in the same order in which they have been
  2072. * submitted for encoding. The NvEncodeAPI interface is responsible for any
  2073. * re-ordering required for B frames and will always ensure that encoded bitstream
  2074. * data is written in the same order in which output buffer is submitted.
  2075. *\code
  2076. The below example shows how asynchronous encoding in case of 1 B frames
  2077. ------------------------------------------------------------------------
  2078. Suppose the client allocated 4 input buffers(I1,I2..), 4 output buffers(O1,O2..)
  2079. and 4 completion events(E1, E2, ...). The NvEncodeAPI interface will need to
  2080. keep a copy of the input buffers for re-ordering and it allocates following
  2081. internal buffers (NvI1, NvI2...). These internal buffers are managed by NvEncodeAPI
  2082. and the client is not responsible for the allocating or freeing the memory of
  2083. the internal buffers.
  2084. a) The client main thread will queue the following encode frame calls.
  2085. Note the picture type is unknown to the client, the decision is being taken by
  2086. NvEncodeAPI interface. The client should pass ::_NV_ENC_PIC_PARAMS parameter
  2087. consisting of allocated input buffer, output buffer and output events in successive
  2088. ::NvEncEncodePicture() API calls along with other required encode picture params.
  2089. For example:
  2090. 1st EncodePicture parameters - (I1, O1, E1)
  2091. 2nd EncodePicture parameters - (I2, O2, E2)
  2092. 3rd EncodePicture parameters - (I3, O3, E3)
  2093. b) NvEncodeAPI SW will receive the following encode Commands from the client.
  2094. The left side shows input from client in the form (Input buffer, Output Buffer,
  2095. Output Event). The right hand side shows a possible picture type decision take by
  2096. the NvEncodeAPI interface.
  2097. (I1, O1, E1) ---P1 Frame
  2098. (I2, O2, E2) ---B2 Frame
  2099. (I3, O3, E3) ---P3 Frame
  2100. c) NvEncodeAPI interface will make a copy of the input buffers to its internal
  2101. buffersfor re-ordering. These copies are done as part of nvEncEncodePicture
  2102. function call from the client and NvEncodeAPI interface is responsible for
  2103. synchronization of copy operation with the actual encoding operation.
  2104. I1 --> NvI1
  2105. I2 --> NvI2
  2106. I3 --> NvI3
  2107. d) After returning from ::NvEncEncodePicture() call , the client must queue the output
  2108. bitstream processing work to the secondary thread. The output bitstream processing
  2109. for asynchronous mode consist of first waiting on completion event(E1, E2..)
  2110. and then locking the output bitstream buffer(O1, O2..) for reading the encoded
  2111. data. The work queued to the secondary thread by the client is in the following order
  2112. (I1, O1, E1)
  2113. (I2, O2, E2)
  2114. (I3, O3, E3)
  2115. Note they are in the same order in which client calls ::NvEncEncodePicture() API
  2116. in \p step a).
  2117. e) NvEncodeAPI interface will do the re-ordering such that Encoder HW will receive
  2118. the following encode commands:
  2119. (NvI1, O1, E1) ---P1 Frame
  2120. (NvI3, O2, E2) ---P3 Frame
  2121. (NvI2, O3, E3) ---B2 frame
  2122. f) After the encoding operations are completed, the events will be signalled
  2123. by NvEncodeAPI interface in the following order :
  2124. (O1, E1) ---P1 Frame ,output bitstream copied to O1 and event E1 signalled.
  2125. (O2, E2) ---P3 Frame ,output bitstream copied to O2 and event E2 signalled.
  2126. (O3, E3) ---B2 Frame ,output bitstream copied to O3 and event E3 signalled.
  2127. g) The client must lock the bitstream data using ::NvEncLockBitstream() API in
  2128. the order O1,O2,O3 to read the encoded data, after waiting for the events
  2129. to be signalled in the same order i.e E1, E2 and E3.The output processing is
  2130. done in the secondary thread in the following order:
  2131. Waits on E1, copies encoded bitstream from O1
  2132. Waits on E2, copies encoded bitstream from O2
  2133. Waits on E3, copies encoded bitstream from O3
  2134. -Note the client will receive the events signalling and output buffer in the
  2135. same order in which they have submitted for encoding.
  2136. -Note the LockBitstream will have picture type field which will notify the
  2137. output picture type to the clients.
  2138. -Note the input, output buffer and the output completion event are free to be
  2139. reused once NvEncodeAPI interfaced has signalled the event and the client has
  2140. copied the data from the output buffer.
  2141. * \endcode
  2142. *
  2143. *\par Synchronous Encoding
  2144. * The client can enable synchronous mode of encoding by setting
  2145. * NV_ENC_INITIALIZE_PARAMS::enableEncodeAsync to 0 in ::NvEncInitializeEncoder() API.
  2146. * The NvEncodeAPI interface may return ::NV_ENC_ERR_NEED_MORE_INPUT error code for
  2147. * some ::NvEncEncodePicture() API calls when NV_ENC_INITIALIZE_PARAMS::enablePTD
  2148. * is set to 1, but the client must not treat it as a fatal error. The NvEncodeAPI
  2149. * interface might not be able to submit an input picture buffer for encoding
  2150. * immediately due to re-ordering for B frames. The NvEncodeAPI interface cannot
  2151. * submit the input picture which is decided to be encoded as B frame as it waits
  2152. * for backward reference from temporally subsequent frames. This input picture
  2153. * is buffered internally and waits for more input picture to arrive. The client
  2154. * must not call ::NvEncLockBitstream() API on the output buffers whose
  2155. * ::NvEncEncodePicture() API returns ::NV_ENC_ERR_NEED_MORE_INPUT. The client must
  2156. * wait for the NvEncodeAPI interface to return ::NV_ENC_SUCCESS before locking the
  2157. * output bitstreams to read the encoded bitstream data. The following example
  2158. * explains the scenario with synchronous encoding with 2 B frames.
  2159. *\code
  2160. The below example shows how synchronous encoding works in case of 1 B frames
  2161. -----------------------------------------------------------------------------
  2162. Suppose the client allocated 4 input buffers(I1,I2..), 4 output buffers(O1,O2..)
  2163. and 4 completion events(E1, E2, ...). The NvEncodeAPI interface will need to
  2164. keep a copy of the input buffers for re-ordering and it allocates following
  2165. internal buffers (NvI1, NvI2...). These internal buffers are managed by NvEncodeAPI
  2166. and the client is not responsible for the allocating or freeing the memory of
  2167. the internal buffers.
  2168. The client calls ::NvEncEncodePicture() API with input buffer I1 and output buffer O1.
  2169. The NvEncodeAPI decides to encode I1 as P frame and submits it to encoder
  2170. HW and returns ::NV_ENC_SUCCESS.
  2171. The client can now read the encoded data by locking the output O1 by calling
  2172. NvEncLockBitstream API.
  2173. The client calls ::NvEncEncodePicture() API with input buffer I2 and output buffer O2.
  2174. The NvEncodeAPI decides to encode I2 as B frame and buffers I2 by copying it
  2175. to internal buffer and returns ::NV_ENC_ERR_NEED_MORE_INPUT.
  2176. The error is not fatal and it notifies client that it cannot read the encoded
  2177. data by locking the output O2 by calling ::NvEncLockBitstream() API without submitting
  2178. more work to the NvEncodeAPI interface.
  2179. The client calls ::NvEncEncodePicture() with input buffer I3 and output buffer O3.
  2180. The NvEncodeAPI decides to encode I3 as P frame and it first submits I3 for
  2181. encoding which will be used as backward reference frame for I2.
  2182. The NvEncodeAPI then submits I2 for encoding and returns ::NV_ENC_SUCESS. Both
  2183. the submission are part of the same ::NvEncEncodePicture() function call.
  2184. The client can now read the encoded data for both the frames by locking the output
  2185. O2 followed by O3 ,by calling ::NvEncLockBitstream() API.
  2186. The client must always lock the output in the same order in which it has submitted
  2187. to receive the encoded bitstream in correct encoding order.
  2188. * \endcode
  2189. *
  2190. * \param [in] encoder
  2191. * Pointer to the NvEncodeAPI interface.
  2192. * \param [in,out] encodePicParams
  2193. * Pointer to the ::_NV_ENC_PIC_PARAMS structure.
  2194. *
  2195. * \return
  2196. * ::NV_ENC_SUCCESS \n
  2197. * ::NV_ENC_ERR_INVALID_PTR \n
  2198. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2199. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2200. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2201. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2202. * ::NV_ENC_ERR_INVALID_PARAM \n
  2203. * ::NV_ENC_ERR_INVALID_VERSION \n
  2204. * ::NV_ENC_ERR_ENCODER_BUSY \n
  2205. * ::NV_ENC_ERR_NEED_MORE_INPUT \n
  2206. * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  2207. * ::NV_ENC_ERR_GENERIC \n
  2208. *
  2209. */
  2210. NVENCSTATUS NVENCAPI NvEncEncodePicture (void* encoder, NV_ENC_PIC_PARAMS* encodePicParams);
  2211. // NvEncLockBitstream
  2212. /**
  2213. * \brief Lock output bitstream buffer
  2214. *
  2215. * This function is used to lock the bitstream buffer to read the encoded data.
  2216. * The client can only access the encoded data by calling this function.
  2217. * The pointer to client accessible encoded data is returned in the
  2218. * NV_ENC_LOCK_BITSTREAM::bitstreamBufferPtr field. The size of the encoded data
  2219. * in the output buffer is returned in the NV_ENC_LOCK_BITSTREAM::bitstreamSizeInBytes
  2220. * The NvEncodeAPI interface also returns the output picture type and picture structure
  2221. * of the encoded frame in NV_ENC_LOCK_BITSTREAM::pictureType and
  2222. * NV_ENC_LOCK_BITSTREAM::pictureStruct fields respectively. If the client has
  2223. * set NV_ENC_LOCK_BITSTREAM::doNotWait to 1, the function might return
  2224. * ::NV_ENC_ERR_LOCK_BUSY if client is operating in synchronous mode. This is not
  2225. * a fatal failure if NV_ENC_LOCK_BITSTREAM::doNotWait is set to 1. In the above case the client can
  2226. * retry the function after few milliseconds.
  2227. *
  2228. * \param [in] encoder
  2229. * Pointer to the NvEncodeAPI interface.
  2230. * \param [in,out] lockBitstreamBufferParams
  2231. * Pointer to the ::_NV_ENC_LOCK_BITSTREAM structure.
  2232. *
  2233. * \return
  2234. * ::NV_ENC_SUCCESS \n
  2235. * ::NV_ENC_ERR_INVALID_PTR \n
  2236. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2237. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2238. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2239. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2240. * ::NV_ENC_ERR_INVALID_PARAM \n
  2241. * ::NV_ENC_ERR_INVALID_VERSION \n
  2242. * ::NV_ENC_ERR_LOCK_BUSY \n
  2243. * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  2244. * ::NV_ENC_ERR_GENERIC \n
  2245. *
  2246. */
  2247. NVENCSTATUS NVENCAPI NvEncLockBitstream (void* encoder, NV_ENC_LOCK_BITSTREAM* lockBitstreamBufferParams);
  2248. // NvEncUnlockBitstream
  2249. /**
  2250. * \brief Unlock the output bitstream buffer
  2251. *
  2252. * This function is used to unlock the output bitstream buffer after the client
  2253. * has read the encoded data from output buffer. The client must call this function
  2254. * to unlock the output buffer which it has previously locked using ::NvEncLockBitstream()
  2255. * function. Using a locked bitstream buffer in ::NvEncEncodePicture() API will cause
  2256. * the function to fail.
  2257. *
  2258. * \param [in] encoder
  2259. * Pointer to the NvEncodeAPI interface.
  2260. * \param [in,out] bitstreamBuffer
  2261. * bitstream buffer pointer being unlocked
  2262. *
  2263. * \return
  2264. * ::NV_ENC_SUCCESS \n
  2265. * ::NV_ENC_ERR_INVALID_PTR \n
  2266. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2267. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2268. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2269. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2270. * ::NV_ENC_ERR_INVALID_PARAM \n
  2271. * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  2272. * ::NV_ENC_ERR_GENERIC \n
  2273. *
  2274. */
  2275. NVENCSTATUS NVENCAPI NvEncUnlockBitstream (void* encoder, NV_ENC_OUTPUT_PTR bitstreamBuffer);
  2276. // NvLockInputBuffer
  2277. /**
  2278. * \brief Locks an input buffer
  2279. *
  2280. * This function is used to lock the input buffer to load the uncompressed YUV
  2281. * pixel data into input buffer memory. The client must pass the NV_ENC_INPUT_PTR
  2282. * it had previously allocated using ::NvEncCreateInputBuffer()in the
  2283. * NV_ENC_LOCK_INPUT_BUFFER::inputBuffer field.
  2284. * The NvEncodeAPI interface returns pointer to client accessible input buffer
  2285. * memory in NV_ENC_LOCK_INPUT_BUFFER::bufferDataPtr field.
  2286. *
  2287. * \param [in] encoder
  2288. * Pointer to the NvEncodeAPI interface.
  2289. * \param [in,out] lockInputBufferParams
  2290. * Pointer to the ::_NV_ENC_LOCK_INPUT_BUFFER structure
  2291. *
  2292. * \return
  2293. * \return
  2294. * ::NV_ENC_SUCCESS \n
  2295. * ::NV_ENC_ERR_INVALID_PTR \n
  2296. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2297. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2298. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2299. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2300. * ::NV_ENC_ERR_INVALID_PARAM \n
  2301. * ::NV_ENC_ERR_INVALID_VERSION \n
  2302. * ::NV_ENC_ERR_LOCK_BUSY \n
  2303. * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  2304. * ::NV_ENC_ERR_GENERIC \n
  2305. *
  2306. */
  2307. NVENCSTATUS NVENCAPI NvEncLockInputBuffer (void* encoder, NV_ENC_LOCK_INPUT_BUFFER* lockInputBufferParams);
  2308. // NvUnlockInputBuffer
  2309. /**
  2310. * \brief Unlocks the input buffer
  2311. *
  2312. * This function is used to unlock the input buffer memory previously locked for
  2313. * uploading YUV pixel data. The input buffer must be unlocked before being used
  2314. * again for encoding, otherwise NvEncodeAPI will fail the ::NvEncEncodePicture()
  2315. *
  2316. * \param [in] encoder
  2317. * Pointer to the NvEncodeAPI interface.
  2318. * \param [in] inputBuffer
  2319. * Pointer to the input buffer that is being unlocked.
  2320. *
  2321. * \return
  2322. * ::NV_ENC_SUCCESS \n
  2323. * ::NV_ENC_ERR_INVALID_PTR \n
  2324. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2325. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2326. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2327. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2328. * ::NV_ENC_ERR_INVALID_VERSION \n
  2329. * ::NV_ENC_ERR_INVALID_PARAM \n
  2330. * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  2331. * ::NV_ENC_ERR_GENERIC \n
  2332. *
  2333. *
  2334. */
  2335. NVENCSTATUS NVENCAPI NvEncUnlockInputBuffer (void* encoder, NV_ENC_INPUT_PTR inputBuffer);
  2336. // NvEncGetEncodeStats
  2337. /**
  2338. * \brief Get encoding statistics.
  2339. *
  2340. * This function is used to retrieve the encoding statistics.
  2341. * This API is not supported when encode device type is CUDA.
  2342. *
  2343. * \param [in] encoder
  2344. * Pointer to the NvEncodeAPI interface.
  2345. * \param [in,out] encodeStats
  2346. * Pointer to the ::_NV_ENC_STAT structure.
  2347. *
  2348. * \return
  2349. * ::NV_ENC_SUCCESS \n
  2350. * ::NV_ENC_ERR_INVALID_PTR \n
  2351. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2352. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2353. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2354. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2355. * ::NV_ENC_ERR_INVALID_PARAM \n
  2356. * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  2357. * ::NV_ENC_ERR_GENERIC \n
  2358. *
  2359. */
  2360. NVENCSTATUS NVENCAPI NvEncGetEncodeStats (void* encoder, NV_ENC_STAT* encodeStats);
  2361. // NvEncGetSequenceParams
  2362. /**
  2363. * \brief Get encoded sequence and picture header.
  2364. *
  2365. * This function can be used to retrieve the sequence and picture header out of
  2366. * band. The client must call this function only after the encoder has been
  2367. * initialized using ::NvEncInitializeEncoder() function. The client must
  2368. * allocate the memory where the NvEncodeAPI interface can copy the bitstream
  2369. * header and pass the pointer to the memory in NV_ENC_SEQUENCE_PARAM_PAYLOAD::spsppsBuffer.
  2370. * The size of buffer is passed in the field NV_ENC_SEQUENCE_PARAM_PAYLOAD::inBufferSize.
  2371. * The NvEncodeAPI interface will copy the bitstream header payload and returns
  2372. * the actual size of the bitstream header in the field
  2373. * NV_ENC_SEQUENCE_PARAM_PAYLOAD::outSPSPPSPayloadSize.
  2374. * The client must call ::NvEncGetSequenceParams() function from the same thread which is
  2375. * being used to call ::NvEncEncodePicture() function.
  2376. *
  2377. * \param [in] encoder
  2378. * Pointer to the NvEncodeAPI interface.
  2379. * \param [in,out] sequenceParamPayload
  2380. * Pointer to the ::_NV_ENC_SEQUENCE_PARAM_PAYLOAD structure.
  2381. *
  2382. * \return
  2383. * ::NV_ENC_SUCCESS \n
  2384. * ::NV_ENC_ERR_INVALID_PTR \n
  2385. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2386. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2387. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2388. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2389. * ::NV_ENC_ERR_INVALID_VERSION \n
  2390. * ::NV_ENC_ERR_INVALID_PARAM \n
  2391. * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  2392. * ::NV_ENC_ERR_GENERIC \n
  2393. *
  2394. */
  2395. NVENCSTATUS NVENCAPI NvEncGetSequenceParams (void* encoder, NV_ENC_SEQUENCE_PARAM_PAYLOAD* sequenceParamPayload);
  2396. // NvEncRegisterAsyncEvent
  2397. /**
  2398. * \brief Register event for notification to encoding completion.
  2399. *
  2400. * This function is used to register the completion event with NvEncodeAPI
  2401. * interface. The event is required when the client has configured the encoder to
  2402. * work in asynchronous mode. In this mode the client needs to send a completion
  2403. * event with every output buffer. The NvEncodeAPI interface will signal the
  2404. * completion of the encoding process using this event. Only after the event is
  2405. * signalled the client can get the encoded data using ::NvEncLockBitstream() function.
  2406. *
  2407. * \param [in] encoder
  2408. * Pointer to the NvEncodeAPI interface.
  2409. * \param [in] eventParams
  2410. * Pointer to the ::_NV_ENC_EVENT_PARAMS structure.
  2411. *
  2412. * \return
  2413. * ::NV_ENC_SUCCESS \n
  2414. * ::NV_ENC_ERR_INVALID_PTR \n
  2415. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2416. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2417. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2418. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2419. * ::NV_ENC_ERR_INVALID_VERSION \n
  2420. * ::NV_ENC_ERR_INVALID_PARAM \n
  2421. * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  2422. * ::NV_ENC_ERR_GENERIC \n
  2423. *
  2424. */
  2425. NVENCSTATUS NVENCAPI NvEncRegisterAsyncEvent (void* encoder, NV_ENC_EVENT_PARAMS* eventParams);
  2426. // NvEncUnregisterAsyncEvent
  2427. /**
  2428. * \brief Unregister completion event.
  2429. *
  2430. * This function is used to unregister completion event which has been previously
  2431. * registered using ::NvEncRegisterAsyncEvent() function. The client must unregister
  2432. * all events before destroying the encoder using ::NvEncDestroyEncoder() function.
  2433. *
  2434. * \param [in] encoder
  2435. * Pointer to the NvEncodeAPI interface.
  2436. * \param [in] eventParams
  2437. * Pointer to the ::_NV_ENC_EVENT_PARAMS structure.
  2438. *
  2439. * \return
  2440. * ::NV_ENC_SUCCESS \n
  2441. * ::NV_ENC_ERR_INVALID_PTR \n
  2442. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2443. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2444. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2445. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2446. * ::NV_ENC_ERR_INVALID_VERSION \n
  2447. * ::NV_ENC_ERR_INVALID_PARAM \n
  2448. * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  2449. * ::NV_ENC_ERR_GENERIC \n
  2450. *
  2451. */
  2452. NVENCSTATUS NVENCAPI NvEncUnregisterAsyncEvent (void* encoder, NV_ENC_EVENT_PARAMS* eventParams);
  2453. // NvEncMapInputResource
  2454. /**
  2455. * \brief Map an externally created input resource pointer for encoding.
  2456. *
  2457. * Maps an externally allocated input resource [using and returns a NV_ENC_INPUT_PTR
  2458. * which can be used for encoding in the ::NvEncEncodePicture() function. The
  2459. * mapped resource is returned in the field NV_ENC_MAP_INPUT_RESOURCE::outputResourcePtr.
  2460. * The NvEncodeAPI interface also returns the buffer format of the mapped resource
  2461. * in the field NV_ENC_MAP_INPUT_RESOURCE::outbufferFmt.
  2462. * This function provides synchronization guarantee that any direct3d or cuda
  2463. * work submitted on the input buffer is completed before the buffer is used for encoding.
  2464. * The client should not access any input buffer while they are mapped by the encoder.
  2465. *
  2466. * \param [in] encoder
  2467. * Pointer to the NvEncodeAPI interface.
  2468. * \param [in,out] mapInputResParams
  2469. * Pointer to the ::_NV_ENC_MAP_INPUT_RESOURCE structure.
  2470. *
  2471. * \return
  2472. * ::NV_ENC_SUCCESS \n
  2473. * ::NV_ENC_ERR_INVALID_PTR \n
  2474. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2475. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2476. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2477. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2478. * ::NV_ENC_ERR_INVALID_VERSION \n
  2479. * ::NV_ENC_ERR_INVALID_PARAM \n
  2480. * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  2481. * ::NV_ENC_ERR_RESOURCE_NOT_REGISTERED \n
  2482. * ::NV_ENC_ERR_MAP_FAILED \n
  2483. * ::NV_ENC_ERR_GENERIC \n
  2484. *
  2485. */
  2486. NVENCSTATUS NVENCAPI NvEncMapInputResource (void* encoder, NV_ENC_MAP_INPUT_RESOURCE* mapInputResParams);
  2487. // NvEncUnmapInputResource
  2488. /**
  2489. * \brief UnMaps a NV_ENC_INPUT_PTR which was mapped for encoding
  2490. *
  2491. *
  2492. * UnMaps an input buffer which was previously mapped using ::NvEncMapInputResource()
  2493. * API. The mapping created using ::NvEncMapInputResource() should be invalidated
  2494. * using this API before the external resource is destroyed by the client. The client
  2495. * must unmap the buffer after ::NvEncLockBitstream() API returns succuessfully for encode
  2496. * work submitted using the mapped input buffer.
  2497. *
  2498. *
  2499. * \param [in] encoder
  2500. * Pointer to the NvEncodeAPI interface.
  2501. * \param [in] mappedInputBuffer
  2502. * Pointer to the NV_ENC_INPUT_PTR
  2503. *
  2504. * \return
  2505. * ::NV_ENC_SUCCESS \n
  2506. * ::NV_ENC_ERR_INVALID_PTR \n
  2507. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2508. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2509. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2510. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2511. * ::NV_ENC_ERR_INVALID_VERSION \n
  2512. * ::NV_ENC_ERR_INVALID_PARAM \n
  2513. * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  2514. * ::NV_ENC_ERR_RESOURCE_NOT_REGISTERED \n
  2515. * ::NV_ENC_ERR_RESOURCE_NOT_MAPPED \n
  2516. * ::NV_ENC_ERR_GENERIC \n
  2517. *
  2518. */
  2519. NVENCSTATUS NVENCAPI NvEncUnmapInputResource (void* encoder, NV_ENC_INPUT_PTR mappedInputBuffer);
  2520. // NvEncDestroyEncoder
  2521. /**
  2522. * \brief Destroy Encoding Session
  2523. *
  2524. * Destroys the encoder session previously created using ::NvEncOpenEncodeSession()
  2525. * function. The client must flush the encoder before freeing any resources. In order
  2526. * to flush the encoder the client must pass a NULL encode picture packet and either
  2527. * wait for the ::NvEncEncodePicture() function to return in synchronous mode or wait
  2528. * for the flush event to be signaled by the encoder in asynchronous mode.
  2529. * The client must free all the input and output resources created using the
  2530. * NvEncodeAPI interface before destroying the encoder. If the client is operating
  2531. * in asynchronous mode, it must also unregister the completion events previously
  2532. * registered.
  2533. *
  2534. * \param [in] encoder
  2535. * Pointer to the NvEncodeAPI interface.
  2536. *
  2537. * \return
  2538. * ::NV_ENC_SUCCESS \n
  2539. * ::NV_ENC_ERR_INVALID_PTR \n
  2540. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2541. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2542. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2543. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2544. * ::NV_ENC_ERR_INVALID_PARAM \n
  2545. * ::NV_ENC_ERR_GENERIC \n
  2546. *
  2547. */
  2548. NVENCSTATUS NVENCAPI NvEncDestroyEncoder (void* encoder);
  2549. // NvEncInvalidateRefFrames
  2550. /**
  2551. * \brief Invalidate reference frames
  2552. *
  2553. * Invalidates reference frame based on the time stamp provided by the client.
  2554. * The encoder marks any reference frames or any frames which have been reconstructed
  2555. * using the corrupt frame as invalid for motion estimation and uses older reference
  2556. * frames for motion estimation. The encoded forces the current frame to be encoded
  2557. * as an intra frame if no reference frames are left after invalidation process.
  2558. * This is useful for low latency application for error resiliency. The client
  2559. * is recommended to set NV_ENC_CONFIG_H264::maxNumRefFrames to a large value so
  2560. * that encoder can keep a backup of older reference frames in the DPB and can use them
  2561. * for motion estimation when the newer reference frames have been invalidated.
  2562. * This API can be called multiple times.
  2563. *
  2564. * \param [in] encoder
  2565. * Pointer to the NvEncodeAPI interface.
  2566. * \param [in] invalidRefFrameTimeStamp
  2567. * Timestamp of the invalid reference frames which needs to be invalidated.
  2568. *
  2569. * \return
  2570. * ::NV_ENC_SUCCESS \n
  2571. * ::NV_ENC_ERR_INVALID_PTR \n
  2572. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2573. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2574. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2575. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2576. * ::NV_ENC_ERR_INVALID_PARAM \n
  2577. * ::NV_ENC_ERR_GENERIC \n
  2578. *
  2579. */
  2580. NVENCSTATUS NVENCAPI NvEncInvalidateRefFrames(void* encoder, uint64_t invalidRefFrameTimeStamp);
  2581. // NvEncOpenEncodeSessionEx
  2582. /**
  2583. * \brief Opens an encoding session.
  2584. *
  2585. * Opens an encoding session and returns a pointer to the encoder interface in
  2586. * the \p **encoder parameter. The client should start encoding process by calling
  2587. * this API first.
  2588. * The client must pass a pointer to IDirect3DDevice9/CUDA interface in the \p *device parameter.
  2589. * If the creation of encoder session fails, the client must call ::NvEncDestroyEncoder API
  2590. * before exiting.
  2591. *
  2592. * \param [in] openSessionExParams
  2593. * Pointer to a ::NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS structure.
  2594. * \param [out] encoder
  2595. * Encode Session pointer to the NvEncodeAPI interface.
  2596. * \return
  2597. * ::NV_ENC_SUCCESS \n
  2598. * ::NV_ENC_ERR_INVALID_PTR \n
  2599. * ::NV_ENC_ERR_NO_ENCODE_DEVICE \n
  2600. * ::NV_ENC_ERR_UNSUPPORTED_DEVICE \n
  2601. * ::NV_ENC_ERR_INVALID_DEVICE \n
  2602. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2603. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2604. * ::NV_ENC_ERR_GENERIC \n
  2605. *
  2606. */
  2607. NVENCSTATUS NVENCAPI NvEncOpenEncodeSessionEx (NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS *openSessionExParams, void** encoder);
  2608. // NvEncRegisterResource
  2609. /**
  2610. * \brief Registers a resource with the Nvidia Video Encoder Interface.
  2611. *
  2612. * Registers a resource with the Nvidia Video Encoder Interface for book keeping.
  2613. * The client is expected to pass the registered resource handle as well, while calling ::NvEncMapInputResource API.
  2614. * This API is not implemented for the DirectX Interface.
  2615. * DirectX based clients need not change their implementation.
  2616. *
  2617. * \param [in] encoder
  2618. * Pointer to the NVEncodeAPI interface.
  2619. *
  2620. * \param [in] registerResParams
  2621. * Pointer to a ::_NV_ENC_REGISTER_RESOURCE structure
  2622. *
  2623. * \return
  2624. * ::NV_ENC_SUCCESS \n
  2625. * ::NV_ENC_ERR_INVALID_PTR \n
  2626. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2627. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2628. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2629. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2630. * ::NV_ENC_ERR_INVALID_VERSION \n
  2631. * ::NV_ENC_ERR_INVALID_PARAM \n
  2632. * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  2633. * ::NV_ENC_ERR_RESOURCE_REGISTER_FAILED \n
  2634. * ::NV_ENC_ERR_GENERIC \n
  2635. * ::NV_ENC_ERR_UNIMPLEMENTED \n
  2636. *
  2637. */
  2638. NVENCSTATUS NVENCAPI NvEncRegisterResource (void* encoder, NV_ENC_REGISTER_RESOURCE* registerResParams);
  2639. // NvEncUnregisterResource
  2640. /**
  2641. * \brief Unregisters a resource previously registered with the Nvidia Video Encoder Interface.
  2642. *
  2643. * Unregisters a resource previously registered with the Nvidia Video Encoder Interface.
  2644. * The client is expected to unregister any resource that it has registered with the
  2645. * Nvidia Video Encoder Interface before destroying the resource.
  2646. * This API is not implemented for the DirectX Interface.
  2647. * DirectX based clients need not change their implementation.
  2648. *
  2649. * \param [in] encoder
  2650. * Pointer to the NVEncodeAPI interface.
  2651. *
  2652. * \param [in] registeredResource
  2653. * The registered resource pointer that was returned in ::NvEncRegisterResource.
  2654. *
  2655. * \return
  2656. * ::NV_ENC_SUCCESS \n
  2657. * ::NV_ENC_ERR_INVALID_PTR \n
  2658. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2659. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2660. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2661. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2662. * ::NV_ENC_ERR_INVALID_VERSION \n
  2663. * ::NV_ENC_ERR_INVALID_PARAM \n
  2664. * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  2665. * ::NV_ENC_ERR_RESOURCE_NOT_REGISTERED \n
  2666. * ::NV_ENC_ERR_GENERIC \n
  2667. * ::NV_ENC_ERR_UNIMPLEMENTED \n
  2668. *
  2669. */
  2670. NVENCSTATUS NVENCAPI NvEncUnregisterResource (void* encoder, NV_ENC_REGISTERED_PTR registeredResource);
  2671. // NvEncReconfigureEncoder
  2672. /**
  2673. * \brief Reconfigure an existing encoding session.
  2674. *
  2675. * Reconfigure an existing encoding session.
  2676. * The client should call this API to change/reconfigure the parameter passed during
  2677. * NvEncInitializeEncoder API call.
  2678. * Currently Reconfiguration of following are not supported.
  2679. * Change in GOP structure.
  2680. * Change in sync-Async mode.
  2681. * Change in MaxWidth & MaxHeight.
  2682. * Change in PTDmode.
  2683. *
  2684. * Resolution change is possible only if maxEncodeWidth & maxEncodeHeight of NV_ENC_INITIALIZE_PARAMS
  2685. * is set while creating encoder session.
  2686. *
  2687. * \param [in] encoder
  2688. * Pointer to the NVEncodeAPI interface.
  2689. *
  2690. * \param [in] reInitEncodeParams
  2691. * Pointer to a ::NV_ENC_RECONFIGURE_PARAMS structure.
  2692. * \return
  2693. * ::NV_ENC_SUCCESS \n
  2694. * ::NV_ENC_ERR_INVALID_PTR \n
  2695. * ::NV_ENC_ERR_NO_ENCODE_DEVICE \n
  2696. * ::NV_ENC_ERR_UNSUPPORTED_DEVICE \n
  2697. * ::NV_ENC_ERR_INVALID_DEVICE \n
  2698. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2699. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2700. * ::NV_ENC_ERR_GENERIC \n
  2701. *
  2702. */
  2703. NVENCSTATUS NVENCAPI NvEncReconfigureEncoder (void *encoder, NV_ENC_RECONFIGURE_PARAMS* reInitEncodeParams);
  2704. // NvEncCreateMVBuffer
  2705. /**
  2706. * \brief Allocates output MV buffer for ME only mode.
  2707. *
  2708. * This function is used to allocate an output MV buffer. The size of the mvBuffer is
  2709. * dependent on the frame height and width of the last ::NvEncCreateInputBuffer() call.
  2710. * The NV_ENC_OUTPUT_PTR returned by the NvEncodeAPI interface in the
  2711. * ::NV_ENC_CREATE_MV_BUFFER::mvBuffer field should be used in
  2712. * ::NvEncRunMotionEstimationOnly() API.
  2713. * Client must lock ::NV_ENC_CREATE_MV_BUFFER::mvBuffer using ::NvEncLockBitstream() API to get the motion vector data.
  2714. *
  2715. * \param [in] encoder
  2716. * Pointer to the NvEncodeAPI interface.
  2717. * \param [in,out] createMVBufferParams
  2718. * Pointer to the ::NV_ENC_CREATE_MV_BUFFER structure.
  2719. *
  2720. * \return
  2721. * ::NV_ENC_SUCCESS \n
  2722. * ::NV_ENC_ERR_INVALID_PTR \n
  2723. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2724. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2725. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2726. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2727. * ::NV_ENC_ERR_INVALID_PARAM \n
  2728. * ::NV_ENC_ERR_INVALID_VERSION \n
  2729. * ::NV_ENC_ERR_GENERIC \n
  2730. */
  2731. NVENCSTATUS NVENCAPI NvEncCreateMVBuffer (void* encoder, NV_ENC_CREATE_MV_BUFFER* createMVBufferParams);
  2732. // NvEncDestroyMVBuffer
  2733. /**
  2734. * \brief Release an output MV buffer for ME only mode.
  2735. *
  2736. * This function is used to release the output MV buffer allocated using
  2737. * the ::NvEncCreateMVBuffer() function. The client must release the output
  2738. * mvBuffer using this function before destroying the encoder session.
  2739. *
  2740. * \param [in] encoder
  2741. * Pointer to the NvEncodeAPI interface.
  2742. * \param [in] mvBuffer
  2743. * Pointer to the mvBuffer being released.
  2744. *
  2745. * \return
  2746. * ::NV_ENC_SUCCESS \n
  2747. * ::NV_ENC_ERR_INVALID_PTR \n
  2748. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2749. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2750. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2751. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2752. * ::NV_ENC_ERR_INVALID_PARAM \n
  2753. * ::NV_ENC_ERR_INVALID_VERSION \n
  2754. * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  2755. * ::NV_ENC_ERR_GENERIC \n
  2756. */
  2757. NVENCSTATUS NVENCAPI NvEncDestroyMVBuffer (void* encoder, NV_ENC_OUTPUT_PTR mvBuffer);
  2758. // NvEncRunMotionEstimationOnly
  2759. /**
  2760. * \brief Submit an input picture and reference frame for motion estimation in ME only mode.
  2761. *
  2762. * This function is used to submit the input frame and reference frame for motion
  2763. * estimation. The ME parameters are passed using *meOnlyParams which is a pointer
  2764. * to ::_NV_ENC_MEONLY_PARAMS structure.
  2765. * Client must lock ::NV_ENC_CREATE_MV_BUFFER::mvBuffer using ::NvEncLockBitstream() API to get the motion vector data.
  2766. * to get motion vector data.
  2767. *
  2768. * \param [in] encoder
  2769. * Pointer to the NvEncodeAPI interface.
  2770. * \param [in] meOnlyParams
  2771. * Pointer to the ::_NV_ENC_MEONLY_PARAMS structure.
  2772. *
  2773. * \return
  2774. * ::NV_ENC_SUCCESS \n
  2775. * ::NV_ENC_ERR_INVALID_PTR \n
  2776. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2777. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2778. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2779. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2780. * ::NV_ENC_ERR_INVALID_PARAM \n
  2781. * ::NV_ENC_ERR_INVALID_VERSION \n
  2782. * ::NV_ENC_ERR_NEED_MORE_INPUT \n
  2783. * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  2784. * ::NV_ENC_ERR_GENERIC \n
  2785. */
  2786. NVENCSTATUS NVENCAPI NvEncRunMotionEstimationOnly (void* encoder, NV_ENC_MEONLY_PARAMS* meOnlyParams);
  2787. // NvEncodeAPIGetMaxSupportedVersion
  2788. /**
  2789. * \brief Get the largest NvEncodeAPI version supported by the driver.
  2790. *
  2791. * This function can be used by clients to determine if the driver supports
  2792. * the NvEncodeAPI header the application was compiled with.
  2793. *
  2794. * \param [out] version
  2795. * Pointer to the requested value. The 4 least significant bits in the returned
  2796. * indicate the minor version and the rest of the bits indicate the major
  2797. * version of the largest supported version.
  2798. *
  2799. * \return
  2800. * ::NV_ENC_SUCCESS \n
  2801. * ::NV_ENC_ERR_INVALID_PTR \n
  2802. */
  2803. NVENCSTATUS NVENCAPI NvEncodeAPIGetMaxSupportedVersion (uint32_t* version);
  2804. /// \cond API PFN
  2805. /*
  2806. * Defines API function pointers
  2807. */
  2808. typedef NVENCSTATUS (NVENCAPI* PNVENCOPENENCODESESSION) (void* device, uint32_t deviceType, void** encoder);
  2809. typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEGUIDCOUNT) (void* encoder, uint32_t* encodeGUIDCount);
  2810. typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEGUIDS) (void* encoder, GUID* GUIDs, uint32_t guidArraySize, uint32_t* GUIDCount);
  2811. typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEPROFILEGUIDCOUNT) (void* encoder, GUID encodeGUID, uint32_t* encodeProfileGUIDCount);
  2812. typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEPROFILEGUIDS) (void* encoder, GUID encodeGUID, GUID* profileGUIDs, uint32_t guidArraySize, uint32_t* GUIDCount);
  2813. typedef NVENCSTATUS (NVENCAPI* PNVENCGETINPUTFORMATCOUNT) (void* encoder, GUID encodeGUID, uint32_t* inputFmtCount);
  2814. typedef NVENCSTATUS (NVENCAPI* PNVENCGETINPUTFORMATS) (void* encoder, GUID encodeGUID, NV_ENC_BUFFER_FORMAT* inputFmts, uint32_t inputFmtArraySize, uint32_t* inputFmtCount);
  2815. typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODECAPS) (void* encoder, GUID encodeGUID, NV_ENC_CAPS_PARAM* capsParam, int* capsVal);
  2816. typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEPRESETCOUNT) (void* encoder, GUID encodeGUID, uint32_t* encodePresetGUIDCount);
  2817. typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEPRESETGUIDS) (void* encoder, GUID encodeGUID, GUID* presetGUIDs, uint32_t guidArraySize, uint32_t* encodePresetGUIDCount);
  2818. typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEPRESETCONFIG) (void* encoder, GUID encodeGUID, GUID presetGUID, NV_ENC_PRESET_CONFIG* presetConfig);
  2819. typedef NVENCSTATUS (NVENCAPI* PNVENCINITIALIZEENCODER) (void* encoder, NV_ENC_INITIALIZE_PARAMS* createEncodeParams);
  2820. typedef NVENCSTATUS (NVENCAPI* PNVENCCREATEINPUTBUFFER) (void* encoder, NV_ENC_CREATE_INPUT_BUFFER* createInputBufferParams);
  2821. typedef NVENCSTATUS (NVENCAPI* PNVENCDESTROYINPUTBUFFER) (void* encoder, NV_ENC_INPUT_PTR inputBuffer);
  2822. typedef NVENCSTATUS (NVENCAPI* PNVENCCREATEBITSTREAMBUFFER) (void* encoder, NV_ENC_CREATE_BITSTREAM_BUFFER* createBitstreamBufferParams);
  2823. typedef NVENCSTATUS (NVENCAPI* PNVENCDESTROYBITSTREAMBUFFER) (void* encoder, NV_ENC_OUTPUT_PTR bitstreamBuffer);
  2824. typedef NVENCSTATUS (NVENCAPI* PNVENCENCODEPICTURE) (void* encoder, NV_ENC_PIC_PARAMS* encodePicParams);
  2825. typedef NVENCSTATUS (NVENCAPI* PNVENCLOCKBITSTREAM) (void* encoder, NV_ENC_LOCK_BITSTREAM* lockBitstreamBufferParams);
  2826. typedef NVENCSTATUS (NVENCAPI* PNVENCUNLOCKBITSTREAM) (void* encoder, NV_ENC_OUTPUT_PTR bitstreamBuffer);
  2827. typedef NVENCSTATUS (NVENCAPI* PNVENCLOCKINPUTBUFFER) (void* encoder, NV_ENC_LOCK_INPUT_BUFFER* lockInputBufferParams);
  2828. typedef NVENCSTATUS (NVENCAPI* PNVENCUNLOCKINPUTBUFFER) (void* encoder, NV_ENC_INPUT_PTR inputBuffer);
  2829. typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODESTATS) (void* encoder, NV_ENC_STAT* encodeStats);
  2830. typedef NVENCSTATUS (NVENCAPI* PNVENCGETSEQUENCEPARAMS) (void* encoder, NV_ENC_SEQUENCE_PARAM_PAYLOAD* sequenceParamPayload);
  2831. typedef NVENCSTATUS (NVENCAPI* PNVENCREGISTERASYNCEVENT) (void* encoder, NV_ENC_EVENT_PARAMS* eventParams);
  2832. typedef NVENCSTATUS (NVENCAPI* PNVENCUNREGISTERASYNCEVENT) (void* encoder, NV_ENC_EVENT_PARAMS* eventParams);
  2833. typedef NVENCSTATUS (NVENCAPI* PNVENCMAPINPUTRESOURCE) (void* encoder, NV_ENC_MAP_INPUT_RESOURCE* mapInputResParams);
  2834. typedef NVENCSTATUS (NVENCAPI* PNVENCUNMAPINPUTRESOURCE) (void* encoder, NV_ENC_INPUT_PTR mappedInputBuffer);
  2835. typedef NVENCSTATUS (NVENCAPI* PNVENCDESTROYENCODER) (void* encoder);
  2836. typedef NVENCSTATUS (NVENCAPI* PNVENCINVALIDATEREFFRAMES) (void* encoder, uint64_t invalidRefFrameTimeStamp);
  2837. typedef NVENCSTATUS (NVENCAPI* PNVENCOPENENCODESESSIONEX) (NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS *openSessionExParams, void** encoder);
  2838. typedef NVENCSTATUS (NVENCAPI* PNVENCREGISTERRESOURCE) (void* encoder, NV_ENC_REGISTER_RESOURCE* registerResParams);
  2839. typedef NVENCSTATUS (NVENCAPI* PNVENCUNREGISTERRESOURCE) (void* encoder, NV_ENC_REGISTERED_PTR registeredRes);
  2840. typedef NVENCSTATUS (NVENCAPI* PNVENCRECONFIGUREENCODER) (void* encoder, NV_ENC_RECONFIGURE_PARAMS* reInitEncodeParams);
  2841. typedef NVENCSTATUS (NVENCAPI* PNVENCCREATEMVBUFFER) (void* encoder, NV_ENC_CREATE_MV_BUFFER* createMVBufferParams);
  2842. typedef NVENCSTATUS (NVENCAPI* PNVENCDESTROYMVBUFFER) (void* encoder, NV_ENC_OUTPUT_PTR mvBuffer);
  2843. typedef NVENCSTATUS (NVENCAPI* PNVENCRUNMOTIONESTIMATIONONLY) (void* encoder, NV_ENC_MEONLY_PARAMS* meOnlyParams);
  2844. /// \endcond
  2845. /** @} */ /* END ENCODE_FUNC */
  2846. /**
  2847. * \ingroup ENCODER_STRUCTURE
  2848. * NV_ENCODE_API_FUNCTION_LIST
  2849. */
  2850. typedef struct _NV_ENCODE_API_FUNCTION_LIST
  2851. {
  2852. uint32_t version; /**< [in]: Client should pass NV_ENCODE_API_FUNCTION_LIST_VER. */
  2853. uint32_t reserved; /**< [in]: Reserved and should be set to 0. */
  2854. PNVENCOPENENCODESESSION nvEncOpenEncodeSession; /**< [out]: Client should access ::NvEncOpenEncodeSession() API through this pointer. */
  2855. PNVENCGETENCODEGUIDCOUNT nvEncGetEncodeGUIDCount; /**< [out]: Client should access ::NvEncGetEncodeGUIDCount() API through this pointer. */
  2856. PNVENCGETENCODEPRESETCOUNT nvEncGetEncodeProfileGUIDCount; /**< [out]: Client should access ::NvEncGetEncodeProfileGUIDCount() API through this pointer.*/
  2857. PNVENCGETENCODEPRESETGUIDS nvEncGetEncodeProfileGUIDs; /**< [out]: Client should access ::NvEncGetEncodeProfileGUIDs() API through this pointer. */
  2858. PNVENCGETENCODEGUIDS nvEncGetEncodeGUIDs; /**< [out]: Client should access ::NvEncGetEncodeGUIDs() API through this pointer. */
  2859. PNVENCGETINPUTFORMATCOUNT nvEncGetInputFormatCount; /**< [out]: Client should access ::NvEncGetInputFormatCount() API through this pointer. */
  2860. PNVENCGETINPUTFORMATS nvEncGetInputFormats; /**< [out]: Client should access ::NvEncGetInputFormats() API through this pointer. */
  2861. PNVENCGETENCODECAPS nvEncGetEncodeCaps; /**< [out]: Client should access ::NvEncGetEncodeCaps() API through this pointer. */
  2862. PNVENCGETENCODEPRESETCOUNT nvEncGetEncodePresetCount; /**< [out]: Client should access ::NvEncGetEncodePresetCount() API through this pointer. */
  2863. PNVENCGETENCODEPRESETGUIDS nvEncGetEncodePresetGUIDs; /**< [out]: Client should access ::NvEncGetEncodePresetGUIDs() API through this pointer. */
  2864. PNVENCGETENCODEPRESETCONFIG nvEncGetEncodePresetConfig; /**< [out]: Client should access ::NvEncGetEncodePresetConfig() API through this pointer. */
  2865. PNVENCINITIALIZEENCODER nvEncInitializeEncoder; /**< [out]: Client should access ::NvEncInitializeEncoder() API through this pointer. */
  2866. PNVENCCREATEINPUTBUFFER nvEncCreateInputBuffer; /**< [out]: Client should access ::NvEncCreateInputBuffer() API through this pointer. */
  2867. PNVENCDESTROYINPUTBUFFER nvEncDestroyInputBuffer; /**< [out]: Client should access ::NvEncDestroyInputBuffer() API through this pointer. */
  2868. PNVENCCREATEBITSTREAMBUFFER nvEncCreateBitstreamBuffer; /**< [out]: Client should access ::NvEncCreateBitstreamBuffer() API through this pointer. */
  2869. PNVENCDESTROYBITSTREAMBUFFER nvEncDestroyBitstreamBuffer; /**< [out]: Client should access ::NvEncDestroyBitstreamBuffer() API through this pointer. */
  2870. PNVENCENCODEPICTURE nvEncEncodePicture; /**< [out]: Client should access ::NvEncEncodePicture() API through this pointer. */
  2871. PNVENCLOCKBITSTREAM nvEncLockBitstream; /**< [out]: Client should access ::NvEncLockBitstream() API through this pointer. */
  2872. PNVENCUNLOCKBITSTREAM nvEncUnlockBitstream; /**< [out]: Client should access ::NvEncUnlockBitstream() API through this pointer. */
  2873. PNVENCLOCKINPUTBUFFER nvEncLockInputBuffer; /**< [out]: Client should access ::NvEncLockInputBuffer() API through this pointer. */
  2874. PNVENCUNLOCKINPUTBUFFER nvEncUnlockInputBuffer; /**< [out]: Client should access ::NvEncUnlockInputBuffer() API through this pointer. */
  2875. PNVENCGETENCODESTATS nvEncGetEncodeStats; /**< [out]: Client should access ::NvEncGetEncodeStats() API through this pointer. */
  2876. PNVENCGETSEQUENCEPARAMS nvEncGetSequenceParams; /**< [out]: Client should access ::NvEncGetSequenceParams() API through this pointer. */
  2877. PNVENCREGISTERASYNCEVENT nvEncRegisterAsyncEvent; /**< [out]: Client should access ::NvEncRegisterAsyncEvent() API through this pointer. */
  2878. PNVENCUNREGISTERASYNCEVENT nvEncUnregisterAsyncEvent; /**< [out]: Client should access ::NvEncUnregisterAsyncEvent() API through this pointer. */
  2879. PNVENCMAPINPUTRESOURCE nvEncMapInputResource; /**< [out]: Client should access ::NvEncMapInputResource() API through this pointer. */
  2880. PNVENCUNMAPINPUTRESOURCE nvEncUnmapInputResource; /**< [out]: Client should access ::NvEncUnmapInputResource() API through this pointer. */
  2881. PNVENCDESTROYENCODER nvEncDestroyEncoder; /**< [out]: Client should access ::NvEncDestroyEncoder() API through this pointer. */
  2882. PNVENCINVALIDATEREFFRAMES nvEncInvalidateRefFrames; /**< [out]: Client should access ::NvEncInvalidateRefFrames() API through this pointer. */
  2883. PNVENCOPENENCODESESSIONEX nvEncOpenEncodeSessionEx; /**< [out]: Client should access ::NvEncOpenEncodeSession() API through this pointer. */
  2884. PNVENCREGISTERRESOURCE nvEncRegisterResource; /**< [out]: Client should access ::NvEncRegisterResource() API through this pointer. */
  2885. PNVENCUNREGISTERRESOURCE nvEncUnregisterResource; /**< [out]: Client should access ::NvEncUnregisterResource() API through this pointer. */
  2886. PNVENCRECONFIGUREENCODER nvEncReconfigureEncoder; /**< [out]: Client should access ::NvEncReconfigureEncoder() API through this pointer. */
  2887. void* reserved1;
  2888. PNVENCCREATEMVBUFFER nvEncCreateMVBuffer; /**< [out]: Client should access ::NvEncCreateMVBuffer API through this pointer. */
  2889. PNVENCDESTROYMVBUFFER nvEncDestroyMVBuffer; /**< [out]: Client should access ::NvEncDestroyMVBuffer API through this pointer. */
  2890. PNVENCRUNMOTIONESTIMATIONONLY nvEncRunMotionEstimationOnly; /**< [out]: Client should access ::NvEncRunMotionEstimationOnly API through this pointer. */
  2891. void* reserved2[281]; /**< [in]: Reserved and must be set to NULL */
  2892. } NV_ENCODE_API_FUNCTION_LIST;
  2893. /** Macro for constructing the version field of ::_NV_ENCODEAPI_FUNCTION_LIST. */
  2894. #define NV_ENCODE_API_FUNCTION_LIST_VER NVENCAPI_STRUCT_VERSION(2)
  2895. // NvEncodeAPICreateInstance
  2896. /**
  2897. * \ingroup ENCODE_FUNC
  2898. * Entry Point to the NvEncodeAPI interface.
  2899. *
  2900. * Creates an instance of the NvEncodeAPI interface, and populates the
  2901. * pFunctionList with function pointers to the API routines implemented by the
  2902. * NvEncodeAPI interface.
  2903. *
  2904. * \param [out] functionList
  2905. *
  2906. * \return
  2907. * ::NV_ENC_SUCCESS
  2908. * ::NV_ENC_ERR_INVALID_PTR
  2909. */
  2910. NVENCSTATUS NVENCAPI NvEncodeAPICreateInstance(NV_ENCODE_API_FUNCTION_LIST *functionList);
  2911. #ifdef __cplusplus
  2912. }
  2913. #endif
  2914. #endif