File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ extern "C" {
10
10
#include < libavutil/pixdesc.h>
11
11
}
12
12
13
+ #include < stdexcept>
14
+
13
15
namespace avtranscoder
14
16
{
15
17
@@ -65,7 +67,13 @@ AVPixelFormat Pixel::findPixel() const
65
67
66
68
void Pixel::init ( const AVPixelFormat avPixelFormat )
67
69
{
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
+
69
77
setBitsPerPixel ( av_get_bits_per_pixel ( pix_desc ) );
70
78
setBigEndian ( pix_desc->flags & PIX_FMT_BE );
71
79
setComponents ( pix_desc->nb_components );
Original file line number Diff line number Diff line change @@ -281,7 +281,7 @@ VideoProperties videoStreamInfo(
281
281
const AVPixFmtDescriptor* pixFmt = av_pix_fmt_desc_get ( codec_context->pix_fmt );
282
282
#else
283
283
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 )
285
285
pixFmt = &av_pix_fmt_descriptors[ codec_context->pix_fmt ];
286
286
#endif
287
287
You can’t perform that action at this time.
0 commit comments