Add primitive description of what the playlist is doing. Add missing de-interleave...
authorCarl Hetherington <cth@carlh.net>
Sat, 4 May 2013 17:01:19 +0000 (18:01 +0100)
committerCarl Hetherington <cth@carlh.net>
Sat, 4 May 2013 17:01:19 +0000 (18:01 +0100)
run/dcpomatic_cli [new file with mode: 0755]
run/makedcp [deleted file]
src/lib/film.cc
src/lib/film.h
src/lib/playlist.cc
src/lib/playlist.h
src/lib/sndfile_decoder.cc
src/lib/sndfile_decoder.h
src/wx/film_editor.cc
src/wx/film_editor.h

diff --git a/run/dcpomatic_cli b/run/dcpomatic_cli
new file mode 100755 (executable)
index 0000000..bf2f080
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+export LD_LIBRARY_PATH=build/src/lib:$LD_LIBRARY_PATH:build/src
+if [ "$1" == "--debug" ]; then
+    shift
+    gdb --args build/src/tools/dcpomatic_cli "$@"
+elif [ "$1" == "--valgrind" ]; then
+    shift
+    valgrind --tool="memcheck" --leak-check=full --show-reachable=yes build/src/tools/dcpomatic_cli "$@"
+else
+    build/src/tools/dcpomatic_cli "$@"
+fi
diff --git a/run/makedcp b/run/makedcp
deleted file mode 100755 (executable)
index f71345b..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/bash
-
-export LD_LIBRARY_PATH=build/src/lib:$LD_LIBRARY_PATH:build/src
-if [ "$1" == "--debug" ]; then
-    shift
-    gdb --args build/src/tools/makedcp "$@"
-elif [ "$1" == "--valgrind" ]; then
-    shift
-    valgrind --tool="memcheck" --leak-check=full --show-reachable=yes build/src/tools/makedcp "$@"
-else
-    build/src/tools/makedcp "$@"
-fi
index 7d1985d08eac56cea8265762c5af171191342919..2dc97c1b3fbd9d6e3579d3e71c4939e02e579de2 100644 (file)
@@ -1160,6 +1160,12 @@ Film::has_subtitles () const
        return _playlist->has_subtitles ();
 }
 
+string
+Film::playlist_description () const
+{
+       return _playlist->description ();
+}
+
 void
 Film::set_audio_mapping (AudioMapping m)
 {
index 48b0d16c548d921c9adebb2e05b1a3c20eb675c6..8748e18f55aa9b3aff8a14fe38262773c9a96d94 100644 (file)
@@ -121,6 +121,8 @@ public:
 
        ContentVideoFrame content_length () const;
 
+       std::string playlist_description () const;
+
        void set_loop (int);
        int loop () const;
 
index 63b44f9d649f8ad59ad4d24d8355feb27802a202..6913874b905d19e8574a20a0e89a1a525e74c6c9 100644 (file)
 #include "imagemagick_content.h"
 #include "job.h"
 
+#include "i18n.h"
+
 using std::list;
 using std::cout;
 using std::vector;
 using std::min;
 using std::max;
 using std::string;
+using std::stringstream;
 using boost::shared_ptr;
 using boost::weak_ptr;
 using boost::dynamic_pointer_cast;
@@ -427,3 +430,51 @@ Playlist::has_subtitles () const
        
        return !fc->subtitle_streams().empty();
 }
