From 3dcabe8d9c7d82f6be4790fd68db62188ce64710 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 12 Apr 2025 11:32:55 +0200 Subject: Add has_alpha() flag to VideoContent. --- src/lib/dcp_examiner.h | 4 ++++ src/lib/ffmpeg_examiner.h | 3 ++- src/lib/image_examiner.cc | 4 +++- src/lib/image_examiner.h | 4 ++++ src/lib/video_content.cc | 5 +++++ src/lib/video_content.h | 6 ++++++ src/lib/video_examiner.h | 1 + src/lib/video_mxf_examiner.h | 3 +++ 8 files changed, 28 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/lib/dcp_examiner.h b/src/lib/dcp_examiner.h index 381afdaed..ca3cae76e 100644 --- a/src/lib/dcp_examiner.h +++ b/src/lib/dcp_examiner.h @@ -68,6 +68,10 @@ public: return {}; } + bool has_alpha() const override { + return false; + } + std::string name() const { return _name; } diff --git a/src/lib/ffmpeg_examiner.h b/src/lib/ffmpeg_examiner.h index ad64f349d..c85a76d40 100644 --- a/src/lib/ffmpeg_examiner.h +++ b/src/lib/ffmpeg_examiner.h @@ -59,6 +59,8 @@ public: PixelQuanta pixel_quanta () const override; + bool has_alpha() const override; + AVColorRange color_range () const { return video_codec_context()->color_range; } @@ -77,7 +79,6 @@ public: boost::optional bits_per_pixel () const; - bool has_alpha() const; boost::optional rotation () const { return _rotation; diff --git a/src/lib/image_examiner.cc b/src/lib/image_examiner.cc index 15a0b043d..16258aed5 100644 --- a/src/lib/image_examiner.cc +++ b/src/lib/image_examiner.cc @@ -66,7 +66,9 @@ ImageExaminer::ImageExaminer (shared_ptr film, shared_ptrpath(0)); - _video_size = proxy.image(Image::Alignment::COMPACT).image->size(); + auto image = proxy.image(Image::Alignment::COMPACT); + _video_size = image.image->size(); + _has_alpha = image.image->has_alpha(); } if (content->still ()) { diff --git a/src/lib/image_examiner.h b/src/lib/image_examiner.h index 54fca7ed1..d6cdfac53 100644 --- a/src/lib/image_examiner.h +++ b/src/lib/image_examiner.h @@ -43,10 +43,14 @@ public: /* See ::yuv - we're assuming the image is not YUV and so not subsampled */ return {}; } + bool has_alpha() const override { + return _has_alpha; + } private: std::weak_ptr _film; std::shared_ptr _image_content; boost::optional _video_size; Frame _video_length; + bool _has_alpha = false; }; diff --git a/src/lib/video_content.cc b/src/lib/video_content.cc index 4203d6640..a5f65de24 100644 --- a/src/lib/video_content.cc +++ b/src/lib/video_content.cc @@ -199,6 +199,7 @@ VideoContent::VideoContent(Content* parent, cxml::ConstNodePtr node, int version _burnt_subtitle_language = dcp::LanguageTag(*burnt); } + _has_alpha = node->optional_bool_child("HasAlpha").get_value_or(false); } @@ -255,6 +256,7 @@ VideoContent::VideoContent(Content* parent, vector > c) } _pixel_quanta = max(_pixel_quanta, c[i]->video->_pixel_quanta); + _has_alpha = _has_alpha | c[i]->video->_has_alpha; } _use = ref->use(); @@ -303,6 +305,7 @@ VideoContent::as_xml(xmlpp::Element* element) const if (_burnt_subtitle_language) { cxml::add_text_child(element, "BurntSubtitleLanguage", _burnt_subtitle_language->as_string()); } + cxml::add_text_child(element, "HasAlpha", _has_alpha ? "1" : "0"); } void @@ -315,6 +318,7 @@ VideoContent::take_from_examiner(shared_ptr film, shared_ptryuv(); auto const range = d->range(); auto const pixel_quanta = d->pixel_quanta(); + auto const has_alpha = d->has_alpha(); ContentChangeSignaller cc1(_parent, VideoContentProperty::SIZE); ContentChangeSignaller cc2(_parent, ContentProperty::LENGTH); @@ -328,6 +332,7 @@ VideoContent::take_from_examiner(shared_ptr film, shared_ptr _burnt_subtitle_language; + bool _has_alpha = false; }; diff --git a/src/lib/video_examiner.h b/src/lib/video_examiner.h index 471537f7a..e13241885 100644 --- a/src/lib/video_examiner.h +++ b/src/lib/video_examiner.h @@ -53,4 +53,5 @@ public: virtual bool yuv() const = 0; virtual VideoRange range() const = 0; virtual PixelQuanta pixel_quanta() const = 0; + virtual bool has_alpha() const = 0; }; diff --git a/src/lib/video_mxf_examiner.h b/src/lib/video_mxf_examiner.h index e4cd98f07..2dad09c08 100644 --- a/src/lib/video_mxf_examiner.h +++ b/src/lib/video_mxf_examiner.h @@ -45,6 +45,9 @@ public: PixelQuanta pixel_quanta () const override { return {}; } + bool has_alpha() const override { + return false; + } private: std::shared_ptr _asset; -- cgit v1.2.3