No-Op: rename Normalizer to Intermediate
authorRobin Gareus <robin@gareus.org>
Mon, 18 Jul 2016 15:36:29 +0000 (17:36 +0200)
committerRobin Gareus <robin@gareus.org>
Mon, 18 Jul 2016 15:37:13 +0000 (17:37 +0200)
post-processing is no longer just Normalization. RealtimeExport
does Encoding - faster than realtime - using the same infrastructure.

libs/ardour/ardour/export_graph_builder.h
libs/ardour/ardour/export_handler.h
libs/ardour/export_graph_builder.cc
libs/ardour/export_handler.cc

index b692b03b3231f2e09b91ee1cabfce48e562f9870..8b6f6ceb79441cf089bdcad35b71fa81ae5625c4 100644 (file)
@@ -68,8 +68,8 @@ class LIBARDOUR_API ExportGraphBuilder
        ~ExportGraphBuilder ();
 
        int process (framecnt_t frames, bool last_cycle);
-       bool process_normalize (); // returns true when finished
-       bool will_normalize() const { return !normalizers.empty(); }
+       bool post_process (); // returns true when finished
+       bool need_postprocessing () const { return !intermediates.empty(); }
        bool realtime() const { return _realtime; }
        unsigned get_normalize_cycle_count() const;
 
@@ -147,9 +147,9 @@ class LIBARDOUR_API ExportGraphBuilder
                ShortConverterPtr short_converter;
        };
 
-       class Normalizer {
+       class Intermediate {
                                                public:
-               Normalizer (ExportGraphBuilder & parent, FileSpec const & new_config, framecnt_t max_frames);
+               Intermediate (ExportGraphBuilder & parent, FileSpec const & new_config, framecnt_t max_frames);
                FloatSinkPtr sink ();
                void add_child (FileSpec const & new_config);
                void remove_children (bool remove_out_files);
@@ -207,7 +207,7 @@ class LIBARDOUR_API ExportGraphBuilder
                ExportGraphBuilder &  parent;
                FileSpec              config;
                boost::ptr_list<SFC>  children;
-               boost::ptr_list<Normalizer> normalized_children;
+               boost::ptr_list<Intermediate> intermediate_children;
                SRConverterPtr        converter;
                framecnt_t            max_frames_out;
        };
@@ -263,7 +263,7 @@ class LIBARDOUR_API ExportGraphBuilder
 
        framecnt_t process_buffer_frames;
 
-       std::list<Normalizer *> normalizers;
+       std::list<Intermediate *> intermediates;
 
        AnalysisMap analysis_map;
 
index 80e51232d09b05bad9e931b8490a57cf31678a77..5ed1c0be1c3616b4ed51243f23b90f32d214219c 100644 (file)
@@ -139,13 +139,13 @@ class LIBARDOUR_API ExportHandler : public ExportElementFactory, public sigc::tr
        typedef std::multimap<ExportTimespanPtr, FileSpec> ConfigMap;
        ConfigMap          config_map;
 
-       bool               normalizing;
+       bool               post_processing;
 
        /* Timespan management */
 
        void start_timespan ();
        int  process_timespan (framecnt_t frames);
-       int  process_normalize ();
+       int  post_process ();
        void finish_timespan ();
 
        typedef std::pair<ConfigMap::iterator, ConfigMap::iterator> TimespanBounds;
index 96b0853122b807efcbbd92995cc31f1445a169e4..521916706cee0ca3da08514400205eb691908d49 100644 (file)
@@ -84,24 +84,24 @@ ExportGraphBuilder::process (framecnt_t frames, bool last_cycle)
 }
 
 bool
