13
0

No-Op: rename Normalizer to Intermediate

post-processing is no longer just Normalization. RealtimeExport
does Encoding - faster than realtime - using the same infrastructure.
This commit is contained in:
Robin Gareus 2016-07-18 17:36:29 +02:00
parent ee2d7a2d0c
commit b64dcac17e
4 changed files with 40 additions and 40 deletions

View 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;

View 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;

View 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);
}
}

View 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 {