Skip to content

Commit b5330b0

Browse files
committed
Merge pull request #265 from cchampet/dev_VideoPropertiesGetMaxBitPerChannel
PixelProperties: add getMaxBitPerChannel
2 parents 024d5e6 + ee02960 commit b5330b0

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/AvTranscoder/mediaProperty/PixelProperties.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,21 @@ size_t PixelProperties::getBitsPerPixel() const
5656
return av_get_bits_per_pixel( _pixelDesc );
5757
}
5858

59+
size_t PixelProperties::getMaxNbBitsInChannels() const
60+
{
61+
if( ! _pixelDesc )
62+
throw std::runtime_error( "unable to find pixel description." );
63+
64+
size_t maxNbBitsInChannels = 0;
65+
for( unsigned int channelIndex = 0; channelIndex < _pixelDesc->nb_components; ++channelIndex )
66+
{
67+
const size_t nbBits = _pixelDesc->comp[channelIndex].depth_minus1 + 1;
68+
if( nbBits > maxNbBitsInChannels )
69+
maxNbBitsInChannels = nbBits;
70+
}
71+
return maxNbBitsInChannels;
72+
}
73+
5974
size_t PixelProperties::getNbComponents() const
6075
{
6176
if( ! _pixelDesc )
@@ -230,6 +245,7 @@ PropertyVector PixelProperties::getPropertiesAsVector() const
230245
addProperty( data, "pixelName", &PixelProperties::getPixelName );
231246
addProperty( data, "pixelFormatName", &PixelProperties::getPixelFormatName );
232247
addProperty( data, "bitDepth", &PixelProperties::getBitsPerPixel );
248+
addProperty( data, "maxNbBitsInChannels", &PixelProperties::getMaxNbBitsInChannels );
233249
addProperty( data, "nbComponents", &PixelProperties::getNbComponents );
234250
addProperty( data, "chromaWidth", &PixelProperties::getChromaWidth );
235251
addProperty( data, "chromaHeight", &PixelProperties::getChromaHeight );

src/AvTranscoder/mediaProperty/PixelProperties.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ class AvExport PixelProperties
5555
std::string getPixelName() const;
5656
std::string getPixelFormatName() const;
5757

58-
size_t getBitsPerPixel() const;
58+
size_t getBitsPerPixel() const; ///< padding bits are not counted
59+
size_t getMaxNbBitsInChannels() const;
5960
size_t getNbComponents() const;
6061
size_t getChromaWidth() const;
6162
size_t getChromaHeight() const;

0 commit comments

Comments
 (0)