xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.


Ticket #2145: nvenc-8.2-to-9.0.diff

File nvenc-8.2-to-9.0.diff, 22.4 KB (added by Antoine Martin, 2 years ago)

diff since last version

  • nvEncodeAPI.h

    old new  
    11/*
    22 * This copyright notice applies to this header file only:
    33 *
    4  * Copyright (c) 2010-2018 NVIDIA Corporation
     4 * Copyright (c) 2010-2019 NVIDIA Corporation
    55 *
    66 * Permission is hereby granted, free of charge, to any person
    77 * obtaining a copy of this software and associated documentation
     
    109109typedef void* NV_ENC_OUTPUT_PTR;            /**< NVENCODE API output buffer*/
    110110typedef void* NV_ENC_REGISTERED_PTR;        /**< A Resource that has been registered with NVENCODE API*/
    111111
    112 #define NVENCAPI_MAJOR_VERSION 8
    113 #define NVENCAPI_MINOR_VERSION 1
     112#define NVENCAPI_MAJOR_VERSION 9
     113#define NVENCAPI_MINOR_VERSION 0
    114114
    115115#define NVENCAPI_VERSION (NVENCAPI_MAJOR_VERSION | (NVENCAPI_MINOR_VERSION << 24))
    116116
     
    310310    NV_ENC_PIC_TYPE_BI              = 0x04,    /**< Bi-directionally predicted with only Intra MBs */
    311311    NV_ENC_PIC_TYPE_SKIPPED         = 0x05,    /**< Picture is skipped */
    312312    NV_ENC_PIC_TYPE_INTRA_REFRESH   = 0x06,    /**< First picture in intra refresh cycle */
     313    NV_ENC_PIC_TYPE_NONREF_P        = 0x07,    /**< Non reference P picture */           
    313314    NV_ENC_PIC_TYPE_UNKNOWN         = 0xFF     /**< Picture type unknown */
    314315} NV_ENC_PIC_TYPE;
    315316
     
    358359                                                                             where a pixel is represented by a 32-bit word with R
    359360                                                                             in the lowest 10 bits, G in the next 10 bits, B in the
    360361                                                                             10 bits after that and A in the highest 2 bits. */
     362    NV_ENC_BUFFER_FORMAT_U8                              = 0x40000000,  /**< Buffer format representing one-dimensional buffer.
     363                                                                             This format should be used only when registering the
     364                                                                             resource as output buffer, which will be used to write
     365                                                                             the encoded bit stream or H.264 ME only mode output. */
    361366} NV_ENC_BUFFER_FORMAT;
    362367
    363368#define NV_ENC_BUFFER_FORMAT_NV12_PL NV_ENC_BUFFER_FORMAT_NV12
     
    611616typedef enum _NV_ENC_BFRAME_REF_MODE
    612617{
    613618    NV_ENC_BFRAME_REF_MODE_DISABLED = 0x0,          /**< B frame is not used for reference */
    614     NV_ENC_BFRAME_REF_MODE_EACH     = 0x1,          /**< Each B-frame will be used for reference. currently not supported */
     619    NV_ENC_BFRAME_REF_MODE_EACH     = 0x1,          /**< Each B-frame will be used for reference. currently not supported for H.264 */
    615620    NV_ENC_BFRAME_REF_MODE_MIDDLE   = 0x2,          /**< Only(Number of B-frame)/2 th B-frame will be used for reference */
    616621} NV_ENC_BFRAME_REF_MODE;
    617622
     
    677682{
    678683    NV_ENC_INPUT_RESOURCE_TYPE_DIRECTX          = 0x0,   /**< input resource type is a directx9 surface*/
    679684    NV_ENC_INPUT_RESOURCE_TYPE_CUDADEVICEPTR    = 0x1,   /**< input resource type is a cuda device pointer surface*/
    680     NV_ENC_INPUT_RESOURCE_TYPE_CUDAARRAY        = 0x2,   /**< input resource type is a cuda array surface */
     685    NV_ENC_INPUT_RESOURCE_TYPE_CUDAARRAY        = 0x2,   /**< input resource type is a cuda array surface.
     686                                                              This array must be a 2D array and the CUDA_ARRAY3D_SURFACE_LDST
     687                                                              flag must have been specified when creating it. */
    681688    NV_ENC_INPUT_RESOURCE_TYPE_OPENGL_TEX       = 0x3    /**< input resource type is an OpenGL texture */
    682689} NV_ENC_INPUT_RESOURCE_TYPE;
    683690
    684691/**
     692 *  Buffer usage
     693 */
     694typedef enum _NV_ENC_BUFFER_USAGE
     695{
     696    NV_ENC_INPUT_IMAGE              = 0x0,          /**< Registered surface will be used for input image */
     697    NV_ENC_OUTPUT_MOTION_VECTOR     = 0x1,          /**< Registered surface will be used for output of H.264 ME only mode.
     698                                                         This buffer usage type is not supported for HEVC ME only mode. */
     699    NV_ENC_OUTPUT_BITSTREAM         = 0x2           /**< Registered surface will be used for output bitstream in encoding */
     700} NV_ENC_BUFFER_USAGE;
     701
     702/**
    685703 *  Encoder Device type
    686704 */
    687705typedef enum _NV_ENC_DEVICE_TYPE
     
    10441062
    10451063
    10461064/**
     1065 * Encoder Output parameters
     1066 */
     1067typedef struct _NV_ENC_ENCODE_OUT_PARAMS
     1068{
     1069    uint32_t                  version;                 /**< [out]: Struct version. */
     1070    uint32_t                  bitstreamSizeInBytes;    /**< [out]: Encoded bitstream size in bytes */
     1071    uint32_t                  reserved[62];            /**< [out]: Reserved and must be set to 0 */
     1072} NV_ENC_ENCODE_OUT_PARAMS;
     1073
     1074/** NV_ENC_ENCODE_OUT_PARAMS struct version. */
     1075#define NV_ENC_ENCODE_OUT_PARAMS_VER NVENCAPI_STRUCT_VERSION(1)
     1076
     1077/**
    10471078 * Creation parameters for input buffer.
    10481079 */
    10491080typedef struct _NV_ENC_CREATE_INPUT_BUFFER
     
    11081139typedef struct _NV_ENC_HEVC_MV_DATA
    11091140{
    11101141    NV_ENC_MVECTOR    mv[4];               /**< up to 4 vectors within a CU */
    1111     uint8_t           cuType;              /**< 0 (I), 1(P), 2 (Skip) */
     1142    uint8_t           cuType;              /**< 0 (I), 1(P) */
    11121143    uint8_t           cuSize;              /**< 0: 8x8, 1: 16x16, 2: 32x32, 3: 64x64 */
    11131144    uint8_t           partitionMode;       /**< The CU partition mode
    11141145                                                0 (2Nx2N), 1 (2NxN), 2(Nx2N), 3 (NxN),
     
    13861417                                                                               Set to 1 to use "LTR Trust" mode of LTR operation. Clients are discouraged to use "LTR Trust" mode as this mode may
    13871418                                                                               be deprecated in future releases.
    13881419                                                                               Set to 0 when using "LTR Per Picture" mode of LTR operation. */
    1389     uint32_t                            reserved1[217];             /**< [in]: Reserved and must be set to 0.*/
     1420    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.*/
     1421    uint32_t                            reserved1[216];             /**< [in]: Reserved and must be set to 0.*/
    13901422    void*    reserved2[64];                                         /**< [in]: Reserved and must be set to NULL */
    13911423} NV_ENC_CONFIG_HEVC;
    13921424
     
    14821514                                                                                           NV_ENC_PIC_PARAMS::meHintRefPicDist should preferably be set with enablePTD=1. */
    14831515    uint32_t                                   enableMEOnlyMode          :1;    /**< [in]: Set to 1 to enable ME Only Mode .*/
    14841516    uint32_t                                   enableWeightedPrediction  :1;    /**< [in]: Set this to 1 to enable weighted prediction. Not supported if encode session is configured for B-Frames( 'frameIntervalP' in NV_ENC_CONFIG is greater than 1).*/
    1485     uint32_t                                   reservedBitFields         :27;   /**< [in]: Reserved bitfields and must be set to 0 */
     1517    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. */
     1518    uint32_t                                   reservedBitFields         :26;   /**< [in]: Reserved bitfields and must be set to 0 */
    14861519    uint32_t                                   privDataSize;                    /**< [in]: Reserved private data buffer size and must be set to 0 */
    14871520    void*                                      privData;                        /**< [in]: Reserved private data buffer and must be set to NULL */
    14881521    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.
     
    16011634    uint32_t ltrMarkFrameIdx;                            /**< [in]: Specifies the long term referenceframe index to use for marking this frame as LTR.*/
    16021635    uint32_t ltrUseFrameBitmap;                          /**< [in]: Specifies the the associated bitmap of LTR frame indices to use when encoding this frame. */
    16031636    uint32_t ltrUsageMode;                               /**< [in]: Not supported. Reserved for future use and must be set to 0. */
    1604     uint32_t reserved [243];                             /**< [in]: Reserved and must be set to 0. */
    1605     void*    reserved2[62];                              /**< [in]: Reserved and must be set to NULL. */
     1637    uint32_t forceIntraSliceCount;                       /**< [in]: Specfies the number of slices to be forced to Intra in the current picture.
     1638                                                                    This option along with forceIntraSliceIdx[] array needs to be used with sliceMode = 3 only */
     1639    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.
     1640                                                                    The number of entries in this array should be equal to forceIntraSliceCount */
     1641    uint32_t reserved [242];                             /**< [in]: Reserved and must be set to 0. */
     1642    void*    reserved2[61];                              /**< [in]: Reserved and must be set to NULL. */
    16061643} NV_ENC_PIC_PARAMS_H264;
    16071644
    16081645/**
     
    16731710    uint64_t                                    inputTimeStamp;                 /**< [in]: Specifies presentation timestamp associated with the input picture. */
    16741711    uint64_t                                    inputDuration;                  /**< [in]: Specifies duration of the input picture */
    16751712    NV_ENC_INPUT_PTR                            inputBuffer;                    /**< [in]: Specifies the input buffer pointer. Client must use a pointer obtained from ::NvEncCreateInputBuffer() or ::NvEncMapInputResource() APIs.*/
    1676     NV_ENC_OUTPUT_PTR                           outputBitstream;                /**< [in]: Specifies the pointer to output buffer. Client should use a pointer obtained from ::NvEncCreateBitstreamBuffer() API. */
     1713    NV_ENC_OUTPUT_PTR                           outputBitstream;                /**< [in]: Specifies the output buffer pointer.
     1714                                                                                           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.
     1715                                                                                           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
     1716                                                                                           should use a pointer obtained from ::NvEncMapInputResource() API, when mapping this output buffer and assign it to NV_ENC_PIC_PARAMS::outputBitstream.
     1717                                                                                           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
     1718                                                                                           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
     1719                                                                                           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
     1720                                                                                           the default stream. */
    16771721    void*                                       completionEvent;                /**< [in]: Specifies an event to be signalled on completion of encoding of this Frame [only if operating in Asynchronous mode]. Each output buffer should be associated with a distinct event pointer. */
    16781722    NV_ENC_BUFFER_FORMAT                        bufferFmt;                      /**< [in]: Specifies the input buffer format. */
    16791723    NV_ENC_PIC_STRUCT                           pictureStruct;                  /**< [in]: Specifies structure of the input picture. */
     
    17151759    uint32_t                inputHeight;                        /**< [in]: Specifies the input buffer height */
    17161760    NV_ENC_INPUT_PTR        inputBuffer;                        /**< [in]: Specifies the input buffer pointer. Client must use a pointer obtained from NvEncCreateInputBuffer() or NvEncMapInputResource() APIs. */
    17171761    NV_ENC_INPUT_PTR        referenceFrame;                     /**< [in]: Specifies the reference frame pointer */
    1718     NV_ENC_OUTPUT_PTR       mvBuffer;                           /**< [in]: Specifies the pointer to motion vector data buffer allocated by NvEncCreateMVBuffer. Client must lock mvBuffer using ::NvEncLockBitstream() API to get the motion vector data. */
     1762    NV_ENC_OUTPUT_PTR       mvBuffer;                           /**< [in]: Specifies the output buffer pointer.
     1763                                                                           If NV_ENC_INITIALIZE_PARAMS::enableOutputInVidmem is set to 0, specifies the pointer to motion vector data buffer allocated by NvEncCreateMVBuffer.
     1764                                                                           Client must lock mvBuffer using ::NvEncLockBitstream() API to get the motion vector data.
     1765                                                                           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
     1766                                                                           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
     1767                                                                           output buffer and assign it to NV_ENC_MEONLY_PARAMS::mvBuffer. All CUDA operations on this buffer must use the default stream. */
    17191768    NV_ENC_BUFFER_FORMAT    bufferFmt;                          /**< [in]: Specifies the input buffer format. */
    17201769    void*                   completionEvent;                    /**< [in]: Specifies an event to be signalled on completion of motion estimation
    17211770                                                                           of this Frame [only if operating in Asynchronous mode].
     
    17451794    uint32_t                version;                     /**< [in]: Struct version. Must be set to ::NV_ENC_LOCK_BITSTREAM_VER. */
    17461795    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. */
    17471796    uint32_t                ltrFrame          :1;        /**< [out]: Flag indicating this frame is marked as LTR frame */
    1748     uint32_t                reservedBitFields :30;       /**< [in]: Reserved bit fields and must be set to 0 */
     1797    uint32_t                getRCStats        :1;        /**< [in]: If this flag is set then lockBitstream call will add additional intra-inter MB count and average MVX, MVY */
     1798    uint32_t                reservedBitFields :29;       /**< [in]: Reserved bit fields and must be set to 0 */
    17491799    void*                   outputBitstream;             /**< [in]: Pointer to the bitstream buffer being locked. */
    17501800    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. */
    17511801    uint32_t                frameIdx;                    /**< [out]: Frame no. for which the bitstream is being retrieved. */
     
    17631813    uint32_t                frameSatd;                   /**< [out]: Total SATD cost for whole frame. */
    17641814    uint32_t                ltrFrameIdx;                 /**< [out]: Frame index associated with this LTR frame. */
    17651815    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. */
    1766     uint32_t                reserved [236];              /**< [in]: Reserved and must be set to 0 */
     1816    uint32_t                reserved[13];                /**< [in]: Reserved and must be set to 0 */
     1817    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. */
     1818    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. */
     1819    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. */
     1820    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. */
     1821    uint32_t                reserved1[219];              /**< [in]: Reserved and must be set to 0 */
    17671822    void*                   reserved2[64];               /**< [in]: Reserved and must be set to NULL */
    17681823} NV_ENC_LOCK_BITSTREAM;
    17691824
     
    18351890                                                                           ::NV_ENC_INPUT_RESOURCE_TYPE_OPENGL_TEX */
    18361891    uint32_t                    width;                          /**< [in]: Input buffer Width. */
    18371892    uint32_t                    height;                         /**< [in]: Input buffer Height. */
    1838     uint32_t                    pitch;                          /**< [in]: Input buffer Pitch.  */
     1893    uint32_t                    pitch;                          /**< [in]: Input buffer Pitch.
     1894                                                                           For ::NV_ENC_INPUT_RESOURCE_TYPE_DIRECTX resources, set this to 0.
     1895                                                                           For ::NV_ENC_INPUT_RESOURCE_TYPE_CUDADEVICEPTR resources, set this to
     1896                                                                             the pitch as obtained from cuMemAllocPitch(), or to the width in
     1897                                                                             bytes (if this resource was created by using cuMemAlloc()). This
     1898                                                                             value must be a multiple of 4.
     1899                                                                           For ::NV_ENC_INPUT_RESOURCE_TYPE_CUDAARRAY resources, set this to the
     1900                                                                             width of the allocation in bytes (i.e.
     1901                                                                             CUDA_ARRAY3D_DESCRIPTOR::Width * CUDA_ARRAY3D_DESCRIPTOR::NumChannels).
     1902                                                                           For ::NV_ENC_INPUT_RESOURCE_TYPE_OPENGL_TEX resources, set this to the
     1903                                                                             texture width multiplied by the number of components in the texture
     1904                                                                             format. */
    18391905    uint32_t                    subResourceIndex;               /**< [in]: Subresource Index of the DirectX resource to be registered. Should be set to 0 for other interfaces. */
    18401906    void*                       resourceToRegister;             /**< [in]: Handle to the resource that is being registered. */
    18411907    NV_ENC_REGISTERED_PTR       registeredResource;             /**< [out]: Registered resource handle. This should be used in future interactions with the Nvidia Video Encoder Interface. */
    18421908    NV_ENC_BUFFER_FORMAT        bufferFormat;                   /**< [in]: Buffer format of resource to be registered. */
    1843     uint32_t                    reserved1[248];                 /**< [in]: Reserved and must be set to 0. */
     1909    NV_ENC_BUFFER_USAGE         bufferUsage;                    /**< [in]: Usage of resource to be registered. */
     1910    uint32_t                    reserved1[247];                 /**< [in]: Reserved and must be set to 0. */
    18441911    void*                       reserved2[62];                  /**< [in]: Reserved and must be set to NULL. */
    18451912} NV_ENC_REGISTER_RESOURCE;
    18461913
     
    29322999 * mapped resource is returned in the field NV_ENC_MAP_INPUT_RESOURCE::outputResourcePtr.
    29333000 * The NvEncodeAPI interface also returns the buffer format of the mapped resource
    29343001 * in the field NV_ENC_MAP_INPUT_RESOURCE::outbufferFmt.
    2935  * This function provides synchronization guarantee that any graphics or compute
    2936  * work submitted on the input buffer is completed before the buffer is used for encoding.
     3002 * This function provides synchronization guarantee that any graphics work submitted
     3003 * on the input buffer is completed before the buffer is used for encoding. This is
     3004 * also true for compute (i.e. CUDA) work, provided that the previous workload using
     3005 * the input resource was submitted to the default stream.
    29373006 * The client should not access any input buffer while they are mapped by the encoder.
    29383007 *
    29393008 * \param [in] encoder