diff --git a/kcmaudiocd/kcmaudiocd.cpp b/kcmaudiocd/kcmaudiocd.cpp index a895e34..1c5208d 100644 --- a/kcmaudiocd/kcmaudiocd.cpp +++ b/kcmaudiocd/kcmaudiocd.cpp @@ -1,275 +1,274 @@ /* Copyright (C) 2001 Carsten Duvenhorst Copyright (C) 2005 Benjamin Meyer This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "kcmaudiocd.h" #include "audiocdplugins_version.h" #include #include #include #include #include #include #include #include -#include #include #include #include #include #include #include #include #include #include K_PLUGIN_FACTORY(Factory, registerPlugin(); ) KAudiocdModule::KAudiocdModule(QWidget *parent, const QVariantList &lst) : KCModule(parent), configChanged(false) { Q_UNUSED(lst); QVBoxLayout *box = new QVBoxLayout(this); audioConfig = new AudiocdConfig(this); box->addWidget(audioConfig); setButtons(Default|Apply); config = new KConfig( QLatin1String( "kcmaudiocdrc" )); QList encoders; AudioCDEncoder::findAllPlugins(0, encoders); foreach (AudioCDEncoder *encoder, encoders) { if (encoder->init()) { KConfigSkeleton *config = NULL; QWidget *widget = encoder->getConfigureWidget(&config); if(widget && config){ audioConfig->tabWidget->addTab(widget, i18n("%1 Encoder", encoder->type())); KConfigDialogManager *configManager = new KConfigDialogManager(widget, config); encoderSettings.append(configManager); } } } qDeleteAll(encoders); encoders.clear(); for (int i = 0; i < encoderSettings.size(); ++i) { connect( encoderSettings.at( i ),SIGNAL(widgetModified()), this, SLOT(slotModuleChanged())); } //CDDA Options connect(audioConfig->ec_enable_check,SIGNAL(clicked()),this,SLOT(slotEcEnable())); connect(audioConfig->ec_skip_check,SIGNAL(clicked()),SLOT(slotConfigChanged())); connect(audioConfig->niceLevel,SIGNAL(valueChanged(int)),SLOT(slotConfigChanged())); // File Name connect(audioConfig->fileNameLineEdit, SIGNAL(textChanged(QString)), this, SLOT(slotConfigChanged())); connect(audioConfig->albumNameLineEdit, SIGNAL(textChanged(QString)), this, SLOT(slotConfigChanged())); connect(audioConfig->fileLocationLineEdit, SIGNAL(textChanged(QString)), this, SLOT(slotConfigChanged())); connect(audioConfig->fileLocationGroupBox, SIGNAL(clicked()), this, SLOT(slotConfigChanged())); connect( audioConfig->kcfg_replaceInput, SIGNAL(textChanged(QString)), this, SLOT(updateExample()) ); connect( audioConfig->kcfg_replaceOutput, SIGNAL(textChanged(QString)), this, SLOT(updateExample()) ); connect( audioConfig->example, SIGNAL(textChanged(QString)), this, SLOT(updateExample()) ); connect( audioConfig->kcfg_replaceInput, SIGNAL(textChanged(QString)), this, SLOT(slotConfigChanged()) ); connect( audioConfig->kcfg_replaceOutput, SIGNAL(textChanged(QString)), this, SLOT(slotConfigChanged()) ); connect( audioConfig->example, SIGNAL(textChanged(QString)), this, SLOT(slotConfigChanged()) ); KAboutData *about = new KAboutData("kcmaudiocd", i18n("KDE Audio CD IO Slave"), AUDIOCDPLUGINS_VERSION_STRING); about->addAuthor(i18n("Benjamin C. Meyer"), i18n("Former Maintainer"), "ben@meyerhome.net"); about->addAuthor(i18n("Carsten Duvenhorst"), i18n("Original Author"), "duvenhorst@duvnet.de"); setAboutData(about); } KAudiocdModule::~KAudiocdModule() { delete config; } QString removeQoutes(const QString& text) { QString deqoutedString=text; QRegExp qoutedStringRegExp( QLatin1String( "^\".*\"$" )); if (qoutedStringRegExp.exactMatch(text)) { deqoutedString=text.mid(1, text.length()-2); } return deqoutedString; } bool needsQoutes(const QString& text) { QRegExp spaceAtTheBeginning( QLatin1String( "^\\s+.*$" )); QRegExp spaceAtTheEnd( QLatin1String( "^.*\\s+$" )); return (spaceAtTheBeginning.exactMatch(text) || spaceAtTheEnd.exactMatch(text)); } void KAudiocdModule::updateExample() { QString text = audioConfig->example->text(); QString deqoutedReplaceInput=removeQoutes(audioConfig->kcfg_replaceInput->text()); QString deqoutedReplaceOutput=removeQoutes(audioConfig->kcfg_replaceOutput->text()); text.replace( QRegExp(deqoutedReplaceInput), deqoutedReplaceOutput ); audioConfig->exampleOutput->setText(text); } void KAudiocdModule::defaults() { audioConfig->ec_enable_check->setChecked(true); audioConfig->ec_skip_check->setChecked(false); audioConfig->niceLevel->setValue(0); audioConfig->kcfg_replaceInput->setText(""); audioConfig->kcfg_replaceOutput->setText(""); audioConfig->example->setText(i18n("Cool artist - example audio file.wav")); for (int i = 0; i < encoderSettings.size(); ++i) { encoderSettings.at( i )->updateWidgetsDefault(); } audioConfig->fileNameLineEdit->setText("%{trackartist} - %{number} - %{title}"); audioConfig->albumNameLineEdit->setText("%{albumartist} - %{albumtitle}"); } void KAudiocdModule::save() { if (!configChanged ) return; { KConfigGroup cg(config, "CDDA"); cg.writeEntry("disable_paranoia",!(audioConfig->ec_enable_check->isChecked())); cg.writeEntry("never_skip",!(audioConfig->ec_skip_check->isChecked())); cg.writeEntry("niceLevel", audioConfig->niceLevel->value()); } { KConfigGroup cg(config, "FileName"); cg.writeEntry("file_name_template", audioConfig->fileNameLineEdit->text()); cg.writeEntry("album_name_template", audioConfig->albumNameLineEdit->text()); cg.writeEntry("show_file_location", audioConfig->fileLocationGroupBox->isChecked()); cg.writeEntry("file_location_template", audioConfig->fileLocationLineEdit->text()); cg.writeEntry("regexp_example", audioConfig->example->text()); // save qouted if required QString replaceInput=audioConfig->kcfg_replaceInput->text(); QString replaceOutput=audioConfig->kcfg_replaceOutput->text(); if (needsQoutes(replaceInput)) { replaceInput=QString("\"")+replaceInput+QString("\""); } if (needsQoutes(replaceOutput)) { replaceOutput=QString("\"")+replaceOutput+QString("\""); } cg.writeEntry("regexp_search", replaceInput); cg.writeEntry("regexp_replace", replaceOutput); } for ( int i = 0;iupdateSettings(); } config->sync(); configChanged = false; } void KAudiocdModule::load() { { KConfigGroup cg(config, "CDDA"); audioConfig->ec_enable_check->setChecked(!(cg.readEntry("disable_paranoia",false))); audioConfig->ec_skip_check->setChecked(!(cg.readEntry("never_skip",true))); audioConfig->niceLevel->setValue(cg.readEntry("niceLevel", 0)); } { KConfigGroup cg(config, "FileName"); audioConfig->fileNameLineEdit->setText(cg.readEntry("file_name_template", "%{trackartist} - %{number} - %{title}")); audioConfig->albumNameLineEdit->setText(cg.readEntry("album_name_template", "%{albumartist} - %{albumtitle}")); audioConfig->fileLocationGroupBox->setChecked(cg.readEntry("show_file_location", false)); audioConfig->fileLocationLineEdit->setText(cg.readEntry("file_location_template", QString())); audioConfig->kcfg_replaceInput->setText(cg.readEntry("regexp_search")); audioConfig->kcfg_replaceOutput->setText(cg.readEntry("regexp_replace")); audioConfig->example->setText(cg.readEntry("example", i18n("Cool artist - example audio file.wav"))); } for ( int i = 0;i updateWidgets(); } } void KAudiocdModule::slotModuleChanged() { for ( int i = 0;ihasChanged() ) { slotConfigChanged(); break; } } } void KAudiocdModule::slotConfigChanged() { configChanged = true; emit changed(true); } /* # slot for the error correction settings */ void KAudiocdModule::slotEcEnable() { if (!(audioConfig->ec_skip_check->isChecked())) { audioConfig->ec_skip_check->setChecked(true); } else { if (audioConfig->ec_skip_check->isEnabled()) { audioConfig->ec_skip_check->setChecked(false); } } slotConfigChanged(); } QString KAudiocdModule::quickHelp() const { return i18n("

Audio CDs

The Audio CD IO-Slave enables you to easily" " create wav, MP3 or Ogg Vorbis files from your audio CD-ROMs or DVDs." " The slave is invoked by typing \"audiocd:/\" in Konqueror's location" " bar. In this module, you can configure" " encoding, and device settings. Note that MP3 and Ogg" " Vorbis encoding are only available if KDE was built with a recent" " version of the LAME or Ogg Vorbis libraries."); } #include "kcmaudiocd.moc" diff --git a/plugins/flac/encoderflac.cpp b/plugins/flac/encoderflac.cpp index 65bcd75..a493c8e 100644 --- a/plugins/flac/encoderflac.cpp +++ b/plugins/flac/encoderflac.cpp @@ -1,248 +1,248 @@ /* Copyright (C) 2004 Allan Sandfeld Jensen Copyright (C) 2005 Benjamin Meyer This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "encoderflac.h" #ifdef HAVE_LIBFLAC #include #include #include #if defined(FLAC_API_VERSION_CURRENT) && FLAC_API_VERSION_CURRENT > 7 #include "audiocd_flac_encoder.h" #endif #include #include #include "audiocd_kio_debug.h" #include #include Q_LOGGING_CATEGORY(AUDIOCD_KIO_LOG, "log_audiocd_kio") extern "C" { AUDIOCDPLUGINS_EXPORT void create_audiocd_encoders(KIO::SlaveBase *slave, QList &encoders) { encoders.append(new EncoderFLAC(slave)); } } class EncoderFLAC::Private { public: FLAC__StreamEncoder *encoder; FLAC__StreamMetadata** metadata; KIO::SlaveBase* ioslave; unsigned long data; #if defined(FLAC_API_VERSION_CURRENT) && FLAC_API_VERSION_CURRENT > 7 unsigned compression_level; #endif }; static FLAC__StreamEncoderWriteStatus WriteCallback(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], #if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT <= 7 unsigned bytes, #else size_t bytes, #endif unsigned samples, unsigned current_frame, void *client_data) { Q_UNUSED(encoder) Q_UNUSED(samples) Q_UNUSED(current_frame) EncoderFLAC::Private *d = (EncoderFLAC::Private*)client_data; d->data += bytes; QByteArray output; if (bytes) { output = QByteArray::fromRawData((const char*)buffer, bytes); d->ioslave->data(output); output.clear(); } return FLAC__STREAM_ENCODER_WRITE_STATUS_OK; } static void MetadataCallback (const FLAC__StreamEncoder *encoder, const FLAC__StreamMetadata *metadata, void *client_data) { // We do not have seekable writeback so we just discard the updated metadata Q_UNUSED(encoder) Q_UNUSED(metadata) Q_UNUSED(client_data) } /* static FLAC__SeekableStreamEncoderSeekStatus SeekCallback(const FLAC__SeekableStreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data) {} ; */ EncoderFLAC::EncoderFLAC(KIO::SlaveBase *slave) : AudioCDEncoder(slave) { d = new Private(); d->ioslave = slave; d->encoder = 0; #if defined(FLAC_API_VERSION_CURRENT) && FLAC_API_VERSION_CURRENT > 7 d->compression_level = 5; #endif } EncoderFLAC::~EncoderFLAC() { if (d->encoder) FLAC__stream_encoder_delete(d->encoder); delete d; } QWidget* EncoderFLAC::getConfigureWidget(KConfigSkeleton** manager) const { #if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT <= 7 Q_UNUSED(manager); return NULL; #else (*manager) = Settings::self(); return new EncoderFLACConfig(); #endif } bool EncoderFLAC::init(){ d->encoder = FLAC__stream_encoder_new(); d->metadata = 0; d->data = 0; return true; } void EncoderFLAC::loadSettings() { #if defined(FLAC_API_VERSION_CURRENT) && FLAC_API_VERSION_CURRENT > 7 Settings *settings = Settings::self(); d->compression_level = settings->flac_compression_level(); if (d->compression_level > 8) d->compression_level = 5; #endif } -// Estimate size to be 5/8 of uncompresed size. +// Estimate size to be 5/8 of uncompressed size. unsigned long EncoderFLAC::size(long time_secs) const { long uncompressed = (time_secs * (44100*2*2)); return (uncompressed/8)*5 + 1000; } long EncoderFLAC::readInit(long size) { qCDebug(AUDIOCD_KIO_LOG) << "EncoderFLAC::readInit() called"; d->data = 0; #if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT <= 7 FLAC__stream_encoder_set_write_callback(d->encoder, WriteCallback); FLAC__stream_encoder_set_metadata_callback(d->encoder, MetadataCallback); FLAC__stream_encoder_set_client_data(d->encoder, d); #endif #if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT <= 7 // The options match approximately those of flac compression-level-5 FLAC__stream_encoder_set_do_mid_side_stereo(d->encoder, true); FLAC__stream_encoder_set_max_lpc_order(d->encoder, 8); // flac -l8 FLAC__stream_encoder_set_min_residual_partition_order(d->encoder, 3); FLAC__stream_encoder_set_max_residual_partition_order(d->encoder, 3); // flac -r3,3 #else FLAC__stream_encoder_set_compression_level(d->encoder, d->compression_level); #endif FLAC__stream_encoder_set_streamable_subset(d->encoder, true); if (size > 0) FLAC__stream_encoder_set_total_samples_estimate(d->encoder, size/4); #if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT <= 7 FLAC__stream_encoder_init(d->encoder); #else FLAC__stream_encoder_init_stream(d->encoder, WriteCallback, NULL, NULL, MetadataCallback, d); #endif return d->data; } long EncoderFLAC::read(qint16 * buf, int frames) { unsigned long olddata = d->data; FLAC__int32 *buffer = new FLAC__int32[frames*2]; for(int i=0; iencoder, buffer, frames); delete[] buffer; return d->data - olddata; } long EncoderFLAC::readCleanup() { FLAC__stream_encoder_finish(d->encoder); // FLAC__stream_encoder_delete(d->encoder); if (d->metadata) { FLAC__metadata_object_delete(d->metadata[0]); delete[] d->metadata; d->metadata = 0; } return 0; } void EncoderFLAC::fillSongInfo( KCDDB::CDInfo info, int track, const QString &comment ) { d->metadata = new FLAC__StreamMetadata*[1]; d->metadata[0] = FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT); // d->metadata[1] = FLAC__metadata_object_new(FLAC__METADATA_TYPE_PADDING); // d->metadata[2] = FLAC__metadata_object_new(FLAC__METADATA_TYPE_SEEKTABLE) typedef QPair Comment; Comment comments[7] = { Comment(QLatin1String( "TITLE" ), info.track(track-1).get(Title)), Comment(QLatin1String( "ARTIST" ), info.track(track-1).get(Artist)), Comment(QLatin1String( "ALBUM" ), info.get(Title)), Comment(QLatin1String( "GENRE" ), info.get(Genre)), Comment(QLatin1String( "TRACKNUMBER" ), QString::number(track)), Comment(QLatin1String( "COMMENT" ), comment), Comment(QLatin1String( "DATE" ), QVariant(QString::null) )}; //krazy:exclude=nullstrassign for old broken gcc if (info.get(Year).toInt() > 0) { QDateTime dt(QDate(info.get(Year).toInt(), 1, 1)); comments[6] = Comment(QLatin1String( "DATE" ), dt.toString(Qt::ISODate)); } FLAC__StreamMetadata_VorbisComment_Entry entry; QString field; QByteArray cfield; int num_comments = 0; for(int i=0; i<7; i++) { if (!comments[i].second.toString().isEmpty()) { field = comments[i].first+QLatin1Char( '=' )+comments[i].second.toString(); cfield = field.toUtf8(); entry.entry = (FLAC__byte*)qstrdup(cfield); entry.length = cfield.length(); // Insert in vorbiscomment and assign ownership of pointers to FLAC FLAC__metadata_object_vorbiscomment_insert_comment(d->metadata[0], num_comments, entry, false); num_comments++; } } FLAC__stream_encoder_set_metadata(d->encoder, d->metadata, 1); } #endif // HAVE_LIBFLAC diff --git a/plugins/flac/encoderflacconfig.ui b/plugins/flac/encoderflacconfig.ui index 20c7336..0ae91c7 100644 --- a/plugins/flac/encoderflacconfig.ui +++ b/plugins/flac/encoderflacconfig.ui @@ -1,55 +1,86 @@ EncoderFLACConfig + + + 0 + 0 + 175 + 128 + + Flac compression level - - - 5 - - - 0 - - - 8 - - - true - - + + + + + 8 + + + 5 + + + Qt::Horizontal + + + QSlider::TicksBelow + + + 1 + + + + + + + 8 + + + 5 + + + + Qt::Vertical 20 40 - - - KIntNumInput - QWidget -
knuminput.h
-
-
- + + + horizontalSlider + valueChanged(int) + kcfg_flac_compression_level + setValue(int) + + + kcfg_flac_compression_level + valueChanged(int) + horizontalSlider + setValue(int) + +
diff --git a/plugins/vorbis/audiocd_vorbis_encoder.kcfg b/plugins/vorbis/audiocd_vorbis_encoder.kcfg index 53465f6..a52ee03 100644 --- a/plugins/vorbis/audiocd_vorbis_encoder.kcfg +++ b/plugins/vorbis/audiocd_vorbis_encoder.kcfg @@ -1,84 +1,84 @@ 0 false false true true 3 - -1 + 0 10 1 0 13 13 0 13 3 0 5 diff --git a/plugins/vorbis/encodervorbis.cpp b/plugins/vorbis/encodervorbis.cpp index ff93bd8..5de699e 100644 --- a/plugins/vorbis/encodervorbis.cpp +++ b/plugins/vorbis/encodervorbis.cpp @@ -1,304 +1,304 @@ /* Copyright (C) 2000 Rik Hemsley (rikkus) Copyright (C) 2000, 2001, 2002 Michael Matz Copyright (C) 2001 Carsten Duvenhorst Copyright (C) 2001 Adrian Schroeter Copyright (C) 2003 Richard Lärkäng Copyright (C) 2003 Scott Wheeler Copyright (C) 2004, 2005 Benjamin Meyer This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "encodervorbis.h" #include "audiocd_vorbis_encoder.h" #include #include #include #include -#include #include #include #include #include extern "C" { AUDIOCDPLUGINS_EXPORT void create_audiocd_encoders(KIO::SlaveBase *slave, QList &encoders) { encoders.append(new EncoderVorbis(slave)); } } // these are the approx. bitrates for the current 5 Vorbis modes static const int vorbis_nominal_bitrates[] = { 128, 160, 192, 256, 350 }; static const int vorbis_bitrates[] = { 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 350 }; class EncoderVorbis::Private { public: ogg_stream_state os; /* take physical pages, weld into a logical stream of packets */ ogg_page og; /* one Ogg bitstream page. Vorbis packets are inside */ ogg_packet op; /* one raw packet of data for decode */ vorbis_info vi; /* struct that stores all the static vorbis bitstream settings */ vorbis_comment vc; /* struct that stores all the user comments */ vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */ vorbis_block vb; /* local working space for packet->PCM decode */ bool write_vorbis_comments; long vorbis_bitrate_lower; long vorbis_bitrate_upper; long vorbis_bitrate_nominal; int vorbis_encode_method; double vorbis_quality; int vorbis_bitrate; }; EncoderVorbis::EncoderVorbis(KIO::SlaveBase *slave) : AudioCDEncoder(slave) { d = new Private(); } EncoderVorbis::~EncoderVorbis(){ vorbis_info_clear(&d->vi); vorbis_comment_clear(&d->vc); delete d; } QWidget* EncoderVorbis::getConfigureWidget(KConfigSkeleton** manager) const { (*manager) = Settings::self(); EncoderVorbisConfig *config = new EncoderVorbisConfig(); - config->kcfg_vorbis_quality->setRange(0.0, 10.0, 0.2, true); + config->kcfg_vorbis_quality->setRange(0.0, 10.0); + config->kcfg_vorbis_quality->setSingleStep(0.1); config->vorbis_bitrate_settings->hide(); return config; } bool EncoderVorbis::init(){ vorbis_info_init(&d->vi); vorbis_comment_init(&d->vc); vorbis_comment_add_tag ( &d->vc, const_cast("kde-encoder"), const_cast("kio_audiocd") ); return true; } void EncoderVorbis::loadSettings(){ Settings *settings = Settings::self(); d->vorbis_encode_method = settings->vorbis_enc_method(); d->vorbis_quality = settings->vorbis_quality(); if ( settings->set_vorbis_min_br()) { d->vorbis_bitrate_lower = vorbis_bitrates[settings->vorbis_min_br()] * 1000; } else { d->vorbis_bitrate_lower = -1; } if ( settings->set_vorbis_max_br() ) { d->vorbis_bitrate_upper = vorbis_bitrates[settings->vorbis_max_br()] * 1000; } else { d->vorbis_bitrate_upper = -1; } // this is such a hack! if ( d->vorbis_bitrate_upper != -1 && d->vorbis_bitrate_lower != -1 ) { d->vorbis_bitrate = 104000; // empirically determined ...?! } else { d->vorbis_bitrate = 160 * 1000; } if ( settings->set_vorbis_nominal_br() ) { d->vorbis_bitrate_nominal = vorbis_nominal_bitrates[settings->vorbis_nominal_br()] * 1000; d->vorbis_bitrate = d->vorbis_bitrate_nominal; } else { d->vorbis_bitrate_nominal = -1; } d->write_vorbis_comments = settings->vorbis_comments(); // Now that we have read in the settings apply them to the encoder lib switch (d->vorbis_encode_method) { case 0: vorbis_encode_init_vbr(&d->vi, 2, 44100, d->vorbis_quality/10.0); break; case 1: vorbis_encode_init(&d->vi, 2, 44100, d->vorbis_bitrate_upper, d->vorbis_bitrate_nominal, d->vorbis_bitrate_lower); break; } } long EncoderVorbis::flush_vorbis(void) { long processed(0); while(vorbis_analysis_blockout(&d->vd,&d->vb)==1) { vorbis_analysis(&d->vb,NULL); /* Non-ancient case. */ vorbis_bitrate_addblock(&d->vb); while(vorbis_bitrate_flushpacket(&d->vd, &d->op)) { ogg_stream_packetin(&d->os,&d->op); while(int result=ogg_stream_pageout(&d->os,&d->og)) { if (!result) break; char * oggheader = reinterpret_cast(d->og.header); char * oggbody = reinterpret_cast(d->og.body); if (d->og.header_len) { ioslave->data(QByteArray::fromRawData(oggheader, d->og.header_len)); } if (d->og.body_len) { ioslave->data(QByteArray::fromRawData(oggbody, d->og.body_len)); } processed += d->og.header_len + d->og.body_len; } } } return processed; } unsigned long EncoderVorbis::size(long time_secs) const { long vorbis_size; switch (d->vorbis_encode_method) { case 0: // quality based encoding { // Estimated numbers based on the Vorbis FAQ: // http://www.xiph.org/archives/vorbis-faq/200203/0030.html static long vorbis_q_bitrate[] = { 60, 74, 86, 106, 120, 152, 183, 207, 239, 309, 440 }; long quality = static_cast(d->vorbis_quality); if (quality < 0 || quality > 10) quality = 3; vorbis_size = (time_secs * vorbis_q_bitrate[quality] * 1000) / 8; break; } default: // bitrate based encoding vorbis_size = (time_secs * d->vorbis_bitrate/8); break; } return vorbis_size; } const char * EncoderVorbis::mimeType() const{ return "audio/x-vorbis+ogg"; } long EncoderVorbis::readInit(long /*size*/){ ogg_packet header; ogg_packet header_comm; ogg_packet header_code; vorbis_analysis_init(&d->vd,&d->vi); vorbis_block_init(&d->vd,&d->vb); qsrand(time(NULL)); ogg_stream_init(&d->os,qrand()); vorbis_analysis_headerout(&d->vd,&d->vc,&header,&header_comm,&header_code); ogg_stream_packetin(&d->os,&header); ogg_stream_packetin(&d->os,&header_comm); ogg_stream_packetin(&d->os,&header_code); while (int result = ogg_stream_flush(&d->os,&d->og)) { if (!result) break; char * oggheader = reinterpret_cast(d->og.header); char * oggbody = reinterpret_cast(d->og.body); if (d->og.header_len) { ioslave->data(QByteArray::fromRawData(oggheader, d->og.header_len)); } if (d->og.body_len) { ioslave->data(QByteArray::fromRawData(oggbody, d->og.body_len)); } } return 0; } long EncoderVorbis::read(qint16 * buf, int frames){ int i; float **buffer=vorbis_analysis_buffer(&d->vd,frames); /* uninterleave samples */ for(i=0;ivd,i); return flush_vorbis(); } long EncoderVorbis::readCleanup(){ // send end-of-stream and flush the encoder vorbis_analysis_wrote(&d->vd,0); long processed = flush_vorbis(); ogg_stream_clear(&d->os); vorbis_block_clear(&d->vb); vorbis_dsp_clear(&d->vd); vorbis_info_clear(&d->vi); return processed; } void EncoderVorbis::fillSongInfo( KCDDB::CDInfo info, int track, const QString &comment ) { if( !d->write_vorbis_comments ) return; typedef QPair CommentField; QList commentFields; commentFields.append(CommentField("TITLE", info.track(track-1).get(Title))); commentFields.append(CommentField("ARTIST", info.track(track-1).get(Artist))); commentFields.append(CommentField("ALBUM", info.get(Title))); commentFields.append(CommentField("GENRE", info.get(Genre))); commentFields.append(CommentField("TRACKNUMBER", QString::number(track))); commentFields.append(CommentField("COMMENT", comment)); if (info.get(Year).toInt() > 0) { QDateTime dt( QDate(info.get(Year).toInt(), 1, 1) ); commentFields.append(CommentField("DATE",QLatin1String( dt.toString(Qt::ISODate).toUtf8().data() ))); } for(QList::iterator it = commentFields.begin(); it != commentFields.end(); ++it) { // if the value is not empty if(!(*it).second.toString().isEmpty()) { char *key = qstrdup((*it).first); char *value = qstrdup((*it).second.toString().toUtf8().data()); vorbis_comment_add_tag(&d->vc, key, value); delete [] key; delete [] value; } } } diff --git a/plugins/vorbis/encodervorbisconfig.ui b/plugins/vorbis/encodervorbisconfig.ui index 060fd82..ab674c9 100644 --- a/plugins/vorbis/encodervorbisconfig.ui +++ b/plugins/vorbis/encodervorbisconfig.ui @@ -1,379 +1,369 @@ EncoderVorbisConfig 0 0 375 408 &Encoding Method Quality based true Bitrate based true Vorbis Bitrate Settings false 1 32 kbps 40 kbps 48 kbps 56 kbps 64 kbps 80 kbps 96 kbps 112 kbps 128 kbps 160 kbps 192 kbps 224 kbps 256 kbps 350 kbps false 13 32 kbps 40 kbps 48 kbps 56 kbps 64 kbps 80 kbps 96 kbps 112 kbps 128 kbps 160 kbps 192 kbps 224 kbps 256 kbps 350 kbps true M&inimal bitrate: true Ma&ximal bitrate: 1 128 kbps 160 kbps 192 kbps 256 kbps 350 kbps A&verage bitrate: true Vorbis &Quality Setting You can set the quality of the encoded stream here. A higher value implies a higher quality but encodes slower. - + 0 - 0 + 0.0 - 10000 + 10.0 1 Higher is better but slower Options true Add &track information Add a description of the song to the file header. This makes it easy for the user to get advanced song information shown by his media player. You can get this information automatically via the Internet. Look at the <i>"CDDB Retrieval"</i> control module for details. 20 51 Expanding Vertical - - - KDoubleNumInput -
knuminput.h
- 0 -
-
vorbis_enc_quality kcfg_set_vorbis_min_br kcfg_set_vorbis_max_br kcfg_set_vorbis_nominal_br kcfg_vorbis_min_br kcfg_vorbis_max_br kcfg_vorbis_nominal_br kcfg_vorbis_quality kcfg_vorbis_comments - - knuminput.h - vorbis_enc_bitrate toggled(bool) vorbis_bitrate_settings setShown(bool) vorbis_enc_quality toggled(bool) vorbis_quality_settings setShown(bool)