Skip to content

Commit f304bb4

Browse files
author
Clement Champetier
committed
PixelProperties: add getPixelFormatName
1 parent e65a4ca commit f304bb4

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/AvTranscoder/mediaProperty/PixelProperties.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ std::string PixelProperties::getPixelName() const
3535
return "unknown pixel name";
3636
}
3737

38+
std::string PixelProperties::getPixelFormatName() const
39+
{
40+
if( ! _pixelFormat )
41+
throw std::runtime_error( "unable to find pixel format." );
42+
43+
const char* formatName = av_get_pix_fmt_name( _pixelFormat );
44+
return formatName ? std::string( formatName ) : "unknown pixel format";
45+
}
46+
3847
size_t PixelProperties::getBitsPerPixel() const
3948
{
4049
if( ! _pixelDesc )
@@ -214,6 +223,7 @@ PropertiesMap PixelProperties::getPropertiesAsMap() const
214223
PropertiesMap dataMap;
215224

216225
detail::add( dataMap, "pixelName", getPixelName() );
226+
detail::add( dataMap, "pixelFormatName", getPixelFormatName() );
217227
detail::add( dataMap, "bitDepth", getBitsPerPixel() );
218228
detail::add( dataMap, "nbComponents", getNbComponents() );
219229
detail::add( dataMap, "chromaWidth", getChromaWidth() );

src/AvTranscoder/mediaProperty/PixelProperties.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class AvExport PixelProperties
5353
PixelProperties( const AVPixelFormat avPixelFormat );
5454

5555
std::string getPixelName() const;
56+
std::string getPixelFormatName() const;
5657

5758
size_t getBitsPerPixel() const;
5859
size_t getNbComponents() const;

0 commit comments

Comments
 (0)