diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-02-25 00:11:49 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-02-25 00:11:49 +0000 |
| commit | 040a227d300033f8a103dc6eb67847286131d9b7 (patch) | |
| tree | 54093eaad6186817d1ee744d3f299f93ea49b475 /src/lib | |
| parent | dcd968d6d64d645816af0efbcd2f928128c95b9f (diff) | |
Some tidying up, add channel selector to Audio dialog.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/analyse_audio_job.cc | 14 | ||||
| -rw-r--r-- | src/lib/analyse_audio_job.h | 1 | ||||
| -rw-r--r-- | src/lib/ffmpeg_decoder.cc | 2 | ||||
| -rw-r--r-- | src/lib/util.cc | 20 | ||||
| -rw-r--r-- | src/lib/util.h | 1 |
5 files changed, 27 insertions, 11 deletions
diff --git a/src/lib/analyse_audio_job.cc b/src/lib/analyse_audio_job.cc index 190d2a5d9..fb5f2868f 100644 --- a/src/lib/analyse_audio_job.cc +++ b/src/lib/analyse_audio_job.cc @@ -27,13 +27,13 @@ using std::string; using std::max; +using std::cout; using boost::shared_ptr; -int const AnalyseAudioJob::_num_points = 1024; +int const AnalyseAudioJob::_num_points = 128; AnalyseAudioJob::AnalyseAudioJob (shared_ptr<Film> f) : Job (f) - , _done_for_this_point (0) , _done (0) , _samples_per_point (1) { @@ -94,20 +94,16 @@ AnalyseAudioJob::audio (shared_ptr<AudioBuffers> b) _current[j][AudioPoint::RMS] += pow (s, 2); _current[j][AudioPoint::PEAK] = max (_current[j][AudioPoint::PEAK], fabsf (s)); - if (_done_for_this_point == _samples_per_point) { + if ((_done % _samples_per_point) == 0) { _current[j][AudioPoint::RMS] = 20 * log10 (sqrt (_current[j][AudioPoint::RMS] / _samples_per_point)); _current[j][AudioPoint::PEAK] = 20 * log10 (_current[j][AudioPoint::PEAK]); - _analysis->add_point (j, _current[j]); - _done_for_this_point = 0; _current[j] = AudioPoint (); } } - - ++_done_for_this_point; - } - _done += b->frames (); + ++_done; + } } diff --git a/src/lib/analyse_audio_job.h b/src/lib/analyse_audio_job.h index 1e7229ce6..dc1e073ee 100644 --- a/src/lib/analyse_audio_job.h +++ b/src/lib/analyse_audio_job.h @@ -33,7 +33,6 @@ public: private: void audio (boost::shared_ptr<AudioBuffers>); - int64_t _done_for_this_point; int64_t _done; int64_t _samples_per_point; std::vector<AudioPoint> _current; diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 58c7317ac..148764162 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -197,7 +197,7 @@ FFmpegDecoder::setup_audio () void FFmpegDecoder::setup_subtitle () { - if (!_subtitle_stream) { + if (!_subtitle_stream || _subtitle_stream->id() >= _format_context->nb_streams) { return; } diff --git a/src/lib/util.cc b/src/lib/util.cc index 4ee304600..f807bf329 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -898,3 +898,23 @@ cpu_info () return info; } + +string +audio_channel_name (int c) +{ + assert (MAX_AUDIO_CHANNELS == 6); + + /* TRANSLATORS: these are the names of audio channels; Lfe (sub) is the low-frequency + enhancement channel (sub-woofer)./ + */ + string const channels[] = { + "Left", + "Right", + "Centre", + "Lfe (sub)", + "Left surround", + "Right surround", + }; + + return channels[c]; +} diff --git a/src/lib/util.h b/src/lib/util.h index 87735ea8e..b76aead41 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -57,6 +57,7 @@ extern std::vector<std::string> split_at_spaces_considering_quotes (std::string) extern std::string md5_digest (std::string); extern std::string md5_digest (void const *, int); extern void ensure_ui_thread (); +extern std::string audio_channel_name (int); typedef int SourceFrame; |
