Zao SDK for Jetson / libzep API Reference
Loading...
Searching...
No Matches
VideoFormat.hpp
1/*
2 * Copyright (c) 2022-2023, Soliton Systems K.K. All rights reserved.
3 * Use in source and binary forms, with or without modification,
4 * is permitted provided that the following a condition is met:
5 *
6 * Use is permitted only in accordance with the terms and
7 * conditions set forth in the Software License Agreement available
8 * at https://zao-sdk.org/license-agreement/.
9 */
10#ifndef ZEP_VIDEO_VIDEO_FORMAT_HPP_
11#define ZEP_VIDEO_VIDEO_FORMAT_HPP_
12
13#include <linux/videodev2.h>
14
15#include <memory>
16#include <string>
17
18namespace zep {
19namespace video {
20
24class VideoFormat {
25 public:
30 VideoFormat() noexcept {}
31
44 VideoFormat(int width, int height, bool interlaced, double fps,
45 uint32_t pixelformat, v4l2_quantization quantization,
46 v4l2_colorspace colorspace) noexcept
47 : width_(width),
48 height_(height),
49 interlaced_(interlaced),
50 fps_(fps),
51 pixelformat_(pixelformat),
52 quantization_(quantization),
53 colorspace_(colorspace) {}
54
62 void GetFramerate(int& numerator, int& denominator) const noexcept {
64 denominator = 100;
65 numerator = fps_ * denominator;
66 }
67
71 double GetFramerate() const noexcept { return fps_; }
72
76 int GetWidth() const noexcept { return width_; }
77
84 int GetHeight() const noexcept { return height_; }
85
92 int GetFieldHeight() const noexcept {
93 return interlaced_ ? height_ / 2 : height_;
94 }
95
102 bool GetInterlaced() const noexcept { return interlaced_; }
103
108 uint32_t GetPixelFormat() const noexcept { return pixelformat_; }
109
114 v4l2_quantization GetQuantization() const noexcept { return quantization_; }
115
120 v4l2_colorspace GetColorSpace() const noexcept { return colorspace_; }
121
122 bool operator==(const VideoFormat& other) const {
123 return ((this->width_ == other.width_) &&
124 (this->height_ == other.height_) &&
125 (this->interlaced_ == other.interlaced_) &&
126 (std::abs(this->fps_ - other.fps_) < 0.01) &&
127 (this->pixelformat_ == other.pixelformat_) &&
128 (this->quantization_ == other.quantization_) &&
129 (this->colorspace_ == other.colorspace_));
130 }
131
132 bool operator!=(const VideoFormat& other) const { return !(*this == other); }
133
134 private:
135 int width_ = 0;
136 int height_ = 0;
137 bool interlaced_ = false;
138 double fps_ = 0.0;
139
140 // V4L2 固有設定
142 uint32_t pixelformat_ = 0;
143 v4l2_quantization quantization_ =
144 v4l2_quantization::V4L2_QUANTIZATION_DEFAULT;
145 v4l2_colorspace colorspace_ = v4l2_colorspace::V4L2_COLORSPACE_DEFAULT;
146};
147
148} // namespace video
149} // namespace zep
150
151#endif // ZEP_VIDEO_VIDEO_FORMAT_HPP_
Video format information.
Definition VideoFormat.hpp:24
double GetFramerate() const noexcept
フレームレートを浮動小数点で取得する。
Definition VideoFormat.hpp:71
uint32_t GetPixelFormat() const noexcept
ピクセルフォーマットを取得する。
Definition VideoFormat.hpp:108
bool GetInterlaced() const noexcept
インターレース方式か否かを取得する。
Definition VideoFormat.hpp:102
int GetFieldHeight() const noexcept
フィールドの高さをピクセル数で取得する。
Definition VideoFormat.hpp:92
v4l2_colorspace GetColorSpace() const noexcept
色空間を取得する。
Definition VideoFormat.hpp:120
VideoFormat(int width, int height, bool interlaced, double fps, uint32_t pixelformat, v4l2_quantization quantization, v4l2_colorspace colorspace) noexcept
VideoFormatオブジェクトを初期値付きで構築する。
Definition VideoFormat.hpp:44
bool operator==(const VideoFormat &other) const
Definition VideoFormat.hpp:122
VideoFormat() noexcept
VideoFormatオブジェクトをデフォルト構築する。
Definition VideoFormat.hpp:30
int GetWidth() const noexcept
ピクチャの横幅をピクセル数で取得する。
Definition VideoFormat.hpp:76
v4l2_quantization GetQuantization() const noexcept
Limited rangeかFull rangeかを取得する。
Definition VideoFormat.hpp:114
int GetHeight() const noexcept
ピクチャの高さをピクセル数で取得する。
Definition VideoFormat.hpp:84
void GetFramerate(int &numerator, int &denominator) const noexcept
フレームレートの分子と分母を取得する。
Definition VideoFormat.hpp:62
Namespace for ZEP SDK.
Definition FactoryInterface.hpp:19