+
+string
+Playlist::description () const
+{
+       stringstream s;
+
+       if (_video.empty ()) {
+               s << _("There is no video.") << "\n";
+       } else {
+               s << _("Video will come from ");
+               list<shared_ptr<const VideoContent> >::const_iterator i = _video.begin();
+               while (i != _video.end ()) {
+                       s << (*i)->file().filename().string();
+                       ++i;
+                       if (i != _video.end ()) {
+                               s << ", ";
+                       }
+               }
+               if (_video.size() > 1) {
+                       s << " " << _("in sequence.");
+               }
+               s << "\n";
+       }
+
+       if (_audio.empty ()) {
+               s << _("There is no audio.") << "\n";
+       } else {
+               if (_audio_from == AUDIO_FFMPEG) {
+                       s << _("Audio will come from the video files.") << "\n";
+               } else {
+                       s << _("Audio will come from ");
+                       list<shared_ptr<const AudioContent> >::const_iterator i = _audio.begin();
+                       while (i != _audio.end ()) {
+                               s << (*i)->file().filename().string();
+                               ++i;
+                               if (i != _audio.end ()) {
+                                       s << ", ";
+                               }
+                       }
+                       if (_audio.size() > 1) {
+                               s << _(" run simultaneously.");
+                       }
+                       s << "\n";
+               }
+       }
+                       
+       return s.str ();
+}
index e6acff6944472db7e45827237914f1279c1c1a93..cea41ab3281729c84c185ed0e188d492f546218a 100644 (file)
@@ -88,6 +88,8 @@ public:
                return _content;
        }
 
+       std::string description () const;
+
        boost::shared_ptr<FFmpegContent> ffmpeg () const;
 
        std::list<boost::shared_ptr<const VideoContent> > video () const {
index 9ba972e565ffbdb47b52056f2aaede885dcee560..dd9e654c77de7984a4672a7a577fb8d91f340f44 100644 (file)
@@ -36,6 +36,7 @@ SndfileDecoder::SndfileDecoder (shared_ptr<const Film> f, shared_ptr<const Sndfi
        : Decoder (f)
        , AudioDecoder (f)
        , _sndfile_content (c)
+       , _deinterleave_buffer (0)
 {
        _sndfile = sf_open (_sndfile_content->file().string().c_str(), SFM_READ, &_info);
        if (!_sndfile) {
@@ -49,6 +50,7 @@ SndfileDecoder::SndfileDecoder (shared_ptr<const Film> f, shared_ptr<const Sndfi
 SndfileDecoder::~SndfileDecoder ()
 {
        sf_close (_sndfile);
+       delete[] _deinterleave_buffer;
 }
 
 bool
@@ -59,9 +61,32 @@ SndfileDecoder::pass ()
        */
        sf_count_t const block = _sndfile_content->audio_frame_rate() / 2;
        sf_count_t const this_time = min (block, _remaining);
+
+       int const channels = _sndfile_content->audio_channels ();
        
-       shared_ptr<AudioBuffers> audio (new AudioBuffers (_sndfile_content->audio_channels(), this_time));
-       sf_read_float (_sndfile, audio->data(0), this_time);
+       shared_ptr<AudioBuffers> audio (new AudioBuffers (channels, this_time));
+
+       if (_sndfile_content->audio_channels() == 1) {
+               /* No de-interleaving required */
+               sf_read_float (_sndfile, audio->data(0), this_time);
+       } else {
+               /* Deinterleave */
+               if (!_deinterleave_buffer) {
+                       _deinterleave_buffer = new float[block * channels];
+               }
+               sf_readf_float (_sndfile, _deinterleave_buffer, this_time);
+               vector<float*> out_ptr (channels);
+               for (int i = 0; i < channels; ++i) {
+                       out_ptr[i] = audio->data(i);
+               }
+               float* in_ptr = _deinterleave_buffer;
+               for (int i = 0; i < this_time; ++i) {
+                       for (int j = 0; j < channels; ++j) {
+                               *out_ptr[j]++ = *in_ptr++;
+                       }
+               }
+       }
+               
        audio->set_frames (this_time);
        Audio (audio, double(_done) / audio_frame_rate());
        _done += this_time;
index 1d212cc9b26871bb972f96f135d91cac48736f8c..64bd2f7f53a4de574bafa48911936c3955a4169a 100644 (file)
@@ -41,4 +41,5 @@ private:
        SF_INFO _info;
        ContentAudioFrame _done;
        ContentAudioFrame _remaining;
+       float* _deinterleave_buffer;
 };
index 85c4f71f866631f4018e635d0b8cb5d3dab3256d..db3e03d78f2f6ee72b3ec93cd88a4a445dfa53b1 100644 (file)
@@ -88,6 +88,8 @@ FilmEditor::FilmEditor (shared_ptr<Film> f, wxWindow* parent)
        make_subtitle_panel ();
        _notebook->AddPage (_subtitle_panel, _("Subtitles"), false);
 
+       setup_formats ();
+
        set_film (f);
        connect_to_widgets ();
 
@@ -95,8 +97,6 @@ FilmEditor::FilmEditor (shared_ptr<Film> f, wxWindow* parent)
                bind (&FilmEditor::active_jobs_changed, this, _1)
                );
        
-       setup_formats ();
-
        SetSizerAndFit (s);
 }
 
@@ -367,9 +367,12 @@ FilmEditor::make_content_panel ()
 
                 s->Add (b, 0, wxALL, 4);
 
-                _content_sizer->Add (s, 1, wxEXPAND | wxALL, 6);
+                _content_sizer->Add (s, 0.75, wxEXPAND | wxALL, 6);
         }
 
+       _content_information = new wxTextCtrl (_content_panel, wxID_ANY, wxT ("\n \n "), wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_MULTILINE);
+       _content_sizer->Add (_content_information, 1, wxEXPAND | wxALL, 6);
+
        wxBoxSizer* h = new wxBoxSizer (wxHORIZONTAL);
        _loop_content = new wxCheckBox (_content_panel, wxID_ANY, _("Loop everything"));
        h->Add (_loop_content, 0, wxALL, 6);
@@ -378,8 +381,12 @@ FilmEditor::make_content_panel ()
        add_label_to_sizer (h, _content_panel, _("times"));
        _content_sizer->Add (h, 0, 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);
+       _playlist_description = new wxStaticText (_content_panel, wxID_ANY, wxT ("\n \n \n \n "));
+       _content_sizer->Add (_playlist_description, 0.25, wxEXPAND | wxALL, 6);
+       wxFont font = _playlist_description->GetFont();
+       font.SetStyle(wxFONTSTYLE_ITALIC);
+       font.SetPointSize(font.GetPointSize() - 1);
+       _playlist_description->SetFont(font);
 
        _loop_count->SetRange (2, 1024);
 }
