Fix crash when FFmpeg doesn't recognise a file's pixel format.
authorCarl Hetherington <cth@carlh.net>
Thu, 18 Feb 2016 13:52:41 +0000 (13:52 +0000)
committerCarl Hetherington <cth@carlh.net>
Thu, 18 Feb 2016 13:52:41 +0000 (13:52 +0000)
src/lib/ffmpeg_examiner.cc

index dacc652bb73b273a5781b8017f95b40a1e8b7aac..29cc69063c12fd60360aa64c061103a939845f46 100644 (file)
@@ -353,7 +353,13 @@ FFmpegExaminer::stream_name (AVStream* s) const
 int
 FFmpegExaminer::bits_per_pixel () const
 {
-       return av_get_bits_per_pixel (av_pix_fmt_desc_get (video_codec_context()->pix_fmt));
+       if (video_codec_context()->pix_fmt == -1) {
+               throw DecodeError (_("Could not find pixel format for video."));
+       }
+
+       AVPixFmtDescriptor const * d = av_pix_fmt_desc_get (video_codec_context()->pix_fmt);
+       DCPOMATIC_ASSERT (d);
+       return av_get_bits_per_pixel (d);
 }
 
 bool