ext/wavpack/gstwavpackenc.*: Fixup docs, make the bitrate property an int as it should be and allow to set the differ...

Original commit message from CVS:
* ext/wavpack/gstwavpackenc.c: (gst_wavpack_enc_class_init),
(gst_wavpack_enc_init), (gst_wavpack_enc_set_wp_config),
(gst_wavpack_enc_set_property), (gst_wavpack_enc_get_property):
* ext/wavpack/gstwavpackenc.h:
Fixup docs, make the bitrate property an int as it should be and
allow to set the different extra processing modes instead of only
allowing none and the default one.
This commit is contained in:
Sebastian Dröge 2007-05-21 11:17:21 +00:00
parent 127d233104
commit 5947345f9a
2 changed files with 40 additions and 32 deletions

View file

@ -31,7 +31,8 @@
* <programlisting> * <programlisting>
* gst-launch audiotestsrc num-buffers=500 ! audioconvert ! wavpackenc ! filesink location=sinewave.wv * gst-launch audiotestsrc num-buffers=500 ! audioconvert ! wavpackenc ! filesink location=sinewave.wv
* </programlisting> * </programlisting>
* This pipeline encodes audio from audiotestsrc into a Wavpack file. * This pipeline encodes audio from audiotestsrc into a Wavpack file. The audioconvert element is needed
* as the Wavpack encoder only accepts input with 32 bit width (and every depth between 1 and 32 bits).
* </para> * </para>
* <para> * <para>
* <programlisting> * <programlisting>
@ -269,18 +270,18 @@ gst_wavpack_enc_class_init (GstWavpackEncClass * klass)
GST_TYPE_WAVPACK_ENC_MODE, GST_WAVPACK_ENC_MODE_DEFAULT, GST_TYPE_WAVPACK_ENC_MODE, GST_WAVPACK_ENC_MODE_DEFAULT,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_BITRATE, g_object_class_install_property (gobject_class, ARG_BITRATE,
g_param_spec_double ("bitrate", "Bitrate", g_param_spec_int ("bitrate", "Bitrate",
"Try to encode with this average bitrate (bits/sec). " "Try to encode with this average bitrate (bits/sec). "
"This enables lossy encoding! A value smaller than 24000.0 disables this.", "This enables lossy encoding, values smaller than 24000 disable it again.",
0.0, 9600000.0, 0.0, G_PARAM_READWRITE)); 0, 9600000, 0, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_BITSPERSAMPLE, g_object_class_install_property (gobject_class, ARG_BITSPERSAMPLE,
g_param_spec_double ("bits-per-sample", "Bits per sample", g_param_spec_double ("bits-per-sample", "Bits per sample",
"Try to encode with this amount of bits per sample. " "Try to encode with this amount of bits per sample. "
"This enables lossy encoding! A value smaller than 2.0 disables this.", "This enables lossy encoding, values smaller than 2.0 disable it again.",
0.0, 24.0, 0.0, G_PARAM_READWRITE)); 0.0, 24.0, 0.0, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_CORRECTION_MODE, g_object_class_install_property (gobject_class, ARG_CORRECTION_MODE,
g_param_spec_enum ("correction-mode", "Correction file mode", g_param_spec_enum ("correction-mode", "Correction stream mode",
"Use this mode for correction file creation. Only works in lossy mode!", "Use this mode for the correction stream. Only works in lossy mode!",
GST_TYPE_WAVPACK_ENC_CORRECTION_MODE, GST_WAVPACK_CORRECTION_MODE_OFF, GST_TYPE_WAVPACK_ENC_CORRECTION_MODE, GST_WAVPACK_CORRECTION_MODE_OFF,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_MD5, g_object_class_install_property (gobject_class, ARG_MD5,
@ -288,8 +289,9 @@ gst_wavpack_enc_class_init (GstWavpackEncClass * klass)
"Store MD5 hash of raw samples within the file.", FALSE, "Store MD5 hash of raw samples within the file.", FALSE,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_EXTRA_PROCESSING, g_object_class_install_property (gobject_class, ARG_EXTRA_PROCESSING,
g_param_spec_boolean ("extra-processing", "Extra processing", g_param_spec_int ("extra-processing", "Extra processing",
"Extra encode processing.", FALSE, G_PARAM_READWRITE)); "Use better but slower filters for better compression/quality.",
0, 6, 0, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_JOINT_STEREO_MODE, g_object_class_install_property (gobject_class, ARG_JOINT_STEREO_MODE,
g_param_spec_enum ("joint-stereo-mode", "Joint-Stereo mode", g_param_spec_enum ("joint-stereo-mode", "Joint-Stereo mode",
"Use this joint-stereo mode.", GST_TYPE_WAVPACK_ENC_JOINT_STEREO_MODE, "Use this joint-stereo mode.", GST_TYPE_WAVPACK_ENC_JOINT_STEREO_MODE,
@ -359,10 +361,11 @@ gst_wavpack_enc_init (GstWavpackEnc * enc, GstWavpackEncClass * gclass)
/* set default values of params */ /* set default values of params */
enc->mode = GST_WAVPACK_ENC_MODE_DEFAULT; enc->mode = GST_WAVPACK_ENC_MODE_DEFAULT;
enc->bitrate = 0.0; enc->bitrate = 0;
enc->bps = 0.0;
enc->correction_mode = GST_WAVPACK_CORRECTION_MODE_OFF; enc->correction_mode = GST_WAVPACK_CORRECTION_MODE_OFF;
enc->md5 = FALSE; enc->md5 = FALSE;
enc->extra_processing = FALSE; enc->extra_processing = 0;
enc->joint_stereo_mode = GST_WAVPACK_JS_MODE_AUTO; enc->joint_stereo_mode = GST_WAVPACK_JS_MODE_AUTO;
} }
@ -450,14 +453,13 @@ gst_wavpack_enc_set_wp_config (GstWavpackEnc * enc)
} }
/* Bitrate, enables lossy mode */ /* Bitrate, enables lossy mode */
if (enc->bitrate >= 2.0) { if (enc->bitrate) {
enc->wp_config->flags |= CONFIG_HYBRID_FLAG; enc->wp_config->flags |= CONFIG_HYBRID_FLAG;
if (enc->bitrate >= 24000.0) { enc->wp_config->flags |= CONFIG_BITRATE_KBPS;
enc->wp_config->bitrate = enc->bitrate / 1000.0; enc->wp_config->bitrate = enc->bitrate / 1000.0;
enc->wp_config->flags |= CONFIG_BITRATE_KBPS; } else if (enc->bps) {
} else { enc->wp_config->flags |= CONFIG_HYBRID_FLAG;
enc->wp_config->bitrate = enc->bitrate; enc->wp_config->bitrate = enc->bps;
}
} }
/* Correction Mode, only in lossy mode */ /* Correction Mode, only in lossy mode */
@ -505,6 +507,7 @@ gst_wavpack_enc_set_wp_config (GstWavpackEnc * enc)
/* Extra encode processing */ /* Extra encode processing */
if (enc->extra_processing) { if (enc->extra_processing) {
enc->wp_config->flags |= CONFIG_EXTRA_MODE; enc->wp_config->flags |= CONFIG_EXTRA_MODE;
enc->wp_config->xmode = enc->extra_processing;
} }
/* Joint stereo mode */ /* Joint stereo mode */
@ -808,12 +811,14 @@ gst_wavpack_enc_set_property (GObject * object, guint prop_id,
enc->mode = g_value_get_enum (value); enc->mode = g_value_get_enum (value);
break; break;
case ARG_BITRATE:{ case ARG_BITRATE:{
gdouble val = g_value_get_double (value); gint val = g_value_get_int (value);
if ((val >= 24000.0) && (val <= 9600000.0)) { if ((val >= 24000) && (val <= 9600000)) {
enc->bitrate = val; enc->bitrate = val;
enc->bps = 0.0;
} else { } else {
enc->bitrate = 0.0; enc->bitrate = 0;
enc->bps = 0.0;
} }
break; break;
} }
@ -821,9 +826,11 @@ gst_wavpack_enc_set_property (GObject * object, guint prop_id,
gdouble val = g_value_get_double (value); gdouble val = g_value_get_double (value);
if ((val >= 2.0) && (val <= 24.0)) { if ((val >= 2.0) && (val <= 24.0)) {
enc->bitrate = val; enc->bps = val;
enc->bitrate = 0;
} else { } else {
enc->bitrate = 0.0; enc->bps = 0.0;
enc->bitrate = 0;
} }
break; break;
} }
@ -834,7 +841,7 @@ gst_wavpack_enc_set_property (GObject * object, guint prop_id,
enc->md5 = g_value_get_boolean (value); enc->md5 = g_value_get_boolean (value);
break; break;
case ARG_EXTRA_PROCESSING: case ARG_EXTRA_PROCESSING:
enc->extra_processing = g_value_get_boolean (value); enc->extra_processing = g_value_get_int (value);
break; break;
case ARG_JOINT_STEREO_MODE: case ARG_JOINT_STEREO_MODE:
enc->joint_stereo_mode = g_value_get_enum (value); enc->joint_stereo_mode = g_value_get_enum (value);
@ -856,15 +863,15 @@ gst_wavpack_enc_get_property (GObject * object, guint prop_id, GValue * value,
g_value_set_enum (value, enc->mode); g_value_set_enum (value, enc->mode);
break; break;
case ARG_BITRATE: case ARG_BITRATE:
if (enc->bitrate >= 24000.0) { if (enc->bps == 0.0) {
g_value_set_double (value, enc->bitrate); g_value_set_int (value, enc->bitrate);
} else { } else {
g_value_set_double (value, 0.0); g_value_set_int (value, 0);
} }
break; break;
case ARG_BITSPERSAMPLE: case ARG_BITSPERSAMPLE:
if (enc->bitrate <= 24.0) { if (enc->bitrate == 0) {
g_value_set_double (value, enc->bitrate); g_value_set_double (value, enc->bps);
} else { } else {
g_value_set_double (value, 0.0); g_value_set_double (value, 0.0);
} }
@ -876,7 +883,7 @@ gst_wavpack_enc_get_property (GObject * object, guint prop_id, GValue * value,
g_value_set_boolean (value, enc->md5); g_value_set_boolean (value, enc->md5);
break; break;
case ARG_EXTRA_PROCESSING: case ARG_EXTRA_PROCESSING:
g_value_set_boolean (value, enc->extra_processing); g_value_set_int (value, enc->extra_processing);
break; break;
case ARG_JOINT_STEREO_MODE: case ARG_JOINT_STEREO_MODE:
g_value_set_enum (value, enc->joint_stereo_mode); g_value_set_enum (value, enc->joint_stereo_mode);

View file

@ -70,11 +70,12 @@ struct _GstWavpackEnc
GstWavpackEncWriteID wvc_id; GstWavpackEncWriteID wvc_id;
guint mode; guint mode;
gdouble bitrate; guint bitrate;
gdouble bps;
guint correction_mode; guint correction_mode;
gboolean md5; gboolean md5;
MD5_CTX *md5_context; MD5_CTX *md5_context;
gboolean extra_processing; guint extra_processing;
guint joint_stereo_mode; guint joint_stereo_mode;
void *first_block; void *first_block;