xpra icon
Bug tracker and wiki

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


Ticket #370: nvenc-sdkv2-v2.patch

File nvenc-sdkv2-v2.patch, 11.5 KB (added by Antoine Martin, 7 years ago)

updated (smaller) patch to apply on top of r4620

  • xpra/codecs/nvenc/encoder.pyx

     
    235235        uint32_t    ltrFrame            #[out]: Flag indicating this frame is marked as LTR frame
    236236        uint32_t    reservedBitFields   #[in]: Reserved bit fields and must be set to 0
    237237        void*       outputBitstream     #[in]: Pointer to the bitstream buffer being locked.
    238         uint32_t*   sliceOffsets        #[in,out]: Array which receives the slice offsets. Currently used only when NV_ENC_CONFIG_H264::sliceMode == 3. Array size must be equal to NV_ENC_CONFIG_H264::sliceModeData.
     238        #uint32_t*   sliceOffsets        #[in,out]: Array which receives the slice offsets. Currently used only when NV_ENC_CONFIG_H264::sliceMode == 3. Array size must be equal to NV_ENC_CONFIG_H264::sliceModeData.
    239239        uint32_t    frameIdx            #[out]: Frame no. for which the bitstream is being retrieved.
    240240        uint32_t    hwEncodeStatus      #[out]: The NvEncodeAPI interface status for the locked picture.
    241241        uint32_t    numSlices           #[out]: Number of slices in the encoded picture. Will be reported only if NV_ENC_INITIALIZE_PARAMS::reportSliceOffsets set to 1.
     
    319319    GUID NV_ENC_H264_PROFILE_HIGH_GUID
    320320    GUID NV_ENC_H264_PROFILE_STEREO_GUID
    321321    GUID NV_ENC_H264_PROFILE_SVC_TEMPORAL_SCALABILTY
    322     GUID NV_ENC_H264_PROFILE_CONSTRAINED_HIGH_GUID
     322    #GUID NV_ENC_H264_PROFILE_CONSTRAINED_HIGH_GUID
    323323    GUID NV_ENC_MPEG2_PROFILE_SIMPLE_GUID
    324324    GUID NV_ENC_MPEG2_PROFILE_MAIN_GUID
    325325    GUID NV_ENC_MPEG2_PROFILE_HIGH_GUID
     
    335335    GUID NV_ENC_PRESET_HQ_GUID
    336336    GUID NV_ENC_PRESET_BD_GUID
    337337    #V3 ONLY:
    338     GUID NV_ENC_PRESET_LOW_LATENCY_DEFAULT_GUID
    339     GUID NV_ENC_PRESET_LOW_LATENCY_HQ_GUID
    340     GUID NV_ENC_PRESET_LOW_LATENCY_HP_GUID
     338    #GUID NV_ENC_PRESET_LOW_LATENCY_DEFAULT_GUID
     339    #GUID NV_ENC_PRESET_LOW_LATENCY_HQ_GUID
     340    #GUID NV_ENC_PRESET_LOW_LATENCY_HP_GUID
     341    #NV_ENC_CODEC_MPEG2_GUID, etc..
    341342    #V2 ONLY:
    342     #GUID NV_ENC_PRESET_VC_GUID
    343     #GUID NV_ENC_PRESET_WIDI_GUID
    344     #GUID NV_ENC_PRESET_CAMERA_GUID
    345     #GUID NV_ENC_PRESET_AVCHD_GUID
    346     #GUID NV_ENC_PRESET_IPOD_GUID
    347     #GUID NV_ENC_PRESET_PSP_GUID
    348     #GUID NV_ENC_PRESET_GAME_CAPTURE_GUID
    349     #GUID NV_ENC_PRESET_CLOUD_GAMING_720p60_GUID
    350     #GUID NV_ENC_PRESET_CLOUD_GAMING_720p30_GUID
    351     #GUID NV_ENC_PRESET_DESKTOP_CAPTURE_GUID
    352     #GUID NV_ENC_PRESET_MVC_STEREO_GUID
    353     #GUID NV_ENC_PRESET_CLOUD_GAMING_720p60_GUID
    354     #GUID NV_ENC_PRESET_CLOUD_GAMING_720p30_GUID
    355     #GUID NV_ENC_PRESET_DESKTOP_CAPTURE_GUID
    356     #GUID NV_ENC_PRESET_MVC_STEREO_GUID
     343    GUID NV_ENC_PRESET_VC_GUID
     344    GUID NV_ENC_PRESET_WIDI_GUID
     345    GUID NV_ENC_PRESET_CAMERA_GUID
     346    GUID NV_ENC_PRESET_AVCHD_GUID
     347    GUID NV_ENC_PRESET_IPOD_GUID
     348    GUID NV_ENC_PRESET_PSP_GUID
     349    GUID NV_ENC_PRESET_GAME_CAPTURE_GUID
     350    GUID NV_ENC_PRESET_CLOUD_GAMING_720p60_GUID
     351    GUID NV_ENC_PRESET_CLOUD_GAMING_720p30_GUID
     352    GUID NV_ENC_PRESET_DESKTOP_CAPTURE_GUID
     353    GUID NV_ENC_PRESET_MVC_STEREO_GUID
     354    GUID NV_ENC_PRESET_CLOUD_GAMING_720p60_GUID
     355    GUID NV_ENC_PRESET_CLOUD_GAMING_720p30_GUID
     356    GUID NV_ENC_PRESET_DESKTOP_CAPTURE_GUID
     357    GUID NV_ENC_PRESET_MVC_STEREO_GUID
    357358
    358359    ctypedef struct NV_ENC_CAPS_PARAM:
    359360        uint32_t    version
     
    467468                                        #The low latency application which wants to invalidate reference frame as an error resilience tool
    468469                                        #is recommended to use a large DPB size so that the encoder can keep old reference frames which can be used if recent
    469470                                        #frames are invalidated.
    470         uint32_t    sliceMode           #[in]: This parameter in conjunction with sliceModeData specifies the way in which the picture is divided into slices
     471        #uint32_t    sliceMode           #[in]: This parameter in conjunction with sliceModeData specifies the way in which the picture is divided into slices
    471472                                        #sliceMode = 0 MB based slices, sliceMode = 1 Byte based slices, sliceMode = 2 MB row based slices, sliceMode = 3, numSlices in Picture
    472473                                        #When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting
    473474                                        #When sliceMode == 0 and sliceModeData == 0 whole picture will be coded with one slice
    474         uint32_t    sliceModeData       #[in]: Specifies the parameter needed for sliceMode. For:
     475        #uint32_t    sliceModeData       #[in]: Specifies the parameter needed for sliceMode. For:
    475476                                        #sliceMode = 0, sliceModeData specifies # of MBs in each slice (except last slice)
    476477                                        #sliceMode = 1, sliceModeData specifies maximum # of bytes in each slice (except last slice)
    477478                                        #sliceMode = 2, sliceModeData specifies # of MB rows in each slice (except last slice)
     
    643644                                        #forceIntraRefreshWithFrameCnt cannot be used if B frames are used in the GOP structure specified
    644645        uint32_t    constrainedFrame    #[in]: Set to 1 if client wants to encode this frame with each slice completely independent of other slices in the frame.
    645646                                        #NV_ENC_INITIALIZE_PARAMS::enableConstrainedEncoding should be set to 1
    646         uint32_t    sliceModeDataUpdate #[in]: Set to 1 if client wants to change the sliceModeData field to speficy new sliceSize Parameter
     647        #uint32_t    sliceModeDataUpdate #[in]: Set to 1 if client wants to change the sliceModeData field to speficy new sliceSize Parameter
    647648                                        #When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting
    648649        uint32_t    ltrMarkFrame        #[in]: Set to 1 if client wants to mark this frame as LTR
    649650        uint32_t    ltrUseFrames        #[in]: Set to 1 if client allows encoding this frame using the LTR frames specified in ltrFrameBitmap
     
    655656        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
    656657        uint32_t    seiPayloadArrayCnt  #[in]: Specifies the number of elements allocated in  seiPayloadArray array.
    657658        NV_ENC_H264_SEI_PAYLOAD *seiPayloadArray    #[in]: Array of SEI payloads which will be inserted for this frame.
    658         uint32_t    sliceMode           #[in]: This parameter in conjunction with sliceModeData specifies the way in which the picture is divided into slices
     659        #uint32_t    sliceMode           #[in]: This parameter in conjunction with sliceModeData specifies the way in which the picture is divided into slices
    659660                                        #sliceMode = 0 MB based slices, sliceMode = 1 Byte based slices, sliceMode = 2 MB row based slices, sliceMode = 3, numSlices in Picture
    660661                                        #When forceIntraRefreshWithFrameCnt is set it will have priority over sliceMode setting
    661662                                        #When sliceMode == 0 and sliceModeData == 0 whole picture will be coded with one slice
    662         uint32_t    sliceModeData       #[in]: Specifies the parameter needed for sliceMode. For:
     663        #uint32_t    sliceModeData       #[in]: Specifies the parameter needed for sliceMode. For:
    663664                                        #sliceMode = 0, sliceModeData specifies # of MBs in each slice (except last slice)
    664665                                        #sliceMode = 1, sliceModeData specifies maximum # of bytes in each slice (except last slice)
    665666                                        #sliceMode = 2, sliceModeData specifies # of MB rows in each slice (except last slice)
     
    971972        guidstr(NV_ENC_H264_PROFILE_HIGH_GUID)              : "high",
    972973        guidstr(NV_ENC_H264_PROFILE_STEREO_GUID)            : "stereo",
    973974        guidstr(NV_ENC_H264_PROFILE_SVC_TEMPORAL_SCALABILTY): "temporal",
    974         guidstr(NV_ENC_H264_PROFILE_CONSTRAINED_HIGH_GUID)  : "constrained-high",
     975        #guidstr(NV_ENC_H264_PROFILE_CONSTRAINED_HIGH_GUID)  : "constrained-high",
    975976        },
    976977    guidstr(NV_ENC_CODEC_MPEG2_GUID) : {
    977978        guidstr(NV_ENC_CODEC_PROFILE_AUTOSELECT_GUID)       : "auto",
     
    10001001    guidstr(NV_ENC_PRESET_HQ_GUID)                          : "hq",
    10011002    guidstr(NV_ENC_PRESET_BD_GUID)                          : "bd",
    10021003    #V3 only:
    1003     guidstr(NV_ENC_PRESET_LOW_LATENCY_DEFAULT_GUID)         : "low-latency",
    1004     guidstr(NV_ENC_PRESET_LOW_LATENCY_HQ_GUID)              : "low-latency-hq",
    1005     guidstr(NV_ENC_PRESET_LOW_LATENCY_HP_GUID)              : "low-latency-hp",
     1004    #guidstr(NV_ENC_PRESET_LOW_LATENCY_DEFAULT_GUID)         : "low-latency",
     1005    #guidstr(NV_ENC_PRESET_LOW_LATENCY_HQ_GUID)              : "low-latency-hq",
     1006    #guidstr(NV_ENC_PRESET_LOW_LATENCY_HP_GUID)              : "low-latency-hp",
    10061007    #V2 only:
    1007     #guidstr(NV_ENC_PRESET_VC_GUID)                          : "vc",
    1008     #guidstr(NV_ENC_PRESET_WIDI_GUID)                        : "widi",
    1009     #guidstr(NV_ENC_PRESET_CAMERA_GUID)                      : "camera",
    1010     #guidstr(NV_ENC_PRESET_AVCHD_GUID)                       : "avchd",
    1011     #guidstr(NV_ENC_PRESET_IPOD_GUID)                        : "ipod",
    1012     #guidstr(NV_ENC_PRESET_PSP_GUID)                         : "psp",
    1013     #guidstr(NV_ENC_PRESET_GAME_CAPTURE_GUID)                : "game-capture",
    1014     #guidstr(NV_ENC_PRESET_CLOUD_GAMING_720p60_GUID)         : "gaming 720p60",
    1015     #guidstr(NV_ENC_PRESET_CLOUD_GAMING_720p30_GUID)         : "gaming 720p30",
    1016     #guidstr(NV_ENC_PRESET_DESKTOP_CAPTURE_GUID)             : "desktop-capture",
    1017     #guidstr(NV_ENC_PRESET_MVC_STEREO_GUID)                  : "mvc-stereo",
     1008    guidstr(NV_ENC_PRESET_VC_GUID)                          : "vc",
     1009    guidstr(NV_ENC_PRESET_WIDI_GUID)                        : "widi",
     1010    guidstr(NV_ENC_PRESET_CAMERA_GUID)                      : "camera",
     1011    guidstr(NV_ENC_PRESET_AVCHD_GUID)                       : "avchd",
     1012    guidstr(NV_ENC_PRESET_IPOD_GUID)                        : "ipod",
     1013    guidstr(NV_ENC_PRESET_PSP_GUID)                         : "psp",
     1014    guidstr(NV_ENC_PRESET_GAME_CAPTURE_GUID)                : "game-capture",
     1015    guidstr(NV_ENC_PRESET_CLOUD_GAMING_720p60_GUID)         : "gaming 720p60",
     1016    guidstr(NV_ENC_PRESET_CLOUD_GAMING_720p30_GUID)         : "gaming 720p30",
     1017    guidstr(NV_ENC_PRESET_DESKTOP_CAPTURE_GUID)             : "desktop-capture",
     1018    guidstr(NV_ENC_PRESET_MVC_STEREO_GUID)                  : "mvc-stereo",
    10181019    }
    10191020
    10201021BUFFER_FORMAT = {
     
    14961497                picParams.pictureType = NV_ENC_PIC_TYPE_P
    14971498            picParams.codecPicParams.h264PicParams.displayPOCSyntax = 2*self.frames
    14981499            picParams.codecPicParams.h264PicParams.refPicFlag = 1
    1499             picParams.codecPicParams.h264PicParams.sliceMode = 3            #sliceModeData specifies the number of slices
    1500             picParams.codecPicParams.h264PicParams.sliceModeData = 1        #1 slice!
     1500            #picParams.codecPicParams.h264PicParams.sliceMode = 3            #sliceModeData specifies the number of slices
     1501            #picParams.codecPicParams.h264PicParams.sliceModeData = 1        #1 slice!
    15011502            #picParams.encodePicFlags = NV_ENC_PIC_FLAG_FORCEINTRA
    15021503            #picParams.inputTimeStamp = int(1000.0 * time.time())
    15031504            #inputDuration = 0      #FIXME: use frame delay?