VR-Forces 4.7 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtEncoderIO.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2018 VT-MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 #pragma once
10 #include <vrvCore/DtDe.h>
14 #include <osg/Image>
15 // CUDA includes
16 #include "cuda_runtime.h"
17 #include <cuda_gl_interop.h>
18 
19 // CUDA utilities and system includes
21 #include <cuda.h>
22 #include <cuda_runtime_api.h>
23 
24 #include <NvCodec/NvEncoder/nvEncodeAPI.h>
25 
26 namespace makVrv
27 {
28 #define MAX_ENCODE_QUEUE 32
29 
32  {
34  : dwWidth(0)
35  , dwHeight(0)
36  , pNV12devPtr(0)
37  , uNV12Stride(0)
38  , nvRegisteredResource(0)
39  , hInputSurface(0)
40  , bufferFmt(NV_ENC_BUFFER_FORMAT_ARGB)
41  {
42 
43  }
44  unsigned int dwWidth;
45  unsigned int dwHeight;
46  CUdeviceptr pNV12devPtr;
47  uint32_t uNV12Stride;
49  NV_ENC_INPUT_PTR hInputSurface;
50  NV_ENC_BUFFER_FORMAT bufferFmt;
52 
55  {
57  : hBitstreamBuffer(0)
58  {
59 
60  }
61  NV_ENC_OUTPUT_PTR hBitstreamBuffer;
63 
66  {
69  } EncodeBuffer;
70 
75  {
76  public:
78  DtEncoderIO();
79 
81  virtual ~DtEncoderIO();
82 
84  void deinitialize();
85 
87  bool initialize(DtDe* theDe, const osg::ref_ptr<osg::Image>& image, unsigned int frameRate);
88 
90  void flipVertically(CUdeviceptr dev, uint32_t stride, int height);
91 
93  void submitPBO(unsigned int pboId, osg::ref_ptr<osg::Image>& image, DtReadFramebufferProcessData& fbData, unsigned int frameRate);
94 
95  protected:
96 
98  void deinitCUDA();
99 
101  bool initCUDA(const osg::ref_ptr<osg::Image>& image, unsigned int frameRate);
102 
104  void deinitNVidiaEncoder();
105 
107  bool initNVidiaEncoder(const osg::ref_ptr<osg::Image>& image, unsigned int frameRate);
108 
111 
114 
116  CUcontext myHcuContext;
117 
120 
123 
125  void * myNVEncoder;
126 
128  uint64_t myEncodeIdx;
129 
131  CUdeviceptr myCUDATempDevicePtr;
132 
134  uint32_t myTempStride;
135 
137  unsigned int myFrameRate;
138 
141  };
142 }

Document ID: Generated on Fri Apr 26 21:53:14 EDT 2019 from SVN revision 197883
Copyright © 2005-2019 VT MAK. All Rights Reserved (www.mak.com)