summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-04-02 23:33:46 +0100
committerCarl Hetherington <cth@carlh.net>2013-04-02 23:33:46 +0100
commit7ebb57db2013c9e929d44d0e547ab1f27c59cc7f (patch)
tree19959172e24e2cf097a2814aeb9e2298805d8a2b /src
parent2343509c75673d3fad82a5d0eab9622a4d6902e3 (diff)
Add basic content information, and some other bits.
Diffstat (limited to 'src')
-rw-r--r--src/lib/content.h1
-rw-r--r--src/lib/ffmpeg_content.cc12
-rw-r--r--src/lib/ffmpeg_content.h1
-rw-r--r--src/lib/film.cc2
-rw-r--r--src/lib/imagemagick_content.cc1
-rw-r--r--src/lib/sndfile_content.cc6
-rw-r--r--src/lib/sndfile_content.h1
-rw-r--r--src/lib/video_content.cc20
-rw-r--r--src/lib/video_content.h1
-rw-r--r--src/wx/film_editor.cc99
-rw-r--r--src/wx/film_editor.h3
11 files changed, 106 insertions, 41 deletions
diff --git a/src/lib/content.h b/src/lib/content.h
index 3f348ca91..11c7438a6 100644
--- a/src/lib/content.h
+++ b/src/lib/content.h
@@ -41,6 +41,7 @@ public:
virtual void examine (boost::shared_ptr<Film>, boost::shared_ptr<Job>, bool);
virtual std::string summary () const = 0;
+ virtual std::string information () const = 0;
virtual void as_xml (xmlpp::Node *) const;
virtual boost::shared_ptr<Content> clone () const = 0;
diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc
index 5bff1cecc..c6344d567 100644
--- a/src/lib/ffmpeg_content.cc
+++ b/src/lib/ffmpeg_content.cc
@@ -28,6 +28,7 @@
#include "i18n.h"
using std::string;
+using std::stringstream;
using std::vector;
using std::list;
using boost::shared_ptr;
@@ -162,6 +163,17 @@ FFmpegContent::summary () const
return String::compose (_("Movie: %1"), file().filename ());
}
+string
+FFmpegContent::information () const
+{
+ stringstream s;
+
+ s << String::compose (_("%1 frames; %2 frames per second"), video_length(), video_frame_rate()) << "\n";
+ s << VideoContent::information ();
+
+ return s.str ();
+}
+
void
FFmpegContent::set_subtitle_stream (FFmpegSubtitleStream s)
{
diff --git a/src/lib/ffmpeg_content.h b/src/lib/ffmpeg_content.h
index 598ebf484..3d69a2f99 100644
--- a/src/lib/ffmpeg_content.h
+++ b/src/lib/ffmpeg_content.h
@@ -86,6 +86,7 @@ public:
void examine (boost::shared_ptr<Film>, boost::shared_ptr<Job>, bool);
std::string summary () const;
+ std::string information () const;
void as_xml (xmlpp::Node *) const;
boost::shared_ptr<Content> clone () const;
diff --git a/src/lib/film.cc b/src/lib/film.cc
index d58f7fd53..f71180157 100644
--- a/src/lib/film.cc
+++ b/src/lib/film.cc
@@ -95,7 +95,7 @@ Film::Film (string d, bool must_exist)
, _use_dci_name (true)
, _trust_content_headers (true)
, _dcp_content_type (0)
- , _format (0)
+ , _format (Format::from_id ("185"))
, _scaler (Scaler::from_id ("bicubic"))
, _trim_start (0)
, _trim_end (0)
diff --git a/src/lib/imagemagick_content.cc b/src/lib/imagemagick_content.cc
index 5ad94db45..f7c76a34d 100644
--- a/src/lib/imagemagick_content.cc
+++ b/src/lib/imagemagick_content.cc
@@ -25,6 +25,7 @@
#include "i18n.h"
using std::string;
+using std::stringstream;
using boost::shared_ptr;
ImageMagickContent::ImageMagickContent (boost::filesystem::path f)
diff --git a/src/lib/sndfile_content.cc b/src/lib/sndfile_content.cc
index 657e7d519..cf7921a93 100644
--- a/src/lib/sndfile_content.cc
+++ b/src/lib/sndfile_content.cc
@@ -27,6 +27,12 @@ SndfileContent::summary () const
return String::compose (_("Sound file: %1"), file().filename ());
}
+string
+SndfileContent::information () const
+{
+ return "";
+}
+
int
SndfileContent::audio_channels () const
{
diff --git a/src/lib/sndfile_content.h b/src/lib/sndfile_content.h
index 81a964ec8..ab8a04e4d 100644
--- a/src/lib/sndfile_content.h
+++ b/src/lib/sndfile_content.h
@@ -11,6 +11,7 @@ public:
SndfileContent (boost::shared_ptr<const cxml::Node>);
std::string summary () const;
+ std::string information () const;
boost::shared_ptr<Content> clone () const;
/* AudioContent */
diff --git a/src/lib/video_content.cc b/src/lib/video_content.cc
index f48813f60..edb713466 100644
--- a/src/lib/video_content.cc
+++ b/src/lib/video_content.cc
@@ -2,11 +2,15 @@
#include "video_content.h"
#include "video_decoder.h"
+#include "i18n.h"
+
int const VideoContentProperty::VIDEO_LENGTH = 0;
int const VideoContentProperty::VIDEO_SIZE = 1;
int const VideoContentProperty::VIDEO_FRAME_RATE = 2;
using std::string;
+using std::stringstream;
+using std::setprecision;
using boost::shared_ptr;
using boost::lexical_cast;
@@ -61,3 +65,19 @@ VideoContent::take_from_video_decoder (shared_ptr<VideoDecoder> d)
Changed (VideoContentProperty::VIDEO_SIZE);
Changed (VideoContentProperty::VIDEO_FRAME_RATE);
}
+
+
+string
+VideoContent::information () const
+{
+ stringstream s;
+
+ s << String::compose (
+ _("%1x%2 pixels (%3:1)"),
+ video_size().width,
+ video_size().height,
+ setprecision (3), float (video_size().width) / video_size().height
+ );
+
+ return s.str ();
+}
diff --git a/src/lib/video_content.h b/src/lib/video_content.h
index 25cb28938..19b49e926 100644
--- a/src/lib/video_content.h
+++ b/src/lib/video_content.h
@@ -22,6 +22,7 @@ public:
VideoContent (VideoContent const &);
void as_xml (xmlpp::Node *) const;
+ virtual std::string information () const;
ContentVideoFrame video_length () const {
boost::mutex::scoped_lock lm (_mutex);
diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc
index 67ebf49d0..d354e6e5a 100644
--- a/src/wx/film_editor.cc
+++ b/src/wx/film_editor.cc
@@ -331,11 +331,6 @@ FilmEditor::make_content_panel ()
_content_sizer = new wxBoxSizer (wxVERTICAL);
_content_panel->SetSizer (_content_sizer);
- wxGridBagSizer* grid = new wxGridBagSizer (4, 4);
- _content_sizer->Add (grid, 0, wxALL, 8);
-
- int r = 0;
-
{
wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
@@ -357,9 +352,11 @@ FilmEditor::make_content_panel ()
s->Add (b, 0, wxALL, 4);
- grid->Add (s, wxGBPosition (r, 0), wxGBSpan (1, 2), wxEXPAND);
- ++r;
+ _content_sizer->Add (s, 1, wxEXPAND | wxALL, 6);
}
+
+ _content_information = new wxTextCtrl (_content_panel, wxID_ANY, wxT ("\n\n\n\n"), wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_MULTILINE);
+ _content_sizer->Add (_content_information, 1, wxEXPAND | wxALL, 6);
}
void
@@ -585,35 +582,18 @@ FilmEditor::film_changed (Film::Property p)
case Film::CONTENT:
setup_content ();
setup_formats ();
+ setup_format ();
setup_subtitle_control_sensitivity ();
setup_streams ();
setup_show_audio_sensitivity ();
+ setup_length ();
break;
case Film::TRUST_CONTENT_HEADERS:
checked_set (_trust_content_headers, _film->trust_content_headers ());
break;
case Film::FORMAT:
- {
- int n = 0;
- vector<Format const *>::iterator i = _formats.begin ();
- while (i != _formats.end() && *i != _film->format ()) {
- ++i;
- ++n;
- }
- if (i == _formats.end()) {
- checked_set (_format, -1);
- } else {
- checked_set (_format, n);
- }
- setup_dcp_name ();
-
- if (_film->format ()) {
- _format_description->SetLabel (std_to_wx (_film->format()->description ()));
- } else {
- _format_description->SetLabel (wxT (""));
- }
+ setup_format ();
break;
- }
case Film::CROP:
checked_set (_left_crop, _film->crop().left);
checked_set (_right_crop, _film->crop().right);
@@ -737,22 +717,51 @@ FilmEditor::film_content_changed (int p)
setup_streams ();
setup_show_audio_sensitivity ();
} else if (p == VideoContentProperty::VIDEO_LENGTH) {
- stringstream s;
- if (_film->video_frame_rate() > 0 && _film->video_length()) {
- s << _film->video_length() << " "
- << wx_to_std (_("frames")) << "; " << seconds_to_hms (_film->video_length() / _film->video_frame_rate());
- } else if (_film->video_length()) {
- s << _film->video_length() << " "
- << wx_to_std (_("frames"));
- }
- _length->SetLabel (std_to_wx (s.str ()));
- if (_film->video_length()) {
- _trim_start->SetRange (0, _film->video_length());
- _trim_end->SetRange (0, _film->video_length());
- }
+ setup_length ();
}
}
+void
+FilmEditor::setup_format ()
+{
+ int n = 0;
+ vector<Format const *>::iterator i = _formats.begin ();
+ while (i != _formats.end() && *i != _film->format ()) {
+ ++i;
+ ++n;
+ }
+ if (i == _formats.end()) {
+ checked_set (_format, -1);
+ } else {
+ checked_set (_format, n);
+ }
+ setup_dcp_name ();
+
+ if (_film->format ()) {
+ _format_description->SetLabel (std_to_wx (_film->format()->description ()));
+ } else {
+ _format_description->SetLabel (wxT (""));
+ }
+}
+
+void
+FilmEditor::setup_length ()
+{
+ stringstream s;
+ if (_film->video_frame_rate() > 0 && _film->video_length()) {
+ s << _film->video_length() << " "
+ << wx_to_std (_("frames")) << "; " << seconds_to_hms (_film->video_length() / _film->video_frame_rate());
+ } else if (_film->video_length()) {
+ s << _film->video_length() << " "
+ << wx_to_std (_("frames"));
+ }
+ _length->SetLabel (std_to_wx (s.str ()));
+ if (_film->video_length()) {
+ _trim_start->SetRange (0, _film->video_length());
+ _trim_end->SetRange (0, _film->video_length());
+ }
+}
+
/** Called when the format widget has been changed */
void
@@ -1227,6 +1236,16 @@ void
FilmEditor::content_item_selected (wxListEvent &)
{
setup_content_button_sensitivity ();
+
+ int const s = _content->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
+ if (s == -1) {
+ _content_information->SetValue ("");
+ return;
+ }
+
+ ContentList c = _film->content ();
+ assert (s >= 0 && size_t (s) < c.size ());
+ _content_information->SetValue (std_to_wx (c[s]->information ()));
}
void
diff --git a/src/wx/film_editor.h b/src/wx/film_editor.h
index e01ab8ccc..311f8ceaa 100644
--- a/src/wx/film_editor.h
+++ b/src/wx/film_editor.h
@@ -104,6 +104,8 @@ private:
void setup_show_audio_sensitivity ();
void setup_content ();
void setup_content_button_sensitivity ();
+ void setup_length ();
+ void setup_format ();
void active_jobs_changed (bool);
@@ -130,6 +132,7 @@ private:
wxButton* _content_remove;
wxButton* _content_earlier;
wxButton* _content_later;
+ wxTextCtrl* _content_information;
wxButton* _edit_dci_button;
wxChoice* _format;
wxStaticText* _format_description;