From 4b5333a7215679a43769ccb83f83812818171b53 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sat, 25 Mar 2023 06:40:28 +0100 Subject: [PATCH] Disambiguate export formats with different encoder settings Disambiguate export formats with different encoder qualities, sample-formats or settings (wav/bwav). This allows to export multipe mp3 with different bitrates. --- .../ardour/export_format_specification.h | 1 + libs/ardour/export_format_specification.cc | 21 +++++++++++++++++++ libs/ardour/export_graph_builder.cc | 20 ++++++++++++++++-- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/libs/ardour/ardour/export_format_specification.h b/libs/ardour/ardour/export_format_specification.h index c740b259de..b32e6da2dc 100644 --- a/libs/ardour/ardour/export_format_specification.h +++ b/libs/ardour/ardour/export_format_specification.h @@ -80,6 +80,7 @@ class LIBARDOUR_API ExportFormatSpecification : public ExportFormatBase { void set_format (std::shared_ptr format); bool is_format (std::shared_ptr format) const; + bool operator== (ExportFormatSpecification const&) const; void set_name (std::string const & name) { _name = name; } diff --git a/libs/ardour/export_format_specification.cc b/libs/ardour/export_format_specification.cc index b27dff29d3..606d8655bf 100644 --- a/libs/ardour/export_format_specification.cc +++ b/libs/ardour/export_format_specification.cc @@ -581,6 +581,27 @@ ExportFormatSpecification::is_complete () const return true; } +bool ExportFormatSpecification::operator== (ExportFormatSpecification const& other) const +{ + const int a = format_id() | sample_format() | endianness(); + const int b = other.format_id() | other.sample_format() | other.endianness(); + if (a != b) { + return false; + } + + /* BWF has the same format id with wav, so we need to check this. */ + if (has_broadcast_info () != other.has_broadcast_info ()) { + return false; + } + + if (_has_codec_quality && other._has_codec_quality) { + if (_codec_quality != other._codec_quality) { + return false; + } + } + return true; +} + bool ExportFormatSpecification::is_format (std::shared_ptr format) const { diff --git a/libs/ardour/export_graph_builder.cc b/libs/ardour/export_graph_builder.cc index fb93fdd0ae..59fb96f9e0 100644 --- a/libs/ardour/export_graph_builder.cc +++ b/libs/ardour/export_graph_builder.cc @@ -327,7 +327,9 @@ ExportGraphBuilder::Encoder::destroy_writer (bool delete_out_file) bool ExportGraphBuilder::Encoder::operator== (FileSpec const & other_config) const { - return get_real_format (config) == get_real_format (other_config); + ExportFormatSpecification const& a = *config.format; + ExportFormatSpecification const& b = *other_config.format; + return a == b; } int @@ -649,7 +651,21 @@ ExportGraphBuilder::SFC::operator== (FileSpec const& other_config) const ExportFormatSpecification const& a = *config.format; ExportFormatSpecification const& b = *other_config.format; - bool id = a.sample_format() == b.sample_format(); + bool id; + if (a.analyse () || b.analyse ()) { + /* Show dedicated analysis result for files with different + * quality or wav/bwav. This adds a dedicated SFC for each + * format, rater than only running dedicated Encoders as + * childs of of the same SFC. + * + * TODO: separate normalizer, and limiter into a dedicated + * graph-node, so that it can be shared. + */ + id = a == b; + } else { + /* delegate disambiguation to Encoder::operator== */ + id = a.sample_format() == b.sample_format(); + } if (a.normalize_loudness () == b.normalize_loudness ()) { id &= a.normalize_lufs () == b.normalize_lufs ();