-ExportGraphBuilder::process_normalize ()
+ExportGraphBuilder::post_process ()
 {
-       for (std::list<Normalizer *>::iterator it = normalizers.begin(); it != normalizers.end(); /* ++ in loop */) {
+       for (std::list<Intermediate *>::iterator it = intermediates.begin(); it != intermediates.end(); /* ++ in loop */) {
                if ((*it)->process()) {
-                       it = normalizers.erase (it);
+                       it = intermediates.erase (it);
                } else {
                        ++it;
                }
        }
 
-       return normalizers.empty();
+       return intermediates.empty();
 }
 
 unsigned
 ExportGraphBuilder::get_normalize_cycle_count() const
 {
        unsigned max = 0;
-       for (std::list<Normalizer *>::const_iterator it = normalizers.begin(); it != normalizers.end(); ++it) {
+       for (std::list<Intermediate *>::const_iterator it = intermediates.begin(); it != intermediates.end(); ++it) {
                max = std::max(max, (*it)->get_normalize_cycle_count());
        }
        return max;
@@ -113,7 +113,7 @@ ExportGraphBuilder::reset ()
        timespan.reset();
        channel_configs.clear ();
        channels.clear ();
-       normalizers.clear ();
+       intermediates.clear ();
        analysis_map.clear();
        _realtime = false;
 }
@@ -411,9 +411,9 @@ ExportGraphBuilder::SFC::operator== (FileSpec const & other_config) const
        return config.format->sample_format() == other_config.format->sample_format();
 }
 
-/* Normalizer */
+/* Intermediate (Normalizer, TmpFile) */
 
-ExportGraphBuilder::Normalizer::Normalizer (ExportGraphBuilder & parent, FileSpec const & new_config, framecnt_t max_frames)
+ExportGraphBuilder::Intermediate::Intermediate (ExportGraphBuilder & parent, FileSpec const & new_config, framecnt_t max_frames)
        : parent (parent)
        , use_loudness (false)
        , use_peak (false)
@@ -453,9 +453,9 @@ ExportGraphBuilder::Normalizer::Normalizer (ExportGraphBuilder & parent, FileSpe
        }
 
        tmp_file->FileWritten.connect_same_thread (post_processing_connection,
-                                                  boost::bind (&Normalizer::prepare_post_processing, this));
+                                                  boost::bind (&Intermediate::prepare_post_processing, this));
        tmp_file->FileFlushed.connect_same_thread (post_processing_connection,
-                                                  boost::bind (&Normalizer::start_post_processing, this));
+                                                  boost::bind (&Intermediate::start_post_processing, this));
 
        add_child (new_config);
 
@@ -467,7 +467,7 @@ ExportGraphBuilder::Normalizer::Normalizer (ExportGraphBuilder & parent, FileSpe
 }
 
 ExportGraphBuilder::FloatSinkPtr