@@ -1198,6 +1205,8 @@ FilmEditor::setup_content ()
                /* Select the first item of content if non was selected before */
                _content->SetItemState (0, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
        }
+
+       setup_playlist_description ();
 }
 
 void
@@ -1429,3 +1438,14 @@ FilmEditor::setup_loop_sensitivity ()
 {
        _loop_count->Enable (_loop_content->GetValue ());
 }
+
+void
+FilmEditor::setup_playlist_description ()
+{
+       if (!_film) {
+               _playlist_description->SetLabel (wxT (""));
+               return;
+       }
+
+       _playlist_description->SetLabel (std_to_wx (_film->playlist_description ()));
+}
index db657a7d3f5b4876fcb13199e45bad1afff5d473..baaeb46d7101ea5ebcf0bef41957a53d93a06958 100644 (file)
@@ -112,6 +112,7 @@ private:
        void setup_content_information ();
        void setup_content_button_sensitivity ();
        void setup_loop_sensitivity ();
+       void setup_playlist_description ();
        
        void active_jobs_changed (bool);
        boost::shared_ptr<Content> selected_content ();
@@ -144,6 +145,7 @@ private:
        wxTextCtrl* _content_information;
        wxCheckBox* _loop_content;
        wxSpinCtrl* _loop_count;
+       wxStaticText* _playlist_description;
        wxButton* _edit_dci_button;
        wxChoice* _format;
        wxStaticText* _format_description;