Skip to content

Commit f784304

Browse files
Merge pull request #39 from cchampet/fix_pixelFormat
Fix pixel format
2 parents 50af13f + 57dbe41 commit f784304

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
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 );

src/AvTranscoder/Metadatas/VideoStreamProperties.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ VideoProperties videoStreamInfo(
281281
const AVPixFmtDescriptor* pixFmt = av_pix_fmt_desc_get( codec_context->pix_fmt );
282282
#else
283283
const AVPixFmtDescriptor* pixFmt = NULL;
284-
if( codec_context->pix_fmt > 0 && codec_context->pix_fmt < PIX_FMT_NB )
284+
if( codec_context->pix_fmt >= 0 && codec_context->pix_fmt < PIX_FMT_NB )
285285
pixFmt = &av_pix_fmt_descriptors[ codec_context->pix_fmt ];
286286
#endif
287287

0 commit comments

Comments
 (0)