Also implement the whole properties thing more neatly.
2015-06-21 Carl Hetherington <cth@carlh.net>
+ * Add some more video properties to the content properties
+ dialogue.
+
* Version 2.1.7 released.
2015-06-21 Carl Hetherington <cth@carlh.net>
/*
- Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2015 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
using std::cout;
using std::vector;
using std::max;
+using std::pair;
using boost::shared_ptr;
int const ContentProperty::PATH = 400;
return s;
}
+
+/** @return a list of properties that might be interesting to the user; first string is the property name,
+ * second is the value.
+ */
+list<pair<string, string> >
+Content::properties () const
+{
+ list<pair<string, string> > p;
+ add_properties (p);
+ return p;
+}
virtual DCPTime full_length () const = 0;
virtual std::string identifier () const;
+ std::list<std::pair<std::string, std::string> > properties () const;
+
boost::shared_ptr<Content> clone () const;
void set_path (boost::filesystem::path);
protected:
void signal_changed (int);
+ virtual void add_properties (std::list<std::pair<std::string, std::string> > &) const {}
boost::weak_ptr<const Film> _film;
/*
- Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2015 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
using std::string;
using std::cout;
using std::distance;
+using std::pair;
+using std::list;
using boost::shared_ptr;
using boost::optional;
return dir;
}
+
+void
+DCPContent::add_properties (list<pair<string, string> >& p) const
+{
+ SingleStreamAudioContent::add_properties (p);
+}
bool can_be_played () const;
+protected:
+ void add_properties (std::list<std::pair<std::string, std::string> >& p) const;
+
private:
void read_directory (boost::filesystem::path);
#include <libcxml/cxml.h>
extern "C" {
#include <libavformat/avformat.h>
+#include <libavutil/pixdesc.h>
}
#include <boost/foreach.hpp>
using std::list;
using std::cout;
using std::pair;
+using std::make_pair;
using boost::shared_ptr;
using boost::dynamic_pointer_cast;
}
_first_video = node->optional_number_child<double> ("FirstVideo");
+
+
+ _color_range = static_cast<AVColorRange> (node->optional_number_child<int>("ColorRange").get_value_or (AVCOL_RANGE_UNSPECIFIED));
+ _color_primaries = static_cast<AVColorPrimaries> (node->optional_number_child<int>("ColorPrimaries").get_value_or (AVCOL_PRI_UNSPECIFIED));
+ _color_trc = static_cast<AVColorTransferCharacteristic> (
+ node->optional_number_child<int>("ColorTransferCharacteristic").get_value_or (AVCOL_TRC_UNSPECIFIED)
+ );
+ _colorspace = static_cast<AVColorSpace> (node->optional_number_child<int>("Colorspace").get_value_or (AVCOL_SPC_UNSPECIFIED));
+
}
FFmpegContent::FFmpegContent (shared_ptr<const Film> film, vector<boost::shared_ptr<Content> > c)
if (_first_video) {
node->add_child("FirstVideo")->add_child_text (raw_convert<string> (_first_video.get().get()));
}
+
+ node->add_child("ColorRange")->add_child_text (raw_convert<string> (_color_range));
+ node->add_child("ColorPrimaries")->add_child_text (raw_convert<string> (_color_primaries));
+ node->add_child("ColorTransferCharacteristic")->add_child_text (raw_convert<string> (_color_trc));
+ node->add_child("Colorspace")->add_child_text (raw_convert<string> (_colorspace));
}
void
}
_first_video = examiner->first_video ();
+
+ _color_range = examiner->color_range ();
+ _color_primaries = examiner->color_primaries ();
+ _color_trc = examiner->color_trc ();
+ _colorspace = examiner->colorspace ();
}
signal_changed (FFmpegContentProperty::SUBTITLE_STREAMS);
copy (_audio_streams.begin(), _audio_streams.end(), back_inserter (s));
return s;
}
+
+void
+FFmpegContent::add_properties (list<pair<string, string> >& p) const
+{
+ VideoContent::add_properties (p);
+
+ /* I tried av_*_name for these but they are not the most
+ nicely formatted.
+ */
+
+ char const * ranges[] = {
+ _("Unspecified"),
+ _("MPEG (0-219 or equivalent)"),
+ _("JPEG (0-255 or equivalent)")
+ };
+
+ DCPOMATIC_ASSERT (AVCOL_RANGE_NB == 3);
+ p.push_back (make_pair (_("Colour range"), ranges[_color_range]));
+
+ char const * primaries[] = {
+ _("Unspecified"),
+ _("BT709"),
+ _("Unspecified"),
+ _("Unspecified"),
+ _("BT470M"),
+ _("BT470BG"),
+ _("SMPTE 170M (BT601)"),
+ _("SMPTE 240M"),
+ _("Film"),
+ _("BT2020")
+ };
+
+ DCPOMATIC_ASSERT (AVCOL_PRI_NB == 10);
+ p.push_back (make_pair (_("Color primaries"), primaries[_color_primaries]));
+
+ char const * transfers[] = {
+ _("Unspecified"),
+ _("BT709"),
+ _("Unspecified"),
+ _("Unspecified"),
+ _("Gamma 22 (BT470M)"),
+ _("Gamma 28 (BT470BG)"),
+ _("SMPTE 170M (BT601)"),
+ _("SMPTE 240M"),
+ _("Linear"),
+ _("Logarithmic (100:1 range)"),
+ _("Logarithmic (316:1 range)"),
+ _("IEC61966-2-4"),
+ _("BT1361 extended colour gamut"),
+ _("IEC61966-2-1 (sRGB or sYCC)"),
+ _("BT2020 for a 10-bit system"),
+ _("BT2020 for a 12-bit system")
+ };
+
+ DCPOMATIC_ASSERT (AVCOL_TRC_NB == 16);
+ p.push_back (make_pair (_("Colour transfer characteristic"), transfers[_color_trc]));
+
+ char const * spaces[] = {
+ _("RGB / sRGB (IEC61966-2-1)"),
+ _("BT709"),
+ _("Unspecified"),
+ _("Unspecified"),
+ _("FCC"),
+ _("BT470BG (BT601-6)"),
+ _("SMPTE 170M (BT601-6)"),
+ _("SMPTE 240M"),
+ _("YCOCG"),
+ _("BT2020 non-constant luminance"),
+ _("BT2020 constant luminance"),
+ };
+
+ DCPOMATIC_ASSERT (AVCOL_SPC_NB == 11);
+ p.push_back (make_pair (_("Colourspace"), spaces[_colorspace]));
+}
std::list<ContentTimePeriod> subtitles_during (ContentTimePeriod, bool starting) const;
+protected:
+ void add_properties (std::list<std::pair<std::string, std::string> > &) const;
+
private:
friend struct ffmpeg_pts_offset_test;
friend struct audio_sampling_rate_test;
boost::optional<ContentTime> _first_video;
/** Video filters that should be used when generating DCPs */
std::vector<Filter const *> _filters;
+
+ AVColorRange _color_range;
+ AVColorPrimaries _color_primaries;
+ AVColorTransferCharacteristic _color_trc;
+ AVColorSpace _colorspace;
};
#endif
return _first_video;
}
+ AVColorRange color_range () const {
+ return video_codec_context()->color_range;
+ }
+
+ AVColorPrimaries color_primaries () const {
+ return video_codec_context()->color_primaries;
+ }
+
+ AVColorTransferCharacteristic color_trc () const {
+ return video_codec_context()->color_trc;
+ }
+
+ AVColorSpace colorspace () const {
+ return video_codec_context()->colorspace;
+ }
+
private:
void video_packet (AVCodecContext *);
void audio_packet (AVCodecContext *, boost::shared_ptr<FFmpegAudioStream>);
#include "film.h"
#include "raw_convert.h"
+#include "i18n.h"
+
using std::string;
using std::cout;
using std::vector;
+using std::list;
+using std::pair;
using boost::shared_ptr;
SingleStreamAudioContent::SingleStreamAudioContent (shared_ptr<const Film> film)
s.push_back (_audio_stream);
return s;
}
+
+void
+SingleStreamAudioContent::add_properties (list<pair<string, string> >& p) const
+{
+ /* XXX: this could be better wrt audio streams */
+ p.push_back (make_pair (_("Audio channels"), raw_convert<string> (audio_stream()->channels ())));
+}
void take_from_audio_examiner (boost::shared_ptr<AudioExaminer>);
protected:
+ void add_properties (std::list<std::pair<std::string, std::string> > &) const;
+
boost::shared_ptr<AudioStream> _audio_stream;
};
using std::stringstream;
using std::fixed;
using std::setprecision;
+using std::list;
+using std::pair;
using boost::shared_ptr;
using boost::optional;
using boost::dynamic_pointer_cast;
return d.str ();
}
+
+void
+VideoContent::add_properties (list<pair<string, string> >& p) const
+{
+ p.push_back (make_pair (_("Video length"), raw_convert<string> (video_length ()) + " " + _("video frames")));
+ p.push_back (make_pair (_("Video size"), raw_convert<string> (video_size().width) + "x" + raw_convert<string> (video_size().height)));
+ p.push_back (make_pair (_("Video frame rate"), raw_convert<string> (video_frame_rate()) + " " + _("frames per second")));
+}
protected:
void take_from_video_examiner (boost::shared_ptr<VideoExaminer>);
+ void add_properties (std::list<std::pair<std::string, std::string> > &) const;
Frame _video_length;
float _video_frame_rate;
#include <boost/algorithm/string.hpp>
using std::string;
+using std::list;
+using std::pair;
using boost::shared_ptr;
using boost::dynamic_pointer_cast;
{
string n = content->path(0).string();
boost::algorithm::replace_all (n, "&", "&&");
- add_property (_("Filename"), std_to_wx (n));
+ add (_("Filename"), true);
+ add (new wxStaticText (this, wxID_ANY, std_to_wx (n)));
- shared_ptr<VideoContent> video = dynamic_pointer_cast<VideoContent> (content);
- if (video) {
- add_property (
- _("Video length"),
- std_to_wx (raw_convert<string> (video->video_length ())) + " " + _("video frames")
- );
- add_property (
- _("Video size"),
- std_to_wx (raw_convert<string> (video->video_size().width) + "x" + raw_convert<string> (video->video_size().height))
- );
- add_property (
- _("Video frame rate"),
- std_to_wx (raw_convert<string> (video->video_frame_rate())) + " " + _("frames per second")
- );
- }
-
- /* XXX: this could be better wrt audio streams */
-
- shared_ptr<SingleStreamAudioContent> single = dynamic_pointer_cast<SingleStreamAudioContent> (content);
- if (single) {
- add_property (
- _("Audio channels"),
- std_to_wx (raw_convert<string> (single->audio_stream()->channels ()))
- );
+ list<pair<string, string> > properties = content->properties ();
+ for (list<pair<string, string> >::const_iterator i = properties.begin(); i != properties.end(); ++i) {
+ add (std_to_wx (i->first), true);
+ add (new wxStaticText (this, wxID_ANY, std_to_wx (i->second)));
}
layout ();
}
-
-void
-ContentPropertiesDialog::add_property (wxString k, wxString v)
-{
- add (k, true);
- add (new wxStaticText (this, wxID_ANY, v));
-}
{
public:
ContentPropertiesDialog (wxWindow* parent, boost::shared_ptr<Content> content);
-
-private:
- void add_property (wxString k, wxString v);
};
-