Skip to content

Commit bde4632

Browse files
author
Clement Champetier
committed
PixelProperties: added getMaxBitPerChannel
1 parent f757baf commit bde4632

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/AvTranscoder/mediaProperty/PixelProperties.cpp

Lines changed: 15 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::getMaxBitPerChannel() const
60+
{
61+
if( ! _pixelDesc )
62+
throw std::runtime_error( "unable to find pixel description." );
63+
64+
size_t maxBitPerChannel = 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 > maxBitPerChannel )
69+
maxBitPerChannel = nbBits;
70+
}
71+
return maxBitPerChannel;
72+
}
73+
5974
size_t PixelProperties::getNbComponents() const
6075
{
6176
if( ! _pixelDesc )

src/AvTranscoder/mediaProperty/PixelProperties.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class AvExport PixelProperties
5656
std::string getPixelFormatName() const;
5757

5858
size_t getBitsPerPixel() const;
59+
size_t getMaxBitPerChannel() const;
5960
size_t getNbComponents() const;
6061
size_t getChromaWidth() const;
6162
size_t getChromaHeight() const;

0 commit comments

Comments
 (0)