AJA NTV2 SDK  17.5.0.1242
NTV2 SDK 17.5.0.1242
ntv2encodehevc.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
9 #ifndef _NTV2ENCODEHEVC_H
10 #define _NTV2ENCODEHEVC_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 #define AUDIO_RING_SIZE (3*VIDEO_RING_SIZE)
30 
31 
38 {
39  // Public Instance Methods
40  public:
65  NTV2EncodeHEVC (const std::string inDeviceSpecifier = "0",
66  const NTV2Channel inChannel = NTV2_CHANNEL1,
69  const bool inQuadMode = false,
70  const uint32_t inAudioChannels = 0,
71  const bool inTimeCodeBurn = false,
72  const bool inInfoMode = false,
73  const bool inTsiMode = false,
74  const uint32_t inMaxFrames = 0xffffffff);
75 
76  virtual ~NTV2EncodeHEVC ();
77 
81  virtual AJAStatus Init (void);
82 
87  virtual AJAStatus Run (void);
88 
92  virtual void Quit (void);
93 
98  virtual void GetStatus (AVHevcStatus & outStatus);
99 
103  virtual M31VideoPreset GetCodecPreset (void);
104 
105  // Protected Instance Methods
106  protected:
110  virtual AJAStatus SetupVideo (void);
111 
115  virtual AJAStatus SetupAudio (void);
116 
120  virtual void RouteInputSignal (void);
121 
125  virtual void SetupHostBuffers (void);
126 
130  virtual void SetupAutoCirculate (void);
131 
135  virtual void StartVideoInputThread (void);
136 
140  virtual void StartVideoProcessThread (void);
141 
145  virtual void StartCodecRawThread (void);
146 
150  virtual void StartCodecHevcThread (void);
151 
155  virtual void StartVideoFileThread (void);
156 
160  virtual void StartAudioFileThread (void);
161 
166  virtual void VideoInputWorker (void);
167 
172  virtual void VideoProcessWorker (void);
173 
178  virtual void CodecRawWorker (void);
179 
184  virtual void CodecHevcWorker (void);
185 
190  virtual void VideoFileWorker (void);
191 
196  virtual void AudioFileWorker (void);
197 
201  virtual AJAStatus ProcessVideoFrame (AVHevcDataBuffer * pSrcFrame, AVHevcDataBuffer * pDstFrame, uint32_t frameNumber);
202 
203  // Protected Class Methods
204  protected:
211  static void VideoInputThreadStatic (AJAThread * pThread, void * pContext);
212 
219  static void VideoProcessThreadStatic (AJAThread * pThread, void * pContext);
220 
227  static void CodecRawThreadStatic (AJAThread * pThread, void * pContext);
228 
235  static void CodecHevcThreadStatic (AJAThread * pThread, void * pContext);
236 
243  static void VideoFileThreadStatic (AJAThread * pThread, void * pContext);
244 
251  static void AudioFileThreadStatic (AJAThread * pThread, void * pContext);
252 
253  // Private Member Data
254  private:
255  AJAThread mACInputThread;
256  AJAThread mVideoProcessThread;
257  AJAThread mCodecRawThread;
258  AJAThread mCodecHevcThread;
259  AJAThread mVideoFileThread;
260  AJAThread mAudioFileThread;
261  CNTV2m31 * mM31;
262  CNTV2DemoHevcCommon * mHevcCommon;
263 
264  CNTV2Card mDevice;
265  NTV2DeviceID mDeviceID;
266  const std::string mDeviceSpecifier;
267  bool mWithAudio;
268  NTV2Channel mInputChannel;
269  NTV2Channel mOutputChannel;
270  M31Channel mEncodeChannel;
271  M31VideoPreset mPreset;
272  NTV2InputSource mInputSource;
273  NTV2VideoFormat mVideoFormat;
274  NTV2FrameBufferFormat mPixelFormat;
275  bool mQuad;
276  bool mTsi;
277  bool m60p;
278  bool mVif;
279  bool mInterlaced;
280  bool mMultiStream;
281  bool mWithInfo;
282  bool mWithAnc;
283  NTV2AudioSystem mAudioSystem;
284  NTV2EveryFrameTaskMode mSavedTaskMode;
285  uint32_t mNumAudioChannels;
286  uint32_t mFileAudioChannels;
287  uint32_t mMaxFrames;
288 
289  bool mLastFrame;
290  bool mLastFrameInput;
291  bool mLastFrameRaw;
292  bool mLastFrameHevc;
293  bool mLastFrameVideo;
294  bool mLastFrameAudio;
295  bool mGlobalQuit;
296  uint32_t mQueueSize;
297  uint32_t mVideoBufferSize;
298  uint32_t mPicInfoBufferSize;
299  uint32_t mEncInfoBufferSize;
300  uint32_t mAudioBufferSize;
301 
302  AVHevcDataBuffer mACInputBuffer [VIDEO_RING_SIZE];
303  AJACircularBuffer <AVHevcDataBuffer *> mACInputCircularBuffer;
304 
305  AVHevcDataBuffer mVideoRawBuffer [VIDEO_RING_SIZE];
306  AJACircularBuffer <AVHevcDataBuffer *> mVideoRawCircularBuffer;
307 
308  AVHevcDataBuffer mVideoHevcBuffer [VIDEO_RING_SIZE];
309  AJACircularBuffer <AVHevcDataBuffer *> mVideoHevcCircularBuffer;
310 
311  AVHevcDataBuffer mAudioInputBuffer [AUDIO_RING_SIZE];
312  AJACircularBuffer <AVHevcDataBuffer *> mAudioInputCircularBuffer;
313 
314  uint32_t mVideoInputFrameCount;
315  uint32_t mVideoProcessFrameCount;
316  uint32_t mCodecRawFrameCount;
317  uint32_t mCodecHevcFrameCount;
318  uint32_t mVideoFileFrameCount;
319  uint32_t mAudioFileFrameCount;
320 
321  AJATimeBase mTimeBase;
322  AJATimeCode mTimeCode;
323  AJATimeCodeBurn mTimeCodeBurn;
324 
325 }; // NTV2EncodeHEVC
326 
327 #endif // _NTV2ENCODEHEVC_H
NTV2_FBF_10BIT_YCBCR_420PL2
@ NTV2_FBF_10BIT_YCBCR_420PL2
10-Bit 4:2:0 2-Plane YCbCr
Definition: ntv2enums.h:242
NTV2EncodeHEVC::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: ntv2encodehevc.cpp:1288
NTV2EncodeHEVC::VideoInputWorker
virtual void VideoInputWorker(void)
Repeatedly captures video frames using AutoCirculate and add them to the video input ring.
Definition: ntv2encodehevc.cpp:814
ntv2devicefeatures.h
Declares device capability functions.
NTV2EncodeHEVC::StartVideoFileThread
virtual void StartVideoFileThread(void)
Start the video file writer thread.
Definition: ntv2encodehevc.cpp:1278
NTV2EncodeHEVC::ProcessVideoFrame
virtual AJAStatus ProcessVideoFrame(AVHevcDataBuffer *pSrcFrame, AVHevcDataBuffer *pDstFrame, uint32_t frameNumber)
Default do-nothing function for processing the captured frames.
Definition: ntv2encodehevc.cpp:1401
NTV2Channel
NTV2Channel
These enum values are mostly used to identify a specific widget_framestore. They're also commonly use...
Definition: ntv2enums.h:1334
ntv2demohevccommon.h
This file contains some structures, constants, classes and functions that are used in some of the hev...
CNTV2DemoHevcCommon
Definition: ntv2demohevccommon.h:56
NTV2EncodeHEVC::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: ntv2encodehevc.cpp:1018
NTV2EncodeHEVC::StartAudioFileThread
virtual void StartAudioFileThread(void)
Start the audio file writer thread.
Definition: ntv2encodehevc.cpp:1337
NTV2EncodeHEVC::CodecHevcWorker
virtual void CodecHevcWorker(void)
Repeatedly transfers hevc frames from the codec and adds them to the hevc ring.
Definition: ntv2encodehevc.cpp:1160
NTV2DeviceID
NTV2DeviceID
Identifies a specific AJA NTV2 device model number. The NTV2DeviceID is actually the PROM part number...
Definition: ntv2enums.h:20
NTV2EncodeHEVC::SetupAudio
virtual AJAStatus SetupAudio(void)
Sets up everything I need for capturing audio.
Definition: ntv2encodehevc.cpp:559
NTV2EncodeHEVC::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: ntv2encodehevc.cpp:804
NTV2FrameBufferFormat
NTV2FrameBufferFormat
Identifies a particular video frame buffer format. See Device Frame Buffer Formats for details.
Definition: ntv2enums.h:210
timecode.h
Declares the AJATimeCode class.
VIDEO_RING_SIZE
#define VIDEO_RING_SIZE
Definition: ntv2encodehevc.h:28
NTV2EncodeHEVC::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: ntv2encodehevc.cpp:967
NTV2_CHANNEL1
@ NTV2_CHANNEL1
Specifies channel or Frame Store 1 (or the first item).
Definition: ntv2enums.h:1336
NTV2EncodeHEVC
Instances of me capture frames in real time from a video signal provided to an input of an AJA device...
Definition: ntv2encodehevc.h:37
NTV2EncodeHEVC::SetupHostBuffers
virtual void SetupHostBuffers(void)
Sets up my circular buffers.
Definition: ntv2encodehevc.cpp:581
AJAThread
Definition: thread.h:69
timecodeburn.h
Declares the AJATimeCodeBurn class.
NTV2EncodeHEVC::VideoProcessWorker
virtual void VideoProcessWorker(void)
Repeatedly removes video frames from the video input ring, calls a custom video process method and ad...
Definition: ntv2encodehevc.cpp:977
AJAStatus
AJAStatus
Definition: types.h:378
NTV2EncodeHEVC::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: ntv2encodehevc.cpp:1150
AJATimeBase
Definition: timebase.h:18
NTV2EncodeHEVC::StartCodecRawThread
virtual void StartCodecRawThread(void)
Start the codec raw thread.
Definition: ntv2encodehevc.cpp:1008
NTV2EncodeHEVC::AudioFileThreadStatic
static void AudioFileThreadStatic(AJAThread *pThread, void *pContext)
This is the audio file writer thread's static callback function that gets called when the thread star...
Definition: ntv2encodehevc.cpp:1347
ntv2devicescanner.h
Declares the CNTV2DeviceScanner class.
NTV2EncodeHEVC::StartVideoInputThread
virtual void StartVideoInputThread(void)
Start the video input thread.
Definition: ntv2encodehevc.cpp:794
NTV2EncodeHEVC::AudioFileWorker
virtual void AudioFileWorker(void)
Repeatedly removes audio samples from the audio input ring and writes them to the audio output file.
Definition: ntv2encodehevc.cpp:1357
NTV2EncodeHEVC::NTV2EncodeHEVC
NTV2EncodeHEVC(const std::string inDeviceSpecifier="0", const NTV2Channel inChannel=NTV2_CHANNEL1, const M31VideoPreset inM31Preset=M31_FILE_1280X720_420_8_5994p, const NTV2FrameBufferFormat inPixelFormat=NTV2_FBF_10BIT_YCBCR_420PL2, const bool inQuadMode=(0), const uint32_t inAudioChannels=0, const bool inTimeCodeBurn=(0), const bool inInfoMode=(0), const bool inTsiMode=(0), const uint32_t inMaxFrames=0xffffffff)
Constructs me using the given settings.
Definition: ntv2encodehevc.cpp:21
ntv2enums.h
Enumerations for controlling NTV2 devices.
NTV2EncodeHEVC::Run
virtual AJAStatus Run(void)
Runs me.
Definition: ntv2encodehevc.cpp:772
CNTV2Card
I interrogate and control an AJA video/audio capture/playout device.
Definition: ntv2card.h:28
M31_FILE_1280X720_420_8_5994p
@ M31_FILE_1280X720_420_8_5994p
Definition: ntv2m31enums.h:35
M31VideoPreset
M31VideoPreset
Definition: ntv2m31enums.h:12
NTV2EncodeHEVC::~NTV2EncodeHEVC
virtual ~NTV2EncodeHEVC()
Definition: ntv2encodehevc.cpp:84
NTV2EncodeHEVC::RouteInputSignal
virtual void RouteInputSignal(void)
Sets up device routing for capture.
Definition: ntv2encodehevc.cpp:653
AUDIO_RING_SIZE
#define AUDIO_RING_SIZE
Definition: ntv2encodehevc.h:29
NTV2InputSource
NTV2InputSource
Identifies a specific video input source.
Definition: ntv2enums.h:1244
videotypes.h
Declares the enumeration constants used in the ajabase library.
ntv2m31enums.h
Enumerations for controlling NTV2 devices with m31 HEVC encoders.
NTV2VideoFormat
enum _NTV2VideoFormat NTV2VideoFormat
Identifies a particular video format.
NTV2EncodeHEVC::Init
virtual AJAStatus Init(void)
Initializes me and prepares me to Run.
Definition: ntv2encodehevc.cpp:259
AVHevcStatus
Definition: ntv2demohevccommon.h:48
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
NTV2EncodeHEVC::Quit
virtual void Quit(void)
Gracefully stops me from running.
Definition: ntv2encodehevc.cpp:181
NTV2EncodeHEVC::GetStatus
virtual void GetStatus(AVHevcStatus &outStatus)
Provides status information about my input (capture) process.
Definition: ntv2encodehevc.cpp:1390
NTV2EncodeHEVC::GetCodecPreset
virtual M31VideoPreset GetCodecPreset(void)
Get the codec preset.
Definition: ntv2encodehevc.cpp:408
NTV2EncodeHEVC::StartCodecHevcThread
virtual void StartCodecHevcThread(void)
Start the codec hevc thread.
Definition: ntv2encodehevc.cpp:1140
circularbuffer.h
Declaration of AJACircularBuffer template class.
AJATimeCodeBurn
Definition: timecodeburn.h:19
NTV2AudioSystem
NTV2AudioSystem
Used to identify an Audio System on an NTV2 device. See Audio System Operation for more information.
Definition: ntv2enums.h:3848
AVHevcDataBuffer
This structure encapsulates the video and audio buffers used by the HEVC demo applications....
Definition: ntv2demohevccommon.h:27
NTV2EncodeHEVC::SetupAutoCirculate
virtual void SetupAutoCirculate(void)
Initializes AutoCirculate.
Definition: ntv2encodehevc.cpp:756
thread.h
Declares the AJAThread class.
NTV2EncodeHEVC::SetupVideo
virtual AJAStatus SetupVideo(void)
Sets up everything I need for capturing video.
Definition: ntv2encodehevc.cpp:414
NTV2EncodeHEVC::StartVideoProcessThread
virtual void StartVideoProcessThread(void)
Start the video process thread.
Definition: ntv2encodehevc.cpp:957
NTV2EncodeHEVC::VideoFileWorker
virtual void VideoFileWorker(void)
Repeatedly removes hevc frame from the hevc ring and writes them to the hevc output file.
Definition: ntv2encodehevc.cpp:1298
AJACircularBuffer< AVHevcDataBuffer * >
NTV2EncodeHEVC::CodecRawWorker
virtual void CodecRawWorker(void)
Repeatedly removes video frames from the raw video ring and transfers them to the codec.
Definition: ntv2encodehevc.cpp:1028
AJATimeCode
Utility class for timecodes.
Definition: timecode.h:17
timebase.h
Declares the AJATimeBase class.