overall length?
trim method (trim in general)
A/B
+
#include "server.h"
#include "scaler.h"
#include "filter.h"
-#include "format.h"
+#include "container.h"
#include "dcp_content_type.h"
#include "sound_processor.h"
, _tms_path (N_("."))
, _sound_processor (SoundProcessor::from_id (N_("dolby_cp750")))
, _default_still_length (10)
- , _default_format (0)
+ , _default_container (0)
, _default_dcp_content_type (0)
{
_allowed_dcp_frame_rates.push_back (24);
_language = f.optional_string_child ("Language");
- c = f.optional_string_child ("DefaultFormat");
+ c = f.optional_string_child ("DefaultContainer");
if (c) {
- _default_format = Format::from_id (c.get ());
+ _default_container = Container::from_id (c.get ());
}
c = f.optional_string_child ("DefaultDCPContentType");
_sound_processor = SoundProcessor::from_id (v);
} else if (k == "language") {
_language = v;
- } else if (k == "default_format") {
- _default_format = Format::from_id (v);
+ } else if (k == "default_container") {
+ _default_container = Container::from_id (v);
} else if (k == "default_dcp_content_type") {
_default_dcp_content_type = DCPContentType::from_dci_name (v);
} else if (k == "dcp_metadata_issuer") {
if (_language) {
root->add_child("Language")->add_child_text (_language.get());
}
- if (_default_format) {
- root->add_child("DefaultFormat")->add_child_text (_default_format->id ());
+ if (_default_container) {
+ root->add_child("DefaultContainer")->add_child_text (_default_container->id ());
}
if (_default_dcp_content_type) {
root->add_child("DefaultDCPContentType")->add_child_text (_default_dcp_content_type->dci_name ());
class Scaler;
class Filter;
class SoundProcessor;
-class Format;
+class Container;
class DCPContentType;
/** @class Config
return _default_still_length;
}
- Format const * default_format () const {
- return _default_format;
+ Container const * default_container () const {
+ return _default_container;
}
DCPContentType const * default_dcp_content_type () const {
_default_still_length = s;
}
- void set_default_format (Format const * f) {
- _default_format = f;
+ void set_default_container (Container const * f) {
+ _default_container = f;
}
void set_default_dcp_content_type (DCPContentType const * t) {
DCIMetadata _default_dci_metadata;
boost::optional<std::string> _language;
int _default_still_length;
- Format const * _default_format;
+ Container const * _default_container;
DCPContentType const * _default_dcp_content_type;
libdcp::XMLMetadata _dcp_metadata;
--- /dev/null
+/*
+ Copyright (C) 2013 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 <sstream>
+#include <libdcp/types.h>
+#include "container.h"
+
+#include "i18n.h"
+
+using std::string;
+using std::stringstream;
+using std::vector;
+
+vector<Container const *> Container::_containers;
+
+void
+Container::setup_containers ()
+{
+ _containers.push_back (new Container (libdcp::Size (1285, 1080), "119", _("1.19"), "F"));
+ _containers.push_back (new Container (libdcp::Size (1436, 1080), "133", _("4:3"), "F"));
+ _containers.push_back (new Container (libdcp::Size (1480, 1080), "137", _("Academy"), "F"));
+ _containers.push_back (new Container (libdcp::Size (1485, 1080), "138", _("1.375"), "F"));
+ _containers.push_back (new Container (libdcp::Size (1793, 1080), "166", _("1.66"), "F"));
+ _containers.push_back (new Container (libdcp::Size (1920, 1080), "178", _("16:9"), "F"));
+ _containers.push_back (new Container (libdcp::Size (1998, 1080), "185", _("Flat"), "F"));
+ _containers.push_back (new Container (libdcp::Size (2048, 858), "239", _("Scope"), "S"));
+ _containers.push_back (new Container (libdcp::Size (2048, 1080), "full-frame", _("Full frame"), "C"));
+}
+
+/** @return A name to be presented to the user */
+string
+Container::name () const
+{
+ stringstream s;
+ if (!_nickname.empty ()) {
+ s << _nickname << " (";
+ }
+
+ s << _dcp_size.width << "x" << _dcp_size.height;
+
+ if (!_nickname.empty ()) {
+ s << ")";
+ }
+
+ return s.str ();
+}
+
+Container const *
+Container::from_id (string i)
+{
+ vector<Container const *>::iterator j = _containers.begin ();
+ while (j != _containers.end() && (*j)->id() != i) {
+ ++j;
+ }
+
+ if (j == _containers.end ()) {
+ return 0;
+ }
+
+ return *j;
+}
+
+float
+Container::ratio () const
+{
+ return static_cast<float> (_dcp_size.width) / _dcp_size.height;
+}
--- /dev/null
+/*
+ Copyright (C) 2013 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 <vector>
+#include <libdcp/util.h>
+
+class Container
+{
+public:
+ Container (libdcp::Size dcp, std::string id, std::string n, std::string d)
+ : _dcp_size (dcp)
+ , _id (id)
+ , _nickname (n)
+ , _dci_name (d)
+ {}
+
+ /** @return size in pixels of the images that we should
+ * put in a DCP for this ratio. This size will not correspond
+ * to the ratio when we are doing things like 16:9 in a Flat frame.
+ */
+ libdcp::Size dcp_size () const {
+ return _dcp_size;
+ }
+
+ std::string id () const {
+ return _id;
+ }
+
+ /** @return Full name to present to the user */
+ std::string name () const;
+
+ /** @return Nickname (e.g. Flat, Scope) */
+ std::string nickname () const {
+ return _nickname;
+ }
+
+ std::string dci_name () const {
+ return _dci_name;
+ }
+
+ float ratio () const;
+
+ static void setup_containers ();
+ static Container const * from_id (std::string i);
+ static std::vector<Container const *> all () {
+ return _containers;
+ }
+
+private:
+ /** libdcp::Size in pixels of the images that we should
+ * put in a DCP for this container.
+ */
+ libdcp::Size _dcp_size;
+ /** id for use in metadata */
+ std::string _id;
+ /** nickname (e.g. Flat, Scope) */
+ std::string _nickname;
+ std::string _dci_name;
+
+ /** all available containers */
+ static std::vector<Container const *> _containers;
+};
#include "writer.h"
#include "player.h"
#include "audio_mapping.h"
+#include "container.h"
#include "i18n.h"
/* Queue this new frame for encoding */
pair<string, string> const s = Filter::ffmpeg_strings (_film->filters());
TIMING ("adding to queue of %1", _queue.size ());
+ /* XXX: padding */
_queue.push_back (shared_ptr<DCPVideoFrame> (
new DCPVideoFrame (
- image, sub, _film->format()->dcp_size(), _film->format()->dcp_padding (_film),
+ image, sub, _film->container()->dcp_size(), 0,
_film->subtitle_offset(), _film->subtitle_scale(),
_film->scaler(), _video_frames_out, _film->dcp_video_frame_rate(), s.second,
_film->colour_lut(), _film->j2k_bandwidth(),
FFmpegDecoder::FFmpegDecoder (shared_ptr<const Film> f, shared_ptr<const FFmpegContent> c, bool video, bool audio, bool subtitles)
: Decoder (f)
- , VideoDecoder (f)
+ , VideoDecoder (f, c)
, AudioDecoder (f, c)
, _ffmpeg_content (c)
, _format_context (0)
FFmpegDecoder::film_changed (Film::Property p)
{
switch (p) {
- case Film::CROP:
case Film::FILTERS:
{
boost::mutex::scoped_lock lm (_filter_graphs_mutex);
bool seek_back ();
bool pass ();
+ boost::shared_ptr<const FFmpegContent> ffmpeg_content () const {
+ return _ffmpeg_content;
+ }
+
private:
/* No copy construction */
#include <libxml++/libxml++.h>
#include <libcxml/cxml.h>
#include "film.h"
-#include "format.h"
+#include "container.h"
#include "job.h"
#include "filter.h"
#include "util.h"
: _playlist (new Playlist)
, _use_dci_name (true)
, _dcp_content_type (Config::instance()->default_dcp_content_type ())
- , _format (Config::instance()->default_format ())
+ , _container (Config::instance()->default_container ())
, _scaler (Scaler::from_id ("bicubic"))
, _ab (false)
, _audio_gain (0)
, _name (o._name)
, _use_dci_name (o._use_dci_name)
, _dcp_content_type (o._dcp_content_type)
- , _format (o._format)
- , _crop (o._crop)
+ , _container (o._container)
, _filters (o._filters)
, _scaler (o._scaler)
, _ab (o._ab)
string
Film::video_state_identifier () const
{
- assert (format ());
+ assert (container ());
LocaleGuard lg;
pair<string, string> f = Filter::ffmpeg_strings (filters());
stringstream s;
- s << format()->id()
+ s << container()->id()
<< "_" << _playlist->video_digest()
- << "_" << crop().left << "_" << crop().right << "_" << crop().top << "_" << crop().bottom
<< "_" << _dcp_video_frame_rate
<< "_" << f.first << "_" << f.second
<< "_" << scaler()->id()
pair<string, int> const c = cpu_info ();
log()->log (String::compose ("CPU: %1, %2 processors", c.first, c.second));
- if (format() == 0) {
- throw MissingSettingError (_("format"));
+ if (container() == 0) {
+ throw MissingSettingError (_("container"));
}
if (_playlist->content().empty ()) {
int
Film::encoded_frames () const
{
- if (format() == 0) {
+ if (container() == 0) {
return 0;
}
root->add_child("DCPContentType")->add_child_text (_dcp_content_type->dci_name ());
}
- if (_format) {
- root->add_child("Format")->add_child_text (_format->id ());
+ if (_container) {
+ root->add_child("Container")->add_child_text (_container->id ());
}
- root->add_child("LeftCrop")->add_child_text (boost::lexical_cast<string> (_crop.left));
- root->add_child("RightCrop")->add_child_text (boost::lexical_cast<string> (_crop.right));
- root->add_child("TopCrop")->add_child_text (boost::lexical_cast<string> (_crop.top));
- root->add_child("BottomCrop")->add_child_text (boost::lexical_cast<string> (_crop.bottom));
-
for (vector<Filter const *>::const_iterator i = _filters.begin(); i != _filters.end(); ++i) {
root->add_child("Filter")->add_child_text ((*i)->id ());
}
}
{
- optional<string> c = f.optional_string_child ("Format");
+ optional<string> c = f.optional_string_child ("Container");
if (c) {
- _format = Format::from_id (c.get ());
+ _container = Container::from_id (c.get ());
}
}
- _crop.left = f.number_child<int> ("LeftCrop");
- _crop.right = f.number_child<int> ("RightCrop");
- _crop.top = f.number_child<int> ("TopCrop");
- _crop.bottom = f.number_child<int> ("BottomCrop");
-
{
list<shared_ptr<cxml::Node> > c = f.node_children ("Filter");
for (list<shared_ptr<cxml::Node> >::iterator i = c.begin(); i != c.end(); ++i) {
_dirty = false;
}
-libdcp::Size
-Film::cropped_size (libdcp::Size s) const
-{
- boost::mutex::scoped_lock lm (_state_mutex);
- s.width -= _crop.left + _crop.right;
- s.height -= _crop.top + _crop.bottom;
- return s;
-}
-
/** Given a directory name, return its full path within the Film's directory.
* The directory (and its parents) will be created if they do not exist.
*/
d << "_" << dcp_content_type()->dci_name();
}
- if (format()) {
- d << "_" << format()->dci_name();
+ if (container()) {
+ d << "_" << container()->dci_name();
}
DCIMetadata const dm = dci_metadata ();
}
void
-Film::set_format (Format const * f)
+Film::set_container (Container const * c)
{
{
boost::mutex::scoped_lock lm (_state_mutex);
- _format = f;
- }
- signal_changed (FORMAT);
-}
-
-void
-Film::set_crop (Crop c)
-{
- {
- boost::mutex::scoped_lock lm (_state_mutex);
- _crop = c;
- }
- signal_changed (CROP);
-}
-
-void
-Film::set_left_crop (int c)
-{
- {
- boost::mutex::scoped_lock lm (_state_mutex);
-
- if (_crop.left == c) {
- return;
- }
-
- _crop.left = c;
- }
- signal_changed (CROP);
-}
-
-void
-Film::set_right_crop (int c)
-{
- {
- boost::mutex::scoped_lock lm (_state_mutex);
- if (_crop.right == c) {
- return;
- }
-
- _crop.right = c;
- }
- signal_changed (CROP);
-}
-
-void
-Film::set_top_crop (int c)
-{
- {
- boost::mutex::scoped_lock lm (_state_mutex);
- if (_crop.top == c) {
- return;
- }
-
- _crop.top = c;
- }
- signal_changed (CROP);
-}
-
-void
-Film::set_bottom_crop (int c)
-{
- {
- boost::mutex::scoped_lock lm (_state_mutex);
- if (_crop.bottom == c) {
- return;
- }
-
- _crop.bottom = c;
+ _container = c;
}
- signal_changed (CROP);
+ signal_changed (CONTAINER);
}
void
#include "playlist.h"
class DCPContentType;
-class Format;
+class Container;
class Job;
class Filter;
class Log;
void write_metadata () const;
- libdcp::Size cropped_size (libdcp::Size) const;
std::string dci_name (bool if_created_now) const;
std::string dcp_name (bool if_created_now = false) const;
CONTENT,
LOOP,
DCP_CONTENT_TYPE,
- FORMAT,
- CROP,
+ CONTAINER,
FILTERS,
SCALER,
AB,
return _dcp_content_type;
}
- Format const * format () const {
+ Container const * container () const {
boost::mutex::scoped_lock lm (_state_mutex);
- return _format;
- }
-
- Crop crop () const {
- boost::mutex::scoped_lock lm (_state_mutex);
- return _crop;
+ return _container;
}
std::vector<Filter const *> filters () const {
void add_content (boost::shared_ptr<Content>);
void remove_content (boost::shared_ptr<Content>);
void set_dcp_content_type (DCPContentType const *);
- void set_format (Format const *);
- void set_crop (Crop);
- void set_left_crop (int);
- void set_right_crop (int);
- void set_top_crop (int);
- void set_bottom_crop (int);
+ void set_container (Container const *);
void set_filters (std::vector<Filter const *>);
void set_scaler (Scaler const *);
void set_ab (bool);
bool _use_dci_name;
/** The type of content that this Film represents (feature, trailer etc.) */
DCPContentType const * _dcp_content_type;
- /** The format to present this Film in (flat, scope, etc.) */
- Format const * _format;
- /** The crop to apply to the source */
- Crop _crop;
+ /** The container to put this Film in (flat, scope, etc.) */
+ Container const * _container;
/** Video filters that should be used when generating DCPs */
std::vector<Filter const *> _filters;
/** Scaler algorithm to use */
filters += N_(",");
}
- filters += crop_string (Position (film->crop().left, film->crop().top), film->cropped_size (decoder->native_size()));
+ Crop crop = decoder->ffmpeg_content()->crop ();
+ libdcp::Size cropped_size = decoder->native_size ();
+ cropped_size.width -= crop.left + crop.right;
+ cropped_size.height -= crop.top + crop.bottom;
+ filters += crop_string (Position (crop.left, crop.top), cropped_size);
AVFilterGraph* graph = avfilter_graph_alloc();
if (graph == 0) {
ImageMagickDecoder::ImageMagickDecoder (shared_ptr<const Film> f, shared_ptr<const ImageMagickContent> c)
: Decoder (f)
- , VideoDecoder (f)
+ , VideoDecoder (f, c)
, _imagemagick_content (c)
, _position (0)
{
delete magick_image;
- _image = _image->crop (_film->crop(), true);
+ _image = _image->crop (_imagemagick_content->crop(), true);
emit_video (_image, false, double (_position) / 24);
++_position;
#include "filter.h"
#include "sound_processor.h"
#include "config.h"
+#include "container.h"
#ifdef DVDOMATIC_WINDOWS
#include "stack.hpp"
#endif
avfilter_register_all ();
Format::setup_formats ();
+ Container::setup_containers ();
DCPContentType::setup_dcp_content_types ();
Scaler::setup_scalers ();
Filter::setup_filters ();
int const VideoContentProperty::VIDEO_LENGTH = 0;
int const VideoContentProperty::VIDEO_SIZE = 1;
int const VideoContentProperty::VIDEO_FRAME_RATE = 2;
+int const VideoContentProperty::VIDEO_CROP = 3;
using std::string;
using std::stringstream;
_video_size.width = node->number_child<int> ("VideoWidth");
_video_size.height = node->number_child<int> ("VideoHeight");
_video_frame_rate = node->number_child<float> ("VideoFrameRate");
+ _crop.left = node->number_child<int> ("LeftCrop");
+ _crop.right = node->number_child<int> ("RightCrop");
+ _crop.top = node->number_child<int> ("TopCrop");
+ _crop.bottom = node->number_child<int> ("BottomCrop");
}
VideoContent::VideoContent (VideoContent const & o)
node->add_child("VideoWidth")->add_child_text (lexical_cast<string> (_video_size.width));
node->add_child("VideoHeight")->add_child_text (lexical_cast<string> (_video_size.height));
node->add_child("VideoFrameRate")->add_child_text (lexical_cast<string> (_video_frame_rate));
+ node->add_child("LeftCrop")->add_child_text (boost::lexical_cast<string> (_crop.left));
+ node->add_child("RightCrop")->add_child_text (boost::lexical_cast<string> (_crop.right));
+ node->add_child("TopCrop")->add_child_text (boost::lexical_cast<string> (_crop.top));
+ node->add_child("BottomCrop")->add_child_text (boost::lexical_cast<string> (_crop.bottom));
}
void
return s.str ();
}
+
+void
+VideoContent::set_crop (Crop c)
+{
+ {
+ boost::mutex::scoped_lock lm (_mutex);
+ _crop = c;
+ }
+ signal_changed (VideoContentProperty::VIDEO_CROP);
+}
+
+void
+VideoContent::set_left_crop (int c)
+{
+ {
+ boost::mutex::scoped_lock lm (_mutex);
+
+ if (_crop.left == c) {
+ return;
+ }
+
+ _crop.left = c;
+ }
+
+ signal_changed (VideoContentProperty::VIDEO_CROP);
+}
+
+void
+VideoContent::set_right_crop (int c)
+{
+ {
+ boost::mutex::scoped_lock lm (_mutex);
+ if (_crop.right == c) {
+ return;
+ }
+
+ _crop.right = c;
+ }
+
+ signal_changed (VideoContentProperty::VIDEO_CROP);
+}
+
+void
+VideoContent::set_top_crop (int c)
+{
+ {
+ boost::mutex::scoped_lock lm (_mutex);
+ if (_crop.top == c) {
+ return;
+ }
+
+ _crop.top = c;
+ }
+
+ signal_changed (VideoContentProperty::VIDEO_CROP);
+}
+
+void
+VideoContent::set_bottom_crop (int c)
+{
+ {
+ boost::mutex::scoped_lock lm (_mutex);
+ if (_crop.bottom == c) {
+ return;
+ }
+
+ _crop.bottom = c;
+ }
+
+ signal_changed (VideoContentProperty::VIDEO_CROP);
+}
+
static int const VIDEO_LENGTH;
static int const VIDEO_SIZE;
static int const VIDEO_FRAME_RATE;
+ static int const VIDEO_CROP;
};
class VideoContent : public virtual Content
return _video_frame_rate;
}
+ void set_crop (Crop);
+ void set_left_crop (int);
+ void set_right_crop (int);
+ void set_top_crop (int);
+ void set_bottom_crop (int);
+
+ Crop crop () const {
+ boost::mutex::scoped_lock lm (_mutex);
+ return _crop;
+ }
+
protected:
void take_from_video_decoder (boost::shared_ptr<VideoDecoder>);
private:
libdcp::Size _video_size;
float _video_frame_rate;
+ Crop _crop;
};
#endif
using boost::shared_ptr;
using boost::optional;
-VideoDecoder::VideoDecoder (shared_ptr<const Film> f)
+VideoDecoder::VideoDecoder (shared_ptr<const Film> f, shared_ptr<const VideoContent> c)
: Decoder (f)
+ , _video_content (c)
, _video_frame (0)
, _last_content_time (0)
{
if (_timed_subtitle) {
Position const p = _timed_subtitle->subtitle()->position ();
- _timed_subtitle->subtitle()->set_position (Position (p.x - _film->crop().left, p.y - _film->crop().top));
+ _timed_subtitle->subtitle()->set_position (Position (p.x - _video_content->crop().left, p.y - _video_content->crop().top));
}
}
class VideoDecoder : public VideoSource, public virtual Decoder
{
public:
- VideoDecoder (boost::shared_ptr<const Film>);
+ VideoDecoder (boost::shared_ptr<const Film>, boost::shared_ptr<const VideoContent>);
/** @return video frame rate second, or 0 if unknown */
virtual float video_frame_rate () const = 0;
void emit_subtitle (boost::shared_ptr<TimedSubtitle>);
private:
+ boost::shared_ptr<const VideoContent> _video_content;
int _video_frame;
double _last_content_time;
-
boost::shared_ptr<TimedSubtitle> _timed_subtitle;
};
#include "writer.h"
#include "compose.hpp"
#include "film.h"
-#include "format.h"
+#include "container.h"
#include "log.h"
#include "dcp_video_frame.h"
#include "dcp_content_type.h"
_film->internal_video_mxf_dir (),
_film->internal_video_mxf_filename (),
_film->dcp_video_frame_rate (),
- _film->format()->dcp_size ()
+ _film->container()->dcp_size ()
)
);
audio_source.cc
config.cc
combiner.cc
+ container.cc
content.cc
cross.cc
dci_metadata.cc
#include <wx/notebook.h>
#include "lib/config.h"
#include "lib/server.h"
-#include "lib/format.h"
+#include "lib/container.h"
#include "lib/scaler.h"
#include "lib/filter.h"
#include "lib/dcp_content_type.h"
table->Add (_default_dci_metadata_button);
table->AddSpacer (1);
- add_label_to_sizer (table, _misc_panel, _("Default format"));
- _default_format = new wxChoice (_misc_panel, wxID_ANY);
- table->Add (_default_format);
+ add_label_to_sizer (table, _misc_panel, _("Default container"));
+ _default_container = new wxChoice (_misc_panel, wxID_ANY);
+ table->Add (_default_container);
table->AddSpacer (1);
add_label_to_sizer (table, _misc_panel, _("Default content type"));
_default_dci_metadata_button->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (ConfigDialog::edit_default_dci_metadata_clicked), 0, this);
- vector<Format const *> fmt = Format::all ();
+ vector<Container const *> fmt = Container::all ();
int n = 0;
- for (vector<Format const *>::iterator i = fmt.begin(); i != fmt.end(); ++i) {
- _default_format->Append (std_to_wx ((*i)->name ()));
- if (*i == config->default_format ()) {
- _default_format->SetSelection (n);
+ for (vector<Container const *>::iterator i = fmt.begin(); i != fmt.end(); ++i) {
+ _default_container->Append (std_to_wx ((*i)->name ()));
+ if (*i == config->default_container ()) {
+ _default_container->SetSelection (n);
}
++n;
}
- _default_format->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (ConfigDialog::default_format_changed), 0, this);
+ _default_container->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (ConfigDialog::default_container_changed), 0, this);
vector<DCPContentType const *> const ct = DCPContentType::all ();
n = 0;
}
void
-ConfigDialog::default_format_changed (wxCommandEvent &)
+ConfigDialog::default_container_changed (wxCommandEvent &)
{
- vector<Format const *> fmt = Format::all ();
- Config::instance()->set_default_format (fmt[_default_format->GetSelection()]);
+ vector<Container const *> fmt = Container::all ();
+ Config::instance()->set_default_container (fmt[_default_container->GetSelection()]);
}
void
void edit_server_clicked (wxCommandEvent &);
void remove_server_clicked (wxCommandEvent &);
void server_selection_changed (wxListEvent &);
- void default_format_changed (wxCommandEvent &);
+ void default_container_changed (wxCommandEvent &);
void default_dcp_content_type_changed (wxCommandEvent &);
void issuer_changed (wxCommandEvent &);
void creator_changed (wxCommandEvent &);
wxPanel* _metadata_panel;
wxCheckBox* _set_language;
wxChoice* _language;
- wxChoice* _default_format;
+ wxChoice* _default_container;
wxChoice* _default_dcp_content_type;
wxTextCtrl* _tms_ip;
wxTextCtrl* _tms_path;
#include "imagemagick_content_dialog.h"
#include "timeline_dialog.h"
#include "audio_mapping_view.h"
+#include "container.h"
using std::string;
using std::cout;
grid->Add (_edit_dci_button, wxGBPosition (r, 1), wxDefaultSpan);
++r;
+ add_label_to_grid_bag_sizer (grid, _dcp_panel, _("Container"), wxGBPosition (r, 0));
+ _container = new wxChoice (_dcp_panel, wxID_ANY);
+ grid->Add (_container, wxGBPosition (r, 1));
+ ++r;
+
add_label_to_grid_bag_sizer (grid, _dcp_panel, _("Content Type"), wxGBPosition (r, 0));
_dcp_content_type = new wxChoice (_dcp_panel, wxID_ANY);
grid->Add (_dcp_content_type, wxGBPosition (r, 1));
_dcp_frame_rate = new wxChoice (_dcp_panel, wxID_ANY);
s->Add (_dcp_frame_rate, 1, wxALIGN_CENTER_VERTICAL);
_best_dcp_frame_rate = new wxButton (_dcp_panel, wxID_ANY, _("Use best"));
- s->Add (_best_dcp_frame_rate, 1, wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 6);
+ s->Add (_best_dcp_frame_rate, 1, wxALIGN_CENTER_VERTICAL | wxEXPAND);
grid->Add (s, wxGBPosition (r, 1));
}
++r;
+ vector<Container const *> const co = Container::all ();
+ for (vector<Container const *>::const_iterator i = co.begin(); i != co.end(); ++i) {
+ _container->Append (std_to_wx ((*i)->name ()));
+ }
+
vector<DCPContentType const *> const ct = DCPContentType::all ();
for (vector<DCPContentType const *>::const_iterator i = ct.begin(); i != ct.end(); ++i) {
_dcp_content_type->Append (std_to_wx ((*i)->pretty_name ()));
_name->Connect (wxID_ANY, wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler (FilmEditor::name_changed), 0, this);
_use_dci_name->Connect (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler (FilmEditor::use_dci_name_toggled), 0, this);
_edit_dci_button->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::edit_dci_button_clicked), 0, this);
- _format->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (FilmEditor::format_changed), 0, this);
+ _container->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (FilmEditor::container_changed), 0, this);
+// _format->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (FilmEditor::format_changed), 0, this);
_content->Connect (wxID_ANY, wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler (FilmEditor::content_selection_changed), 0, this);
_content->Connect (wxID_ANY, wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxListEventHandler (FilmEditor::content_selection_changed), 0, this);
_content_add->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::content_add_clicked), 0, this);
void
FilmEditor::left_crop_changed (wxCommandEvent &)
{
- if (!_film) {
+ shared_ptr<VideoContent> c = selected_video_content ();
+ if (!c) {
return;
}
- _film->set_left_crop (_left_crop->GetValue ());
+ c->set_left_crop (_left_crop->GetValue ());
}
/** Called when the right crop widget has been changed */
void
FilmEditor::right_crop_changed (wxCommandEvent &)
{
- if (!_film) {
+ shared_ptr<VideoContent> c = selected_video_content ();
+ if (!c) {
return;
}
- _film->set_right_crop (_right_crop->GetValue ());
+ c->set_right_crop (_right_crop->GetValue ());
}
/** Called when the top crop widget has been changed */
void
FilmEditor::top_crop_changed (wxCommandEvent &)
{
- if (!_film) {
+ shared_ptr<VideoContent> c = selected_video_content ();
+ if (!c) {
return;
}
- _film->set_top_crop (_top_crop->GetValue ());
+ c->set_top_crop (_top_crop->GetValue ());
}
/** Called when the bottom crop value has been changed */
void
FilmEditor::bottom_crop_changed (wxCommandEvent &)
{
- if (!_film) {
+ shared_ptr<VideoContent> c = selected_video_content ();
+ if (!c) {
return;
}
- _film->set_bottom_crop (_bottom_crop->GetValue ());
+ c->set_bottom_crop (_bottom_crop->GetValue ());
}
/** Called when the name widget has been changed */
case Film::CONTENT:
setup_content ();
setup_formats ();
- setup_format ();
+// setup_format ();
setup_subtitle_control_sensitivity ();
setup_show_audio_sensitivity ();
break;
checked_set (_loop_count, _film->loop());
setup_loop_sensitivity ();
break;
- case Film::FORMAT:
- setup_format ();
- break;
- case Film::CROP:
- checked_set (_left_crop, _film->crop().left);
- checked_set (_right_crop, _film->crop().right);
- checked_set (_top_crop, _film->crop().top);
- checked_set (_bottom_crop, _film->crop().bottom);
- setup_scaling_description ();
+ case Film::CONTAINER:
+ setup_container ();
break;
case Film::FILTERS:
{
}
void
-FilmEditor::film_content_changed (weak_ptr<Content> content, int property)
+FilmEditor::film_content_changed (weak_ptr<Content> weak_content, int property)
{
if (!_film) {
/* We call this method ourselves (as well as using it as a signal handler)
*/
return;
}
-
- if (property == FFmpegContentProperty::SUBTITLE_STREAMS) {
+
+ shared_ptr<Content> content = weak_content.lock ();
+ shared_ptr<VideoContent> video_content;
+ if (content) {
+ video_content = dynamic_pointer_cast<VideoContent> (content);
+ }
+
+ if (property == VideoContentProperty::VIDEO_CROP) {
+ checked_set (_left_crop, video_content ? video_content->crop().left : 0);
+ checked_set (_right_crop, video_content ? video_content->crop().right : 0);
+ checked_set (_top_crop, video_content ? video_content->crop().top : 0);
+ checked_set (_bottom_crop, video_content ? video_content->crop().bottom : 0);
+ setup_scaling_description ();
+ } else if (property == FFmpegContentProperty::SUBTITLE_STREAMS) {
setup_subtitle_control_sensitivity ();
} else if (property == FFmpegContentProperty::AUDIO_STREAMS) {
setup_show_audio_sensitivity ();
}
void
-FilmEditor::setup_format ()
+FilmEditor::setup_container ()
{
int n = 0;
- vector<Format const *>::iterator i = _formats.begin ();
- while (i != _formats.end() && *i != _film->format ()) {
+ vector<Container const *> containers = Container::all ();
+ vector<Container const *>::iterator i = containers.begin ();
+ while (i != containers.end() && *i != _film->container ()) {
++i;
++n;
}
- if (i == _formats.end()) {
- checked_set (_format, -1);
+ if (i == containers.end()) {
+ checked_set (_container, -1);
} else {
- checked_set (_format, n);
+ checked_set (_container, n);
}
setup_dcp_name ();
setup_scaling_description ();
}
-/** Called when the format widget has been changed */
+/** Called when the container widget has been changed */
void
-FilmEditor::format_changed (wxCommandEvent &)
+FilmEditor::container_changed (wxCommandEvent &)
{
if (!_film) {
return;
}
- int const n = _format->GetSelection ();
+ int const n = _container->GetSelection ();
if (n >= 0) {
- assert (n < int (_formats.size()));
- _film->set_format (_formats[n]);
+ vector<Container const *> containers = Container::all ();
+ assert (n < int (containers.size()));
+ _film->set_container (containers[n]);
}
}
film_changed (Film::CONTENT);
film_changed (Film::LOOP);
film_changed (Film::DCP_CONTENT_TYPE);
- film_changed (Film::FORMAT);
- film_changed (Film::CROP);
+ film_changed (Film::CONTAINER);
film_changed (Film::FILTERS);
film_changed (Film::SCALER);
film_changed (Film::AUDIO_GAIN);
film_changed (Film::DCI_METADATA);
film_changed (Film::DCP_VIDEO_FRAME_RATE);
+ film_content_changed (boost::shared_ptr<Content> (), VideoContentProperty::VIDEO_CROP);
film_content_changed (boost::shared_ptr<Content> (), FFmpegContentProperty::SUBTITLE_STREAMS);
film_content_changed (boost::shared_ptr<Content> (), FFmpegContentProperty::SUBTITLE_STREAM);
film_content_changed (boost::shared_ptr<Content> (), FFmpegContentProperty::AUDIO_STREAMS);
return c[s];
}
+shared_ptr<VideoContent>
+FilmEditor::selected_video_content ()
+{
+ shared_ptr<Content> c = selected_content ();
+ if (!c) {
+ return shared_ptr<VideoContent> ();
+ }
+
+ return dynamic_pointer_cast<VideoContent> (c);
+}
+
void
FilmEditor::setup_scaling_description ()
{
class AudioDialog;
class TimelineDialog;
class AudioMappingView;
+class Format;
/** @class FilmEditor
* @brief A wx widget to edit a film's metadata, and perform various functions.
void content_add_clicked (wxCommandEvent &);
void content_remove_clicked (wxCommandEvent &);
void imagemagick_video_length_changed (wxCommandEvent &);
- void format_changed (wxCommandEvent &);
+ void container_changed (wxCommandEvent &);
void dcp_content_type_changed (wxCommandEvent &);
void scaler_changed (wxCommandEvent &);
void audio_gain_changed (wxCommandEvent &);
void setup_scaling_description ();
void setup_main_notebook_size ();
void setup_content ();
- void setup_format ();
+ void setup_container ();
void setup_content_button_sensitivity ();
void setup_loop_sensitivity ();
void setup_content_properties ();
void active_jobs_changed (bool);
boost::shared_ptr<Content> selected_content ();
+ boost::shared_ptr<VideoContent> selected_video_content ();
wxNotebook* _main_notebook;
wxNotebook* _content_notebook;
wxTextCtrl* _name;
wxStaticText* _dcp_name;
wxCheckBox* _use_dci_name;
+ wxChoice* _container;
wxListCtrl* _content;
wxButton* _content_add;
wxButton* _content_remove;
#include <iomanip>
#include <wx/tglbtn.h>
#include "lib/film.h"
+#include "lib/container.h"
#include "lib/format.h"
#include "lib/util.h"
#include "lib/job_manager.h"
FilmViewer::film_changed (Film::Property p)
{
switch (p) {
- case Film::FORMAT:
+ case Film::CONTAINER:
calculate_sizes ();
update_from_raw ();
break;
break;
case Film::SCALER:
case Film::FILTERS:
- case Film::CROP:
update_from_decoder ();
break;
default:
_film->ContentChanged.connect (boost::bind (&FilmViewer::film_content_changed, this, _1, _2));
film_changed (Film::CONTENT);
- film_changed (Film::FORMAT);
+ film_changed (Film::CONTAINER);
film_changed (Film::WITH_SUBTITLES);
film_changed (Film::SUBTITLE_OFFSET);
film_changed (Film::SUBTITLE_SCALE);
when working out the scale that we are applying.
*/
- Size const cropped_size = _film->cropped_size (_raw_frame->size ());
+ /* XXX */
+ Size const cropped_size = _raw_frame->size ();//_film->cropped_size (_raw_frame->size ());
Rect tx = subtitle_transformed_area (
float (_film_size.width) / cropped_size.width,
return;
}
- Format const * format = _film->format ();
+ Container const * container = _film->container ();
float const panel_ratio = static_cast<float> (_panel_size.width) / _panel_size.height;
- float const film_ratio = format ? format->container_ratio () : 1.78;
+ float const film_ratio = container ? container->ratio () : 1.78;
if (panel_ratio < film_ratio) {
/* panel is less widscreen than the film; clamp width */
of our _display_frame.
*/
_display_frame_x = 0;
- if (format) {
- _display_frame_x = static_cast<float> (format->dcp_padding (_film)) * _out_size.width / format->dcp_size().width;
- }
+// if (format) {
+// _display_frame_x = static_cast<float> (format->dcp_padding (_film)) * _out_size.width / format->dcp_size().width;
+// }
_film_size = _out_size;
_film_size.width -= _display_frame_x * 2;
/* Force an update to our frame */
wxScrollEvent ev;
slider_moved (ev);
- }
+ } else if (p == VideoContentProperty::VIDEO_CROP) {
+ update_from_decoder ();
+ }
}
void
#include "ffmpeg_decoder.h"
#include "sndfile_decoder.h"
#include "dcp_content_type.h"
+#include "container.h"
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE dcpomatic_test
#include <boost/test/unit_test.hpp>
shared_ptr<Film> f (new Film (test_film, false));
f->_dci_date = boost::gregorian::from_undelimited_string ("20130211");
- BOOST_CHECK (f->format() == 0);
+ BOOST_CHECK (f->container() == 0);
BOOST_CHECK (f->dcp_content_type() == 0);
BOOST_CHECK (f->filters ().empty());
f->set_name ("fred");
// BOOST_CHECK_THROW (f->set_content ("jim"), OpenFileError);
f->set_dcp_content_type (DCPContentType::from_pretty_name ("Short"));
- f->set_format (Format::from_nickname ("Flat"));
- f->set_left_crop (1);
- f->set_right_crop (2);
- f->set_top_crop (3);
- f->set_bottom_crop (4);
+ f->set_container (Container::from_id ("185"));
vector<Filter const *> f_filters;
f_filters.push_back (Filter::from_id ("pphb"));
f_filters.push_back (Filter::from_id ("unsharp"));
BOOST_CHECK_EQUAL (g->name(), "fred");
BOOST_CHECK_EQUAL (g->dcp_content_type(), DCPContentType::from_pretty_name ("Short"));
- BOOST_CHECK_EQUAL (g->format(), Format::from_nickname ("Flat"));
- BOOST_CHECK_EQUAL (g->crop().left, 1);
- BOOST_CHECK_EQUAL (g->crop().right, 2);
- BOOST_CHECK_EQUAL (g->crop().top, 3);
- BOOST_CHECK_EQUAL (g->crop().bottom, 4);
+ BOOST_CHECK_EQUAL (g->container(), Container::from_id ("185"));
vector<Filter const *> g_filters = g->filters ();
BOOST_CHECK_EQUAL (g_filters.size(), 2);
BOOST_CHECK_EQUAL (g_filters.front(), Filter::from_id ("pphb"));
shared_ptr<Film> film = new_test_film ("make_dcp_test");
film->set_name ("test_film2");
// film->set_content ("../../../test/test.mp4");
- film->set_format (Format::from_nickname ("Flat"));
+ film->set_container (Container::from_id ("185"));
film->set_dcp_content_type (DCPContentType::from_pretty_name ("Test"));
film->make_dcp ();
film->write_metadata ();
film->set_name ("test_film3");
// film->set_content ("../../../test/test.mp4");
// film->examine_content ();
- film->set_format (Format::from_nickname ("Flat"));
+ film->set_container (Container::from_id ("185"));
film->set_dcp_content_type (DCPContentType::from_pretty_name ("Test"));
film->make_dcp ();