Skip to content

Commit 57dbe41

Browse files
author
Clement Champetier
committed
Pixel: throw if unable to find pixel format.
1 parent 841fa76 commit 57dbe41

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/AvTranscoder/EssenceStructures/Pixel.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ extern "C" {
1010
#include <libavutil/pixdesc.h>
1111
}
1212

13+
#include <stdexcept>
14+
1315
namespace avtranscoder
1416
{
1517

@@ -65,7 +67,13 @@ AVPixelFormat Pixel::findPixel() const
6567

6668
void Pixel::init( const AVPixelFormat avPixelFormat )
6769
{
68-
const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get( avPixelFormat );
70+
const AVPixFmtDescriptor* pix_desc = av_pix_fmt_desc_get( avPixelFormat );
71+
72+
if( ! pix_desc )
73+
{
74+
throw std::runtime_error( "unable to find pixel format." );
75+
}
76+
6977
setBitsPerPixel ( av_get_bits_per_pixel( pix_desc ) );
7078
setBigEndian ( pix_desc->flags & PIX_FMT_BE );
7179
setComponents ( pix_desc->nb_components );

0 commit comments

Comments
 (0)