X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Ffilm_editor.cc;h=d0136cfba63824a37848efc4f02b739ed2e9ebc1;hb=d7a166924028262ab307bb622da1dc85f127f944;hp=a97562b98c1881a983d730e71c4c98d85c370626;hpb=99d2e172f5c7fae21e5126a063014727871e9948;p=dcpomatic.git diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc index a97562b98..d0136cfba 100644 --- a/src/wx/film_editor.cc +++ b/src/wx/film_editor.cc @@ -37,7 +37,6 @@ #include "lib/filter.h" #include "lib/config.h" #include "lib/ffmpeg_decoder.h" -#include "lib/external_audio_decoder.h" #include "filter_dialog.h" #include "wx_util.h" #include "film_editor.h" @@ -104,7 +103,7 @@ FilmEditor::make_film_panel () add_label_to_grid_bag_sizer (grid, _film_panel, _("Name"), wxGBPosition (r, 0)); _name = new wxTextCtrl (_film_panel, wxID_ANY); - grid->Add (_name, wxGBPosition(r, 1)); + grid->Add (_name, wxGBPosition(r, 1), wxDefaultSpan, wxEXPAND); ++r; add_label_to_grid_bag_sizer (grid, _film_panel, _("DCP Name"), wxGBPosition (r, 0)); @@ -113,7 +112,7 @@ FilmEditor::make_film_panel () ++r; _use_dci_name = new wxCheckBox (_film_panel, wxID_ANY, _("Use DCI name")); - grid->Add (_use_dci_name, wxGBPosition (r, 0)); + grid->Add (_use_dci_name, wxGBPosition (r, 0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL); _edit_dci_button = new wxButton (_film_panel, wxID_ANY, _("Details...")); grid->Add (_edit_dci_button, wxGBPosition (r, 1), wxDefaultSpan); ++r; @@ -149,7 +148,7 @@ FilmEditor::make_film_panel () } ++r; - _frame_rate_description = new wxStaticText (_film_panel, wxID_ANY, wxT (""), wxDefaultPosition, wxDefaultSize); + _frame_rate_description = new wxStaticText (_film_panel, wxID_ANY, wxT (" \n \n "), wxDefaultPosition, wxDefaultSize); grid->Add (video_control (_frame_rate_description), wxGBPosition (r, 0), wxGBSpan (1, 2), wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL, 6); wxFont font = _frame_rate_description->GetFont(); font.SetStyle(wxFONTSTYLE_ITALIC); @@ -271,14 +270,6 @@ FilmEditor::make_video_panel () grid->Add (_format, wxGBPosition (r, 1)); ++r; - _format_description = new wxStaticText (_video_panel, wxID_ANY, wxT (""), wxDefaultPosition, wxDefaultSize); - grid->Add (_format_description, wxGBPosition (r, 0), wxGBSpan (1, 2), wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL, 6); - wxFont font = _format_description->GetFont(); - font.SetStyle(wxFONTSTYLE_ITALIC); - font.SetPointSize(font.GetPointSize() - 1); - _format_description->SetFont(font); - ++r; - add_label_to_grid_bag_sizer (grid, _video_panel, _("Left crop"), wxGBPosition (r, 0)); _left_crop = new wxSpinCtrl (_video_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (64, -1)); grid->Add (_left_crop, wxGBPosition (r, 1)); @@ -299,6 +290,14 @@ FilmEditor::make_video_panel () grid->Add (_bottom_crop, wxGBPosition (r, 1)); ++r; + _scaling_description = new wxStaticText (_video_panel, wxID_ANY, wxT ("\n \n \n \n"), wxDefaultPosition, wxDefaultSize); + grid->Add (_scaling_description, wxGBPosition (r, 0), wxGBSpan (1, 2), wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL, 6); + wxFont font = _scaling_description->GetFont(); + font.SetStyle(wxFONTSTYLE_ITALIC); + font.SetPointSize(font.GetPointSize() - 1); + _scaling_description->SetFont(font); + ++r; + /* VIDEO-only stuff */ { video_control (add_label_to_grid_bag_sizer (grid, _video_panel, _("Filters"), wxGBPosition (r, 0))); @@ -429,9 +428,14 @@ FilmEditor::make_subtitle_panel () _subtitle_stream = new wxChoice (_subtitle_panel, wxID_ANY); grid->Add (video_control (_subtitle_stream)); - video_control (add_label_to_sizer (grid, _subtitle_panel, _("Subtitle Offset"))); - _subtitle_offset = new wxSpinCtrl (_subtitle_panel); - grid->Add (video_control (_subtitle_offset), 1); + { + video_control (add_label_to_sizer (grid, _subtitle_panel, _("Subtitle Offset"))); + wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL); + _subtitle_offset = new wxSpinCtrl (_subtitle_panel); + s->Add (_subtitle_offset); + video_control (add_label_to_sizer (s, _subtitle_panel, _("pixels"))); + grid->Add (s); + } { video_control (add_label_to_sizer (grid, _subtitle_panel, _("Subtitle Scale"))); @@ -502,7 +506,7 @@ FilmEditor::content_changed (wxCommandEvent &) _film->set_content (wx_to_std (_content->GetPath ())); } catch (std::exception& e) { _content->SetPath (std_to_wx (_film->directory ())); - error_dialog (this, wxString::Format (_("Could not set content: %s"), e.what ())); + error_dialog (this, wxString::Format (_("Could not set content: %s"), std_to_wx (e.what()).data())); } } @@ -617,6 +621,8 @@ FilmEditor::film_changed (Film::Property p) setup_formats (); setup_subtitle_control_sensitivity (); setup_streams (); + setup_show_audio_sensitivity (); + setup_frame_rate_description (); break; case Film::TRUST_CONTENT_HEADER: checked_set (_trust_content_header, _film->trust_content_header ()); @@ -627,6 +633,8 @@ FilmEditor::film_changed (Film::Property p) break; case Film::CONTENT_AUDIO_STREAMS: setup_streams (); + setup_show_audio_sensitivity (); + setup_frame_rate_description (); break; case Film::FORMAT: { @@ -642,8 +650,7 @@ FilmEditor::film_changed (Film::Property p) checked_set (_format, n); } setup_dcp_name (); - - _format_description->SetLabel (std_to_wx (_film->format()->description ())); + setup_scaling_description (); break; } case Film::CROP: @@ -651,6 +658,7 @@ FilmEditor::film_changed (Film::Property p) checked_set (_right_crop, _film->crop().right); checked_set (_top_crop, _film->crop().top); checked_set (_bottom_crop, _film->crop().bottom); + setup_scaling_description (); break; case Film::FILTERS: { @@ -671,6 +679,7 @@ FilmEditor::film_changed (Film::Property p) case Film::SOURCE_FRAME_RATE: s << fixed << setprecision(2) << _film->source_frame_rate(); _source_frame_rate->SetLabel (std_to_wx (s.str ())); + setup_frame_rate_description (); break; case Film::SIZE: if (_film->size().width == 0 && _film->size().height == 0) { @@ -679,12 +688,15 @@ FilmEditor::film_changed (Film::Property p) s << _film->size().width << " x " << _film->size().height; _original_size->SetLabel (std_to_wx (s.str ())); } + setup_scaling_description (); break; case Film::LENGTH: if (_film->source_frame_rate() > 0 && _film->length()) { - s << _film->length().get() << " " << _("frames") << "; " << seconds_to_hms (_film->length().get() / _film->source_frame_rate()); + s << _film->length().get() << " " + << wx_to_std (_("frames")) << "; " << seconds_to_hms (_film->length().get() / _film->source_frame_rate()); } else if (_film->length()) { - s << _film->length().get() << " " << _("frames"); + s << _film->length().get() << " " + << wx_to_std (_("frames")); } _length->SetLabel (std_to_wx (s.str ())); if (_film->length()) { @@ -692,8 +704,6 @@ FilmEditor::film_changed (Film::Property p) _trim_end->SetRange (0, _film->length().get()); } break; - case Film::DCP_INTRINSIC_DURATION: - break; case Film::DCP_CONTENT_TYPE: checked_set (_dcp_content_type, DCPContentType::as_index (_film->dcp_content_type ())); setup_dcp_name (); @@ -750,6 +760,8 @@ FilmEditor::film_changed (Film::Property p) setup_dcp_name (); setup_audio_details (); setup_audio_control_sensitivity (); + setup_show_audio_sensitivity (); + setup_frame_rate_description (); break; case Film::USE_CONTENT_AUDIO: checked_set (_use_content_audio, _film->use_content_audio()); @@ -757,6 +769,8 @@ FilmEditor::film_changed (Film::Property p) setup_dcp_name (); setup_audio_details (); setup_audio_control_sensitivity (); + setup_show_audio_sensitivity (); + setup_frame_rate_description (); break; case Film::SUBTITLE_STREAM: if (_film->subtitle_stream()) { @@ -770,6 +784,8 @@ FilmEditor::film_changed (Film::Property p) checked_set (_external_audio[i], a[i]); } setup_audio_details (); + setup_show_audio_sensitivity (); + setup_frame_rate_description (); break; } case Film::DCP_FRAME_RATE: @@ -781,11 +797,41 @@ FilmEditor::film_changed (Film::Property p) } } } - _frame_rate_description->SetLabel (std_to_wx (FrameRateConversion (_film->source_frame_rate(), _film->dcp_frame_rate()).description)); - _best_dcp_frame_rate->Enable (best_dcp_frame_rate (_film->source_frame_rate ()) != _film->dcp_frame_rate ()); + + if (_film->source_frame_rate()) { + _best_dcp_frame_rate->Enable (best_dcp_frame_rate (_film->source_frame_rate ()) != _film->dcp_frame_rate ()); + } else { + _best_dcp_frame_rate->Disable (); + } + + setup_frame_rate_description (); } } +void +FilmEditor::setup_frame_rate_description () +{ + wxString d; + if (_film->source_frame_rate()) { + d << std_to_wx (FrameRateConversion (_film->source_frame_rate(), _film->dcp_frame_rate()).description); +#ifdef HAVE_SWRESAMPLE + if (_film->audio_stream() && _film->audio_stream()->sample_rate() != _film->target_audio_sample_rate ()) { + d << wxString::Format ( + _("Audio will be resampled from %dHz to %dHz\n"), + _film->audio_stream()->sample_rate(), + _film->target_audio_sample_rate() + ); + } else { + d << wxT ("\n"); + } +#else + d << wxT ("\n"); +#endif + } + + _frame_rate_description->SetLabel (d); +} + /** Called when the format widget has been changed */ void FilmEditor::format_changed (wxCommandEvent &) @@ -830,7 +876,7 @@ FilmEditor::set_film (shared_ptr f) if (_film) { FileChanged (_film->directory ()); } else { - FileChanged (wx_to_std (N_(""))); + FileChanged (""); } if (_audio_dialog) { @@ -905,6 +951,7 @@ FilmEditor::set_things_sensitive (bool s) setup_subtitle_control_sensitivity (); setup_audio_control_sensitivity (); + setup_show_audio_sensitivity (); } /** Called when the `Edit filters' button has been clicked */ @@ -982,6 +1029,12 @@ FilmEditor::setup_visibility () (*i)->Show (c == STILL); } + setup_notebook_size (); +} + +void +FilmEditor::setup_notebook_size () +{ _notebook->InvalidateBestSize (); _film_sizer->Layout (); @@ -1067,9 +1120,7 @@ FilmEditor::setup_formats () vector fmt = Format::all (); for (vector::iterator i = fmt.begin(); i != fmt.end(); ++i) { - if (c == VIDEO && dynamic_cast (*i)) { - _formats.push_back (*i); - } else if (c == STILL && dynamic_cast (*i)) { + if (c == VIDEO || (c == STILL && dynamic_cast (*i))) { _formats.push_back (*i); } } @@ -1115,7 +1166,7 @@ FilmEditor::setup_subtitle_control_sensitivity () void FilmEditor::setup_audio_control_sensitivity () { - _use_content_audio->Enable (_generally_sensitive); + _use_content_audio->Enable (_generally_sensitive && _film && !_film->content_audio_streams().empty()); _use_external_audio->Enable (_generally_sensitive); bool const source = _generally_sensitive && _use_content_audio->GetValue(); @@ -1210,18 +1261,20 @@ FilmEditor::subtitle_stream_changed (wxCommandEvent &) void FilmEditor::setup_audio_details () { - if (!_film->audio_stream()) { + if (!_film->content_audio_stream()) { _audio->SetLabel (wxT ("")); } else { - stringstream s; + wxString s; if (_film->audio_stream()->channels() == 1) { s << _("1 channel"); } else { - s << _film->audio_stream()->channels () << " " << _("channels"); + s << _film->audio_stream()->channels () << wxT (" ") << _("channels"); } - s << ", " << _film->audio_stream()->sample_rate() << _("Hz"); - _audio->SetLabel (std_to_wx (s.str ())); + s << wxT (", ") << _film->audio_stream()->sample_rate() << _("Hz"); + _audio->SetLabel (s); } + + setup_notebook_size (); } void @@ -1281,3 +1334,65 @@ FilmEditor::best_dcp_frame_rate_clicked (wxCommandEvent &) _film->set_dcp_frame_rate (best_dcp_frame_rate (_film->source_frame_rate ())); } + +void +FilmEditor::setup_show_audio_sensitivity () +{ + _show_audio->Enable (_film && _film->has_audio ()); +} + +void +FilmEditor::setup_scaling_description () +{ + wxString d; + + int lines = 0; + + if (_film->size().width && _film->size().height) { + d << wxString::Format ( + _("Original video is %dx%d (%.2f:1)\n"), + _film->size().width, _film->size().height, + float (_film->size().width) / _film->size().height + ); + ++lines; + } + + Crop const crop = _film->crop (); + if (crop.left || crop.right || crop.top || crop.bottom) { + libdcp::Size const cropped = _film->cropped_size (_film->size ()); + d << wxString::Format ( + _("Cropped to %dx%d (%.2f:1)\n"), + cropped.width, cropped.height, + float (cropped.width) / cropped.height + ); + ++lines; + } + + Format const * format = _film->format (); + if (format) { + int const padding = format->dcp_padding (_film); + libdcp::Size scaled = format->dcp_size (); + scaled.width -= padding * 2; + d << wxString::Format ( + _("Scaled to %dx%d (%.2f:1)\n"), + scaled.width, scaled.height, + float (scaled.width) / scaled.height + ); + ++lines; + + if (padding) { + d << wxString::Format ( + _("Padded with black to %dx%d (%.2f:1)\n"), + format->dcp_size().width, format->dcp_size().height, + float (format->dcp_size().width) / format->dcp_size().height + ); + ++lines; + } + } + + for (int i = lines; i < 4; ++i) { + d << wxT (" \n"); + } + + _scaling_description->SetLabel (d); +}