Skip to content

PixelProperties: add getMaxBitPerChannel #265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/AvTranscoder/mediaProperty/PixelProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,21 @@ size_t PixelProperties::getBitsPerPixel() const
return av_get_bits_per_pixel( _pixelDesc );
}

size_t PixelProperties::getMaxNbBitsInChannels() const
{
if( ! _pixelDesc )
throw std::runtime_error( "unable to find pixel description." );

size_t maxNbBitsInChannels = 0;
for( unsigned int channelIndex = 0; channelIndex < _pixelDesc->nb_components; ++channelIndex )
{
const size_t nbBits = _pixelDesc->comp[channelIndex].depth_minus1 + 1;
if( nbBits > maxNbBitsInChannels )
maxNbBitsInChannels = nbBits;
}
return maxNbBitsInChannels;
}

size_t PixelProperties::getNbComponents() const
{
if( ! _pixelDesc )
Expand Down Expand Up @@ -230,6 +245,7 @@ PropertyVector PixelProperties::getPropertiesAsVector() const
addProperty( data, "pixelName", &PixelProperties::getPixelName );
addProperty( data, "pixelFormatName", &PixelProperties::getPixelFormatName );
addProperty( data, "bitDepth", &PixelProperties::getBitsPerPixel );
addProperty( data, "maxNbBitsInChannels", &PixelProperties::getMaxNbBitsInChannels );
addProperty( data, "nbComponents", &PixelProperties::getNbComponents );
addProperty( data, "chromaWidth", &PixelProperties::getChromaWidth );
addProperty( data, "chromaHeight", &PixelProperties::getChromaHeight );
Expand Down
3 changes: 2 additions & 1 deletion src/AvTranscoder/mediaProperty/PixelProperties.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ class AvExport PixelProperties
std::string getPixelName() const;
std::string getPixelFormatName() const;

size_t getBitsPerPixel() 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;
Expand Down