-ExportGraphBuilder::Normalizer::sink ()
+ExportGraphBuilder::Intermediate::sink ()
 {
        if (use_loudness) {
                return loudness_reader;
@@ -478,7 +478,7 @@ ExportGraphBuilder::Normalizer::sink ()
 }
 
 void
-ExportGraphBuilder::Normalizer::add_child (FileSpec const & new_config)
+ExportGraphBuilder::Intermediate::add_child (FileSpec const & new_config)
 {
        for (boost::ptr_list<SFC>::iterator it = children.begin(); it != children.end(); ++it) {
                if (*it == new_config) {
@@ -492,7 +492,7 @@ ExportGraphBuilder::Normalizer::add_child (FileSpec const & new_config)
 }
 
 void
-ExportGraphBuilder::Normalizer::remove_children (bool remove_out_files)
+ExportGraphBuilder::Intermediate::remove_children (bool remove_out_files)
 {
        boost::ptr_list<SFC>::iterator iter = children.begin ();
 
@@ -503,7 +503,7 @@ ExportGraphBuilder::Normalizer::remove_children (bool remove_out_files)
 }
 
 bool
-ExportGraphBuilder::Normalizer::operator== (FileSpec const & other_config) const
+ExportGraphBuilder::Intermediate::operator== (FileSpec const & other_config) const
 {
        return config.format->normalize() == other_config.format->normalize() &&
                config.format->normalize_loudness () == other_config.format->normalize_loudness() &&
@@ -516,21 +516,21 @@ ExportGraphBuilder::Normalizer::operator== (FileSpec const & other_config) const
 }
 
 unsigned
-ExportGraphBuilder::Normalizer::get_normalize_cycle_count() const
+ExportGraphBuilder::Intermediate::get_normalize_cycle_count() const
 {
        return static_cast<unsigned>(std::ceil(static_cast<float>(tmp_file->get_frames_written()) /
                                               max_frames_out));
 }
 
 bool
-ExportGraphBuilder::Normalizer::process()
+ExportGraphBuilder::Intermediate::process()
 {
        framecnt_t frames_read = tmp_file->read (*buffer);
        return frames_read != buffer->frames();
 }
 
 void
-ExportGraphBuilder::Normalizer::prepare_post_processing()
+ExportGraphBuilder::Intermediate::prepare_post_processing()
 {
        // called in sync rt-context
        float gain;
@@ -548,11 +548,11 @@ ExportGraphBuilder::Normalizer::prepare_post_processing()
                }
        }
        tmp_file->add_output (normalizer);
-       parent.normalizers.push_back (this);
+       parent.intermediates.push_back (this);
 }
 
 void
-ExportGraphBuilder::Normalizer::start_post_processing()
+ExportGraphBuilder::Intermediate::start_post_processing()
 {
        // called in disk-thread (when exporting in realtime)
        tmp_file->seek (0, SEEK_SET);
@@ -585,7 +585,7 @@ void
 ExportGraphBuilder::SRC::add_child (FileSpec const & new_config)
 {
        if (new_config.format->normalize() || parent._realtime) {
-               add_child_to_list (new_config, normalized_children);
+               add_child_to_list (new_config, intermediate_children);
        } else {
                add_child_to_list (new_config, children);
        }
@@ -602,12 +602,12 @@ ExportGraphBuilder::SRC::remove_children (bool remove_out_files)
                sfc_iter = children.erase (sfc_iter);
        }
 
-       boost::ptr_list<Normalizer>::iterator norm_iter = normalized_children.begin();
+       boost::ptr_list<Intermediate>::iterator norm_iter = intermediate_children.begin();
 
-       while (norm_iter != normalized_children.end() ) {
+       while (norm_iter != intermediate_children.end() ) {
                converter->remove_output (norm_iter->sink() );
                norm_iter->remove_children (remove_out_files);
-               norm_iter = normalized_children.erase (norm_iter);
+               norm_iter = intermediate_children.erase (norm_iter);
        }
 
 }
index 9d5e9848e624b607c1e98d8d8fe8cd5b506f421e..8e24c80967e426943b8aaf8e186a7818ca3c6934 100644 (file)
@@ -111,7 +111,7 @@ ExportHandler::ExportHandler (Session & session)
   , session (session)
   , graph_builder (new ExportGraphBuilder (session))
   , export_status (session.get_export_status ())
-  , normalizing (false)
+  , post_processing (false)
   , cue_tracknum (0)
   , cue_indexnum (0)
 {
@@ -200,7 +200,7 @@ ExportHandler::start_timespan ()
 
        /* start export */
 
-       normalizing = false;
+       post_processing = false;
        session.ProcessExport.connect_same_thread (process_connection, boost::bind (&ExportHandler::process, this, _1));
        process_position = current_timespan->get_start();
        session.start_audio_export (process_position, realtime);
@@ -232,10 +232,10 @@ ExportHandler::process (framecnt_t frames)
 {
        if (!export_status->running ()) {
                return 0;
-       } else if (normalizing) {
+       } else if (post_processing) {
                Glib::Threads::Mutex::Lock l (export_status->lock());
                if (AudioEngine::instance()->freewheeling ()) {
-                       return process_normalize ();
+                       return post_process ();
                } else {
                        // wait until we're freewheeling
                        return 0;
@@ -271,10 +271,10 @@ ExportHandler::process_timespan (framecnt_t frames)
        /* Do actual processing */
        int ret = graph_builder->process (frames_to_read, last_cycle);
 
-       /* Start normalizing if necessary */
+       /* Start post-processing/normalizing if necessary */
        if (last_cycle) {
-               normalizing = graph_builder->will_normalize ();
-               if (normalizing) {
+               post_processing = graph_builder->need_postprocessing ();
+               if (post_processing) {
                        export_status->total_normalize_cycles = graph_builder->get_normalize_cycle_count();
                        export_status->current_normalize_cycle = 0;
                } else {
@@ -287,9 +287,9 @@ ExportHandler::process_timespan (framecnt_t frames)
 }
 
 int
-ExportHandler::process_normalize ()
+ExportHandler::post_process ()
 {
-       if (graph_builder->process_normalize ()) {
+       if (graph_builder->post_process ()) {
                finish_timespan ();
                export_status->active_job = ExportStatus::Exporting;
        } else {