forked from avTranscoder/avTranscoder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPixelProperties.hpp
More file actions
110 lines (90 loc) · 2.87 KB
/
PixelProperties.hpp
File metadata and controls
110 lines (90 loc) · 2.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#ifndef _AV_TRANSCODER_FRAME_PIXEL_PROPERTIES_HPP_
#define _AV_TRANSCODER_FRAME_PIXEL_PROPERTIES_HPP_
#include <AvTranscoder/common.hpp>
#include <AvTranscoder/properties/util.hpp>
extern "C" {
#include <libavutil/pixfmt.h>
#include <libavutil/pixdesc.h>
}
#include <string>
#include <vector>
struct AVPixFmtDescriptor;
namespace avtranscoder
{
enum EComponentType
{
eComponentGray = 0, ///< Gray color space
eComponentRgb, ///< RGB color space
eComponentYuv, ///< YUV color space. 16 <= Y <= 235, 16 <= U, V <= 240
eComponentYuvJPEG, ///< YUV color space. 0 <= Y <= 255, 0 <= U, V <= 255
eComponentYuvA ///< YUV color space with transparency
};
enum ESubsamplingType
{
eSubsamplingNone = 0, // 4:4:4
eSubsampling440, // 4:4:0
eSubsampling422, // 4:2:2
eSubsampling420, // 4:2:0
eSubsampling411, // 4:1:1
eSubsampling410 // 4:1:0
};
struct AvExport Channel
{
size_t id;
size_t chromaHeight;
size_t bitStep;
};
class AvExport PixelProperties
{
public:
/**
* If parameter is an unknown pixel, its format is AV_PIX_FMT_NONE with no access to pixel description.
*/
PixelProperties(const std::string& avPixelFormat = "");
PixelProperties(const AVPixelFormat avPixelFormat);
std::string getPixelName() const;
std::string getPixelFormatName() const;
size_t getBitsPerPixel() const; ///< padding bits are not counted
size_t getMaxNbBitsInChannels() const;
size_t getNbComponents() const;
size_t getChromaWidth() const;
size_t getChromaHeight() const;
EComponentType getColorComponents() const;
ESubsamplingType getSubsampling() const;
bool isBigEndian() const;
bool hasAlpha() const;
bool isPlanar() const;
bool isIndexedColors() const;
bool isBitWisePacked() const;
bool isHardwareAccelerated() const;
bool isRgbPixelData() const;
bool isPaletted() const;
std::vector<Channel> getChannels() const;
#ifndef SWIG
AVPixelFormat getAVPixelFormat() const { return _pixelFormat; }
const AVPixFmtDescriptor* getAVPixFmtDescriptor() const { return _pixelDesc; }
#endif
PropertyVector asVector() const; ///< Return all pixel properties as a vector (name of property: value)
PropertyVector& fillVector(PropertyVector& data) const; ///< To avoid copy of the vector
private:
void init(const AVPixelFormat avPixelFormat);
#ifndef SWIG
template <typename T>
void addProperty(PropertyVector& data, const std::string& key, T (PixelProperties::*getter)(void) const) const
{
try
{
detail::add(data, key, (this->*getter)());
}
catch(const std::exception& e)
{
detail::add(data, key, detail::propertyValueIfError);
}
}
#endif
private:
AVPixelFormat _pixelFormat;
const AVPixFmtDescriptor* _pixelDesc; ///< Has link (no ownership)
};
}
#endif