nvEncodeAPI.h 231 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844
  1. /*
  2. * This copyright notice applies to this header file only:
  3. *
  4. * Copyright (c) 2010-2020 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. * NVIDIA GPUs - beginning with the Kepler generation - contain a hardware-based encoder
  30. * (referred to as NVENC) which provides fully-accelerated hardware-based video encoding.
  31. * NvEncodeAPI provides the interface for NVIDIA video encoder (NVENC).
  32. * \date 2011-2020
  33. * This file contains the interface constants, structure definitions and function prototypes.
  34. */
  35. #ifndef _NV_ENCODEAPI_H_
  36. #define _NV_ENCODEAPI_H_
  37. #include <stdlib.h>
  38. #ifdef _WIN32
  39. #include <windows.h>
  40. #endif
  41. #ifdef _MSC_VER
  42. #ifndef _STDINT
  43. typedef __int32 int32_t;
  44. typedef unsigned __int32 uint32_t;
  45. typedef __int64 int64_t;
  46. typedef unsigned __int64 uint64_t;
  47. typedef signed char int8_t;
  48. typedef unsigned char uint8_t;
  49. typedef short int16_t;
  50. typedef unsigned short uint16_t;
  51. #endif
  52. #else
  53. #include <stdint.h>
  54. #endif
  55. #ifdef __cplusplus
  56. extern "C" {
  57. #endif
  58. /**
  59. * \addtogroup ENCODER_STRUCTURE NvEncodeAPI Data structures
  60. * @{
  61. */
  62. #ifdef _WIN32
  63. #define NVENCAPI __stdcall
  64. typedef RECT NVENC_RECT;
  65. #else
  66. #define NVENCAPI
  67. // =========================================================================================
  68. #if !defined(GUID) && !defined(GUID_DEFINED)
  69. /*!
  70. * \struct GUID
  71. * Abstracts the GUID structure for non-windows platforms.
  72. */
  73. // =========================================================================================
  74. typedef struct
  75. {
  76. uint32_t Data1; /**< [in]: Specifies the first 8 hexadecimal digits of the GUID. */
  77. uint16_t Data2; /**< [in]: Specifies the first group of 4 hexadecimal digits. */
  78. uint16_t Data3; /**< [in]: Specifies the second group of 4 hexadecimal digits. */
  79. uint8_t Data4[8]; /**< [in]: Array of 8 bytes. The first 2 bytes contain the third group of 4 hexadecimal digits.
  80. The remaining 6 bytes contain the final 12 hexadecimal digits. */
  81. } GUID;
  82. #endif // GUID
  83. /**
  84. * \struct _NVENC_RECT
  85. * Defines a Rectangle. Used in ::NV_ENC_PREPROCESS_FRAME.
  86. */
  87. typedef struct _NVENC_RECT
  88. {
  89. uint32_t left; /**< [in]: X coordinate of the upper left corner of rectangular area to be specified. */
  90. uint32_t top; /**< [in]: Y coordinate of the upper left corner of the rectangular area to be specified. */
  91. uint32_t right; /**< [in]: X coordinate of the bottom right corner of the rectangular area to be specified. */
  92. uint32_t bottom; /**< [in]: Y coordinate of the bottom right corner of the rectangular area to be specified. */
  93. } NVENC_RECT;
  94. #endif // _WIN32
  95. /** @} */ /* End of GUID and NVENC_RECT structure grouping*/
  96. typedef void* NV_ENC_INPUT_PTR; /**< NVENCODE API input buffer */
  97. typedef void* NV_ENC_OUTPUT_PTR; /**< NVENCODE API output buffer*/
  98. typedef void* NV_ENC_REGISTERED_PTR; /**< A Resource that has been registered with NVENCODE API*/
  99. typedef void* NV_ENC_CUSTREAM_PTR; /**< Pointer to CUstream*/
  100. #define NVENCAPI_MAJOR_VERSION 11
  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. #ifdef __GNUC__
  110. #define NV_ENC_DEPRECATED __attribute__ ((deprecated("WILL BE REMOVED IN A FUTURE VIDEO CODEC SDK VERSION")))
  111. #elif defined(_MSC_VER)
  112. #define NV_ENC_DEPRECATED __declspec(deprecated("WILL BE REMOVED IN A FUTURE VIDEO CODEC SDK VERSION"))
  113. #endif
  114. // =========================================================================================
  115. // Encode Codec GUIDS supported by the NvEncodeAPI interface.
  116. // =========================================================================================
  117. // {6BC82762-4E63-4ca4-AA85-1E50F321F6BF}
  118. static const GUID NV_ENC_CODEC_H264_GUID =
  119. { 0x6bc82762, 0x4e63, 0x4ca4, { 0xaa, 0x85, 0x1e, 0x50, 0xf3, 0x21, 0xf6, 0xbf } };
  120. // {790CDC88-4522-4d7b-9425-BDA9975F7603}
  121. static const GUID NV_ENC_CODEC_HEVC_GUID =
  122. { 0x790cdc88, 0x4522, 0x4d7b, { 0x94, 0x25, 0xbd, 0xa9, 0x97, 0x5f, 0x76, 0x3 } };
  123. // =========================================================================================
  124. // * Encode Profile GUIDS supported by the NvEncodeAPI interface.
  125. // =========================================================================================
  126. // {BFD6F8E7-233C-4341-8B3E-4818523803F4}
  127. static const GUID NV_ENC_CODEC_PROFILE_AUTOSELECT_GUID =
  128. { 0xbfd6f8e7, 0x233c, 0x4341, { 0x8b, 0x3e, 0x48, 0x18, 0x52, 0x38, 0x3, 0xf4 } };
  129. // {0727BCAA-78C4-4c83-8C2F-EF3DFF267C6A}
  130. static const GUID NV_ENC_H264_PROFILE_BASELINE_GUID =
  131. { 0x727bcaa, 0x78c4, 0x4c83, { 0x8c, 0x2f, 0xef, 0x3d, 0xff, 0x26, 0x7c, 0x6a } };
  132. // {60B5C1D4-67FE-4790-94D5-C4726D7B6E6D}
  133. static const GUID NV_ENC_H264_PROFILE_MAIN_GUID =
  134. { 0x60b5c1d4, 0x67fe, 0x4790, { 0x94, 0xd5, 0xc4, 0x72, 0x6d, 0x7b, 0x6e, 0x6d } };
  135. // {E7CBC309-4F7A-4b89-AF2A-D537C92BE310}
  136. static const GUID NV_ENC_H264_PROFILE_HIGH_GUID =
  137. { 0xe7cbc309, 0x4f7a, 0x4b89, { 0xaf, 0x2a, 0xd5, 0x37, 0xc9, 0x2b, 0xe3, 0x10 } };
  138. // {7AC663CB-A598-4960-B844-339B261A7D52}
  139. static const GUID NV_ENC_H264_PROFILE_HIGH_444_GUID =
  140. { 0x7ac663cb, 0xa598, 0x4960, { 0xb8, 0x44, 0x33, 0x9b, 0x26, 0x1a, 0x7d, 0x52 } };
  141. // {40847BF5-33F7-4601-9084-E8FE3C1DB8B7}
  142. static const GUID NV_ENC_H264_PROFILE_STEREO_GUID =
  143. { 0x40847bf5, 0x33f7, 0x4601, { 0x90, 0x84, 0xe8, 0xfe, 0x3c, 0x1d, 0xb8, 0xb7 } };
  144. // {B405AFAC-F32B-417B-89C4-9ABEED3E5978}
  145. static const GUID NV_ENC_H264_PROFILE_PROGRESSIVE_HIGH_GUID =
  146. { 0xb405afac, 0xf32b, 0x417b, { 0x89, 0xc4, 0x9a, 0xbe, 0xed, 0x3e, 0x59, 0x78 } };
  147. // {AEC1BD87-E85B-48f2-84C3-98BCA6285072}
  148. static const GUID NV_ENC_H264_PROFILE_CONSTRAINED_HIGH_GUID =
  149. { 0xaec1bd87, 0xe85b, 0x48f2, { 0x84, 0xc3, 0x98, 0xbc, 0xa6, 0x28, 0x50, 0x72 } };
  150. // {B514C39A-B55B-40fa-878F-F1253B4DFDEC}
  151. static const GUID NV_ENC_HEVC_PROFILE_MAIN_GUID =
  152. { 0xb514c39a, 0xb55b, 0x40fa, { 0x87, 0x8f, 0xf1, 0x25, 0x3b, 0x4d, 0xfd, 0xec } };
  153. // {fa4d2b6c-3a5b-411a-8018-0a3f5e3c9be5}
  154. static const GUID NV_ENC_HEVC_PROFILE_MAIN10_GUID =
  155. { 0xfa4d2b6c, 0x3a5b, 0x411a, { 0x80, 0x18, 0x0a, 0x3f, 0x5e, 0x3c, 0x9b, 0xe5 } };
  156. // For HEVC Main 444 8 bit and HEVC Main 444 10 bit profiles only
  157. // {51ec32b5-1b4c-453c-9cbd-b616bd621341}
  158. static const GUID NV_ENC_HEVC_PROFILE_FREXT_GUID =
  159. { 0x51ec32b5, 0x1b4c, 0x453c, { 0x9c, 0xbd, 0xb6, 0x16, 0xbd, 0x62, 0x13, 0x41 } };
  160. // =========================================================================================
  161. // * Preset GUIDS supported by the NvEncodeAPI interface.
  162. // =========================================================================================
  163. // {B2DFB705-4EBD-4C49-9B5F-24A777D3E587}
  164. NV_ENC_DEPRECATED static const GUID NV_ENC_PRESET_DEFAULT_GUID =
  165. { 0xb2dfb705, 0x4ebd, 0x4c49, { 0x9b, 0x5f, 0x24, 0xa7, 0x77, 0xd3, 0xe5, 0x87 } };
  166. // {60E4C59F-E846-4484-A56D-CD45BE9FDDF6}
  167. NV_ENC_DEPRECATED static const GUID NV_ENC_PRESET_HP_GUID =
  168. { 0x60e4c59f, 0xe846, 0x4484, { 0xa5, 0x6d, 0xcd, 0x45, 0xbe, 0x9f, 0xdd, 0xf6 } };
  169. // {34DBA71D-A77B-4B8F-9C3E-B6D5DA24C012}
  170. NV_ENC_DEPRECATED static const GUID NV_ENC_PRESET_HQ_GUID =
  171. { 0x34dba71d, 0xa77b, 0x4b8f, { 0x9c, 0x3e, 0xb6, 0xd5, 0xda, 0x24, 0xc0, 0x12 } };
  172. // {82E3E450-BDBB-4e40-989C-82A90DF9EF32}
  173. NV_ENC_DEPRECATED static const GUID NV_ENC_PRESET_BD_GUID =
  174. { 0x82e3e450, 0xbdbb, 0x4e40, { 0x98, 0x9c, 0x82, 0xa9, 0xd, 0xf9, 0xef, 0x32 } };
  175. // {49DF21C5-6DFA-4feb-9787-6ACC9EFFB726}
  176. NV_ENC_DEPRECATED static const GUID NV_ENC_PRESET_LOW_LATENCY_DEFAULT_GUID =
  177. { 0x49df21c5, 0x6dfa, 0x4feb, { 0x97, 0x87, 0x6a, 0xcc, 0x9e, 0xff, 0xb7, 0x26 } };
  178. // {C5F733B9-EA97-4cf9-BEC2-BF78A74FD105}
  179. NV_ENC_DEPRECATED static const GUID NV_ENC_PRESET_LOW_LATENCY_HQ_GUID =
  180. { 0xc5f733b9, 0xea97, 0x4cf9, { 0xbe, 0xc2, 0xbf, 0x78, 0xa7, 0x4f, 0xd1, 0x5 } };
  181. // {67082A44-4BAD-48FA-98EA-93056D150A58}
  182. NV_ENC_DEPRECATED static const GUID NV_ENC_PRESET_LOW_LATENCY_HP_GUID =
  183. { 0x67082a44, 0x4bad, 0x48fa, { 0x98, 0xea, 0x93, 0x5, 0x6d, 0x15, 0xa, 0x58 } };
  184. // {D5BFB716-C604-44e7-9BB8-DEA5510FC3AC}
  185. NV_ENC_DEPRECATED static const GUID NV_ENC_PRESET_LOSSLESS_DEFAULT_GUID =
  186. { 0xd5bfb716, 0xc604, 0x44e7, { 0x9b, 0xb8, 0xde, 0xa5, 0x51, 0xf, 0xc3, 0xac } };
  187. // {149998E7-2364-411d-82EF-179888093409}
  188. NV_ENC_DEPRECATED static const GUID NV_ENC_PRESET_LOSSLESS_HP_GUID =
  189. { 0x149998e7, 0x2364, 0x411d, { 0x82, 0xef, 0x17, 0x98, 0x88, 0x9, 0x34, 0x9 } };
  190. // Performance degrades and quality improves as we move from P1 to P7. Presets P3 to P7 for H264 and Presets P2 to P7 for HEVC have B frames enabled by default
  191. // for HIGH_QUALITY and LOSSLESS tuning info, and will not work with Weighted Prediction enabled. In case Weighted Prediction is required, disable B frames by
  192. // setting frameIntervalP = 1
  193. // {FC0A8D3E-45F8-4CF8-80C7-298871590EBF}
  194. static const GUID NV_ENC_PRESET_P1_GUID =
  195. { 0xfc0a8d3e, 0x45f8, 0x4cf8, { 0x80, 0xc7, 0x29, 0x88, 0x71, 0x59, 0xe, 0xbf } };
  196. // {F581CFB8-88D6-4381-93F0-DF13F9C27DAB}
  197. static const GUID NV_ENC_PRESET_P2_GUID =
  198. { 0xf581cfb8, 0x88d6, 0x4381, { 0x93, 0xf0, 0xdf, 0x13, 0xf9, 0xc2, 0x7d, 0xab } };
  199. // {36850110-3A07-441F-94D5-3670631F91F6}
  200. static const GUID NV_ENC_PRESET_P3_GUID =
  201. { 0x36850110, 0x3a07, 0x441f, { 0x94, 0xd5, 0x36, 0x70, 0x63, 0x1f, 0x91, 0xf6 } };
  202. // {90A7B826-DF06-4862-B9D2-CD6D73A08681}
  203. static const GUID NV_ENC_PRESET_P4_GUID =
  204. { 0x90a7b826, 0xdf06, 0x4862, { 0xb9, 0xd2, 0xcd, 0x6d, 0x73, 0xa0, 0x86, 0x81 } };
  205. // {21C6E6B4-297A-4CBA-998F-B6CBDE72ADE3}
  206. static const GUID NV_ENC_PRESET_P5_GUID =
  207. { 0x21c6e6b4, 0x297a, 0x4cba, { 0x99, 0x8f, 0xb6, 0xcb, 0xde, 0x72, 0xad, 0xe3 } };
  208. // {8E75C279-6299-4AB6-8302-0B215A335CF5}
  209. static const GUID NV_ENC_PRESET_P6_GUID =
  210. { 0x8e75c279, 0x6299, 0x4ab6, { 0x83, 0x2, 0xb, 0x21, 0x5a, 0x33, 0x5c, 0xf5 } };
  211. // {84848C12-6F71-4C13-931B-53E283F57974}
  212. static const GUID NV_ENC_PRESET_P7_GUID =
  213. { 0x84848c12, 0x6f71, 0x4c13, { 0x93, 0x1b, 0x53, 0xe2, 0x83, 0xf5, 0x79, 0x74 } };
  214. /**
  215. * \addtogroup ENCODER_STRUCTURE NvEncodeAPI Data structures
  216. * @{
  217. */
  218. /**
  219. * Input frame encode modes
  220. */
  221. typedef enum _NV_ENC_PARAMS_FRAME_FIELD_MODE
  222. {
  223. NV_ENC_PARAMS_FRAME_FIELD_MODE_FRAME = 0x01, /**< Frame mode */
  224. NV_ENC_PARAMS_FRAME_FIELD_MODE_FIELD = 0x02, /**< Field mode */
  225. NV_ENC_PARAMS_FRAME_FIELD_MODE_MBAFF = 0x03 /**< MB adaptive frame/field */
  226. } NV_ENC_PARAMS_FRAME_FIELD_MODE;
  227. /**
  228. * Rate Control Modes
  229. */
  230. typedef enum _NV_ENC_PARAMS_RC_MODE
  231. {
  232. NV_ENC_PARAMS_RC_CONSTQP = 0x0, /**< Constant QP mode */
  233. NV_ENC_PARAMS_RC_VBR = 0x1, /**< Variable bitrate mode */
  234. NV_ENC_PARAMS_RC_CBR = 0x2, /**< Constant bitrate mode */
  235. NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ = 0x8, /**< Deprecated, use NV_ENC_PARAMS_RC_CBR + NV_ENC_TWO_PASS_QUARTER_RESOLUTION / NV_ENC_TWO_PASS_FULL_RESOLUTION +
  236. lowDelayKeyFrameScale=1 */
  237. NV_ENC_PARAMS_RC_CBR_HQ = 0x10, /**< Deprecated, use NV_ENC_PARAMS_RC_CBR + NV_ENC_TWO_PASS_QUARTER_RESOLUTION / NV_ENC_TWO_PASS_FULL_RESOLUTION */
  238. NV_ENC_PARAMS_RC_VBR_HQ = 0x20 /**< Deprecated, use NV_ENC_PARAMS_RC_VBR + NV_ENC_TWO_PASS_QUARTER_RESOLUTION / NV_ENC_TWO_PASS_FULL_RESOLUTION */
  239. } NV_ENC_PARAMS_RC_MODE;
  240. /**
  241. * Multi Pass encoding
  242. */
  243. typedef enum _NV_ENC_MULTI_PASS
  244. {
  245. NV_ENC_MULTI_PASS_DISABLED = 0x0, /**< Single Pass */
  246. NV_ENC_TWO_PASS_QUARTER_RESOLUTION = 0x1, /**< Two Pass encoding is enabled where first Pass is quarter resolution */
  247. NV_ENC_TWO_PASS_FULL_RESOLUTION = 0x2, /**< Two Pass encoding is enabled where first Pass is full resolution */
  248. } NV_ENC_MULTI_PASS;
  249. /**
  250. * Emphasis Levels
  251. */
  252. typedef enum _NV_ENC_EMPHASIS_MAP_LEVEL
  253. {
  254. NV_ENC_EMPHASIS_MAP_LEVEL_0 = 0x0, /**< Emphasis Map Level 0, for zero Delta QP value */
  255. NV_ENC_EMPHASIS_MAP_LEVEL_1 = 0x1, /**< Emphasis Map Level 1, for very low Delta QP value */
  256. NV_ENC_EMPHASIS_MAP_LEVEL_2 = 0x2, /**< Emphasis Map Level 2, for low Delta QP value */
  257. NV_ENC_EMPHASIS_MAP_LEVEL_3 = 0x3, /**< Emphasis Map Level 3, for medium Delta QP value */
  258. NV_ENC_EMPHASIS_MAP_LEVEL_4 = 0x4, /**< Emphasis Map Level 4, for high Delta QP value */
  259. NV_ENC_EMPHASIS_MAP_LEVEL_5 = 0x5 /**< Emphasis Map Level 5, for very high Delta QP value */
  260. } NV_ENC_EMPHASIS_MAP_LEVEL;
  261. /**
  262. * QP MAP MODE
  263. */
  264. typedef enum _NV_ENC_QP_MAP_MODE
  265. {
  266. NV_ENC_QP_MAP_DISABLED = 0x0, /**< Value in NV_ENC_PIC_PARAMS::qpDeltaMap have no effect. */
  267. NV_ENC_QP_MAP_EMPHASIS = 0x1, /**< Value in NV_ENC_PIC_PARAMS::qpDeltaMap will be treated as Emphasis level. Currently this is only supported for H264 */
  268. NV_ENC_QP_MAP_DELTA = 0x2, /**< Value in NV_ENC_PIC_PARAMS::qpDeltaMap will be treated as QP delta map. */
  269. NV_ENC_QP_MAP = 0x3, /**< Currently This is not supported. Value in NV_ENC_PIC_PARAMS::qpDeltaMap will be treated as QP value. */
  270. } NV_ENC_QP_MAP_MODE;
  271. #define NV_ENC_PARAMS_RC_VBR_MINQP (NV_ENC_PARAMS_RC_MODE)0x4 /**< Deprecated */
  272. #define NV_ENC_PARAMS_RC_2_PASS_QUALITY NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ /**< Deprecated */
  273. #define NV_ENC_PARAMS_RC_2_PASS_FRAMESIZE_CAP NV_ENC_PARAMS_RC_CBR_HQ /**< Deprecated */
  274. #define NV_ENC_PARAMS_RC_2_PASS_VBR NV_ENC_PARAMS_RC_VBR_HQ /**< Deprecated */
  275. #define NV_ENC_PARAMS_RC_CBR2 NV_ENC_PARAMS_RC_CBR /**< Deprecated */
  276. /**
  277. * Input picture structure
  278. */
  279. typedef enum _NV_ENC_PIC_STRUCT
  280. {
  281. NV_ENC_PIC_STRUCT_FRAME = 0x01, /**< Progressive frame */
  282. NV_ENC_PIC_STRUCT_FIELD_TOP_BOTTOM = 0x02, /**< Field encoding top field first */
  283. NV_ENC_PIC_STRUCT_FIELD_BOTTOM_TOP = 0x03 /**< Field encoding bottom field first */
  284. } NV_ENC_PIC_STRUCT;
  285. /**
  286. * Input picture type
  287. */
  288. typedef enum _NV_ENC_PIC_TYPE
  289. {
  290. NV_ENC_PIC_TYPE_P = 0x0, /**< Forward predicted */
  291. NV_ENC_PIC_TYPE_B = 0x01, /**< Bi-directionally predicted picture */
  292. NV_ENC_PIC_TYPE_I = 0x02, /**< Intra predicted picture */
  293. NV_ENC_PIC_TYPE_IDR = 0x03, /**< IDR picture */
  294. NV_ENC_PIC_TYPE_BI = 0x04, /**< Bi-directionally predicted with only Intra MBs */
  295. NV_ENC_PIC_TYPE_SKIPPED = 0x05, /**< Picture is skipped */
  296. NV_ENC_PIC_TYPE_INTRA_REFRESH = 0x06, /**< First picture in intra refresh cycle */
  297. NV_ENC_PIC_TYPE_NONREF_P = 0x07, /**< Non reference P picture */
  298. NV_ENC_PIC_TYPE_UNKNOWN = 0xFF /**< Picture type unknown */
  299. } NV_ENC_PIC_TYPE;
  300. /**
  301. * Motion vector precisions
  302. */
  303. typedef enum _NV_ENC_MV_PRECISION
  304. {
  305. NV_ENC_MV_PRECISION_DEFAULT = 0x0, /**< Driver selects Quarter-Pel motion vector precision by default */
  306. NV_ENC_MV_PRECISION_FULL_PEL = 0x01, /**< Full-Pel motion vector precision */
  307. NV_ENC_MV_PRECISION_HALF_PEL = 0x02, /**< Half-Pel motion vector precision */
  308. NV_ENC_MV_PRECISION_QUARTER_PEL = 0x03 /**< Quarter-Pel motion vector precision */
  309. } NV_ENC_MV_PRECISION;
  310. /**
  311. * Input buffer formats
  312. */
  313. typedef enum _NV_ENC_BUFFER_FORMAT
  314. {
  315. NV_ENC_BUFFER_FORMAT_UNDEFINED = 0x00000000, /**< Undefined buffer format */
  316. NV_ENC_BUFFER_FORMAT_NV12 = 0x00000001, /**< Semi-Planar YUV [Y plane followed by interleaved UV plane] */
  317. NV_ENC_BUFFER_FORMAT_YV12 = 0x00000010, /**< Planar YUV [Y plane followed by V and U planes] */
  318. NV_ENC_BUFFER_FORMAT_IYUV = 0x00000100, /**< Planar YUV [Y plane followed by U and V planes] */
  319. NV_ENC_BUFFER_FORMAT_YUV444 = 0x00001000, /**< Planar YUV [Y plane followed by U and V planes] */
  320. 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. */
  321. 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. */
  322. NV_ENC_BUFFER_FORMAT_ARGB = 0x01000000, /**< 8 bit Packed A8R8G8B8. This is a word-ordered format
  323. where a pixel is represented by a 32-bit word with B
  324. in the lowest 8 bits, G in the next 8 bits, R in the
  325. 8 bits after that and A in the highest 8 bits. */
  326. NV_ENC_BUFFER_FORMAT_ARGB10 = 0x02000000, /**< 10 bit Packed A2R10G10B10. This is a word-ordered format
  327. where a pixel is represented by a 32-bit word with B
  328. in the lowest 10 bits, G in the next 10 bits, R in the
  329. 10 bits after that and A in the highest 2 bits. */
  330. NV_ENC_BUFFER_FORMAT_AYUV = 0x04000000, /**< 8 bit Packed A8Y8U8V8. This is a word-ordered format
  331. where a pixel is represented by a 32-bit word with V
  332. in the lowest 8 bits, U in the next 8 bits, Y in the
  333. 8 bits after that and A in the highest 8 bits. */
  334. NV_ENC_BUFFER_FORMAT_ABGR = 0x10000000, /**< 8 bit Packed A8B8G8R8. This is a word-ordered format
  335. where a pixel is represented by a 32-bit word with R
  336. in the lowest 8 bits, G in the next 8 bits, B in the
  337. 8 bits after that and A in the highest 8 bits. */
  338. NV_ENC_BUFFER_FORMAT_ABGR10 = 0x20000000, /**< 10 bit Packed A2B10G10R10. This is a word-ordered format
  339. where a pixel is represented by a 32-bit word with R
  340. in the lowest 10 bits, G in the next 10 bits, B in the
  341. 10 bits after that and A in the highest 2 bits. */
  342. NV_ENC_BUFFER_FORMAT_U8 = 0x40000000, /**< Buffer format representing one-dimensional buffer.
  343. This format should be used only when registering the
  344. resource as output buffer, which will be used to write
  345. the encoded bit stream or H.264 ME only mode output. */
  346. } NV_ENC_BUFFER_FORMAT;
  347. #define NV_ENC_BUFFER_FORMAT_NV12_PL NV_ENC_BUFFER_FORMAT_NV12
  348. #define NV_ENC_BUFFER_FORMAT_YV12_PL NV_ENC_BUFFER_FORMAT_YV12
  349. #define NV_ENC_BUFFER_FORMAT_IYUV_PL NV_ENC_BUFFER_FORMAT_IYUV
  350. #define NV_ENC_BUFFER_FORMAT_YUV444_PL NV_ENC_BUFFER_FORMAT_YUV444
  351. /**
  352. * Encoding levels
  353. */
  354. typedef enum _NV_ENC_LEVEL
  355. {
  356. NV_ENC_LEVEL_AUTOSELECT = 0,
  357. NV_ENC_LEVEL_H264_1 = 10,
  358. NV_ENC_LEVEL_H264_1b = 9,
  359. NV_ENC_LEVEL_H264_11 = 11,
  360. NV_ENC_LEVEL_H264_12 = 12,
  361. NV_ENC_LEVEL_H264_13 = 13,
  362. NV_ENC_LEVEL_H264_2 = 20,
  363. NV_ENC_LEVEL_H264_21 = 21,
  364. NV_ENC_LEVEL_H264_22 = 22,
  365. NV_ENC_LEVEL_H264_3 = 30,
  366. NV_ENC_LEVEL_H264_31 = 31,
  367. NV_ENC_LEVEL_H264_32 = 32,
  368. NV_ENC_LEVEL_H264_4 = 40,
  369. NV_ENC_LEVEL_H264_41 = 41,
  370. NV_ENC_LEVEL_H264_42 = 42,
  371. NV_ENC_LEVEL_H264_5 = 50,
  372. NV_ENC_LEVEL_H264_51 = 51,
  373. NV_ENC_LEVEL_H264_52 = 52,
  374. NV_ENC_LEVEL_H264_60 = 60,
  375. NV_ENC_LEVEL_H264_61 = 61,
  376. NV_ENC_LEVEL_H264_62 = 62,
  377. NV_ENC_LEVEL_HEVC_1 = 30,
  378. NV_ENC_LEVEL_HEVC_2 = 60,
  379. NV_ENC_LEVEL_HEVC_21 = 63,
  380. NV_ENC_LEVEL_HEVC_3 = 90,
  381. NV_ENC_LEVEL_HEVC_31 = 93,
  382. NV_ENC_LEVEL_HEVC_4 = 120,
  383. NV_ENC_LEVEL_HEVC_41 = 123,
  384. NV_ENC_LEVEL_HEVC_5 = 150,
  385. NV_ENC_LEVEL_HEVC_51 = 153,
  386. NV_ENC_LEVEL_HEVC_52 = 156,
  387. NV_ENC_LEVEL_HEVC_6 = 180,
  388. NV_ENC_LEVEL_HEVC_61 = 183,
  389. NV_ENC_LEVEL_HEVC_62 = 186,
  390. NV_ENC_TIER_HEVC_MAIN = 0,
  391. NV_ENC_TIER_HEVC_HIGH = 1
  392. } NV_ENC_LEVEL;
  393. /**
  394. * Error Codes
  395. */
  396. typedef enum _NVENCSTATUS
  397. {
  398. /**
  399. * This indicates that API call returned with no errors.
  400. */
  401. NV_ENC_SUCCESS,
  402. /**
  403. * This indicates that no encode capable devices were detected.
  404. */
  405. NV_ENC_ERR_NO_ENCODE_DEVICE,
  406. /**
  407. * This indicates that devices pass by the client is not supported.
  408. */
  409. NV_ENC_ERR_UNSUPPORTED_DEVICE,
  410. /**
  411. * This indicates that the encoder device supplied by the client is not
  412. * valid.
  413. */
  414. NV_ENC_ERR_INVALID_ENCODERDEVICE,
  415. /**
  416. * This indicates that device passed to the API call is invalid.
  417. */
  418. NV_ENC_ERR_INVALID_DEVICE,
  419. /**
  420. * This indicates that device passed to the API call is no longer available and
  421. * needs to be reinitialized. The clients need to destroy the current encoder
  422. * session by freeing the allocated input output buffers and destroying the device
  423. * and create a new encoding session.
  424. */
  425. NV_ENC_ERR_DEVICE_NOT_EXIST,
  426. /**
  427. * This indicates that one or more of the pointers passed to the API call
  428. * is invalid.
  429. */
  430. NV_ENC_ERR_INVALID_PTR,
  431. /**
  432. * This indicates that completion event passed in ::NvEncEncodePicture() call
  433. * is invalid.
  434. */
  435. NV_ENC_ERR_INVALID_EVENT,
  436. /**
  437. * This indicates that one or more of the parameter passed to the API call
  438. * is invalid.
  439. */
  440. NV_ENC_ERR_INVALID_PARAM,
  441. /**
  442. * This indicates that an API call was made in wrong sequence/order.
  443. */
  444. NV_ENC_ERR_INVALID_CALL,
  445. /**
  446. * This indicates that the API call failed because it was unable to allocate
  447. * enough memory to perform the requested operation.
  448. */
  449. NV_ENC_ERR_OUT_OF_MEMORY,
  450. /**
  451. * This indicates that the encoder has not been initialized with
  452. * ::NvEncInitializeEncoder() or that initialization has failed.
  453. * The client cannot allocate input or output buffers or do any encoding
  454. * related operation before successfully initializing the encoder.
  455. */
  456. NV_ENC_ERR_ENCODER_NOT_INITIALIZED,
  457. /**
  458. * This indicates that an unsupported parameter was passed by the client.
  459. */
  460. NV_ENC_ERR_UNSUPPORTED_PARAM,
  461. /**
  462. * This indicates that the ::NvEncLockBitstream() failed to lock the output
  463. * buffer. This happens when the client makes a non blocking lock call to
  464. * access the output bitstream by passing NV_ENC_LOCK_BITSTREAM::doNotWait flag.
  465. * This is not a fatal error and client should retry the same operation after
  466. * few milliseconds.
  467. */
  468. NV_ENC_ERR_LOCK_BUSY,
  469. /**
  470. * This indicates that the size of the user buffer passed by the client is
  471. * insufficient for the requested operation.
  472. */
  473. NV_ENC_ERR_NOT_ENOUGH_BUFFER,
  474. /**
  475. * This indicates that an invalid struct version was used by the client.
  476. */
  477. NV_ENC_ERR_INVALID_VERSION,
  478. /**
  479. * This indicates that ::NvEncMapInputResource() API failed to map the client
  480. * provided input resource.
  481. */
  482. NV_ENC_ERR_MAP_FAILED,
  483. /**
  484. * This indicates encode driver requires more input buffers to produce an output
  485. * bitstream. If this error is returned from ::NvEncEncodePicture() API, this
  486. * is not a fatal error. If the client is encoding with B frames then,
  487. * ::NvEncEncodePicture() API might be buffering the input frame for re-ordering.
  488. *
  489. * A client operating in synchronous mode cannot call ::NvEncLockBitstream()
  490. * API on the output bitstream buffer if ::NvEncEncodePicture() returned the
  491. * ::NV_ENC_ERR_NEED_MORE_INPUT error code.
  492. * The client must continue providing input frames until encode driver returns
  493. * ::NV_ENC_SUCCESS. After receiving ::NV_ENC_SUCCESS status the client can call
  494. * ::NvEncLockBitstream() API on the output buffers in the same order in which
  495. * it has called ::NvEncEncodePicture().
  496. */
  497. NV_ENC_ERR_NEED_MORE_INPUT,
  498. /**
  499. * This indicates that the HW encoder is busy encoding and is unable to encode
  500. * the input. The client should call ::NvEncEncodePicture() again after few
  501. * milliseconds.
  502. */
  503. NV_ENC_ERR_ENCODER_BUSY,
  504. /**
  505. * This indicates that the completion event passed in ::NvEncEncodePicture()
  506. * API has not been registered with encoder driver using ::NvEncRegisterAsyncEvent().
  507. */
  508. NV_ENC_ERR_EVENT_NOT_REGISTERD,
  509. /**
  510. * This indicates that an unknown internal error has occurred.
  511. */
  512. NV_ENC_ERR_GENERIC,
  513. /**
  514. * This indicates that the client is attempting to use a feature
  515. * that is not available for the license type for the current system.
  516. */
  517. NV_ENC_ERR_INCOMPATIBLE_CLIENT_KEY,
  518. /**
  519. * This indicates that the client is attempting to use a feature
  520. * that is not implemented for the current version.
  521. */
  522. NV_ENC_ERR_UNIMPLEMENTED,
  523. /**
  524. * This indicates that the ::NvEncRegisterResource API failed to register the resource.
  525. */
  526. NV_ENC_ERR_RESOURCE_REGISTER_FAILED,
  527. /**
  528. * This indicates that the client is attempting to unregister a resource
  529. * that has not been successfully registered.
  530. */
  531. NV_ENC_ERR_RESOURCE_NOT_REGISTERED,
  532. /**
  533. * This indicates that the client is attempting to unmap a resource
  534. * that has not been successfully mapped.
  535. */
  536. NV_ENC_ERR_RESOURCE_NOT_MAPPED,
  537. } NVENCSTATUS;
  538. /**
  539. * Encode Picture encode flags.
  540. */
  541. typedef enum _NV_ENC_PIC_FLAGS
  542. {
  543. NV_ENC_PIC_FLAG_FORCEINTRA = 0x1, /**< Encode the current picture as an Intra picture */
  544. NV_ENC_PIC_FLAG_FORCEIDR = 0x2, /**< Encode the current picture as an IDR picture.
  545. This flag is only valid when Picture type decision is taken by the Encoder
  546. [_NV_ENC_INITIALIZE_PARAMS::enablePTD == 1]. */
  547. NV_ENC_PIC_FLAG_OUTPUT_SPSPPS = 0x4, /**< Write the sequence and picture header in encoded bitstream of the current picture */
  548. NV_ENC_PIC_FLAG_EOS = 0x8, /**< Indicates end of the input stream */
  549. } NV_ENC_PIC_FLAGS;
  550. /**
  551. * Memory heap to allocate input and output buffers.
  552. */
  553. typedef enum _NV_ENC_MEMORY_HEAP
  554. {
  555. NV_ENC_MEMORY_HEAP_AUTOSELECT = 0, /**< Memory heap to be decided by the encoder driver based on the usage */
  556. NV_ENC_MEMORY_HEAP_VID = 1, /**< Memory heap is in local video memory */
  557. NV_ENC_MEMORY_HEAP_SYSMEM_CACHED = 2, /**< Memory heap is in cached system memory */
  558. NV_ENC_MEMORY_HEAP_SYSMEM_UNCACHED = 3 /**< Memory heap is in uncached system memory */
  559. } NV_ENC_MEMORY_HEAP;
  560. /**
  561. * B-frame used as reference modes
  562. */
  563. typedef enum _NV_ENC_BFRAME_REF_MODE
  564. {
  565. NV_ENC_BFRAME_REF_MODE_DISABLED = 0x0, /**< B frame is not used for reference */
  566. NV_ENC_BFRAME_REF_MODE_EACH = 0x1, /**< Each B-frame will be used for reference. currently not supported for H.264 */
  567. NV_ENC_BFRAME_REF_MODE_MIDDLE = 0x2, /**< Only(Number of B-frame)/2 th B-frame will be used for reference */
  568. } NV_ENC_BFRAME_REF_MODE;
  569. /**
  570. * H.264 entropy coding modes.
  571. */
  572. typedef enum _NV_ENC_H264_ENTROPY_CODING_MODE
  573. {
  574. NV_ENC_H264_ENTROPY_CODING_MODE_AUTOSELECT = 0x0, /**< Entropy coding mode is auto selected by the encoder driver */
  575. NV_ENC_H264_ENTROPY_CODING_MODE_CABAC = 0x1, /**< Entropy coding mode is CABAC */
  576. NV_ENC_H264_ENTROPY_CODING_MODE_CAVLC = 0x2 /**< Entropy coding mode is CAVLC */
  577. } NV_ENC_H264_ENTROPY_CODING_MODE;
  578. /**
  579. * H.264 specific BDirect modes
  580. */
  581. typedef enum _NV_ENC_H264_BDIRECT_MODE
  582. {
  583. NV_ENC_H264_BDIRECT_MODE_AUTOSELECT = 0x0, /**< BDirect mode is auto selected by the encoder driver */
  584. NV_ENC_H264_BDIRECT_MODE_DISABLE = 0x1, /**< Disable BDirect mode */
  585. NV_ENC_H264_BDIRECT_MODE_TEMPORAL = 0x2, /**< Temporal BDirect mode */
  586. NV_ENC_H264_BDIRECT_MODE_SPATIAL = 0x3 /**< Spatial BDirect mode */
  587. } NV_ENC_H264_BDIRECT_MODE;
  588. /**
  589. * H.264 specific FMO usage
  590. */
  591. typedef enum _NV_ENC_H264_FMO_MODE
  592. {
  593. NV_ENC_H264_FMO_AUTOSELECT = 0x0, /**< FMO usage is auto selected by the encoder driver */
  594. NV_ENC_H264_FMO_ENABLE = 0x1, /**< Enable FMO */
  595. NV_ENC_H264_FMO_DISABLE = 0x2, /**< Disable FMO */
  596. } NV_ENC_H264_FMO_MODE;
  597. /**
  598. * H.264 specific Adaptive Transform modes
  599. */
  600. typedef enum _NV_ENC_H264_ADAPTIVE_TRANSFORM_MODE
  601. {
  602. NV_ENC_H264_ADAPTIVE_TRANSFORM_AUTOSELECT = 0x0, /**< Adaptive Transform 8x8 mode is auto selected by the encoder driver*/
  603. NV_ENC_H264_ADAPTIVE_TRANSFORM_DISABLE = 0x1, /**< Adaptive Transform 8x8 mode disabled */
  604. NV_ENC_H264_ADAPTIVE_TRANSFORM_ENABLE = 0x2, /**< Adaptive Transform 8x8 mode should be used */
  605. } NV_ENC_H264_ADAPTIVE_TRANSFORM_MODE;
  606. /**
  607. * Stereo frame packing modes.
  608. */
  609. typedef enum _NV_ENC_STEREO_PACKING_MODE
  610. {
  611. NV_ENC_STEREO_PACKING_MODE_NONE = 0x0, /**< No Stereo packing required */
  612. NV_ENC_STEREO_PACKING_MODE_CHECKERBOARD = 0x1, /**< Checkerboard mode for packing stereo frames */
  613. NV_ENC_STEREO_PACKING_MODE_COLINTERLEAVE = 0x2, /**< Column Interleave mode for packing stereo frames */
  614. NV_ENC_STEREO_PACKING_MODE_ROWINTERLEAVE = 0x3, /**< Row Interleave mode for packing stereo frames */
  615. NV_ENC_STEREO_PACKING_MODE_SIDEBYSIDE = 0x4, /**< Side-by-side mode for packing stereo frames */
  616. NV_ENC_STEREO_PACKING_MODE_TOPBOTTOM = 0x5, /**< Top-Bottom mode for packing stereo frames */
  617. NV_ENC_STEREO_PACKING_MODE_FRAMESEQ = 0x6 /**< Frame Sequential mode for packing stereo frames */
  618. } NV_ENC_STEREO_PACKING_MODE;
  619. /**
  620. * Input Resource type
  621. */
  622. typedef enum _NV_ENC_INPUT_RESOURCE_TYPE
  623. {
  624. NV_ENC_INPUT_RESOURCE_TYPE_DIRECTX = 0x0, /**< input resource type is a directx9 surface*/
  625. NV_ENC_INPUT_RESOURCE_TYPE_CUDADEVICEPTR = 0x1, /**< input resource type is a cuda device pointer surface*/
  626. NV_ENC_INPUT_RESOURCE_TYPE_CUDAARRAY = 0x2, /**< input resource type is a cuda array surface.
  627. This array must be a 2D array and the CUDA_ARRAY3D_SURFACE_LDST
  628. flag must have been specified when creating it. */
  629. NV_ENC_INPUT_RESOURCE_TYPE_OPENGL_TEX = 0x3 /**< input resource type is an OpenGL texture */
  630. } NV_ENC_INPUT_RESOURCE_TYPE;
  631. /**
  632. * Buffer usage
  633. */
  634. typedef enum _NV_ENC_BUFFER_USAGE
  635. {
  636. NV_ENC_INPUT_IMAGE = 0x0, /**< Registered surface will be used for input image */
  637. NV_ENC_OUTPUT_MOTION_VECTOR = 0x1, /**< Registered surface will be used for output of H.264 ME only mode.
  638. This buffer usage type is not supported for HEVC ME only mode. */
  639. NV_ENC_OUTPUT_BITSTREAM = 0x2 /**< Registered surface will be used for output bitstream in encoding */
  640. } NV_ENC_BUFFER_USAGE;
  641. /**
  642. * Encoder Device type
  643. */
  644. typedef enum _NV_ENC_DEVICE_TYPE
  645. {
  646. NV_ENC_DEVICE_TYPE_DIRECTX = 0x0, /**< encode device type is a directx9 device */
  647. NV_ENC_DEVICE_TYPE_CUDA = 0x1, /**< encode device type is a cuda device */
  648. NV_ENC_DEVICE_TYPE_OPENGL = 0x2 /**< encode device type is an OpenGL device.
  649. Use of this device type is supported only on Linux */
  650. } NV_ENC_DEVICE_TYPE;
  651. /**
  652. * Number of reference frames
  653. */
  654. typedef enum _NV_ENC_NUM_REF_FRAMES
  655. {
  656. NV_ENC_NUM_REF_FRAMES_AUTOSELECT = 0x0, /**< Number of reference frames is auto selected by the encoder driver */
  657. NV_ENC_NUM_REF_FRAMES_1 = 0x1, /**< Number of reference frames equal to 1 */
  658. NV_ENC_NUM_REF_FRAMES_2 = 0x2, /**< Number of reference frames equal to 2 */
  659. NV_ENC_NUM_REF_FRAMES_3 = 0x3, /**< Number of reference frames equal to 3 */
  660. NV_ENC_NUM_REF_FRAMES_4 = 0x4, /**< Number of reference frames equal to 4 */
  661. NV_ENC_NUM_REF_FRAMES_5 = 0x5, /**< Number of reference frames equal to 5 */
  662. NV_ENC_NUM_REF_FRAMES_6 = 0x6, /**< Number of reference frames equal to 6 */
  663. NV_ENC_NUM_REF_FRAMES_7 = 0x7 /**< Number of reference frames equal to 7 */
  664. } NV_ENC_NUM_REF_FRAMES;
  665. /**
  666. * Encoder capabilities enumeration.
  667. */
  668. typedef enum _NV_ENC_CAPS
  669. {
  670. /**
  671. * Maximum number of B-Frames supported.
  672. */
  673. NV_ENC_CAPS_NUM_MAX_BFRAMES,
  674. /**
  675. * Rate control modes supported.
  676. * \n The API return value is a bitmask of the values in NV_ENC_PARAMS_RC_MODE.
  677. */
  678. NV_ENC_CAPS_SUPPORTED_RATECONTROL_MODES,
  679. /**
  680. * Indicates HW support for field mode encoding.
  681. * \n 0 : Interlaced mode encoding is not supported.
  682. * \n 1 : Interlaced field mode encoding is supported.
  683. * \n 2 : Interlaced frame encoding and field mode encoding are both supported.
  684. */
  685. NV_ENC_CAPS_SUPPORT_FIELD_ENCODING,
  686. /**
  687. * Indicates HW support for monochrome mode encoding.
  688. * \n 0 : Monochrome mode not supported.
  689. * \n 1 : Monochrome mode supported.
  690. */
  691. NV_ENC_CAPS_SUPPORT_MONOCHROME,
  692. /**
  693. * Indicates HW support for FMO.
  694. * \n 0 : FMO not supported.
  695. * \n 1 : FMO supported.
  696. */
  697. NV_ENC_CAPS_SUPPORT_FMO,
  698. /**
  699. * Indicates HW capability for Quarter pel motion estimation.
  700. * \n 0 : Quarter-Pel Motion Estimation not supported.
  701. * \n 1 : Quarter-Pel Motion Estimation supported.
  702. */
  703. NV_ENC_CAPS_SUPPORT_QPELMV,
  704. /**
  705. * H.264 specific. Indicates HW support for BDirect modes.
  706. * \n 0 : BDirect mode encoding not supported.
  707. * \n 1 : BDirect mode encoding supported.
  708. */
  709. NV_ENC_CAPS_SUPPORT_BDIRECT_MODE,
  710. /**
  711. * H264 specific. Indicates HW support for CABAC entropy coding mode.
  712. * \n 0 : CABAC entropy coding not supported.
  713. * \n 1 : CABAC entropy coding supported.
  714. */
  715. NV_ENC_CAPS_SUPPORT_CABAC,
  716. /**
  717. * Indicates HW support for Adaptive Transform.
  718. * \n 0 : Adaptive Transform not supported.
  719. * \n 1 : Adaptive Transform supported.
  720. */
  721. NV_ENC_CAPS_SUPPORT_ADAPTIVE_TRANSFORM,
  722. /**
  723. * Indicates HW support for Multi View Coding.
  724. * \n 0 : Multi View Coding not supported.
  725. * \n 1 : Multi View Coding supported.
  726. */
  727. NV_ENC_CAPS_SUPPORT_STEREO_MVC,
  728. /**
  729. * Indicates HW support for encoding Temporal layers.
  730. * \n 0 : Encoding Temporal layers not supported.
  731. * \n 1 : Encoding Temporal layers supported.
  732. */
  733. NV_ENC_CAPS_NUM_MAX_TEMPORAL_LAYERS,
  734. /**
  735. * Indicates HW support for Hierarchical P frames.
  736. * \n 0 : Hierarchical P frames not supported.
  737. * \n 1 : Hierarchical P frames supported.
  738. */
  739. NV_ENC_CAPS_SUPPORT_HIERARCHICAL_PFRAMES,
  740. /**
  741. * Indicates HW support for Hierarchical B frames.
  742. * \n 0 : Hierarchical B frames not supported.
  743. * \n 1 : Hierarchical B frames supported.
  744. */
  745. NV_ENC_CAPS_SUPPORT_HIERARCHICAL_BFRAMES,
  746. /**
  747. * Maximum Encoding level supported (See ::NV_ENC_LEVEL for details).
  748. */
  749. NV_ENC_CAPS_LEVEL_MAX,
  750. /**
  751. * Minimum Encoding level supported (See ::NV_ENC_LEVEL for details).
  752. */
  753. NV_ENC_CAPS_LEVEL_MIN,
  754. /**
  755. * Indicates HW support for separate colour plane encoding.
  756. * \n 0 : Separate colour plane encoding not supported.
  757. * \n 1 : Separate colour plane encoding supported.
  758. */
  759. NV_ENC_CAPS_SEPARATE_COLOUR_PLANE,
  760. /**
  761. * Maximum output width supported.
  762. */
  763. NV_ENC_CAPS_WIDTH_MAX,
  764. /**
  765. * Maximum output height supported.
  766. */
  767. NV_ENC_CAPS_HEIGHT_MAX,
  768. /**
  769. * Indicates Temporal Scalability Support.
  770. * \n 0 : Temporal SVC encoding not supported.
  771. * \n 1 : Temporal SVC encoding supported.
  772. */
  773. NV_ENC_CAPS_SUPPORT_TEMPORAL_SVC,
  774. /**
  775. * Indicates Dynamic Encode Resolution Change Support.
  776. * Support added from NvEncodeAPI version 2.0.
  777. * \n 0 : Dynamic Encode Resolution Change not supported.
  778. * \n 1 : Dynamic Encode Resolution Change supported.
  779. */
  780. NV_ENC_CAPS_SUPPORT_DYN_RES_CHANGE,
  781. /**
  782. * Indicates Dynamic Encode Bitrate Change Support.
  783. * Support added from NvEncodeAPI version 2.0.
  784. * \n 0 : Dynamic Encode bitrate change not supported.
  785. * \n 1 : Dynamic Encode bitrate change supported.
  786. */
  787. NV_ENC_CAPS_SUPPORT_DYN_BITRATE_CHANGE,
  788. /**
  789. * Indicates Forcing Constant QP On The Fly Support.
  790. * Support added from NvEncodeAPI version 2.0.
  791. * \n 0 : Forcing constant QP on the fly not supported.
  792. * \n 1 : Forcing constant QP on the fly supported.
  793. */
  794. NV_ENC_CAPS_SUPPORT_DYN_FORCE_CONSTQP,
  795. /**
  796. * Indicates Dynamic rate control mode Change Support.
  797. * \n 0 : Dynamic rate control mode change not supported.
  798. * \n 1 : Dynamic rate control mode change supported.
  799. */
  800. NV_ENC_CAPS_SUPPORT_DYN_RCMODE_CHANGE,
  801. /**
  802. * Indicates Subframe readback support for slice-based encoding. If this feature is supported, it can be enabled by setting enableSubFrameWrite = 1.
  803. * \n 0 : Subframe readback not supported.
  804. * \n 1 : Subframe readback supported.
  805. */
  806. NV_ENC_CAPS_SUPPORT_SUBFRAME_READBACK,
  807. /**
  808. * Indicates Constrained Encoding mode support.
  809. * Support added from NvEncodeAPI version 2.0.
  810. * \n 0 : Constrained encoding mode not supported.
  811. * \n 1 : Constrained encoding mode supported.
  812. * If this mode is supported client can enable this during initialization.
  813. * Client can then force a picture to be coded as constrained picture where
  814. * in-loop filtering is disabled across slice boundaries and prediction vectors for inter
  815. * macroblocks in each slice will be restricted to the slice region.
  816. */
  817. NV_ENC_CAPS_SUPPORT_CONSTRAINED_ENCODING,
  818. /**
  819. * Indicates Intra Refresh Mode Support.
  820. * Support added from NvEncodeAPI version 2.0.
  821. * \n 0 : Intra Refresh Mode not supported.
  822. * \n 1 : Intra Refresh Mode supported.
  823. */
  824. NV_ENC_CAPS_SUPPORT_INTRA_REFRESH,
  825. /**
  826. * Indicates Custom VBV Buffer Size support. It can be used for capping frame size.
  827. * Support added from NvEncodeAPI version 2.0.
  828. * \n 0 : Custom VBV buffer size specification from client, not supported.
  829. * \n 1 : Custom VBV buffer size specification from client, supported.
  830. */
  831. NV_ENC_CAPS_SUPPORT_CUSTOM_VBV_BUF_SIZE,
  832. /**
  833. * Indicates Dynamic Slice Mode Support.
  834. * Support added from NvEncodeAPI version 2.0.
  835. * \n 0 : Dynamic Slice Mode not supported.
  836. * \n 1 : Dynamic Slice Mode supported.
  837. */
  838. NV_ENC_CAPS_SUPPORT_DYNAMIC_SLICE_MODE,
  839. /**
  840. * Indicates Reference Picture Invalidation Support.
  841. * Support added from NvEncodeAPI version 2.0.
  842. * \n 0 : Reference Picture Invalidation not supported.
  843. * \n 1 : Reference Picture Invalidation supported.
  844. */
  845. NV_ENC_CAPS_SUPPORT_REF_PIC_INVALIDATION,
  846. /**
  847. * Indicates support for Pre-Processing.
  848. * The API return value is a bitmask of the values defined in ::NV_ENC_PREPROC_FLAGS
  849. */
  850. NV_ENC_CAPS_PREPROC_SUPPORT,
  851. /**
  852. * Indicates support Async mode.
  853. * \n 0 : Async Encode mode not supported.
  854. * \n 1 : Async Encode mode supported.
  855. */
  856. NV_ENC_CAPS_ASYNC_ENCODE_SUPPORT,
  857. /**
  858. * Maximum MBs per frame supported.
  859. */
  860. NV_ENC_CAPS_MB_NUM_MAX,
  861. /**
  862. * Maximum aggregate throughput in MBs per sec.
  863. */
  864. NV_ENC_CAPS_MB_PER_SEC_MAX,
  865. /**
  866. * Indicates HW support for YUV444 mode encoding.
  867. * \n 0 : YUV444 mode encoding not supported.
  868. * \n 1 : YUV444 mode encoding supported.
  869. */
  870. NV_ENC_CAPS_SUPPORT_YUV444_ENCODE,
  871. /**
  872. * Indicates HW support for lossless encoding.
  873. * \n 0 : lossless encoding not supported.
  874. * \n 1 : lossless encoding supported.
  875. */
  876. NV_ENC_CAPS_SUPPORT_LOSSLESS_ENCODE,
  877. /**
  878. * Indicates HW support for Sample Adaptive Offset.
  879. * \n 0 : SAO not supported.
  880. * \n 1 : SAO encoding supported.
  881. */
  882. NV_ENC_CAPS_SUPPORT_SAO,
  883. /**
  884. * Indicates HW support for Motion Estimation Only Mode.
  885. * \n 0 : MEOnly Mode not supported.
  886. * \n 1 : MEOnly Mode supported for I and P frames.
  887. * \n 2 : MEOnly Mode supported for I, P and B frames.
  888. */
  889. NV_ENC_CAPS_SUPPORT_MEONLY_MODE,
  890. /**
  891. * Indicates HW support for lookahead encoding (enableLookahead=1).
  892. * \n 0 : Lookahead not supported.
  893. * \n 1 : Lookahead supported.
  894. */
  895. NV_ENC_CAPS_SUPPORT_LOOKAHEAD,
  896. /**
  897. * Indicates HW support for temporal AQ encoding (enableTemporalAQ=1).
  898. * \n 0 : Temporal AQ not supported.
  899. * \n 1 : Temporal AQ supported.
  900. */
  901. NV_ENC_CAPS_SUPPORT_TEMPORAL_AQ,
  902. /**
  903. * Indicates HW support for 10 bit encoding.
  904. * \n 0 : 10 bit encoding not supported.
  905. * \n 1 : 10 bit encoding supported.
  906. */
  907. NV_ENC_CAPS_SUPPORT_10BIT_ENCODE,
  908. /**
  909. * Maximum number of Long Term Reference frames supported
  910. */
  911. NV_ENC_CAPS_NUM_MAX_LTR_FRAMES,
  912. /**
  913. * Indicates HW support for Weighted Prediction.
  914. * \n 0 : Weighted Prediction not supported.
  915. * \n 1 : Weighted Prediction supported.
  916. */
  917. NV_ENC_CAPS_SUPPORT_WEIGHTED_PREDICTION,
  918. /**
  919. * On managed (vGPU) platforms (Windows only), this API, in conjunction with other GRID Management APIs, can be used
  920. * to estimate the residual capacity of the hardware encoder on the GPU as a percentage of the total available encoder capacity.
  921. * This API can be called at any time; i.e. during the encode session or before opening the encode session.
  922. * If the available encoder capacity is returned as zero, applications may choose to switch to software encoding
  923. * and continue to call this API (e.g. polling once per second) until capacity becomes available.
  924. *
  925. * On bare metal (non-virtualized GPU) and linux platforms, this API always returns 100.
  926. */
  927. NV_ENC_CAPS_DYNAMIC_QUERY_ENCODER_CAPACITY,
  928. /**
  929. * Indicates B as reference support.
  930. * \n 0 : B as reference is not supported.
  931. * \n 1 : each B-Frame as reference is supported.
  932. * \n 2 : only Middle B-frame as reference is supported.
  933. */
  934. NV_ENC_CAPS_SUPPORT_BFRAME_REF_MODE,
  935. /**
  936. * Indicates HW support for Emphasis Level Map based delta QP computation.
  937. * \n 0 : Emphasis Level Map based delta QP not supported.
  938. * \n 1 : Emphasis Level Map based delta QP is supported.
  939. */
  940. NV_ENC_CAPS_SUPPORT_EMPHASIS_LEVEL_MAP,
  941. /**
  942. * Minimum input width supported.
  943. */
  944. NV_ENC_CAPS_WIDTH_MIN,
  945. /**
  946. * Minimum input height supported.
  947. */
  948. NV_ENC_CAPS_HEIGHT_MIN,
  949. /**
  950. * Indicates HW support for multiple reference frames.
  951. */
  952. NV_ENC_CAPS_SUPPORT_MULTIPLE_REF_FRAMES,
  953. /**
  954. * Indicates HW support for HEVC with alpha encoding.
  955. * \n 0 : HEVC with alpha encoding not supported.
  956. * \n 1 : HEVC with alpha encoding is supported.
  957. */
  958. NV_ENC_CAPS_SUPPORT_ALPHA_LAYER_ENCODING,
  959. /**
  960. * Indicates number of Encoding engines present on GPU.
  961. */
  962. NV_ENC_CAPS_NUM_ENCODER_ENGINES,
  963. /**
  964. * Reserved - Not to be used by clients.
  965. */
  966. NV_ENC_CAPS_EXPOSED_COUNT
  967. } NV_ENC_CAPS;
  968. /**
  969. * HEVC CU SIZE
  970. */
  971. typedef enum _NV_ENC_HEVC_CUSIZE
  972. {
  973. NV_ENC_HEVC_CUSIZE_AUTOSELECT = 0,
  974. NV_ENC_HEVC_CUSIZE_8x8 = 1,
  975. NV_ENC_HEVC_CUSIZE_16x16 = 2,
  976. NV_ENC_HEVC_CUSIZE_32x32 = 3,
  977. NV_ENC_HEVC_CUSIZE_64x64 = 4,
  978. }NV_ENC_HEVC_CUSIZE;
  979. /**
  980. * Input struct for querying Encoding capabilities.
  981. */
  982. typedef struct _NV_ENC_CAPS_PARAM
  983. {
  984. uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_CAPS_PARAM_VER */
  985. NV_ENC_CAPS capsToQuery; /**< [in]: Specifies the encode capability to be queried. Client should pass a member for ::NV_ENC_CAPS enum. */
  986. uint32_t reserved[62]; /**< [in]: Reserved and must be set to 0 */
  987. } NV_ENC_CAPS_PARAM;
  988. /** NV_ENC_CAPS_PARAM struct version. */
  989. #define NV_ENC_CAPS_PARAM_VER NVENCAPI_STRUCT_VERSION(1)
  990. /**
  991. * Encoder Output parameters
  992. */
  993. typedef struct _NV_ENC_ENCODE_OUT_PARAMS
  994. {
  995. uint32_t version; /**< [out]: Struct version. */
  996. uint32_t bitstreamSizeInBytes; /**< [out]: Encoded bitstream size in bytes */
  997. uint32_t reserved[62]; /**< [out]: Reserved and must be set to 0 */
  998. } NV_ENC_ENCODE_OUT_PARAMS;
  999. /** NV_ENC_ENCODE_OUT_PARAMS struct version. */
  1000. #define NV_ENC_ENCODE_OUT_PARAMS_VER NVENCAPI_STRUCT_VERSION(1)
  1001. /**
  1002. * Creation parameters for input buffer.
  1003. */
  1004. typedef struct _NV_ENC_CREATE_INPUT_BUFFER
  1005. {
  1006. uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_CREATE_INPUT_BUFFER_VER */
  1007. uint32_t width; /**< [in]: Input frame width */
  1008. uint32_t height; /**< [in]: Input frame height */
  1009. NV_ENC_MEMORY_HEAP memoryHeap; /**< [in]: Deprecated. Do not use */
  1010. NV_ENC_BUFFER_FORMAT bufferFmt; /**< [in]: Input buffer format */
  1011. uint32_t reserved; /**< [in]: Reserved and must be set to 0 */
  1012. NV_ENC_INPUT_PTR inputBuffer; /**< [out]: Pointer to input buffer */
  1013. void* pSysMemBuffer; /**< [in]: Pointer to existing system memory buffer */
  1014. uint32_t reserved1[57]; /**< [in]: Reserved and must be set to 0 */
  1015. void* reserved2[63]; /**< [in]: Reserved and must be set to NULL */
  1016. } NV_ENC_CREATE_INPUT_BUFFER;
  1017. /** NV_ENC_CREATE_INPUT_BUFFER struct version. */
  1018. #define NV_ENC_CREATE_INPUT_BUFFER_VER NVENCAPI_STRUCT_VERSION(1)
  1019. /**
  1020. * Creation parameters for output bitstream buffer.
  1021. */
  1022. typedef struct _NV_ENC_CREATE_BITSTREAM_BUFFER
  1023. {
  1024. uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_CREATE_BITSTREAM_BUFFER_VER */
  1025. uint32_t size; /**< [in]: Deprecated. Do not use */
  1026. NV_ENC_MEMORY_HEAP memoryHeap; /**< [in]: Deprecated. Do not use */
  1027. uint32_t reserved; /**< [in]: Reserved and must be set to 0 */
  1028. NV_ENC_OUTPUT_PTR bitstreamBuffer; /**< [out]: Pointer to the output bitstream buffer */
  1029. void* bitstreamBufferPtr; /**< [out]: Reserved and should not be used */
  1030. uint32_t reserved1[58]; /**< [in]: Reserved and should be set to 0 */
  1031. void* reserved2[64]; /**< [in]: Reserved and should be set to NULL */
  1032. } NV_ENC_CREATE_BITSTREAM_BUFFER;
  1033. /** NV_ENC_CREATE_BITSTREAM_BUFFER struct version. */
  1034. #define NV_ENC_CREATE_BITSTREAM_BUFFER_VER NVENCAPI_STRUCT_VERSION(1)
  1035. /**
  1036. * Structs needed for ME only mode.
  1037. */
  1038. typedef struct _NV_ENC_MVECTOR
  1039. {
  1040. int16_t mvx; /**< the x component of MV in quarter-pel units */
  1041. int16_t mvy; /**< the y component of MV in quarter-pel units */
  1042. } NV_ENC_MVECTOR;
  1043. /**
  1044. * Motion vector structure per macroblock for H264 motion estimation.
  1045. */
  1046. typedef struct _NV_ENC_H264_MV_DATA
  1047. {
  1048. NV_ENC_MVECTOR mv[4]; /**< up to 4 vectors for 8x8 partition */
  1049. uint8_t mbType; /**< 0 (I), 1 (P), 2 (IPCM), 3 (B) */
  1050. uint8_t partitionType; /**< Specifies the block partition type. 0:16x16, 1:8x8, 2:16x8, 3:8x16 */
  1051. uint16_t reserved; /**< reserved padding for alignment */
  1052. uint32_t mbCost;
  1053. } NV_ENC_H264_MV_DATA;
  1054. /**
  1055. * Motion vector structure per CU for HEVC motion estimation.
  1056. */
  1057. typedef struct _NV_ENC_HEVC_MV_DATA
  1058. {
  1059. NV_ENC_MVECTOR mv[4]; /**< up to 4 vectors within a CU */
  1060. uint8_t cuType; /**< 0 (I), 1(P) */
  1061. uint8_t cuSize; /**< 0: 8x8, 1: 16x16, 2: 32x32, 3: 64x64 */
  1062. uint8_t partitionMode; /**< The CU partition mode
  1063. 0 (2Nx2N), 1 (2NxN), 2(Nx2N), 3 (NxN),
  1064. 4 (2NxnU), 5 (2NxnD), 6(nLx2N), 7 (nRx2N) */
  1065. uint8_t lastCUInCTB; /**< Marker to separate CUs in the current CTB from CUs in the next CTB */
  1066. } NV_ENC_HEVC_MV_DATA;
  1067. /**
  1068. * Creation parameters for output motion vector buffer for ME only mode.
  1069. */
  1070. typedef struct _NV_ENC_CREATE_MV_BUFFER
  1071. {
  1072. uint32_t version; /**< [in]: Struct version. Must be set to NV_ENC_CREATE_MV_BUFFER_VER */
  1073. NV_ENC_OUTPUT_PTR mvBuffer; /**< [out]: Pointer to the output motion vector buffer */
  1074. uint32_t reserved1[255]; /**< [in]: Reserved and should be set to 0 */
  1075. void* reserved2[63]; /**< [in]: Reserved and should be set to NULL */
  1076. } NV_ENC_CREATE_MV_BUFFER;
  1077. /** NV_ENC_CREATE_MV_BUFFER struct version*/
  1078. #define NV_ENC_CREATE_MV_BUFFER_VER NVENCAPI_STRUCT_VERSION(1)
  1079. /**
  1080. * QP value for frames
  1081. */
  1082. typedef struct _NV_ENC_QP
  1083. {
  1084. uint32_t qpInterP; /**< [in]: Specifies QP value for P-frame. Even though this field is uint32_t for legacy reasons, the client should treat this as a signed parameter(int32_t) for cases in which negative QP values are to be specified. */
  1085. uint32_t qpInterB; /**< [in]: Specifies QP value for B-frame. Even though this field is uint32_t for legacy reasons, the client should treat this as a signed parameter(int32_t) for cases in which negative QP values are to be specified. */
  1086. uint32_t qpIntra; /**< [in]: Specifies QP value for Intra Frame. Even though this field is uint32_t for legacy reasons, the client should treat this as a signed parameter(int32_t) for cases in which negative QP values are to be specified. */
  1087. } NV_ENC_QP;
  1088. /**
  1089. * Rate Control Configuration Parameters
  1090. */
  1091. typedef struct _NV_ENC_RC_PARAMS
  1092. {
  1093. uint32_t version;
  1094. 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. */
  1095. 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. */
  1096. uint32_t averageBitRate; /**< [in]: Specifies the average bitrate(in bits/sec) used for encoding. */
  1097. uint32_t maxBitRate; /**< [in]: Specifies the maximum bitrate for the encoded output. This is used for VBR and ignored for CBR mode. */
  1098. uint32_t vbvBufferSize; /**< [in]: Specifies the VBV(HRD) buffer size. in bits. Set 0 to use the default VBV buffer size. */
  1099. uint32_t vbvInitialDelay; /**< [in]: Specifies the VBV(HRD) initial delay in bits. Set 0 to use the default VBV initial delay .*/
  1100. uint32_t enableMinQP :1; /**< [in]: Set this to 1 if minimum QP used for rate control. */
  1101. uint32_t enableMaxQP :1; /**< [in]: Set this to 1 if maximum QP used for rate control. */
  1102. uint32_t enableInitialRCQP :1; /**< [in]: Set this to 1 if user supplied initial QP is used for rate control. */
  1103. uint32_t enableAQ :1; /**< [in]: Set this to 1 to enable adaptive quantization (Spatial). */
  1104. uint32_t reservedBitField1 :1; /**< [in]: Reserved bitfields and must be set to 0. */
  1105. 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) */
  1106. 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) */
  1107. uint32_t disableBadapt :1; /**< [in]: Set this to 1 to disable adaptive B-frame decision (only has an effect when lookahead is enabled) */
  1108. uint32_t enableTemporalAQ :1; /**< [in]: Set this to 1 to enable temporal AQ */
  1109. uint32_t zeroReorderDelay :1; /**< [in]: Set this to 1 to indicate zero latency operation (no reordering delay, num_reorder_frames=0) */
  1110. uint32_t enableNonRefP :1; /**< [in]: Set this to 1 to enable automatic insertion of non-reference P-frames (no effect if enablePTD=0) */
  1111. uint32_t strictGOPTarget :1; /**< [in]: Set this to 1 to minimize GOP-to-GOP rate fluctuations */
  1112. 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).
  1113. If not set, strength is auto selected by driver. */
  1114. uint32_t reservedBitFields :16; /**< [in]: Reserved bitfields and must be set to 0 */
  1115. NV_ENC_QP minQP; /**< [in]: Specifies the minimum QP used for rate control. Client must set NV_ENC_CONFIG::enableMinQP to 1. */
  1116. NV_ENC_QP maxQP; /**< [in]: Specifies the maximum QP used for rate control. Client must set NV_ENC_CONFIG::enableMaxQP to 1. */
  1117. NV_ENC_QP initialRCQP; /**< [in]: Specifies the initial QP used for rate control. Client must set NV_ENC_CONFIG::enableInitialRCQP to 1. */
  1118. 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].
  1119. Applicable only for constant QP mode (NV_ENC_RC_PARAMS::rateControlMode = NV_ENC_PARAMS_RC_CONSTQP). */
  1120. uint8_t temporalLayerQP[8]; /**< [in]: Specifies the temporal layer QPs used for rate control. Temporal layer index is used as the array index.
  1121. Applicable only for constant QP mode (NV_ENC_RC_PARAMS::rateControlMode = NV_ENC_PARAMS_RC_CONSTQP). */
  1122. uint8_t targetQuality; /**< [in]: Target CQ (Constant Quality) level for VBR mode (range 0-51 with 0-automatic) */
  1123. uint8_t targetQualityLSB; /**< [in]: Fractional part of target quality (as 8.8 fixed point format) */
  1124. uint16_t lookaheadDepth; /**< [in]: Maximum depth of lookahead with range 0-(31 - number of B frames).
  1125. lookaheadDepth is only used if enableLookahead=1.*/
  1126. uint8_t lowDelayKeyFrameScale; /**< [in]: Specifies the ratio of I frame bits to P frame bits in case of single frame VBV and CBR rate control mode,
  1127. is set to 2 by default for low latency tuning info and 1 by default for ultra low latency tuning info */
  1128. uint8_t reserved1[3];
  1129. NV_ENC_QP_MAP_MODE qpMapMode; /**< [in]: This flag is used to interpret values in array specified by NV_ENC_PIC_PARAMS::qpDeltaMap.
  1130. Set this to NV_ENC_QP_MAP_EMPHASIS to treat values specified by NV_ENC_PIC_PARAMS::qpDeltaMap as Emphasis Level Map.
  1131. Emphasis Level can be assigned any value specified in enum NV_ENC_EMPHASIS_MAP_LEVEL.
  1132. Emphasis Level Map is used to specify regions to be encoded at varying levels of quality.
  1133. The hardware encoder adjusts the quantization within the image as per the provided emphasis map,
  1134. by adjusting the quantization parameter (QP) assigned to each macroblock. This adjustment is commonly called “Delta QP”.
  1135. The adjustment depends on the absolute QP decided by the rate control algorithm, and is applied after the rate control has decided each macroblock’s QP.
  1136. Since the Delta QP overrides rate control, enabling Emphasis Level Map may violate bitrate and VBV buffer size constraints.
  1137. Emphasis Level Map is useful in situations where client has a priori knowledge of the image complexity (e.g. via use of NVFBC's Classification feature) and encoding those high-complexity areas at higher quality (lower QP) is important, even at the possible cost of violating bitrate/VBV buffer size constraints
  1138. This feature is not supported when AQ( Spatial/Temporal) is enabled.
  1139. This feature is only supported for H264 codec currently.
  1140. Set this to NV_ENC_QP_MAP_DELTA to treat values specified by NV_ENC_PIC_PARAMS::qpDeltaMap as QP Delta. This specifies QP modifier to be applied on top of the QP chosen by rate control
  1141. Set this to NV_ENC_QP_MAP_DISABLED to ignore NV_ENC_PIC_PARAMS::qpDeltaMap values. In this case, qpDeltaMap should be set to NULL.
  1142. Other values are reserved for future use.*/
  1143. NV_ENC_MULTI_PASS multiPass; /**< [in]: This flag is used to enable multi-pass encoding for a given ::NV_ENC_PARAMS_RC_MODE. This flag is not valid for H264 and HEVC MEOnly mode */
  1144. uint32_t alphaLayerBitrateRatio; /**< [in]: Specifies the ratio in which bitrate should be split between base and alpha layer. A value 'x' for this field will split the target bitrate in a ratio of x : 1 between base and alpha layer.
  1145. The default split ratio is 15.*/
  1146. uint32_t reserved[5];
  1147. } NV_ENC_RC_PARAMS;
  1148. /** macro for constructing the version field of ::_NV_ENC_RC_PARAMS */
  1149. #define NV_ENC_RC_PARAMS_VER NVENCAPI_STRUCT_VERSION(1)
  1150. /**
  1151. * \struct _NV_ENC_CONFIG_H264_VUI_PARAMETERS
  1152. * H264 Video Usability Info parameters
  1153. */
  1154. typedef struct _NV_ENC_CONFIG_H264_VUI_PARAMETERS
  1155. {
  1156. uint32_t overscanInfoPresentFlag; /**< [in]: if set to 1 , it specifies that the overscanInfo is present */
  1157. uint32_t overscanInfo; /**< [in]: Specifies the overscan info(as defined in Annex E of the ITU-T Specification). */
  1158. uint32_t videoSignalTypePresentFlag; /**< [in]: If set to 1, it specifies that the videoFormat, videoFullRangeFlag and colourDescriptionPresentFlag are present. */
  1159. uint32_t videoFormat; /**< [in]: Specifies the source video format(as defined in Annex E of the ITU-T Specification).*/
  1160. uint32_t videoFullRangeFlag; /**< [in]: Specifies the output range of the luma and chroma samples(as defined in Annex E of the ITU-T Specification). */
  1161. uint32_t colourDescriptionPresentFlag; /**< [in]: If set to 1, it specifies that the colourPrimaries, transferCharacteristics and colourMatrix are present. */
  1162. uint32_t colourPrimaries; /**< [in]: Specifies color primaries for converting to RGB(as defined in Annex E of the ITU-T Specification) */
  1163. uint32_t transferCharacteristics; /**< [in]: Specifies the opto-electronic transfer characteristics to use (as defined in Annex E of the ITU-T Specification) */
  1164. 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). */
  1165. uint32_t chromaSampleLocationFlag; /**< [in]: if set to 1 , it specifies that the chromaSampleLocationTop and chromaSampleLocationBot are present.*/
  1166. uint32_t chromaSampleLocationTop; /**< [in]: Specifies the chroma sample location for top field(as defined in Annex E of the ITU-T Specification) */
  1167. uint32_t chromaSampleLocationBot; /**< [in]: Specifies the chroma sample location for bottom field(as defined in Annex E of the ITU-T Specification) */
  1168. uint32_t bitstreamRestrictionFlag; /**< [in]: if set to 1, it specifies the bitstream restriction parameters are present in the bitstream.*/
  1169. uint32_t reserved[15];
  1170. }NV_ENC_CONFIG_H264_VUI_PARAMETERS;
  1171. typedef NV_ENC_CONFIG_H264_VUI_PARAMETERS NV_ENC_CONFIG_HEVC_VUI_PARAMETERS;
  1172. /**
  1173. * \struct _NVENC_EXTERNAL_ME_HINT_COUNTS_PER_BLOCKTYPE
  1174. * External motion vector hint counts per block type.
  1175. * H264 supports multiple hint while HEVC supports one hint for each valid candidate.
  1176. */
  1177. typedef struct _NVENC_EXTERNAL_ME_HINT_COUNTS_PER_BLOCKTYPE
  1178. {
  1179. uint32_t numCandsPerBlk16x16 : 4; /**< [in]: Supported for H264, HEVC. It Specifies the number of candidates per 16x16 block. */
  1180. uint32_t numCandsPerBlk16x8 : 4; /**< [in]: Supported for H264 only. Specifies the number of candidates per 16x8 block. */
  1181. uint32_t numCandsPerBlk8x16 : 4; /**< [in]: Supported for H264 only. Specifies the number of candidates per 8x16 block. */
  1182. uint32_t numCandsPerBlk8x8 : 4; /**< [in]: Supported for H264, HEVC. Specifies the number of candidates per 8x8 block. */
  1183. uint32_t reserved : 16; /**< [in]: Reserved for padding. */
  1184. uint32_t reserved1[3]; /**< [in]: Reserved for future use. */
  1185. } NVENC_EXTERNAL_ME_HINT_COUNTS_PER_BLOCKTYPE;
  1186. /**
  1187. * \struct _NVENC_EXTERNAL_ME_HINT
  1188. * External Motion Vector hint structure.
  1189. */
  1190. typedef struct _NVENC_EXTERNAL_ME_HINT
  1191. {
  1192. int32_t mvx : 12; /**< [in]: Specifies the x component of integer pixel MV (relative to current MB) S12.0. */
  1193. int32_t mvy : 10; /**< [in]: Specifies the y component of integer pixel MV (relative to current MB) S10.0 .*/
  1194. 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. */
  1195. int32_t dir : 1; /**< [in]: Specifies the direction of motion estimation . 0=L0 1=L1.*/
  1196. int32_t partType : 2; /**< [in]: Specifies the block partition type.0=16x16 1=16x8 2=8x16 3=8x8 (blocks in partition must be consecutive).*/
  1197. int32_t lastofPart : 1; /**< [in]: Set to 1 for the last MV of (sub) partition */
  1198. int32_t lastOfMB : 1; /**< [in]: Set to 1 for the last MV of macroblock. */
  1199. } NVENC_EXTERNAL_ME_HINT;
  1200. /**
  1201. * \struct _NV_ENC_CONFIG_H264
  1202. * H264 encoder configuration parameters
  1203. */
  1204. typedef struct _NV_ENC_CONFIG_H264
  1205. {
  1206. uint32_t enableTemporalSVC :1; /**< [in]: Set to 1 to enable SVC temporal*/
  1207. uint32_t enableStereoMVC :1; /**< [in]: Set to 1 to enable stereo MVC*/
  1208. uint32_t hierarchicalPFrames :1; /**< [in]: Set to 1 to enable hierarchical P Frames */
  1209. uint32_t hierarchicalBFrames :1; /**< [in]: Set to 1 to enable hierarchical B Frames */
  1210. uint32_t outputBufferingPeriodSEI :1; /**< [in]: Set to 1 to write SEI buffering period syntax in the bitstream */
  1211. uint32_t outputPictureTimingSEI :1; /**< [in]: Set to 1 to write SEI picture timing syntax in the bitstream. When set for following rateControlMode : NV_ENC_PARAMS_RC_CBR, NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ,
  1212. NV_ENC_PARAMS_RC_CBR_HQ, filler data is inserted if needed to achieve HRD bitrate */
  1213. uint32_t outputAUD :1; /**< [in]: Set to 1 to write access unit delimiter syntax in bitstream */
  1214. uint32_t disableSPSPPS :1; /**< [in]: Set to 1 to disable writing of Sequence and Picture parameter info in bitstream */
  1215. uint32_t outputFramePackingSEI :1; /**< [in]: Set to 1 to enable writing of frame packing arrangement SEI messages to bitstream */
  1216. uint32_t outputRecoveryPointSEI :1; /**< [in]: Set to 1 to enable writing of recovery point SEI message */
  1217. 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 */
  1218. uint32_t enableConstrainedEncoding :1; /**< [in]: Set this to 1 to enable constrainedFrame encoding where each slice in the constrained picture is independent of other slices.
  1219. Constrained encoding works only with rectangular slices.
  1220. Check support for constrained encoding using ::NV_ENC_CAPS_SUPPORT_CONSTRAINED_ENCODING caps. */
  1221. uint32_t repeatSPSPPS :1; /**< [in]: Set to 1 to enable writing of Sequence and Picture parameter for every IDR frame */
  1222. uint32_t enableVFR :1; /**< [in]: Setting enableVFR=1 currently only sets the fixed_frame_rate_flag=0 in the VUI but otherwise
  1223. has no impact on the encoder behavior. For more details please refer to E.1 VUI syntax of H.264 standard. Note, however, that NVENC does not support VFR encoding and rate control. */
  1224. uint32_t enableLTR :1; /**< [in]: Set to 1 to enable LTR (Long Term Reference) frame support. LTR can be used in two modes: "LTR Trust" mode and "LTR Per Picture" mode.
  1225. LTR Trust mode: In this mode, ltrNumFrames pictures after IDR are automatically marked as LTR. This mode is enabled by setting ltrTrustMode = 1.
  1226. Use of LTR Trust mode is strongly discouraged as this mode may be deprecated in future.
  1227. LTR Per Picture mode: In this mode, client can control whether the current picture should be marked as LTR. Enable this mode by setting
  1228. ltrTrustMode = 0 and ltrMarkFrame = 1 for the picture to be marked as LTR. This is the preferred mode
  1229. for using LTR.
  1230. Note that LTRs are not supported if encoding session is configured with B-frames */
  1231. 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.
  1232. Check support for lossless encoding using ::NV_ENC_CAPS_SUPPORT_LOSSLESS_ENCODE caps. */
  1233. uint32_t useConstrainedIntraPred :1; /**< [in]: Set 1 to enable constrained intra prediction. */
  1234. uint32_t enableFillerDataInsertion :1; /**< [in]: Set to 1 to enable insertion of filler data in the bitstream.
  1235. This flag will take effect only when one of the CBR rate
  1236. control modes (NV_ENC_PARAMS_RC_CBR, NV_ENC_PARAMS_RC_CBR_HQ,
  1237. NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ) is in use and both
  1238. NV_ENC_INITIALIZE_PARAMS::frameRateNum and
  1239. NV_ENC_INITIALIZE_PARAMS::frameRateDen are set to non-zero
  1240. values. Setting this field when
  1241. NV_ENC_INITIALIZE_PARAMS::enableOutputInVidmem is also set
  1242. is currently not supported and will make ::NvEncInitializeEncoder()
  1243. return an error. */
  1244. uint32_t disableSVCPrefixNalu :1; /**< [in]: Set to 1 to disable writing of SVC Prefix NALU preceding each slice in bitstream.
  1245. Applicable only when temporal SVC is enabled (NV_ENC_CONFIG_H264::enableTemporalSVC = 1). */
  1246. uint32_t enableScalabilityInfoSEI :1; /**< [in]: Set to 1 to enable writing of Scalability Information SEI message preceding each IDR picture in bitstream
  1247. Applicable only when temporal SVC is enabled (NV_ENC_CONFIG_H264::enableTemporalSVC = 1). */
  1248. uint32_t reservedBitFields :12; /**< [in]: Reserved bitfields and must be set to 0 */
  1249. 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. */
  1250. 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. */
  1251. uint32_t separateColourPlaneFlag; /**< [in]: Set to 1 to enable 4:4:4 separate colour planes */
  1252. uint32_t disableDeblockingFilterIDC; /**< [in]: Specifies the deblocking filter mode. Permissible value range: [0,2]. This flag corresponds
  1253. to the flag disable_deblocking_filter_idc specified in section 7.4.3 of H.264 specification,
  1254. which specifies whether the operation of the deblocking filter shall be disabled across some
  1255. block edges of the slice and specifies for which edges the filtering is disabled. See section
  1256. 7.4.3 of H.264 specification for more details.*/
  1257. uint32_t numTemporalLayers; /**< [in]: Specifies number of temporal layers to be used for hierarchical coding / temporal SVC. Valid value range is [1,::NV_ENC_CAPS_NUM_MAX_TEMPORAL_LAYERS] */
  1258. uint32_t spsId; /**< [in]: Specifies the SPS id of the sequence header */
  1259. uint32_t ppsId; /**< [in]: Specifies the PPS id of the picture header */
  1260. 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. */
  1261. NV_ENC_H264_FMO_MODE fmoMode; /**< [in]: Specified the FMO Mode. Check support for FMO using ::NV_ENC_CAPS_SUPPORT_FMO caps. */
  1262. NV_ENC_H264_BDIRECT_MODE bdirectMode; /**< [in]: Specifies the BDirect mode. Check support for BDirect mode using ::NV_ENC_CAPS_SUPPORT_BDIRECT_MODE caps.*/
  1263. 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. */
  1264. NV_ENC_STEREO_PACKING_MODE stereoMode; /**< [in]: Specifies the stereo frame packing mode which is to be signaled in frame packing arrangement SEI */
  1265. uint32_t intraRefreshPeriod; /**< [in]: Specifies the interval between successive intra refresh if enableIntrarefresh is set. Requires enableIntraRefresh to be set.
  1266. Will be disabled if NV_ENC_CONFIG::gopLength is not set to NVENC_INFINITE_GOPLENGTH. */
  1267. 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 */
  1268. uint32_t maxNumRefFrames; /**< [in]: Specifies the DPB size used for encoding. Setting it to 0 will let driver use the default DPB size.
  1269. The low latency application which wants to invalidate reference frame as an error resilience tool
  1270. is recommended to use a large DPB size so that the encoder can keep old reference frames which can be used if recent
  1271. frames are invalidated. */
  1272. uint32_t sliceMode; /**< [in]: This parameter in conjunction with sliceModeData specifies the way in which the picture is divided into slices
  1273. sliceMode = 0 MB based slices, sliceMode = 1 Byte based slices, sliceMode = 2 MB row based slices, sliceMode = 3 numSlices in Picture.
  1274. When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting
  1275. When sliceMode == 0 and sliceModeData == 0 whole picture will be coded with one slice */
  1276. uint32_t sliceModeData; /**< [in]: Specifies the parameter needed for sliceMode. For:
  1277. sliceMode = 0, sliceModeData specifies # of MBs in each slice (except last slice)
  1278. sliceMode = 1, sliceModeData specifies maximum # of bytes in each slice (except last slice)
  1279. sliceMode = 2, sliceModeData specifies # of MB rows in each slice (except last slice)
  1280. sliceMode = 3, sliceModeData specifies number of slices in the picture. Driver will divide picture into slices optimally */
  1281. NV_ENC_CONFIG_H264_VUI_PARAMETERS h264VUIParameters; /**< [in]: Specifies the H264 video usability info parameters */
  1282. uint32_t ltrNumFrames; /**< [in]: Specifies the number of LTR frames. This parameter has different meaning in two LTR modes.
  1283. In "LTR Trust" mode (ltrTrustMode = 1), encoder will mark the first ltrNumFrames base layer reference frames within each IDR interval as LTR.
  1284. In "LTR Per Picture" mode (ltrTrustMode = 0 and ltrMarkFrame = 1), ltrNumFrames specifies maximum number of LTR frames in DPB. */
  1285. uint32_t ltrTrustMode; /**< [in]: Specifies the LTR operating mode. See comments near NV_ENC_CONFIG_H264::enableLTR for description of the two modes.
  1286. Set to 1 to use "LTR Trust" mode of LTR operation. Clients are discouraged to use "LTR Trust" mode as this mode may
  1287. be deprecated in future releases.
  1288. Set to 0 when using "LTR Per Picture" mode of LTR operation. */
  1289. uint32_t chromaFormatIDC; /**< [in]: Specifies the chroma format. Should be set to 1 for yuv420 input, 3 for yuv444 input.
  1290. Check support for YUV444 encoding using ::NV_ENC_CAPS_SUPPORT_YUV444_ENCODE caps.*/
  1291. uint32_t maxTemporalLayers; /**< [in]: Specifies the maximum temporal layer used for temporal SVC / hierarchical coding.
  1292. Defaut value of this field is NV_ENC_CAPS::NV_ENC_CAPS_NUM_MAX_TEMPORAL_LAYERS. Note that the value NV_ENC_CONFIG_H264::maxNumRefFrames should
  1293. be greater than or equal to (NV_ENC_CONFIG_H264::maxTemporalLayers - 2) * 2, for NV_ENC_CONFIG_H264::maxTemporalLayers >= 2.*/
  1294. NV_ENC_BFRAME_REF_MODE useBFramesAsRef; /**< [in]: Specifies the B-Frame as reference mode. Check support for useBFramesAsRef mode using ::NV_ENC_CAPS_SUPPORT_BFRAME_REF_MODE caps.*/
  1295. NV_ENC_NUM_REF_FRAMES numRefL0; /**< [in]: Specifies max number of reference frames in reference picture list L0, that can be used by hardware for prediction of a frame.
  1296. Check support for numRefL0 using ::NV_ENC_CAPS_SUPPORT_MULTIPLE_REF_FRAMES caps. */
  1297. NV_ENC_NUM_REF_FRAMES numRefL1; /**< [in]: Specifies max number of reference frames in reference picture list L1, that can be used by hardware for prediction of a frame.
  1298. Check support for numRefL1 using ::NV_ENC_CAPS_SUPPORT_MULTIPLE_REF_FRAMES caps. */
  1299. uint32_t reserved1[267]; /**< [in]: Reserved and must be set to 0 */
  1300. void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
  1301. } NV_ENC_CONFIG_H264;
  1302. /**
  1303. * \struct _NV_ENC_CONFIG_HEVC
  1304. * HEVC encoder configuration parameters to be set during initialization.
  1305. */
  1306. typedef struct _NV_ENC_CONFIG_HEVC
  1307. {
  1308. uint32_t level; /**< [in]: Specifies the level of the encoded bitstream.*/
  1309. uint32_t tier; /**< [in]: Specifies the level tier of the encoded bitstream.*/
  1310. NV_ENC_HEVC_CUSIZE minCUSize; /**< [in]: Specifies the minimum size of luma coding unit.*/
  1311. 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.*/
  1312. uint32_t useConstrainedIntraPred :1; /**< [in]: Set 1 to enable constrained intra prediction. */
  1313. uint32_t disableDeblockAcrossSliceBoundary :1; /**< [in]: Set 1 to disable in loop filtering across slice boundary.*/
  1314. uint32_t outputBufferingPeriodSEI :1; /**< [in]: Set 1 to write SEI buffering period syntax in the bitstream */
  1315. uint32_t outputPictureTimingSEI :1; /**< [in]: Set 1 to write SEI picture timing syntax in the bitstream */
  1316. uint32_t outputAUD :1; /**< [in]: Set 1 to write Access Unit Delimiter syntax. */
  1317. uint32_t enableLTR :1; /**< [in]: Set to 1 to enable LTR (Long Term Reference) frame support. LTR can be used in two modes: "LTR Trust" mode and "LTR Per Picture" mode.
  1318. LTR Trust mode: In this mode, ltrNumFrames pictures after IDR are automatically marked as LTR. This mode is enabled by setting ltrTrustMode = 1.
  1319. Use of LTR Trust mode is strongly discouraged as this mode may be deprecated in future releases.
  1320. LTR Per Picture mode: In this mode, client can control whether the current picture should be marked as LTR. Enable this mode by setting
  1321. ltrTrustMode = 0 and ltrMarkFrame = 1 for the picture to be marked as LTR. This is the preferred mode
  1322. for using LTR.
  1323. Note that LTRs are not supported if encoding session is configured with B-frames */
  1324. uint32_t disableSPSPPS :1; /**< [in]: Set 1 to disable VPS, SPS and PPS signaling in the bitstream. */
  1325. uint32_t repeatSPSPPS :1; /**< [in]: Set 1 to output VPS,SPS and PPS for every IDR frame.*/
  1326. 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 */
  1327. uint32_t chromaFormatIDC :2; /**< [in]: Specifies the chroma format. Should be set to 1 for yuv420 input, 3 for yuv444 input.*/
  1328. 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.*/
  1329. uint32_t enableFillerDataInsertion :1; /**< [in]: Set to 1 to enable insertion of filler data in the bitstream.
  1330. This flag will take effect only when one of the CBR rate
  1331. control modes (NV_ENC_PARAMS_RC_CBR, NV_ENC_PARAMS_RC_CBR_HQ,
  1332. NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ) is in use and both
  1333. NV_ENC_INITIALIZE_PARAMS::frameRateNum and
  1334. NV_ENC_INITIALIZE_PARAMS::frameRateDen are set to non-zero
  1335. values. Setting this field when
  1336. NV_ENC_INITIALIZE_PARAMS::enableOutputInVidmem is also set
  1337. is currently not supported and will make ::NvEncInitializeEncoder()
  1338. return an error. */
  1339. uint32_t enableConstrainedEncoding :1; /**< [in]: Set this to 1 to enable constrainedFrame encoding where each slice in the constrained picture is independent of other slices.
  1340. Constrained encoding works only with rectangular slices.
  1341. Check support for constrained encoding using ::NV_ENC_CAPS_SUPPORT_CONSTRAINED_ENCODING caps. */
  1342. uint32_t enableAlphaLayerEncoding :1; /**< [in]: Set this to 1 to enable HEVC encode with alpha layer. */
  1343. uint32_t reserved :15; /**< [in]: Reserved bitfields.*/
  1344. 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. */
  1345. uint32_t intraRefreshPeriod; /**< [in]: Specifies the interval between successive intra refresh if enableIntrarefresh is set. Requires enableIntraRefresh to be set.
  1346. Will be disabled if NV_ENC_CONFIG::gopLength is not set to NVENC_INFINITE_GOPLENGTH. */
  1347. 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 */
  1348. uint32_t maxNumRefFramesInDPB; /**< [in]: Specifies the maximum number of references frames in the DPB.*/
  1349. uint32_t ltrNumFrames; /**< [in]: This parameter has different meaning in two LTR modes.
  1350. In "LTR Trust" mode (ltrTrustMode = 1), encoder will mark the first ltrNumFrames base layer reference frames within each IDR interval as LTR.
  1351. In "LTR Per Picture" mode (ltrTrustMode = 0 and ltrMarkFrame = 1), ltrNumFrames specifies maximum number of LTR frames in DPB. */
  1352. uint32_t vpsId; /**< [in]: Specifies the VPS id of the video parameter set */
  1353. uint32_t spsId; /**< [in]: Specifies the SPS id of the sequence header */
  1354. uint32_t ppsId; /**< [in]: Specifies the PPS id of the picture header */
  1355. uint32_t sliceMode; /**< [in]: This parameter in conjunction with sliceModeData specifies the way in which the picture is divided into slices
  1356. sliceMode = 0 CTU based slices, sliceMode = 1 Byte based slices, sliceMode = 2 CTU row based slices, sliceMode = 3, numSlices in Picture
  1357. When sliceMode == 0 and sliceModeData == 0 whole picture will be coded with one slice */
  1358. uint32_t sliceModeData; /**< [in]: Specifies the parameter needed for sliceMode. For:
  1359. sliceMode = 0, sliceModeData specifies # of CTUs in each slice (except last slice)
  1360. sliceMode = 1, sliceModeData specifies maximum # of bytes in each slice (except last slice)
  1361. sliceMode = 2, sliceModeData specifies # of CTU rows in each slice (except last slice)
  1362. sliceMode = 3, sliceModeData specifies number of slices in the picture. Driver will divide picture into slices optimally */
  1363. uint32_t maxTemporalLayersMinus1; /**< [in]: Specifies the max temporal layer used for hierarchical coding. */
  1364. NV_ENC_CONFIG_HEVC_VUI_PARAMETERS hevcVUIParameters; /**< [in]: Specifies the HEVC video usability info parameters */
  1365. uint32_t ltrTrustMode; /**< [in]: Specifies the LTR operating mode. See comments near NV_ENC_CONFIG_HEVC::enableLTR for description of the two modes.
  1366. Set to 1 to use "LTR Trust" mode of LTR operation. Clients are discouraged to use "LTR Trust" mode as this mode may
  1367. be deprecated in future releases.
  1368. Set to 0 when using "LTR Per Picture" mode of LTR operation. */
  1369. NV_ENC_BFRAME_REF_MODE useBFramesAsRef; /**< [in]: Specifies the B-Frame as reference mode. Check support for useBFramesAsRef mode using ::NV_ENC_CAPS_SUPPORT_BFRAME_REF_MODE caps.*/
  1370. NV_ENC_NUM_REF_FRAMES numRefL0; /**< [in]: Specifies max number of reference frames in reference picture list L0, that can be used by hardware for prediction of a frame.
  1371. Check support for numRefL0 using ::NV_ENC_CAPS_SUPPORT_MULTIPLE_REF_FRAMES caps. */
  1372. NV_ENC_NUM_REF_FRAMES numRefL1; /**< [in]: Specifies max number of reference frames in reference picture list L1, that can be used by hardware for prediction of a frame.
  1373. Check support for numRefL1 using ::NV_ENC_CAPS_SUPPORT_MULTIPLE_REF_FRAMES caps. */
  1374. uint32_t reserved1[214]; /**< [in]: Reserved and must be set to 0.*/
  1375. void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
  1376. } NV_ENC_CONFIG_HEVC;
  1377. /**
  1378. * \struct _NV_ENC_CONFIG_H264_MEONLY
  1379. * H264 encoder configuration parameters for ME only Mode
  1380. *
  1381. */
  1382. typedef struct _NV_ENC_CONFIG_H264_MEONLY
  1383. {
  1384. uint32_t disablePartition16x16 :1; /**< [in]: Disable Motion Estimation on 16x16 blocks*/
  1385. uint32_t disablePartition8x16 :1; /**< [in]: Disable Motion Estimation on 8x16 blocks*/
  1386. uint32_t disablePartition16x8 :1; /**< [in]: Disable Motion Estimation on 16x8 blocks*/
  1387. uint32_t disablePartition8x8 :1; /**< [in]: Disable Motion Estimation on 8x8 blocks*/
  1388. uint32_t disableIntraSearch :1; /**< [in]: Disable Intra search during Motion Estimation*/
  1389. uint32_t bStereoEnable :1; /**< [in]: Enable Stereo Mode for Motion Estimation where each view is independently executed*/
  1390. uint32_t reserved :26; /**< [in]: Reserved and must be set to 0 */
  1391. uint32_t reserved1 [255]; /**< [in]: Reserved and must be set to 0 */
  1392. void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
  1393. } NV_ENC_CONFIG_H264_MEONLY;
  1394. /**
  1395. * \struct _NV_ENC_CONFIG_HEVC_MEONLY
  1396. * HEVC encoder configuration parameters for ME only Mode
  1397. *
  1398. */
  1399. typedef struct _NV_ENC_CONFIG_HEVC_MEONLY
  1400. {
  1401. uint32_t reserved [256]; /**< [in]: Reserved and must be set to 0 */
  1402. void* reserved1[64]; /**< [in]: Reserved and must be set to NULL */
  1403. } NV_ENC_CONFIG_HEVC_MEONLY;
  1404. /**
  1405. * \struct _NV_ENC_CODEC_CONFIG
  1406. * Codec-specific encoder configuration parameters to be set during initialization.
  1407. */
  1408. typedef union _NV_ENC_CODEC_CONFIG
  1409. {
  1410. NV_ENC_CONFIG_H264 h264Config; /**< [in]: Specifies the H.264-specific encoder configuration. */
  1411. NV_ENC_CONFIG_HEVC hevcConfig; /**< [in]: Specifies the HEVC-specific encoder configuration. */
  1412. NV_ENC_CONFIG_H264_MEONLY h264MeOnlyConfig; /**< [in]: Specifies the H.264-specific ME only encoder configuration. */
  1413. NV_ENC_CONFIG_HEVC_MEONLY hevcMeOnlyConfig; /**< [in]: Specifies the HEVC-specific ME only encoder configuration. */
  1414. uint32_t reserved[320]; /**< [in]: Reserved and must be set to 0 */
  1415. } NV_ENC_CODEC_CONFIG;
  1416. /**
  1417. * \struct _NV_ENC_CONFIG
  1418. * Encoder configuration parameters to be set during initialization.
  1419. */
  1420. typedef struct _NV_ENC_CONFIG
  1421. {
  1422. uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_CONFIG_VER. */
  1423. 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. */
  1424. 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. */
  1425. 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. */
  1426. uint32_t monoChromeEncoding; /**< [in]: Set this to 1 to enable monochrome encoding for this session. */
  1427. NV_ENC_PARAMS_FRAME_FIELD_MODE frameFieldMode; /**< [in]: Specifies the frame/field mode.
  1428. Check support for field encoding using ::NV_ENC_CAPS_SUPPORT_FIELD_ENCODING caps.
  1429. Using a frameFieldMode other than NV_ENC_PARAMS_FRAME_FIELD_MODE_FRAME for RGB input is not supported. */
  1430. NV_ENC_MV_PRECISION mvPrecision; /**< [in]: Specifies the desired motion vector prediction precision. */
  1431. NV_ENC_RC_PARAMS rcParams; /**< [in]: Specifies the rate control parameters for the current encoding session. */
  1432. NV_ENC_CODEC_CONFIG encodeCodecConfig; /**< [in]: Specifies the codec specific config parameters through this union. */
  1433. uint32_t reserved [278]; /**< [in]: Reserved and must be set to 0 */
  1434. void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
  1435. } NV_ENC_CONFIG;
  1436. /** macro for constructing the version field of ::_NV_ENC_CONFIG */
  1437. #define NV_ENC_CONFIG_VER (NVENCAPI_STRUCT_VERSION(7) | ( 1<<31 ))
  1438. /**
  1439. * Tuning information of NVENC encoding (TuningInfo is not applicable to H264 and HEVC MEOnly mode).
  1440. */
  1441. typedef enum NV_ENC_TUNING_INFO
  1442. {
  1443. NV_ENC_TUNING_INFO_UNDEFINED = 0, /**< Undefined tuningInfo. Invalid value for encoding. */
  1444. NV_ENC_TUNING_INFO_HIGH_QUALITY = 1, /**< Tune presets for latency tolerant encoding.*/
  1445. NV_ENC_TUNING_INFO_LOW_LATENCY = 2, /**< Tune presets for low latency streaming.*/
  1446. NV_ENC_TUNING_INFO_ULTRA_LOW_LATENCY = 3, /**< Tune presets for ultra low latency streaming.*/
  1447. NV_ENC_TUNING_INFO_LOSSLESS = 4, /**< Tune presets for lossless encoding.*/
  1448. NV_ENC_TUNING_INFO_COUNT /**< Count number of tuningInfos. Invalid value. */
  1449. }NV_ENC_TUNING_INFO;
  1450. /**
  1451. * \struct _NV_ENC_INITIALIZE_PARAMS
  1452. * Encode Session Initialization parameters.
  1453. */
  1454. typedef struct _NV_ENC_INITIALIZE_PARAMS
  1455. {
  1456. uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_INITIALIZE_PARAMS_VER. */
  1457. 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. */
  1458. 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. */
  1459. uint32_t encodeWidth; /**< [in]: Specifies the encode width. If not set ::NvEncInitializeEncoder() API will fail. */
  1460. uint32_t encodeHeight; /**< [in]: Specifies the encode height. If not set ::NvEncInitializeEncoder() API will fail. */
  1461. uint32_t darWidth; /**< [in]: Specifies the display aspect ratio Width. */
  1462. uint32_t darHeight; /**< [in]: Specifies the display aspect ratio height. */
  1463. uint32_t frameRateNum; /**< [in]: Specifies the numerator for frame rate used for encoding in frames per second ( Frame rate = frameRateNum / frameRateDen ). */
  1464. uint32_t frameRateDen; /**< [in]: Specifies the denominator for frame rate used for encoding in frames per second ( Frame rate = frameRateNum / frameRateDen ). */
  1465. uint32_t enableEncodeAsync; /**< [in]: Set this to 1 to enable asynchronous mode and is expected to use events to get picture completion notification. */
  1466. uint32_t enablePTD; /**< [in]: Set this to 1 to enable the Picture Type Decision is be taken by the NvEncodeAPI interface. */
  1467. 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 */
  1468. uint32_t enableSubFrameWrite :1; /**< [in]: Set this to 1 to write out available bitstream to memory at subframe intervals.
  1469. If enableSubFrameWrite = 1, then the hardware encoder returns data as soon as a slice has completed encoding.
  1470. This results in better encoding latency, but the downside is that the application has to keep polling via a call to nvEncLockBitstream API continuously to see if any encoded slice data is available.
  1471. Use this mode if you feel that the marginal reduction in latency from sub-frame encoding is worth the increase in complexity due to CPU-based polling. */
  1472. 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.
  1473. NV_ENC_PIC_PARAMS::meHintRefPicDist should preferably be set with enablePTD=1. */
  1474. uint32_t enableMEOnlyMode :1; /**< [in]: Set to 1 to enable ME Only Mode .*/
  1475. uint32_t enableWeightedPrediction :1; /**< [in]: Set this to 1 to enable weighted prediction. Not supported if encode session is configured for B-Frames (i.e. NV_ENC_CONFIG::frameIntervalP > 1 or preset >=P3 when tuningInfo = ::NV_ENC_TUNING_INFO_HIGH_QUALITY or
  1476. tuningInfo = ::NV_ENC_TUNING_INFO_LOSSLESS. This is because preset >=p3 internally enables B frames when tuningInfo = ::NV_ENC_TUNING_INFO_HIGH_QUALITY or ::NV_ENC_TUNING_INFO_LOSSLESS). */
  1477. uint32_t enableOutputInVidmem :1; /**< [in]: Set this to 1 to enable output of NVENC in video memory buffer created by application. This feature is not supported for HEVC ME only mode. */
  1478. uint32_t reservedBitFields :26; /**< [in]: Reserved bitfields and must be set to 0 */
  1479. uint32_t privDataSize; /**< [in]: Reserved private data buffer size and must be set to 0 */
  1480. void* privData; /**< [in]: Reserved private data buffer and must be set to NULL */
  1481. 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.
  1482. 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.
  1483. 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. */
  1484. uint32_t maxEncodeWidth; /**< [in]: Maximum encode width to be used for current Encode session.
  1485. Client should allocate output buffers according to this dimension for dynamic resolution change. If set to 0, Encoder will not allow dynamic resolution change. */
  1486. uint32_t maxEncodeHeight; /**< [in]: Maximum encode height to be allowed for current Encode session.
  1487. Client should allocate output buffers according to this dimension for dynamic resolution change. If set to 0, Encode will not allow dynamic resolution change. */
  1488. 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.
  1489. The NV_ENC_INITIALIZE_PARAMS::maxMEHintCountsPerBlock[0] is for L0 predictors and NV_ENC_INITIALIZE_PARAMS::maxMEHintCountsPerBlock[1] is for L1 predictors.
  1490. This client must also set NV_ENC_INITIALIZE_PARAMS::enableExternalMEHints to 1. */
  1491. NV_ENC_TUNING_INFO tuningInfo; /**< [in]: Tuning Info of NVENC encoding(TuningInfo is not applicable to H264 and HEVC meonly mode). */
  1492. uint32_t reserved [288]; /**< [in]: Reserved and must be set to 0 */
  1493. void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
  1494. } NV_ENC_INITIALIZE_PARAMS;
  1495. /** macro for constructing the version field of ::_NV_ENC_INITIALIZE_PARAMS */
  1496. #define NV_ENC_INITIALIZE_PARAMS_VER (NVENCAPI_STRUCT_VERSION(5) | ( 1<<31 ))
  1497. /**
  1498. * \struct _NV_ENC_RECONFIGURE_PARAMS
  1499. * Encode Session Reconfigured parameters.
  1500. */
  1501. typedef struct _NV_ENC_RECONFIGURE_PARAMS
  1502. {
  1503. uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_RECONFIGURE_PARAMS_VER. */
  1504. NV_ENC_INITIALIZE_PARAMS reInitEncodeParams; /**< [in]: Encoder session re-initialization parameters.
  1505. If reInitEncodeParams.encodeConfig is NULL and
  1506. reInitEncodeParams.presetGUID is the same as the preset
  1507. GUID specified on the call to NvEncInitializeEncoder(),
  1508. EncodeAPI will continue to use the existing encode
  1509. configuration.
  1510. If reInitEncodeParams.encodeConfig is NULL and
  1511. reInitEncodeParams.presetGUID is different from the preset
  1512. GUID specified on the call to NvEncInitializeEncoder(),
  1513. EncodeAPI will try to use the default configuration for
  1514. the preset specified by reInitEncodeParams.presetGUID.
  1515. In this case, reconfiguration may fail if the new
  1516. configuration is incompatible with the existing
  1517. configuration (e.g. the new configuration results in
  1518. a change in the GOP structure). */
  1519. 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.
  1520. If NV_ENC_INITIALIZE_PARAMS::enablePTD is set to 1, encoder will force the frame type to IDR */
  1521. 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
  1522. [_NV_ENC_INITIALIZE_PARAMS::enablePTD == 1]. */
  1523. uint32_t reserved :30;
  1524. }NV_ENC_RECONFIGURE_PARAMS;
  1525. /** macro for constructing the version field of ::_NV_ENC_RECONFIGURE_PARAMS */
  1526. #define NV_ENC_RECONFIGURE_PARAMS_VER (NVENCAPI_STRUCT_VERSION(1) | ( 1<<31 ))
  1527. /**
  1528. * \struct _NV_ENC_PRESET_CONFIG
  1529. * Encoder preset config
  1530. */
  1531. typedef struct _NV_ENC_PRESET_CONFIG
  1532. {
  1533. uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_PRESET_CONFIG_VER. */
  1534. NV_ENC_CONFIG presetCfg; /**< [out]: preset config returned by the Nvidia Video Encoder interface. */
  1535. uint32_t reserved1[255]; /**< [in]: Reserved and must be set to 0 */
  1536. void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
  1537. }NV_ENC_PRESET_CONFIG;
  1538. /** macro for constructing the version field of ::_NV_ENC_PRESET_CONFIG */
  1539. #define NV_ENC_PRESET_CONFIG_VER (NVENCAPI_STRUCT_VERSION(4) | ( 1<<31 ))
  1540. /**
  1541. * \struct _NV_ENC_PIC_PARAMS_MVC
  1542. * MVC-specific parameters to be sent on a per-frame basis.
  1543. */
  1544. typedef struct _NV_ENC_PIC_PARAMS_MVC
  1545. {
  1546. uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_PIC_PARAMS_MVC_VER. */
  1547. uint32_t viewID; /**< [in]: Specifies the view ID associated with the current input view. */
  1548. uint32_t temporalID; /**< [in]: Specifies the temporal ID associated with the current input view. */
  1549. uint32_t priorityID; /**< [in]: Specifies the priority ID associated with the current input view. Reserved and ignored by the NvEncodeAPI interface. */
  1550. uint32_t reserved1[12]; /**< [in]: Reserved and must be set to 0. */
  1551. void* reserved2[8]; /**< [in]: Reserved and must be set to NULL. */
  1552. }NV_ENC_PIC_PARAMS_MVC;
  1553. /** macro for constructing the version field of ::_NV_ENC_PIC_PARAMS_MVC */
  1554. #define NV_ENC_PIC_PARAMS_MVC_VER NVENCAPI_STRUCT_VERSION(1)
  1555. /**
  1556. * \union _NV_ENC_PIC_PARAMS_H264_EXT
  1557. * H264 extension picture parameters
  1558. */
  1559. typedef union _NV_ENC_PIC_PARAMS_H264_EXT
  1560. {
  1561. NV_ENC_PIC_PARAMS_MVC mvcPicParams; /**< [in]: Specifies the MVC picture parameters. */
  1562. uint32_t reserved1[32]; /**< [in]: Reserved and must be set to 0. */
  1563. }NV_ENC_PIC_PARAMS_H264_EXT;
  1564. /**
  1565. * \struct _NV_ENC_SEI_PAYLOAD
  1566. * User SEI message
  1567. */
  1568. typedef struct _NV_ENC_SEI_PAYLOAD
  1569. {
  1570. uint32_t payloadSize; /**< [in] SEI payload size in bytes. SEI payload must be byte aligned, as described in Annex D */
  1571. uint32_t payloadType; /**< [in] SEI payload types and syntax can be found in Annex D of the H.264 Specification. */
  1572. uint8_t *payload; /**< [in] pointer to user data */
  1573. } NV_ENC_SEI_PAYLOAD;
  1574. #define NV_ENC_H264_SEI_PAYLOAD NV_ENC_SEI_PAYLOAD
  1575. /**
  1576. * \struct _NV_ENC_PIC_PARAMS_H264
  1577. * H264 specific enc pic params. sent on a per frame basis.
  1578. */
  1579. typedef struct _NV_ENC_PIC_PARAMS_H264
  1580. {
  1581. uint32_t displayPOCSyntax; /**< [in]: Specifies the display POC syntax This is required to be set if client is handling the picture type decision. */
  1582. uint32_t reserved3; /**< [in]: Reserved and must be set to 0 */
  1583. uint32_t refPicFlag; /**< [in]: Set to 1 for a reference picture. This is ignored if NV_ENC_INITIALIZE_PARAMS::enablePTD is set to 1. */
  1584. uint32_t colourPlaneId; /**< [in]: Specifies the colour plane ID associated with the current input. */
  1585. uint32_t forceIntraRefreshWithFrameCnt; /**< [in]: Forces an intra refresh with duration equal to intraRefreshFrameCnt.
  1586. When outputRecoveryPointSEI is set this is value is used for recovery_frame_cnt in recovery point SEI message
  1587. forceIntraRefreshWithFrameCnt cannot be used if B frames are used in the GOP structure specified */
  1588. 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.
  1589. NV_ENC_INITIALIZE_PARAMS::enableConstrainedEncoding should be set to 1 */
  1590. uint32_t sliceModeDataUpdate :1; /**< [in]: Set to 1 if client wants to change the sliceModeData field to specify new sliceSize Parameter
  1591. When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting */
  1592. uint32_t ltrMarkFrame :1; /**< [in]: Set to 1 if client wants to mark this frame as LTR */
  1593. uint32_t ltrUseFrames :1; /**< [in]: Set to 1 if client allows encoding this frame using the LTR frames specified in ltrFrameBitmap */
  1594. uint32_t reservedBitFields :28; /**< [in]: Reserved bit fields and must be set to 0 */
  1595. uint8_t* sliceTypeData; /**< [in]: Deprecated. */
  1596. uint32_t sliceTypeArrayCnt; /**< [in]: Deprecated. */
  1597. uint32_t seiPayloadArrayCnt; /**< [in]: Specifies the number of elements allocated in seiPayloadArray array. */
  1598. NV_ENC_SEI_PAYLOAD* seiPayloadArray; /**< [in]: Array of SEI payloads which will be inserted for this frame. */
  1599. uint32_t sliceMode; /**< [in]: This parameter in conjunction with sliceModeData specifies the way in which the picture is divided into slices
  1600. sliceMode = 0 MB based slices, sliceMode = 1 Byte based slices, sliceMode = 2 MB row based slices, sliceMode = 3, numSlices in Picture
  1601. When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting
  1602. When sliceMode == 0 and sliceModeData == 0 whole picture will be coded with one slice */
  1603. uint32_t sliceModeData; /**< [in]: Specifies the parameter needed for sliceMode. For:
  1604. sliceMode = 0, sliceModeData specifies # of MBs in each slice (except last slice)
  1605. sliceMode = 1, sliceModeData specifies maximum # of bytes in each slice (except last slice)
  1606. sliceMode = 2, sliceModeData specifies # of MB rows in each slice (except last slice)
  1607. sliceMode = 3, sliceModeData specifies number of slices in the picture. Driver will divide picture into slices optimally */
  1608. uint32_t ltrMarkFrameIdx; /**< [in]: Specifies the long term referenceframe index to use for marking this frame as LTR.*/
  1609. uint32_t ltrUseFrameBitmap; /**< [in]: Specifies the associated bitmap of LTR frame indices to use when encoding this frame. */
  1610. uint32_t ltrUsageMode; /**< [in]: Not supported. Reserved for future use and must be set to 0. */
  1611. uint32_t forceIntraSliceCount; /**< [in]: Specifies the number of slices to be forced to Intra in the current picture.
  1612. This option along with forceIntraSliceIdx[] array needs to be used with sliceMode = 3 only */
  1613. uint32_t *forceIntraSliceIdx; /**< [in]: Slice indices to be forced to intra in the current picture. Each slice index should be <= num_slices_in_picture -1. Index starts from 0 for first slice.
  1614. The number of entries in this array should be equal to forceIntraSliceCount */
  1615. NV_ENC_PIC_PARAMS_H264_EXT h264ExtPicParams; /**< [in]: Specifies the H264 extension config parameters using this config. */
  1616. uint32_t reserved [210]; /**< [in]: Reserved and must be set to 0. */
  1617. void* reserved2[61]; /**< [in]: Reserved and must be set to NULL. */
  1618. } NV_ENC_PIC_PARAMS_H264;
  1619. /**
  1620. * \struct _NV_ENC_PIC_PARAMS_HEVC
  1621. * HEVC specific enc pic params. sent on a per frame basis.
  1622. */
  1623. typedef struct _NV_ENC_PIC_PARAMS_HEVC
  1624. {
  1625. uint32_t displayPOCSyntax; /**< [in]: Specifies the display POC syntax This is required to be set if client is handling the picture type decision. */
  1626. uint32_t refPicFlag; /**< [in]: Set to 1 for a reference picture. This is ignored if NV_ENC_INITIALIZE_PARAMS::enablePTD is set to 1. */
  1627. uint32_t temporalId; /**< [in]: Specifies the temporal id of the picture */
  1628. uint32_t forceIntraRefreshWithFrameCnt; /**< [in]: Forces an intra refresh with duration equal to intraRefreshFrameCnt.
  1629. When outputRecoveryPointSEI is set this is value is used for recovery_frame_cnt in recovery point SEI message
  1630. forceIntraRefreshWithFrameCnt cannot be used if B frames are used in the GOP structure specified */
  1631. 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.
  1632. NV_ENC_INITIALIZE_PARAMS::enableConstrainedEncoding should be set to 1 */
  1633. uint32_t sliceModeDataUpdate :1; /**< [in]: Set to 1 if client wants to change the sliceModeData field to specify new sliceSize Parameter
  1634. When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting */
  1635. uint32_t ltrMarkFrame :1; /**< [in]: Set to 1 if client wants to mark this frame as LTR */
  1636. uint32_t ltrUseFrames :1; /**< [in]: Set to 1 if client allows encoding this frame using the LTR frames specified in ltrFrameBitmap */
  1637. uint32_t reservedBitFields :28; /**< [in]: Reserved bit fields and must be set to 0 */
  1638. 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.
  1639. Client should allocate array of size sliceModeData where sliceModeData is specified in field of ::_NV_ENC_CONFIG_H264
  1640. 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
  1641. all other array elements should be set to NV_ENC_SLICE_TYPE_DEFAULT */
  1642. 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 */
  1643. uint32_t sliceMode; /**< [in]: This parameter in conjunction with sliceModeData specifies the way in which the picture is divided into slices
  1644. sliceMode = 0 CTU based slices, sliceMode = 1 Byte based slices, sliceMode = 2 CTU row based slices, sliceMode = 3, numSlices in Picture
  1645. When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting
  1646. When sliceMode == 0 and sliceModeData == 0 whole picture will be coded with one slice */
  1647. uint32_t sliceModeData; /**< [in]: Specifies the parameter needed for sliceMode. For:
  1648. sliceMode = 0, sliceModeData specifies # of CTUs in each slice (except last slice)
  1649. sliceMode = 1, sliceModeData specifies maximum # of bytes in each slice (except last slice)
  1650. sliceMode = 2, sliceModeData specifies # of CTU rows in each slice (except last slice)
  1651. sliceMode = 3, sliceModeData specifies number of slices in the picture. Driver will divide picture into slices optimally */
  1652. uint32_t ltrMarkFrameIdx; /**< [in]: Specifies the long term reference frame index to use for marking this frame as LTR.*/
  1653. uint32_t ltrUseFrameBitmap; /**< [in]: Specifies the associated bitmap of LTR frame indices to use when encoding this frame. */
  1654. uint32_t ltrUsageMode; /**< [in]: Not supported. Reserved for future use and must be set to 0. */
  1655. uint32_t seiPayloadArrayCnt; /**< [in]: Specifies the number of elements allocated in seiPayloadArray array. */
  1656. uint32_t reserved; /**< [in]: Reserved and must be set to 0. */
  1657. NV_ENC_SEI_PAYLOAD* seiPayloadArray; /**< [in]: Array of SEI payloads which will be inserted for this frame. */
  1658. uint32_t reserved2 [244]; /**< [in]: Reserved and must be set to 0. */
  1659. void* reserved3[61]; /**< [in]: Reserved and must be set to NULL. */
  1660. } NV_ENC_PIC_PARAMS_HEVC;
  1661. /**
  1662. * Codec specific per-picture encoding parameters.
  1663. */
  1664. typedef union _NV_ENC_CODEC_PIC_PARAMS
  1665. {
  1666. NV_ENC_PIC_PARAMS_H264 h264PicParams; /**< [in]: H264 encode picture params. */
  1667. NV_ENC_PIC_PARAMS_HEVC hevcPicParams; /**< [in]: HEVC encode picture params. */
  1668. uint32_t reserved[256]; /**< [in]: Reserved and must be set to 0. */
  1669. } NV_ENC_CODEC_PIC_PARAMS;
  1670. /**
  1671. * \struct _NV_ENC_PIC_PARAMS
  1672. * Encoding parameters that need to be sent on a per frame basis.
  1673. */
  1674. typedef struct _NV_ENC_PIC_PARAMS
  1675. {
  1676. uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_PIC_PARAMS_VER. */
  1677. uint32_t inputWidth; /**< [in]: Specifies the input frame width */
  1678. uint32_t inputHeight; /**< [in]: Specifies the input frame height */
  1679. uint32_t inputPitch; /**< [in]: Specifies the input buffer pitch. If pitch value is not known, set this to inputWidth. */
  1680. uint32_t encodePicFlags; /**< [in]: Specifies bit-wise OR of encode picture flags. See ::NV_ENC_PIC_FLAGS enum. */
  1681. uint32_t frameIdx; /**< [in]: Specifies the frame index associated with the input frame [optional]. */
  1682. uint64_t inputTimeStamp; /**< [in]: Specifies opaque data which is associated with the encoded frame, but not actually encoded in the output bitstream.
  1683. This opaque data can be used later to uniquely refer to the corresponding encoded frame. For example, it can be used
  1684. for identifying the frame to be invalidated in the reference picture buffer, if lost at the client. */
  1685. uint64_t inputDuration; /**< [in]: Specifies duration of the input picture */
  1686. NV_ENC_INPUT_PTR inputBuffer; /**< [in]: Specifies the input buffer pointer. Client must use a pointer obtained from ::NvEncCreateInputBuffer() or ::NvEncMapInputResource() APIs.*/
  1687. NV_ENC_OUTPUT_PTR outputBitstream; /**< [in]: Specifies the output buffer pointer.
  1688. If NV_ENC_INITIALIZE_PARAMS::enableOutputInVidmem is set to 0, specifies the pointer to output buffer. Client should use a pointer obtained from ::NvEncCreateBitstreamBuffer() API.
  1689. If NV_ENC_INITIALIZE_PARAMS::enableOutputInVidmem is set to 1, client should allocate buffer in video memory for NV_ENC_ENCODE_OUT_PARAMS struct and encoded bitstream data. Client
  1690. should use a pointer obtained from ::NvEncMapInputResource() API, when mapping this output buffer and assign it to NV_ENC_PIC_PARAMS::outputBitstream.
  1691. First 256 bytes of this buffer should be interpreted as NV_ENC_ENCODE_OUT_PARAMS struct followed by encoded bitstream data. Recommended size for output buffer is sum of size of
  1692. NV_ENC_ENCODE_OUT_PARAMS struct and twice the input frame size for lower resolution eg. CIF and 1.5 times the input frame size for higher resolutions. If encoded bitstream size is
  1693. greater than the allocated buffer size for encoded bitstream, then the output buffer will have encoded bitstream data equal to buffer size. All CUDA operations on this buffer must use
  1694. the default stream. */
  1695. void* completionEvent; /**< [in]: Specifies an event to be signaled on completion of encoding of this Frame [only if operating in Asynchronous mode]. Each output buffer should be associated with a distinct event pointer. */
  1696. NV_ENC_BUFFER_FORMAT bufferFmt; /**< [in]: Specifies the input buffer format. */
  1697. NV_ENC_PIC_STRUCT pictureStruct; /**< [in]: Specifies structure of the input picture. */
  1698. 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. */
  1699. NV_ENC_CODEC_PIC_PARAMS codecPicParams; /**< [in]: Specifies the codec specific per-picture encoding parameters. */
  1700. 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.
  1701. The candidate count in NV_ENC_PIC_PARAMS::meHintCountsPerBlock[lx] must never exceed NV_ENC_INITIALIZE_PARAMS::maxMEHintCountsPerBlock[lx] provided during encoder initialization. */
  1702. NVENC_EXTERNAL_ME_HINT *meExternalHints; /**< [in]: Specifies the pointer to ME external hints for the current frame. The size of ME hint buffer should be equal to number of macroblocks * the total number of candidates per macroblock.
  1703. The total number of candidates per MB per direction = 1*meHintCountsPerBlock[Lx].numCandsPerBlk16x16 + 2*meHintCountsPerBlock[Lx].numCandsPerBlk16x8 + 2*meHintCountsPerBlock[Lx].numCandsPerBlk8x8
  1704. + 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) */
  1705. uint32_t reserved1[6]; /**< [in]: Reserved and must be set to 0 */
  1706. void* reserved2[2]; /**< [in]: Reserved and must be set to NULL */
  1707. int8_t *qpDeltaMap; /**< [in]: Specifies the pointer to signed byte array containing value per MB for H264 and per CTB for HEVC in raster scan order for the current picture, which will be interpreted depending on NV_ENC_RC_PARAMS::qpMapMode.
  1708. If NV_ENC_RC_PARAMS::qpMapMode is NV_ENC_QP_MAP_DELTA, qpDeltaMap specifies QP modifier per MB for H264 and per CTB for HEVC. This QP modifier will be applied on top of the QP chosen by rate control.
  1709. If NV_ENC_RC_PARAMS::qpMapMode is NV_ENC_QP_MAP_EMPHASIS, qpDeltaMap specifies Emphasis Level Map per MB for H264. This level value along with QP chosen by rate control is used to
  1710. compute the QP modifier, which in turn is applied on top of QP chosen by rate control.
  1711. If NV_ENC_RC_PARAMS::qpMapMode is NV_ENC_QP_MAP_DISABLED, value in qpDeltaMap will be ignored.*/
  1712. uint32_t qpDeltaMapSize; /**< [in]: Specifies the size in bytes of qpDeltaMap surface allocated by client and pointed to by NV_ENC_PIC_PARAMS::qpDeltaMap. Surface (array) should be picWidthInMbs * picHeightInMbs for H264 and picWidthInCtbs * picHeightInCtbs for HEVC */
  1713. uint32_t reservedBitFields; /**< [in]: Reserved bitfields and must be set to 0 */
  1714. 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.
  1715. If not set, will internally infer distance of 1. Ignored for NV_ENC_INITALIZE_PARAMS::enablePTD = 0 */
  1716. NV_ENC_INPUT_PTR alphaBuffer; /**< [in]: Specifies the input alpha buffer pointer. Client must use a pointer obtained from ::NvEncCreateInputBuffer() or ::NvEncMapInputResource() APIs.
  1717. Applicable only when encoding hevc with alpha layer is enabled. */
  1718. uint32_t reserved3[286]; /**< [in]: Reserved and must be set to 0 */
  1719. void* reserved4[59]; /**< [in]: Reserved and must be set to NULL */
  1720. } NV_ENC_PIC_PARAMS;
  1721. /** Macro for constructing the version field of ::_NV_ENC_PIC_PARAMS */
  1722. #define NV_ENC_PIC_PARAMS_VER (NVENCAPI_STRUCT_VERSION(4) | ( 1<<31 ))
  1723. /**
  1724. * \struct _NV_ENC_MEONLY_PARAMS
  1725. * MEOnly parameters that need to be sent on a per motion estimation basis.
  1726. * NV_ENC_MEONLY_PARAMS::meExternalHints is supported for H264 only.
  1727. */
  1728. typedef struct _NV_ENC_MEONLY_PARAMS
  1729. {
  1730. uint32_t version; /**< [in]: Struct version. Must be set to NV_ENC_MEONLY_PARAMS_VER.*/
  1731. uint32_t inputWidth; /**< [in]: Specifies the input frame width */
  1732. uint32_t inputHeight; /**< [in]: Specifies the input frame height */
  1733. NV_ENC_INPUT_PTR inputBuffer; /**< [in]: Specifies the input buffer pointer. Client must use a pointer obtained from NvEncCreateInputBuffer() or NvEncMapInputResource() APIs. */
  1734. NV_ENC_INPUT_PTR referenceFrame; /**< [in]: Specifies the reference frame pointer */
  1735. NV_ENC_OUTPUT_PTR mvBuffer; /**< [in]: Specifies the output buffer pointer.
  1736. If NV_ENC_INITIALIZE_PARAMS::enableOutputInVidmem is set to 0, specifies the pointer to motion vector data buffer allocated by NvEncCreateMVBuffer.
  1737. Client must lock mvBuffer using ::NvEncLockBitstream() API to get the motion vector data.
  1738. If NV_ENC_INITIALIZE_PARAMS::enableOutputInVidmem is set to 1, client should allocate buffer in video memory for storing the motion vector data. The size of this buffer must
  1739. be equal to total number of macroblocks multiplied by size of NV_ENC_H264_MV_DATA struct. Client should use a pointer obtained from ::NvEncMapInputResource() API, when mapping this
  1740. output buffer and assign it to NV_ENC_MEONLY_PARAMS::mvBuffer. All CUDA operations on this buffer must use the default stream. */
  1741. NV_ENC_BUFFER_FORMAT bufferFmt; /**< [in]: Specifies the input buffer format. */
  1742. void* completionEvent; /**< [in]: Specifies an event to be signaled on completion of motion estimation
  1743. of this Frame [only if operating in Asynchronous mode].
  1744. Each output buffer should be associated with a distinct event pointer. */
  1745. uint32_t viewID; /**< [in]: Specifies left or right viewID if NV_ENC_CONFIG_H264_MEONLY::bStereoEnable is set.
  1746. viewID can be 0,1 if bStereoEnable is set, 0 otherwise. */
  1747. NVENC_EXTERNAL_ME_HINT_COUNTS_PER_BLOCKTYPE
  1748. meHintCountsPerBlock[2]; /**< [in]: Specifies the number of hint candidates per block for the current frame. meHintCountsPerBlock[0] is for L0 predictors.
  1749. The candidate count in NV_ENC_PIC_PARAMS::meHintCountsPerBlock[lx] must never exceed NV_ENC_INITIALIZE_PARAMS::maxMEHintCountsPerBlock[lx] provided during encoder initialization. */
  1750. NVENC_EXTERNAL_ME_HINT *meExternalHints; /**< [in]: Specifies the pointer to ME external hints for the current frame. The size of ME hint buffer should be equal to number of macroblocks * the total number of candidates per macroblock.
  1751. The total number of candidates per MB per direction = 1*meHintCountsPerBlock[Lx].numCandsPerBlk16x16 + 2*meHintCountsPerBlock[Lx].numCandsPerBlk16x8 + 2*meHintCountsPerBlock[Lx].numCandsPerBlk8x8
  1752. + 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) */
  1753. uint32_t reserved1[243]; /**< [in]: Reserved and must be set to 0 */
  1754. void* reserved2[59]; /**< [in]: Reserved and must be set to NULL */
  1755. } NV_ENC_MEONLY_PARAMS;
  1756. /** NV_ENC_MEONLY_PARAMS struct version*/
  1757. #define NV_ENC_MEONLY_PARAMS_VER NVENCAPI_STRUCT_VERSION(3)
  1758. /**
  1759. * \struct _NV_ENC_LOCK_BITSTREAM
  1760. * Bitstream buffer lock parameters.
  1761. */
  1762. typedef struct _NV_ENC_LOCK_BITSTREAM
  1763. {
  1764. uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_LOCK_BITSTREAM_VER. */
  1765. 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. */
  1766. uint32_t ltrFrame :1; /**< [out]: Flag indicating this frame is marked as LTR frame */
  1767. uint32_t getRCStats :1; /**< [in]: If this flag is set then lockBitstream call will add additional intra-inter MB count and average MVX, MVY */
  1768. uint32_t reservedBitFields :29; /**< [in]: Reserved bit fields and must be set to 0 */
  1769. void* outputBitstream; /**< [in]: Pointer to the bitstream buffer being locked. */
  1770. 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. */
  1771. uint32_t frameIdx; /**< [out]: Frame no. for which the bitstream is being retrieved. */
  1772. uint32_t hwEncodeStatus; /**< [out]: The NvEncodeAPI interface status for the locked picture. */
  1773. uint32_t numSlices; /**< [out]: Number of slices in the encoded picture. Will be reported only if NV_ENC_INITIALIZE_PARAMS::reportSliceOffsets set to 1. */
  1774. uint32_t bitstreamSizeInBytes; /**< [out]: Actual number of bytes generated and copied to the memory pointed by bitstreamBufferPtr.
  1775. When HEVC alpha layer encoding is enabled, this field reports the total encoded size in bytes i.e it is the encoded size of the base plus the alpha layer. */
  1776. uint64_t outputTimeStamp; /**< [out]: Presentation timestamp associated with the encoded output. */
  1777. uint64_t outputDuration; /**< [out]: Presentation duration associates with the encoded output. */
  1778. void* bitstreamBufferPtr; /**< [out]: Pointer to the generated output bitstream.
  1779. For MEOnly mode _NV_ENC_LOCK_BITSTREAM::bitstreamBufferPtr should be typecast to
  1780. NV_ENC_H264_MV_DATA/NV_ENC_HEVC_MV_DATA pointer respectively for H264/HEVC */
  1781. NV_ENC_PIC_TYPE pictureType; /**< [out]: Picture type of the encoded picture. */
  1782. NV_ENC_PIC_STRUCT pictureStruct; /**< [out]: Structure of the generated output picture. */
  1783. uint32_t frameAvgQP; /**< [out]: Average QP of the frame. */
  1784. uint32_t frameSatd; /**< [out]: Total SATD cost for whole frame. */
  1785. uint32_t ltrFrameIdx; /**< [out]: Frame index associated with this LTR frame. */
  1786. 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. */
  1787. uint32_t reserved[13]; /**< [in]: Reserved and must be set to 0 */
  1788. uint32_t intraMBCount; /**< [out]: For H264, Number of Intra MBs in the encoded frame. For HEVC, Number of Intra CTBs in the encoded frame. Supported only if _NV_ENC_LOCK_BITSTREAM::getRCStats set to 1. */
  1789. uint32_t interMBCount; /**< [out]: For H264, Number of Inter MBs in the encoded frame, includes skip MBs. For HEVC, Number of Inter CTBs in the encoded frame. Supported only if _NV_ENC_LOCK_BITSTREAM::getRCStats set to 1. */
  1790. int32_t averageMVX; /**< [out]: Average Motion Vector in X direction for the encoded frame. Supported only if _NV_ENC_LOCK_BITSTREAM::getRCStats set to 1. */
  1791. int32_t averageMVY; /**< [out]: Average Motion Vector in y direction for the encoded frame. Supported only if _NV_ENC_LOCK_BITSTREAM::getRCStats set to 1. */
  1792. uint32_t alphaLayerSizeInBytes; /**< [out]: Number of bytes generated for the alpha layer in the encoded output. Applicable only when HEVC with alpha encoding is enabled. */
  1793. uint32_t reserved1[218]; /**< [in]: Reserved and must be set to 0 */
  1794. void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
  1795. } NV_ENC_LOCK_BITSTREAM;
  1796. /** Macro for constructing the version field of ::_NV_ENC_LOCK_BITSTREAM */
  1797. #define NV_ENC_LOCK_BITSTREAM_VER NVENCAPI_STRUCT_VERSION(1)
  1798. /**
  1799. * \struct _NV_ENC_LOCK_INPUT_BUFFER
  1800. * Uncompressed Input Buffer lock parameters.
  1801. */
  1802. typedef struct _NV_ENC_LOCK_INPUT_BUFFER
  1803. {
  1804. uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_LOCK_INPUT_BUFFER_VER. */
  1805. 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. */
  1806. uint32_t reservedBitFields :31; /**< [in]: Reserved bitfields and must be set to 0 */
  1807. 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. */
  1808. void* bufferDataPtr; /**< [out]: Pointed to the locked input buffer data. Client can only access input buffer using the \p bufferDataPtr. */
  1809. uint32_t pitch; /**< [out]: Pitch of the locked input buffer. */
  1810. uint32_t reserved1[251]; /**< [in]: Reserved and must be set to 0 */
  1811. void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
  1812. } NV_ENC_LOCK_INPUT_BUFFER;
  1813. /** Macro for constructing the version field of ::_NV_ENC_LOCK_INPUT_BUFFER */
  1814. #define NV_ENC_LOCK_INPUT_BUFFER_VER NVENCAPI_STRUCT_VERSION(1)
  1815. /**
  1816. * \struct _NV_ENC_MAP_INPUT_RESOURCE
  1817. * Map an input resource to a Nvidia Encoder Input Buffer
  1818. */
  1819. typedef struct _NV_ENC_MAP_INPUT_RESOURCE
  1820. {
  1821. uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_MAP_INPUT_RESOURCE_VER. */
  1822. uint32_t subResourceIndex; /**< [in]: Deprecated. Do not use. */
  1823. void* inputResource; /**< [in]: Deprecated. Do not use. */
  1824. NV_ENC_REGISTERED_PTR registeredResource; /**< [in]: The Registered resource handle obtained by calling NvEncRegisterInputResource. */
  1825. 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. */
  1826. 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. */
  1827. uint32_t reserved1[251]; /**< [in]: Reserved and must be set to 0. */
  1828. void* reserved2[63]; /**< [in]: Reserved and must be set to NULL */
  1829. } NV_ENC_MAP_INPUT_RESOURCE;
  1830. /** Macro for constructing the version field of ::_NV_ENC_MAP_INPUT_RESOURCE */
  1831. #define NV_ENC_MAP_INPUT_RESOURCE_VER NVENCAPI_STRUCT_VERSION(4)
  1832. /**
  1833. * \struct _NV_ENC_INPUT_RESOURCE_OPENGL_TEX
  1834. * NV_ENC_REGISTER_RESOURCE::resourceToRegister must be a pointer to a variable of this type,
  1835. * when NV_ENC_REGISTER_RESOURCE::resourceType is NV_ENC_INPUT_RESOURCE_TYPE_OPENGL_TEX
  1836. */
  1837. typedef struct _NV_ENC_INPUT_RESOURCE_OPENGL_TEX
  1838. {
  1839. uint32_t texture; /**< [in]: The name of the texture to be used. */
  1840. uint32_t target; /**< [in]: Accepted values are GL_TEXTURE_RECTANGLE and GL_TEXTURE_2D. */
  1841. } NV_ENC_INPUT_RESOURCE_OPENGL_TEX;
  1842. /**
  1843. * \struct _NV_ENC_REGISTER_RESOURCE
  1844. * Register a resource for future use with the Nvidia Video Encoder Interface.
  1845. */
  1846. typedef struct _NV_ENC_REGISTER_RESOURCE
  1847. {
  1848. uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_REGISTER_RESOURCE_VER. */
  1849. NV_ENC_INPUT_RESOURCE_TYPE resourceType; /**< [in]: Specifies the type of resource to be registered.
  1850. Supported values are
  1851. ::NV_ENC_INPUT_RESOURCE_TYPE_DIRECTX,
  1852. ::NV_ENC_INPUT_RESOURCE_TYPE_CUDADEVICEPTR,
  1853. ::NV_ENC_INPUT_RESOURCE_TYPE_OPENGL_TEX */
  1854. uint32_t width; /**< [in]: Input frame width. */
  1855. uint32_t height; /**< [in]: Input frame height. */
  1856. uint32_t pitch; /**< [in]: Input buffer pitch.
  1857. For ::NV_ENC_INPUT_RESOURCE_TYPE_DIRECTX resources, set this to 0.
  1858. For ::NV_ENC_INPUT_RESOURCE_TYPE_CUDADEVICEPTR resources, set this to
  1859. the pitch as obtained from cuMemAllocPitch(), or to the width in
  1860. bytes (if this resource was created by using cuMemAlloc()). This
  1861. value must be a multiple of 4.
  1862. For ::NV_ENC_INPUT_RESOURCE_TYPE_CUDAARRAY resources, set this to the
  1863. width of the allocation in bytes (i.e.
  1864. CUDA_ARRAY3D_DESCRIPTOR::Width * CUDA_ARRAY3D_DESCRIPTOR::NumChannels).
  1865. For ::NV_ENC_INPUT_RESOURCE_TYPE_OPENGL_TEX resources, set this to the
  1866. texture width multiplied by the number of components in the texture
  1867. format. */
  1868. uint32_t subResourceIndex; /**< [in]: Subresource Index of the DirectX resource to be registered. Should be set to 0 for other interfaces. */
  1869. void* resourceToRegister; /**< [in]: Handle to the resource that is being registered. */
  1870. NV_ENC_REGISTERED_PTR registeredResource; /**< [out]: Registered resource handle. This should be used in future interactions with the Nvidia Video Encoder Interface. */
  1871. NV_ENC_BUFFER_FORMAT bufferFormat; /**< [in]: Buffer format of resource to be registered. */
  1872. NV_ENC_BUFFER_USAGE bufferUsage; /**< [in]: Usage of resource to be registered. */
  1873. uint32_t reserved1[247]; /**< [in]: Reserved and must be set to 0. */
  1874. void* reserved2[62]; /**< [in]: Reserved and must be set to NULL. */
  1875. } NV_ENC_REGISTER_RESOURCE;
  1876. /** Macro for constructing the version field of ::_NV_ENC_REGISTER_RESOURCE */
  1877. #define NV_ENC_REGISTER_RESOURCE_VER NVENCAPI_STRUCT_VERSION(3)
  1878. /**
  1879. * \struct _NV_ENC_STAT
  1880. * Encode Stats structure.
  1881. */
  1882. typedef struct _NV_ENC_STAT
  1883. {
  1884. uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_STAT_VER. */
  1885. uint32_t reserved; /**< [in]: Reserved and must be set to 0 */
  1886. NV_ENC_OUTPUT_PTR outputBitStream; /**< [out]: Specifies the pointer to output bitstream. */
  1887. uint32_t bitStreamSize; /**< [out]: Size of generated bitstream in bytes. */
  1888. uint32_t picType; /**< [out]: Picture type of encoded picture. See ::NV_ENC_PIC_TYPE. */
  1889. uint32_t lastValidByteOffset; /**< [out]: Offset of last valid bytes of completed bitstream */
  1890. uint32_t sliceOffsets[16]; /**< [out]: Offsets of each slice */
  1891. uint32_t picIdx; /**< [out]: Picture number */
  1892. uint32_t frameAvgQP; /**< [out]: Average QP of the frame. */
  1893. uint32_t ltrFrame :1; /**< [out]: Flag indicating this frame is marked as LTR frame */
  1894. uint32_t reservedBitFields :31; /**< [in]: Reserved bit fields and must be set to 0 */
  1895. uint32_t ltrFrameIdx; /**< [out]: Frame index associated with this LTR frame. */
  1896. uint32_t intraMBCount; /**< [out]: For H264, Number of Intra MBs in the encoded frame. For HEVC, Number of Intra CTBs in the encoded frame. */
  1897. uint32_t interMBCount; /**< [out]: For H264, Number of Inter MBs in the encoded frame, includes skip MBs. For HEVC, Number of Inter CTBs in the encoded frame. */
  1898. int32_t averageMVX; /**< [out]: Average Motion Vector in X direction for the encoded frame. */
  1899. int32_t averageMVY; /**< [out]: Average Motion Vector in y direction for the encoded frame. */
  1900. uint32_t reserved1[226]; /**< [in]: Reserved and must be set to 0 */
  1901. void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
  1902. } NV_ENC_STAT;
  1903. /** Macro for constructing the version field of ::_NV_ENC_STAT */
  1904. #define NV_ENC_STAT_VER NVENCAPI_STRUCT_VERSION(1)
  1905. /**
  1906. * \struct _NV_ENC_SEQUENCE_PARAM_PAYLOAD
  1907. * Sequence and picture paramaters payload.
  1908. */
  1909. typedef struct _NV_ENC_SEQUENCE_PARAM_PAYLOAD
  1910. {
  1911. uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_INITIALIZE_PARAMS_VER. */
  1912. uint32_t inBufferSize; /**< [in]: Specifies the size of the spsppsBuffer provided by the client */
  1913. uint32_t spsId; /**< [in]: Specifies the SPS id to be used in sequence header. Default value is 0. */
  1914. uint32_t ppsId; /**< [in]: Specifies the PPS id to be used in picture header. Default value is 0. */
  1915. void* spsppsBuffer; /**< [in]: Specifies bitstream header pointer of size NV_ENC_SEQUENCE_PARAM_PAYLOAD::inBufferSize.
  1916. It is the client's responsibility to manage this memory. */
  1917. uint32_t* outSPSPPSPayloadSize; /**< [out]: Size of the sequence and picture header in bytes. */
  1918. uint32_t reserved [250]; /**< [in]: Reserved and must be set to 0 */
  1919. void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
  1920. } NV_ENC_SEQUENCE_PARAM_PAYLOAD;
  1921. /** Macro for constructing the version field of ::_NV_ENC_SEQUENCE_PARAM_PAYLOAD */
  1922. #define NV_ENC_SEQUENCE_PARAM_PAYLOAD_VER NVENCAPI_STRUCT_VERSION(1)
  1923. /**
  1924. * Event registration/unregistration parameters.
  1925. */
  1926. typedef struct _NV_ENC_EVENT_PARAMS
  1927. {
  1928. uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_EVENT_PARAMS_VER. */
  1929. uint32_t reserved; /**< [in]: Reserved and must be set to 0 */
  1930. void* completionEvent; /**< [in]: Handle to event to be registered/unregistered with the NvEncodeAPI interface. */
  1931. uint32_t reserved1[253]; /**< [in]: Reserved and must be set to 0 */
  1932. void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
  1933. } NV_ENC_EVENT_PARAMS;
  1934. /** Macro for constructing the version field of ::_NV_ENC_EVENT_PARAMS */
  1935. #define NV_ENC_EVENT_PARAMS_VER NVENCAPI_STRUCT_VERSION(1)
  1936. /**
  1937. * Encoder Session Creation parameters
  1938. */
  1939. typedef struct _NV_ENC_OPEN_ENCODE_SESSIONEX_PARAMS
  1940. {
  1941. uint32_t version; /**< [in]: Struct version. Must be set to ::NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS_VER. */
  1942. NV_ENC_DEVICE_TYPE deviceType; /**< [in]: Specified the device Type */
  1943. void* device; /**< [in]: Pointer to client device. */
  1944. void* reserved; /**< [in]: Reserved and must be set to 0. */
  1945. uint32_t apiVersion; /**< [in]: API version. Should be set to NVENCAPI_VERSION. */
  1946. uint32_t reserved1[253]; /**< [in]: Reserved and must be set to 0 */
  1947. void* reserved2[64]; /**< [in]: Reserved and must be set to NULL */
  1948. } NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS;
  1949. /** Macro for constructing the version field of ::_NV_ENC_OPEN_ENCODE_SESSIONEX_PARAMS */
  1950. #define NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS_VER NVENCAPI_STRUCT_VERSION(1)
  1951. /** @} */ /* END ENCODER_STRUCTURE */
  1952. /**
  1953. * \addtogroup ENCODE_FUNC NvEncodeAPI Functions
  1954. * @{
  1955. */
  1956. // NvEncOpenEncodeSession
  1957. /**
  1958. * \brief Opens an encoding session.
  1959. *
  1960. * Deprecated.
  1961. *
  1962. * \return
  1963. * ::NV_ENC_ERR_INVALID_CALL\n
  1964. *
  1965. */
  1966. NVENCSTATUS NVENCAPI NvEncOpenEncodeSession (void* device, uint32_t deviceType, void** encoder);
  1967. // NvEncGetEncodeGuidCount
  1968. /**
  1969. * \brief Retrieves the number of supported encode GUIDs.
  1970. *
  1971. * The function returns the number of codec GUIDs supported by the NvEncodeAPI
  1972. * interface.
  1973. *
  1974. * \param [in] encoder
  1975. * Pointer to the NvEncodeAPI interface.
  1976. * \param [out] encodeGUIDCount
  1977. * Number of supported encode GUIDs.
  1978. *
  1979. * \return
  1980. * ::NV_ENC_SUCCESS \n
  1981. * ::NV_ENC_ERR_INVALID_PTR \n
  1982. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  1983. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  1984. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  1985. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  1986. * ::NV_ENC_ERR_INVALID_PARAM \n
  1987. * ::NV_ENC_ERR_GENERIC \n
  1988. *
  1989. */
  1990. NVENCSTATUS NVENCAPI NvEncGetEncodeGUIDCount (void* encoder, uint32_t* encodeGUIDCount);
  1991. // NvEncGetEncodeGUIDs
  1992. /**
  1993. * \brief Retrieves an array of supported encoder codec GUIDs.
  1994. *
  1995. * The function returns an array of codec GUIDs supported by the NvEncodeAPI interface.
  1996. * The client must allocate an array where the NvEncodeAPI interface can
  1997. * fill the supported GUIDs and pass the pointer in \p *GUIDs parameter.
  1998. * The size of the array can be determined by using ::NvEncGetEncodeGUIDCount() API.
  1999. * The Nvidia Encoding interface returns the number of codec GUIDs it has actually
  2000. * filled in the GUID array in the \p GUIDCount parameter.
  2001. *
  2002. * \param [in] encoder
  2003. * Pointer to the NvEncodeAPI interface.
  2004. * \param [in] guidArraySize
  2005. * Number of GUIDs to retrieved. Should be set to the number retrieved using
  2006. * ::NvEncGetEncodeGUIDCount.
  2007. * \param [out] GUIDs
  2008. * Array of supported Encode GUIDs.
  2009. * \param [out] GUIDCount
  2010. * Number of supported Encode GUIDs.
  2011. *
  2012. * \return
  2013. * ::NV_ENC_SUCCESS \n
  2014. * ::NV_ENC_ERR_INVALID_PTR \n
  2015. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2016. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2017. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2018. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2019. * ::NV_ENC_ERR_INVALID_PARAM \n
  2020. * ::NV_ENC_ERR_GENERIC \n
  2021. *
  2022. */
  2023. NVENCSTATUS NVENCAPI NvEncGetEncodeGUIDs (void* encoder, GUID* GUIDs, uint32_t guidArraySize, uint32_t* GUIDCount);
  2024. // NvEncGetEncodeProfileGuidCount
  2025. /**
  2026. * \brief Retrieves the number of supported profile GUIDs.
  2027. *
  2028. * The function returns the number of profile GUIDs supported for a given codec.
  2029. * The client must first enumerate the codec GUIDs supported by the NvEncodeAPI
  2030. * interface. After determining the codec GUID, it can query the NvEncodeAPI
  2031. * interface to determine the number of profile GUIDs supported for a particular
  2032. * codec GUID.
  2033. *
  2034. * \param [in] encoder
  2035. * Pointer to the NvEncodeAPI interface.
  2036. * \param [in] encodeGUID
  2037. * The codec GUID for which the profile GUIDs are being enumerated.
  2038. * \param [out] encodeProfileGUIDCount
  2039. * Number of encode profiles supported for the given encodeGUID.
  2040. *
  2041. * \return
  2042. * ::NV_ENC_SUCCESS \n
  2043. * ::NV_ENC_ERR_INVALID_PTR \n
  2044. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2045. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2046. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2047. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2048. * ::NV_ENC_ERR_INVALID_PARAM \n
  2049. * ::NV_ENC_ERR_GENERIC \n
  2050. *
  2051. */
  2052. NVENCSTATUS NVENCAPI NvEncGetEncodeProfileGUIDCount (void* encoder, GUID encodeGUID, uint32_t* encodeProfileGUIDCount);
  2053. // NvEncGetEncodeProfileGUIDs
  2054. /**
  2055. * \brief Retrieves an array of supported encode profile GUIDs.
  2056. *
  2057. * The function returns an array of supported profile GUIDs for a particular
  2058. * codec GUID. The client must allocate an array where the NvEncodeAPI interface
  2059. * can populate the profile GUIDs. The client can determine the array size using
  2060. * ::NvEncGetEncodeProfileGUIDCount() API. The client must also validiate that the
  2061. * NvEncodeAPI interface supports the GUID the client wants to pass as \p encodeGUID
  2062. * parameter.
  2063. *
  2064. * \param [in] encoder
  2065. * Pointer to the NvEncodeAPI interface.
  2066. * \param [in] encodeGUID
  2067. * The encode GUID whose profile GUIDs are being enumerated.
  2068. * \param [in] guidArraySize
  2069. * Number of GUIDs to be retrieved. Should be set to the number retrieved using
  2070. * ::NvEncGetEncodeProfileGUIDCount.
  2071. * \param [out] profileGUIDs
  2072. * Array of supported Encode Profile GUIDs
  2073. * \param [out] GUIDCount
  2074. * Number of valid encode profile GUIDs in \p profileGUIDs array.
  2075. *
  2076. * \return
  2077. * ::NV_ENC_SUCCESS \n
  2078. * ::NV_ENC_ERR_INVALID_PTR \n
  2079. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2080. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2081. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2082. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2083. * ::NV_ENC_ERR_INVALID_PARAM \n
  2084. * ::NV_ENC_ERR_GENERIC \n
  2085. *
  2086. */
  2087. NVENCSTATUS NVENCAPI NvEncGetEncodeProfileGUIDs (void* encoder, GUID encodeGUID, GUID* profileGUIDs, uint32_t guidArraySize, uint32_t* GUIDCount);
  2088. // NvEncGetInputFormatCount
  2089. /**
  2090. * \brief Retrieve the number of supported Input formats.
  2091. *
  2092. * The function returns the number of supported input formats. The client must
  2093. * query the NvEncodeAPI interface to determine the supported input formats
  2094. * before creating the input surfaces.
  2095. *
  2096. * \param [in] encoder
  2097. * Pointer to the NvEncodeAPI interface.
  2098. * \param [in] encodeGUID
  2099. * Encode GUID, corresponding to which the number of supported input formats
  2100. * is to be retrieved.
  2101. * \param [out] inputFmtCount
  2102. * Number of input formats supported for specified Encode GUID.
  2103. *
  2104. * \return
  2105. * ::NV_ENC_SUCCESS \n
  2106. * ::NV_ENC_ERR_INVALID_PTR \n
  2107. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2108. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2109. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2110. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2111. * ::NV_ENC_ERR_INVALID_PARAM \n
  2112. * ::NV_ENC_ERR_GENERIC \n
  2113. */
  2114. NVENCSTATUS NVENCAPI NvEncGetInputFormatCount (void* encoder, GUID encodeGUID, uint32_t* inputFmtCount);
  2115. // NvEncGetInputFormats
  2116. /**
  2117. * \brief Retrieves an array of supported Input formats
  2118. *
  2119. * Returns an array of supported input formats The client must use the input
  2120. * format to create input surface using ::NvEncCreateInputBuffer() API.
  2121. *
  2122. * \param [in] encoder
  2123. * Pointer to the NvEncodeAPI interface.
  2124. * \param [in] encodeGUID
  2125. * Encode GUID, corresponding to which the number of supported input formats
  2126. * is to be retrieved.
  2127. *\param [in] inputFmtArraySize
  2128. * Size input format count array passed in \p inputFmts.
  2129. *\param [out] inputFmts
  2130. * Array of input formats supported for this Encode GUID.
  2131. *\param [out] inputFmtCount
  2132. * The number of valid input format types returned by the NvEncodeAPI
  2133. * interface in \p inputFmts array.
  2134. *
  2135. * \return
  2136. * ::NV_ENC_SUCCESS \n
  2137. * ::NV_ENC_ERR_INVALID_PTR \n
  2138. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2139. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2140. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2141. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2142. * ::NV_ENC_ERR_INVALID_PARAM \n
  2143. * ::NV_ENC_ERR_GENERIC \n
  2144. *
  2145. */
  2146. NVENCSTATUS NVENCAPI NvEncGetInputFormats (void* encoder, GUID encodeGUID, NV_ENC_BUFFER_FORMAT* inputFmts, uint32_t inputFmtArraySize, uint32_t* inputFmtCount);
  2147. // NvEncGetEncodeCaps
  2148. /**
  2149. * \brief Retrieves the capability value for a specified encoder attribute.
  2150. *
  2151. * The function returns the capability value for a given encoder attribute. The
  2152. * client must validate the encodeGUID using ::NvEncGetEncodeGUIDs() API before
  2153. * calling this function. The encoder attribute being queried are enumerated in
  2154. * ::NV_ENC_CAPS_PARAM enum.
  2155. *
  2156. * \param [in] encoder
  2157. * Pointer to the NvEncodeAPI interface.
  2158. * \param [in] encodeGUID
  2159. * Encode GUID, corresponding to which the capability attribute is to be retrieved.
  2160. * \param [in] capsParam
  2161. * Used to specify attribute being queried. Refer ::NV_ENC_CAPS_PARAM for more
  2162. * details.
  2163. * \param [out] capsVal
  2164. * The value corresponding to the capability attribute being queried.
  2165. *
  2166. * \return
  2167. * ::NV_ENC_SUCCESS \n
  2168. * ::NV_ENC_ERR_INVALID_PTR \n
  2169. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2170. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2171. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2172. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2173. * ::NV_ENC_ERR_INVALID_PARAM \n
  2174. * ::NV_ENC_ERR_GENERIC \n
  2175. */
  2176. NVENCSTATUS NVENCAPI NvEncGetEncodeCaps (void* encoder, GUID encodeGUID, NV_ENC_CAPS_PARAM* capsParam, int* capsVal);
  2177. // NvEncGetEncodePresetCount
  2178. /**
  2179. * \brief Retrieves the number of supported preset GUIDs.
  2180. *
  2181. * The function returns the number of preset GUIDs available for a given codec.
  2182. * The client must validate the codec GUID using ::NvEncGetEncodeGUIDs() API
  2183. * before calling this function.
  2184. *
  2185. * \param [in] encoder
  2186. * Pointer to the NvEncodeAPI interface.
  2187. * \param [in] encodeGUID
  2188. * Encode GUID, corresponding to which the number of supported presets is to
  2189. * be retrieved.
  2190. * \param [out] encodePresetGUIDCount
  2191. * Receives the number of supported preset GUIDs.
  2192. *
  2193. * \return
  2194. * ::NV_ENC_SUCCESS \n
  2195. * ::NV_ENC_ERR_INVALID_PTR \n
  2196. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2197. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2198. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2199. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2200. * ::NV_ENC_ERR_INVALID_PARAM \n
  2201. * ::NV_ENC_ERR_GENERIC \n
  2202. *
  2203. */
  2204. NVENCSTATUS NVENCAPI NvEncGetEncodePresetCount (void* encoder, GUID encodeGUID, uint32_t* encodePresetGUIDCount);
  2205. // NvEncGetEncodePresetGUIDs
  2206. /**
  2207. * \brief Receives an array of supported encoder preset GUIDs.
  2208. *
  2209. * The function returns an array of encode preset GUIDs available for a given codec.
  2210. * The client can directly use one of the preset GUIDs based upon the use case
  2211. * or target device. The preset GUID chosen can be directly used in
  2212. * NV_ENC_INITIALIZE_PARAMS::presetGUID parameter to ::NvEncEncodePicture() API.
  2213. * Alternately client can also use the preset GUID to retrieve the encoding config
  2214. * parameters being used by NvEncodeAPI interface for that given preset, using
  2215. * ::NvEncGetEncodePresetConfig() API. It can then modify preset config parameters
  2216. * as per its use case and send it to NvEncodeAPI interface as part of
  2217. * NV_ENC_INITIALIZE_PARAMS::encodeConfig parameter for NvEncInitializeEncoder()
  2218. * API.
  2219. *
  2220. *
  2221. * \param [in] encoder
  2222. * Pointer to the NvEncodeAPI interface.
  2223. * \param [in] encodeGUID
  2224. * Encode GUID, corresponding to which the list of supported presets is to be
  2225. * retrieved.
  2226. * \param [in] guidArraySize
  2227. * Size of array of preset GUIDs passed in \p preset GUIDs
  2228. * \param [out] presetGUIDs
  2229. * Array of supported Encode preset GUIDs from the NvEncodeAPI interface
  2230. * to client.
  2231. * \param [out] encodePresetGUIDCount
  2232. * Receives the number of preset GUIDs returned by the NvEncodeAPI
  2233. * interface.
  2234. *
  2235. * \return
  2236. * ::NV_ENC_SUCCESS \n
  2237. * ::NV_ENC_ERR_INVALID_PTR \n
  2238. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2239. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2240. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2241. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2242. * ::NV_ENC_ERR_INVALID_PARAM \n
  2243. * ::NV_ENC_ERR_GENERIC \n
  2244. *
  2245. */
  2246. NVENCSTATUS NVENCAPI NvEncGetEncodePresetGUIDs (void* encoder, GUID encodeGUID, GUID* presetGUIDs, uint32_t guidArraySize, uint32_t* encodePresetGUIDCount);
  2247. // NvEncGetEncodePresetConfig
  2248. /**
  2249. * \brief Returns a preset config structure supported for given preset GUID.
  2250. *
  2251. * The function returns a preset config structure for a given preset GUID. Before
  2252. * using this function the client must enumerate the preset GUIDs available for
  2253. * a given codec. The preset config structure can be modified by the client depending
  2254. * upon its use case and can be then used to initialize the encoder using
  2255. * ::NvEncInitializeEncoder() API. The client can use this function only if it
  2256. * wants to modify the NvEncodeAPI preset configuration, otherwise it can
  2257. * directly use the preset GUID.
  2258. *
  2259. * \param [in] encoder
  2260. * Pointer to the NvEncodeAPI interface.
  2261. * \param [in] encodeGUID
  2262. * Encode GUID, corresponding to which the list of supported presets is to be
  2263. * retrieved.
  2264. * \param [in] presetGUID
  2265. * Preset GUID, corresponding to which the Encoding configurations is to be
  2266. * retrieved.
  2267. * \param [out] presetConfig
  2268. * The requested Preset Encoder Attribute set. Refer ::_NV_ENC_CONFIG for
  2269. * more details.
  2270. *
  2271. * \return
  2272. * ::NV_ENC_SUCCESS \n
  2273. * ::NV_ENC_ERR_INVALID_PTR \n
  2274. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2275. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2276. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2277. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2278. * ::NV_ENC_ERR_INVALID_PARAM \n
  2279. * ::NV_ENC_ERR_INVALID_VERSION \n
  2280. * ::NV_ENC_ERR_GENERIC \n
  2281. *
  2282. */
  2283. NVENCSTATUS NVENCAPI NvEncGetEncodePresetConfig (void* encoder, GUID encodeGUID, GUID presetGUID, NV_ENC_PRESET_CONFIG* presetConfig);
  2284. // NvEncGetEncodePresetConfigEx
  2285. /**
  2286. * \brief Returns a preset config structure supported for given preset GUID.
  2287. *
  2288. * The function returns a preset config structure for a given preset GUID and tuning info.
  2289. * NvEncGetEncodePresetConfigEx() API is not applicable to H264 and HEVC meonly mode.
  2290. * Before using this function the client must enumerate the preset GUIDs available for
  2291. * a given codec. The preset config structure can be modified by the client depending
  2292. * upon its use case and can be then used to initialize the encoder using
  2293. * ::NvEncInitializeEncoder() API. The client can use this function only if it
  2294. * wants to modify the NvEncodeAPI preset configuration, otherwise it can
  2295. * directly use the preset GUID.
  2296. *
  2297. * \param [in] encoder
  2298. * Pointer to the NvEncodeAPI interface.
  2299. * \param [in] encodeGUID
  2300. * Encode GUID, corresponding to which the list of supported presets is to be
  2301. * retrieved.
  2302. * \param [in] presetGUID
  2303. * Preset GUID, corresponding to which the Encoding configurations is to be
  2304. * retrieved.
  2305. * \param [in] tuningInfo
  2306. * tuning info, corresponding to which the Encoding configurations is to be
  2307. * retrieved.
  2308. * \param [out] presetConfig
  2309. * The requested Preset Encoder Attribute set. Refer ::_NV_ENC_CONFIG for
  2310. * more details.
  2311. *
  2312. * \return
  2313. * ::NV_ENC_SUCCESS \n
  2314. * ::NV_ENC_ERR_INVALID_PTR \n
  2315. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2316. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2317. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2318. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2319. * ::NV_ENC_ERR_INVALID_PARAM \n
  2320. * ::NV_ENC_ERR_INVALID_VERSION \n
  2321. * ::NV_ENC_ERR_GENERIC \n
  2322. *
  2323. */
  2324. NVENCSTATUS NVENCAPI NvEncGetEncodePresetConfigEx (void* encoder, GUID encodeGUID, GUID presetGUID, NV_ENC_TUNING_INFO tuningInfo, NV_ENC_PRESET_CONFIG* presetConfig);
  2325. // NvEncInitializeEncoder
  2326. /**
  2327. * \brief Initialize the encoder.
  2328. *
  2329. * This API must be used to initialize the encoder. The initialization parameter
  2330. * is passed using \p *createEncodeParams The client must send the following
  2331. * fields of the _NV_ENC_INITIALIZE_PARAMS structure with a valid value.
  2332. * - NV_ENC_INITIALIZE_PARAMS::encodeGUID
  2333. * - NV_ENC_INITIALIZE_PARAMS::encodeWidth
  2334. * - NV_ENC_INITIALIZE_PARAMS::encodeHeight
  2335. *
  2336. * The client can pass a preset GUID directly to the NvEncodeAPI interface using
  2337. * NV_ENC_INITIALIZE_PARAMS::presetGUID field. If the client doesn't pass
  2338. * NV_ENC_INITIALIZE_PARAMS::encodeConfig structure, the codec specific parameters
  2339. * will be selected based on the preset GUID. The preset GUID must have been
  2340. * validated by the client using ::NvEncGetEncodePresetGUIDs() API.
  2341. * If the client passes a custom ::_NV_ENC_CONFIG structure through
  2342. * NV_ENC_INITIALIZE_PARAMS::encodeConfig , it will override the codec specific parameters
  2343. * based on the preset GUID. It is recommended that even if the client passes a custom config,
  2344. * it should also send a preset GUID. In this case, the preset GUID passed by the client
  2345. * will not override any of the custom config parameters programmed by the client,
  2346. * it is only used as a hint by the NvEncodeAPI interface to determine certain encoder parameters
  2347. * which are not exposed to the client.
  2348. *
  2349. * There are two modes of operation for the encoder namely:
  2350. * - Asynchronous mode
  2351. * - Synchronous mode
  2352. *
  2353. * The client can select asynchronous or synchronous mode by setting the \p
  2354. * enableEncodeAsync field in ::_NV_ENC_INITIALIZE_PARAMS to 1 or 0 respectively.
  2355. *\par Asynchronous mode of operation:
  2356. * The Asynchronous mode can be enabled by setting NV_ENC_INITIALIZE_PARAMS::enableEncodeAsync to 1.
  2357. * The client operating in asynchronous mode must allocate completion event object
  2358. * for each output buffer and pass the completion event object in the
  2359. * ::NvEncEncodePicture() API. The client can create another thread and wait on
  2360. * the event object to be signaled by NvEncodeAPI interface on completion of the
  2361. * encoding process for the output frame. This should unblock the main thread from
  2362. * submitting work to the encoder. When the event is signaled the client can call
  2363. * NvEncodeAPI interfaces to copy the bitstream data using ::NvEncLockBitstream()
  2364. * API. This is the preferred mode of operation.
  2365. *
  2366. * NOTE: Asynchronous mode is not supported on Linux.
  2367. *
  2368. *\par Synchronous mode of operation:
  2369. * The client can select synchronous mode by setting NV_ENC_INITIALIZE_PARAMS::enableEncodeAsync to 0.
  2370. * The client working in synchronous mode can work in a single threaded or multi
  2371. * threaded mode. The client need not allocate any event objects. The client can
  2372. * only lock the bitstream data after NvEncodeAPI interface has returned
  2373. * ::NV_ENC_SUCCESS from encode picture. The NvEncodeAPI interface can return
  2374. * ::NV_ENC_ERR_NEED_MORE_INPUT error code from ::NvEncEncodePicture() API. The
  2375. * client must not lock the output buffer in such case but should send the next
  2376. * frame for encoding. The client must keep on calling ::NvEncEncodePicture() API
  2377. * until it returns ::NV_ENC_SUCCESS. \n
  2378. * The client must always lock the bitstream data in order in which it has submitted.
  2379. * This is true for both asynchronous and synchronous mode.
  2380. *
  2381. *\par Picture type decision:
  2382. * If the client is taking the picture type decision and it must disable the picture
  2383. * type decision module in NvEncodeAPI by setting NV_ENC_INITIALIZE_PARAMS::enablePTD
  2384. * to 0. In this case the client is required to send the picture in encoding
  2385. * order to NvEncodeAPI by doing the re-ordering for B frames. \n
  2386. * If the client doesn't want to take the picture type decision it can enable
  2387. * picture type decision module in the NvEncodeAPI interface by setting
  2388. * NV_ENC_INITIALIZE_PARAMS::enablePTD to 1 and send the input pictures in display
  2389. * order.
  2390. *
  2391. * \param [in] encoder
  2392. * Pointer to the NvEncodeAPI interface.
  2393. * \param [in] createEncodeParams
  2394. * Refer ::_NV_ENC_INITIALIZE_PARAMS for details.
  2395. *
  2396. * \return
  2397. * ::NV_ENC_SUCCESS \n
  2398. * ::NV_ENC_ERR_INVALID_PTR \n
  2399. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2400. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2401. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2402. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2403. * ::NV_ENC_ERR_INVALID_PARAM \n
  2404. * ::NV_ENC_ERR_INVALID_VERSION \n
  2405. * ::NV_ENC_ERR_GENERIC \n
  2406. *
  2407. */
  2408. NVENCSTATUS NVENCAPI NvEncInitializeEncoder (void* encoder, NV_ENC_INITIALIZE_PARAMS* createEncodeParams);
  2409. // NvEncCreateInputBuffer
  2410. /**
  2411. * \brief Allocates Input buffer.
  2412. *
  2413. * This function is used to allocate an input buffer. The client must enumerate
  2414. * the input buffer format before allocating the input buffer resources. The
  2415. * NV_ENC_INPUT_PTR returned by the NvEncodeAPI interface in the
  2416. * NV_ENC_CREATE_INPUT_BUFFER::inputBuffer field can be directly used in
  2417. * ::NvEncEncodePicture() API. The number of input buffers to be allocated by the
  2418. * client must be at least 4 more than the number of B frames being used for encoding.
  2419. *
  2420. * \param [in] encoder
  2421. * Pointer to the NvEncodeAPI interface.
  2422. * \param [in,out] createInputBufferParams
  2423. * Pointer to the ::NV_ENC_CREATE_INPUT_BUFFER structure.
  2424. *
  2425. * \return
  2426. * ::NV_ENC_SUCCESS \n
  2427. * ::NV_ENC_ERR_INVALID_PTR \n
  2428. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2429. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2430. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2431. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2432. * ::NV_ENC_ERR_INVALID_PARAM \n
  2433. * ::NV_ENC_ERR_INVALID_VERSION \n
  2434. * ::NV_ENC_ERR_GENERIC \n
  2435. *
  2436. */
  2437. NVENCSTATUS NVENCAPI NvEncCreateInputBuffer (void* encoder, NV_ENC_CREATE_INPUT_BUFFER* createInputBufferParams);
  2438. // NvEncDestroyInputBuffer
  2439. /**
  2440. * \brief Release an input buffers.
  2441. *
  2442. * This function is used to free an input buffer. If the client has allocated
  2443. * any input buffer using ::NvEncCreateInputBuffer() API, it must free those
  2444. * input buffers by calling this function. The client must release the input
  2445. * buffers before destroying the encoder using ::NvEncDestroyEncoder() API.
  2446. *
  2447. * \param [in] encoder
  2448. * Pointer to the NvEncodeAPI interface.
  2449. * \param [in] inputBuffer
  2450. * Pointer to the input buffer to be released.
  2451. *
  2452. * \return
  2453. * ::NV_ENC_SUCCESS \n
  2454. * ::NV_ENC_ERR_INVALID_PTR \n
  2455. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2456. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2457. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2458. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2459. * ::NV_ENC_ERR_INVALID_PARAM \n
  2460. * ::NV_ENC_ERR_INVALID_VERSION \n
  2461. * ::NV_ENC_ERR_GENERIC \n
  2462. *
  2463. */
  2464. NVENCSTATUS NVENCAPI NvEncDestroyInputBuffer (void* encoder, NV_ENC_INPUT_PTR inputBuffer);
  2465. // NvEncSetIOCudaStreams
  2466. /**
  2467. * \brief Set input and output CUDA stream for specified encoder attribute.
  2468. *
  2469. * Encoding may involve CUDA pre-processing on the input and post-processing on encoded output.
  2470. * This function is used to set input and output CUDA streams to pipeline the CUDA pre-processing
  2471. * and post-processing tasks. Clients should call this function before the call to
  2472. * NvEncUnlockInputBuffer(). If this function is not called, the default CUDA stream is used for
  2473. * input and output processing. After a successful call to this function, the streams specified
  2474. * in that call will replace the previously-used streams.
  2475. * This API is supported for NVCUVID interface only.
  2476. *
  2477. * \param [in] encoder
  2478. * Pointer to the NvEncodeAPI interface.
  2479. * \param [in] inputStream
  2480. * Pointer to CUstream which is used to process ::NV_ENC_PIC_PARAMS::inputFrame for encode.
  2481. * In case of ME-only mode, inputStream is used to process ::NV_ENC_MEONLY_PARAMS::inputBuffer and
  2482. * ::NV_ENC_MEONLY_PARAMS::referenceFrame
  2483. * \param [in] outputStream
  2484. * Pointer to CUstream which is used to process ::NV_ENC_PIC_PARAMS::outputBuffer for encode.
  2485. * In case of ME-only mode, outputStream is used to process ::NV_ENC_MEONLY_PARAMS::mvBuffer
  2486. *
  2487. * \return
  2488. * ::NV_ENC_SUCCESS \n
  2489. * ::NV_ENC_ERR_INVALID_PTR \n
  2490. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2491. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2492. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2493. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2494. * ::NV_ENC_ERR_INVALID_PARAM \n
  2495. * ::NV_ENC_ERR_INVALID_VERSION \n
  2496. * ::NV_ENC_ERR_GENERIC \n
  2497. */
  2498. NVENCSTATUS NVENCAPI NvEncSetIOCudaStreams (void* encoder, NV_ENC_CUSTREAM_PTR inputStream, NV_ENC_CUSTREAM_PTR outputStream);
  2499. // NvEncCreateBitstreamBuffer
  2500. /**
  2501. * \brief Allocates an output bitstream buffer
  2502. *
  2503. * This function is used to allocate an output bitstream buffer and returns a
  2504. * NV_ENC_OUTPUT_PTR to bitstream buffer to the client in the
  2505. * NV_ENC_CREATE_BITSTREAM_BUFFER::bitstreamBuffer field.
  2506. * The client can only call this function after the encoder session has been
  2507. * initialized using ::NvEncInitializeEncoder() API. The minimum number of output
  2508. * buffers allocated by the client must be at least 4 more than the number of B
  2509. * B frames being used for encoding. The client can only access the output
  2510. * bitstream data by locking the \p bitstreamBuffer using the ::NvEncLockBitstream()
  2511. * function.
  2512. *
  2513. * \param [in] encoder
  2514. * Pointer to the NvEncodeAPI interface.
  2515. * \param [in,out] createBitstreamBufferParams
  2516. * Pointer ::NV_ENC_CREATE_BITSTREAM_BUFFER for details.
  2517. *
  2518. * \return
  2519. * ::NV_ENC_SUCCESS \n
  2520. * ::NV_ENC_ERR_INVALID_PTR \n
  2521. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2522. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2523. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2524. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2525. * ::NV_ENC_ERR_INVALID_PARAM \n
  2526. * ::NV_ENC_ERR_INVALID_VERSION \n
  2527. * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  2528. * ::NV_ENC_ERR_GENERIC \n
  2529. *
  2530. */
  2531. NVENCSTATUS NVENCAPI NvEncCreateBitstreamBuffer (void* encoder, NV_ENC_CREATE_BITSTREAM_BUFFER* createBitstreamBufferParams);
  2532. // NvEncDestroyBitstreamBuffer
  2533. /**
  2534. * \brief Release a bitstream buffer.
  2535. *
  2536. * This function is used to release the output bitstream buffer allocated using
  2537. * the ::NvEncCreateBitstreamBuffer() function. The client must release the output
  2538. * bitstreamBuffer using this function before destroying the encoder session.
  2539. *
  2540. * \param [in] encoder
  2541. * Pointer to the NvEncodeAPI interface.
  2542. * \param [in] bitstreamBuffer
  2543. * Pointer to the bitstream buffer being released.
  2544. *
  2545. * \return
  2546. * ::NV_ENC_SUCCESS \n
  2547. * ::NV_ENC_ERR_INVALID_PTR \n
  2548. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2549. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2550. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2551. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2552. * ::NV_ENC_ERR_INVALID_PARAM \n
  2553. * ::NV_ENC_ERR_INVALID_VERSION \n
  2554. * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  2555. * ::NV_ENC_ERR_GENERIC \n
  2556. *
  2557. */
  2558. NVENCSTATUS NVENCAPI NvEncDestroyBitstreamBuffer (void* encoder, NV_ENC_OUTPUT_PTR bitstreamBuffer);
  2559. // NvEncEncodePicture
  2560. /**
  2561. * \brief Submit an input picture for encoding.
  2562. *
  2563. * This function is used to submit an input picture buffer for encoding. The
  2564. * encoding parameters are passed using \p *encodePicParams which is a pointer
  2565. * to the ::_NV_ENC_PIC_PARAMS structure.
  2566. *
  2567. * If the client has set NV_ENC_INITIALIZE_PARAMS::enablePTD to 0, then it must
  2568. * send a valid value for the following fields.
  2569. * - NV_ENC_PIC_PARAMS::pictureType
  2570. * - NV_ENC_PIC_PARAMS_H264::displayPOCSyntax (H264 only)
  2571. * - NV_ENC_PIC_PARAMS_H264::frameNumSyntax(H264 only)
  2572. * - NV_ENC_PIC_PARAMS_H264::refPicFlag(H264 only)
  2573. *
  2574. *\par MVC Encoding:
  2575. * For MVC encoding the client must call encode picture API for each view separately
  2576. * and must pass valid view id in NV_ENC_PIC_PARAMS_MVC::viewID field. Currently
  2577. * NvEncodeAPI only support stereo MVC so client must send viewID as 0 for base
  2578. * view and view ID as 1 for dependent view.
  2579. *
  2580. *\par Asynchronous Encoding
  2581. * If the client has enabled asynchronous mode of encoding by setting
  2582. * NV_ENC_INITIALIZE_PARAMS::enableEncodeAsync to 1 in the ::NvEncInitializeEncoder()
  2583. * API ,then the client must send a valid NV_ENC_PIC_PARAMS::completionEvent.
  2584. * Incase of asynchronous mode of operation, client can queue the ::NvEncEncodePicture()
  2585. * API commands from the main thread and then queue output buffers to be processed
  2586. * to a secondary worker thread. Before the locking the output buffers in the
  2587. * secondary thread , the client must wait on NV_ENC_PIC_PARAMS::completionEvent
  2588. * it has queued in ::NvEncEncodePicture() API call. The client must always process
  2589. * completion event and the output buffer in the same order in which they have been
  2590. * submitted for encoding. The NvEncodeAPI interface is responsible for any
  2591. * re-ordering required for B frames and will always ensure that encoded bitstream
  2592. * data is written in the same order in which output buffer is submitted.
  2593. * The NvEncodeAPI interface may return ::NV_ENC_ERR_NEED_MORE_INPUT error code for
  2594. * some ::NvEncEncodePicture() API calls but the client must not treat it as a fatal error.
  2595. * The NvEncodeAPI interface might not be able to submit an input picture buffer for encoding
  2596. * immediately due to re-ordering for B frames.
  2597. *\code
  2598. The below example shows how asynchronous encoding in case of 1 B frames
  2599. ------------------------------------------------------------------------
  2600. Suppose the client allocated 4 input buffers(I1,I2..), 4 output buffers(O1,O2..)
  2601. and 4 completion events(E1, E2, ...). The NvEncodeAPI interface will need to
  2602. keep a copy of the input buffers for re-ordering and it allocates following
  2603. internal buffers (NvI1, NvI2...). These internal buffers are managed by NvEncodeAPI
  2604. and the client is not responsible for the allocating or freeing the memory of
  2605. the internal buffers.
  2606. a) The client main thread will queue the following encode frame calls.
  2607. Note the picture type is unknown to the client, the decision is being taken by
  2608. NvEncodeAPI interface. The client should pass ::_NV_ENC_PIC_PARAMS parameter
  2609. consisting of allocated input buffer, output buffer and output events in successive
  2610. ::NvEncEncodePicture() API calls along with other required encode picture params.
  2611. For example:
  2612. 1st EncodePicture parameters - (I1, O1, E1)
  2613. 2nd EncodePicture parameters - (I2, O2, E2)
  2614. 3rd EncodePicture parameters - (I3, O3, E3)
  2615. b) NvEncodeAPI SW will receive the following encode Commands from the client.
  2616. The left side shows input from client in the form (Input buffer, Output Buffer,
  2617. Output Event). The right hand side shows a possible picture type decision take by
  2618. the NvEncodeAPI interface.
  2619. (I1, O1, E1) ---P1 Frame
  2620. (I2, O2, E2) ---B2 Frame
  2621. (I3, O3, E3) ---P3 Frame
  2622. c) NvEncodeAPI interface will make a copy of the input buffers to its internal
  2623. buffers for re-ordering. These copies are done as part of nvEncEncodePicture
  2624. function call from the client and NvEncodeAPI interface is responsible for
  2625. synchronization of copy operation with the actual encoding operation.
  2626. I1 --> NvI1
  2627. I2 --> NvI2
  2628. I3 --> NvI3
  2629. d) The NvEncodeAPI encodes I1 as P frame and submits I1 to encoder HW and returns ::NV_ENC_SUCCESS.
  2630. The NvEncodeAPI tries to encode I2 as B frame and fails with ::NV_ENC_ERR_NEED_MORE_INPUT error code.
  2631. The error is not fatal and it notifies client that I2 is not submitted to encoder immediately.
  2632. The NvEncodeAPI encodes I3 as P frame and submits I3 for encoding which will be used as backward
  2633. reference frame for I2. The NvEncodeAPI then submits I2 for encoding and returns ::NV_ENC_SUCESS.
  2634. Both the submission are part of the same ::NvEncEncodePicture() function call.
  2635. e) After returning from ::NvEncEncodePicture() call , the client must queue the output
  2636. bitstream processing work to the secondary thread. The output bitstream processing
  2637. for asynchronous mode consist of first waiting on completion event(E1, E2..)
  2638. and then locking the output bitstream buffer(O1, O2..) for reading the encoded
  2639. data. The work queued to the secondary thread by the client is in the following order
  2640. (I1, O1, E1)
  2641. (I2, O2, E2)
  2642. (I3, O3, E3)
  2643. Note they are in the same order in which client calls ::NvEncEncodePicture() API
  2644. in \p step a).
  2645. f) NvEncodeAPI interface will do the re-ordering such that Encoder HW will receive
  2646. the following encode commands:
  2647. (NvI1, O1, E1) ---P1 Frame
  2648. (NvI3, O2, E2) ---P3 Frame
  2649. (NvI2, O3, E3) ---B2 frame
  2650. g) After the encoding operations are completed, the events will be signaled
  2651. by NvEncodeAPI interface in the following order :
  2652. (O1, E1) ---P1 Frame ,output bitstream copied to O1 and event E1 signaled.
  2653. (O2, E2) ---P3 Frame ,output bitstream copied to O2 and event E2 signaled.
  2654. (O3, E3) ---B2 Frame ,output bitstream copied to O3 and event E3 signaled.
  2655. h) The client must lock the bitstream data using ::NvEncLockBitstream() API in
  2656. the order O1,O2,O3 to read the encoded data, after waiting for the events
  2657. to be signaled in the same order i.e E1, E2 and E3.The output processing is
  2658. done in the secondary thread in the following order:
  2659. Waits on E1, copies encoded bitstream from O1
  2660. Waits on E2, copies encoded bitstream from O2
  2661. Waits on E3, copies encoded bitstream from O3
  2662. -Note the client will receive the events signaling and output buffer in the
  2663. same order in which they have submitted for encoding.
  2664. -Note the LockBitstream will have picture type field which will notify the
  2665. output picture type to the clients.
  2666. -Note the input, output buffer and the output completion event are free to be
  2667. reused once NvEncodeAPI interfaced has signaled the event and the client has
  2668. copied the data from the output buffer.
  2669. * \endcode
  2670. *
  2671. *\par Synchronous Encoding
  2672. * The client can enable synchronous mode of encoding by setting
  2673. * NV_ENC_INITIALIZE_PARAMS::enableEncodeAsync to 0 in ::NvEncInitializeEncoder() API.
  2674. * The NvEncodeAPI interface may return ::NV_ENC_ERR_NEED_MORE_INPUT error code for
  2675. * some ::NvEncEncodePicture() API calls when NV_ENC_INITIALIZE_PARAMS::enablePTD
  2676. * is set to 1, but the client must not treat it as a fatal error. The NvEncodeAPI
  2677. * interface might not be able to submit an input picture buffer for encoding
  2678. * immediately due to re-ordering for B frames. The NvEncodeAPI interface cannot
  2679. * submit the input picture which is decided to be encoded as B frame as it waits
  2680. * for backward reference from temporally subsequent frames. This input picture
  2681. * is buffered internally and waits for more input picture to arrive. The client
  2682. * must not call ::NvEncLockBitstream() API on the output buffers whose
  2683. * ::NvEncEncodePicture() API returns ::NV_ENC_ERR_NEED_MORE_INPUT. The client must
  2684. * wait for the NvEncodeAPI interface to return ::NV_ENC_SUCCESS before locking the
  2685. * output bitstreams to read the encoded bitstream data. The following example
  2686. * explains the scenario with synchronous encoding with 2 B frames.
  2687. *\code
  2688. The below example shows how synchronous encoding works in case of 1 B frames
  2689. -----------------------------------------------------------------------------
  2690. Suppose the client allocated 4 input buffers(I1,I2..), 4 output buffers(O1,O2..)
  2691. and 4 completion events(E1, E2, ...). The NvEncodeAPI interface will need to
  2692. keep a copy of the input buffers for re-ordering and it allocates following
  2693. internal buffers (NvI1, NvI2...). These internal buffers are managed by NvEncodeAPI
  2694. and the client is not responsible for the allocating or freeing the memory of
  2695. the internal buffers.
  2696. The client calls ::NvEncEncodePicture() API with input buffer I1 and output buffer O1.
  2697. The NvEncodeAPI decides to encode I1 as P frame and submits it to encoder
  2698. HW and returns ::NV_ENC_SUCCESS.
  2699. The client can now read the encoded data by locking the output O1 by calling
  2700. NvEncLockBitstream API.
  2701. The client calls ::NvEncEncodePicture() API with input buffer I2 and output buffer O2.
  2702. The NvEncodeAPI decides to encode I2 as B frame and buffers I2 by copying it
  2703. to internal buffer and returns ::NV_ENC_ERR_NEED_MORE_INPUT.
  2704. The error is not fatal and it notifies client that it cannot read the encoded
  2705. data by locking the output O2 by calling ::NvEncLockBitstream() API without submitting
  2706. more work to the NvEncodeAPI interface.
  2707. The client calls ::NvEncEncodePicture() with input buffer I3 and output buffer O3.
  2708. The NvEncodeAPI decides to encode I3 as P frame and it first submits I3 for
  2709. encoding which will be used as backward reference frame for I2.
  2710. The NvEncodeAPI then submits I2 for encoding and returns ::NV_ENC_SUCESS. Both
  2711. the submission are part of the same ::NvEncEncodePicture() function call.
  2712. The client can now read the encoded data for both the frames by locking the output
  2713. O2 followed by O3 ,by calling ::NvEncLockBitstream() API.
  2714. The client must always lock the output in the same order in which it has submitted
  2715. to receive the encoded bitstream in correct encoding order.
  2716. * \endcode
  2717. *
  2718. * \param [in] encoder
  2719. * Pointer to the NvEncodeAPI interface.
  2720. * \param [in,out] encodePicParams
  2721. * Pointer to the ::_NV_ENC_PIC_PARAMS structure.
  2722. *
  2723. * \return
  2724. * ::NV_ENC_SUCCESS \n
  2725. * ::NV_ENC_ERR_INVALID_PTR \n
  2726. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2727. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2728. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2729. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2730. * ::NV_ENC_ERR_INVALID_PARAM \n
  2731. * ::NV_ENC_ERR_INVALID_VERSION \n
  2732. * ::NV_ENC_ERR_ENCODER_BUSY \n
  2733. * ::NV_ENC_ERR_NEED_MORE_INPUT \n
  2734. * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  2735. * ::NV_ENC_ERR_GENERIC \n
  2736. *
  2737. */
  2738. NVENCSTATUS NVENCAPI NvEncEncodePicture (void* encoder, NV_ENC_PIC_PARAMS* encodePicParams);
  2739. // NvEncLockBitstream
  2740. /**
  2741. * \brief Lock output bitstream buffer
  2742. *
  2743. * This function is used to lock the bitstream buffer to read the encoded data.
  2744. * The client can only access the encoded data by calling this function.
  2745. * The pointer to client accessible encoded data is returned in the
  2746. * NV_ENC_LOCK_BITSTREAM::bitstreamBufferPtr field. The size of the encoded data
  2747. * in the output buffer is returned in the NV_ENC_LOCK_BITSTREAM::bitstreamSizeInBytes
  2748. * The NvEncodeAPI interface also returns the output picture type and picture structure
  2749. * of the encoded frame in NV_ENC_LOCK_BITSTREAM::pictureType and
  2750. * NV_ENC_LOCK_BITSTREAM::pictureStruct fields respectively. If the client has
  2751. * set NV_ENC_LOCK_BITSTREAM::doNotWait to 1, the function might return
  2752. * ::NV_ENC_ERR_LOCK_BUSY if client is operating in synchronous mode. This is not
  2753. * a fatal failure if NV_ENC_LOCK_BITSTREAM::doNotWait is set to 1. In the above case the client can
  2754. * retry the function after few milliseconds.
  2755. *
  2756. * \param [in] encoder
  2757. * Pointer to the NvEncodeAPI interface.
  2758. * \param [in,out] lockBitstreamBufferParams
  2759. * Pointer to the ::_NV_ENC_LOCK_BITSTREAM structure.
  2760. *
  2761. * \return
  2762. * ::NV_ENC_SUCCESS \n
  2763. * ::NV_ENC_ERR_INVALID_PTR \n
  2764. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2765. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2766. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2767. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2768. * ::NV_ENC_ERR_INVALID_PARAM \n
  2769. * ::NV_ENC_ERR_INVALID_VERSION \n
  2770. * ::NV_ENC_ERR_LOCK_BUSY \n
  2771. * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  2772. * ::NV_ENC_ERR_GENERIC \n
  2773. *
  2774. */
  2775. NVENCSTATUS NVENCAPI NvEncLockBitstream (void* encoder, NV_ENC_LOCK_BITSTREAM* lockBitstreamBufferParams);
  2776. // NvEncUnlockBitstream
  2777. /**
  2778. * \brief Unlock the output bitstream buffer
  2779. *
  2780. * This function is used to unlock the output bitstream buffer after the client
  2781. * has read the encoded data from output buffer. The client must call this function
  2782. * to unlock the output buffer which it has previously locked using ::NvEncLockBitstream()
  2783. * function. Using a locked bitstream buffer in ::NvEncEncodePicture() API will cause
  2784. * the function to fail.
  2785. *
  2786. * \param [in] encoder
  2787. * Pointer to the NvEncodeAPI interface.
  2788. * \param [in,out] bitstreamBuffer
  2789. * bitstream buffer pointer being unlocked
  2790. *
  2791. * \return
  2792. * ::NV_ENC_SUCCESS \n
  2793. * ::NV_ENC_ERR_INVALID_PTR \n
  2794. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2795. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2796. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2797. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2798. * ::NV_ENC_ERR_INVALID_PARAM \n
  2799. * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  2800. * ::NV_ENC_ERR_GENERIC \n
  2801. *
  2802. */
  2803. NVENCSTATUS NVENCAPI NvEncUnlockBitstream (void* encoder, NV_ENC_OUTPUT_PTR bitstreamBuffer);
  2804. // NvLockInputBuffer
  2805. /**
  2806. * \brief Locks an input buffer
  2807. *
  2808. * This function is used to lock the input buffer to load the uncompressed YUV
  2809. * pixel data into input buffer memory. The client must pass the NV_ENC_INPUT_PTR
  2810. * it had previously allocated using ::NvEncCreateInputBuffer()in the
  2811. * NV_ENC_LOCK_INPUT_BUFFER::inputBuffer field.
  2812. * The NvEncodeAPI interface returns pointer to client accessible input buffer
  2813. * memory in NV_ENC_LOCK_INPUT_BUFFER::bufferDataPtr field.
  2814. *
  2815. * \param [in] encoder
  2816. * Pointer to the NvEncodeAPI interface.
  2817. * \param [in,out] lockInputBufferParams
  2818. * Pointer to the ::_NV_ENC_LOCK_INPUT_BUFFER structure
  2819. *
  2820. * \return
  2821. * \return
  2822. * ::NV_ENC_SUCCESS \n
  2823. * ::NV_ENC_ERR_INVALID_PTR \n
  2824. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2825. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2826. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2827. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2828. * ::NV_ENC_ERR_INVALID_PARAM \n
  2829. * ::NV_ENC_ERR_INVALID_VERSION \n
  2830. * ::NV_ENC_ERR_LOCK_BUSY \n
  2831. * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  2832. * ::NV_ENC_ERR_GENERIC \n
  2833. *
  2834. */
  2835. NVENCSTATUS NVENCAPI NvEncLockInputBuffer (void* encoder, NV_ENC_LOCK_INPUT_BUFFER* lockInputBufferParams);
  2836. // NvUnlockInputBuffer
  2837. /**
  2838. * \brief Unlocks the input buffer
  2839. *
  2840. * This function is used to unlock the input buffer memory previously locked for
  2841. * uploading YUV pixel data. The input buffer must be unlocked before being used
  2842. * again for encoding, otherwise NvEncodeAPI will fail the ::NvEncEncodePicture()
  2843. *
  2844. * \param [in] encoder
  2845. * Pointer to the NvEncodeAPI interface.
  2846. * \param [in] inputBuffer
  2847. * Pointer to the input buffer that is being unlocked.
  2848. *
  2849. * \return
  2850. * ::NV_ENC_SUCCESS \n
  2851. * ::NV_ENC_ERR_INVALID_PTR \n
  2852. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2853. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2854. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2855. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2856. * ::NV_ENC_ERR_INVALID_VERSION \n
  2857. * ::NV_ENC_ERR_INVALID_PARAM \n
  2858. * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  2859. * ::NV_ENC_ERR_GENERIC \n
  2860. *
  2861. *
  2862. */
  2863. NVENCSTATUS NVENCAPI NvEncUnlockInputBuffer (void* encoder, NV_ENC_INPUT_PTR inputBuffer);
  2864. // NvEncGetEncodeStats
  2865. /**
  2866. * \brief Get encoding statistics.
  2867. *
  2868. * This function is used to retrieve the encoding statistics.
  2869. * This API is not supported when encode device type is CUDA.
  2870. *
  2871. * \param [in] encoder
  2872. * Pointer to the NvEncodeAPI interface.
  2873. * \param [in,out] encodeStats
  2874. * Pointer to the ::_NV_ENC_STAT structure.
  2875. *
  2876. * \return
  2877. * ::NV_ENC_SUCCESS \n
  2878. * ::NV_ENC_ERR_INVALID_PTR \n
  2879. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2880. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2881. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2882. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2883. * ::NV_ENC_ERR_INVALID_PARAM \n
  2884. * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  2885. * ::NV_ENC_ERR_GENERIC \n
  2886. *
  2887. */
  2888. NVENCSTATUS NVENCAPI NvEncGetEncodeStats (void* encoder, NV_ENC_STAT* encodeStats);
  2889. // NvEncGetSequenceParams
  2890. /**
  2891. * \brief Get encoded sequence and picture header.
  2892. *
  2893. * This function can be used to retrieve the sequence and picture header out of
  2894. * band. The client must call this function only after the encoder has been
  2895. * initialized using ::NvEncInitializeEncoder() function. The client must
  2896. * allocate the memory where the NvEncodeAPI interface can copy the bitstream
  2897. * header and pass the pointer to the memory in NV_ENC_SEQUENCE_PARAM_PAYLOAD::spsppsBuffer.
  2898. * The size of buffer is passed in the field NV_ENC_SEQUENCE_PARAM_PAYLOAD::inBufferSize.
  2899. * The NvEncodeAPI interface will copy the bitstream header payload and returns
  2900. * the actual size of the bitstream header in the field
  2901. * NV_ENC_SEQUENCE_PARAM_PAYLOAD::outSPSPPSPayloadSize.
  2902. * The client must call ::NvEncGetSequenceParams() function from the same thread which is
  2903. * being used to call ::NvEncEncodePicture() function.
  2904. *
  2905. * \param [in] encoder
  2906. * Pointer to the NvEncodeAPI interface.
  2907. * \param [in,out] sequenceParamPayload
  2908. * Pointer to the ::_NV_ENC_SEQUENCE_PARAM_PAYLOAD structure.
  2909. *
  2910. * \return
  2911. * ::NV_ENC_SUCCESS \n
  2912. * ::NV_ENC_ERR_INVALID_PTR \n
  2913. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2914. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2915. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2916. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2917. * ::NV_ENC_ERR_INVALID_VERSION \n
  2918. * ::NV_ENC_ERR_INVALID_PARAM \n
  2919. * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  2920. * ::NV_ENC_ERR_GENERIC \n
  2921. *
  2922. */
  2923. NVENCSTATUS NVENCAPI NvEncGetSequenceParams (void* encoder, NV_ENC_SEQUENCE_PARAM_PAYLOAD* sequenceParamPayload);
  2924. // NvEncGetSequenceParamEx
  2925. /**
  2926. * \brief Get sequence and picture header.
  2927. *
  2928. * This function can be used to retrieve the sequence and picture header out of band, even when
  2929. * encoder has not been initialized using ::NvEncInitializeEncoder() function.
  2930. * The client must allocate the memory where the NvEncodeAPI interface can copy the bitstream
  2931. * header and pass the pointer to the memory in NV_ENC_SEQUENCE_PARAM_PAYLOAD::spsppsBuffer.
  2932. * The size of buffer is passed in the field NV_ENC_SEQUENCE_PARAM_PAYLOAD::inBufferSize.
  2933. * If encoder has not been initialized using ::NvEncInitializeEncoder() function, client must
  2934. * send NV_ENC_INITIALIZE_PARAMS as input. The NV_ENC_INITIALIZE_PARAMS passed must be same as the
  2935. * one which will be used for initializing encoder using ::NvEncInitializeEncoder() function later.
  2936. * If encoder is already initialized using ::NvEncInitializeEncoder() function, the provided
  2937. * NV_ENC_INITIALIZE_PARAMS structure is ignored. The NvEncodeAPI interface will copy the bitstream
  2938. * header payload and returns the actual size of the bitstream header in the field
  2939. * NV_ENC_SEQUENCE_PARAM_PAYLOAD::outSPSPPSPayloadSize. The client must call ::NvEncGetSequenceParamsEx()
  2940. * function from the same thread which is being used to call ::NvEncEncodePicture() function.
  2941. *
  2942. * \param [in] encoder
  2943. * Pointer to the NvEncodeAPI interface.
  2944. * \param [in] encInitParams
  2945. * Pointer to the _NV_ENC_INITIALIZE_PARAMS structure.
  2946. * \param [in,out] sequenceParamPayload
  2947. * Pointer to the ::_NV_ENC_SEQUENCE_PARAM_PAYLOAD structure.
  2948. *
  2949. * \return
  2950. * ::NV_ENC_SUCCESS \n
  2951. * ::NV_ENC_ERR_INVALID_PTR \n
  2952. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2953. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2954. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2955. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2956. * ::NV_ENC_ERR_INVALID_VERSION \n
  2957. * ::NV_ENC_ERR_INVALID_PARAM \n
  2958. * ::NV_ENC_ERR_GENERIC \n
  2959. *
  2960. */
  2961. NVENCSTATUS NVENCAPI NvEncGetSequenceParamEx (void* encoder, NV_ENC_INITIALIZE_PARAMS* encInitParams, NV_ENC_SEQUENCE_PARAM_PAYLOAD* sequenceParamPayload);
  2962. // NvEncRegisterAsyncEvent
  2963. /**
  2964. * \brief Register event for notification to encoding completion.
  2965. *
  2966. * This function is used to register the completion event with NvEncodeAPI
  2967. * interface. The event is required when the client has configured the encoder to
  2968. * work in asynchronous mode. In this mode the client needs to send a completion
  2969. * event with every output buffer. The NvEncodeAPI interface will signal the
  2970. * completion of the encoding process using this event. Only after the event is
  2971. * signaled the client can get the encoded data using ::NvEncLockBitstream() function.
  2972. *
  2973. * \param [in] encoder
  2974. * Pointer to the NvEncodeAPI interface.
  2975. * \param [in] eventParams
  2976. * Pointer to the ::_NV_ENC_EVENT_PARAMS structure.
  2977. *
  2978. * \return
  2979. * ::NV_ENC_SUCCESS \n
  2980. * ::NV_ENC_ERR_INVALID_PTR \n
  2981. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  2982. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  2983. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  2984. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  2985. * ::NV_ENC_ERR_INVALID_VERSION \n
  2986. * ::NV_ENC_ERR_INVALID_PARAM \n
  2987. * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  2988. * ::NV_ENC_ERR_GENERIC \n
  2989. *
  2990. */
  2991. NVENCSTATUS NVENCAPI NvEncRegisterAsyncEvent (void* encoder, NV_ENC_EVENT_PARAMS* eventParams);
  2992. // NvEncUnregisterAsyncEvent
  2993. /**
  2994. * \brief Unregister completion event.
  2995. *
  2996. * This function is used to unregister completion event which has been previously
  2997. * registered using ::NvEncRegisterAsyncEvent() function. The client must unregister
  2998. * all events before destroying the encoder using ::NvEncDestroyEncoder() function.
  2999. *
  3000. * \param [in] encoder
  3001. * Pointer to the NvEncodeAPI interface.
  3002. * \param [in] eventParams
  3003. * Pointer to the ::_NV_ENC_EVENT_PARAMS structure.
  3004. *
  3005. * \return
  3006. * ::NV_ENC_SUCCESS \n
  3007. * ::NV_ENC_ERR_INVALID_PTR \n
  3008. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  3009. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  3010. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  3011. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  3012. * ::NV_ENC_ERR_INVALID_VERSION \n
  3013. * ::NV_ENC_ERR_INVALID_PARAM \n
  3014. * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  3015. * ::NV_ENC_ERR_GENERIC \n
  3016. *
  3017. */
  3018. NVENCSTATUS NVENCAPI NvEncUnregisterAsyncEvent (void* encoder, NV_ENC_EVENT_PARAMS* eventParams);
  3019. // NvEncMapInputResource
  3020. /**
  3021. * \brief Map an externally created input resource pointer for encoding.
  3022. *
  3023. * Maps an externally allocated input resource [using and returns a NV_ENC_INPUT_PTR
  3024. * which can be used for encoding in the ::NvEncEncodePicture() function. The
  3025. * mapped resource is returned in the field NV_ENC_MAP_INPUT_RESOURCE::outputResourcePtr.
  3026. * The NvEncodeAPI interface also returns the buffer format of the mapped resource
  3027. * in the field NV_ENC_MAP_INPUT_RESOURCE::outbufferFmt.
  3028. * This function provides synchronization guarantee that any graphics work submitted
  3029. * on the input buffer is completed before the buffer is used for encoding. This is
  3030. * also true for compute (i.e. CUDA) work, provided that the previous workload using
  3031. * the input resource was submitted to the default stream.
  3032. * The client should not access any input buffer while they are mapped by the encoder.
  3033. *
  3034. * \param [in] encoder
  3035. * Pointer to the NvEncodeAPI interface.
  3036. * \param [in,out] mapInputResParams
  3037. * Pointer to the ::_NV_ENC_MAP_INPUT_RESOURCE structure.
  3038. *
  3039. * \return
  3040. * ::NV_ENC_SUCCESS \n
  3041. * ::NV_ENC_ERR_INVALID_PTR \n
  3042. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  3043. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  3044. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  3045. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  3046. * ::NV_ENC_ERR_INVALID_VERSION \n
  3047. * ::NV_ENC_ERR_INVALID_PARAM \n
  3048. * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  3049. * ::NV_ENC_ERR_RESOURCE_NOT_REGISTERED \n
  3050. * ::NV_ENC_ERR_MAP_FAILED \n
  3051. * ::NV_ENC_ERR_GENERIC \n
  3052. *
  3053. */
  3054. NVENCSTATUS NVENCAPI NvEncMapInputResource (void* encoder, NV_ENC_MAP_INPUT_RESOURCE* mapInputResParams);
  3055. // NvEncUnmapInputResource
  3056. /**
  3057. * \brief UnMaps a NV_ENC_INPUT_PTR which was mapped for encoding
  3058. *
  3059. *
  3060. * UnMaps an input buffer which was previously mapped using ::NvEncMapInputResource()
  3061. * API. The mapping created using ::NvEncMapInputResource() should be invalidated
  3062. * using this API before the external resource is destroyed by the client. The client
  3063. * must unmap the buffer after ::NvEncLockBitstream() API returns successfully for encode
  3064. * work submitted using the mapped input buffer.
  3065. *
  3066. *
  3067. * \param [in] encoder
  3068. * Pointer to the NvEncodeAPI interface.
  3069. * \param [in] mappedInputBuffer
  3070. * Pointer to the NV_ENC_INPUT_PTR
  3071. *
  3072. * \return
  3073. * ::NV_ENC_SUCCESS \n
  3074. * ::NV_ENC_ERR_INVALID_PTR \n
  3075. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  3076. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  3077. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  3078. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  3079. * ::NV_ENC_ERR_INVALID_VERSION \n
  3080. * ::NV_ENC_ERR_INVALID_PARAM \n
  3081. * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  3082. * ::NV_ENC_ERR_RESOURCE_NOT_REGISTERED \n
  3083. * ::NV_ENC_ERR_RESOURCE_NOT_MAPPED \n
  3084. * ::NV_ENC_ERR_GENERIC \n
  3085. *
  3086. */
  3087. NVENCSTATUS NVENCAPI NvEncUnmapInputResource (void* encoder, NV_ENC_INPUT_PTR mappedInputBuffer);
  3088. // NvEncDestroyEncoder
  3089. /**
  3090. * \brief Destroy Encoding Session
  3091. *
  3092. * Destroys the encoder session previously created using ::NvEncOpenEncodeSession()
  3093. * function. The client must flush the encoder before freeing any resources. In order
  3094. * to flush the encoder the client must pass a NULL encode picture packet and either
  3095. * wait for the ::NvEncEncodePicture() function to return in synchronous mode or wait
  3096. * for the flush event to be signaled by the encoder in asynchronous mode.
  3097. * The client must free all the input and output resources created using the
  3098. * NvEncodeAPI interface before destroying the encoder. If the client is operating
  3099. * in asynchronous mode, it must also unregister the completion events previously
  3100. * registered.
  3101. *
  3102. * \param [in] encoder
  3103. * Pointer to the NvEncodeAPI interface.
  3104. *
  3105. * \return
  3106. * ::NV_ENC_SUCCESS \n
  3107. * ::NV_ENC_ERR_INVALID_PTR \n
  3108. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  3109. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  3110. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  3111. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  3112. * ::NV_ENC_ERR_INVALID_PARAM \n
  3113. * ::NV_ENC_ERR_GENERIC \n
  3114. *
  3115. */
  3116. NVENCSTATUS NVENCAPI NvEncDestroyEncoder (void* encoder);
  3117. // NvEncInvalidateRefFrames
  3118. /**
  3119. * \brief Invalidate reference frames
  3120. *
  3121. * Invalidates reference frame based on the time stamp provided by the client.
  3122. * The encoder marks any reference frames or any frames which have been reconstructed
  3123. * using the corrupt frame as invalid for motion estimation and uses older reference
  3124. * frames for motion estimation. The encoded forces the current frame to be encoded
  3125. * as an intra frame if no reference frames are left after invalidation process.
  3126. * This is useful for low latency application for error resiliency. The client
  3127. * is recommended to set NV_ENC_CONFIG_H264::maxNumRefFrames to a large value so
  3128. * that encoder can keep a backup of older reference frames in the DPB and can use them
  3129. * for motion estimation when the newer reference frames have been invalidated.
  3130. * This API can be called multiple times.
  3131. *
  3132. * \param [in] encoder
  3133. * Pointer to the NvEncodeAPI interface.
  3134. * \param [in] invalidRefFrameTimeStamp
  3135. * Timestamp of the invalid reference frames which needs to be invalidated.
  3136. *
  3137. * \return
  3138. * ::NV_ENC_SUCCESS \n
  3139. * ::NV_ENC_ERR_INVALID_PTR \n
  3140. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  3141. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  3142. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  3143. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  3144. * ::NV_ENC_ERR_INVALID_PARAM \n
  3145. * ::NV_ENC_ERR_GENERIC \n
  3146. *
  3147. */
  3148. NVENCSTATUS NVENCAPI NvEncInvalidateRefFrames(void* encoder, uint64_t invalidRefFrameTimeStamp);
  3149. // NvEncOpenEncodeSessionEx
  3150. /**
  3151. * \brief Opens an encoding session.
  3152. *
  3153. * Opens an encoding session and returns a pointer to the encoder interface in
  3154. * the \p **encoder parameter. The client should start encoding process by calling
  3155. * this API first.
  3156. * The client must pass a pointer to IDirect3DDevice9 device or CUDA context in the \p *device parameter.
  3157. * For the OpenGL interface, \p device must be NULL. An OpenGL context must be current when
  3158. * calling all NvEncodeAPI functions.
  3159. * If the creation of encoder session fails, the client must call ::NvEncDestroyEncoder API
  3160. * before exiting.
  3161. *
  3162. * \param [in] openSessionExParams
  3163. * Pointer to a ::NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS structure.
  3164. * \param [out] encoder
  3165. * Encode Session pointer to the NvEncodeAPI interface.
  3166. * \return
  3167. * ::NV_ENC_SUCCESS \n
  3168. * ::NV_ENC_ERR_INVALID_PTR \n
  3169. * ::NV_ENC_ERR_NO_ENCODE_DEVICE \n
  3170. * ::NV_ENC_ERR_UNSUPPORTED_DEVICE \n
  3171. * ::NV_ENC_ERR_INVALID_DEVICE \n
  3172. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  3173. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  3174. * ::NV_ENC_ERR_GENERIC \n
  3175. *
  3176. */
  3177. NVENCSTATUS NVENCAPI NvEncOpenEncodeSessionEx (NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS *openSessionExParams, void** encoder);
  3178. // NvEncRegisterResource
  3179. /**
  3180. * \brief Registers a resource with the Nvidia Video Encoder Interface.
  3181. *
  3182. * Registers a resource with the Nvidia Video Encoder Interface for book keeping.
  3183. * The client is expected to pass the registered resource handle as well, while calling ::NvEncMapInputResource API.
  3184. *
  3185. * \param [in] encoder
  3186. * Pointer to the NVEncodeAPI interface.
  3187. *
  3188. * \param [in] registerResParams
  3189. * Pointer to a ::_NV_ENC_REGISTER_RESOURCE structure
  3190. *
  3191. * \return
  3192. * ::NV_ENC_SUCCESS \n
  3193. * ::NV_ENC_ERR_INVALID_PTR \n
  3194. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  3195. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  3196. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  3197. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  3198. * ::NV_ENC_ERR_INVALID_VERSION \n
  3199. * ::NV_ENC_ERR_INVALID_PARAM \n
  3200. * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  3201. * ::NV_ENC_ERR_RESOURCE_REGISTER_FAILED \n
  3202. * ::NV_ENC_ERR_GENERIC \n
  3203. * ::NV_ENC_ERR_UNIMPLEMENTED \n
  3204. *
  3205. */
  3206. NVENCSTATUS NVENCAPI NvEncRegisterResource (void* encoder, NV_ENC_REGISTER_RESOURCE* registerResParams);
  3207. // NvEncUnregisterResource
  3208. /**
  3209. * \brief Unregisters a resource previously registered with the Nvidia Video Encoder Interface.
  3210. *
  3211. * Unregisters a resource previously registered with the Nvidia Video Encoder Interface.
  3212. * The client is expected to unregister any resource that it has registered with the
  3213. * Nvidia Video Encoder Interface before destroying the resource.
  3214. *
  3215. * \param [in] encoder
  3216. * Pointer to the NVEncodeAPI interface.
  3217. *
  3218. * \param [in] registeredResource
  3219. * The registered resource pointer that was returned in ::NvEncRegisterResource.
  3220. *
  3221. * \return
  3222. * ::NV_ENC_SUCCESS \n
  3223. * ::NV_ENC_ERR_INVALID_PTR \n
  3224. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  3225. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  3226. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  3227. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  3228. * ::NV_ENC_ERR_INVALID_VERSION \n
  3229. * ::NV_ENC_ERR_INVALID_PARAM \n
  3230. * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  3231. * ::NV_ENC_ERR_RESOURCE_NOT_REGISTERED \n
  3232. * ::NV_ENC_ERR_GENERIC \n
  3233. * ::NV_ENC_ERR_UNIMPLEMENTED \n
  3234. *
  3235. */
  3236. NVENCSTATUS NVENCAPI NvEncUnregisterResource (void* encoder, NV_ENC_REGISTERED_PTR registeredResource);
  3237. // NvEncReconfigureEncoder
  3238. /**
  3239. * \brief Reconfigure an existing encoding session.
  3240. *
  3241. * Reconfigure an existing encoding session.
  3242. * The client should call this API to change/reconfigure the parameter passed during
  3243. * NvEncInitializeEncoder API call.
  3244. * Currently Reconfiguration of following are not supported.
  3245. * Change in GOP structure.
  3246. * Change in sync-Async mode.
  3247. * Change in MaxWidth & MaxHeight.
  3248. * Change in PTD mode.
  3249. *
  3250. * Resolution change is possible only if maxEncodeWidth & maxEncodeHeight of NV_ENC_INITIALIZE_PARAMS
  3251. * is set while creating encoder session.
  3252. *
  3253. * \param [in] encoder
  3254. * Pointer to the NVEncodeAPI interface.
  3255. *
  3256. * \param [in] reInitEncodeParams
  3257. * Pointer to a ::NV_ENC_RECONFIGURE_PARAMS structure.
  3258. * \return
  3259. * ::NV_ENC_SUCCESS \n
  3260. * ::NV_ENC_ERR_INVALID_PTR \n
  3261. * ::NV_ENC_ERR_NO_ENCODE_DEVICE \n
  3262. * ::NV_ENC_ERR_UNSUPPORTED_DEVICE \n
  3263. * ::NV_ENC_ERR_INVALID_DEVICE \n
  3264. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  3265. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  3266. * ::NV_ENC_ERR_GENERIC \n
  3267. *
  3268. */
  3269. NVENCSTATUS NVENCAPI NvEncReconfigureEncoder (void *encoder, NV_ENC_RECONFIGURE_PARAMS* reInitEncodeParams);
  3270. // NvEncCreateMVBuffer
  3271. /**
  3272. * \brief Allocates output MV buffer for ME only mode.
  3273. *
  3274. * This function is used to allocate an output MV buffer. The size of the mvBuffer is
  3275. * dependent on the frame height and width of the last ::NvEncCreateInputBuffer() call.
  3276. * The NV_ENC_OUTPUT_PTR returned by the NvEncodeAPI interface in the
  3277. * ::NV_ENC_CREATE_MV_BUFFER::mvBuffer field should be used in
  3278. * ::NvEncRunMotionEstimationOnly() API.
  3279. * Client must lock ::NV_ENC_CREATE_MV_BUFFER::mvBuffer using ::NvEncLockBitstream() API to get the motion vector data.
  3280. *
  3281. * \param [in] encoder
  3282. * Pointer to the NvEncodeAPI interface.
  3283. * \param [in,out] createMVBufferParams
  3284. * Pointer to the ::NV_ENC_CREATE_MV_BUFFER structure.
  3285. *
  3286. * \return
  3287. * ::NV_ENC_SUCCESS \n
  3288. * ::NV_ENC_ERR_INVALID_PTR \n
  3289. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  3290. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  3291. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  3292. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  3293. * ::NV_ENC_ERR_INVALID_PARAM \n
  3294. * ::NV_ENC_ERR_INVALID_VERSION \n
  3295. * ::NV_ENC_ERR_GENERIC \n
  3296. */
  3297. NVENCSTATUS NVENCAPI NvEncCreateMVBuffer (void* encoder, NV_ENC_CREATE_MV_BUFFER* createMVBufferParams);
  3298. // NvEncDestroyMVBuffer
  3299. /**
  3300. * \brief Release an output MV buffer for ME only mode.
  3301. *
  3302. * This function is used to release the output MV buffer allocated using
  3303. * the ::NvEncCreateMVBuffer() function. The client must release the output
  3304. * mvBuffer using this function before destroying the encoder session.
  3305. *
  3306. * \param [in] encoder
  3307. * Pointer to the NvEncodeAPI interface.
  3308. * \param [in] mvBuffer
  3309. * Pointer to the mvBuffer being released.
  3310. *
  3311. * \return
  3312. * ::NV_ENC_SUCCESS \n
  3313. * ::NV_ENC_ERR_INVALID_PTR \n
  3314. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  3315. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  3316. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  3317. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  3318. * ::NV_ENC_ERR_INVALID_PARAM \n
  3319. * ::NV_ENC_ERR_INVALID_VERSION \n
  3320. * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  3321. * ::NV_ENC_ERR_GENERIC \n
  3322. */
  3323. NVENCSTATUS NVENCAPI NvEncDestroyMVBuffer (void* encoder, NV_ENC_OUTPUT_PTR mvBuffer);
  3324. // NvEncRunMotionEstimationOnly
  3325. /**
  3326. * \brief Submit an input picture and reference frame for motion estimation in ME only mode.
  3327. *
  3328. * This function is used to submit the input frame and reference frame for motion
  3329. * estimation. The ME parameters are passed using *meOnlyParams which is a pointer
  3330. * to ::_NV_ENC_MEONLY_PARAMS structure.
  3331. * Client must lock ::NV_ENC_CREATE_MV_BUFFER::mvBuffer using ::NvEncLockBitstream() API to get the motion vector data.
  3332. * to get motion vector data.
  3333. *
  3334. * \param [in] encoder
  3335. * Pointer to the NvEncodeAPI interface.
  3336. * \param [in] meOnlyParams
  3337. * Pointer to the ::_NV_ENC_MEONLY_PARAMS structure.
  3338. *
  3339. * \return
  3340. * ::NV_ENC_SUCCESS \n
  3341. * ::NV_ENC_ERR_INVALID_PTR \n
  3342. * ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
  3343. * ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
  3344. * ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
  3345. * ::NV_ENC_ERR_OUT_OF_MEMORY \n
  3346. * ::NV_ENC_ERR_INVALID_PARAM \n
  3347. * ::NV_ENC_ERR_INVALID_VERSION \n
  3348. * ::NV_ENC_ERR_NEED_MORE_INPUT \n
  3349. * ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
  3350. * ::NV_ENC_ERR_GENERIC \n
  3351. */
  3352. NVENCSTATUS NVENCAPI NvEncRunMotionEstimationOnly (void* encoder, NV_ENC_MEONLY_PARAMS* meOnlyParams);
  3353. // NvEncodeAPIGetMaxSupportedVersion
  3354. /**
  3355. * \brief Get the largest NvEncodeAPI version supported by the driver.
  3356. *
  3357. * This function can be used by clients to determine if the driver supports
  3358. * the NvEncodeAPI header the application was compiled with.
  3359. *
  3360. * \param [out] version
  3361. * Pointer to the requested value. The 4 least significant bits in the returned
  3362. * indicate the minor version and the rest of the bits indicate the major
  3363. * version of the largest supported version.
  3364. *
  3365. * \return
  3366. * ::NV_ENC_SUCCESS \n
  3367. * ::NV_ENC_ERR_INVALID_PTR \n
  3368. */
  3369. NVENCSTATUS NVENCAPI NvEncodeAPIGetMaxSupportedVersion (uint32_t* version);
  3370. // NvEncGetLastErrorString
  3371. /**
  3372. * \brief Get the description of the last error reported by the API.
  3373. *
  3374. * This function returns a null-terminated string that can be used by clients to better understand the reason
  3375. * for failure of a previous API call.
  3376. *
  3377. * \param [in] encoder
  3378. * Pointer to the NvEncodeAPI interface.
  3379. *
  3380. * \return
  3381. * Pointer to buffer containing the details of the last error encountered by the API.
  3382. */
  3383. const char * NVENCAPI NvEncGetLastErrorString (void* encoder);
  3384. /// \cond API PFN
  3385. /*
  3386. * Defines API function pointers
  3387. */
  3388. typedef NVENCSTATUS (NVENCAPI* PNVENCOPENENCODESESSION) (void* device, uint32_t deviceType, void** encoder);
  3389. typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEGUIDCOUNT) (void* encoder, uint32_t* encodeGUIDCount);
  3390. typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEGUIDS) (void* encoder, GUID* GUIDs, uint32_t guidArraySize, uint32_t* GUIDCount);
  3391. typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEPROFILEGUIDCOUNT) (void* encoder, GUID encodeGUID, uint32_t* encodeProfileGUIDCount);
  3392. typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEPROFILEGUIDS) (void* encoder, GUID encodeGUID, GUID* profileGUIDs, uint32_t guidArraySize, uint32_t* GUIDCount);
  3393. typedef NVENCSTATUS (NVENCAPI* PNVENCGETINPUTFORMATCOUNT) (void* encoder, GUID encodeGUID, uint32_t* inputFmtCount);
  3394. typedef NVENCSTATUS (NVENCAPI* PNVENCGETINPUTFORMATS) (void* encoder, GUID encodeGUID, NV_ENC_BUFFER_FORMAT* inputFmts, uint32_t inputFmtArraySize, uint32_t* inputFmtCount);
  3395. typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODECAPS) (void* encoder, GUID encodeGUID, NV_ENC_CAPS_PARAM* capsParam, int* capsVal);
  3396. typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEPRESETCOUNT) (void* encoder, GUID encodeGUID, uint32_t* encodePresetGUIDCount);
  3397. typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEPRESETGUIDS) (void* encoder, GUID encodeGUID, GUID* presetGUIDs, uint32_t guidArraySize, uint32_t* encodePresetGUIDCount);
  3398. typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEPRESETCONFIG) (void* encoder, GUID encodeGUID, GUID presetGUID, NV_ENC_PRESET_CONFIG* presetConfig);
  3399. typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODEPRESETCONFIGEX) (void* encoder, GUID encodeGUID, GUID presetGUID, NV_ENC_TUNING_INFO tuningInfo, NV_ENC_PRESET_CONFIG* presetConfig);
  3400. typedef NVENCSTATUS (NVENCAPI* PNVENCINITIALIZEENCODER) (void* encoder, NV_ENC_INITIALIZE_PARAMS* createEncodeParams);
  3401. typedef NVENCSTATUS (NVENCAPI* PNVENCCREATEINPUTBUFFER) (void* encoder, NV_ENC_CREATE_INPUT_BUFFER* createInputBufferParams);
  3402. typedef NVENCSTATUS (NVENCAPI* PNVENCDESTROYINPUTBUFFER) (void* encoder, NV_ENC_INPUT_PTR inputBuffer);
  3403. typedef NVENCSTATUS (NVENCAPI* PNVENCCREATEBITSTREAMBUFFER) (void* encoder, NV_ENC_CREATE_BITSTREAM_BUFFER* createBitstreamBufferParams);
  3404. typedef NVENCSTATUS (NVENCAPI* PNVENCDESTROYBITSTREAMBUFFER) (void* encoder, NV_ENC_OUTPUT_PTR bitstreamBuffer);
  3405. typedef NVENCSTATUS (NVENCAPI* PNVENCENCODEPICTURE) (void* encoder, NV_ENC_PIC_PARAMS* encodePicParams);
  3406. typedef NVENCSTATUS (NVENCAPI* PNVENCLOCKBITSTREAM) (void* encoder, NV_ENC_LOCK_BITSTREAM* lockBitstreamBufferParams);
  3407. typedef NVENCSTATUS (NVENCAPI* PNVENCUNLOCKBITSTREAM) (void* encoder, NV_ENC_OUTPUT_PTR bitstreamBuffer);
  3408. typedef NVENCSTATUS (NVENCAPI* PNVENCLOCKINPUTBUFFER) (void* encoder, NV_ENC_LOCK_INPUT_BUFFER* lockInputBufferParams);
  3409. typedef NVENCSTATUS (NVENCAPI* PNVENCUNLOCKINPUTBUFFER) (void* encoder, NV_ENC_INPUT_PTR inputBuffer);
  3410. typedef NVENCSTATUS (NVENCAPI* PNVENCGETENCODESTATS) (void* encoder, NV_ENC_STAT* encodeStats);
  3411. typedef NVENCSTATUS (NVENCAPI* PNVENCGETSEQUENCEPARAMS) (void* encoder, NV_ENC_SEQUENCE_PARAM_PAYLOAD* sequenceParamPayload);
  3412. typedef NVENCSTATUS (NVENCAPI* PNVENCREGISTERASYNCEVENT) (void* encoder, NV_ENC_EVENT_PARAMS* eventParams);
  3413. typedef NVENCSTATUS (NVENCAPI* PNVENCUNREGISTERASYNCEVENT) (void* encoder, NV_ENC_EVENT_PARAMS* eventParams);
  3414. typedef NVENCSTATUS (NVENCAPI* PNVENCMAPINPUTRESOURCE) (void* encoder, NV_ENC_MAP_INPUT_RESOURCE* mapInputResParams);
  3415. typedef NVENCSTATUS (NVENCAPI* PNVENCUNMAPINPUTRESOURCE) (void* encoder, NV_ENC_INPUT_PTR mappedInputBuffer);
  3416. typedef NVENCSTATUS (NVENCAPI* PNVENCDESTROYENCODER) (void* encoder);
  3417. typedef NVENCSTATUS (NVENCAPI* PNVENCINVALIDATEREFFRAMES) (void* encoder, uint64_t invalidRefFrameTimeStamp);
  3418. typedef NVENCSTATUS (NVENCAPI* PNVENCOPENENCODESESSIONEX) (NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS *openSessionExParams, void** encoder);
  3419. typedef NVENCSTATUS (NVENCAPI* PNVENCREGISTERRESOURCE) (void* encoder, NV_ENC_REGISTER_RESOURCE* registerResParams);
  3420. typedef NVENCSTATUS (NVENCAPI* PNVENCUNREGISTERRESOURCE) (void* encoder, NV_ENC_REGISTERED_PTR registeredRes);
  3421. typedef NVENCSTATUS (NVENCAPI* PNVENCRECONFIGUREENCODER) (void* encoder, NV_ENC_RECONFIGURE_PARAMS* reInitEncodeParams);
  3422. typedef NVENCSTATUS (NVENCAPI* PNVENCCREATEMVBUFFER) (void* encoder, NV_ENC_CREATE_MV_BUFFER* createMVBufferParams);
  3423. typedef NVENCSTATUS (NVENCAPI* PNVENCDESTROYMVBUFFER) (void* encoder, NV_ENC_OUTPUT_PTR mvBuffer);
  3424. typedef NVENCSTATUS (NVENCAPI* PNVENCRUNMOTIONESTIMATIONONLY) (void* encoder, NV_ENC_MEONLY_PARAMS* meOnlyParams);
  3425. typedef const char * (NVENCAPI* PNVENCGETLASTERROR) (void* encoder);
  3426. typedef NVENCSTATUS (NVENCAPI* PNVENCSETIOCUDASTREAMS) (void* encoder, NV_ENC_CUSTREAM_PTR inputStream, NV_ENC_CUSTREAM_PTR outputStream);
  3427. typedef NVENCSTATUS (NVENCAPI* PNVENCGETSEQUENCEPARAMEX) (void* encoder, NV_ENC_INITIALIZE_PARAMS* encInitParams, NV_ENC_SEQUENCE_PARAM_PAYLOAD* sequenceParamPayload);
  3428. /// \endcond
  3429. /** @} */ /* END ENCODE_FUNC */
  3430. /**
  3431. * \ingroup ENCODER_STRUCTURE
  3432. * NV_ENCODE_API_FUNCTION_LIST
  3433. */
  3434. typedef struct _NV_ENCODE_API_FUNCTION_LIST
  3435. {
  3436. uint32_t version; /**< [in]: Client should pass NV_ENCODE_API_FUNCTION_LIST_VER. */
  3437. uint32_t reserved; /**< [in]: Reserved and should be set to 0. */
  3438. PNVENCOPENENCODESESSION nvEncOpenEncodeSession; /**< [out]: Client should access ::NvEncOpenEncodeSession() API through this pointer. */
  3439. PNVENCGETENCODEGUIDCOUNT nvEncGetEncodeGUIDCount; /**< [out]: Client should access ::NvEncGetEncodeGUIDCount() API through this pointer. */
  3440. PNVENCGETENCODEPRESETCOUNT nvEncGetEncodeProfileGUIDCount; /**< [out]: Client should access ::NvEncGetEncodeProfileGUIDCount() API through this pointer.*/
  3441. PNVENCGETENCODEPRESETGUIDS nvEncGetEncodeProfileGUIDs; /**< [out]: Client should access ::NvEncGetEncodeProfileGUIDs() API through this pointer. */
  3442. PNVENCGETENCODEGUIDS nvEncGetEncodeGUIDs; /**< [out]: Client should access ::NvEncGetEncodeGUIDs() API through this pointer. */
  3443. PNVENCGETINPUTFORMATCOUNT nvEncGetInputFormatCount; /**< [out]: Client should access ::NvEncGetInputFormatCount() API through this pointer. */
  3444. PNVENCGETINPUTFORMATS nvEncGetInputFormats; /**< [out]: Client should access ::NvEncGetInputFormats() API through this pointer. */
  3445. PNVENCGETENCODECAPS nvEncGetEncodeCaps; /**< [out]: Client should access ::NvEncGetEncodeCaps() API through this pointer. */
  3446. PNVENCGETENCODEPRESETCOUNT nvEncGetEncodePresetCount; /**< [out]: Client should access ::NvEncGetEncodePresetCount() API through this pointer. */
  3447. PNVENCGETENCODEPRESETGUIDS nvEncGetEncodePresetGUIDs; /**< [out]: Client should access ::NvEncGetEncodePresetGUIDs() API through this pointer. */
  3448. PNVENCGETENCODEPRESETCONFIG nvEncGetEncodePresetConfig; /**< [out]: Client should access ::NvEncGetEncodePresetConfig() API through this pointer. */
  3449. PNVENCINITIALIZEENCODER nvEncInitializeEncoder; /**< [out]: Client should access ::NvEncInitializeEncoder() API through this pointer. */
  3450. PNVENCCREATEINPUTBUFFER nvEncCreateInputBuffer; /**< [out]: Client should access ::NvEncCreateInputBuffer() API through this pointer. */
  3451. PNVENCDESTROYINPUTBUFFER nvEncDestroyInputBuffer; /**< [out]: Client should access ::NvEncDestroyInputBuffer() API through this pointer. */
  3452. PNVENCCREATEBITSTREAMBUFFER nvEncCreateBitstreamBuffer; /**< [out]: Client should access ::NvEncCreateBitstreamBuffer() API through this pointer. */
  3453. PNVENCDESTROYBITSTREAMBUFFER nvEncDestroyBitstreamBuffer; /**< [out]: Client should access ::NvEncDestroyBitstreamBuffer() API through this pointer. */
  3454. PNVENCENCODEPICTURE nvEncEncodePicture; /**< [out]: Client should access ::NvEncEncodePicture() API through this pointer. */
  3455. PNVENCLOCKBITSTREAM nvEncLockBitstream; /**< [out]: Client should access ::NvEncLockBitstream() API through this pointer. */
  3456. PNVENCUNLOCKBITSTREAM nvEncUnlockBitstream; /**< [out]: Client should access ::NvEncUnlockBitstream() API through this pointer. */
  3457. PNVENCLOCKINPUTBUFFER nvEncLockInputBuffer; /**< [out]: Client should access ::NvEncLockInputBuffer() API through this pointer. */
  3458. PNVENCUNLOCKINPUTBUFFER nvEncUnlockInputBuffer; /**< [out]: Client should access ::NvEncUnlockInputBuffer() API through this pointer. */
  3459. PNVENCGETENCODESTATS nvEncGetEncodeStats; /**< [out]: Client should access ::NvEncGetEncodeStats() API through this pointer. */
  3460. PNVENCGETSEQUENCEPARAMS nvEncGetSequenceParams; /**< [out]: Client should access ::NvEncGetSequenceParams() API through this pointer. */
  3461. PNVENCREGISTERASYNCEVENT nvEncRegisterAsyncEvent; /**< [out]: Client should access ::NvEncRegisterAsyncEvent() API through this pointer. */
  3462. PNVENCUNREGISTERASYNCEVENT nvEncUnregisterAsyncEvent; /**< [out]: Client should access ::NvEncUnregisterAsyncEvent() API through this pointer. */
  3463. PNVENCMAPINPUTRESOURCE nvEncMapInputResource; /**< [out]: Client should access ::NvEncMapInputResource() API through this pointer. */
  3464. PNVENCUNMAPINPUTRESOURCE nvEncUnmapInputResource; /**< [out]: Client should access ::NvEncUnmapInputResource() API through this pointer. */
  3465. PNVENCDESTROYENCODER nvEncDestroyEncoder; /**< [out]: Client should access ::NvEncDestroyEncoder() API through this pointer. */
  3466. PNVENCINVALIDATEREFFRAMES nvEncInvalidateRefFrames; /**< [out]: Client should access ::NvEncInvalidateRefFrames() API through this pointer. */
  3467. PNVENCOPENENCODESESSIONEX nvEncOpenEncodeSessionEx; /**< [out]: Client should access ::NvEncOpenEncodeSession() API through this pointer. */
  3468. PNVENCREGISTERRESOURCE nvEncRegisterResource; /**< [out]: Client should access ::NvEncRegisterResource() API through this pointer. */
  3469. PNVENCUNREGISTERRESOURCE nvEncUnregisterResource; /**< [out]: Client should access ::NvEncUnregisterResource() API through this pointer. */
  3470. PNVENCRECONFIGUREENCODER nvEncReconfigureEncoder; /**< [out]: Client should access ::NvEncReconfigureEncoder() API through this pointer. */
  3471. void* reserved1;
  3472. PNVENCCREATEMVBUFFER nvEncCreateMVBuffer; /**< [out]: Client should access ::NvEncCreateMVBuffer API through this pointer. */
  3473. PNVENCDESTROYMVBUFFER nvEncDestroyMVBuffer; /**< [out]: Client should access ::NvEncDestroyMVBuffer API through this pointer. */
  3474. PNVENCRUNMOTIONESTIMATIONONLY nvEncRunMotionEstimationOnly; /**< [out]: Client should access ::NvEncRunMotionEstimationOnly API through this pointer. */
  3475. PNVENCGETLASTERROR nvEncGetLastErrorString; /**< [out]: Client should access ::nvEncGetLastErrorString API through this pointer. */
  3476. PNVENCSETIOCUDASTREAMS nvEncSetIOCudaStreams; /**< [out]: Client should access ::nvEncSetIOCudaStreams API through this pointer. */
  3477. PNVENCGETENCODEPRESETCONFIGEX nvEncGetEncodePresetConfigEx; /**< [out]: Client should access ::NvEncGetEncodePresetConfigEx() API through this pointer. */
  3478. PNVENCGETSEQUENCEPARAMEX nvEncGetSequenceParamEx; /**< [out]: Client should access ::NvEncGetSequenceParamEx() API through this pointer. */
  3479. void* reserved2[277]; /**< [in]: Reserved and must be set to NULL */
  3480. } NV_ENCODE_API_FUNCTION_LIST;
  3481. /** Macro for constructing the version field of ::_NV_ENCODEAPI_FUNCTION_LIST. */
  3482. #define NV_ENCODE_API_FUNCTION_LIST_VER NVENCAPI_STRUCT_VERSION(2)
  3483. // NvEncodeAPICreateInstance
  3484. /**
  3485. * \ingroup ENCODE_FUNC
  3486. * Entry Point to the NvEncodeAPI interface.
  3487. *
  3488. * Creates an instance of the NvEncodeAPI interface, and populates the
  3489. * pFunctionList with function pointers to the API routines implemented by the
  3490. * NvEncodeAPI interface.
  3491. *
  3492. * \param [out] functionList
  3493. *
  3494. * \return
  3495. * ::NV_ENC_SUCCESS
  3496. * ::NV_ENC_ERR_INVALID_PTR
  3497. */
  3498. NVENCSTATUS NVENCAPI NvEncodeAPICreateInstance(NV_ENCODE_API_FUNCTION_LIST *functionList);
  3499. #ifdef __cplusplus
  3500. }
  3501. #endif
  3502. #endif