X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fffmpeg_content.cc;h=4bc88e1e4937ca2e896101ae8903c0539893cd7e;hb=ff639b3cf30afcc097bfd21d39c8d15f466cadd6;hp=b1bb632b1496536da2f6f3a1ff96b6b5655e0561;hpb=e0255a64d22440d718e5512f34a4f21f0d37a21b;p=dcpomatic.git
diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc
index b1bb632b1..4bc88e1e4 100644
--- a/src/lib/ffmpeg_content.cc
+++ b/src/lib/ffmpeg_content.cc
@@ -16,6 +16,7 @@
You should have received a copy of the GNU General Public License
along with DCP-o-matic. If not, see .
+
*/
#include "ffmpeg_content.h"
@@ -45,6 +46,7 @@ extern "C" {
#include "i18n.h"
+
using std::string;
using std::vector;
using std::list;
@@ -59,17 +61,20 @@ using boost::optional;
using dcp::raw_convert;
using namespace dcpomatic;
+
int const FFmpegContentProperty::SUBTITLE_STREAMS = 100;
int const FFmpegContentProperty::SUBTITLE_STREAM = 101;
int const FFmpegContentProperty::FILTERS = 102;
int const FFmpegContentProperty::KDM = 103;
+
FFmpegContent::FFmpegContent (boost::filesystem::path p)
: Content (p)
{
}
+
template
optional
get_optional_enum (cxml::ConstNodePtr node, string name)
@@ -81,12 +86,17 @@ get_optional_enum (cxml::ConstNodePtr node, string name)
return static_cast(*v);
}
+
FFmpegContent::FFmpegContent (cxml::ConstNodePtr node, int version, list& notes)
: Content (node)
{
- video = VideoContent::from_xml (this, node, version);
+ _color_range = get_optional_enum(node, "ColorRange");
+
+ VideoRange const video_range_hint = (_color_range && *_color_range == AVCOL_RANGE_JPEG) ? VideoRange::FULL : VideoRange::VIDEO;
+
+ video = VideoContent::from_xml (this, node, version, video_range_hint);
audio = AudioContent::from_xml (this, node, version);
- text = TextContent::from_xml (this, node, version);
+ text = TextContent::from_xml (this, node, version, notes);
for (auto i: node->node_children("SubtitleStream")) {
_subtitle_streams.push_back (make_shared(i, version));
@@ -118,14 +128,14 @@ FFmpegContent::FFmpegContent (cxml::ConstNodePtr node, int version, list
_first_video = ContentTime (f.get ());
}
- _color_range = get_optional_enum(node, "ColorRange");
_color_primaries = get_optional_enum(node, "ColorPrimaries");
_color_trc = get_optional_enum(node, "ColorTransferCharacteristic");
_colorspace = get_optional_enum(node, "Colorspace");
_bits_per_pixel = node->optional_number_child ("BitsPerPixel");
}
-FFmpegContent::FFmpegContent (vector > c)
+
+FFmpegContent::FFmpegContent (vector> c)
: Content (c)
{
auto i = c.begin ();
@@ -186,10 +196,11 @@ FFmpegContent::FFmpegContent (vector > c)
_bits_per_pixel = ref->_bits_per_pixel;
}
+
void
FFmpegContent::as_xml (xmlpp::Node* node, bool with_paths) const
{
- node->add_child("Type")->add_child_text ("FFmpeg");
+ node->add_child("Type")->add_child_text("FFmpeg");
Content::as_xml (node, with_paths);
if (video) {
@@ -199,7 +210,7 @@ FFmpegContent::as_xml (xmlpp::Node* node, bool with_paths) const
if (audio) {
audio->as_xml (node);
- for (auto i: audio->streams ()) {
+ for (auto i: audio->streams()) {
auto f = dynamic_pointer_cast (i);
DCPOMATIC_ASSERT (f);
f->as_xml (node->add_child("AudioStream"));
@@ -225,26 +236,27 @@ FFmpegContent::as_xml (xmlpp::Node* node, bool with_paths) const
}
if (_first_video) {
- node->add_child("FirstVideo")->add_child_text (raw_convert (_first_video.get().get()));
+ node->add_child("FirstVideo")->add_child_text(raw_convert(_first_video.get().get()));
}
if (_color_range) {
- node->add_child("ColorRange")->add_child_text (raw_convert (static_cast (*_color_range)));
+ node->add_child("ColorRange")->add_child_text(raw_convert(static_cast(*_color_range)));
}
if (_color_primaries) {
- node->add_child("ColorPrimaries")->add_child_text (raw_convert (static_cast (*_color_primaries)));
+ node->add_child("ColorPrimaries")->add_child_text(raw_convert(static_cast(*_color_primaries)));
}
if (_color_trc) {
- node->add_child("ColorTransferCharacteristic")->add_child_text (raw_convert (static_cast (*_color_trc)));
+ node->add_child("ColorTransferCharacteristic")->add_child_text(raw_convert(static_cast(*_color_trc)));
}
if (_colorspace) {
- node->add_child("Colorspace")->add_child_text (raw_convert (static_cast (*_colorspace)));
+ node->add_child("Colorspace")->add_child_text(raw_convert(static_cast(*_colorspace)));
}
if (_bits_per_pixel) {
- node->add_child("BitsPerPixel")->add_child_text (raw_convert (*_bits_per_pixel));
+ node->add_child("BitsPerPixel")->add_child_text(raw_convert(*_bits_per_pixel));
}
}
+
void
FFmpegContent::examine (shared_ptr film, shared_ptr job)
{
@@ -290,7 +302,7 @@ FFmpegContent::examine (shared_ptr film, shared_ptr job)
}
}
- if (!examiner->audio_streams().empty ()) {
+ if (!examiner->audio_streams().empty()) {
audio = make_shared(this);
for (auto i: examiner->audio_streams()) {
@@ -308,6 +320,7 @@ FFmpegContent::examine (shared_ptr film, shared_ptr job)
text.clear ();
text.push_back (make_shared(this, TextType::OPEN_SUBTITLE, TextType::UNKNOWN));
_subtitle_stream = _subtitle_streams.front ();
+ text.front()->add_font(make_shared(""));
}
}
@@ -324,20 +337,22 @@ FFmpegContent::examine (shared_ptr film, shared_ptr job)
}
}
+
string
FFmpegContent::summary () const
{
if (video && audio) {
- return String::compose (_("%1 [movie]"), path_summary ());
+ return String::compose (_("%1 [movie]"), path_summary());
} else if (video) {
- return String::compose (_("%1 [video]"), path_summary ());
+ return String::compose (_("%1 [video]"), path_summary());
} else if (audio) {
- return String::compose (_("%1 [audio]"), path_summary ());
+ return String::compose (_("%1 [audio]"), path_summary());
}
return path_summary ();
}
+
string
FFmpegContent::technical_summary () const
{
@@ -372,6 +387,7 @@ FFmpegContent::technical_summary () const
);
}
+
void
FFmpegContent::set_subtitle_stream (shared_ptr s)
{
@@ -383,18 +399,21 @@ FFmpegContent::set_subtitle_stream (shared_ptr s)
}
}
+
bool
operator== (FFmpegStream const & a, FFmpegStream const & b)
{
return a._id == b._id;
}
+
bool
operator!= (FFmpegStream const & a, FFmpegStream const & b)
{
return a._id != b._id;
}
+
DCPTime
FFmpegContent::full_length (shared_ptr film) const
{
@@ -413,9 +432,10 @@ FFmpegContent::full_length (shared_ptr film) const
/* XXX: subtitle content? */
- return DCPTime();
+ return {};
}
+
DCPTime
FFmpegContent::approximate_length () const
{
@@ -433,6 +453,7 @@ FFmpegContent::approximate_length () const
return DCPTime::from_frames (longest, 24);
}
+
void
FFmpegContent::set_filters (vector const & filters)
{
@@ -444,6 +465,7 @@ FFmpegContent::set_filters (vector const & filters)
}
}
+
string
FFmpegContent::identifier () const
{
@@ -470,6 +492,7 @@ FFmpegContent::identifier () const
return s;
}
+
void
FFmpegContent::set_default_colour_conversion ()
{
@@ -505,6 +528,7 @@ FFmpegContent::set_default_colour_conversion ()
}
}
+
void
FFmpegContent::add_properties (shared_ptr film, list& p) const
{
@@ -649,6 +673,7 @@ FFmpegContent::add_properties (shared_ptr film, list&
}
}
+
/** Our subtitle streams have colour maps, which can be changed, but
* they have no way of signalling that change. As a hack, we have this
* method which callers can use when they've modified one of our subtitle
@@ -661,20 +686,22 @@ FFmpegContent::signal_subtitle_stream_changed ()
ContentChangeSignaller cc (this, FFmpegContentProperty::SUBTITLE_STREAM);
}
-vector >
+
+vector>
FFmpegContent::ffmpeg_audio_streams () const
{
- vector > fa;
+ vector> fa;
if (audio) {
for (auto i: audio->streams()) {
- fa.push_back (dynamic_pointer_cast (i));
+ fa.push_back (dynamic_pointer_cast(i));
}
}
return fa;
}
+
void
FFmpegContent::take_settings_from (shared_ptr c)
{