Add FFmpegExaminer::has_alpha().
authorCarl Hetherington <cth@carlh.net>
Sun, 10 Dec 2023 15:20:20 +0000 (16:20 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 12 Dec 2023 14:03:23 +0000 (15:03 +0100)
src/lib/ffmpeg_examiner.cc
src/lib/ffmpeg_examiner.h

index 46f4f236e889515eca0254da7f7195be74efb5bb..ed6f210945960503ac303effc8d731af4554e4d2 100644 (file)
@@ -383,6 +383,19 @@ FFmpegExaminer::bits_per_pixel () const
 }
 
 
+bool
+FFmpegExaminer::has_alpha() const
+{
+       if (video_codec_context()->pix_fmt == -1) {
+               return false;
+       }
+
+       auto const d = av_pix_fmt_desc_get(video_codec_context()->pix_fmt);
+       DCPOMATIC_ASSERT(d);
+       return d->flags & AV_PIX_FMT_FLAG_ALPHA;
+}
+
+
 bool
 FFmpegExaminer::yuv () const
 {
index 10d060707588be939ba20925c4a2d41b6035bea1..4747929b594571caf08775d5baea04c2a2261639 100644 (file)
@@ -77,6 +77,8 @@ public:
 
        boost::optional<int> bits_per_pixel () const;
 
+       bool has_alpha() const;
+
        boost::optional<double> rotation () const {
                return _rotation;
        }