diff options
author | Thomas Vander Stichele <thomas@apestaart.org> | 2004-03-14 22:34:33 +0000 |
---|---|---|
committer | Thomas Vander Stichele <thomas@apestaart.org> | 2004-03-14 22:34:33 +0000 |
commit | 5d25c00e4b613b9cdf2c04fa3a68dffa03834a68 (patch) | |
tree | 74a5b1eaf3a324b520e64e87404fd0b3018a7829 /ext/flac/gstflacenc.c | |
parent | 1e83b097f7b732ae49e294a5a398bdc3e88854a8 (diff) |
gst-indent
Original commit message from CVS:
gst-indent
Diffstat (limited to 'ext/flac/gstflacenc.c')
-rw-r--r-- | ext/flac/gstflacenc.c | 646 |
1 files changed, 328 insertions, 318 deletions
diff --git a/ext/flac/gstflacenc.c b/ext/flac/gstflacenc.c index eacedeb4..7e658047 100644 --- a/ext/flac/gstflacenc.c +++ b/ext/flac/gstflacenc.c @@ -40,12 +40,14 @@ GstElementDetails flacenc_details = { }; /* FlacEnc signals and args */ -enum { +enum +{ /* FILL ME */ LAST_SIGNAL }; -enum { +enum +{ ARG_0, ARG_QUALITY, ARG_STREAMABLE_SUBSET, @@ -62,34 +64,32 @@ enum { ARG_RICE_PARAMETER_SEARCH_DIST, }; -static void gst_flacenc_base_init (gpointer g_class); -static void gst_flacenc_init (FlacEnc *flacenc); -static void gst_flacenc_class_init (FlacEncClass *klass); -static void gst_flacenc_dispose (GObject *object); +static void gst_flacenc_base_init (gpointer g_class); +static void gst_flacenc_init (FlacEnc * flacenc); +static void gst_flacenc_class_init (FlacEncClass * klass); +static void gst_flacenc_dispose (GObject * object); static GstPadLinkReturn - gst_flacenc_sinkconnect (GstPad *pad, const GstCaps *caps); -static void gst_flacenc_chain (GstPad *pad, GstData *_data); - -static gboolean gst_flacenc_update_quality (FlacEnc *flacenc, gint quality); -static void gst_flacenc_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void gst_flacenc_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); -static GstElementStateReturn - gst_flacenc_change_state (GstElement *element); - -static FLAC__StreamEncoderWriteStatus - gst_flacenc_write_callback (const FLAC__SeekableStreamEncoder *encoder, - const FLAC__byte buffer[], unsigned bytes, - unsigned samples, unsigned current_frame, - void *client_data); +gst_flacenc_sinkconnect (GstPad * pad, const GstCaps * caps); +static void gst_flacenc_chain (GstPad * pad, GstData * _data); + +static gboolean gst_flacenc_update_quality (FlacEnc * flacenc, gint quality); +static void gst_flacenc_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_flacenc_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); +static GstElementStateReturn gst_flacenc_change_state (GstElement * element); + +static FLAC__StreamEncoderWriteStatus +gst_flacenc_write_callback (const FLAC__SeekableStreamEncoder * encoder, + const FLAC__byte buffer[], unsigned bytes, + unsigned samples, unsigned current_frame, void *client_data); static FLAC__SeekableStreamEncoderSeekStatus - gst_flacenc_seek_callback (const FLAC__SeekableStreamEncoder *encoder, - FLAC__uint64 absolute_byte_offset, - void *client_data); +gst_flacenc_seek_callback (const FLAC__SeekableStreamEncoder * encoder, + FLAC__uint64 absolute_byte_offset, void *client_data); static GstElementClass *parent_class = NULL; + /*static guint gst_flacenc_signals[LAST_SIGNAL] = { 0 }; */ GType @@ -99,15 +99,15 @@ flacenc_get_type (void) if (!flacenc_type) { static const GTypeInfo flacenc_info = { - sizeof(FlacEncClass), + sizeof (FlacEncClass), gst_flacenc_base_init, NULL, - (GClassInitFunc)gst_flacenc_class_init, + (GClassInitFunc) gst_flacenc_class_init, NULL, NULL, - sizeof(FlacEnc), + sizeof (FlacEnc), 0, - (GInstanceInitFunc)gst_flacenc_init, + (GInstanceInitFunc) gst_flacenc_init, }; static const GInterfaceInfo tag_setter_info = { @@ -116,38 +116,40 @@ flacenc_get_type (void) NULL }; - flacenc_type = g_type_register_static (GST_TYPE_ELEMENT, "FlacEnc", &flacenc_info, 0); - g_type_add_interface_static (flacenc_type, GST_TYPE_TAG_SETTER, &tag_setter_info); + flacenc_type = + g_type_register_static (GST_TYPE_ELEMENT, "FlacEnc", &flacenc_info, 0); + g_type_add_interface_static (flacenc_type, GST_TYPE_TAG_SETTER, + &tag_setter_info); } return flacenc_type; } -typedef struct { - gboolean exhaustive_model_search; - gboolean escape_coding; - gboolean mid_side; - gboolean loose_mid_side; - guint qlp_coeff_precision; - gboolean qlp_coeff_prec_search; - guint min_residual_partition_order; - guint max_residual_partition_order; - guint rice_parameter_search_dist; - guint max_lpc_order; - guint blocksize; +typedef struct +{ + gboolean exhaustive_model_search; + gboolean escape_coding; + gboolean mid_side; + gboolean loose_mid_side; + guint qlp_coeff_precision; + gboolean qlp_coeff_prec_search; + guint min_residual_partition_order; + guint max_residual_partition_order; + guint rice_parameter_search_dist; + guint max_lpc_order; + guint blocksize; } FlacEncParams; -static const FlacEncParams flacenc_params[] = -{ - { FALSE, FALSE, FALSE, FALSE, 0, FALSE, 2, 2, 0, 0, 1152 }, - { FALSE, FALSE, TRUE, TRUE, 0, FALSE, 2, 2, 0, 0, 1152 }, - { FALSE, FALSE, TRUE, FALSE, 0, FALSE, 0, 3, 0, 0, 1152 }, - { FALSE, FALSE, FALSE, FALSE, 0, FALSE, 3, 3, 0, 6, 4608 }, - { FALSE, FALSE, TRUE, TRUE, 0, FALSE, 3, 3, 0, 8, 4608 }, - { FALSE, FALSE, TRUE, FALSE, 0, FALSE, 3, 3, 0, 8, 4608 }, - { FALSE, FALSE, TRUE, FALSE, 0, FALSE, 0, 4, 0, 8, 4608 }, - { TRUE, FALSE, TRUE, FALSE, 0, FALSE, 0, 6, 0, 8, 4608 }, - { TRUE, FALSE, TRUE, FALSE, 0, FALSE, 0, 6, 0, 12, 4608 }, - { TRUE, TRUE, TRUE, FALSE, 0, FALSE, 0, 16, 0, 32, 4608 }, +static const FlacEncParams flacenc_params[] = { + {FALSE, FALSE, FALSE, FALSE, 0, FALSE, 2, 2, 0, 0, 1152}, + {FALSE, FALSE, TRUE, TRUE, 0, FALSE, 2, 2, 0, 0, 1152}, + {FALSE, FALSE, TRUE, FALSE, 0, FALSE, 0, 3, 0, 0, 1152}, + {FALSE, FALSE, FALSE, FALSE, 0, FALSE, 3, 3, 0, 6, 4608}, + {FALSE, FALSE, TRUE, TRUE, 0, FALSE, 3, 3, 0, 8, 4608}, + {FALSE, FALSE, TRUE, FALSE, 0, FALSE, 3, 3, 0, 8, 4608}, + {FALSE, FALSE, TRUE, FALSE, 0, FALSE, 0, 4, 0, 8, 4608}, + {TRUE, FALSE, TRUE, FALSE, 0, FALSE, 0, 6, 0, 8, 4608}, + {TRUE, FALSE, TRUE, FALSE, 0, FALSE, 0, 6, 0, 12, 4608}, + {TRUE, TRUE, TRUE, FALSE, 0, FALSE, 0, 16, 0, 32, 4608}, }; #define DEFAULT_QUALITY 5 @@ -157,44 +159,44 @@ GType gst_flacenc_quality_get_type (void) { static GType qtype = 0; + if (qtype == 0) { static const GEnumValue values[] = { - { 0, "0", "0 - Fastest compression" }, - { 1, "1", "1" }, - { 2, "2", "2" }, - { 3, "3", "3" }, - { 4, "4", "4" }, - { 5, "5", "5 - Default" }, - { 6, "6", "6" }, - { 7, "7", "7" }, - { 8, "8", "8 - Highest compression " }, - { 9, "9", "9 - Insane" }, - { 0, NULL, NULL } + {0, "0", "0 - Fastest compression"}, + {1, "1", "1"}, + {2, "2", "2"}, + {3, "3", "3"}, + {4, "4", "4"}, + {5, "5", "5 - Default"}, + {6, "6", "6"}, + {7, "7", "7"}, + {8, "8", "8 - Highest compression "}, + {9, "9", "9 - Insane"}, + {0, NULL, NULL} }; qtype = g_enum_register_static ("FlacEncQuality", values); } return qtype; } -static GstCaps* +static GstCaps * flac_caps_factory (void) { return gst_caps_new_simple ("audio/x-flac", NULL); - /* "rate", GST_PROPS_INT_RANGE (11025, 48000), - * "channels", GST_PROPS_INT_RANGE (1, 2), */ + /* "rate", GST_PROPS_INT_RANGE (11025, 48000), + * "channels", GST_PROPS_INT_RANGE (1, 2), */ } -static GstCaps* +static GstCaps * raw_caps_factory (void) { return gst_caps_new_simple ("audio/x-raw-int", - "endianness", G_TYPE_INT, G_BYTE_ORDER, - "signed", G_TYPE_BOOLEAN, TRUE, - "width", G_TYPE_INT, 16, - "depth", G_TYPE_INT, 16, - "rate", GST_TYPE_INT_RANGE, 11025, 48000, - "channels", GST_TYPE_INT_RANGE, 1, 2, - NULL); + "endianness", G_TYPE_INT, G_BYTE_ORDER, + "signed", G_TYPE_BOOLEAN, TRUE, + "width", G_TYPE_INT, 16, + "depth", G_TYPE_INT, 16, + "rate", GST_TYPE_INT_RANGE, 11025, 48000, + "channels", GST_TYPE_INT_RANGE, 1, 2, NULL); } static void @@ -206,125 +208,123 @@ gst_flacenc_base_init (gpointer g_class) raw_caps = raw_caps_factory (); flac_caps = flac_caps_factory (); - sink_template = gst_pad_template_new ("sink", GST_PAD_SINK, - GST_PAD_ALWAYS, - raw_caps); - src_template = gst_pad_template_new ("src", GST_PAD_SRC, - GST_PAD_ALWAYS, - flac_caps); + sink_template = gst_pad_template_new ("sink", GST_PAD_SINK, + GST_PAD_ALWAYS, raw_caps); + src_template = gst_pad_template_new ("src", GST_PAD_SRC, + GST_PAD_ALWAYS, flac_caps); gst_element_class_add_pad_template (element_class, sink_template); gst_element_class_add_pad_template (element_class, src_template); gst_element_class_set_details (element_class, &flacenc_details); } static void -gst_flacenc_class_init (FlacEncClass *klass) +gst_flacenc_class_init (FlacEncClass * klass) { GObjectClass *gobject_class; GstElementClass *gstelement_class; - gobject_class = (GObjectClass*)klass; - gstelement_class = (GstElementClass*)klass; + gobject_class = (GObjectClass *) klass; + gstelement_class = (GstElementClass *) klass; + + parent_class = g_type_class_ref (GST_TYPE_ELEMENT); - parent_class = g_type_class_ref(GST_TYPE_ELEMENT); - /* we have no properties atm so this is a bit silly */ gobject_class->set_property = gst_flacenc_set_property; gobject_class->get_property = gst_flacenc_get_property; - gobject_class->dispose = gst_flacenc_dispose; + gobject_class->dispose = gst_flacenc_dispose; g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_QUALITY, - g_param_spec_enum ("quality", - "Quality", - "Speed versus compression tradeoff", - GST_TYPE_FLACENC_QUALITY, DEFAULT_QUALITY, G_PARAM_READWRITE)); - g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_STREAMABLE_SUBSET, - g_param_spec_boolean ("streamable_subset", - "Streamable subset", - "true to limit encoder to generating a Subset stream, else false", - TRUE, G_PARAM_READWRITE)); + g_param_spec_enum ("quality", + "Quality", + "Speed versus compression tradeoff", + GST_TYPE_FLACENC_QUALITY, DEFAULT_QUALITY, G_PARAM_READWRITE)); + g_object_class_install_property (G_OBJECT_CLASS (klass), + ARG_STREAMABLE_SUBSET, g_param_spec_boolean ("streamable_subset", + "Streamable subset", + "true to limit encoder to generating a Subset stream, else false", + TRUE, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MID_SIDE_STEREO, - g_param_spec_boolean ("mid_side_stereo", - "Do mid side stereo", - "Do mid side stereo (only for stereo input)", - flacenc_params[DEFAULT_QUALITY].mid_side, G_PARAM_READWRITE)); - g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOOSE_MID_SIDE_STEREO, - g_param_spec_boolean ("loose_mid_side_stereo", - "Loose mid side stereo", - "Loose mid side stereo", - flacenc_params[DEFAULT_QUALITY].loose_mid_side, G_PARAM_READWRITE)); + g_param_spec_boolean ("mid_side_stereo", "Do mid side stereo", + "Do mid side stereo (only for stereo input)", + flacenc_params[DEFAULT_QUALITY].mid_side, G_PARAM_READWRITE)); + g_object_class_install_property (G_OBJECT_CLASS (klass), + ARG_LOOSE_MID_SIDE_STEREO, g_param_spec_boolean ("loose_mid_side_stereo", + "Loose mid side stereo", "Loose mid side stereo", + flacenc_params[DEFAULT_QUALITY].loose_mid_side, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BLOCKSIZE, - g_param_spec_uint ("blocksize", - "Blocksize", - "Blocksize in samples", - FLAC__MIN_BLOCK_SIZE, FLAC__MAX_BLOCK_SIZE, - flacenc_params[DEFAULT_QUALITY].blocksize, G_PARAM_READWRITE)); + g_param_spec_uint ("blocksize", "Blocksize", "Blocksize in samples", + FLAC__MIN_BLOCK_SIZE, FLAC__MAX_BLOCK_SIZE, + flacenc_params[DEFAULT_QUALITY].blocksize, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MAX_LPC_ORDER, - g_param_spec_uint ("max_lpc_order", - "Max LPC order", - "Max LPC order; 0 => use only fixed predictors", - 0, FLAC__MAX_LPC_ORDER, - flacenc_params[DEFAULT_QUALITY].max_lpc_order, G_PARAM_READWRITE)); - g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_QLP_COEFF_PRECISION, - g_param_spec_uint ("qlp_coeff_precision", - "QLP coefficients precision", - "Precision in bits of quantized linear-predictor coefficients; 0 = automatic", - 0, 32, - flacenc_params[DEFAULT_QUALITY].qlp_coeff_precision, G_PARAM_READWRITE)); - g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_QLP_COEFF_PREC_SEARCH, - g_param_spec_boolean ("qlp_coeff_prec_search", - "Do QLP coefficients precision search", - "false = use qlp_coeff_precision, " - "true = search around qlp_coeff_precision, take best", - flacenc_params[DEFAULT_QUALITY].qlp_coeff_prec_search, G_PARAM_READWRITE)); + g_param_spec_uint ("max_lpc_order", "Max LPC order", + "Max LPC order; 0 => use only fixed predictors", 0, + FLAC__MAX_LPC_ORDER, flacenc_params[DEFAULT_QUALITY].max_lpc_order, + G_PARAM_READWRITE)); + g_object_class_install_property (G_OBJECT_CLASS (klass), + ARG_QLP_COEFF_PRECISION, g_param_spec_uint ("qlp_coeff_precision", + "QLP coefficients precision", + "Precision in bits of quantized linear-predictor coefficients; 0 = automatic", + 0, 32, flacenc_params[DEFAULT_QUALITY].qlp_coeff_precision, + G_PARAM_READWRITE)); + g_object_class_install_property (G_OBJECT_CLASS (klass), + ARG_QLP_COEFF_PREC_SEARCH, g_param_spec_boolean ("qlp_coeff_prec_search", + "Do QLP coefficients precision search", + "false = use qlp_coeff_precision, " + "true = search around qlp_coeff_precision, take best", + flacenc_params[DEFAULT_QUALITY].qlp_coeff_prec_search, + G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ESCAPE_CODING, - g_param_spec_boolean ("escape_coding", - "Do Escape coding", - "search for escape codes in the entropy coding stage " - "for slightly better compression", - flacenc_params[DEFAULT_QUALITY].escape_coding, G_PARAM_READWRITE)); - g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_EXHAUSTIVE_MODEL_SEARCH, - g_param_spec_boolean ("exhaustive_model_search", - "Do exhaustive model search", - "do exhaustive search of LP coefficient quantization (expensive!)", - flacenc_params[DEFAULT_QUALITY].exhaustive_model_search, G_PARAM_READWRITE)); - g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MIN_RESIDUAL_PARTITION_ORDER, - g_param_spec_uint ("min_residual_partition_order", - "Min residual partition order", - "Min residual partition order (above 4 doesn't usually help much)", - 0, 16, - flacenc_params[DEFAULT_QUALITY].min_residual_partition_order, G_PARAM_READWRITE)); - g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MAX_RESIDUAL_PARTITION_ORDER, - g_param_spec_uint ("max_residual_partition_order", - "Max residual partition order", - "Max residual partition order (above 4 doesn't usually help much)", - 0, 16, - flacenc_params[DEFAULT_QUALITY].max_residual_partition_order, G_PARAM_READWRITE)); - g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_RICE_PARAMETER_SEARCH_DIST, - g_param_spec_uint ("rice_parameter_search_dist", - "rice_parameter_search_dist", - "0 = try only calc'd parameter k; else try all [k-dist..k+dist] " - "parameters, use best", - 0, FLAC__MAX_RICE_PARTITION_ORDER, - flacenc_params[DEFAULT_QUALITY].rice_parameter_search_dist, G_PARAM_READWRITE)); + g_param_spec_boolean ("escape_coding", "Do Escape coding", + "search for escape codes in the entropy coding stage " + "for slightly better compression", + flacenc_params[DEFAULT_QUALITY].escape_coding, G_PARAM_READWRITE)); + g_object_class_install_property (G_OBJECT_CLASS (klass), + ARG_EXHAUSTIVE_MODEL_SEARCH, + g_param_spec_boolean ("exhaustive_model_search", + "Do exhaustive model search", + "do exhaustive search of LP coefficient quantization (expensive!)", + flacenc_params[DEFAULT_QUALITY].exhaustive_model_search, + G_PARAM_READWRITE)); + g_object_class_install_property (G_OBJECT_CLASS (klass), + ARG_MIN_RESIDUAL_PARTITION_ORDER, + g_param_spec_uint ("min_residual_partition_order", + "Min residual partition order", + "Min residual partition order (above 4 doesn't usually help much)", 0, + 16, flacenc_params[DEFAULT_QUALITY].min_residual_partition_order, + G_PARAM_READWRITE)); + g_object_class_install_property (G_OBJECT_CLASS (klass), + ARG_MAX_RESIDUAL_PARTITION_ORDER, + g_param_spec_uint ("max_residual_partition_order", + "Max residual partition order", + "Max residual partition order (above 4 doesn't usually help much)", 0, + 16, flacenc_params[DEFAULT_QUALITY].max_residual_partition_order, + G_PARAM_READWRITE)); + g_object_class_install_property (G_OBJECT_CLASS (klass), + ARG_RICE_PARAMETER_SEARCH_DIST, + g_param_spec_uint ("rice_parameter_search_dist", + "rice_parameter_search_dist", + "0 = try only calc'd parameter k; else try all [k-dist..k+dist] " + "parameters, use best", 0, FLAC__MAX_RICE_PARTITION_ORDER, + flacenc_params[DEFAULT_QUALITY].rice_parameter_search_dist, + G_PARAM_READWRITE)); gstelement_class->change_state = gst_flacenc_change_state; } static void -gst_flacenc_init (FlacEnc *flacenc) +gst_flacenc_init (FlacEnc * flacenc) { flacenc->sinkpad = gst_pad_new_from_template (sink_template, "sink"); - gst_element_add_pad(GST_ELEMENT(flacenc),flacenc->sinkpad); - gst_pad_set_chain_function(flacenc->sinkpad,gst_flacenc_chain); + gst_element_add_pad (GST_ELEMENT (flacenc), flacenc->sinkpad); + gst_pad_set_chain_function (flacenc->sinkpad, gst_flacenc_chain); gst_pad_set_link_function (flacenc->sinkpad, gst_flacenc_sinkconnect); flacenc->srcpad = gst_pad_new_from_template (src_template, "src"); - gst_element_add_pad(GST_ELEMENT(flacenc),flacenc->srcpad); + gst_element_add_pad (GST_ELEMENT (flacenc), flacenc->srcpad); GST_FLAG_SET (flacenc, GST_ELEMENT_EVENT_AWARE); - flacenc->encoder = FLAC__seekable_stream_encoder_new(); + flacenc->encoder = FLAC__seekable_stream_encoder_new (); flacenc->negotiated = FALSE; flacenc->first = TRUE; @@ -335,17 +335,17 @@ gst_flacenc_init (FlacEnc *flacenc) } static void -gst_flacenc_dispose (GObject *object) +gst_flacenc_dispose (GObject * object) { FlacEnc *flacenc = GST_FLACENC (object); FLAC__seekable_stream_encoder_delete (flacenc->encoder); - + G_OBJECT_CLASS (parent_class)->dispose (object); } static GstPadLinkReturn -gst_flacenc_sinkconnect (GstPad *pad, const GstCaps *caps) +gst_flacenc_sinkconnect (GstPad * pad, const GstCaps * caps) { GstPadLinkReturn ret; FlacEnc *flacenc; @@ -358,7 +358,7 @@ gst_flacenc_sinkconnect (GstPad *pad, const GstCaps *caps) gst_structure_get_int (structure, "channels", &flacenc->channels); gst_structure_get_int (structure, "depth", &flacenc->depth); gst_structure_get_int (structure, "rate", &flacenc->sample_rate); - + caps = gst_caps_new_simple ("audio/x-flac", "channels", G_TYPE_INT, flacenc->channels, "rate", G_TYPE_INT, flacenc->sample_rate, NULL); @@ -367,12 +367,12 @@ gst_flacenc_sinkconnect (GstPad *pad, const GstCaps *caps) return ret; } - FLAC__seekable_stream_encoder_set_bits_per_sample (flacenc->encoder, - flacenc->depth); - FLAC__seekable_stream_encoder_set_sample_rate (flacenc->encoder, - flacenc->sample_rate); - FLAC__seekable_stream_encoder_set_channels (flacenc->encoder, - flacenc->channels); + FLAC__seekable_stream_encoder_set_bits_per_sample (flacenc->encoder, + flacenc->depth); + FLAC__seekable_stream_encoder_set_sample_rate (flacenc->encoder, + flacenc->sample_rate); + FLAC__seekable_stream_encoder_set_channels (flacenc->encoder, + flacenc->channels); flacenc->negotiated = TRUE; @@ -380,7 +380,7 @@ gst_flacenc_sinkconnect (GstPad *pad, const GstCaps *caps) } static gboolean -gst_flacenc_update_quality (FlacEnc *flacenc, gint quality) +gst_flacenc_update_quality (FlacEnc * flacenc, gint quality) { flacenc->quality = quality; @@ -396,17 +396,22 @@ gst_flacenc_update_quality (FlacEnc *flacenc, gint quality) g_object_freeze_notify (G_OBJECT (flacenc)); - DO_UPDATE (do_mid_side_stereo, mid_side, "mid_side_stereo"); - DO_UPDATE (loose_mid_side_stereo, loose_mid_side, "loose_mid_side"); - DO_UPDATE (blocksize, blocksize, "blocksize"); - DO_UPDATE (max_lpc_order, max_lpc_order, "max_lpc_order"); - DO_UPDATE (qlp_coeff_precision, qlp_coeff_precision, "qlp_coeff_precision"); - DO_UPDATE (do_qlp_coeff_prec_search, qlp_coeff_prec_search, "qlp_coeff_prec_search"); - DO_UPDATE (do_escape_coding, escape_coding, "escape_coding"); - DO_UPDATE (do_exhaustive_model_search, exhaustive_model_search, "exhaustive_model_search"); - DO_UPDATE (min_residual_partition_order, min_residual_partition_order, "min_residual_partition_order"); - DO_UPDATE (max_residual_partition_order, max_residual_partition_order, "max_residual_partition_order"); - DO_UPDATE (rice_parameter_search_dist, rice_parameter_search_dist, "rice_parameter_search_dist"); + DO_UPDATE (do_mid_side_stereo, mid_side, "mid_side_stereo"); + DO_UPDATE (loose_mid_side_stereo, loose_mid_side, "loose_mid_side"); + DO_UPDATE (blocksize, blocksize, "blocksize"); + DO_UPDATE (max_lpc_order, max_lpc_order, "max_lpc_order"); + DO_UPDATE (qlp_coeff_precision, qlp_coeff_precision, "qlp_coeff_precision"); + DO_UPDATE (do_qlp_coeff_prec_search, qlp_coeff_prec_search, + "qlp_coeff_prec_search"); + DO_UPDATE (do_escape_coding, escape_coding, "escape_coding"); + DO_UPDATE (do_exhaustive_model_search, exhaustive_model_search, + "exhaustive_model_search"); + DO_UPDATE (min_residual_partition_order, min_residual_partition_order, + "min_residual_partition_order"); + DO_UPDATE (max_residual_partition_order, max_residual_partition_order, + "max_residual_partition_order"); + DO_UPDATE (rice_parameter_search_dist, rice_parameter_search_dist, + "rice_parameter_search_dist"); #undef DO_UPDATE @@ -416,38 +421,38 @@ gst_flacenc_update_quality (FlacEnc *flacenc, gint quality) } static FLAC__SeekableStreamEncoderSeekStatus -gst_flacenc_seek_callback (const FLAC__SeekableStreamEncoder *encoder, - FLAC__uint64 absolute_byte_offset, - void *client_data) +gst_flacenc_seek_callback (const FLAC__SeekableStreamEncoder * encoder, + FLAC__uint64 absolute_byte_offset, void *client_data) { -FlacEnc *flacenc; -GstEvent *event; + FlacEnc *flacenc; + GstEvent *event; flacenc = GST_FLACENC (client_data); - if (flacenc->stopped) + if (flacenc->stopped) return FLAC__STREAM_ENCODER_OK; - event = gst_event_new_seek ((GstSeekType)(int)(GST_FORMAT_BYTES | GST_SEEK_METHOD_SET), absolute_byte_offset); + event = + gst_event_new_seek ((GstSeekType) (int) (GST_FORMAT_BYTES | + GST_SEEK_METHOD_SET), absolute_byte_offset); if (event) gst_pad_push (flacenc->srcpad, GST_DATA (event)); - - return FLAC__STREAM_ENCODER_OK; + + return FLAC__STREAM_ENCODER_OK; } -static FLAC__StreamEncoderWriteStatus -gst_flacenc_write_callback (const FLAC__SeekableStreamEncoder *encoder, - const FLAC__byte buffer[], unsigned bytes, - unsigned samples, unsigned current_frame, - void *client_data) +static FLAC__StreamEncoderWriteStatus +gst_flacenc_write_callback (const FLAC__SeekableStreamEncoder * encoder, + const FLAC__byte buffer[], unsigned bytes, + unsigned samples, unsigned current_frame, void *client_data) { FlacEnc *flacenc; GstBuffer *outbuf; - + flacenc = GST_FLACENC (client_data); - if (flacenc->stopped) + if (flacenc->stopped) return FLAC__STREAM_ENCODER_OK; outbuf = gst_buffer_new_and_alloc (bytes); @@ -465,30 +470,29 @@ gst_flacenc_write_callback (const FLAC__SeekableStreamEncoder *encoder, return FLAC__STREAM_ENCODER_OK; } -static void -add_one_tag (const GstTagList *list, const gchar *tag, - gpointer user_data) +static void +add_one_tag (const GstTagList * list, const gchar * tag, gpointer user_data) { - GList *comments; - GList *it; - FlacEnc *flacenc = GST_FLACENC (user_data); - - comments = gst_tag_to_vorbis_comments (list, tag); - for (it = comments; it != NULL; it = it->next) { - FLAC__StreamMetadata_VorbisComment_Entry commment_entry; - commment_entry.length = strlen(it->data); - commment_entry.entry = it->data; - FLAC__metadata_object_vorbiscomment_insert_comment (flacenc->meta[0], - flacenc->meta[0]->data.vorbis_comment.num_comments, - commment_entry, - TRUE); - g_free (it->data); - } - g_list_free (comments); + GList *comments; + GList *it; + FlacEnc *flacenc = GST_FLACENC (user_data); + + comments = gst_tag_to_vorbis_comments (list, tag); + for (it = comments; it != NULL; it = it->next) { + FLAC__StreamMetadata_VorbisComment_Entry commment_entry; + + commment_entry.length = strlen (it->data); + commment_entry.entry = it->data; + FLAC__metadata_object_vorbiscomment_insert_comment (flacenc->meta[0], + flacenc->meta[0]->data.vorbis_comment.num_comments, + commment_entry, TRUE); + g_free (it->data); + } + g_list_free (comments); } static void -gst_flacenc_set_metadata (FlacEnc *flacenc) +gst_flacenc_set_metadata (FlacEnc * flacenc) { const GstTagList *user_tags; GstTagList *copy; @@ -498,21 +502,23 @@ gst_flacenc_set_metadata (FlacEnc *flacenc) if ((flacenc->tags == NULL) && (user_tags == NULL)) { return; } - copy = gst_tag_list_merge (user_tags, flacenc->tags, - gst_tag_setter_get_merge_mode (GST_TAG_SETTER (flacenc))); + copy = gst_tag_list_merge (user_tags, flacenc->tags, + gst_tag_setter_get_merge_mode (GST_TAG_SETTER (flacenc))); flacenc->meta = g_malloc (sizeof (FLAC__StreamMetadata **)); - flacenc->meta[0] = FLAC__metadata_object_new (FLAC__METADATA_TYPE_VORBIS_COMMENT); + flacenc->meta[0] = + FLAC__metadata_object_new (FLAC__METADATA_TYPE_VORBIS_COMMENT); gst_tag_list_foreach (copy, add_one_tag, flacenc); - if (FLAC__seekable_stream_encoder_set_metadata(flacenc->encoder, flacenc->meta, 1) != true) + if (FLAC__seekable_stream_encoder_set_metadata (flacenc->encoder, + flacenc->meta, 1) != true) g_warning ("Dude, i'm already initialized!"); gst_tag_list_free (copy); } static void -gst_flacenc_chain (GstPad *pad, GstData *_data) +gst_flacenc_chain (GstPad * pad, GstData * _data) { GstBuffer *buf = GST_BUFFER (_data); FlacEnc *flacenc; @@ -522,7 +528,7 @@ gst_flacenc_chain (GstPad *pad, GstData *_data) gulong i; FLAC__bool res; - g_return_if_fail(buf != NULL); + g_return_if_fail (buf != NULL); flacenc = GST_FLACENC (gst_pad_get_parent (pad)); @@ -531,18 +537,18 @@ gst_flacenc_chain (GstPad *pad, GstData *_data) switch (GST_EVENT_TYPE (event)) { case GST_EVENT_EOS: - FLAC__seekable_stream_encoder_finish(flacenc->encoder); + FLAC__seekable_stream_encoder_finish (flacenc->encoder); break; case GST_EVENT_TAG: if (flacenc->tags) { - gst_tag_list_insert (flacenc->tags, gst_event_tag_get_list (event), - GST_TAG_MERGE_REPLACE); + gst_tag_list_insert (flacenc->tags, gst_event_tag_get_list (event), + GST_TAG_MERGE_REPLACE); } else { g_assert_not_reached (); } break; default: - break; + break; } gst_pad_event_default (pad, event); return; @@ -550,33 +556,31 @@ gst_flacenc_chain (GstPad *pad, GstData *_data) if (!flacenc->negotiated) { GST_ELEMENT_ERROR (flacenc, CORE, NEGOTIATION, (NULL), - ("format wasn't negotiated before chain function")); + ("format wasn't negotiated before chain function")); return; } depth = flacenc->depth; insize = GST_BUFFER_SIZE (buf); - samples = insize / ((depth+7)>>3); + samples = insize / ((depth + 7) >> 3); - if (FLAC__seekable_stream_encoder_get_state (flacenc->encoder) == - FLAC__SEEKABLE_STREAM_ENCODER_UNINITIALIZED) - { + if (FLAC__seekable_stream_encoder_get_state (flacenc->encoder) == + FLAC__SEEKABLE_STREAM_ENCODER_UNINITIALIZED) { FLAC__SeekableStreamEncoderState state; - FLAC__seekable_stream_encoder_set_write_callback (flacenc->encoder, - gst_flacenc_write_callback); - FLAC__seekable_stream_encoder_set_seek_callback (flacenc->encoder, - gst_flacenc_seek_callback); - - FLAC__seekable_stream_encoder_set_client_data (flacenc->encoder, - flacenc); - + FLAC__seekable_stream_encoder_set_write_callback (flacenc->encoder, + gst_flacenc_write_callback); + FLAC__seekable_stream_encoder_set_seek_callback (flacenc->encoder, + gst_flacenc_seek_callback); + + FLAC__seekable_stream_encoder_set_client_data (flacenc->encoder, flacenc); + gst_flacenc_set_metadata (flacenc); state = FLAC__seekable_stream_encoder_init (flacenc->encoder); if (state != FLAC__STREAM_ENCODER_OK) { GST_ELEMENT_ERROR (flacenc, LIBRARY, INIT, (NULL), - ("could not initialize encoder (wrong parameters?)")); + ("could not initialize encoder (wrong parameters?)")); return; } } @@ -584,27 +588,26 @@ gst_flacenc_chain (GstPad *pad, GstData *_data) /* we keep a pointer in the flacenc struct because we are freeing the data * after a push opreration that might never return */ data = flacenc->data = g_malloc (samples * sizeof (FLAC__int32)); - + if (depth == 8) { gint8 *indata = (gint8 *) GST_BUFFER_DATA (buf); - - for (i=0; i<samples; i++) { - data[i] = (FLAC__int32) *indata++; + + for (i = 0; i < samples; i++) { + data[i] = (FLAC__int32) * indata++; } - } - else if (depth == 16) { + } else if (depth == 16) { gint16 *indata = (gint16 *) GST_BUFFER_DATA (buf); - for (i=0; i<samples; i++) { - data[i] = (FLAC__int32) *indata++; + for (i = 0; i < samples; i++) { + data[i] = (FLAC__int32) * indata++; } } - gst_buffer_unref(buf); + gst_buffer_unref (buf); - res = FLAC__seekable_stream_encoder_process_interleaved (flacenc->encoder, - (const FLAC__int32 *) data, samples / flacenc->channels); + res = FLAC__seekable_stream_encoder_process_interleaved (flacenc->encoder, + (const FLAC__int32 *) data, samples / flacenc->channels); g_free (flacenc->data); flacenc->data = NULL; @@ -615,63 +618,63 @@ gst_flacenc_chain (GstPad *pad, GstData *_data) } static void -gst_flacenc_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) +gst_flacenc_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) { FlacEnc *this; - - this = (FlacEnc *)object; + + this = (FlacEnc *) object; switch (prop_id) { case ARG_QUALITY: gst_flacenc_update_quality (this, g_value_get_enum (value)); break; case ARG_STREAMABLE_SUBSET: - FLAC__seekable_stream_encoder_set_streamable_subset (this->encoder, - g_value_get_boolean (value)); + FLAC__seekable_stream_encoder_set_streamable_subset (this->encoder, + g_value_get_boolean (value)); break; case ARG_MID_SIDE_STEREO: - FLAC__seekable_stream_encoder_set_do_mid_side_stereo (this->encoder, - g_value_get_boolean (value)); + FLAC__seekable_stream_encoder_set_do_mid_side_stereo (this->encoder, + g_value_get_boolean (value)); break; case ARG_LOOSE_MID_SIDE_STEREO: - FLAC__seekable_stream_encoder_set_loose_mid_side_stereo (this->encoder, - g_value_get_boolean (value)); + FLAC__seekable_stream_encoder_set_loose_mid_side_stereo (this->encoder, + g_value_get_boolean (value)); break; case ARG_BLOCKSIZE: - FLAC__seekable_stream_encoder_set_blocksize (this->encoder, - g_value_get_uint (value)); + FLAC__seekable_stream_encoder_set_blocksize (this->encoder, + g_value_get_uint (value)); break; case ARG_MAX_LPC_ORDER: - FLAC__seekable_stream_encoder_set_max_lpc_order (this->encoder, - g_value_get_uint (value)); + FLAC__seekable_stream_encoder_set_max_lpc_order (this->encoder, + g_value_get_uint (value)); break; case ARG_QLP_COEFF_PRECISION: - FLAC__seekable_stream_encoder_set_qlp_coeff_precision (this->encoder, - g_value_get_uint (value)); + FLAC__seekable_stream_encoder_set_qlp_coeff_precision (this->encoder, + g_value_get_uint (value)); break; case ARG_QLP_COEFF_PREC_SEARCH: - FLAC__seekable_stream_encoder_set_do_qlp_coeff_prec_search (this->encoder, - g_value_get_boolean (value)); + FLAC__seekable_stream_encoder_set_do_qlp_coeff_prec_search (this->encoder, + g_value_get_boolean (value)); break; case ARG_ESCAPE_CODING: - FLAC__seekable_stream_encoder_set_do_escape_coding (this->encoder, - g_value_get_boolean (value)); + FLAC__seekable_stream_encoder_set_do_escape_coding (this->encoder, + g_value_get_boolean (value)); break; case ARG_EXHAUSTIVE_MODEL_SEARCH: - FLAC__seekable_stream_encoder_set_do_exhaustive_model_search (this->encoder, - g_value_get_boolean (value)); + FLAC__seekable_stream_encoder_set_do_exhaustive_model_search (this-> + encoder, g_value_get_boolean (value)); break; case ARG_MIN_RESIDUAL_PARTITION_ORDER: - FLAC__seekable_stream_encoder_set_min_residual_partition_order (this->encoder, - g_value_get_uint (value)); + FLAC__seekable_stream_encoder_set_min_residual_partition_order (this-> + encoder, g_value_get_uint (value)); break; case ARG_MAX_RESIDUAL_PARTITION_ORDER: - FLAC__seekable_stream_encoder_set_max_residual_partition_order (this->encoder, - g_value_get_uint (value)); + FLAC__seekable_stream_encoder_set_max_residual_partition_order (this-> + encoder, g_value_get_uint (value)); break; case ARG_RICE_PARAMETER_SEARCH_DIST: - FLAC__seekable_stream_encoder_set_rice_parameter_search_dist (this->encoder, - g_value_get_uint (value)); + FLAC__seekable_stream_encoder_set_rice_parameter_search_dist (this-> + encoder, g_value_get_uint (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -680,64 +683,71 @@ gst_flacenc_set_property (GObject *object, guint prop_id, } static void -gst_flacenc_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) +gst_flacenc_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec) { FlacEnc *this; - - this = (FlacEnc *)object; - + + this = (FlacEnc *) object; + switch (prop_id) { case ARG_QUALITY: g_value_set_enum (value, this->quality); break; case ARG_STREAMABLE_SUBSET: - g_value_set_boolean (value, - FLAC__seekable_stream_encoder_get_streamable_subset (this->encoder)); + g_value_set_boolean (value, + FLAC__seekable_stream_encoder_get_streamable_subset (this->encoder)); break; case ARG_MID_SIDE_STEREO: - g_value_set_boolean (value, - FLAC__seekable_stream_encoder_get_do_mid_side_stereo (this->encoder)); + g_value_set_boolean (value, + FLAC__seekable_stream_encoder_get_do_mid_side_stereo (this->encoder)); break; case ARG_LOOSE_MID_SIDE_STEREO: - g_value_set_boolean (value, - FLAC__seekable_stream_encoder_get_loose_mid_side_stereo (this->encoder)); + g_value_set_boolean (value, + FLAC__seekable_stream_encoder_get_loose_mid_side_stereo (this-> + encoder)); break; case ARG_BLOCKSIZE: - g_value_set_uint (value, - FLAC__seekable_stream_encoder_get_blocksize (this->encoder)); + g_value_set_uint (value, + FLAC__seekable_stream_encoder_get_blocksize (this->encoder)); break; case ARG_MAX_LPC_ORDER: - g_value_set_uint (value, - FLAC__seekable_stream_encoder_get_max_lpc_order (this->encoder)); + g_value_set_uint (value, + FLAC__seekable_stream_encoder_get_max_lpc_order (this->encoder)); break; case ARG_QLP_COEFF_PRECISION: - g_value_set_uint (value, - FLAC__seekable_stream_encoder_get_qlp_coeff_precision (this->encoder)); + g_value_set_uint (value, + FLAC__seekable_stream_encoder_get_qlp_coeff_precision (this-> + encoder)); break; case ARG_QLP_COEFF_PREC_SEARCH: - g_value_set_boolean (value, - FLAC__seekable_stream_encoder_get_do_qlp_coeff_prec_search (this->encoder)); + g_value_set_boolean (value, + FLAC__seekable_stream_encoder_get_do_qlp_coeff_prec_search (this-> + encoder)); break; case ARG_ESCAPE_CODING: - g_value_set_boolean (value, - FLAC__seekable_stream_encoder_get_do_escape_coding (this->encoder)); + g_value_set_boolean (value, + FLAC__seekable_stream_encoder_get_do_escape_coding (this->encoder)); break; case ARG_EXHAUSTIVE_MODEL_SEARCH: - g_value_set_boolean (value, - FLAC__seekable_stream_encoder_get_do_exhaustive_model_search (this->encoder)); + g_value_set_boolean (value, + FLAC__seekable_stream_encoder_get_do_exhaustive_model_search (this-> + encoder)); break; case ARG_MIN_RESIDUAL_PARTITION_ORDER: - g_value_set_uint (value, - FLAC__seekable_stream_encoder_get_min_residual_partition_order (this->encoder)); + g_value_set_uint (value, + FLAC__seekable_stream_encoder_get_min_residual_partition_order (this-> + encoder)); break; case ARG_MAX_RESIDUAL_PARTITION_ORDER: - g_value_set_uint (value, - FLAC__seekable_stream_encoder_get_max_residual_partition_order (this->encoder)); + g_value_set_uint (value, + FLAC__seekable_stream_encoder_get_max_residual_partition_order (this-> + encoder)); break; case ARG_RICE_PARAMETER_SEARCH_DIST: - g_value_set_uint (value, - FLAC__seekable_stream_encoder_get_rice_parameter_search_dist (this->encoder)); + g_value_set_uint (value, + FLAC__seekable_stream_encoder_get_rice_parameter_search_dist (this-> + encoder)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -746,7 +756,7 @@ gst_flacenc_get_property (GObject *object, guint prop_id, } static GstElementStateReturn -gst_flacenc_change_state (GstElement *element) +gst_flacenc_change_state (GstElement * element) { FlacEnc *flacenc = GST_FLACENC (element); @@ -760,10 +770,10 @@ gst_flacenc_change_state (GstElement *element) case GST_STATE_PLAYING_TO_PAUSED: break; case GST_STATE_PAUSED_TO_READY: - if (FLAC__seekable_stream_encoder_get_state (flacenc->encoder) != - FLAC__STREAM_ENCODER_UNINITIALIZED) { - flacenc->stopped = TRUE; - FLAC__seekable_stream_encoder_finish (flacenc->encoder); + if (FLAC__seekable_stream_encoder_get_state (flacenc->encoder) != + FLAC__STREAM_ENCODER_UNINITIALIZED) { + flacenc->stopped = TRUE; + FLAC__seekable_stream_encoder_finish (flacenc->encoder); } flacenc->negotiated = FALSE; if (flacenc->first_buf) |