AJA NTV2 SDK  18.0.0.2122
NTV2 SDK 18.0.0.2122
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
virtual void CodecHevcWorker(void)
Repeatedly transfers hevc frames from the codec and adds them to the hevc ring.
virtual void StartCodecHevcThread(void)
Start the codec hevc thread.
I interrogate and control an AJA video/audio capture/playout device.
Definition: ntv2card.h:28
NTV2FrameBufferFormat
Identifies a particular video frame buffer pixel format. See Device Frame Buffer Formats for details...
Definition: ntv2enums.h:219
NTV2TaskMode
Describes the task mode state. See also: Sharing AJA Devices With Other Applications.
static void CodecHevcThreadStatic(AJAThread *pThread, void *pContext)
This is the codec hevc thread&#39;s static callback function that gets called when the thread starts...
AJAStatus
Definition: types.h:380
enum _NTV2VideoFormat NTV2VideoFormat
Identifies a particular video format.
static void VideoFileThreadStatic(AJAThread *pThread, void *pContext)
This is the video file writer thread&#39;s static callback function that gets called when the thread star...
Instances of me capture frames in real time from a video signal provided to an input of an AJA device...
static void CodecRawThreadStatic(AJAThread *pThread, void *pContext)
This is the codec raw thread&#39;s static callback function that gets called when the thread starts...
virtual void VideoFileWorker(void)
Repeatedly removes hevc frame from the hevc ring and writes them to the hevc output file...
virtual void Quit(void)
Gracefully stops me from running.
virtual AJAStatus Run(void)
Runs me.
Declares the AJATimeCodeBurn class.
NTV2Channel
These enum values are mostly used to identify a specific widget_framestore. They&#39;re also commonly use...
Definition: ntv2enums.h:1357
virtual M31VideoPreset GetCodecPreset(void)
Get the codec preset.
static void VideoInputThreadStatic(AJAThread *pThread, void *pContext)
This is the video input thread&#39;s static callback function that gets called when the thread starts...
Declares the AJATimeBase class.
M31VideoPreset
Definition: ntv2m31enums.h:13
virtual void StartVideoProcessThread(void)
Start the video process thread.
NTV2DeviceID
Identifies a specific AJA NTV2 device model number. The NTV2DeviceID is actually the PROM part number...
Definition: ntv2enums.h:20
Enumerations for controlling NTV2 devices.
Declares the AJAThread class.
Utility class for timecodes.
Definition: timecode.h:28
#define VIDEO_RING_SIZE
virtual void VideoProcessWorker(void)
Repeatedly removes video frames from the video input ring, calls a custom video process method and ad...
static void VideoProcessThreadStatic(AJAThread *pThread, void *pContext)
This is the video process thread&#39;s static callback function that gets called when the thread starts...
virtual void SetupHostBuffers(void)
Sets up my circular buffers.
Declares the CNTV2DeviceScanner class.
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.
Declaration of AJACircularBuffer template class.
Declares the AJATimeCode class.
virtual void GetStatus(AVHevcStatus &outStatus)
Provides status information about my input (capture) process.
virtual void CodecRawWorker(void)
Repeatedly removes video frames from the raw video ring and transfers them to the codec...
M31Channel
Definition: ntv2m31enums.h:226
Specifies channel or FrameStore 1 (or the first item).
Definition: ntv2enums.h:1359
This structure encapsulates the video and audio buffers used by the HEVC demo applications. The demo programs that employ producer/consumer threads use a fixed number of these buffers.
virtual AJAStatus Init(void)
Initializes me and prepares me to Run.
virtual AJAStatus ProcessVideoFrame(AVHevcDataBuffer *pSrcFrame, AVHevcDataBuffer *pDstFrame)
Default do-nothing function for processing the captured frames.
virtual void VideoInputWorker(void)
Repeatedly captures video frames using AutoCirculate and add them to the video input ring...
#define M31PRESET
virtual void StartCodecRawThread(void)
Start the codec raw thread.
This file contains some structures, constants, classes and functions that are used in some of the hev...
Declares the enumeration constants used in the ajabase library.
virtual void StartVideoInputThread(void)
Start the video input thread.
I am a circular frame buffer that simplifies implementing a type-safe producer/consumer model for pro...
virtual void StartVideoFileThread(void)
Start the video file writer thread.
Declares device capability functions.