CVB++ 15.0
codec_bridge.hpp
1#pragma once
2
3#include <memory>
4
5#include "../_cexports/c_codec_bridge.h"
6
7#include "../utilities/system_info.hpp"
8#include "../global.hpp"
9
10namespace Cvb
11{
12
13CVB_BEGIN_INLINE_NS
14
16
23 namespace CodecBridge
24{
25
26 class Decoder;
29
30 class Encoder;
33
34 class CodecConfig;
37
38 class FormatConverter;
41
42 class Frame;
45
46 class InputContainer;
49
50 class OutputContainer;
53
54 class Packet;
57
59
64 enum class LogLevel
65 {
67 Quiet = CExports::CVCBLL_Quiet,
69 Panic = CExports::CVCBLL_Panic,
71 Fatal = CExports::CVCBLL_Fatal,
73 Error = CExports::CVCBLL_Error,
75 Warning = CExports::CVCBLL_Warning,
77 Info = CExports::CVCBLL_Info,
79 Verbose = CExports::CVCBLL_Verbose,
81 Debug = CExports::CVCBLL_Debug,
83 Trace = CExports::CVCBLL_Trace,
84 };
85
86
88
91 enum class PixelFormat
92 {
94 None = CExports::CVCBPF_None,
96 YUV420P = CExports::CVCBPF_YUV420P,
98 YUYV422 = CExports::CVCBPF_YUYV422,
100 RGB24 = CExports::CVCBPF_RGB24,
102 BGR24 = CExports::CVCBPF_BGR24,
104 YUV422P = CExports::CVCBPF_YUV422P,
106 YUV444P = CExports::CVCBPF_YUV444P,
108 GRAY8 = CExports::CVCBPF_GRAY8,
110 NV12 = CExports::CVCBPF_NV12,
112 NV21 = CExports::CVCBPF_NV21,
114 RGBA = CExports::CVCBPF_RGBA,
116 BGRA = CExports::CVCBPF_BGRA,
118 YUV444P16LE = CExports::CVCBPF_YUV444P16LE,
120 DXVA2_VLD = CExports::CVCBPF_DXVA2_VLD,
122 YUV420P10LE = CExports::CVCBPF_YUV420P10LE,
124 YUV422P10LE = CExports::CVCBPF_YUV422P10LE,
126 YUV444P10LE = CExports::CVCBPF_YUV444P10LE,
128 GBRP = CExports::CVCBPF_GBRP,
130 GBRP10LE = CExports::CVCBPF_GBRP10LE,
132 GBRP16LE = CExports::CVCBPF_GBRP16LE,
134 NV16 = CExports::CVCBPF_NV16,
136 NV20LE = CExports::CVCBPF_NV20LE,
138 QSV = CExports::CVCBPF_QSV,
140 CUDA = CExports::CVCBPF_CUDA,
142 RGB0 = CExports::CVCBPF_RGB0,
144 BGR0 = CExports::CVCBPF_BGR0,
146 YUV420P12LE = CExports::CVCBPF_YUV420P12LE,
148 YUV422P12LE = CExports::CVCBPF_YUV422P12LE,
150 YUV444P12LE = CExports::CVCBPF_YUV444P12LE,
152 GBRP12LE = CExports::CVCBPF_GBRP12LE,
154 P010LE = CExports::CVCBPF_P010LE,
156 GRAY12LE = CExports::CVCBPF_GRAY12LE,
158 GRAY10LE = CExports::CVCBPF_GRAY10LE,
160 P016LE = CExports::CVCBPF_P016LE,
162 D3D11 = CExports::CVCBPF_D3D11,
164 Y210LE = CExports::CVCBPF_Y210LE,
166 X2RGB10LE = CExports::CVCBPF_X2RGB10LE,
168 X2BGR10LE = CExports::CVCBPF_X2BGR10LE,
169 };
170
172
175 enum class Interpolation
176 {
178 BilinearFast = CExports::CVCBI_BilinearFast,
180 Bilinear = CExports::CVCBI_Bilinear,
182 Bicubic = CExports::CVCBI_Bicubic,
183 };
184
186 enum class CodecStatus
187 {
189 Ok = CExports::CVCBCS_Ok,
191 ReadoutRequired = CExports::CVCBCS_ReadoutRequired
192 };
193
195
199 class Rational final
200 {
201
202 public:
203
204 Rational(int numerator, int denominator) noexcept
205 : numerator_(numerator)
206 , denominator_(denominator)
207 {
208 }
209
210 Rational() noexcept = default;
211 Rational(const Rational& other) noexcept = default;
212 Rational& operator=(const Rational& other) noexcept = default;
213 Rational(Rational&& other) noexcept = default;
214 Rational& operator=(Rational&& other) noexcept = default;
215 ~Rational() = default;
216
217 int Numerator() const noexcept
218 {
219 return numerator_;
220 }
221
222 void SetNumerator(int numerator) noexcept
223 {
224 numerator_ = numerator;
225 }
226
227 int Denominator() const noexcept
228 {
229 return denominator_;
230 }
231
232 void SetDenominator(int denominator) noexcept
233 {
234 denominator_ = denominator;
235 }
236
238
243 bool operator==(const Rational& other) const noexcept
244 {
245 return numerator_ == other.numerator_ && denominator_ == other.denominator_;
246 }
247
249
254 bool operator!=(const Rational& other) const noexcept
255 {
256 return !(*this == other);
257 }
258
259 private:
261 int32_t numerator_ = 0;
263 int32_t denominator_ = 1;
264 };
265
266 inline void SetBackendLogLevel(LogLevel logLevel)
267 {
268 CVB_CALL_CAPI_CHECKED(CVCBSetBackendLogLevel(static_cast<CExports::CVCBLogLevel>(logLevel)));
269 }
270}
271
272CVB_END_INLINE_NS
273
274}
A configuration defining a codec.
Definition: codec_config.hpp:33
A decoder for video frames.
Definition: decoder.hpp:33
An encoder for video frames.
Definition: encoder.hpp:33
A format converter for video frames.
Definition: format_converter.hpp:31
A video frame for encoding and decoding.
Definition: frame.hpp:30
A container file for reading encoded videos from disk.
Definition: input_container.hpp:32
A container file for writing encoded videos to disk.
Definition: output_container.hpp:32
A packet that holds encoded data frame data.
Definition: packet.hpp:28
A pair of rational numbers.
Definition: codec_bridge.hpp:200
bool operator!=(const Rational &other) const noexcept
Compares to an other rational.
Definition: codec_bridge.hpp:254
bool operator==(const Rational &other) const noexcept
Compares to an other rational.
Definition: codec_bridge.hpp:243
CodecStatus
Status of the encoder/decoder after sending data.
Definition: codec_bridge.hpp:187
@ ReadoutRequired
The data was not accepted. Receive the processed data fist.
@ Ok
The data was accepted.
PixelFormat
Subset of FFmpeg pixel formats.
Definition: codec_bridge.hpp:92
@ BGR0
Equal to PIX_FMT_BGR0. Corresponds to PfncFormat::BGRa8, but the alpah channel is ignored.
@ RGB24
Equal to PIX_FMT_RGB24. Corresponds to PfncFormat::RGB8.
@ YUV444P
Equal to PIX_FMT_YUV444P.
@ NV12
Equal to PIX_FMT_NV12.
@ GBRP10LE
Equal to PIX_FMT_GBRP10LE. Corresponds to PfncFormat::BayerGB10.
@ YUV420P10LE
Equal to PIX_FMT_YUV420P10LE.
@ YUYV422
Equal to PIX_FMT_YUYV422.
@ GRAY12LE
Equal to PIX_FMT_GRAY12LE. Corresponds to PfncFormat::Mono12.
@ GRAY10LE
Equal to PIX_FMT_GRAY10LE. Corresponds to PfncFormat::Mono10.
@ BGRA
Equal to PIX_FMT_BGRA. Corresponds to PfncFormat::BGRa8.
@ P010LE
Equal to PIX_FMT_P010LE.
@ YUV422P10LE
Equal to PIX_FMT_YUV422P10LE.
@ GBRP16LE
Equal to PIX_FMT_GBRP16LE. Corresponds to PfncFormat::BayerGB16.
@ Y210LE
Equal to PIX_FMT_Y210LE.
@ NV21
Equal to PIX_FMT_NV21.
@ GBRP12LE
Equal to PIX_FMT_GBRP12LE.
@ X2RGB10LE
Equal to PIX_FMT_X2RGB10LE.
@ CUDA
Equal to PIX_FMT_CUDA.
@ GBRP
Equal to PIX_FMT_GBRP. Corresponds to PfncFormat::BayerGB8.
@ GRAY8
Equal to PIX_FMT_GRAY8. Corresponds to PfncFormat::Mono8.
@ DXVA2_VLD
Equal to PIX_FMT_DXVA2_VLD.
@ YUV444P10LE
Equal to PIX_FMT_YUV444P10LE.
@ YUV422P12LE
Equal to PIX_FMT_YUV422P12LE.
@ D3D11
Equal to PIX_FMT_D3D11.
@ QSV
Equal to PIX_FMT_QSV.
@ NV16
Equal to PIX_FMT_NV16.
@ RGB0
Equal to PIX_FMT_RGB0. Corresponds to PfncFormat::RGBa8, but the alpah channel is ignored.
@ YUV444P16LE
Equal to PIX_FMT_YUV444P16LE.
@ YUV422P
Equal to PIX_FMT_YUV422P.
@ YUV444P12LE
Equal to PIX_FMT_YUV444P12LE.
@ RGBA
Equal to PIX_FMT_RGBA. Corresponds to PfncFormat::RGBa8.
@ YUV420P
Equal to PIX_FMT_YUV420P.
@ X2BGR10LE
Equal to PIX_FMT_X2BGR10LE.
@ YUV420P12LE
Equal to PIX_FMT_YUV420P12LE.
@ NV20LE
Equal to PIX_FMT_NV20LE.
@ BGR24
Equal to PIX_FMT_BGR24. Corresponds to PfncFormat::BGR8.
@ P016LE
Equal to PIX_FMT_P016LE.
Interpolation
Interpolation method when scaling frames.
Definition: codec_bridge.hpp:176
@ Bicubic
Equal to SWS_BICUBIC.
@ BilinearFast
Equal to FAST_BILINEAR.
@ Bilinear
Equal to SWS_BILINEAR.
LogLevel
Log level for the codecs.
Definition: codec_bridge.hpp:65
@ Quiet
Equal to FFmpeg level: AV_LOG_QUIET.
@ Warning
Equal to FFmpeg level: AV_LOG_WARNING.
@ Fatal
Equal to FFmpeg level: AV_LOG_FATAL.
@ Error
Equal to FFmpeg level: AV_LOG_ERROR.
@ Debug
Equal to FFmpeg level: AV_LOG_DEBUG.
@ Verbose
Equal to FFmpeg level: AV_LOG_VERBOSE.
@ Panic
Equal to FFmpeg level: AV_LOG_PANIC.
@ Trace
Equal to FFmpeg level: AV_LOG_TRACE.
Root namespace for the Image Manager interface.
Definition: c_barcode.h:15