diff -urN kdemultimedia-3.5.5.orig/kioslave/audiocd/configure.in.in kdemultimedia-3.5.5/kioslave/audiocd/configure.in.in
--- kdemultimedia-3.5.5.orig/kioslave/audiocd/configure.in.in 2005-09-10 11:19:49 +0300
+++ kdemultimedia-3.5.5/kioslave/audiocd/configure.in.in 2007-01-16 01:01:39 +0200
@@ -5,7 +5,7 @@
have_libFLAC=no
KDE_CHECK_HEADER(FLAC/metadata.h,
[
- KDE_CHECK_LIB(FLAC,FLAC__seekable_stream_decoder_process_single,
+ KDE_CHECK_LIB(FLAC,FLAC__stream_decoder_process_single,
have_libFLAC=yes)
])
diff -urN kdemultimedia-3.5.5.orig/kioslave/audiocd/plugins/flac/audiocd_flac_encoder.kcfg kdemultimedia-3.5.5/kioslave/audiocd/plugins/flac/audiocd_flac_encoder.kcfg
--- kdemultimedia-3.5.5.orig/kioslave/audiocd/plugins/flac/audiocd_flac_encoder.kcfg 1970-01-01 03:00:00 +0300
+++ kdemultimedia-3.5.5/kioslave/audiocd/plugins/flac/audiocd_flac_encoder.kcfg 2007-01-16 01:02:33 +0200
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+ 5
+
+
+
+
+
diff -urN kdemultimedia-3.5.5.orig/kioslave/audiocd/plugins/flac/audiocd_flac_encoder.kcfgc kdemultimedia-3.5.5/kioslave/audiocd/plugins/flac/audiocd_flac_encoder.kcfgc
--- kdemultimedia-3.5.5.orig/kioslave/audiocd/plugins/flac/audiocd_flac_encoder.kcfgc 1970-01-01 03:00:00 +0300
+++ kdemultimedia-3.5.5/kioslave/audiocd/plugins/flac/audiocd_flac_encoder.kcfgc 2007-01-16 01:02:33 +0200
@@ -0,0 +1,4 @@
+# Code generation options for kconfig_compiler
+File=audiocd_flac_encoder.kcfg
+ClassName=Settings
+Singleton=true
diff -urN kdemultimedia-3.5.5.orig/kioslave/audiocd/plugins/flac/encoderflacconfig.ui kdemultimedia-3.5.5/kioslave/audiocd/plugins/flac/encoderflacconfig.ui
--- kdemultimedia-3.5.5.orig/kioslave/audiocd/plugins/flac/encoderflacconfig.ui 1970-01-01 03:00:00 +0300
+++ kdemultimedia-3.5.5/kioslave/audiocd/plugins/flac/encoderflacconfig.ui 2007-01-16 01:02:33 +0200
@@ -0,0 +1,90 @@
+
+EncoderFlacConfig
+
+
+ FlacConfig
+
+
+
+ 0
+ 0
+ 489
+ 314
+
+
+
+
+ unnamed
+
+
+
+ groupBox8
+
+
+ &Preset Compression Level
+
+
+
+ unnamed
+
+
+
+ Layout21
+
+
+
+ unnamed
+
+
+ 0
+
+
+ 6
+
+
+
+ TextLabel3_2
+
+
+ Fast
+
+
+
+
+ kcfg_compression_level
+
+
+ 0
+
+
+ 8
+
+
+ 1
+
+
+ 5
+
+
+ Horizontal
+
+
+ Below
+
+
+
+
+ TextLabel2_2
+
+
+ Best
+
+
+
+
+
+
+
+
+
+
diff -urN kdemultimedia-3.5.5.orig/kioslave/audiocd/plugins/flac/encoderflac.cpp kdemultimedia-3.5.5/kioslave/audiocd/plugins/flac/encoderflac.cpp
--- kdemultimedia-3.5.5.orig/kioslave/audiocd/plugins/flac/encoderflac.cpp 2006-01-19 18:40:33 +0200
+++ kdemultimedia-3.5.5/kioslave/audiocd/plugins/flac/encoderflac.cpp 2007-01-16 01:08:47 +0200
@@ -19,6 +19,8 @@
*/
#include "encoderflac.h"
+#include "audiocd_flac_encoder.h"
+#include "encoderflacconfig.h"
#ifdef HAVE_LIBFLAC
@@ -29,6 +31,11 @@
#include
#include
+#if !defined FLAC_API_VERSION_CURRENT || FLAC_API_VERSION_CURRENT < 8
+#define LEGACY_FLAC
+#else
+#undef LEGACY_FLAC
+#endif
extern "C"
{
@@ -38,6 +45,140 @@
}
}
+struct FLACSettings {
+ bool verify; /**< -V */
+ bool subset; /**< --no-lax */
+ bool mid_side_stereo; /**< -m */
+ bool loose_mid_side_stereo; /**< -M */
+ uint blocksize; /**< -b */
+ uint max_lpc_order; /**< -l */
+ uint qlp_coef_prec; /**< -q */
+ bool qlp_coef_prec_search; /**< -p */
+ bool exhaustive_model_search; /**< -e */
+ uint min_residual_part_order; /**< -r */
+ uint max_residual_part_order; /**< -r */
+};
+
+static FLACSettings presets[] = {
+ { /* compression level 0 */
+ false,
+ true,
+ false,
+ false,
+ 1152,
+ 0,
+ 0,
+ false,
+ false,
+ 2,
+ 2
+ },
+ { /* compression level 1 */
+ false,
+ true,
+ false,
+ true,
+ 1152,
+ 0,
+ 0,
+ false,
+ false,
+ 2,
+ 2
+ },
+ { /* compression level 2 */
+ false,
+ true,
+ true,
+ false,
+ 1152,
+ 0,
+ 0,
+ false,
+ false,
+ 0,
+ 3
+ },
+ { /* compression level 3 */
+ false,
+ true,
+ false,
+ false,
+ 4608,
+ 6,
+ 0,
+ false,
+ false,
+ 3,
+ 3
+ },
+ { /* compression level 4 */
+ false,
+ true,
+ false,
+ true,
+ 4608,
+ 8,
+ 0,
+ false,
+ false,
+ 3,
+ 3
+ },
+ { /* compression level 5 */
+ false,
+ true,
+ true,
+ false,
+ 4608,
+ 8,
+ 0,
+ false,
+ false,
+ 3,
+ 3
+ },
+ { /* compression level 6 */
+ false,
+ true,
+ true,
+ false,
+ 4608,
+ 8,
+ 0,
+ false,
+ false,
+ 0,
+ 4
+ },
+ { /* compression level 7 */
+ false,
+ true,
+ true,
+ false,
+ 4608,
+ 8,
+ 0,
+ false,
+ true,
+ 0,
+ 6
+ },
+ { /* compression level 7 */
+ false,
+ true,
+ true,
+ false,
+ 4608,
+ 12,
+ 0,
+ false,
+ true,
+ 0,
+ 6
+ }
+};
+
class EncoderFLAC::Private {
public:
@@ -45,9 +186,46 @@
FLAC__StreamMetadata** metadata;
KIO::SlaveBase* ioslave;
unsigned long data;
+
+ void loadSettings(const FLACSettings& s);
+ void loadPreset(uint preset);
};
+void EncoderFLAC::Private::loadSettings(const FLACSettings& s)
+{
+ FLAC__stream_encoder_set_verify(encoder, s.verify);
+ FLAC__stream_encoder_set_streamable_subset(encoder, s.subset);
+
+ FLAC__stream_encoder_set_do_mid_side_stereo(encoder, s.mid_side_stereo);
+ FLAC__stream_encoder_set_loose_mid_side_stereo(encoder, s.loose_mid_side_stereo);
+
+ FLAC__stream_encoder_set_blocksize(encoder, s.blocksize);
+ FLAC__stream_encoder_set_max_lpc_order(encoder, s.max_lpc_order);
+
+ FLAC__stream_encoder_set_qlp_coeff_precision(encoder, s.qlp_coef_prec);
+ FLAC__stream_encoder_set_do_qlp_coeff_prec_search(encoder, s.qlp_coef_prec_search);
+
+ FLAC__stream_encoder_set_do_exhaustive_model_search(encoder, s.exhaustive_model_search);
+ FLAC__stream_encoder_set_min_residual_partition_order(encoder, s.min_residual_part_order);
+ FLAC__stream_encoder_set_max_residual_partition_order(encoder, s.max_residual_part_order);
+}
+
+void EncoderFLAC::Private::loadPreset(uint preset)
+{
+ size_t max_preset = sizeof(presets) / sizeof(presets[0]);
+// Q_ASSERT(preset < max_preset);
+ // be more tolerant ;-)
+ if (preset >= max_preset) {
+ preset = max_preset - 1;
+ }
+ loadSettings(presets[preset]);
+}
+
+#ifdef LEGACY_FLAC
static FLAC__StreamEncoderWriteStatus WriteCallback(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data)
+#else
+static FLAC__StreamEncoderWriteStatus WriteCallback(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, unsigned samples, unsigned current_frame, void *client_data)
+#endif
{
EncoderFLAC::Private *d = (EncoderFLAC::Private*)client_data;
@@ -74,13 +252,17 @@
static FLAC__SeekableStreamEncoderSeekStatus SeekCallback(const FLAC__SeekableStreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data)
{} ; */
+#include
+#include
+
+#include
EncoderFLAC::EncoderFLAC(KIO::SlaveBase *slave) : AudioCDEncoder(slave) {
d = new Private();
d->ioslave = slave;
- d->encoder = 0;
+ d->encoder = NULL;
}
EncoderFLAC::~EncoderFLAC() {
@@ -95,9 +277,24 @@
return true;
}
-void EncoderFLAC::loadSettings() {
-// config->setGroup("FLAC");
+QWidget* EncoderFLAC::getConfigureWidget(KConfigSkeleton** manager) const {
+ (*manager) = Settings::self();
+ KGlobal::locale()->insertCatalogue("audiocd_encoder_flac");
+ EncoderFlacConfig *config = new EncoderFlacConfig();
+ config->kcfg_compression_level->setValue(5);
+ return config;
+}
+void EncoderFLAC::loadSettings() {
+ kdDebug(7117) << "EncoderFLAC::loadSettings() called"<< endl;
+ Settings *settings = Settings::self();
+ // make sure we deal with the _current_ config.
+ // unfortunately current (3.4.x) kconfig machinery doesn't
+ // guaranty that config changes will be delivered to all
+ // currently running applications. This makes hard to predict
+ // what config values will be used for pre-loaded konqueror instances
+ settings->readConfig();
+ d->loadPreset(settings->compression_level());
}
// Estimate size to be 5/8 of uncompresed size.
@@ -109,22 +306,25 @@
long EncoderFLAC::readInit(long size) {
kdDebug(7117) << "EncoderFLAC::readInit() called"<< endl;
d->data = 0;
+#ifdef LEGACY_FLAC
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
+
+ // make sure we loaded the most recent settings
+ loadSettings();
- // The options match approximely those of flac compression-level-3
- FLAC__stream_encoder_set_do_mid_side_stereo(d->encoder, true);
- FLAC__stream_encoder_set_loose_mid_side_stereo(d->encoder, true); // flac -M
- FLAC__stream_encoder_set_max_lpc_order(d->encoder, 6); // flac -l6
- 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
- FLAC__stream_encoder_set_blocksize(d->encoder, 4608);
- FLAC__stream_encoder_set_streamable_subset(d->encoder, true);
if (size > 0)
FLAC__stream_encoder_set_total_samples_estimate(d->encoder, size/4);
- FLAC__stream_encoder_init(d->encoder);
+#ifdef LEGACY_FLAC
+ if(FLAC__stream_encoder_init(d->encoder) != FLAC__STREAM_ENCODER_OK)
+ ; // really should handle an init failure
+#else
+ if(FLAC__stream_encoder_init_stream(d->encoder, WriteCallback, NULL, NULL, MetadataCallback, d) != FLAC__STREAM_ENCODER_INIT_STATUS_OK)
+ ; // really should handle an init failure
+#endif
return d->data;
}
diff -urN kdemultimedia-3.5.5.orig/kioslave/audiocd/plugins/flac/encoderflac.h kdemultimedia-3.5.5/kioslave/audiocd/plugins/flac/encoderflac.h
--- kdemultimedia-3.5.5.orig/kioslave/audiocd/plugins/flac/encoderflac.h 2005-09-10 11:19:49 +0300
+++ kdemultimedia-3.5.5/kioslave/audiocd/plugins/flac/encoderflac.h 2007-01-16 01:02:33 +0200
@@ -49,6 +49,8 @@
virtual long read(int16_t * buf, int frames);
virtual long readCleanup();
+ virtual QWidget* getConfigureWidget(KConfigSkeleton** manager) const;
+
class Private;
private:
Private * d;
diff -urN kdemultimedia-3.5.5.orig/kioslave/audiocd/plugins/flac/Makefile.am kdemultimedia-3.5.5/kioslave/audiocd/plugins/flac/Makefile.am
--- kdemultimedia-3.5.5.orig/kioslave/audiocd/plugins/flac/Makefile.am 2005-09-10 11:19:49 +0300
+++ kdemultimedia-3.5.5/kioslave/audiocd/plugins/flac/Makefile.am 2007-01-16 01:02:33 +0200
@@ -1,8 +1,10 @@
INCLUDES = -I$(top_srcdir)/libkcddb -I$(srcdir)/.. $(all_includes)
+kde_kcfg_DATA = audiocd_flac_encoder.kcfg
+
kde_module_LTLIBRARIES = libaudiocd_encoder_flac.la
-libaudiocd_encoder_flac_la_SOURCES = encoderflac.cpp
+libaudiocd_encoder_flac_la_SOURCES = audiocd_flac_encoder.kcfgc encoderflac.cpp encoderflacconfig.ui
libaudiocd_encoder_flac_la_LIBADD = $(LIBFLAC) $(LIB_KIO) ../libaudiocdplugins.la