Prepare export-format codec-quality setting
authorRobin Gareus <robin@gareus.org>
Mon, 19 Nov 2018 21:26:16 +0000 (22:26 +0100)
committerRobin Gareus <robin@gareus.org>
Mon, 19 Nov 2018 21:26:16 +0000 (22:26 +0100)
libs/ardour/ardour/export_format_specification.h
libs/ardour/export_format_specification.cc
libs/ardour/export_graph_builder.cc

index 4fdb16961a520c85c3c5e6ffbf5d5cd2d7b111fc..ecbb8421ca7724b8942a21f33cb4e9be809d43c8 100644 (file)
@@ -103,6 +103,7 @@ class LIBARDOUR_API ExportFormatSpecification : public ExportFormatBase {
        void set_soundcloud_upload (bool yn) { _soundcloud_upload = yn; }
        void set_command (std::string command) { _command = command; }
        void set_analyse (bool yn) { _analyse = yn; }
+       void set_codec_quality (int q) { _codec_quality = q; }
 
        void set_silence_beginning (AnyTime const & value) { _silence_beginning = value; }
        void set_silence_end (AnyTime const & value) { _silence_end = value; }
@@ -171,6 +172,7 @@ class LIBARDOUR_API ExportFormatSpecification : public ExportFormatBase {
        bool soundcloud_upload() const { return _soundcloud_upload; }
        std::string command() const { return _command; }
        bool analyse() const { return _analyse; }
+       int  codec_quality() const { return _codec_quality; }
 
        bool tag () const { return _tag && supports_tagging; }
 
@@ -228,6 +230,7 @@ class LIBARDOUR_API ExportFormatSpecification : public ExportFormatBase {
 
        std::string     _command;
        bool            _analyse;
+       int             _codec_quality;
 
        /* serialization helpers */
 
index a41c2a085affd5721241b509f3724596c27192f8..17ce59933dc96631624e97ba51152331f2dcf4eb 100644 (file)
@@ -156,6 +156,7 @@ ExportFormatSpecification::ExportFormatSpecification (Session & s)
        , _soundcloud_upload (false)
        , _command ("")
        , _analyse (true)
+       , _codec_quality (-3)
 {
        format_ids.insert (F_None);
        endiannesses.insert (E_FileDefault);
@@ -191,6 +192,7 @@ ExportFormatSpecification::ExportFormatSpecification (Session & s, XMLNode const
        , _soundcloud_upload (false)
        , _command ("")
        , _analyse (true)
+       , _codec_quality (-3)
 {
        _silence_beginning.type = Time::Timecode;
        _silence_end.type = Time::Timecode;
@@ -205,6 +207,7 @@ ExportFormatSpecification::ExportFormatSpecification (ExportFormatSpecification
        , _silence_end (other.session)
        , _soundcloud_upload (false)
        , _analyse (other._analyse)
+       , _codec_quality (other._codec_quality)
 {
        if (modify_name) {
                set_name (other.name() + " (copy)");
@@ -277,6 +280,9 @@ ExportFormatSpecification::get_state ()
        node = root->add_child ("SRCQuality");
        node->set_property ("quality", src_quality());
 
+       node = root->add_child ("CodecQuality");
+       node->set_property ("quality", codec_quality());
+
        XMLNode * enc_opts = root->add_child ("EncodingOptions");
 
        add_option (enc_opts, "sample-format", to_string(sample_format()));
@@ -384,6 +390,10 @@ ExportFormatSpecification::set_state (const XMLNode & root)
                child->get_property ("quality", _src_quality);
        }
 
+       if ((child = root.child ("CodecQuality"))) {
+               child->get_property ("quality", _codec_quality);
+       }
+
        /* Encoding options */
 
        if ((child = root.child ("EncodingOptions"))) {
index b2eaafce21dc7aa3004110772c57ffa4af6f9702..e190791291b8f5288fae3c2214760b5b15d26f36 100644 (file)
@@ -322,7 +322,7 @@ ExportGraphBuilder::Encoder::init_writer (boost::shared_ptr<AudioGrapher::CmdPip
                throw ExportFailed ("External encoder (ffmpeg) is not available.");
        }
 
-       int quality = 3; // TODO get from config.format
+       int quality = config.format->codec_quality ();
 
        int a=0;
        char **argp = (char**) calloc (100, sizeof(char*));
@@ -342,9 +342,9 @@ ExportGraphBuilder::Encoder::init_writer (boost::shared_ptr<AudioGrapher::CmdPip
        argp[a++] = strdup ("pipe:0");
 
        argp[a++] = strdup ("-y");
-       if (quality < 10) {
+       if (quality <0) {
                /* variable rate, lower is better */
-               snprintf (tmp, sizeof(tmp), "%d", quality);
+               snprintf (tmp, sizeof(tmp), "%d", -quality);
                argp[a++] = strdup ("-q:a"); argp[a++] = strdup (tmp);
        } else {
                /* fixed bitrate, higher is better */