+2016-05-25 c.hetherington <cth@carlh.net>
+
+ * Treat video MXFs better by not transcoding
+ them unless necessary (part of #803).
+
2016-05-24 c.hetherington <cth@carlh.net>
* Add somewhat speculative Rec 1886 and Rec 2020
#include "dcp_subtitle_content.h"
#include "util.h"
#include "ffmpeg_audio_stream.h"
+#include "video_mxf_content.h"
#include "film.h"
#include "log_entry.h"
#include "log.h"
content.reset (new DCPContent (film, node, version));
} else if (type == "DCPSubtitle") {
content.reset (new DCPSubtitleContent (film, node, version));
+ } else if (type == "VideoMXF") {
+ content.reset (new VideoMXFContent (film, node, version));
}
return content;
content.reset (new DCPSubtitleContent (film, path));
} else if (ext == ".mxf" && dcp::SMPTESubtitleAsset::valid_mxf (path)) {
content.reset (new DCPSubtitleContent (film, path));
+ } else if (ext == ".mxf" && VideoMXFContent::valid_mxf (path)) {
+ content.reset (new VideoMXFContent (film, path));
}
if (!content) {
#include "subtitle_content.h"
#include "text_subtitle_decoder.h"
#include "text_subtitle_content.h"
+#include "video_mxf_decoder.h"
+#include "video_mxf_content.h"
#include "dcp_content.h"
#include "job.h"
#include "image.h"
frc = FrameRateChange (dsc->active_video_frame_rate(), _film->video_frame_rate());
}
+ /* VideoMXFContent */
+ shared_ptr<const VideoMXFContent> vmc = dynamic_pointer_cast<const VideoMXFContent> (i);
+ if (vmc) {
+ decoder.reset (new VideoMXFDecoder (vmc, _film->log()));
+ frc = FrameRateChange (vmc->active_video_frame_rate(), _film->video_frame_rate());
+ }
+
+ DCPOMATIC_ASSERT (decoder);
+
if (decoder->video && _ignore_video) {
decoder->video->set_ignore ();
}
--- /dev/null
+/*
+ Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "video_mxf_examiner.h"
+#include "video_mxf_content.h"
+#include "video_content.h"
+#include "job.h"
+#include "film.h"
+#include "compose.hpp"
+#include <dcp/mono_picture_asset.h>
+#include <dcp/stereo_picture_asset.h>
+#include <dcp/exceptions.h>
+#include <libxml++/libxml++.h>
+
+#include "i18n.h"
+
+using std::list;
+using std::string;
+using boost::shared_ptr;
+
+VideoMXFContent::VideoMXFContent (shared_ptr<const Film> film, boost::filesystem::path path)
+ : Content (film, path)
+{
+
+}
+
+VideoMXFContent::VideoMXFContent (shared_ptr<const Film> film, cxml::ConstNodePtr node, int version)
+ : Content (film, node)
+{
+ video = VideoContent::from_xml (this, node, version);
+}
+
+bool
+VideoMXFContent::valid_mxf (boost::filesystem::path path)
+{
+ try {
+ shared_ptr<dcp::MonoPictureAsset> mp (new dcp::MonoPictureAsset (path));
+ return true;
+ } catch (dcp::MXFFileError& e) {
+
+ } catch (dcp::DCPReadError& e) {
+
+ }
+
+ try {
+ shared_ptr<dcp::StereoPictureAsset> sp (new dcp::StereoPictureAsset (path));
+ return true;
+ } catch (dcp::MXFFileError& e) {
+
+ } catch (dcp::DCPReadError& e) {
+
+ }
+
+ return false;
+}
+
+void
+VideoMXFContent::examine (shared_ptr<Job> job)
+{
+ job->set_progress_unknown ();
+
+ Content::examine (job);
+
+ video.reset (new VideoContent (this));
+ shared_ptr<VideoMXFExaminer> examiner (new VideoMXFExaminer (shared_from_this ()));
+ video->take_from_examiner (examiner);
+}
+
+string
+VideoMXFContent::summary () const
+{
+ return String::compose (_("%1 [video]"), path_summary());
+}
+
+string
+VideoMXFContent::technical_summary () const
+{
+ return Content::technical_summary() + " - " + video->technical_summary ();
+}
+
+string
+VideoMXFContent::identifier () const
+{
+ return Content::identifier() + "_" + video->identifier();
+}
+
+void
+VideoMXFContent::as_xml (xmlpp::Node* node) const
+{
+ node->add_child("Type")->add_child_text ("VideoMXF");
+ Content::as_xml (node);
+ video->as_xml (node);
+}
+
+DCPTime
+VideoMXFContent::full_length () const
+{
+ FrameRateChange const frc (active_video_frame_rate(), film()->video_frame_rate());
+ return DCPTime::from_frames (llrint (video->length_after_3d_combine() * frc.factor()), film()->video_frame_rate());
+}
+
+void
+VideoMXFContent::add_properties (list<UserProperty>& p) const
+{
+ video->add_properties (p);
+}
+
+void
+VideoMXFContent::set_default_colour_conversion ()
+{
+ video->unset_colour_conversion ();
+}
--- /dev/null
+/*
+ Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "content.h"
+
+class VideoMXFContent : public Content
+{
+public:
+ VideoMXFContent (boost::shared_ptr<const Film> film, boost::filesystem::path path);
+ VideoMXFContent (boost::shared_ptr<const Film> film, cxml::ConstNodePtr node, int version);
+
+ boost::shared_ptr<VideoMXFContent> shared_from_this () {
+ return boost::dynamic_pointer_cast<VideoMXFContent> (Content::shared_from_this ());
+ }
+
+ void examine (boost::shared_ptr<Job> job);
+ std::string summary () const;
+ std::string technical_summary () const;
+ std::string identifier () const;
+ void as_xml (xmlpp::Node* node) const;
+ DCPTime full_length () const;
+ void add_properties (std::list<UserProperty>& p) const;
+ void set_default_colour_conversion ();
+
+ static bool valid_mxf (boost::filesystem::path path);
+};
--- /dev/null
+/*
+ Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "video_mxf_decoder.h"
+#include "video_decoder.h"
+#include "video_mxf_content.h"
+#include "j2k_image_proxy.h"
+#include <dcp/mono_picture_asset.h>
+#include <dcp/stereo_picture_asset.h>
+#include <dcp/exceptions.h>
+
+using boost::shared_ptr;
+
+VideoMXFDecoder::VideoMXFDecoder (shared_ptr<const VideoMXFContent> content, shared_ptr<Log> log)
+ : _content (content)
+{
+ video.reset (new VideoDecoder (this, content, log));
+}
+
+bool
+VideoMXFDecoder::pass (PassReason reason, bool)
+{
+ shared_ptr<dcp::MonoPictureAsset> mono;
+ try {
+ mono.reset (new dcp::MonoPictureAsset (_content->path(0)));
+ } catch (dcp::MXFFileError& e) {
+ /* maybe it's stereo */
+ } catch (dcp::DCPReadError& e) {
+ /* maybe it's stereo */
+ }
+
+ shared_ptr<dcp::StereoPictureAsset> stereo;
+ try {
+ stereo.reset (new dcp::StereoPictureAsset (_content->path(0)));
+ } catch (dcp::MXFFileError& e) {
+ if (!mono) {
+ throw;
+ }
+ } catch (dcp::DCPReadError& e) {
+ if (!mono) {
+ throw;
+ }
+ }
+
+ double const vfr = _content->active_video_frame_rate ();
+ int64_t const frame = _next.frames_round (vfr);
+
+ if (mono) {
+ video->give (shared_ptr<ImageProxy> (new J2KImageProxy (mono->get_frame(frame), mono->size())), frame);
+ } else {
+ video->give (shared_ptr<ImageProxy> (new J2KImageProxy (stereo->get_frame(frame), stereo->size(), dcp::EYE_LEFT)), frame);
+ video->give (shared_ptr<ImageProxy> (new J2KImageProxy (stereo->get_frame(frame), stereo->size(), dcp::EYE_RIGHT)), frame);
+ }
+
+ _next += ContentTime::from_frames (1, vfr);
+}
+
+void
+VideoMXFDecoder::seek (ContentTime t, bool accurate)
+{
+ video->seek (t, accurate);
+ _next = t;
+}
--- /dev/null
+/*
+ Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "decoder.h"
+
+class VideoMXFContent;
+class Log;
+
+class VideoMXFDecoder : public Decoder
+{
+public:
+ VideoMXFDecoder (boost::shared_ptr<const VideoMXFContent>, boost::shared_ptr<Log> log);
+
+private:
+ bool pass (PassReason, bool accurate);
+ void seek (ContentTime t, bool accurate);
+
+ boost::shared_ptr<const VideoMXFContent> _content;
+ /** Time of next thing to return from pass */
+ ContentTime _next;
+};
--- /dev/null
+/*
+ Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "video_mxf_content.h"
+#include "video_mxf_examiner.h"
+#include <dcp/exceptions.h>
+#include <dcp/mono_picture_asset.h>
+#include <dcp/stereo_picture_asset.h>
+
+using boost::shared_ptr;
+using boost::optional;
+
+VideoMXFExaminer::VideoMXFExaminer (shared_ptr<const VideoMXFContent> content)
+{
+ try {
+ _asset.reset (new dcp::MonoPictureAsset (content->path(0)));
+ } catch (dcp::MXFFileError& e) {
+ /* maybe it's stereo */
+ } catch (dcp::DCPReadError& e) {
+ /* maybe it's stereo */
+ }
+
+ if (!_asset) {
+ _asset.reset (new dcp::StereoPictureAsset (content->path(0)));
+ }
+}
+
+optional<double>
+VideoMXFExaminer::video_frame_rate () const
+{
+ return _asset->frame_rate().as_float ();
+}
+
+dcp::Size
+VideoMXFExaminer::video_size () const
+{
+ return _asset->size ();
+}
+
+Frame
+VideoMXFExaminer::video_length () const
+{
+ return _asset->intrinsic_duration ();
+}
+
+optional<double>
+VideoMXFExaminer::sample_aspect_ratio () const
+{
+ return 1.0;
+}
+
+bool
+VideoMXFExaminer::yuv () const
+{
+ return false;
+}
--- /dev/null
+/*
+ Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "video_examiner.h"
+
+class VideoMXFContent;
+
+namespace dcp {
+ class PictureAsset;
+}
+
+class VideoMXFExaminer : public VideoExaminer
+{
+public:
+ VideoMXFExaminer (boost::shared_ptr<const VideoMXFContent>);
+
+ boost::optional<double> video_frame_rate () const;
+ dcp::Size video_size () const;
+ Frame video_length () const;
+ boost::optional<double> sample_aspect_ratio () const;
+ bool yuv () const;
+
+private:
+ boost::shared_ptr<dcp::PictureAsset> _asset;
+};
video_content_scale.cc
video_decoder.cc
video_filter_graph.cc
+ video_mxf_content.cc
+ video_mxf_decoder.cc
+ video_mxf_examiner.cc
writer.cc
"""
--- /dev/null
+/*
+ Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "lib/film.h"
+#include "lib/video_mxf_content.h"
+#include "lib/content_factory.h"
+#include "lib/dcp_content_type.h"
+#include "lib/ratio.h"
+#include "test.h"
+#include <dcp/mono_picture_asset.h>
+#include <boost/test/unit_test.hpp>
+
+using boost::shared_ptr;
+using boost::dynamic_pointer_cast;
+
+static boost::filesystem::path ref_mxf = "test/data/scaling_test_185_185/j2c_a41afbff-e1ad-41c4-9a84-de315b95dd0f.mxf";
+
+static void note (dcp::NoteType, std::string)
+{
+
+}
+
+/** Basic test of using video MXF content */
+BOOST_AUTO_TEST_CASE (video_mxf_content_test)
+{
+ shared_ptr<Film> film = new_test_film ("video_mxf_content_test");
+ film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR"));
+ film->set_container (Ratio::from_id ("185"));
+ film->set_name ("video_mxf_content_test");
+
+ shared_ptr<Content> content = content_factory (film, ref_mxf);
+ shared_ptr<VideoMXFContent> check = dynamic_pointer_cast<VideoMXFContent> (content);
+ BOOST_REQUIRE (check);
+ film->examine_and_add_content (content);
+ wait_for_jobs ();
+ film->make_dcp ();
+ wait_for_jobs ();
+
+ shared_ptr<dcp::MonoPictureAsset> ref (new dcp::MonoPictureAsset (ref_mxf));
+ boost::filesystem::directory_iterator i ("build/test/video_mxf_content_test/video");
+ shared_ptr<dcp::MonoPictureAsset> comp (new dcp::MonoPictureAsset (*i));
+ dcp::EqualityOptions op;
+ BOOST_CHECK (ref->equals (comp, op, note));
+}
vf_test.cc
video_content_scale_test.cc
video_decoder_fill_test.cc
+ video_mxf_content_test.cc
xml_subtitle_test.cc
"""