summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-04-12 11:32:55 +0200
committerCarl Hetherington <cth@carlh.net>2025-04-12 11:32:55 +0200
commit3dcabe8d9c7d82f6be4790fd68db62188ce64710 (patch)
treee23124f9d4faab4abaa2d532f2fff0d7afd1d327 /src/lib
parent401821e667cd4c719dc0e6e84a1fa662c8d30c86 (diff)
Add has_alpha() flag to VideoContent.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/dcp_examiner.h4
-rw-r--r--src/lib/ffmpeg_examiner.h3
-rw-r--r--src/lib/image_examiner.cc4
-rw-r--r--src/lib/image_examiner.h4
-rw-r--r--src/lib/video_content.cc5
-rw-r--r--src/lib/video_content.h6
-rw-r--r--src/lib/video_examiner.h1
-rw-r--r--src/lib/video_mxf_examiner.h3
8 files changed, 28 insertions, 2 deletions
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<int> bits_per_pixel () const;
- bool has_alpha() const;
boost::optional<double> 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<const Film> film, shared_ptr<const Imag
}
} else {
FFmpegImageProxy proxy(content->path(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<const Film> _film;
std::shared_ptr<const ImageContent> _image_content;
boost::optional<dcp::Size> _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<shared_ptr<Content> > 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<const Film> film, shared_ptr<VideoEx
auto const yuv = d->yuv();
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<const Film> film, shared_ptr<VideoEx
_yuv = yuv;
_range = range;
_pixel_quanta = pixel_quanta;
+ _has_alpha = has_alpha;
}
LOG_GENERAL("Video length obtained from header as %1 frames", _length);
diff --git a/src/lib/video_content.h b/src/lib/video_content.h
index c6fce70d5..db46f06eb 100644
--- a/src/lib/video_content.h
+++ b/src/lib/video_content.h
@@ -192,6 +192,11 @@ public:
return _pixel_quanta;
}
+ bool has_alpha() const {
+ boost::mutex::scoped_lock lm(_mutex);
+ return _has_alpha;
+ }
+
bool use() const {
boost::mutex::scoped_lock lm(_mutex);
return _use;
@@ -261,6 +266,7 @@ private:
VideoRange _range;
PixelQuanta _pixel_quanta;
boost::optional<dcp::LanguageTag> _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<dcp::PictureAsset> _asset;