13 init(av_get_pix_fmt(avPixelFormat.c_str()));
26 _pixelDesc = av_pix_fmt_desc_get(avPixelFormat);
32 throw std::runtime_error(
"unable to find pixel description.");
35 throw std::runtime_error(
"unknown pixel name");
43 throw std::runtime_error(
"unable to find pixel format.");
45 const char* formatName = av_get_pix_fmt_name(
_pixelFormat);
47 throw std::runtime_error(
"unknown pixel format");
49 return std::string(formatName);
55 throw std::runtime_error(
"unable to find pixel description.");
62 throw std::runtime_error(
"unable to find pixel description.");
64 size_t maxNbBitsInChannels = 0;
65 for(
unsigned int channelIndex = 0; channelIndex <
_pixelDesc->nb_components; ++channelIndex)
67 const size_t nbBits =
_pixelDesc->comp[channelIndex].depth_minus1 + 1;
68 if(nbBits > maxNbBitsInChannels)
69 maxNbBitsInChannels = nbBits;
71 return maxNbBitsInChannels;
77 throw std::runtime_error(
"unable to find pixel description.");
84 throw std::runtime_error(
"unable to find pixel description.");
91 throw std::runtime_error(
"unable to find pixel description.");
98 throw std::runtime_error(
"unable to find pixel description.");
125 throw std::runtime_error(
"unable to find pixel description.");
156 throw std::runtime_error(
"unable to find pixel description.");
157 return (
_pixelDesc->flags & PIX_FMT_BE) == PIX_FMT_BE;
163 throw std::runtime_error(
"unable to find pixel description.");
165 #if LIBAVCODEC_VERSION_MAJOR > 53
166 return (
_pixelDesc->flags & PIX_FMT_ALPHA) == PIX_FMT_ALPHA;
175 throw std::runtime_error(
"unable to find pixel description.");
176 return (
_pixelDesc->flags & PIX_FMT_PLANAR) == PIX_FMT_PLANAR;
182 throw std::runtime_error(
"unable to find pixel description.");
183 return (
_pixelDesc->flags & PIX_FMT_PAL) == PIX_FMT_PAL;
189 throw std::runtime_error(
"unable to find pixel description.");
190 return (
_pixelDesc->flags & PIX_FMT_BITSTREAM) == PIX_FMT_BITSTREAM;
196 throw std::runtime_error(
"unable to find pixel description.");
197 return (
_pixelDesc->flags & PIX_FMT_HWACCEL) == PIX_FMT_HWACCEL;
203 throw std::runtime_error(
"unable to find pixel description.");
204 return (
_pixelDesc->flags & PIX_FMT_RGB) == PIX_FMT_RGB;
210 throw std::runtime_error(
"unable to find pixel description.");
212 #if LIBAVCODEC_VERSION_MAJOR > 53
213 return (
_pixelDesc->flags & PIX_FMT_PSEUDOPAL) == PIX_FMT_PSEUDOPAL;
222 throw std::runtime_error(
"unable to find pixel description.");
224 std::vector<Channel> channels;
225 for(
size_t channel = 0; channel < (size_t)
_pixelDesc->nb_components; ++channel)
231 channels.push_back(c);
254 std::string colorComponents;
258 colorComponents =
"gray";
261 colorComponents =
"RGB";
264 colorComponents =
"YUVJPEG";
267 colorComponents =
"YUVA";
270 colorComponents =
"YUV";
273 detail::add(data,
"colorComponents", colorComponents);
275 catch(
const std::exception& e)
282 std::string subsampling;
301 subsampling =
"None";
306 catch(
const std::exception& e)
323 for(
size_t channelIndex = 0; channelIndex < channels.size(); ++channelIndex)
325 std::stringstream channelName;
326 channelName <<
"channel_" << channels.at(channelIndex).id;
328 std::stringstream channelValue;
329 channelValue <<
"chromaHeight " << channels.at(channelIndex).chromaHeight;
330 channelValue <<
" - ";
331 channelValue <<
"bitStep " << channels.at(channelIndex).bitStep;
333 detail::add(data, channelName.str(), channelValue.str());
336 catch(
const std::exception& e)
std::vector< std::pair< std::string, std::string > > PropertyVector
PropertyVector is a vector of pair, because the order of properties matters to us.
bool isBitWisePacked() const
bool isPseudoPaletted() const
ESubsamplingType getSubsampling() const
std::string getPixelName() const
EComponentType getColorComponents() const
std::string getPixelFormatName() const
PropertyVector asVector() const
Return all pixel properties as a vector (name of property: value)
void add(PropertyVector &propertyVector, const std::string &key, const size_t &value)
size_t getNbComponents() const
YUV color space. 16 <= Y <= 235, 16 <= U, V <= 240.
YUV color space with transparency.
PixelProperties(const std::string &avPixelFormat="")
bool isRgbPixelData() const
YUV color space. 0 <= Y <= 255, 0 <= U, V <= 255.
const AVPixFmtDescriptor * _pixelDesc
Has link (no ownership)
void addProperty(PropertyVector &data, const std::string &key, T(PixelProperties::*getter)(void) const) const
size_t getChromaHeight() const
AVPixelFormat _pixelFormat
std::vector< Channel > getChannels() const
bool isHardwareAccelerated() const
size_t getMaxNbBitsInChannels() const
PropertyVector & fillVector(PropertyVector &data) const
To avoid copy of the vector.
bool isIndexedColors() const
void init(const AVPixelFormat avPixelFormat)
size_t getBitsPerPixel() const
padding bits are not counted
const std::string propertyValueIfError
size_t getChromaWidth() const