AJA NTV2 SDK  17.1.1.1245
NTV2 SDK 17.1.1.1245
ntv2encodehevcfile.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
9 #ifndef _NTV2ENCODEHEVCFILE_H
10 #define _NTV2ENCODEHEVCFILE_H
11 
12 #include "ntv2enums.h"
13 #include "ntv2devicefeatures.h"
14 #include "ntv2devicescanner.h"
15 #include "ntv2demohevccommon.h"
16 
17 #include "ntv2m31enums.h"
18 
24 #include "ajabase/system/thread.h"
25 
26 #include "ntv2m31.h"
27 
28 #define VIDEO_RING_SIZE 60
29 
30 #define RAWFILEPATH "ElephantsDream.yuv"
31 #define RAWFILEWIDTH 1920
32 #define RAWFILEHEIGHT 1080
33 #define M31PRESET M31_FILE_1920X1080_420_8_24p
34 
41 {
42  // Public Instance Methods
43  public:
57  NTV2EncodeHEVCFile (const std::string inDeviceSpecifier = "0",
58  const NTV2Channel inChannel = NTV2_CHANNEL1,
59  const std::string inFilePath = "",
60  const uint32_t inFrameWidth = 0,
61  const uint32_t inFrameHeight = 0,
62  const M31VideoPreset inM31Preset = M31PRESET);
63 
64  virtual ~NTV2EncodeHEVCFile ();
65 
69  virtual AJAStatus Init (void);
70 
75  virtual AJAStatus Run (void);
76 
80  virtual void Quit (void);
81 
86  virtual void GetStatus (AVHevcStatus & outStatus);
87 
91  virtual M31VideoPreset GetCodecPreset (void);
92 
93  // Protected Instance Methods
94  protected:
98  virtual void SetupHostBuffers (void);
99 
103  virtual void StartVideoInputThread (void);
104 
108  virtual void StartVideoProcessThread (void);
109 
113  virtual void StartCodecRawThread (void);
114 
118  virtual void StartCodecHevcThread (void);
119 
123  virtual void StartVideoFileThread (void);
124 
129  virtual void VideoInputWorker (void);
130 
135  virtual void VideoProcessWorker (void);
136 
141  virtual void CodecRawWorker (void);
142 
147  virtual void CodecHevcWorker (void);
148 
153  virtual void VideoFileWorker (void);
154 
158  virtual AJAStatus ProcessVideoFrame (AVHevcDataBuffer * pSrcFrame, AVHevcDataBuffer * pDstFrame);
159 
160  // Protected Class Methods
161  protected:
168  static void VideoInputThreadStatic (AJAThread * pThread, void * pContext);
169 
176  static void VideoProcessThreadStatic (AJAThread * pThread, void * pContext);
177 
184  static void CodecRawThreadStatic (AJAThread * pThread, void * pContext);
185 
192  static void CodecHevcThreadStatic (AJAThread * pThread, void * pContext);
193 
200  static void VideoFileThreadStatic (AJAThread * pThread, void * pContext);
201 
202 
203  // Private Member Data
204  private:
205  AJAThread mFileInputThread;
206  AJAThread mVideoProcessThread;
207  AJAThread mCodecRawThread;
208  AJAThread mCodecHevcThread;
209  AJAThread mVideoFileThread;
210  CNTV2m31 * mM31;
211  CNTV2DemoHevcCommon * mHevcCommon;
212 
213  CNTV2Card mDevice;
214  NTV2DeviceID mDeviceID;
215  const std::string mDeviceSpecifier;
216  const std::string mFileName;
217  uint32_t mFrameWidth;
218  uint32_t mFrameHeight;
219 
220  NTV2Channel mInputChannel;
221  M31Channel mEncodeChannel;
222  M31VideoPreset mPreset;
223  NTV2VideoFormat mVideoFormat;
224  NTV2FrameBufferFormat mPixelFormat;
225  bool mQuad;
226  bool mInterlaced;
227  bool mMultiStream;
228  NTV2EveryFrameTaskMode mSavedTaskMode;
229 
230  bool mLastFrame;
231  bool mLastFrameInput;
232  bool mLastFrameRaw;
233  bool mLastFrameHevc;
234  bool mLastFrameVideo;
235  bool mGlobalQuit;
236  uint32_t mQueueSize;
237  uint32_t mVideoBufferSize;
238  uint32_t mPicInfoBufferSize;
239  uint32_t mEncInfoBufferSize;
240 
241  AVHevcDataBuffer mFileInputBuffer [VIDEO_RING_SIZE];
242  AJACircularBuffer <AVHevcDataBuffer *> mFileInputCircularBuffer;
243 
244  AVHevcDataBuffer mVideoRawBuffer [VIDEO_RING_SIZE];
245  AJACircularBuffer <AVHevcDataBuffer *> mVideoRawCircularBuffer;
246 
247  AVHevcDataBuffer mVideoHevcBuffer [VIDEO_RING_SIZE];
248  AJACircularBuffer <AVHevcDataBuffer *> mVideoHevcCircularBuffer;
249 
250  uint32_t mVideoInputFrameCount;
251  uint32_t mVideoProcessFrameCount;
252  uint32_t mCodecRawFrameCount;
253  uint32_t mCodecHevcFrameCount;
254  uint32_t mVideoFileFrameCount;
255 
256  AJATimeBase mTimeBase;
257  AJATimeCode mTimeCode;
258  AJATimeCodeBurn mTimeCodeBurn;
259 
260 }; // NTV2EncodeHEVCFile
261 
262 #endif // _NTV2ENCODEHEVCFILE_H
NTV2EncodeHEVCFile::StartVideoFileThread
virtual void StartVideoFileThread(void)
Start the video file writer thread.
Definition: ntv2encodehevcfile.cpp:708
NTV2EncodeHEVCFile::VideoFileThreadStatic
static void VideoFileThreadStatic(AJAThread *pThread, void *pContext)
This is the video file writer thread's static callback function that gets called when the thread star...
Definition: ntv2encodehevcfile.cpp:718
ntv2devicefeatures.h
Declares device capability functions.
NTV2Channel
NTV2Channel
These enum values are mostly used to identify a specific widget_framestore. They're also commonly use...
Definition: ntv2enums.h:1305
NTV2EncodeHEVCFile::VideoInputThreadStatic
static void VideoInputThreadStatic(AJAThread *pThread, void *pContext)
This is the video input thread's static callback function that gets called when the thread starts....
Definition: ntv2encodehevcfile.cpp:380
ntv2demohevccommon.h
This file contains some structures, constants, classes and functions that are used in some of the hev...
NTV2EncodeHEVCFile::ProcessVideoFrame
virtual AJAStatus ProcessVideoFrame(AVHevcDataBuffer *pSrcFrame, AVHevcDataBuffer *pDstFrame)
Default do-nothing function for processing the captured frames.
Definition: ntv2encodehevcfile.cpp:771
NTV2EncodeHEVCFile::CodecRawWorker
virtual void CodecRawWorker(void)
Repeatedly removes video frames from the raw video ring and transfers them to the codec.
Definition: ntv2encodehevcfile.cpp:511
NTV2EncodeHEVCFile::~NTV2EncodeHEVCFile
virtual ~NTV2EncodeHEVCFile()
Definition: ntv2encodehevcfile.cpp:66
NTV2EncodeHEVCFile::GetStatus
virtual void GetStatus(AVHevcStatus &outStatus)
Provides status information about my input (capture) process.
Definition: ntv2encodehevcfile.cpp:761
NTV2EncodeHEVCFile::Run
virtual AJAStatus Run(void)
Runs me.
Definition: ntv2encodehevcfile.cpp:355
CNTV2DemoHevcCommon
Definition: ntv2demohevccommon.h:56
NTV2EncodeHEVCFile::StartCodecRawThread
virtual void StartCodecRawThread(void)
Start the codec raw thread.
Definition: ntv2encodehevcfile.cpp:491
NTV2EncodeHEVCFile::VideoProcessThreadStatic
static void VideoProcessThreadStatic(AJAThread *pThread, void *pContext)
This is the video process thread's static callback function that gets called when the thread starts....
Definition: ntv2encodehevcfile.cpp:450
NTV2DeviceID
NTV2DeviceID
Identifies a specific AJA NTV2 device model number. The NTV2DeviceID is actually the PROM part number...
Definition: ntv2enums.h:20
NTV2FrameBufferFormat
NTV2FrameBufferFormat
Identifies a particular video frame buffer format. See Device Frame Buffer Formats for details.
Definition: ntv2enums.h:207
timecode.h
Declares the AJATimeCode class.
NTV2EncodeHEVCFile::VideoFileWorker
virtual void VideoFileWorker(void)
Repeatedly removes hevc frame from the hevc ring and writes them to the hevc output file.
Definition: ntv2encodehevcfile.cpp:728
NTV2EncodeHEVCFile::CodecHevcWorker
virtual void CodecHevcWorker(void)
Repeatedly transfers hevc frames from the codec and adds them to the hevc ring.
Definition: ntv2encodehevcfile.cpp:590
NTV2_CHANNEL1
@ NTV2_CHANNEL1
Specifies channel or Frame Store 1 (or the first item).
Definition: ntv2enums.h:1307
NTV2EncodeHEVCFile
Instances of me capture frames in real time from a video signal provided to an input of an AJA device...
Definition: ntv2encodehevcfile.h:40
AJAThread
Definition: thread.h:69
timecodeburn.h
Declares the AJATimeCodeBurn class.
AJAStatus
AJAStatus
Definition: types.h:378
AJATimeBase
Definition: timebase.h:18
ntv2devicescanner.h
Declares the CNTV2DeviceScanner class.
ntv2enums.h
Enumerations for controlling NTV2 devices.
CNTV2Card
I interrogate and control an AJA video/audio capture/playout device.
Definition: ntv2card.h:28
NTV2EncodeHEVCFile::CodecRawThreadStatic
static void CodecRawThreadStatic(AJAThread *pThread, void *pContext)
This is the codec raw thread's static callback function that gets called when the thread starts....
Definition: ntv2encodehevcfile.cpp:501
VIDEO_RING_SIZE
#define VIDEO_RING_SIZE
Definition: ntv2encodehevcfile.h:28
M31PRESET
#define M31PRESET
Definition: ntv2encodehevcfile.h:33
M31VideoPreset
M31VideoPreset
Definition: ntv2m31enums.h:12
NTV2EncodeHEVCFile::GetCodecPreset
virtual M31VideoPreset GetCodecPreset(void)
Get the codec preset.
Definition: ntv2encodehevcfile.cpp:292
NTV2EncodeHEVCFile::StartVideoProcessThread
virtual void StartVideoProcessThread(void)
Start the video process thread.
Definition: ntv2encodehevcfile.cpp:440
NTV2EncodeHEVCFile::VideoProcessWorker
virtual void VideoProcessWorker(void)
Repeatedly removes video frames from the video input ring, calls a custom video process method and ad...
Definition: ntv2encodehevcfile.cpp:460
videotypes.h
Declares the enumeration constants used in the ajabase library.
NTV2EncodeHEVCFile::Init
virtual AJAStatus Init(void)
Initializes me and prepares me to Run.
Definition: ntv2encodehevcfile.cpp:194
ntv2m31enums.h
Enumerations for controlling NTV2 devices with m31 HEVC encoders.
NTV2VideoFormat
enum _NTV2VideoFormat NTV2VideoFormat
Identifies a particular video format.
AVHevcStatus
Definition: ntv2demohevccommon.h:48
NTV2EncodeHEVCFile::NTV2EncodeHEVCFile
NTV2EncodeHEVCFile(const std::string inDeviceSpecifier="0", const NTV2Channel inChannel=NTV2_CHANNEL1, const std::string inFilePath="", const uint32_t inFrameWidth=0, const uint32_t inFrameHeight=0, const M31VideoPreset inM31Preset=M31_FILE_1920X1080_420_8_24p)
Constructs me using the given settings.
Definition: ntv2encodehevcfile.cpp:19
M31Channel
M31Channel
Definition: ntv2m31enums.h:225
NTV2EveryFrameTaskMode
NTV2EveryFrameTaskMode
Describes the task mode state. See also: Sharing AJA Devices With Other Applications.
Definition: ntv2publicinterface.h:4288
NTV2EncodeHEVCFile::SetupHostBuffers
virtual void SetupHostBuffers(void)
Sets up my circular buffers.
Definition: ntv2encodehevcfile.cpp:298
NTV2EncodeHEVCFile::StartVideoInputThread
virtual void StartVideoInputThread(void)
Start the video input thread.
Definition: ntv2encodehevcfile.cpp:370
NTV2EncodeHEVCFile::CodecHevcThreadStatic
static void CodecHevcThreadStatic(AJAThread *pThread, void *pContext)
This is the codec hevc thread's static callback function that gets called when the thread starts....
Definition: ntv2encodehevcfile.cpp:580
NTV2EncodeHEVCFile::Quit
virtual void Quit(void)
Gracefully stops me from running.
Definition: ntv2encodehevcfile.cpp:123
circularbuffer.h
Declaration of AJACircularBuffer template class.
NTV2EncodeHEVCFile::VideoInputWorker
virtual void VideoInputWorker(void)
Repeatedly captures video frames using AutoCirculate and add them to the video input ring.
Definition: ntv2encodehevcfile.cpp:390
AJATimeCodeBurn
Definition: timecodeburn.h:19
AVHevcDataBuffer
This structure encapsulates the video and audio buffers used by the HEVC demo applications....
Definition: ntv2demohevccommon.h:27
thread.h
Declares the AJAThread class.
NTV2EncodeHEVCFile::StartCodecHevcThread
virtual void StartCodecHevcThread(void)
Start the codec hevc thread.
Definition: ntv2encodehevcfile.cpp:570
AJACircularBuffer< AVHevcDataBuffer * >
AJATimeCode
Utility class for timecodes.
Definition: timecode.h:17
timebase.h
Declares the AJATimeBase class.