Newer
Older
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
*
* The function returns an array of encode preset guids available for a given codec.
* The client can directly use one of the preset guids based upon the use case
* or target device. The preset guid chosen can be directly used in
* NV_ENC_INITIALIZE_PARAMS::presetGUID parameter to ::NvEncEncodePicture() API.
* Alternately client can also use the preset guid to retrieve the encoding config
* parameters being used by NvEncodeAPI interface for that given preset, using
* ::NvEncGetEncodePresetConfig() API. It can then modify preset config parameters
* as per its use case and send it to NvEncodeAPI interface as part of
* NV_ENC_INITIALIZE_PARAMS::encodeConfig parameter for NvEncInitializeEncoder()
* API.
*
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in] encodeGUID
* Encode GUID, corresponding to which the list of supported presets is to be
* retrieved.
* \param [in] guidArraySize
* Size of array of preset guids passed in \p preset GUIDs
* \param [out] presetGUIDs
* Array of supported Encode preset GUIDs from the NvEncodeAPI interface
* to client.
* \param [out] encodePresetGUIDCount
* Receives the number of preset GUIDs returned by the NvEncodeAPI
* interface.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncGetEncodePresetGUIDs (void* encoder, GUID encodeGUID, GUID* presetGUIDs, uint32_t guidArraySize, uint32_t* encodePresetGUIDCount);
// NvEncGetEncodePresetConfig
/**
* \brief Returns a preset config structure supported for given preset GUID.
*
* The function returns a preset config structure for a given preset guid. Before
* using this function the client must enumerate the preset guids available for
* a given codec. The preset config structure can be modified by the client depending
* upon its use case and can be then used to initialize the encoder using
* ::NvEncInitializeEncoder() API. The client can use this function only if it
* wants to modify the NvEncodeAPI preset configuration, otherwise it can
* directly use the preset guid.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in] encodeGUID
* Encode GUID, corresponding to which the list of supported presets is to be
* retrieved.
* \param [in] presetGUID
* Preset GUID, corresponding to which the Encoding configurations is to be
* retrieved.
* \param [out] presetConfig
* The requested Preset Encoder Attribute set. Refer ::_NV_ENC_CONFIG for
* more details.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_INVALID_VERSION \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncGetEncodePresetConfig (void* encoder, GUID encodeGUID, GUID presetGUID, NV_ENC_PRESET_CONFIG* presetConfig);
// NvEncInitializeEncoder
/**
* \brief Initialize the encoder.
*
* This API must be used to initialize the encoder. The initialization parameter
* is passed using \p *createEncodeParams The client must send the following
* fields of the _NV_ENC_INITIALIZE_PARAMS structure with a valid value.
* - NV_ENC_INITIALIZE_PARAMS::encodeGUID
* - NV_ENC_INITIALIZE_PARAMS::encodeWidth
* - NV_ENC_INITIALIZE_PARAMS::encodeHeight
*
* The client can pass a preset guid directly to the NvEncodeAPI interface using
* NV_ENC_INITIALIZE_PARAMS::presetGUID field. If the client doesn't pass
* NV_ENC_INITIALIZE_PARAMS::encodeConfig structure, the codec specific parameters
* will be selected based on the preset guid. The preset guid must have been
* validated by the client using ::NvEncGetEncodePresetGUIDs() API.
* If the client passes a custom ::_NV_ENC_CONFIG structure through
* NV_ENC_INITIALIZE_PARAMS::encodeConfig , it will override the codec specific parameters
* based on the preset guid. It is recommended that even if the client passes a custom config,
* it should also send a preset guid. In this case, the preset guid passed by the client
* will not override any of the custom config parameters programmed by the client,
* it is only used as a hint by the NvEncodeAPI interface to determine certain encoder parameters
* which are not exposed to the client.
*
* There are two modes of operation for the encoder namely:
* - Asynchronous mode
* - Synchronous mode
*
* The client can select asynchronous or synchronous mode by setting the \p
* enableEncodeAsync field in ::_NV_ENC_INITIALIZE_PARAMS to 1 or 0 respectively.
*\par Asynchronous mode of operation:
* The Asynchronous mode can be enabled by setting NV_ENC_INITIALIZE_PARAMS::enableEncodeAsync to 1.
* The client operating in asynchronous mode must allocate completion event object
* for each output buffer and pass the completion event object in the
* ::NvEncEncodePicture() API. The client can create another thread and wait on
* the event object to be signalled by NvEncodeAPI interface on completion of the
* encoding process for the output frame. This should unblock the main thread from
* submitting work to the encoder. When the event is signalled the client can call
* NvEncodeAPI interfaces to copy the bitstream data using ::NvEncLockBitstream()
* API. This is the preferred mode of operation.
*
* NOTE: Asynchronous mode is not supported on Linux.
*
*\par Synchronous mode of operation:
* The client can select synchronous mode by setting NV_ENC_INITIALIZE_PARAMS::enableEncodeAsync to 0.
* The client working in synchronous mode can work in a single threaded or multi
* threaded mode. The client need not allocate any event objects. The client can
* only lock the bitstream data after NvEncodeAPI interface has returned
* ::NV_ENC_SUCCESS from encode picture. The NvEncodeAPI interface can return
* ::NV_ENC_ERR_NEED_MORE_INPUT error code from ::NvEncEncodePicture() API. The
* client must not lock the output buffer in such case but should send the next
* frame for encoding. The client must keep on calling ::NvEncEncodePicture() API
* until it returns ::NV_ENC_SUCCESS. \n
* The client must always lock the bitstream data in order in which it has submitted.
* This is true for both asynchronous and synchronous mode.
*
*\par Picture type decision:
* If the client is taking the picture type decision and it must disable the picture
* type decision module in NvEncodeAPI by setting NV_ENC_INITIALIZE_PARAMS::enablePTD
* to 0. In this case the client is required to send the picture in encoding
* order to NvEncodeAPI by doing the re-ordering for B frames. \n
* If the client doesn't want to take the picture type decision it can enable
* picture type decision module in the NvEncodeAPI interface by setting
* NV_ENC_INITIALIZE_PARAMS::enablePTD to 1 and send the input pictures in display
* order.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in] createEncodeParams
* Refer ::_NV_ENC_INITIALIZE_PARAMS for details.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_INVALID_VERSION \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncInitializeEncoder (void* encoder, NV_ENC_INITIALIZE_PARAMS* createEncodeParams);
// NvEncCreateInputBuffer
/**
* \brief Allocates Input buffer.
*
* This function is used to allocate an input buffer. The client must enumerate
* the input buffer format before allocating the input buffer resources. The
* NV_ENC_INPUT_PTR returned by the NvEncodeAPI interface in the
* NV_ENC_CREATE_INPUT_BUFFER::inputBuffer field can be directly used in
* ::NvEncEncodePicture() API. The number of input buffers to be allocated by the
* client must be at least 4 more than the number of B frames being used for encoding.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in,out] createInputBufferParams
* Pointer to the ::NV_ENC_CREATE_INPUT_BUFFER structure.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_INVALID_VERSION \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncCreateInputBuffer (void* encoder, NV_ENC_CREATE_INPUT_BUFFER* createInputBufferParams);
// NvEncDestroyInputBuffer
/**
* \brief Release an input buffers.
*
* This function is used to free an input buffer. If the client has allocated
* any input buffer using ::NvEncCreateInputBuffer() API, it must free those
* input buffers by calling this function. The client must release the input
* buffers before destroying the encoder using ::NvEncDestroyEncoder() API.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in] inputBuffer
* Pointer to the input buffer to be released.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_INVALID_VERSION \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncDestroyInputBuffer (void* encoder, NV_ENC_INPUT_PTR inputBuffer);
// NvEncCreateBitstreamBuffer
/**
* \brief Allocates an output bitstream buffer
*
* This function is used to allocate an output bitstream buffer and returns a
* NV_ENC_OUTPUT_PTR to bitstream buffer to the client in the
* NV_ENC_CREATE_BITSTREAM_BUFFER::bitstreamBuffer field.
* The client can only call this function after the encoder session has been
* initialized using ::NvEncInitializeEncoder() API. The minimum number of output
* buffers allocated by the client must be at least 4 more than the number of B
* B frames being used for encoding. The client can only access the output
* bitsteam data by locking the \p bitstreamBuffer using the ::NvEncLockBitstream()
* function.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in,out] createBitstreamBufferParams
* Pointer ::NV_ENC_CREATE_BITSTREAM_BUFFER for details.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_INVALID_VERSION \n
* ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncCreateBitstreamBuffer (void* encoder, NV_ENC_CREATE_BITSTREAM_BUFFER* createBitstreamBufferParams);
// NvEncDestroyBitstreamBuffer
/**
* \brief Release a bitstream buffer.
*
* This function is used to release the output bitstream buffer allocated using
* the ::NvEncCreateBitstreamBuffer() function. The client must release the output
* bitstreamBuffer using this function before destroying the encoder session.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in] bitstreamBuffer
* Pointer to the bitstream buffer being released.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_INVALID_VERSION \n
* ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncDestroyBitstreamBuffer (void* encoder, NV_ENC_OUTPUT_PTR bitstreamBuffer);
// NvEncEncodePicture
/**
* \brief Submit an input picture for encoding.
*
* This function is used to submit an input picture buffer for encoding. The
* encoding parameters are passed using \p *encodePicParams which is a pointer
* to the ::_NV_ENC_PIC_PARAMS structure.
*
* If the client has set NV_ENC_INITIALIZE_PARAMS::enablePTD to 0, then it must
* send a valid value for the following fields.
* - NV_ENC_PIC_PARAMS::pictureType
* - NV_ENC_PIC_PARAMS_H264::displayPOCSyntax (H264 only)
* - NV_ENC_PIC_PARAMS_H264::frameNumSyntax(H264 only)
* - NV_ENC_PIC_PARAMS_H264::refPicFlag(H264 only)
*
*
*\par Asynchronous Encoding
* If the client has enabled asynchronous mode of encoding by setting
* NV_ENC_INITIALIZE_PARAMS::enableEncodeAsync to 1 in the ::NvEncInitializeEncoder()
* API ,then the client must send a valid NV_ENC_PIC_PARAMS::completionEvent.
* Incase of asynchronous mode of operation, client can queue the ::NvEncEncodePicture()
* API commands from the main thread and then queue output buffers to be processed
* to a secondary worker thread. Before the locking the output buffers in the
* secondary thread , the client must wait on NV_ENC_PIC_PARAMS::completionEvent
* it has queued in ::NvEncEncodePicture() API call. The client must always process
* completion event and the output buffer in the same order in which they have been
* submitted for encoding. The NvEncodeAPI interface is responsible for any
* re-ordering required for B frames and will always ensure that encoded bitstream
* data is written in the same order in which output buffer is submitted.
*\code
The below example shows how asynchronous encoding in case of 1 B frames
------------------------------------------------------------------------
Suppose the client allocated 4 input buffers(I1,I2..), 4 output buffers(O1,O2..)
and 4 completion events(E1, E2, ...). The NvEncodeAPI interface will need to
keep a copy of the input buffers for re-ordering and it allocates following
internal buffers (NvI1, NvI2...). These internal buffers are managed by NvEncodeAPI
and the client is not responsible for the allocating or freeing the memory of
the internal buffers.
a) The client main thread will queue the following encode frame calls.
Note the picture type is unknown to the client, the decision is being taken by
NvEncodeAPI interface. The client should pass ::_NV_ENC_PIC_PARAMS parameter
consisting of allocated input buffer, output buffer and output events in successive
::NvEncEncodePicture() API calls along with other required encode picture params.
For example:
1st EncodePicture parameters - (I1, O1, E1)
2nd EncodePicture parameters - (I2, O2, E2)
3rd EncodePicture parameters - (I3, O3, E3)
b) NvEncodeAPI SW will receive the following encode Commands from the client.
The left side shows input from client in the form (Input buffer, Output Buffer,
Output Event). The right hand side shows a possible picture type decision take by
the NvEncodeAPI interface.
(I1, O1, E1) ---P1 Frame
(I2, O2, E2) ---B2 Frame
(I3, O3, E3) ---P3 Frame
c) NvEncodeAPI interface will make a copy of the input buffers to its internal
buffersfor re-ordering. These copies are done as part of nvEncEncodePicture
function call from the client and NvEncodeAPI interface is responsible for
synchronization of copy operation with the actual encoding operation.
I1 --> NvI1
I2 --> NvI2
I3 --> NvI3
d) After returning from ::NvEncEncodePicture() call , the client must queue the output
bitstream processing work to the secondary thread. The output bitstream processing
for asynchronous mode consist of first waiting on completion event(E1, E2..)
and then locking the output bitstream buffer(O1, O2..) for reading the encoded
data. The work queued to the secondary thread by the client is in the following order
(I1, O1, E1)
(I2, O2, E2)
(I3, O3, E3)
Note they are in the same order in which client calls ::NvEncEncodePicture() API
in \p step a).
e) NvEncodeAPI interface will do the re-ordering such that Encoder HW will receive
the following encode commands:
(NvI1, O1, E1) ---P1 Frame
(NvI3, O2, E2) ---P3 Frame
(NvI2, O3, E3) ---B2 frame
f) After the encoding operations are completed, the events will be signalled
by NvEncodeAPI interface in the following order :
(O1, E1) ---P1 Frame ,output bitstream copied to O1 and event E1 signalled.
(O2, E2) ---P3 Frame ,output bitstream copied to O2 and event E2 signalled.
(O3, E3) ---B2 Frame ,output bitstream copied to O3 and event E3 signalled.
g) The client must lock the bitstream data using ::NvEncLockBitstream() API in
the order O1,O2,O3 to read the encoded data, after waiting for the events
to be signalled in the same order i.e E1, E2 and E3.The output processing is
done in the secondary thread in the following order:
Waits on E1, copies encoded bitstream from O1
Waits on E2, copies encoded bitstream from O2
Waits on E3, copies encoded bitstream from O3
-Note the client will receive the events signalling and output buffer in the
same order in which they have submitted for encoding.
-Note the LockBitstream will have picture type field which will notify the
output picture type to the clients.
-Note the input, output buffer and the output completion event are free to be
reused once NvEncodeAPI interfaced has signalled the event and the client has
copied the data from the output buffer.
* \endcode
*
*\par Synchronous Encoding
* The client can enable synchronous mode of encoding by setting
* NV_ENC_INITIALIZE_PARAMS::enableEncodeAsync to 0 in ::NvEncInitializeEncoder() API.
* The NvEncodeAPI interface may return ::NV_ENC_ERR_NEED_MORE_INPUT error code for
* some ::NvEncEncodePicture() API calls when NV_ENC_INITIALIZE_PARAMS::enablePTD
* is set to 1, but the client must not treat it as a fatal error. The NvEncodeAPI
* interface might not be able to submit an input picture buffer for encoding
* immediately due to re-ordering for B frames. The NvEncodeAPI interface cannot
* submit the input picture which is decided to be encoded as B frame as it waits
* for backward reference from temporally subsequent frames. This input picture
* is buffered internally and waits for more input picture to arrive. The client
* must not call ::NvEncLockBitstream() API on the output buffers whose
* ::NvEncEncodePicture() API returns ::NV_ENC_ERR_NEED_MORE_INPUT. The client must
* wait for the NvEncodeAPI interface to return ::NV_ENC_SUCCESS before locking the
* output bitstreams to read the encoded bitstream data. The following example
* explains the scenario with synchronous encoding with 2 B frames.
*\code
The below example shows how synchronous encoding works in case of 1 B frames
-----------------------------------------------------------------------------
Suppose the client allocated 4 input buffers(I1,I2..), 4 output buffers(O1,O2..)
and 4 completion events(E1, E2, ...). The NvEncodeAPI interface will need to
keep a copy of the input buffers for re-ordering and it allocates following
internal buffers (NvI1, NvI2...). These internal buffers are managed by NvEncodeAPI
and the client is not responsible for the allocating or freeing the memory of
the internal buffers.
The client calls ::NvEncEncodePicture() API with input buffer I1 and output buffer O1.
The NvEncodeAPI decides to encode I1 as P frame and submits it to encoder
HW and returns ::NV_ENC_SUCCESS.
The client can now read the encoded data by locking the output O1 by calling
NvEncLockBitstream API.
The client calls ::NvEncEncodePicture() API with input buffer I2 and output buffer O2.
The NvEncodeAPI decides to encode I2 as B frame and buffers I2 by copying it
to internal buffer and returns ::NV_ENC_ERR_NEED_MORE_INPUT.
The error is not fatal and it notifies client that it cannot read the encoded
data by locking the output O2 by calling ::NvEncLockBitstream() API without submitting
more work to the NvEncodeAPI interface.
The client calls ::NvEncEncodePicture() with input buffer I3 and output buffer O3.
The NvEncodeAPI decides to encode I3 as P frame and it first submits I3 for
encoding which will be used as backward reference frame for I2.
The NvEncodeAPI then submits I2 for encoding and returns ::NV_ENC_SUCESS. Both
the submission are part of the same ::NvEncEncodePicture() function call.
The client can now read the encoded data for both the frames by locking the output
O2 followed by O3 ,by calling ::NvEncLockBitstream() API.
The client must always lock the output in the same order in which it has submitted
to receive the encoded bitstream in correct encoding order.
* \endcode
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in,out] encodePicParams
* Pointer to the ::_NV_ENC_PIC_PARAMS structure.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_INVALID_VERSION \n
* ::NV_ENC_ERR_ENCODER_BUSY \n
* ::NV_ENC_ERR_NEED_MORE_INPUT \n
* ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncEncodePicture (void* encoder, NV_ENC_PIC_PARAMS* encodePicParams);
// NvEncLockBitstream
/**
* \brief Lock output bitstream buffer
*
* This function is used to lock the bitstream buffer to read the encoded data.
* The client can only access the encoded data by calling this function.
* The pointer to client accessible encoded data is returned in the
* NV_ENC_LOCK_BITSTREAM::bitstreamBufferPtr field. The size of the encoded data
* in the output buffer is returned in the NV_ENC_LOCK_BITSTREAM::bitstreamSizeInBytes
* The NvEncodeAPI interface also returns the output picture type and picture structure
* of the encoded frame in NV_ENC_LOCK_BITSTREAM::pictureType and
* NV_ENC_LOCK_BITSTREAM::pictureStruct fields respectively. If the client has
* set NV_ENC_LOCK_BITSTREAM::doNotWait to 1, the function might return
* ::NV_ENC_ERR_LOCK_BUSY if client is operating in synchronous mode. This is not
* a fatal failure if NV_ENC_LOCK_BITSTREAM::doNotWait is set to 1. In the above case the client can
* retry the function after few milliseconds.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in,out] lockBitstreamBufferParams
* Pointer to the ::_NV_ENC_LOCK_BITSTREAM structure.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_INVALID_VERSION \n
* ::NV_ENC_ERR_LOCK_BUSY \n
* ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncLockBitstream (void* encoder, NV_ENC_LOCK_BITSTREAM* lockBitstreamBufferParams);
// NvEncUnlockBitstream
/**
* \brief Unlock the output bitstream buffer
*
* This function is used to unlock the output bitstream buffer after the client
* has read the encoded data from output buffer. The client must call this function
* to unlock the output buffer which it has previously locked using ::NvEncLockBitstream()
* function. Using a locked bitstream buffer in ::NvEncEncodePicture() API will cause
* the function to fail.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in,out] bitstreamBuffer
* bitstream buffer pointer being unlocked
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncUnlockBitstream (void* encoder, NV_ENC_OUTPUT_PTR bitstreamBuffer);
// NvLockInputBuffer
/**
* \brief Locks an input buffer
*
* This function is used to lock the input buffer to load the uncompressed YUV
* pixel data into input buffer memory. The client must pass the NV_ENC_INPUT_PTR
* it had previously allocated using ::NvEncCreateInputBuffer()in the
* NV_ENC_LOCK_INPUT_BUFFER::inputBuffer field.
* The NvEncodeAPI interface returns pointer to client accessible input buffer
* memory in NV_ENC_LOCK_INPUT_BUFFER::bufferDataPtr field.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in,out] lockInputBufferParams
* Pointer to the ::_NV_ENC_LOCK_INPUT_BUFFER structure
*
* \return
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_INVALID_VERSION \n
* ::NV_ENC_ERR_LOCK_BUSY \n
* ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncLockInputBuffer (void* encoder, NV_ENC_LOCK_INPUT_BUFFER* lockInputBufferParams);
// NvUnlockInputBuffer
/**
* \brief Unlocks the input buffer
*
* This function is used to unlock the input buffer memory previously locked for
* uploading YUV pixel data. The input buffer must be unlocked before being used
* again for encoding, otherwise NvEncodeAPI will fail the ::NvEncEncodePicture()
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in] inputBuffer
* Pointer to the input buffer that is being unlocked.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_VERSION \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
* ::NV_ENC_ERR_GENERIC \n
*
*
*/
NVENCSTATUS NVENCAPI NvEncUnlockInputBuffer (void* encoder, NV_ENC_INPUT_PTR inputBuffer);
// NvEncGetEncodeStats
/**
* \brief Get encoding statistics.
*
* This function is used to retrieve the encoding statistics.
* This API is not supported when encode device type is CUDA.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in,out] encodeStats
* Pointer to the ::_NV_ENC_STAT structure.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncGetEncodeStats (void* encoder, NV_ENC_STAT* encodeStats);
// NvEncGetSequenceParams
/**
* \brief Get encoded sequence and picture header.
*
* This function can be used to retrieve the sequence and picture header out of
* band. The client must call this function only after the encoder has been
* initialized using ::NvEncInitializeEncoder() function. The client must
* allocate the memory where the NvEncodeAPI interface can copy the bitstream
* header and pass the pointer to the memory in NV_ENC_SEQUENCE_PARAM_PAYLOAD::spsppsBuffer.
* The size of buffer is passed in the field NV_ENC_SEQUENCE_PARAM_PAYLOAD::inBufferSize.
* The NvEncodeAPI interface will copy the bitstream header payload and returns
* the actual size of the bitstream header in the field
* NV_ENC_SEQUENCE_PARAM_PAYLOAD::outSPSPPSPayloadSize.
* The client must call ::NvEncGetSequenceParams() function from the same thread which is
* being used to call ::NvEncEncodePicture() function.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in,out] sequenceParamPayload
* Pointer to the ::_NV_ENC_SEQUENCE_PARAM_PAYLOAD structure.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_VERSION \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncGetSequenceParams (void* encoder, NV_ENC_SEQUENCE_PARAM_PAYLOAD* sequenceParamPayload);
// NvEncRegisterAsyncEvent
/**
* \brief Register event for notification to encoding completion.
*
* This function is used to register the completion event with NvEncodeAPI
* interface. The event is required when the client has configured the encoder to
* work in asynchronous mode. In this mode the client needs to send a completion
* event with every output buffer. The NvEncodeAPI interface will signal the
* completion of the encoding process using this event. Only after the event is
* signalled the client can get the encoded data using ::NvEncLockBitstream() function.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in] eventParams
* Pointer to the ::_NV_ENC_EVENT_PARAMS structure.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_VERSION \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncRegisterAsyncEvent (void* encoder, NV_ENC_EVENT_PARAMS* eventParams);
// NvEncUnregisterAsyncEvent
/**
* \brief Unregister completion event.
*
* This function is used to unregister completion event which has been previously
* registered using ::NvEncRegisterAsyncEvent() function. The client must unregister
* all events before destroying the encoder using ::NvEncDestroyEncoder() function.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in] eventParams
* Pointer to the ::_NV_ENC_EVENT_PARAMS structure.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_VERSION \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncUnregisterAsyncEvent (void* encoder, NV_ENC_EVENT_PARAMS* eventParams);
// NvEncMapInputResource
/**
* \brief Map an externally created input resource pointer for encoding.
*
* Maps an externally allocated input resource [using and returns a NV_ENC_INPUT_PTR
* which can be used for encoding in the ::NvEncEncodePicture() function. The
* mapped resource is returned in the field NV_ENC_MAP_INPUT_RESOURCE::outputResourcePtr.
* The NvEncodeAPI interface also returns the buffer format of the mapped resource
* in the field NV_ENC_MAP_INPUT_RESOURCE::outbufferFmt.
* This function provides synchronization guarantee that any direct3d or cuda
* work submitted on the input buffer is completed before the buffer is used for encoding.
* The client should not access any input buffer while they are mapped by the encoder.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in,out] mapInputResParams
* Pointer to the ::_NV_ENC_MAP_INPUT_RESOURCE structure.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_VERSION \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
* ::NV_ENC_ERR_RESOURCE_NOT_REGISTERED \n
* ::NV_ENC_ERR_MAP_FAILED \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncMapInputResource (void* encoder, NV_ENC_MAP_INPUT_RESOURCE* mapInputResParams);
// NvEncUnmapInputResource
/**
* \brief UnMaps a NV_ENC_INPUT_PTR which was mapped for encoding
*
*
* UnMaps an input buffer which was previously mapped using ::NvEncMapInputResource()
* API. The mapping created using ::NvEncMapInputResource() should be invalidated
* using this API before the external resource is destroyed by the client. The client
* must unmap the buffer after ::NvEncLockBitstream() API returns succuessfully for encode
* work submitted using the mapped input buffer.
*
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in] mappedInputBuffer
* Pointer to the NV_ENC_INPUT_PTR
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_VERSION \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
* ::NV_ENC_ERR_RESOURCE_NOT_REGISTERED \n
* ::NV_ENC_ERR_RESOURCE_NOT_MAPPED \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncUnmapInputResource (void* encoder, NV_ENC_INPUT_PTR mappedInputBuffer);
// NvEncDestroyEncoder
/**
* \brief Destroy Encoding Session
*
* Destroys the encoder session previously created using ::NvEncOpenEncodeSession()
* function. The client must flush the encoder before freeing any resources. In order
* to flush the encoder the client must pass a NULL encode picture packet and either
* wait for the ::NvEncEncodePicture() function to return in synchronous mode or wait
* for the flush event to be signaled by the encoder in asynchronous mode.
* The client must free all the input and output resources created using the
* NvEncodeAPI interface before destroying the encoder. If the client is operating
* in asynchronous mode, it must also unregister the completion events previously
* registered.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncDestroyEncoder (void* encoder);
// NvEncInvalidateRefFrames
/**
* \brief Invalidate reference frames
*
* Invalidates reference frame based on the time stamp provided by the client.
* The encoder marks any reference frames or any frames which have been reconstructed
* using the corrupt frame as invalid for motion estimation and uses older reference
* frames for motion estimation. The encoded forces the current frame to be encoded
* as an intra frame if no reference frames are left after invalidation process.
* This is useful for low latency application for error resiliency. The client
* is recommended to set NV_ENC_CONFIG_H264::maxNumRefFrames to a large value so
* that encoder can keep a backup of older reference frames in the DPB and can use them
* for motion estimation when the newer reference frames have been invalidated.
* This API can be called multiple times.
*
* \param [in] encoder
* Pointer to the NvEncodeAPI interface.
* \param [in] invalidRefFrameTimeStamp
* Timestamp of the invalid reference frames which needs to be invalidated.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncInvalidateRefFrames(void* encoder, uint64_t invalidRefFrameTimeStamp);
// NvEncOpenEncodeSessionEx
/**
* \brief Opens an encoding session.
*
* Opens an encoding session and returns a pointer to the encoder interface in
* the \p **encoder parameter. The client should start encoding process by calling
* this API first.
* The client must pass a pointer to IDirect3DDevice9/CUDA interface in the \p *device parameter.
* If the creation of encoder session fails, the client must call ::NvEncDestroyEncoder API
* before exiting.
*
* \param [in] openSessionExParams
* Pointer to a ::NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS structure.
* \param [out] encoder
* Encode Session pointer to the NvEncodeAPI interface.
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_NO_ENCODE_DEVICE \n
* ::NV_ENC_ERR_UNSUPPORTED_DEVICE \n
* ::NV_ENC_ERR_INVALID_DEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncOpenEncodeSessionEx (NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS *openSessionExParams, void** encoder);
// NvEncRegisterResource
/**
* \brief Registers a resource with the Nvidia Video Encoder Interface.
*
* Registers a resource with the Nvidia Video Encoder Interface for book keeping.
* The client is expected to pass the registered resource handle as well, while calling ::NvEncMapInputResource API.
* This API is not implemented for the DirectX Interface.
* DirectX based clients need not change their implementation.
*
* \param [in] encoder
* Pointer to the NVEncodeAPI interface.
*
* \param [in] registerResParams
* Pointer to a ::_NV_ENC_REGISTER_RESOURCE structure
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_VERSION \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
* ::NV_ENC_ERR_RESOURCE_REGISTER_FAILED \n
* ::NV_ENC_ERR_GENERIC \n
* ::NV_ENC_ERR_UNIMPLEMENTED \n
*
*/
NVENCSTATUS NVENCAPI NvEncRegisterResource (void* encoder, NV_ENC_REGISTER_RESOURCE* registerResParams);
// NvEncUnregisterResource
/**
* \brief Unregisters a resource previously registered with the Nvidia Video Encoder Interface.
*
* Unregisters a resource previously registered with the Nvidia Video Encoder Interface.
* The client is expected to unregister any resource that it has registered with the
* Nvidia Video Encoder Interface before destroying the resource.
* This API is not implemented for the DirectX Interface.
* DirectX based clients need not change their implementation.
*
* \param [in] encoder
* Pointer to the NVEncodeAPI interface.
*
* \param [in] registeredResource
* The registered resource pointer that was returned in ::NvEncRegisterResource.
*
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_INVALID_ENCODERDEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_OUT_OF_MEMORY \n
* ::NV_ENC_ERR_INVALID_VERSION \n
* ::NV_ENC_ERR_INVALID_PARAM \n
* ::NV_ENC_ERR_ENCODER_NOT_INITIALIZED \n
* ::NV_ENC_ERR_RESOURCE_NOT_REGISTERED \n
* ::NV_ENC_ERR_GENERIC \n
* ::NV_ENC_ERR_UNIMPLEMENTED \n
*
*/
NVENCSTATUS NVENCAPI NvEncUnregisterResource (void* encoder, NV_ENC_REGISTERED_PTR registeredResource);
// NvEncReconfigureEncoder
/**
* \brief Reconfigure an existing encoding session.
*
* Reconfigure an existing encoding session.
* The client should call this API to change/reconfigure the parameter passed during
* NvEncInitializeEncoder API call.
* Currently Reconfiguration of following are not supported.
* Change in GOP structure.
* Change in sync-Async mode.
* Change in MaxWidth & MaxHeight.
* Change in PTDmode.
*
* Resolution change is possible only if maxEncodeWidth & maxEncodeHeight of NV_ENC_INITIALIZE_PARAMS
* is set while creating encoder session.
*
* \param [in] encoder
* Pointer to the NVEncodeAPI interface.
*
* \param [in] reInitEncodeParams
* Pointer to a ::NV_ENC_RECONFIGURE_PARAMS structure.
* \return
* ::NV_ENC_SUCCESS \n
* ::NV_ENC_ERR_INVALID_PTR \n
* ::NV_ENC_ERR_NO_ENCODE_DEVICE \n
* ::NV_ENC_ERR_UNSUPPORTED_DEVICE \n
* ::NV_ENC_ERR_INVALID_DEVICE \n
* ::NV_ENC_ERR_DEVICE_NOT_EXIST \n
* ::NV_ENC_ERR_UNSUPPORTED_PARAM \n
* ::NV_ENC_ERR_GENERIC \n
*
*/
NVENCSTATUS NVENCAPI NvEncReconfigureEncoder (void *encoder, NV_ENC_RECONFIGURE_PARAMS* reInitEncodeParams);
// NvEncCreateMVBuffer
/**
* \brief Allocates output MV buffer for ME only mode.
*
* This function is used to allocate an output MV buffer. The size of the mvBuffer is
* dependent on the frame height and width of the last ::NvEncCreateInputBuffer() call.
* The NV_ENC_OUTPUT_PTR returned by the NvEncodeAPI interface in the
* ::NV_ENC_CREATE_MV_BUFFER::mvBuffer field should be used in
* ::NvEncRunMotionEstimationOnly() API.
* Client must lock ::NV_ENC_CREATE_MV_BUFFER::mvBuffer using ::NvEncLockBitstream() API to get the motion vector data.
*