From 490558a8fc5fdc567f7f586c0421ad89101a9a2c Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 9 May 2014 22:30:49 +0100 Subject: Re-introduce ffprobe call when adding content. --- src/lib/film.cc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/lib') diff --git a/src/lib/film.cc b/src/lib/film.cc index 8bececf4f..7b72126f9 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -827,6 +827,10 @@ Film::content () const void Film::examine_and_add_content (shared_ptr c) { + if (dynamic_pointer_cast (c)) { + run_ffprobe (c->path(0), file ("ffprobe.log"), _log); + } + shared_ptr j (new ExamineContentJob (shared_from_this(), c)); j->Finished.connect (bind (&Film::maybe_add_content, this, boost::weak_ptr (j), boost::weak_ptr (c))); JobManager::instance()->add (j); -- cgit v1.2.3 From 9579bfdec2fab28fc221e397cf848a08e48f6840 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 9 May 2014 22:51:30 +0100 Subject: MAX_AUDIO_CHANNELS -> MAX_DCP_AUDIO_CHANNELS. --- src/lib/audio_mapping.cc | 6 +++--- src/lib/util.cc | 2 +- src/lib/util.h | 4 ++-- src/wx/audio_dialog.cc | 6 +++--- src/wx/audio_dialog.h | 2 +- src/wx/audio_mapping_view.cc | 8 ++++---- src/wx/audio_plot.cc | 12 ++++++------ src/wx/audio_plot.h | 2 +- src/wx/film_editor.cc | 2 +- test/audio_mapping_test.cc | 2 +- test/silence_padding_test.cc | 2 +- 11 files changed, 24 insertions(+), 24 deletions(-) (limited to 'src/lib') diff --git a/src/lib/audio_mapping.cc b/src/lib/audio_mapping.cc index ae7702998..28a0fc380 100644 --- a/src/lib/audio_mapping.cc +++ b/src/lib/audio_mapping.cc @@ -53,7 +53,7 @@ AudioMapping::setup (int c) _gain.resize (_content_channels); for (int i = 0; i < _content_channels; ++i) { - _gain[i].resize (MAX_AUDIO_CHANNELS); + _gain[i].resize (MAX_DCP_AUDIO_CHANNELS); } } @@ -61,7 +61,7 @@ void AudioMapping::make_default () { for (int i = 0; i < _content_channels; ++i) { - for (int j = 0; j < MAX_AUDIO_CHANNELS; ++j) { + for (int j = 0; j < MAX_DCP_AUDIO_CHANNELS; ++j) { _gain[i][j] = 0; } } @@ -117,7 +117,7 @@ AudioMapping::as_xml (xmlpp::Node* node) const node->add_child ("ContentChannels")->add_child_text (lexical_cast (_content_channels)); for (int c = 0; c < _content_channels; ++c) { - for (int d = 0; d < MAX_AUDIO_CHANNELS; ++d) { + for (int d = 0; d < MAX_DCP_AUDIO_CHANNELS; ++d) { xmlpp::Element* t = node->add_child ("Gain"); t->set_attribute ("Content", lexical_cast (c)); t->set_attribute ("DCP", lexical_cast (d)); diff --git a/src/lib/util.cc b/src/lib/util.cc index f15d2283c..62416163b 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -790,7 +790,7 @@ video_frames_to_audio_frames (VideoContent::Frame v, float audio_sample_rate, fl string audio_channel_name (int c) { - assert (MAX_AUDIO_CHANNELS == 12); + assert (MAX_DCP_AUDIO_CHANNELS == 12); /* TRANSLATORS: these are the names of audio channels; Lfe (sub) is the low-frequency enhancement channel (sub-woofer). HI is the hearing-impaired audio track and diff --git a/src/lib/util.h b/src/lib/util.h index 0bbab8305..473c90239 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -48,8 +48,8 @@ extern "C" { #undef check -/** The maximum number of audio channels that we can cope with */ -#define MAX_AUDIO_CHANNELS 12 +/** The maximum number of audio channels that we can have in a DCP */ +#define MAX_DCP_AUDIO_CHANNELS 12 #define DCPOMATIC_HELLO "Boys, you gotta learn not to talk to nuns that way" diff --git a/src/wx/audio_dialog.cc b/src/wx/audio_dialog.cc index 1bce22811..0e1316cf3 100644 --- a/src/wx/audio_dialog.cc +++ b/src/wx/audio_dialog.cc @@ -45,7 +45,7 @@ AudioDialog::AudioDialog (wxWindow* parent) side->Add (m, 1, wxALIGN_CENTER_VERTICAL | wxTOP, 16); } - for (int i = 0; i < MAX_AUDIO_CHANNELS; ++i) { + for (int i = 0; i < MAX_DCP_AUDIO_CHANNELS; ++i) { _channel_checkbox[i] = new wxCheckBox (this, wxID_ANY, std_to_wx (audio_channel_name (i))); side->Add (_channel_checkbox[i], 1, wxEXPAND | wxALL, 3); _channel_checkbox[i]->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&AudioDialog::channel_clicked, this, _1)); @@ -144,11 +144,11 @@ void AudioDialog::channel_clicked (wxCommandEvent& ev) { int c = 0; - while (c < MAX_AUDIO_CHANNELS && ev.GetEventObject() != _channel_checkbox[c]) { + while (c < MAX_DCP_AUDIO_CHANNELS && ev.GetEventObject() != _channel_checkbox[c]) { ++c; } - assert (c < MAX_AUDIO_CHANNELS); + assert (c < MAX_DCP_AUDIO_CHANNELS); _plot->set_channel_visible (c, _channel_checkbox[c]->GetValue ()); } diff --git a/src/wx/audio_dialog.h b/src/wx/audio_dialog.h index b4257057d..b27785292 100644 --- a/src/wx/audio_dialog.h +++ b/src/wx/audio_dialog.h @@ -43,7 +43,7 @@ private: boost::shared_ptr _content; AudioPlot* _plot; - wxCheckBox* _channel_checkbox[MAX_AUDIO_CHANNELS]; + wxCheckBox* _channel_checkbox[MAX_DCP_AUDIO_CHANNELS]; wxCheckBox* _type_checkbox[AudioPoint::COUNT]; wxSlider* _smoothing; boost::signals2::scoped_connection _content_changed_connection; diff --git a/src/wx/audio_mapping_view.cc b/src/wx/audio_mapping_view.cc index 7fdecb8d5..39bc0825b 100644 --- a/src/wx/audio_mapping_view.cc +++ b/src/wx/audio_mapping_view.cc @@ -111,7 +111,7 @@ AudioMappingView::AudioMappingView (wxWindow* parent) { _grid = new wxGrid (this, wxID_ANY); - _grid->CreateGrid (0, MAX_AUDIO_CHANNELS + 1); + _grid->CreateGrid (0, MAX_DCP_AUDIO_CHANNELS + 1); _grid->HideRowLabels (); _grid->DisableDragRowSize (); _grid->DisableDragColSize (); @@ -233,7 +233,7 @@ AudioMappingView::update_cells () _grid->InsertRows (0, _map.content_channels ()); for (int i = 0; i < _map.content_channels(); ++i) { - for (int j = 0; j < MAX_AUDIO_CHANNELS; ++j) { + for (int j = 0; j < MAX_DCP_AUDIO_CHANNELS; ++j) { _grid->SetCellRenderer (i, j + 1, new ValueRenderer); } } @@ -272,8 +272,8 @@ AudioMappingView::set_column_labels () _grid->SetColLabelValue (0, _("Content")); -#if MAX_AUDIO_CHANNELS != 12 -#warning AudioMappingView::set_column_labels() is expecting the wrong MAX_AUDIO_CHANNELS +#if MAX_DCP_AUDIO_CHANNELS != 12 +#warning AudioMappingView::set_column_labels() is expecting the wrong MAX_DCP_AUDIO_CHANNELS #endif if (c > 0) { diff --git a/src/wx/audio_plot.cc b/src/wx/audio_plot.cc index 124b92736..69faf127e 100644 --- a/src/wx/audio_plot.cc +++ b/src/wx/audio_plot.cc @@ -46,7 +46,7 @@ AudioPlot::AudioPlot (wxWindow* parent) SetDoubleBuffered (true); #endif - for (int i = 0; i < MAX_AUDIO_CHANNELS; ++i) { + for (int i = 0; i < MAX_DCP_AUDIO_CHANNELS; ++i) { _channel_visible[i] = false; } @@ -67,8 +67,8 @@ AudioPlot::AudioPlot (wxWindow* parent) _colours.push_back (wxColour (255, 0, 139)); _colours.push_back (wxColour (139, 0, 255)); -#if MAX_AUDIO_CHANNELS != 12 -#warning AudioPlot::AudioPlot is expecting the wrong MAX_AUDIO_CHANNELS +#if MAX_DCP_AUDIO_CHANNELS != 12 +#warning AudioPlot::AudioPlot is expecting the wrong MAX_DCP_AUDIO_CHANNELS #endif Bind (wxEVT_PAINT, boost::bind (&AudioPlot::paint, this)); @@ -81,7 +81,7 @@ AudioPlot::set_analysis (shared_ptr a) { _analysis = a; - for (int i = 0; i < MAX_AUDIO_CHANNELS; ++i) { + for (int i = 0; i < MAX_DCP_AUDIO_CHANNELS; ++i) { _channel_visible[i] = false; } @@ -168,7 +168,7 @@ AudioPlot::paint () gc->DrawText (_("Time"), data_width, metrics.height - metrics.y_origin + db_label_height / 2); if (_type_visible[AudioPoint::PEAK]) { - for (int c = 0; c < MAX_AUDIO_CHANNELS; ++c) { + for (int c = 0; c < MAX_DCP_AUDIO_CHANNELS; ++c) { wxGraphicsPath p = gc->CreatePath (); if (_channel_visible[c] && c < _analysis->channels()) { plot_peak (p, c, metrics); @@ -180,7 +180,7 @@ AudioPlot::paint () } if (_type_visible[AudioPoint::RMS]) { - for (int c = 0; c < MAX_AUDIO_CHANNELS; ++c) { + for (int c = 0; c < MAX_DCP_AUDIO_CHANNELS; ++c) { wxGraphicsPath p = gc->CreatePath (); if (_channel_visible[c] && c < _analysis->channels()) { plot_rms (p, c, metrics); diff --git a/src/wx/audio_plot.h b/src/wx/audio_plot.h index 4a1a40aa1..adf11e633 100644 --- a/src/wx/audio_plot.h +++ b/src/wx/audio_plot.h @@ -46,7 +46,7 @@ private: float y_for_linear (float, Metrics const &) const; boost::shared_ptr _analysis; - bool _channel_visible[MAX_AUDIO_CHANNELS]; + bool _channel_visible[MAX_DCP_AUDIO_CHANNELS]; bool _type_visible[AudioPoint::COUNT]; /** gain to apply in dB */ float _gain; diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc index 1131675bc..17198e8b3 100644 --- a/src/wx/film_editor.cc +++ b/src/wx/film_editor.cc @@ -214,7 +214,7 @@ FilmEditor::make_dcp_panel () _frame_rate->Append (std_to_wx (boost::lexical_cast (*i))); } - _audio_channels->SetRange (0, MAX_AUDIO_CHANNELS); + _audio_channels->SetRange (0, MAX_DCP_AUDIO_CHANNELS); _j2k_bandwidth->SetRange (1, Config::instance()->maximum_j2k_bandwidth() / 1000000); _resolution->Append (_("2K")); diff --git a/test/audio_mapping_test.cc b/test/audio_mapping_test.cc index a2a74104b..bfb53b087 100644 --- a/test/audio_mapping_test.cc +++ b/test/audio_mapping_test.cc @@ -34,7 +34,7 @@ BOOST_AUTO_TEST_CASE (audio_mapping_test) four.make_default (); for (int i = 0; i < 4; ++i) { - for (int j = 0; j < MAX_AUDIO_CHANNELS; ++j) { + for (int j = 0; j < MAX_DCP_AUDIO_CHANNELS; ++j) { BOOST_CHECK_EQUAL (four.get (i, static_cast (j)), i == j ? 1 : 0); } } diff --git a/test/silence_padding_test.cc b/test/silence_padding_test.cc index 82cbad080..d5236c144 100644 --- a/test/silence_padding_test.cc +++ b/test/silence_padding_test.cc @@ -115,7 +115,7 @@ static void test_silence_padding (int channels) BOOST_AUTO_TEST_CASE (silence_padding_test) { - for (int i = 1; i < MAX_AUDIO_CHANNELS; ++i) { + for (int i = 1; i < MAX_DCP_AUDIO_CHANNELS; ++i) { test_silence_padding (i); } } -- cgit v1.2.3 From 283770d0bdde7ba4d1f7bc4b1a7d1812bff5c835 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 9 May 2014 22:55:43 +0100 Subject: Fix crash on using content with more than 12 audio channels. Reported-by: Sumit --- ChangeLog | 2 ++ src/lib/audio_mapping.cc | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'src/lib') diff --git a/ChangeLog b/ChangeLog index f76c6ba35..21b6eec15 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2014-05-09 Carl Hetherington + * Fix crash on using content with more than 12 audio channels. + * Re-introduce ffprobe call when adding content. 2014-05-02 Carl Hetherington diff --git a/src/lib/audio_mapping.cc b/src/lib/audio_mapping.cc index 28a0fc380..301d44fa6 100644 --- a/src/lib/audio_mapping.cc +++ b/src/lib/audio_mapping.cc @@ -28,6 +28,7 @@ using std::cout; using std::make_pair; using std::pair; using std::string; +using std::min; using boost::shared_ptr; using boost::lexical_cast; using boost::dynamic_pointer_cast; @@ -71,7 +72,7 @@ AudioMapping::make_default () set (0, libdcp::CENTRE, 1); } else { /* 1:1 mapping */ - for (int i = 0; i < _content_channels; ++i) { + for (int i = 0; i < min (_content_channels, MAX_DCP_AUDIO_CHANNELS); ++i) { set (i, static_cast (i), 1); } } -- cgit v1.2.3 From 7f3a784849bb94a40480d6a5e6119eb182e93197 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 10 May 2014 13:35:55 +0100 Subject: Fix setup of the libswresample context to work with high channel counts. Reported-by: Sumit --- ChangeLog | 4 ++++ src/lib/resampler.cc | 34 +++++++++++++++------------------- 2 files changed, 19 insertions(+), 19 deletions(-) (limited to 'src/lib') diff --git a/ChangeLog b/ChangeLog index 440434d5e..e3398702e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-05-10 Carl Hetherington + + * Fix setup of the libswresample context to work with high channel counts. + 2014-05-09 Carl Hetherington * Fix crash on using content with more than 12 audio channels. diff --git a/src/lib/resampler.cc b/src/lib/resampler.cc index d897bf562..e6b1623d9 100644 --- a/src/lib/resampler.cc +++ b/src/lib/resampler.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Carl Hetherington + Copyright (C) 2013-2014 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 @@ -19,6 +19,7 @@ extern "C" { #include "libavutil/channel_layout.h" +#include "libavutil/opt.h" } #include "resampler.h" #include "audio_buffers.h" @@ -37,24 +38,19 @@ Resampler::Resampler (int in, int out, int channels) , _out_rate (out) , _channels (channels) { - /* We will be using planar float data when we call the - resampler. As far as I can see, the audio channel - layout is not necessary for our purposes; it seems - only to be used get the number of channels and - decide if rematrixing is needed. It won't be, since - input and output layouts are the same. - */ - - _swr_context = swr_alloc_set_opts ( - 0, - av_get_default_channel_layout (_channels), - AV_SAMPLE_FMT_FLTP, - _out_rate, - av_get_default_channel_layout (_channels), - AV_SAMPLE_FMT_FLTP, - _in_rate, - 0, 0 - ); + _swr_context = swr_alloc (); + + /* Sample formats */ + av_opt_set_int (_swr_context, "isf", AV_SAMPLE_FMT_FLTP, 0); + av_opt_set_int (_swr_context, "osf", AV_SAMPLE_FMT_FLTP, 0); + + /* Channel counts */ + av_opt_set_int (_swr_context, "ich", _channels, 0); + av_opt_set_int (_swr_context, "och", _channels, 0); + + /* Sample rates */ + av_opt_set_int (_swr_context, "isr", _in_rate, 0); + av_opt_set_int (_swr_context, "osr", _out_rate, 0); swr_init (_swr_context); } -- cgit v1.2.3