From fe771b1f0ed9f794bc98faa4cca2a15651f28e87 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 21 Jun 2015 19:12:44 +0100 Subject: [PATCH] Add more video properties to content properties dialog. Also implement the whole properties thing more neatly. --- ChangeLog | 3 + src/lib/content.cc | 14 +++- src/lib/content.h | 3 + src/lib/dcp_content.cc | 10 ++- src/lib/dcp_content.h | 3 + src/lib/ffmpeg_content.cc | 95 ++++++++++++++++++++++++++ src/lib/ffmpeg_content.h | 8 +++ src/lib/ffmpeg_examiner.h | 16 +++++ src/lib/single_stream_audio_content.cc | 11 +++ src/lib/single_stream_audio_content.h | 2 + src/lib/video_content.cc | 10 +++ src/lib/video_content.h | 1 + src/wx/content_properties_dialog.cc | 40 +++-------- src/wx/content_properties_dialog.h | 4 -- 14 files changed, 182 insertions(+), 38 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4203e9f7e..85c61c928 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2015-06-21 Carl Hetherington + * Add some more video properties to the content properties + dialogue. + * Version 2.1.7 released. 2015-06-21 Carl Hetherington diff --git a/src/lib/content.cc b/src/lib/content.cc index aa382d68b..2b4f02b90 100644 --- a/src/lib/content.cc +++ b/src/lib/content.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2014 Carl Hetherington + Copyright (C) 2013-2015 Carl Hetherington 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 @@ -40,6 +40,7 @@ using std::list; using std::cout; using std::vector; using std::max; +using std::pair; using boost::shared_ptr; int const ContentProperty::PATH = 400; @@ -273,3 +274,14 @@ Content::path_summary () const 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 > +Content::properties () const +{ + list > p; + add_properties (p); + return p; +} diff --git a/src/lib/content.h b/src/lib/content.h index 6ee9e59dd..2deee9763 100644 --- a/src/lib/content.h +++ b/src/lib/content.h @@ -84,6 +84,8 @@ public: virtual DCPTime full_length () const = 0; virtual std::string identifier () const; + std::list > properties () const; + boost::shared_ptr clone () const; void set_path (boost::filesystem::path); @@ -159,6 +161,7 @@ public: protected: void signal_changed (int); + virtual void add_properties (std::list > &) const {} boost::weak_ptr _film; diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc index 880a543e7..b1c9e3815 100644 --- a/src/lib/dcp_content.cc +++ b/src/lib/dcp_content.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington + Copyright (C) 2014-2015 Carl Hetherington 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 @@ -32,6 +32,8 @@ using std::string; using std::cout; using std::distance; +using std::pair; +using std::list; using boost::shared_ptr; using boost::optional; @@ -181,3 +183,9 @@ DCPContent::directory () const return dir; } + +void +DCPContent::add_properties (list >& p) const +{ + SingleStreamAudioContent::add_properties (p); +} diff --git a/src/lib/dcp_content.h b/src/lib/dcp_content.h index 2d0aaacde..d7a29c6ed 100644 --- a/src/lib/dcp_content.h +++ b/src/lib/dcp_content.h @@ -84,6 +84,9 @@ public: bool can_be_played () const; +protected: + void add_properties (std::list >& p) const; + private: void read_directory (boost::filesystem::path); diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc index 8feb7df57..ba0b4cc52 100644 --- a/src/lib/ffmpeg_content.cc +++ b/src/lib/ffmpeg_content.cc @@ -34,6 +34,7 @@ #include extern "C" { #include +#include } #include @@ -46,6 +47,7 @@ using std::vector; using std::list; using std::cout; using std::pair; +using std::make_pair; using boost::shared_ptr; using boost::dynamic_pointer_cast; @@ -96,6 +98,15 @@ FFmpegContent::FFmpegContent (shared_ptr film, cxml::ConstNodePtr no } _first_video = node->optional_number_child ("FirstVideo"); + + + _color_range = static_cast (node->optional_number_child("ColorRange").get_value_or (AVCOL_RANGE_UNSPECIFIED)); + _color_primaries = static_cast (node->optional_number_child("ColorPrimaries").get_value_or (AVCOL_PRI_UNSPECIFIED)); + _color_trc = static_cast ( + node->optional_number_child("ColorTransferCharacteristic").get_value_or (AVCOL_TRC_UNSPECIFIED) + ); + _colorspace = static_cast (node->optional_number_child("Colorspace").get_value_or (AVCOL_SPC_UNSPECIFIED)); + } FFmpegContent::FFmpegContent (shared_ptr film, vector > c) @@ -150,6 +161,11 @@ FFmpegContent::as_xml (xmlpp::Node* node) const if (_first_video) { node->add_child("FirstVideo")->add_child_text (raw_convert (_first_video.get().get())); } + + node->add_child("ColorRange")->add_child_text (raw_convert (_color_range)); + node->add_child("ColorPrimaries")->add_child_text (raw_convert (_color_primaries)); + node->add_child("ColorTransferCharacteristic")->add_child_text (raw_convert (_color_trc)); + node->add_child("Colorspace")->add_child_text (raw_convert (_colorspace)); } void @@ -182,6 +198,11 @@ FFmpegContent::examine (shared_ptr job) } _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); @@ -332,3 +353,77 @@ FFmpegContent::audio_streams () const copy (_audio_streams.begin(), _audio_streams.end(), back_inserter (s)); return s; } + +void +FFmpegContent::add_properties (list >& 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])); +} diff --git a/src/lib/ffmpeg_content.h b/src/lib/ffmpeg_content.h index c5797d5d1..05f6cebb6 100644 --- a/src/lib/ffmpeg_content.h +++ b/src/lib/ffmpeg_content.h @@ -104,6 +104,9 @@ public: std::list subtitles_during (ContentTimePeriod, bool starting) const; +protected: + void add_properties (std::list > &) const; + private: friend struct ffmpeg_pts_offset_test; friend struct audio_sampling_rate_test; @@ -114,6 +117,11 @@ private: boost::optional _first_video; /** Video filters that should be used when generating DCPs */ std::vector _filters; + + AVColorRange _color_range; + AVColorPrimaries _color_primaries; + AVColorTransferCharacteristic _color_trc; + AVColorSpace _colorspace; }; #endif diff --git a/src/lib/ffmpeg_examiner.h b/src/lib/ffmpeg_examiner.h index 7b64b508a..f2bdea0c2 100644 --- a/src/lib/ffmpeg_examiner.h +++ b/src/lib/ffmpeg_examiner.h @@ -46,6 +46,22 @@ public: 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); diff --git a/src/lib/single_stream_audio_content.cc b/src/lib/single_stream_audio_content.cc index cf2dcc1bd..38623422d 100644 --- a/src/lib/single_stream_audio_content.cc +++ b/src/lib/single_stream_audio_content.cc @@ -22,9 +22,13 @@ #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 film) @@ -81,3 +85,10 @@ SingleStreamAudioContent::audio_streams () const s.push_back (_audio_stream); return s; } + +void +SingleStreamAudioContent::add_properties (list >& p) const +{ + /* XXX: this could be better wrt audio streams */ + p.push_back (make_pair (_("Audio channels"), raw_convert (audio_stream()->channels ()))); +} diff --git a/src/lib/single_stream_audio_content.h b/src/lib/single_stream_audio_content.h index 7ae6dbaa4..ad4de46ea 100644 --- a/src/lib/single_stream_audio_content.h +++ b/src/lib/single_stream_audio_content.h @@ -49,6 +49,8 @@ public: void take_from_audio_examiner (boost::shared_ptr); protected: + void add_properties (std::list > &) const; + boost::shared_ptr _audio_stream; }; diff --git a/src/lib/video_content.cc b/src/lib/video_content.cc index 8c6f6c7eb..e2fba5829 100644 --- a/src/lib/video_content.cc +++ b/src/lib/video_content.cc @@ -56,6 +56,8 @@ using std::max; 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; @@ -569,3 +571,11 @@ VideoContent::processing_description () const return d.str (); } + +void +VideoContent::add_properties (list >& p) const +{ + p.push_back (make_pair (_("Video length"), raw_convert (video_length ()) + " " + _("video frames"))); + p.push_back (make_pair (_("Video size"), raw_convert (video_size().width) + "x" + raw_convert (video_size().height))); + p.push_back (make_pair (_("Video frame rate"), raw_convert (video_frame_rate()) + " " + _("frames per second"))); +} diff --git a/src/lib/video_content.h b/src/lib/video_content.h index 01e3cb2aa..71c20e737 100644 --- a/src/lib/video_content.h +++ b/src/lib/video_content.h @@ -164,6 +164,7 @@ public: protected: void take_from_video_examiner (boost::shared_ptr); + void add_properties (std::list > &) const; Frame _video_length; float _video_frame_rate; diff --git a/src/wx/content_properties_dialog.cc b/src/wx/content_properties_dialog.cc index 7fb0cccba..4f92e53ce 100644 --- a/src/wx/content_properties_dialog.cc +++ b/src/wx/content_properties_dialog.cc @@ -27,6 +27,8 @@ #include using std::string; +using std::list; +using std::pair; using boost::shared_ptr; using boost::dynamic_pointer_cast; @@ -35,40 +37,14 @@ ContentPropertiesDialog::ContentPropertiesDialog (wxWindow* parent, shared_ptrpath(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 video = dynamic_pointer_cast (content); - if (video) { - add_property ( - _("Video length"), - std_to_wx (raw_convert (video->video_length ())) + " " + _("video frames") - ); - add_property ( - _("Video size"), - std_to_wx (raw_convert (video->video_size().width) + "x" + raw_convert (video->video_size().height)) - ); - add_property ( - _("Video frame rate"), - std_to_wx (raw_convert (video->video_frame_rate())) + " " + _("frames per second") - ); - } - - /* XXX: this could be better wrt audio streams */ - - shared_ptr single = dynamic_pointer_cast (content); - if (single) { - add_property ( - _("Audio channels"), - std_to_wx (raw_convert (single->audio_stream()->channels ())) - ); + list > properties = content->properties (); + for (list >::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)); -} diff --git a/src/wx/content_properties_dialog.h b/src/wx/content_properties_dialog.h index 5c5efa1e8..52cce7ec6 100644 --- a/src/wx/content_properties_dialog.h +++ b/src/wx/content_properties_dialog.h @@ -26,8 +26,4 @@ class ContentPropertiesDialog : public TableDialog { public: ContentPropertiesDialog (wxWindow* parent, boost::shared_ptr content); - -private: - void add_property (wxString k, wxString v); }; - -- 2.30.2