Skip to content

Commit 0f30297

Browse files
author
Clement Champetier
committed
PixelProperties: all getters throw exception when can't access data
1 parent 9fbb444 commit 0f30297

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/AvTranscoder/mediaProperty/PixelProperties.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ std::string PixelProperties::getPixelName() const
3131
if( ! _pixelDesc )
3232
throw std::runtime_error( "unable to find pixel description." );
3333

34-
if( _pixelDesc && _pixelDesc->name )
35-
return std::string( _pixelDesc->name );
36-
return "unknown pixel name";
34+
if( ! _pixelDesc || ! _pixelDesc->name )
35+
throw std::runtime_error( "unknown pixel name" );
36+
37+
return std::string( _pixelDesc->name );
3738
}
3839

3940
std::string PixelProperties::getPixelFormatName() const
@@ -42,7 +43,10 @@ std::string PixelProperties::getPixelFormatName() const
4243
throw std::runtime_error( "unable to find pixel format." );
4344

4445
const char* formatName = av_get_pix_fmt_name( _pixelFormat );
45-
return formatName ? std::string( formatName ) : "unknown pixel format";
46+
if( ! formatName )
47+
throw std::runtime_error( "unknown pixel format" );
48+
49+
return std::string( formatName );
4650
}
4751

4852
size_t PixelProperties::getBitsPerPixel() const

0 commit comments

Comments
 (0)