+2004-03-14 Thomas Vander Stichele <thomas at apestaart dot org>
+
+ * *.c, *.h: run gst-indent
+
2004-03-14 Benjamin Otte <otte@gnome.org>
* gst/modplug/gstmodplug.cc:
* connection would use the I420 format (assuming Xv is enabled) */
static void
-new_pad_func (GstElement *element, GstPad *newpad, gpointer data)
+new_pad_func (GstElement * element, GstPad * newpad, gpointer data)
{
GstElement *pipeline = (GstElement *) data;
GstElement *queue = gst_bin_get_by_name (GST_BIN (pipeline), "queue");
}
gint
-main (gint argc, gchar *argv[])
+main (gint argc, gchar * argv[])
{
GstElement *pipeline;
GstElement *filesrc;
g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
demux = gst_element_factory_make ("mpegdemux", "demux");
g_return_val_if_fail (demux, -1);
- g_signal_connect (G_OBJECT (demux), "new_pad", G_CALLBACK (new_pad_func), pipeline);
+ g_signal_connect (G_OBJECT (demux), "new_pad", G_CALLBACK (new_pad_func),
+ pipeline);
thread = gst_thread_new ("thread");
queue = gst_element_factory_make ("queue", "queue");
gst_bin_add (GST_BIN (pipeline), filesrc);
gst_bin_add (GST_BIN (pipeline), demux);
-
+
gst_bin_add (GST_BIN (thread), queue);
gst_bin_add (GST_BIN (thread), mpeg2dec);
gst_bin_add (GST_BIN (thread), colorspace);
gst_element_link (mpeg2dec, "src", colorspace, "sink");
/* force RGB data passing between colorspace and xvideosink */
res = gst_element_link_filtered (colorspace, "src", xvideosink, "sink",
- GST_CAPS_NEW (
- "filtercaps",
- "video/raw",
- "format", GST_PROPS_FOURCC (GST_STR_FOURCC ("RGB "))
- ));
+ GST_CAPS_NEW ("filtercaps",
+ "video/raw", "format", GST_PROPS_FOURCC (GST_STR_FOURCC ("RGB "))
+ ));
if (!res) {
g_print ("could not connect colorspace and xvideosink\n");
return -1;
gst_element_set_state (pipeline, GST_STATE_PLAYING);
while (gst_bin_iterate (GST_BIN (pipeline)));
-
+
gst_element_set_state (pipeline, GST_STATE_NULL);
return 0;
GtkWidget *window; /* top-level interface window */
GtkWidget *buttons; /* all of the control buttons */
- GtkWidget *parse, *play, *stop; /* control buttons */
-
+ GtkWidget *parse, *play, *stop; /* control buttons */
+
GtkWidget *feedback; /* here's where we'll tell you stuff */
GtkTextBuffer *fb_buffer; /* feedback buffer */
GtkWidget *selection; /* the place to input element stuff */
- GtkWidget *input, *filter, *output; /* the selection widgets */
-
+ GtkWidget *input, *filter, *output; /* the selection widgets */
+
GtkWidget *control; /* the dynamically generated control UI */
};
/* back-end data */
struct _filter_data
{
- _filter_ui_t *ui; /* the UI data */
+ _filter_ui_t *ui; /* the UI data */
gchar *input_pipe, *output_pipe, *filter_element;
gchar *pipe_string;
GList *filter_choices;
gboolean playing;
- GstElement *input, *output; /* these are in and out bins */
+ GstElement *input, *output; /* these are in and out bins */
GstElement *pipeline;
GstElement *filter;
};
typedef struct _filter_data _filter_data_t;
/* internal prototypes when they can't be avoided */
-void cb_remove_and_destroy (GtkWidget *widget, gpointer user_data);
-//void cb_dynparm_value_changed (GtkWidget *widget, gpointer user_data);
-void cb_dynparm_value_changed (GtkRange *range, GstDParam *dparam);
+void cb_remove_and_destroy (GtkWidget * widget, gpointer user_data);
+
+//void cb_dynparm_value_changed (GtkWidget *widget, gpointer user_data);
+void cb_dynparm_value_changed (GtkRange * range, GstDParam * dparam);
/* GStreamer helper functions go here */
-
+
/* go through a bin, finding the one pad that is unconnected in the given
* direction, and return a ghost pad */
GstPad *
-gst_bin_find_unconnected_pad (GstBin *bin, GstPadDirection direction,
- gchar *name)
+gst_bin_find_unconnected_pad (GstBin * bin, GstPadDirection direction,
+ gchar * name)
{
GstPad *pad = NULL;
GList *elements = NULL;
g_print ("DEBUG: find_unconnected start\n");
elements = (GList *) gst_bin_get_list (bin);
/* traverse all elements looking for unconnected pads */
- while (elements && pad == NULL)
- {
+ while (elements && pad == NULL) {
element = GST_ELEMENT (elements->data);
g_print ("DEBUG: looking in element %s\n", gst_element_get_name (element));
pads = gst_element_get_pad_list (element);
- while (pads)
- {
+ while (pads) {
/* check if the direction matches */
- if (GST_PAD_DIRECTION (GST_PAD (pads->data)) == direction)
- {
- if (GST_PAD_PEER (GST_PAD (pads->data)) == NULL)
- {
+ if (GST_PAD_DIRECTION (GST_PAD (pads->data)) == direction) {
+ if (GST_PAD_PEER (GST_PAD (pads->data)) == NULL) {
/* found it ! */
g_print ("DEBUG: found an unconnected pad !\n");
pad = GST_PAD (pads->data);
}
}
- if (pad) break; /* found one already */
+ if (pad)
+ break; /* found one already */
pads = g_list_next (pads);
}
elements = g_list_next (elements);
}
g_print ("DEBUG: find_unconnected stop\n");
- if (pad == NULL) /* we didn't find it at all */
+ if (pad == NULL) /* we didn't find it at all */
return NULL;
-
+
pad = gst_ghost_pad_new (name, pad);
return pad;
}
void
-ui_feedback_add_text (_filter_ui_t *ui, const gchar *text)
+ui_feedback_add_text (_filter_ui_t * ui, const gchar * text)
{
GtkTextIter iter;
}
void
-ui_feedback_add (_filter_ui_t *ui, const gchar *format, ...)
+ui_feedback_add (_filter_ui_t * ui, const gchar * format, ...)
{
va_list args;
gchar *buffer = NULL;
}
void
-ui_feedback_clear (_filter_ui_t *ui)
+ui_feedback_clear (_filter_ui_t * ui)
{
gtk_text_buffer_set_text (ui->fb_buffer, "", 0);
}
/* create the control widget using the element's dynparams
* control is a vbox which we need to empty first */
void
-ui_control_create (GstElement *element, GtkWidget *control, _filter_ui_t *ui)
+ui_control_create (GstElement * element, GtkWidget * control, _filter_ui_t * ui)
{
GtkWidget *hbox = NULL;
GtkWidget *widget = NULL;
GstDParam *dparam = NULL;
GParamSpec **specs = NULL;
int i = 0;
-
+
g_assert (GTK_IS_VBOX (control));
/* empty control vbox */
g_print ("DEBUG: emptying control widget\n");
- gtk_container_foreach (GTK_CONTAINER (control), cb_remove_and_destroy,
- (gpointer) control);
+ gtk_container_foreach (GTK_CONTAINER (control), cb_remove_and_destroy,
+ (gpointer) control);
g_print ("DEBUG: adding label to control widget\n");
widget = gtk_label_new ("Dynamic Parameters");
gtk_container_add (GTK_CONTAINER (control), widget);
gtk_widget_show (widget);
-
- if ((dpman = gst_dpman_get_manager (element)))
- {
+
+ if ((dpman = gst_dpman_get_manager (element))) {
ui_feedback_add (ui, "Found Dynamic Parameters on filter element.\n");
specs = gst_dpman_list_dparam_specs (dpman);
- for (i = 0; specs[i] != NULL; ++i)
- {
+ for (i = 0; specs[i] != NULL; ++i) {
hbox = gtk_hbox_new (FALSE, 0);
widget = gtk_label_new (g_param_spec_get_name (specs[i]));
gtk_container_add (GTK_CONTAINER (hbox), widget);
gtk_widget_show (widget);
- switch (G_PARAM_SPEC_VALUE_TYPE (specs[i]))
- {
- case G_TYPE_INT64:
+ switch (G_PARAM_SPEC_VALUE_TYPE (specs[i])) {
+ case G_TYPE_INT64:
widget = gtk_hscale_new_with_range (
- (gdouble) (((GParamSpecInt64*)specs[i])->minimum),
- (gdouble) (((GParamSpecInt64*)specs[i])->maximum),
- 1.0);
+ (gdouble) (((GParamSpecInt64 *) specs[i])->minimum),
+ (gdouble) (((GParamSpecInt64 *) specs[i])->maximum), 1.0);
gtk_range_set_value (GTK_RANGE (widget),
- (gdouble) ((GParamSpecInt64*)specs[i])->default_value);
- break;
+ (gdouble) ((GParamSpecInt64 *) specs[i])->default_value);
+ break;
case G_TYPE_INT:
widget = gtk_hscale_new_with_range (
- (gdouble) (((GParamSpecInt*)specs[i])->minimum),
- (gdouble) (((GParamSpecInt*)specs[i])->maximum),
- 1.0);
+ (gdouble) (((GParamSpecInt *) specs[i])->minimum),
+ (gdouble) (((GParamSpecInt *) specs[i])->maximum), 1.0);
gtk_range_set_value (GTK_RANGE (widget),
- (gdouble) ((GParamSpecInt*)specs[i])->default_value);
- break;
- case G_TYPE_FLOAT:
+ (gdouble) ((GParamSpecInt *) specs[i])->default_value);
+ break;
+ case G_TYPE_FLOAT:
widget = gtk_hscale_new_with_range (
- (gdouble) (((GParamSpecFloat*)specs[i])->minimum),
- (gdouble) (((GParamSpecFloat*)specs[i])->maximum),
- 0.00001);
+ (gdouble) (((GParamSpecFloat *) specs[i])->minimum),
+ (gdouble) (((GParamSpecFloat *) specs[i])->maximum), 0.00001);
gtk_range_set_value (GTK_RANGE (widget),
- (gdouble) ((GParamSpecFloat*)specs[i])->default_value);
+ (gdouble) ((GParamSpecFloat *) specs[i])->default_value);
break;
}
/* create the dparam object */
dparam = gst_dpsmooth_new (G_PARAM_SPEC_VALUE_TYPE (specs[i]));
g_object_set (G_OBJECT (dparam), "update_period", 2000000LL, NULL);
- g_assert (gst_dpman_attach_dparam (dpman,
- (gchar *) g_param_spec_get_name (specs[i]),
- dparam));
- gst_dpman_set_mode(dpman, "asynchronous");
+ g_assert (gst_dpman_attach_dparam (dpman,
+ (gchar *) g_param_spec_get_name (specs[i]), dparam));
+ gst_dpman_set_mode (dpman, "asynchronous");
g_signal_connect (widget, "value-changed",
- G_CALLBACK (cb_dynparm_value_changed), dparam);
+ G_CALLBACK (cb_dynparm_value_changed), dparam);
cb_dynparm_value_changed (GTK_RANGE (widget), dparam);
-
+
gtk_container_add (GTK_CONTAINER (hbox), widget);
- gtk_widget_show (widget);
+ gtk_widget_show (widget);
}
gtk_container_add (GTK_CONTAINER (control), hbox);
gtk_widget_show (hbox);
/* all the pretty callbacks gather here please */
void
-cb_remove_and_destroy (GtkWidget *widget, gpointer user_data)
+cb_remove_and_destroy (GtkWidget * widget, gpointer user_data)
{
GtkContainer *container = GTK_CONTAINER (user_data);
/* when the scale associated with a dparam changes, respond */
void
-cb_dynparm_value_changed (GtkRange *range, GstDParam *dparam)
+cb_dynparm_value_changed (GtkRange * range, GstDParam * dparam)
{
/*
- GstDParam *dparam = GST_DPARAM (user_data);
- GtkHScale *adj = GTK_HSCALE (widget);
- */
+ GstDParam *dparam = GST_DPARAM (user_data);
+ GtkHScale *adj = GTK_HSCALE (widget);
+ */
gdouble value = 0.0;
+
g_assert (GST_IS_DPARAM (dparam));
g_assert (GTK_IS_RANGE (range));
value = gtk_range_get_value (range);
- g_print ("DEBUG: setting value to %f\n", value);
+ g_print ("DEBUG: setting value to %f\n", value);
- switch (G_PARAM_SPEC_VALUE_TYPE (GST_DPARAM_PARAM_SPEC (dparam)))
- {
+ switch (G_PARAM_SPEC_VALUE_TYPE (GST_DPARAM_PARAM_SPEC (dparam))) {
case G_TYPE_INT64:
- g_object_set (G_OBJECT (dparam), "value_int64",
- (gint64) value, NULL);
+ g_object_set (G_OBJECT (dparam), "value_int64", (gint64) value, NULL);
break;
case G_TYPE_INT:
- g_object_set (G_OBJECT (dparam), "value_int",
- (gint) value, NULL);
+ g_object_set (G_OBJECT (dparam), "value_int", (gint) value, NULL);
break;
case G_TYPE_FLOAT:
- g_object_set (G_OBJECT (dparam), "value_float",
- (gfloat) value, NULL);
+ g_object_set (G_OBJECT (dparam), "value_float", (gfloat) value, NULL);
break;
}
}
-
+
void
-cb_entry_activate (GtkEntry *entry, gpointer user_data)
+cb_entry_activate (GtkEntry * entry, gpointer user_data)
{
g_print ("DEBUG: oi ! you activated an entry !\n");
g_print ("DEBUG: pipeline: %s\n", gtk_entry_get_text (entry));
}
void
-cb_play_clicked (GtkButton *button, gpointer *user_data)
+cb_play_clicked (GtkButton * button, gpointer * user_data)
{
_filter_data_t *fd = (_filter_data_t *) user_data;
g_return_if_fail (GST_IS_PIPELINE (fd->pipeline));
- if (GST_STATE (fd->pipeline) == GST_STATE_PLAYING)
- {
+ if (GST_STATE (fd->pipeline) == GST_STATE_PLAYING) {
ui_feedback_add (fd->ui, "Pipeline is already playing !\n");
return;
}
}
void
-cb_stop_clicked (GtkButton *button, gpointer *user_data)
+cb_stop_clicked (GtkButton * button, gpointer * user_data)
{
_filter_data_t *fd = (_filter_data_t *) user_data;
- if (GST_STATE (fd->pipeline) != GST_STATE_PLAYING)
- {
+ if (GST_STATE (fd->pipeline) != GST_STATE_PLAYING) {
ui_feedback_add (fd->ui, "Pipeline is not playing !\n");
return;
}
}
void
-cb_parse_clicked (GtkButton *button, gpointer *user_data)
+cb_parse_clicked (GtkButton * button, gpointer * user_data)
{
_filter_data_t *fd = (_filter_data_t *) user_data;
GtkCombo *filter = GTK_COMBO (fd->ui->filter);
GError *error = NULL;
GstPad *src_pad, *sink_pad;
-
+
g_print ("DEBUG: you pressed parse.\n");
ui_feedback_clear (fd->ui);
ui_feedback_add (fd->ui, "Parsing pipeline ...\n");
- if (fd->input_pipe) g_free (fd->input_pipe);
- if (fd->output_pipe) g_free (fd->output_pipe);
- if (fd->filter_element) g_free (fd->filter_element);
+ if (fd->input_pipe)
+ g_free (fd->input_pipe);
+ if (fd->output_pipe)
+ g_free (fd->output_pipe);
+ if (fd->filter_element)
+ g_free (fd->filter_element);
fd->input_pipe = g_strdup_printf ("bin.( %s )",
- gtk_entry_get_text (GTK_ENTRY (fd->ui->input)));
+ gtk_entry_get_text (GTK_ENTRY (fd->ui->input)));
fd->output_pipe = g_strdup_printf ("bin.( %s )",
- gtk_entry_get_text (GTK_ENTRY (fd->ui->output)));
+ gtk_entry_get_text (GTK_ENTRY (fd->ui->output)));
/* gtkcombo.h says I can access the entry field directly */
- fd->filter_element = g_strdup (gtk_entry_get_text (GTK_ENTRY (filter->entry)));
- g_print ("Input pipeline :\t%s (%d)\n", fd->input_pipe, (int)strlen (fd->input_pipe));
- g_print ("Filter element :\t%s (%d)\n", fd->filter_element, (int)strlen (fd->filter_element));
- g_print ("Output pipeline :\t%s (%d)\n", fd->output_pipe, (int)strlen (fd->output_pipe));
+ fd->filter_element =
+ g_strdup (gtk_entry_get_text (GTK_ENTRY (filter->entry)));
+ g_print ("Input pipeline :\t%s (%d)\n", fd->input_pipe,
+ (int) strlen (fd->input_pipe));
+ g_print ("Filter element :\t%s (%d)\n", fd->filter_element,
+ (int) strlen (fd->filter_element));
+ g_print ("Output pipeline :\t%s (%d)\n", fd->output_pipe,
+ (int) strlen (fd->output_pipe));
/* try to create in and out bins */
- if (strlen (fd->input_pipe) == 0)
- {
+ if (strlen (fd->input_pipe) == 0) {
ui_feedback_add (fd->ui, "Error : try setting an input pipe.\n");
return;
}
- if (fd->input) gst_object_unref (GST_OBJECT (fd->input));
+ if (fd->input)
+ gst_object_unref (GST_OBJECT (fd->input));
fd->input = GST_ELEMENT (gst_parse_launch (fd->input_pipe, &error));
- if (error)
- {
- ui_feedback_add (fd->ui, "Error : parsing input pipeline : %s\n",
- error->message);
+ if (error) {
+ ui_feedback_add (fd->ui, "Error : parsing input pipeline : %s\n",
+ error->message);
g_error_free (error);
return;
}
-
- if (strlen (fd->output_pipe) == 0)
- {
+
+ if (strlen (fd->output_pipe) == 0) {
ui_feedback_add (fd->ui, "Error : try setting an output pipe.\n");
return;
}
- if (fd->output) gst_object_unref (GST_OBJECT (fd->output));
+ if (fd->output)
+ gst_object_unref (GST_OBJECT (fd->output));
fd->output = GST_ELEMENT (gst_parse_launch (fd->output_pipe, &error));
- if (error)
- {
- ui_feedback_add (fd->ui, "Error : parsing output pipeline : %s\n",
- error->message);
+ if (error) {
+ ui_feedback_add (fd->ui, "Error : parsing output pipeline : %s\n",
+ error->message);
g_error_free (error);
return;
}
/* try to create filter */
- if (fd->filter) gst_object_unref (GST_OBJECT (fd->filter));
+ if (fd->filter)
+ gst_object_unref (GST_OBJECT (fd->filter));
fd->filter = gst_element_factory_make (fd->filter_element, "filter");
- if (fd->filter == NULL)
- {
+ if (fd->filter == NULL) {
ui_feedback_add (fd->ui, "Error : could not create element %s\n",
- fd->filter_element);
+ fd->filter_element);
return;
}
fd->pipeline = gst_thread_new ("toplevel");
/* add the players to it */
- gst_bin_add_many (GST_BIN (fd->pipeline),
- fd->input, fd->filter,
- fd->output, NULL);
+ gst_bin_add_many (GST_BIN (fd->pipeline),
+ fd->input, fd->filter, fd->output, NULL);
/* connect filter to input and output bin */
- src_pad = gst_bin_find_unconnected_pad (GST_BIN (fd->input), GST_PAD_SRC,
- "source");
- if (src_pad == NULL)
- {
- ui_feedback_add (fd->ui,
- "Error : could not find an unconnected source pad !\n");
+ src_pad = gst_bin_find_unconnected_pad (GST_BIN (fd->input), GST_PAD_SRC,
+ "source");
+ if (src_pad == NULL) {
+ ui_feedback_add (fd->ui,
+ "Error : could not find an unconnected source pad !\n");
return;
}
- sink_pad = gst_bin_find_unconnected_pad (GST_BIN (fd->output), GST_PAD_SINK,
- "sink");
- if (sink_pad == NULL)
- {
- ui_feedback_add (fd->ui,
- "Error : could not find an unconnected sink pad !\n");
+ sink_pad = gst_bin_find_unconnected_pad (GST_BIN (fd->output), GST_PAD_SINK,
+ "sink");
+ if (sink_pad == NULL) {
+ ui_feedback_add (fd->ui,
+ "Error : could not find an unconnected sink pad !\n");
return;
}
gst_element_add_pad (fd->input, src_pad);
gst_element_add_pad (fd->output, sink_pad);
gst_element_link_many (fd->input, fd->filter, fd->output, NULL);
-
- if (fd->pipe_string) g_free (fd->pipe_string);
+
+ if (fd->pipe_string)
+ g_free (fd->pipe_string);
fd->pipe_string = g_strdup_printf ("%s ! %s ! %s", fd->input_pipe,
- fd->filter_element, fd->output_pipe);
+ fd->filter_element, fd->output_pipe);
g_print ("Pipeline : %s\n", fd->pipe_string);
ui_feedback_add (fd->ui, "Complete parsed pipeline: %s\n", fd->pipe_string);
choices = g_list_append (choices, "volume");
choices = g_list_append (choices, "ladspa_lpf");
choices = g_list_append (choices, "ladspa_hpf");
-
+
return choices;
}
void
-init_data (_filter_data_t *fd)
+init_data (_filter_data_t * fd)
{
fd->input_pipe = NULL;
fd->output_pipe = NULL;
}
void
-create_ui (_filter_ui_t *fui, _filter_data_t *fd)
+create_ui (_filter_ui_t * fui, _filter_data_t * fd)
{
GtkWidget *widget; /* temporary widget */
GtkWidget *vbox; /* temporary vbox */
-
+
g_print ("DEBUG: creating top-level window\n");
fui->window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
widget = gtk_vbox_new (FALSE, 0);
fui->parse = gtk_button_new_with_label ("Parse");
gtk_container_add (GTK_CONTAINER (fui->buttons), fui->parse);
g_signal_connect (G_OBJECT (fui->parse), "clicked",
- G_CALLBACK (cb_parse_clicked), fd);
+ G_CALLBACK (cb_parse_clicked), fd);
fui->play = gtk_button_new_with_label ("Play");
gtk_container_add (GTK_CONTAINER (fui->buttons), fui->play);
g_signal_connect (G_OBJECT (fui->play), "clicked",
- G_CALLBACK (cb_play_clicked), fd);
+ G_CALLBACK (cb_play_clicked), fd);
fui->stop = gtk_button_new_with_label ("Stop");
gtk_container_add (GTK_CONTAINER (fui->buttons), fui->stop);
g_signal_connect (G_OBJECT (fui->stop), "clicked",
- G_CALLBACK (cb_stop_clicked), fd);
+ G_CALLBACK (cb_stop_clicked), fd);
/* feedback widget */
fui->fb_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (fui->feedback));
- gtk_text_buffer_set_text (fui->fb_buffer,
- "Hello, and welcome to the GStreamer filter demo app !\n"\
+ gtk_text_buffer_set_text (fui->fb_buffer,
+ "Hello, and welcome to the GStreamer filter demo app !\n"
"I'll be your feedback window for today.\n", -1);
-
+
/* selection widget */
vbox = gtk_vbox_new (FALSE, 0);
widget = gtk_label_new ("Input Pipe");
gtk_entry_set_text (GTK_ENTRY (fui->input), "sinesrc");
gtk_container_add (GTK_CONTAINER (vbox), fui->input);
gtk_container_add (GTK_CONTAINER (fui->selection), vbox);
- g_signal_connect (G_OBJECT (fui->input), "activate",
- G_CALLBACK (cb_entry_activate), NULL);
+ g_signal_connect (G_OBJECT (fui->input), "activate",
+ G_CALLBACK (cb_entry_activate), NULL);
vbox = gtk_vbox_new (FALSE, 0);
widget = gtk_label_new ("Filter");
widget = gtk_label_new ("Output Pipe");
gtk_container_add (GTK_CONTAINER (vbox), widget);
fui->output = gtk_entry_new ();
- gtk_entry_set_text (GTK_ENTRY (fui->output), "osssink fragment=1572872"); /* fixme: gconf default ? */
+ gtk_entry_set_text (GTK_ENTRY (fui->output), "osssink fragment=1572872"); /* fixme: gconf default ? */
gtk_container_add (GTK_CONTAINER (vbox), fui->output);
gtk_container_add (GTK_CONTAINER (fui->selection), vbox);
- g_signal_connect (G_OBJECT (fui->output), "activate",
- G_CALLBACK (cb_entry_activate), NULL);
+ g_signal_connect (G_OBJECT (fui->output), "activate",
+ G_CALLBACK (cb_entry_activate), NULL);
/* control widget is dynamically generated */
/*
- g_print ("DEBUG: labeling control area.\n");
- widget = gtk_label_new ("This is the big control area.");
- gtk_container_add (GTK_CONTAINER (fui->control), widget);
- */
+ g_print ("DEBUG: labeling control area.\n");
+ widget = gtk_label_new ("This is the big control area.");
+ gtk_container_add (GTK_CONTAINER (fui->control), widget);
+ */
}
{
_filter_data_t filter_data;
_filter_ui_t filter_ui;
-
-
+
+
gtk_init (&argc, &argv);
gst_init (&argc, &argv);
gst_control_init (&argc, &argv);
gtk_widget_show_all (filter_ui.window);
gtk_main ();
-
+
return 0;
}
-
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
-
+
#include <gst/play/play.h>
static GMainLoop *loop = NULL;
static gint64 length = 0;
static void
-print_tag (const GstTagList *list, const gchar *tag, gpointer unused)
+print_tag (const GstTagList * list, const gchar * tag, gpointer unused)
{
gint i, count;
for (i = 0; i < count; i++) {
gchar *str;
-
+
if (gst_tag_get_type (tag) == G_TYPE_STRING) {
g_assert (gst_tag_list_get_string_index (list, tag, i, &str));
} else {
- str = g_strdup_value_contents (
- gst_tag_list_get_value_index (list, tag, i));
+ str =
+ g_strdup_value_contents (gst_tag_list_get_value_index (list, tag, i));
}
-
+
if (i == 0) {
g_print ("%15s: %s\n", gst_tag_get_nick (tag), str);
} else {
}
static void
-got_found_tag (GstPlay *play,GstElement *source, GstTagList *tag_list)
+got_found_tag (GstPlay * play, GstElement * source, GstTagList * tag_list)
{
gst_tag_list_foreach (tag_list, print_tag, NULL);
}
static void
-got_time_tick (GstPlay *play, gint64 time_nanos)
+got_time_tick (GstPlay * play, gint64 time_nanos)
{
g_print ("time tick %f\n", time_nanos / (float) GST_SECOND);
}
static void
-got_stream_length (GstPlay *play, gint64 length_nanos)
+got_stream_length (GstPlay * play, gint64 length_nanos)
{
g_print ("got length %llu\n", length_nanos);
length = length_nanos;
}
static void
-got_video_size (GstPlay *play, gint width, gint height)
+got_video_size (GstPlay * play, gint width, gint height)
{
g_print ("got video size %d, %d\n", width, height);
}
static void
-got_eos (GstPlay *play)
+got_eos (GstPlay * play)
{
g_print ("End Of Stream\n");
g_main_loop_quit (loop);
}
static gboolean
-seek_timer (GstPlay *play)
+seek_timer (GstPlay * play)
{
gst_play_seek_to_time (play, length / 2);
return FALSE;
}
static gboolean
-idle_iterate (GstPlay *play)
+idle_iterate (GstPlay * play)
{
gst_bin_iterate (GST_BIN (play));
return (GST_STATE (GST_ELEMENT (play)) == GST_STATE_PLAYING);
/* Creating the GstPlay object */
play = gst_play_new (&error);
- if (error)
- {
+ if (error) {
g_print ("Error: could not create play object:\n%s\n", error->message);
g_error_free (error);
return 1;
/* gst_xml_write_file (GST_ELEMENT (play), stdout); */
g_signal_connect (G_OBJECT (play), "time_tick",
- G_CALLBACK (got_time_tick), NULL);
+ G_CALLBACK (got_time_tick), NULL);
g_signal_connect (G_OBJECT (play), "stream_length",
- G_CALLBACK (got_stream_length), NULL);
+ G_CALLBACK (got_stream_length), NULL);
g_signal_connect (G_OBJECT (play), "have_video_size",
- G_CALLBACK (got_video_size), NULL);
+ G_CALLBACK (got_video_size), NULL);
g_signal_connect (G_OBJECT (play), "found_tag",
- G_CALLBACK (got_found_tag), NULL);
+ G_CALLBACK (got_found_tag), NULL);
g_signal_connect (G_OBJECT (play), "error",
- G_CALLBACK (gst_element_default_error), NULL);
- g_signal_connect (G_OBJECT (play), "eos",
- G_CALLBACK (got_eos), NULL);
+ G_CALLBACK (gst_element_default_error), NULL);
+ g_signal_connect (G_OBJECT (play), "eos", G_CALLBACK (got_eos), NULL);
/* Change state to PLAYING */
gst_element_set_state (GST_ELEMENT (play), GST_STATE_PLAYING);
g_print ("setting pipeline to ready\n");
gst_element_set_state (GST_ELEMENT (play), GST_STATE_READY);
-
+
/* unref
- gst_object_unref (GST_OBJECT (play)); */
+ gst_object_unref (GST_OBJECT (play)); */
exit (0);
}
static gboolean quiet = FALSE;
static void
-entry_added (GstIndex *index, GstIndexEntry *entry)
+entry_added (GstIndex * index, GstIndexEntry * entry)
{
switch (entry->type) {
case GST_INDEX_ENTRY_ID:
- g_print ("id %d describes writer %s\n", entry->id,
- GST_INDEX_ID_DESCRIPTION (entry));
+ g_print ("id %d describes writer %s\n", entry->id,
+ GST_INDEX_ID_DESCRIPTION (entry));
break;
case GST_INDEX_ENTRY_FORMAT:
- g_print ("%d: registered format %d for %s\n", entry->id,
- GST_INDEX_FORMAT_FORMAT (entry),
- GST_INDEX_FORMAT_KEY (entry));
+ g_print ("%d: registered format %d for %s\n", entry->id,
+ GST_INDEX_FORMAT_FORMAT (entry), GST_INDEX_FORMAT_KEY (entry));
break;
case GST_INDEX_ENTRY_ASSOCIATION:
{
gint i;
- g_print ("%p, %d: %08x ", entry, entry->id, GST_INDEX_ASSOC_FLAGS (entry));
+ g_print ("%p, %d: %08x ", entry, entry->id,
+ GST_INDEX_ASSOC_FLAGS (entry));
for (i = 0; i < GST_INDEX_NASSOCS (entry); i++) {
- g_print ("%d %lld ", GST_INDEX_ASSOC_FORMAT (entry, i),
- GST_INDEX_ASSOC_VALUE (entry, i));
+ g_print ("%d %lld ", GST_INDEX_ASSOC_FORMAT (entry, i),
+ GST_INDEX_ASSOC_VALUE (entry, i));
}
g_print ("\n");
break;
typedef struct
{
- const gchar *padname;
- GstPad *target;
- GstElement *bin;
- GstElement *pipeline;
- GstIndex *index;
+ const gchar *padname;
+ GstPad *target;
+ GstElement *bin;
+ GstElement *pipeline;
+ GstIndex *index;
} dyn_link;
static void
-dynamic_link (GstPadTemplate *templ, GstPad *newpad, gpointer data)
+dynamic_link (GstPadTemplate * templ, GstPad * newpad, gpointer data)
{
dyn_link *link = (dyn_link *) data;
}
static void
-setup_dynamic_linking (GstElement *pipeline,
- GstElement *element,
- const gchar *padname,
- GstPad *target,
- GstElement *bin,
- GstIndex *index)
+setup_dynamic_linking (GstElement * pipeline,
+ GstElement * element,
+ const gchar * padname, GstPad * target, GstElement * bin, GstIndex * index)
{
dyn_link *link;
link = g_new0 (dyn_link, 1);
- link->padname = g_strdup (padname);
- link->target = target;
- link->bin = bin;
- link->pipeline = pipeline;
- link->index = index;
-
- g_signal_connect (G_OBJECT (element), "new_pad", G_CALLBACK (dynamic_link), link);
+ link->padname = g_strdup (padname);
+ link->target = target;
+ link->bin = bin;
+ link->pipeline = pipeline;
+ link->index = index;
+
+ g_signal_connect (G_OBJECT (element), "new_pad", G_CALLBACK (dynamic_link),
+ link);
}
-static GstElement*
-make_mpeg_systems_pipeline (const gchar *path, GstIndex *index)
+static GstElement *
+make_mpeg_systems_pipeline (const gchar * path, GstIndex * index)
{
GstElement *pipeline;
GstElement *src, *demux;
}
gst_element_link_pads (src, "src", demux, "sink");
-
+
return pipeline;
}
-static GstElement*
-make_mpeg_decoder_pipeline (const gchar *path, GstIndex *index)
+static GstElement *
+make_mpeg_decoder_pipeline (const gchar * path, GstIndex * index)
{
GstElement *pipeline;
GstElement *src, *demux;
video_decoder = gst_element_factory_make ("mpeg2dec", "video_decoder");
gst_bin_add (GST_BIN (video_bin), video_decoder);
-
- setup_dynamic_linking (pipeline, demux, "video_00",
- gst_element_get_pad (video_decoder, "sink"),
- video_bin, index);
+
+ setup_dynamic_linking (pipeline, demux, "video_00",
+ gst_element_get_pad (video_decoder, "sink"), video_bin, index);
audio_bin = gst_bin_new ("audio_bin");
audio_decoder = gst_element_factory_make ("mad", "audio_decoder");
- setup_dynamic_linking (pipeline, demux, "audio_00",
- gst_element_get_pad (audio_decoder, "sink"),
- audio_bin, index);
+ setup_dynamic_linking (pipeline, demux, "audio_00",
+ gst_element_get_pad (audio_decoder, "sink"), audio_bin, index);
gst_bin_add (GST_BIN (audio_bin), audio_decoder);
if (index) {
gst_element_set_index (pipeline, index);
}
-
+
return pipeline;
}
static void
-print_progress (GstPad *pad)
+print_progress (GstPad * pad)
{
gint i = 0;
gchar status[53];
format = GST_FORMAT_PERCENT;
res = gst_pad_query (pad, GST_QUERY_POSITION, &format, &value);
if (res) {
- percent = value / (2 * GST_FORMAT_PERCENT_SCALE);
+ percent = value / (2 * GST_FORMAT_PERCENT_SCALE);
}
-
+
for (i = 0; i < percent; i++) {
- status[i+1] = '=';
+ status[i + 1] = '=';
}
for (i = percent; i < 50; i++) {
- status[i+1] = ' ';
+ status[i + 1] = ' ';
}
status[51] = '|';
status[52] = 0;
g_print ("%s\r", status);
}
-gint
-main (gint argc, gchar *argv[])
+gint
+main (gint argc, gchar * argv[])
{
GstElement *pipeline;
GstElement *src;
gboolean res;
GstElement *sink;
struct poptOption options[] = {
- { "verbose", 'v', POPT_ARG_NONE|POPT_ARGFLAG_STRIP, &verbose, 0,
- "Print index entries", NULL},
- { "quiet", 'q', POPT_ARG_NONE|POPT_ARGFLAG_STRIP, &quiet, 0,
- "don't print progress bar", NULL},
- POPT_TABLEEND
- };
+ {"verbose", 'v', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &verbose, 0,
+ "Print index entries", NULL},
+ {"quiet", 'q', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &quiet, 0,
+ "don't print progress bar", NULL},
+ POPT_TABLEEND
+ };
if (!gst_init_check_with_popt_table (&argc, &argv, options) || argc < 3) {
- g_print ("usage: %s [-v] <type> <filename> \n"
- " type can be: 0 mpeg_systems\n"
- " 1 mpeg_decoder\n"
- " -v : report added index entries\n"
- " -q : don't print progress\n" , argv[0]);
+ g_print ("usage: %s [-v] <type> <filename> \n"
+ " type can be: 0 mpeg_systems\n"
+ " 1 mpeg_decoder\n"
+ " -v : report added index entries\n"
+ " -q : don't print progress\n", argv[0]);
return -1;
}
/* create index that elements can fill */
index = gst_index_factory_make ("memindex");
if (index) {
- if (verbose)
- g_signal_connect (G_OBJECT (index), "entry_added", G_CALLBACK (entry_added), NULL);
+ if (verbose)
+ g_signal_connect (G_OBJECT (index), "entry_added",
+ G_CALLBACK (entry_added), NULL);
g_object_set (G_OBJECT (index), "resolver", 1, NULL);
}
}
/* setup some default info/error handlers */
- g_signal_connect (G_OBJECT (pipeline), "deep_notify",
- G_CALLBACK (gst_element_default_deep_notify), NULL);
- g_signal_connect (G_OBJECT (pipeline), "error",
- G_CALLBACK (gst_element_default_error), NULL);
+ g_signal_connect (G_OBJECT (pipeline), "deep_notify",
+ G_CALLBACK (gst_element_default_deep_notify), NULL);
+ g_signal_connect (G_OBJECT (pipeline), "error",
+ G_CALLBACK (gst_element_default_error), NULL);
/* get a pad to perform progress reporting on */
src = gst_bin_get_by_name (GST_BIN (pipeline), "src");
/* prepare for iteration */
gst_element_set_state (pipeline, GST_STATE_PLAYING);
- g_print ("indexing %s...\n", argv [2]);
+ g_print ("indexing %s...\n", argv[2]);
/* run through the complete stream to let it generate an index */
while (gst_bin_iterate (GST_BIN (pipeline))) {
if (!quiet && (count % 1000 == 0)) {
gint total_tm;
gst_index_get_writer_id (index, GST_OBJECT (src), &id);
-
+
entry = gst_index_get_assoc_entry (index, id, GST_INDEX_LOOKUP_BEFORE, 0,
- GST_FORMAT_TIME, G_MAXINT64);
+ GST_FORMAT_TIME, G_MAXINT64);
g_assert (entry);
gst_index_entry_assoc_map (entry, GST_FORMAT_TIME, &result);
total_tm = result * 60 / GST_SECOND;
g_print ("total time = %.2fs\n", total_tm / 60.0);
}
-
+
pad = gst_element_get_pad (src, "src");
sink = gst_element_factory_make ("fakesink", "sink");
gst_element_link_pads (src, "src", sink, "sink");
gst_bin_add (GST_BIN (pipeline), sink);
- g_print ("seeking %s...\n", argv [2]);
+ g_print ("seeking %s...\n", argv[2]);
event = gst_event_new_seek (GST_FORMAT_TIME |
- GST_SEEK_METHOD_SET |
- GST_SEEK_FLAG_FLUSH, 5 * GST_SECOND);
+ GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, 5 * GST_SECOND);
res = gst_pad_send_event (pad, event);
if (!res) {
return 1;
}
-
#include <string.h>
static void
-get_position_info (GstElement *cdparanoia)
+get_position_info (GstElement * cdparanoia)
{
GstFormat track_format;
const GstFormat *formats;
definition = gst_format_get_details (*formats);
format = *formats;
- res = gst_pad_query (pad, GST_QUERY_POSITION,
- &format, &position);
+ res = gst_pad_query (pad, GST_QUERY_POSITION, &format, &position);
if (format == GST_FORMAT_TIME) {
position /= GST_SECOND;
- g_print ("%s: %lld:%02lld", definition->nick, position/60, position%60);
- }
- else {
+ g_print ("%s: %lld:%02lld", definition->nick, position / 60,
+ position % 60);
+ } else {
g_print ("%s: %lld", definition->nick, position);
}
}
static void
-get_track_info (GstElement *cdparanoia)
+get_track_info (GstElement * cdparanoia)
{
GstFormat track_format;
gint64 total_tracks = 0, total_time = 0;
const GstFormat *formats;
gint i;
gint64 time_count = 0;
-
+
track_format = gst_format_get_by_nick ("track");
g_assert (track_format != 0);
gint64 total;
GstFormat format;
gboolean res;
-
+
definition = gst_format_get_details (*formats);
format = *formats;
- res = gst_pad_query (pad, GST_QUERY_TOTAL,
- &format, &total);
+ res = gst_pad_query (pad, GST_QUERY_TOTAL, &format, &total);
if (res) {
if (format == GST_FORMAT_TIME) {
total /= GST_SECOND;
- g_print ("%s total: %lld:%02lld\n", definition->nick, total/60, total%60);
- }
- else
- g_print ("%s total: %lld\n", definition->nick, total);
+ g_print ("%s total: %lld:%02lld\n", definition->nick, total / 60,
+ total % 60);
+ } else
+ g_print ("%s total: %lld\n", definition->nick, total);
if (format == track_format)
total_tracks = total;
else if (format == GST_FORMAT_TIME)
total_time = total;
- }
- else
+ } else
g_print ("failed to get %s total\n", definition->nick);
formats++;
GstFormat format;
format = GST_FORMAT_TIME;
- res = gst_pad_convert (pad, track_format, i,
- &format, &time);
+ res = gst_pad_convert (pad, track_format, i, &format, &time);
time /= GST_SECOND;
- }
- else {
+ } else {
time = total_time;
res = TRUE;
}
if (i > 0) {
gint64 length = time - time_count;
- g_print ("track %d: %lld:%02lld -> %lld:%02lld, length: %lld:%02lld\n",
- i-1,
- time_count / 60, time_count % 60,
- time / 60, time % 60,
- length / 60, length % 60);
+ g_print ("track %d: %lld:%02lld -> %lld:%02lld, length: %lld:%02lld\n",
+ i - 1,
+ time_count / 60, time_count % 60,
+ time / 60, time % 60, length / 60, length % 60);
}
- }
- else {
+ } else {
g_print ("could not get time for track %d\n", i);
}
gst_element_link_pads (cdparanoia, "src", osssink, "sink");
g_signal_connect (G_OBJECT (pipeline), "deep_notify",
- G_CALLBACK (gst_element_default_deep_notify), NULL);
+ G_CALLBACK (gst_element_default_deep_notify), NULL);
gst_element_set_state (pipeline, GST_STATE_PAUSED);
g_print ("playing from track 3\n");
/* seek to track3 */
event = gst_event_new_seek (track_format |
- GST_SEEK_METHOD_SET |
- GST_SEEK_FLAG_FLUSH,
- 3);
+ GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, 3);
res = gst_pad_send_event (pad, event);
if (!res)
g_print ("\nplaying from second 25 to second 29\n");
/* seek to some seconds */
event = gst_event_new_segment_seek (GST_FORMAT_TIME |
- GST_SEEK_METHOD_SET |
- GST_SEEK_FLAG_FLUSH,
- 25 * GST_SECOND, 29 * GST_SECOND);
+ GST_SEEK_METHOD_SET |
+ GST_SEEK_FLAG_FLUSH, 25 * GST_SECOND, 29 * GST_SECOND);
res = gst_pad_send_event (pad, event);
if (!res)
g_warning ("seek failed");
#define UPDATE_INTERVAL 500
-static GstElement*
-make_cdaudio_pipeline (void)
+static GstElement *
+make_cdaudio_pipeline (void)
{
GstElement *cdaudio;
-
+
cdaudio = gst_element_factory_make ("cdaudio", "cdaudio");
g_assert (cdaudio != NULL);
return cdaudio;
}
-static gchar*
-format_value (GtkScale *scale,
- gdouble value)
+static gchar *
+format_value (GtkScale * scale, gdouble value)
{
gint64 real;
gint64 seconds;
subseconds = (gint64) real / (GST_SECOND / 100);
return g_strdup_printf ("%02lld:%02lld:%02lld",
- seconds/60,
- seconds%60,
- subseconds%100);
+ seconds / 60, seconds % 60, subseconds % 100);
}
typedef struct
const GstFormat format;
} seek_format;
-static seek_format seek_formats[] =
-{
- { "tim", GST_FORMAT_TIME },
- { "byt", GST_FORMAT_BYTES },
- { "buf", GST_FORMAT_BUFFERS },
- { "def", GST_FORMAT_DEFAULT },
- { NULL, 0 },
+static seek_format seek_formats[] = {
+ {"tim", GST_FORMAT_TIME},
+ {"byt", GST_FORMAT_BYTES},
+ {"buf", GST_FORMAT_BUFFERS},
+ {"def", GST_FORMAT_DEFAULT},
+ {NULL, 0},
};
format = seek_formats[i].format;
res = gst_element_query (element, GST_QUERY_TOTAL, &format, &value);
if (res) {
- g_print ("%s %13lld | ", seek_formats[i].name, value);
- }
- else {
- g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
+ g_print ("%s %13lld | ", seek_formats[i].name, value);
+ } else {
+ g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
}
i++;
}
format = seek_formats[i].format;
res = gst_element_query (element, GST_QUERY_POSITION, &format, &value);
if (res) {
- g_print ("%s %13lld | ", seek_formats[i].name, value);
- }
- else {
- g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
+ g_print ("%s %13lld | ", seek_formats[i].name, value);
+ } else {
+ g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
}
i++;
}
}
static gboolean
-update_scale (gpointer data)
+update_scale (gpointer data)
{
GstClock *clock;
guint64 position = 0;
if (seekable_elements) {
GstElement *element = GST_ELEMENT (seekable_elements->data);
+
gst_element_query (element, GST_QUERY_TOTAL, &format, &duration);
}
if (clock)
if (stats) {
if (clock)
- g_print ("clock: %13llu (%s)\n", position, gst_object_get_name (GST_OBJECT (clock)));
+ g_print ("clock: %13llu (%s)\n", position,
+ gst_object_get_name (GST_OBJECT (clock)));
query_durations ();
query_positions ();
}
}
static gboolean
-start_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
+start_seek (GtkWidget * widget, GdkEventButton * event, gpointer user_data)
{
gst_element_set_state (pipeline, GST_STATE_PAUSED);
gtk_timeout_remove (update_id);
}
static gboolean
-stop_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
+stop_seek (GtkWidget * widget, GdkEventButton * event, gpointer user_data)
{
gint64 real = gtk_range_get_value (GTK_RANGE (widget)) * duration / 100;
gboolean res;
g_print ("seek to %lld on element %s\n", real, GST_ELEMENT_NAME (seekable));
s_event = gst_event_new_seek (GST_FORMAT_TIME |
- GST_SEEK_METHOD_SET |
- GST_SEEK_FLAG_FLUSH, real);
+ GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, real);
res = gst_element_send_event (seekable, s_event);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
if (!GST_FLAG_IS_SET (pipeline, GST_BIN_SELF_SCHEDULABLE))
gtk_idle_add ((GtkFunction) iterate, pipeline);
- update_id = gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
+ update_id =
+ gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
return FALSE;
}
gst_element_set_state (pipeline, GST_STATE_PLAYING);
if (!GST_FLAG_IS_SET (pipeline, GST_BIN_SELF_SCHEDULABLE))
gtk_idle_add ((GtkFunction) iterate, pipeline);
- update_id = gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
+ update_id =
+ gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
}
}
int
main (int argc, char **argv)
{
- GtkWidget *window, *hbox, *vbox,
- *play_button, *pause_button, *stop_button,
- *hscale;
+ GtkWidget *window, *hbox, *vbox,
+ *play_button, *pause_button, *stop_button, *hscale;
struct poptOption options[] = {
- {"stats", 's', POPT_ARG_NONE|POPT_ARGFLAG_STRIP, &stats, 0,
- "Show element stats", NULL},
- POPT_TABLEEND
- };
+ {"stats", 's', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &stats, 0,
+ "Show element stats", NULL},
+ POPT_TABLEEND
+ };
gst_init_with_popt_table (&argc, &argv, options);
gtk_init (&argc, &argv);
pipeline = make_cdaudio_pipeline ();
- g_signal_connect (pipeline, "deep_notify", G_CALLBACK (gst_element_default_deep_notify), NULL);
- g_signal_connect (pipeline, "error", G_CALLBACK (gst_element_default_error), NULL);
+ g_signal_connect (pipeline, "deep_notify",
+ G_CALLBACK (gst_element_default_deep_notify), NULL);
+ g_signal_connect (pipeline, "error", G_CALLBACK (gst_element_default_error),
+ NULL);
/* initialize gui elements ... */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
pause_button = gtk_button_new_with_label ("pause");
stop_button = gtk_button_new_with_label ("stop");
- adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.00, 100.0, 0.1, 1.0, 1.0));
+ adjustment =
+ GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.00, 100.0, 0.1, 1.0, 1.0));
hscale = gtk_hscale_new (adjustment);
gtk_scale_set_digits (GTK_SCALE (hscale), 2);
gtk_range_set_update_policy (GTK_RANGE (hscale), GTK_UPDATE_CONTINUOUS);
- gtk_signal_connect(GTK_OBJECT(hscale),
- "button_press_event", G_CALLBACK (start_seek), pipeline);
- gtk_signal_connect(GTK_OBJECT(hscale),
- "button_release_event", G_CALLBACK (stop_seek), pipeline);
- gtk_signal_connect(GTK_OBJECT(hscale),
- "format_value", G_CALLBACK (format_value), pipeline);
+ gtk_signal_connect (GTK_OBJECT (hscale),
+ "button_press_event", G_CALLBACK (start_seek), pipeline);
+ gtk_signal_connect (GTK_OBJECT (hscale),
+ "button_release_event", G_CALLBACK (stop_seek), pipeline);
+ gtk_signal_connect (GTK_OBJECT (hscale),
+ "format_value", G_CALLBACK (format_value), pipeline);
/* do the packing stuff ... */
gtk_window_set_default_size (GTK_WINDOW (window), 96, 96);
gtk_box_pack_start (GTK_BOX (vbox), hscale, TRUE, TRUE, 2);
/* connect things ... */
- g_signal_connect (G_OBJECT (play_button), "clicked", G_CALLBACK (play_cb), pipeline);
- g_signal_connect (G_OBJECT (pause_button), "clicked", G_CALLBACK (pause_cb), pipeline);
- g_signal_connect (G_OBJECT (stop_button), "clicked", G_CALLBACK (stop_cb), pipeline);
+ g_signal_connect (G_OBJECT (play_button), "clicked", G_CALLBACK (play_cb),
+ pipeline);
+ g_signal_connect (G_OBJECT (pause_button), "clicked", G_CALLBACK (pause_cb),
+ pipeline);
+ g_signal_connect (G_OBJECT (stop_button), "clicked", G_CALLBACK (stop_cb),
+ pipeline);
g_signal_connect (G_OBJECT (window), "delete_event", gtk_main_quit, NULL);
/* show the gui. */
typedef struct
{
- const gchar *padname;
- GstPad *target;
- GstElement *bin;
+ const gchar *padname;
+ GstPad *target;
+ GstElement *bin;
} dyn_link;
static GstElement *
-gst_element_factory_make_or_warn (gchar *type, gchar *name)
+gst_element_factory_make_or_warn (gchar * type, gchar * name)
{
GstElement *element = gst_element_factory_make (type, name);
if (!element) {
- g_warning ("Failed to create element %s of type %s",
- name, type);
+ g_warning ("Failed to create element %s of type %s", name, type);
}
return element;
}
static void
-dynamic_link (GstPadTemplate *templ, GstPad *newpad, gpointer data)
+dynamic_link (GstPadTemplate * templ, GstPad * newpad, gpointer data)
{
dyn_link *connect = (dyn_link *) data;
}
static void
-setup_dynamic_link (GstElement *element, const gchar *padname, GstPad *target, GstElement *bin)
+setup_dynamic_link (GstElement * element, const gchar * padname,
+ GstPad * target, GstElement * bin)
{
dyn_link *connect;
connect = g_new0 (dyn_link, 1);
- connect->padname = g_strdup (padname);
- connect->target = target;
- connect->bin = bin;
+ connect->padname = g_strdup (padname);
+ connect->target = target;
+ connect->bin = bin;
- g_signal_connect (G_OBJECT (element), "new_pad", G_CALLBACK (dynamic_link), connect);
+ g_signal_connect (G_OBJECT (element), "new_pad", G_CALLBACK (dynamic_link),
+ connect);
}
-static GstElement*
-make_mod_pipeline (const gchar *location)
+static GstElement *
+make_mod_pipeline (const gchar * location)
{
GstElement *pipeline;
GstElement *src, *decoder, *audiosink;
GstPad *seekable;
-
+
pipeline = gst_pipeline_new ("app");
src = gst_element_factory_make_or_warn (SOURCE, "src");
return pipeline;
}
-static GstElement*
-make_dv_pipeline (const gchar *location)
+static GstElement *
+make_dv_pipeline (const gchar * location)
{
GstElement *pipeline;
GstElement *src, *decoder, *audiosink, *videosink;
GstPad *seekable;
-
+
pipeline = gst_pipeline_new ("app");
src = gst_element_factory_make_or_warn (SOURCE, "src");
return pipeline;
}
-static GstElement*
-make_wav_pipeline (const gchar *location)
+static GstElement *
+make_wav_pipeline (const gchar * location)
{
GstElement *pipeline;
GstElement *src, *decoder, *audiosink;
GstPad *seekable;
-
+
pipeline = gst_pipeline_new ("app");
src = gst_element_factory_make_or_warn (SOURCE, "src");
return pipeline;
}
-static GstElement*
-make_flac_pipeline (const gchar *location)
+static GstElement *
+make_flac_pipeline (const gchar * location)
{
GstElement *pipeline;
GstElement *src, *decoder, *audiosink;
GstPad *seekable;
-
+
pipeline = gst_pipeline_new ("app");
src = gst_element_factory_make_or_warn (SOURCE, "src");
return pipeline;
}
-static GstElement*
-make_sid_pipeline (const gchar *location)
+static GstElement *
+make_sid_pipeline (const gchar * location)
{
GstElement *pipeline;
GstElement *src, *decoder, *audiosink;
GstPad *seekable;
-
+
pipeline = gst_pipeline_new ("app");
src = gst_element_factory_make_or_warn (SOURCE, "src");
return pipeline;
}
-static GstElement*
-make_parse_pipeline (const gchar *location)
+static GstElement *
+make_parse_pipeline (const gchar * location)
{
GstElement *pipeline;
GstElement *src, *parser, *fakesink;
GstPad *seekable;
-
+
pipeline = gst_pipeline_new ("app");
src = gst_element_factory_make_or_warn (SOURCE, "src");
return pipeline;
}
-static GstElement*
-make_vorbis_pipeline (const gchar *location)
+static GstElement *
+make_vorbis_pipeline (const gchar * location)
{
GstElement *pipeline;
GstElement *src, *decoder, *audiosink;
GstPad *seekable;
-
+
pipeline = gst_pipeline_new ("app");
src = gst_element_factory_make_or_warn (SOURCE, "src");
return pipeline;
}
-static GstElement*
-make_mp3_pipeline (const gchar *location)
+static GstElement *
+make_mp3_pipeline (const gchar * location)
{
GstElement *pipeline;
GstElement *src, *decoder, *osssink, *queue, *audio_thread;
GstPad *seekable;
-
+
pipeline = gst_pipeline_new ("app");
src = gst_element_factory_make_or_warn (SOURCE, "src");
return pipeline;
}
-static GstElement*
-make_avi_pipeline (const gchar *location)
+static GstElement *
+make_avi_pipeline (const gchar * location)
{
GstElement *pipeline, *audio_bin, *video_bin;
GstElement *src, *demux, *a_decoder, *v_decoder, *audiosink, *videosink;
- GstElement *a_queue = NULL, *audio_thread = NULL, *v_queue = NULL, *video_thread = NULL;
+ GstElement *a_queue = NULL, *audio_thread = NULL, *v_queue =
+ NULL, *video_thread = NULL;
GstPad *seekable;
-
+
pipeline = gst_pipeline_new ("app");
src = gst_element_factory_make_or_warn (SOURCE, "src");
gst_bin_add (GST_BIN (audio_thread), audiosink);
gst_element_set_state (audio_bin, GST_STATE_PAUSED);
- setup_dynamic_link (demux, "audio_00", gst_element_get_pad (a_decoder, "sink"), audio_bin);
+ setup_dynamic_link (demux, "audio_00", gst_element_get_pad (a_decoder,
+ "sink"), audio_bin);
seekable = gst_element_get_pad (a_queue, "src");
seekable_pads = g_list_prepend (seekable_pads, seekable);
rate_pads = g_list_prepend (rate_pads, seekable);
- rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (a_decoder, "sink"));
+ rate_pads =
+ g_list_prepend (rate_pads, gst_element_get_pad (a_decoder, "sink"));
video_bin = gst_bin_new ("v_decoder_bin");
//v_decoder = gst_element_factory_make_or_warn ("identity", "v_dec");
gst_element_set_state (video_bin, GST_STATE_PAUSED);
- setup_dynamic_link (demux, "video_00", gst_element_get_pad (v_decoder, "sink"), video_bin);
+ setup_dynamic_link (demux, "video_00", gst_element_get_pad (v_decoder,
+ "sink"), video_bin);
seekable = gst_element_get_pad (v_queue, "src");
seekable_pads = g_list_prepend (seekable_pads, seekable);
rate_pads = g_list_prepend (rate_pads, seekable);
- rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (v_decoder, "sink"));
+ rate_pads =
+ g_list_prepend (rate_pads, gst_element_get_pad (v_decoder, "sink"));
return pipeline;
}
-static GstElement*
-make_mpeg_pipeline (const gchar *location)
+static GstElement *
+make_mpeg_pipeline (const gchar * location)
{
GstElement *pipeline, *audio_bin, *video_bin;
GstElement *src, *demux, *a_decoder, *v_decoder, *v_filter;
GstElement *audiosink, *videosink;
GstElement *a_queue, *audio_thread, *v_queue, *video_thread;
GstPad *seekable;
-
+
pipeline = gst_pipeline_new ("app");
src = gst_element_factory_make_or_warn (SOURCE, "src");
gst_bin_add (GST_BIN (audio_thread), a_queue);
gst_bin_add (GST_BIN (audio_thread), audiosink);
- setup_dynamic_link (demux, "audio_00", gst_element_get_pad (a_decoder, "sink"), audio_bin);
+ setup_dynamic_link (demux, "audio_00", gst_element_get_pad (a_decoder,
+ "sink"), audio_bin);
seekable = gst_element_get_pad (a_queue, "src");
seekable_pads = g_list_prepend (seekable_pads, seekable);
rate_pads = g_list_prepend (rate_pads, seekable);
- rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (a_decoder, "sink"));
+ rate_pads =
+ g_list_prepend (rate_pads, gst_element_get_pad (a_decoder, "sink"));
video_bin = gst_bin_new ("v_decoder_bin");
v_decoder = gst_element_factory_make_or_warn ("mpeg2dec", "v_dec");
v_filter = gst_element_factory_make_or_warn ("colorspace", "v_filter");
videosink = gst_element_factory_make_or_warn ("xvideosink", "v_sink");
gst_element_link_many (v_decoder, v_queue, v_filter, NULL);
-
+
gst_element_link (v_filter, videosink);
gst_bin_add_many (GST_BIN (video_bin), v_decoder, video_thread, NULL);
gst_bin_add_many (GST_BIN (video_thread), v_queue, v_filter, videosink, NULL);
- setup_dynamic_link (demux, "video_00", gst_element_get_pad (v_decoder, "sink"), video_bin);
+ setup_dynamic_link (demux, "video_00", gst_element_get_pad (v_decoder,
+ "sink"), video_bin);
seekable = gst_element_get_pad (v_queue, "src");
seekable_pads = g_list_prepend (seekable_pads, seekable);
rate_pads = g_list_prepend (rate_pads, seekable);
- rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (v_decoder, "sink"));
+ rate_pads =
+ g_list_prepend (rate_pads, gst_element_get_pad (v_decoder, "sink"));
return pipeline;
}
-static GstElement*
-make_mpegnt_pipeline (const gchar *location)
+static GstElement *
+make_mpegnt_pipeline (const gchar * location)
{
GstElement *pipeline, *audio_bin, *video_bin;
GstElement *src, *demux, *a_decoder, *v_decoder, *v_filter;
GstElement *audiosink, *videosink;
GstElement *a_queue, *audio_thread;
GstPad *seekable;
-
+
pipeline = gst_pipeline_new ("app");
src = gst_element_factory_make_or_warn (SOURCE, "src");
gst_bin_add (GST_BIN (audio_thread), a_queue);
gst_bin_add (GST_BIN (audio_thread), audiosink);
- setup_dynamic_link (demux, "audio_00", gst_element_get_pad (a_decoder, "sink"), audio_bin);
+ setup_dynamic_link (demux, "audio_00", gst_element_get_pad (a_decoder,
+ "sink"), audio_bin);
seekable = gst_element_get_pad (a_queue, "src");
seekable_pads = g_list_prepend (seekable_pads, seekable);
rate_pads = g_list_prepend (rate_pads, seekable);
- rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (a_decoder, "sink"));
+ rate_pads =
+ g_list_prepend (rate_pads, gst_element_get_pad (a_decoder, "sink"));
video_bin = gst_bin_new ("v_decoder_bin");
v_decoder = gst_element_factory_make_or_warn ("mpeg2dec", "v_dec");
v_filter = gst_element_factory_make_or_warn ("colorspace", "v_filter");
videosink = gst_element_factory_make_or_warn ("xvideosink", "v_sink");
gst_element_link_many (v_decoder, v_filter, videosink, NULL);
-
+
gst_bin_add_many (GST_BIN (video_bin), v_decoder, v_filter, videosink, NULL);
- setup_dynamic_link (demux, "video_00", gst_element_get_pad (v_decoder, "sink"), video_bin);
+ setup_dynamic_link (demux, "video_00", gst_element_get_pad (v_decoder,
+ "sink"), video_bin);
seekable = gst_element_get_pad (v_decoder, "src");
seekable_pads = g_list_prepend (seekable_pads, seekable);
rate_pads = g_list_prepend (rate_pads, seekable);
- rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (v_decoder, "sink"));
+ rate_pads =
+ g_list_prepend (rate_pads, gst_element_get_pad (v_decoder, "sink"));
return pipeline;
}
-static GstElement*
-make_playerbin_pipeline (const gchar *location)
+static GstElement *
+make_playerbin_pipeline (const gchar * location)
{
return NULL;
}
-static gchar*
-format_value (GtkScale *scale,
- gdouble value)
+static gchar *
+format_value (GtkScale * scale, gdouble value)
{
gint64 real;
gint64 seconds;
subseconds = (gint64) real / (GST_SECOND / 100);
return g_strdup_printf ("%02lld:%02lld:%02lld",
- seconds/60,
- seconds%60,
- subseconds%100);
+ seconds / 60, seconds % 60, subseconds % 100);
}
typedef struct
const GstFormat format;
} seek_format;
-static seek_format seek_formats[] =
-{
- { "tim", GST_FORMAT_TIME },
- { "byt", GST_FORMAT_BYTES },
- { "buf", GST_FORMAT_BUFFERS },
- { "def", GST_FORMAT_DEFAULT },
- { NULL, 0 },
+static seek_format seek_formats[] = {
+ {"tim", GST_FORMAT_TIME},
+ {"byt", GST_FORMAT_BYTES},
+ {"buf", GST_FORMAT_BUFFERS},
+ {"def", GST_FORMAT_DEFAULT},
+ {NULL, 0},
};
G_GNUC_UNUSED static void
format = seek_formats[i].format;
- if (gst_pad_convert (pad, GST_FORMAT_TIME, GST_SECOND,
- &format, &value))
- {
- g_print ("%s %13lld | ", seek_formats[i].name, value);
- }
- else {
- g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
+ if (gst_pad_convert (pad, GST_FORMAT_TIME, GST_SECOND, &format, &value)) {
+ g_print ("%s %13lld | ", seek_formats[i].name, value);
+ } else {
+ g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
}
i++;
format = seek_formats[i].format;
res = gst_pad_query (pad, GST_QUERY_TOTAL, &format, &value);
if (res) {
- g_print ("%s %13lld | ", seek_formats[i].name, value);
- }
- else {
- g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
+ g_print ("%s %13lld | ", seek_formats[i].name, value);
+ } else {
+ g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
}
i++;
}
g_print (" %s:%s\n", GST_DEBUG_PAD_NAME (pad));
-
+
walk = g_list_next (walk);
}
}
format = seek_formats[i].format;
res = gst_pad_query (pad, GST_QUERY_POSITION, &format, &value);
if (res) {
- g_print ("%s %13lld | ", seek_formats[i].name, value);
- }
- else {
- g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
+ g_print ("%s %13lld | ", seek_formats[i].name, value);
+ } else {
+ g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
}
i++;
}
}
static gboolean
-update_scale (gpointer data)
+update_scale (gpointer data)
{
GstClock *clock;
guint64 position;
if (seekable_pads) {
GstPad *pad = GST_PAD (seekable_pads->data);
+
gst_pad_query (pad, GST_QUERY_TOTAL, &format, &duration);
}
position = gst_clock_get_time (clock);
if (stats) {
- g_print ("clock: %13llu (%s)\n", position, gst_object_get_name (GST_OBJECT (clock)));
+ g_print ("clock: %13llu (%s)\n", position,
+ gst_object_get_name (GST_OBJECT (clock)));
query_durations ();
query_positions ();
query_rates ();
}
static gboolean
-start_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
+start_seek (GtkWidget * widget, GdkEventButton * event, gpointer user_data)
{
gst_element_set_state (pipeline, GST_STATE_PAUSED);
gtk_timeout_remove (update_id);
}
static gboolean
-stop_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
+stop_seek (GtkWidget * widget, GdkEventButton * event, gpointer user_data)
{
gint64 real = gtk_range_get_value (GTK_RANGE (widget)) * duration / 100;
gboolean res;
GstEvent *s_event;
+
#ifdef PAD_SEEK
GList *walk = seekable_pads;
while (walk) {
GstPad *seekable = GST_PAD (walk->data);
- g_print ("seek to %lld on pad %s:%s\n", real, GST_DEBUG_PAD_NAME (seekable));
- s_event = gst_event_new_seek (GST_FORMAT_TIME |
- GST_SEEK_METHOD_SET |
- GST_SEEK_FLAG_FLUSH, real);
+ g_print ("seek to %lld on pad %s:%s\n", real,
+ GST_DEBUG_PAD_NAME (seekable));
+ s_event =
+ gst_event_new_seek (GST_FORMAT_TIME | GST_SEEK_METHOD_SET |
+ GST_SEEK_FLAG_FLUSH, real);
res = gst_pad_send_event (seekable, s_event);
while (walk) {
GstElement *seekable = GST_ELEMENT (walk->data);
- g_print ("seek to %lld on element %s\n", real, gst_element_get_name (seekable));
- s_event = gst_event_new_seek (GST_FORMAT_TIME |
- GST_SEEK_METHOD_SET |
- GST_SEEK_FLAG_FLUSH, real);
+ g_print ("seek to %lld on element %s\n", real,
+ gst_element_get_name (seekable));
+ s_event =
+ gst_event_new_seek (GST_FORMAT_TIME | GST_SEEK_METHOD_SET |
+ GST_SEEK_FLAG_FLUSH, real);
res = gst_element_send_event (seekable, s_event);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
gtk_idle_add ((GtkFunction) iterate, pipeline);
- update_id = gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
+ update_id =
+ gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
return FALSE;
}
if (gst_element_get_state (pipeline) != GST_STATE_PLAYING) {
gst_element_set_state (pipeline, GST_STATE_PLAYING);
gtk_idle_add ((GtkFunction) iterate, pipeline);
- update_id = gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
+ update_id =
+ gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
}
}
typedef struct
{
gchar *name;
- GstElement* (*func) (const gchar *location);
+ GstElement *(*func) (const gchar * location);
} Pipeline;
static Pipeline pipelines[] = {
- { "mp3", make_mp3_pipeline },
- { "avi", make_avi_pipeline },
- { "mpeg1", make_mpeg_pipeline },
- { "mpegparse", make_parse_pipeline },
- { "vorbis", make_vorbis_pipeline },
- { "sid", make_sid_pipeline },
- { "flac", make_flac_pipeline },
- { "wav", make_wav_pipeline },
- { "mod", make_mod_pipeline },
- { "dv", make_dv_pipeline },
- { "mpeg1nothreads", make_mpegnt_pipeline },
- { "playerbin", make_playerbin_pipeline },
- { NULL, NULL},
+ {"mp3", make_mp3_pipeline},
+ {"avi", make_avi_pipeline},
+ {"mpeg1", make_mpeg_pipeline},
+ {"mpegparse", make_parse_pipeline},
+ {"vorbis", make_vorbis_pipeline},
+ {"sid", make_sid_pipeline},
+ {"flac", make_flac_pipeline},
+ {"wav", make_wav_pipeline},
+ {"mod", make_mod_pipeline},
+ {"dv", make_dv_pipeline},
+ {"mpeg1nothreads", make_mpegnt_pipeline},
+ {"playerbin", make_playerbin_pipeline},
+ {NULL, NULL},
};
#define NUM_TYPES ((sizeof (pipelines) / sizeof (Pipeline)) - 1)
int
main (int argc, char **argv)
{
- GtkWidget *window, *hbox, *vbox,
- *play_button, *pause_button, *stop_button,
- *hscale;
+ GtkWidget *window, *hbox, *vbox,
+ *play_button, *pause_button, *stop_button, *hscale;
struct poptOption options[] = {
- { "stats", 's', POPT_ARG_NONE|POPT_ARGFLAG_STRIP, &stats, 0,
- "Show pad stats", NULL },
+ {"stats", 's', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &stats, 0,
+ "Show pad stats", NULL},
POPT_TABLEEND
};
gint type;
-
+
gst_init_with_popt_table (&argc, &argv, options);
gtk_init (&argc, &argv);
pause_button = gtk_button_new_with_label ("pause");
stop_button = gtk_button_new_with_label ("stop");
- adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.00, 100.0, 0.1, 1.0, 1.0));
+ adjustment =
+ GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.00, 100.0, 0.1, 1.0, 1.0));
hscale = gtk_hscale_new (adjustment);
gtk_scale_set_digits (GTK_SCALE (hscale), 2);
gtk_range_set_update_policy (GTK_RANGE (hscale), GTK_UPDATE_CONTINUOUS);
- gtk_signal_connect(GTK_OBJECT(hscale),
- "button_press_event", G_CALLBACK (start_seek), pipeline);
- gtk_signal_connect(GTK_OBJECT(hscale),
- "button_release_event", G_CALLBACK (stop_seek), pipeline);
- gtk_signal_connect(GTK_OBJECT(hscale),
- "format_value", G_CALLBACK (format_value), pipeline);
+ gtk_signal_connect (GTK_OBJECT (hscale),
+ "button_press_event", G_CALLBACK (start_seek), pipeline);
+ gtk_signal_connect (GTK_OBJECT (hscale),
+ "button_release_event", G_CALLBACK (stop_seek), pipeline);
+ gtk_signal_connect (GTK_OBJECT (hscale),
+ "format_value", G_CALLBACK (format_value), pipeline);
/* do the packing stuff ... */
gtk_window_set_default_size (GTK_WINDOW (window), 96, 96);
gtk_box_pack_start (GTK_BOX (vbox), hscale, TRUE, TRUE, 2);
/* connect things ... */
- g_signal_connect (G_OBJECT (play_button), "clicked", G_CALLBACK (play_cb), pipeline);
- g_signal_connect (G_OBJECT (pause_button), "clicked", G_CALLBACK (pause_cb), pipeline);
- g_signal_connect (G_OBJECT (stop_button), "clicked", G_CALLBACK (stop_cb), pipeline);
+ g_signal_connect (G_OBJECT (play_button), "clicked", G_CALLBACK (play_cb),
+ pipeline);
+ g_signal_connect (G_OBJECT (pause_button), "clicked", G_CALLBACK (pause_cb),
+ pipeline);
+ g_signal_connect (G_OBJECT (stop_button), "clicked", G_CALLBACK (stop_cb),
+ pipeline);
g_signal_connect (G_OBJECT (window), "delete_event", gtk_main_quit, NULL);
/* show the gui. */
gtk_widget_show_all (window);
- g_signal_connect (pipeline, "deep_notify", G_CALLBACK (gst_element_default_deep_notify), NULL);
- g_signal_connect (pipeline, "error", G_CALLBACK (gst_element_default_error), NULL);
+ g_signal_connect (pipeline, "deep_notify",
+ G_CALLBACK (gst_element_default_deep_notify), NULL);
+ g_signal_connect (pipeline, "error", G_CALLBACK (gst_element_default_error),
+ NULL);
gtk_main ();
#define UPDATE_INTERVAL 500
-static GstElement*
-make_spider_pipeline (const gchar *location, gboolean thread)
+static GstElement *
+make_spider_pipeline (const gchar * location, gboolean thread)
{
GstElement *pipeline;
- GstElement *src, *decoder, *audiosink, *videosink, *a_thread, *v_thread, *a_queue, *v_queue;
-
+ GstElement *src, *decoder, *audiosink, *videosink, *a_thread, *v_thread,
+ *a_queue, *v_queue;
+
if (thread) {
pipeline = gst_thread_new ("app");
- }
- else {
+ } else {
pipeline = gst_pipeline_new ("app");
}
-
+
src = gst_element_factory_make (SOURCE, "src");
decoder = gst_element_factory_make ("spider", "decoder");
seekable_elements = g_list_prepend (seekable_elements, videosink);
seekable_elements = g_list_prepend (seekable_elements, audiosink);
- rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (audiosink, "sink"));
- rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (videosink, "sink"));
+ rate_pads =
+ g_list_prepend (rate_pads, gst_element_get_pad (audiosink, "sink"));
+ rate_pads =
+ g_list_prepend (rate_pads, gst_element_get_pad (videosink, "sink"));
return pipeline;
}
-static gchar*
-format_value (GtkScale *scale,
- gdouble value)
+static gchar *
+format_value (GtkScale * scale, gdouble value)
{
gint64 real;
gint64 seconds;
subseconds = (gint64) real / (GST_SECOND / 100);
return g_strdup_printf ("%02lld:%02lld:%02lld",
- seconds/60,
- seconds%60,
- subseconds%100);
+ seconds / 60, seconds % 60, subseconds % 100);
}
typedef struct
const GstFormat format;
} seek_format;
-static seek_format seek_formats[] =
-{
- { "tim", GST_FORMAT_TIME },
- { "byt", GST_FORMAT_BYTES },
- { "buf", GST_FORMAT_BUFFERS },
- { "def", GST_FORMAT_DEFAULT },
- { NULL, 0 },
+static seek_format seek_formats[] = {
+ {"tim", GST_FORMAT_TIME},
+ {"byt", GST_FORMAT_BYTES},
+ {"buf", GST_FORMAT_BUFFERS},
+ {"def", GST_FORMAT_DEFAULT},
+ {NULL, 0},
};
G_GNUC_UNUSED static void
format = seek_formats[i].format;
- if (gst_pad_convert (pad, GST_FORMAT_TIME, GST_SECOND,
- &format, &value))
- {
- g_print ("%s %13lld | ", seek_formats[i].name, value);
- }
- else {
- g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
+ if (gst_pad_convert (pad, GST_FORMAT_TIME, GST_SECOND, &format, &value)) {
+ g_print ("%s %13lld | ", seek_formats[i].name, value);
+ } else {
+ g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
}
i++;
format = seek_formats[i].format;
res = gst_element_query (element, GST_QUERY_TOTAL, &format, &value);
if (res) {
- g_print ("%s %13lld | ", seek_formats[i].name, value);
- }
- else {
- g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
+ g_print ("%s %13lld | ", seek_formats[i].name, value);
+ } else {
+ g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
}
i++;
}
format = seek_formats[i].format;
res = gst_element_query (element, GST_QUERY_POSITION, &format, &value);
if (res) {
- g_print ("%s %13lld | ", seek_formats[i].name, value);
- }
- else {
- g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
+ g_print ("%s %13lld | ", seek_formats[i].name, value);
+ } else {
+ g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
}
i++;
}
}
static gboolean
-update_scale (gpointer data)
+update_scale (gpointer data)
{
GstClock *clock;
guint64 position;
if (seekable_elements) {
GstElement *element = GST_ELEMENT (seekable_elements->data);
+
gst_element_query (element, GST_QUERY_TOTAL, &format, &duration);
}
position = gst_clock_get_time (clock);
if (stats) {
- g_print ("clock: %13llu (%s)\n", position, gst_object_get_name (GST_OBJECT (clock)));
+ g_print ("clock: %13llu (%s)\n", position,
+ gst_object_get_name (GST_OBJECT (clock)));
query_durations ();
query_positions ();
query_rates ();
}
static gboolean
-start_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
+start_seek (GtkWidget * widget, GdkEventButton * event, gpointer user_data)
{
gst_element_set_state (pipeline, GST_STATE_PAUSED);
gtk_timeout_remove (update_id);
}
static gboolean
-stop_seek (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
+stop_seek (GtkWidget * widget, GdkEventButton * event, gpointer user_data)
{
gint64 real = gtk_range_get_value (GTK_RANGE (widget)) * duration / 100;
gboolean res;
g_print ("seek to %lld on element %s\n", real, GST_ELEMENT_NAME (seekable));
s_event = gst_event_new_seek (GST_FORMAT_TIME |
- GST_SEEK_METHOD_SET |
- GST_SEEK_FLAG_FLUSH, real);
+ GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, real);
res = gst_element_send_event (seekable, s_event);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
if (!GST_FLAG_IS_SET (pipeline, GST_BIN_SELF_SCHEDULABLE))
gtk_idle_add ((GtkFunction) iterate, pipeline);
- update_id = gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
+ update_id =
+ gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
return FALSE;
}
gst_element_set_state (pipeline, GST_STATE_PLAYING);
if (!GST_FLAG_IS_SET (pipeline, GST_BIN_SELF_SCHEDULABLE))
gtk_idle_add ((GtkFunction) iterate, pipeline);
- update_id = gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
+ update_id =
+ gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
}
}
int
main (int argc, char **argv)
{
- GtkWidget *window, *hbox, *vbox,
- *play_button, *pause_button, *stop_button,
- *hscale;
+ GtkWidget *window, *hbox, *vbox,
+ *play_button, *pause_button, *stop_button, *hscale;
gboolean threaded = FALSE;
struct poptOption options[] = {
- {"threaded", 't', POPT_ARG_NONE|POPT_ARGFLAG_STRIP, &threaded, 0,
- "Run the pipeline in a toplevel thread", NULL},
- {"stats", 's', POPT_ARG_NONE|POPT_ARGFLAG_STRIP, &stats, 0,
- "Show element stats", NULL},
- POPT_TABLEEND
- };
+ {"threaded", 't', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &threaded, 0,
+ "Run the pipeline in a toplevel thread", NULL},
+ {"stats", 's', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &stats, 0,
+ "Show element stats", NULL},
+ POPT_TABLEEND
+ };
gst_init_with_popt_table (&argc, &argv, options);
gtk_init (&argc, &argv);
pause_button = gtk_button_new_with_label ("pause");
stop_button = gtk_button_new_with_label ("stop");
- adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.00, 100.0, 0.1, 1.0, 1.0));
+ adjustment =
+ GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.00, 100.0, 0.1, 1.0, 1.0));
hscale = gtk_hscale_new (adjustment);
gtk_scale_set_digits (GTK_SCALE (hscale), 2);
gtk_range_set_update_policy (GTK_RANGE (hscale), GTK_UPDATE_CONTINUOUS);
- gtk_signal_connect(GTK_OBJECT(hscale),
- "button_press_event", G_CALLBACK (start_seek), pipeline);
- gtk_signal_connect(GTK_OBJECT(hscale),
- "button_release_event", G_CALLBACK (stop_seek), pipeline);
- gtk_signal_connect(GTK_OBJECT(hscale),
- "format_value", G_CALLBACK (format_value), pipeline);
+ gtk_signal_connect (GTK_OBJECT (hscale),
+ "button_press_event", G_CALLBACK (start_seek), pipeline);
+ gtk_signal_connect (GTK_OBJECT (hscale),
+ "button_release_event", G_CALLBACK (stop_seek), pipeline);
+ gtk_signal_connect (GTK_OBJECT (hscale),
+ "format_value", G_CALLBACK (format_value), pipeline);
/* do the packing stuff ... */
gtk_window_set_default_size (GTK_WINDOW (window), 96, 96);
gtk_box_pack_start (GTK_BOX (vbox), hscale, TRUE, TRUE, 2);
/* connect things ... */
- g_signal_connect (G_OBJECT (play_button), "clicked", G_CALLBACK (play_cb), pipeline);
- g_signal_connect (G_OBJECT (pause_button), "clicked", G_CALLBACK (pause_cb), pipeline);
- g_signal_connect (G_OBJECT (stop_button), "clicked", G_CALLBACK (stop_cb), pipeline);
+ g_signal_connect (G_OBJECT (play_button), "clicked", G_CALLBACK (play_cb),
+ pipeline);
+ g_signal_connect (G_OBJECT (pause_button), "clicked", G_CALLBACK (pause_cb),
+ pipeline);
+ g_signal_connect (G_OBJECT (stop_button), "clicked", G_CALLBACK (stop_cb),
+ pipeline);
g_signal_connect (G_OBJECT (window), "delete_event", gtk_main_quit, NULL);
/* show the gui. */
static gboolean ready = FALSE;
-struct probe_context {
+struct probe_context
+{
GstElement *pipeline;
GstElement *element;
- GstPad *pad;
- GstFormat ls_format;
+ GstPad *pad;
+ GstFormat ls_format;
- gint total_ls;
+ gint total_ls;
- GstCaps *metadata;
- GstCaps *streaminfo;
- GstCaps *caps;
+ GstCaps *metadata;
+ GstCaps *streaminfo;
+ GstCaps *caps;
};
static void
-print_caps (GstCaps *caps)
+print_caps (GstCaps * caps)
{
char *s;
+
s = gst_caps_to_string (caps);
- g_print(" %s\n", s);
+ g_print (" %s\n", s);
g_free (s);
}
static void
-print_format (GstCaps *caps)
+print_format (GstCaps * caps)
{
char *s;
+
s = gst_caps_to_string (caps);
- g_print(" format: %s\n", s);
+ g_print (" format: %s\n", s);
g_free (s);
}
definition = gst_format_get_details (format);
/* get start and end position of this stream */
- res = gst_pad_convert (context->pad,
- context->ls_format, stream,
- &format, &value_start);
+ res = gst_pad_convert (context->pad,
+ context->ls_format, stream, &format, &value_start);
res &= gst_pad_convert (context->pad,
- context->ls_format, stream + 1,
- &format, &value_end);
+ context->ls_format, stream + 1, &format, &value_end);
if (res) {
/* substract to get the length */
value_end -= value_start;
if (format == GST_FORMAT_TIME) {
- value_end /= (GST_SECOND/100);
- g_print (" %s: %lld:%02lld.%02lld\n", definition->nick,
- value_end/6000, (value_end/100)%60, (value_end%100));
+ value_end /= (GST_SECOND / 100);
+ g_print (" %s: %lld:%02lld.%02lld\n", definition->nick,
+ value_end / 6000, (value_end / 100) % 60, (value_end % 100));
+ } else {
+ g_print (" %s: %lld\n", definition->nick, value_end);
}
- else {
- g_print (" %s: %lld\n", definition->nick, value_end);
- }
- }
- else
+ } else
g_print (" could not get logical stream %s\n", definition->nick);
}
}
static void
-deep_notify (GObject *object, GstObject *origin,
- GParamSpec *pspec, gpointer data)
+deep_notify (GObject * object, GstObject * origin,
+ GParamSpec * pspec, gpointer data)
{
struct probe_context *context = (struct probe_context *) data;
GValue value = { 0, };
g_value_init (&value, pspec->value_type);
g_object_get_property (G_OBJECT (origin), pspec->name, &value);
context->metadata = g_value_peek_pointer (&value);
- }
- else if (!strcmp (pspec->name, "streaminfo")) {
+ } else if (!strcmp (pspec->name, "streaminfo")) {
g_value_init (&value, pspec->value_type);
g_object_get_property (G_OBJECT (origin), pspec->name, &value);
/* seek to stream */
event = gst_event_new_seek (context->ls_format |
- GST_SEEK_METHOD_SET |
- GST_SEEK_FLAG_FLUSH,
- stream);
+ GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, stream);
res = gst_pad_send_event (context->pad, event);
if (!res) {
g_warning ("seek to logical track failed");
ready = FALSE;
while (gst_bin_iterate (GST_BIN (context->pipeline)) && !ready) {
count++;
- if (count > 10) break;
+ if (count > 10)
+ break;
}
print_caps (context->metadata);
format = *formats;
formats++;
- res = gst_pad_query (context->pad, GST_QUERY_TOTAL,
- &format, &value);
+ res = gst_pad_query (context->pad, GST_QUERY_TOTAL, &format, &value);
definition = gst_format_get_details (format);
if (res) {
if (format == GST_FORMAT_TIME) {
- value /= (GST_SECOND/100);
- g_print (" total %s: %lld:%02lld.%02lld\n", definition->nick,
- value/6000, (value/100)%60, (value%100));
- }
- else {
- if (format == context->ls_format)
- context->total_ls = value;
- g_print (" total %s: %lld\n", definition->nick, value);
+ value /= (GST_SECOND / 100);
+ g_print (" total %s: %lld:%02lld.%02lld\n", definition->nick,
+ value / 6000, (value / 100) % 60, (value % 100));
+ } else {
+ if (format == context->ls_format)
+ context->total_ls = value;
+ g_print (" total %s: %lld\n", definition->nick, value);
}
}
}
context->ls_format = logical_stream_format;
g_signal_connect (G_OBJECT (pipeline), "deep_notify",
- G_CALLBACK (deep_notify), context);
+ G_CALLBACK (deep_notify), context);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
* compression status of mpeg audio to ogg vorbis transcoding.
*/
-gint
-main (gint argc, gchar *argv[])
+gint
+main (gint argc, gchar * argv[])
{
GstElement *pipeline;
GError *error = NULL;
GstPad *dec_sink, *enc_src;
gst_init (&argc, &argv);
-
+
if (argc < 3) {
g_print ("usage: %s <inputfile> <outputfile>\n", argv[0]);
return -1;
}
description = g_strdup_printf ("filesrc location=\"%s\" ! mad name=decoder ! "
- "vorbisenc name=encoder ! filesink location=\"%s\"", argv[1], argv[2]);
+ "vorbisenc name=encoder ! filesink location=\"%s\"", argv[1], argv[2]);
pipeline = GST_ELEMENT (gst_parse_launch (description, &error));
if (!pipeline) {
if (error)
- g_print ("ERROR: pipeline could not be constructed: %s\n", error->message);
+ g_print ("ERROR: pipeline could not be constructed: %s\n",
+ error->message);
else
- g_print ("ERROR: pipeline could not be constructed\n");
+ g_print ("ERROR: pipeline could not be constructed\n");
return -1;
}
dec_sink = gst_element_get_pad (decoder, "sink");
enc_src = gst_element_get_pad (encoder, "src");
-
+
if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS) {
g_print ("pipeline doesn't want to play\n");
return -1;
format = GST_FORMAT_TIME;
/* get the position */
- gst_pad_query (enc_src, GST_QUERY_POSITION,
- &format, &position);
+ gst_pad_query (enc_src, GST_QUERY_POSITION, &format, &position);
/* get the total duration */
- gst_pad_query (enc_src, GST_QUERY_TOTAL,
- &format, &duration);
+ gst_pad_query (enc_src, GST_QUERY_TOTAL, &format, &duration);
format = GST_FORMAT_BYTES;
/* see how many bytes are genereated per 8 seconds (== bitrate) */
gst_pad_convert (enc_src, GST_FORMAT_TIME, 8 * GST_SECOND,
- &format, &bitrate_enc);
+ &format, &bitrate_enc);
gst_pad_convert (dec_sink, GST_FORMAT_TIME, 8 * GST_SECOND,
- &format, &bitrate_dec);
+ &format, &bitrate_dec);
g_print ("[%2dm %.2ds] of [%2dm %.2ds], "
- "src avg bitrate: %lld, dest avg birate: %lld, ratio [%02.2f] \r",
- (gint)(position / (GST_SECOND * 60)),
- (gint)(position / (GST_SECOND)) % 60,
- (gint)(duration / (GST_SECOND * 60)),
- (gint)(duration / (GST_SECOND)) % 60,
- bitrate_dec,
- bitrate_enc,
- (gfloat)bitrate_dec/bitrate_enc);
+ "src avg bitrate: %lld, dest avg birate: %lld, ratio [%02.2f] \r",
+ (gint) (position / (GST_SECOND * 60)),
+ (gint) (position / (GST_SECOND)) % 60,
+ (gint) (duration / (GST_SECOND * 60)),
+ (gint) (duration / (GST_SECOND)) % 60,
+ bitrate_dec, bitrate_enc, (gfloat) bitrate_dec / bitrate_enc);
}
g_print ("\n");
-
+
return 0;
}
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
-
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
static void
-got_eos (GstElement *pipeline)
+got_eos (GstElement * pipeline)
{
g_main_loop_quit (loop);
}
static gboolean
-idle_iterate (GstElement *pipeline)
+idle_iterate (GstElement * pipeline)
{
gst_bin_iterate (GST_BIN (pipeline));
return (GST_STATE (GST_ELEMENT (pipeline)) == GST_STATE_PLAYING);
}
static gboolean
-switch_timer (GstElement *video_switch)
+switch_timer (GstElement * video_switch)
{
gint nb_sources, active_source;
-
+
g_object_get (G_OBJECT (video_switch), "nb_sources", &nb_sources, NULL);
- g_object_get (G_OBJECT (video_switch), "active_source",
- &active_source, NULL);
-
- active_source ++;
-
+ g_object_get (G_OBJECT (video_switch), "active_source", &active_source, NULL);
+
+ active_source++;
+
if (active_source > nb_sources - 1)
active_source = 0;
-
- g_object_set (G_OBJECT (video_switch), "active_source",
- active_source, NULL);
-
+
+ g_object_set (G_OBJECT (video_switch), "active_source", active_source, NULL);
+
g_message ("current number of sources : %d, active source %d",
- nb_sources, active_source);
-
+ nb_sources, active_source);
+
return (GST_STATE (GST_ELEMENT (video_switch)) == GST_STATE_PLAYING);
}
gst_init (&argc, &argv);
loop = g_main_loop_new (NULL, FALSE);
-
+
pipeline = gst_pipeline_new ("pipeline");
src1 = gst_element_factory_make ("videotestsrc", "src1");
g_object_set (G_OBJECT (src1), "pattern", 0, NULL);
g_object_set (G_OBJECT (src2), "pattern", 1, NULL);
video_switch = gst_element_factory_make ("switch", "video_switch");
video_sink = gst_element_factory_make ("ximagesink", "video_sink");
-
+
gst_bin_add_many (GST_BIN (pipeline), src1, src2, video_switch,
- video_sink, NULL);
-
+ video_sink, NULL);
+
gst_element_link (src1, video_switch);
gst_element_link (src2, video_switch);
gst_element_link (video_switch, video_sink);
-
- g_signal_connect (G_OBJECT (pipeline), "eos",
- G_CALLBACK (got_eos), NULL);
+
+ g_signal_connect (G_OBJECT (pipeline), "eos", G_CALLBACK (got_eos), NULL);
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
-
+
g_idle_add ((GSourceFunc) idle_iterate, pipeline);
g_timeout_add (2000, (GSourceFunc) switch_timer, video_switch);
-
+
g_main_loop_run (loop);
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_READY);
-
+
/* unref */
gst_object_unref (GST_OBJECT (pipeline));
"Filter/Audio",
"aRts wrapper filter",
"Erik Walthinsen <omega@temple-baptist.com,\n"
- "Stefan Westerfeld <stefan@space.twc.de>",
+ "Stefan Westerfeld <stefan@space.twc.de>",
};
-static GstStaticPadTemplate sink_temp =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ( "audio/x-raw-int, "
- "depth = (int) 16, "
- "width = (int) 16, "
- "signed = (boolean) true, "
- "channels = (int) 2, "
- "endianness = (int) byte_order"
- )
-);
-
-static GstStaticPadTemplate src_temp =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-raw-int, "
- "depth = (int) 16, "
- "width = (int) 16, "
- "signed = (boolean) true, "
- "channels = (int) 2, "
- "rate = (int) 44100, "
- "endianness = (int) byte_order"
- )
-);
-
-enum {
+static GstStaticPadTemplate sink_temp = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "depth = (int) 16, "
+ "width = (int) 16, "
+ "signed = (boolean) true, "
+ "channels = (int) 2, " "endianness = (int) byte_order")
+ );
+
+static GstStaticPadTemplate src_temp = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "depth = (int) 16, "
+ "width = (int) 16, "
+ "signed = (boolean) true, "
+ "channels = (int) 2, "
+ "rate = (int) 44100, " "endianness = (int) byte_order")
+ );
+
+enum
+{
ARG_0,
ARG_LAST,
};
-static void gst_arts_base_init (gpointer g_class);
-static void gst_arts_class_init (GstARTSClass *klass);
-static void gst_arts_init (GstARTS *arts);
+static void gst_arts_base_init (gpointer g_class);
+static void gst_arts_class_init (GstARTSClass * klass);
+static void gst_arts_init (GstARTS * arts);
-static void gst_arts_loop (GstElement *element);
+static void gst_arts_loop (GstElement * element);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_arts_signals[LAST_SIGNAL] = { 0 }; */
GType
if (!gst_arts_type) {
static const GTypeInfo gst_arts_info = {
- sizeof(GstARTSClass),
+ sizeof (GstARTSClass),
gst_arts_base_init,
NULL,
- (GClassInitFunc)gst_arts_class_init,
+ (GClassInitFunc) gst_arts_class_init,
NULL,
NULL,
- sizeof(GstARTS),
+ sizeof (GstARTS),
0,
- (GInstanceInitFunc)gst_arts_init,
+ (GInstanceInitFunc) gst_arts_init,
};
- gst_arts_type = g_type_register_static(GST_TYPE_ELEMENT, "GstArts", &gst_arts_info, 0);
+ gst_arts_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstArts", &gst_arts_info, 0);
}
return gst_arts_type;
-}
+}
static void
gst_arts_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
+
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&sink_temp));
gst_element_class_add_pad_template (element_class,
}
static void
-gst_arts_class_init (GstARTSClass *klass)
+gst_arts_class_init (GstARTSClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
+ parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
- gobject_class = (GObjectClass*)klass;
- gstelement_class = (GstElementClass*)klass;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
}
static void
-gst_arts_init (GstARTS *arts)
+gst_arts_init (GstARTS * arts)
{
- arts->sinkpad = gst_pad_new_from_template(
- gst_element_get_pad_template (GST_ELEMENT (arts), "sink"), "sink");
- gst_element_add_pad(GST_ELEMENT(arts),arts->sinkpad);
+ arts->sinkpad =
+ gst_pad_new_from_template (gst_element_get_pad_template (GST_ELEMENT
+ (arts), "sink"), "sink");
+ gst_element_add_pad (GST_ELEMENT (arts), arts->sinkpad);
- arts->srcpad = gst_pad_new_from_template(
- gst_element_get_pad_template (GST_ELEMENT (arts), "src"), "src");
- gst_element_add_pad(GST_ELEMENT(arts),arts->srcpad);
+ arts->srcpad =
+ gst_pad_new_from_template (gst_element_get_pad_template (GST_ELEMENT
+ (arts), "src"), "src");
+ gst_element_add_pad (GST_ELEMENT (arts), arts->srcpad);
gst_element_set_loop_function (GST_ELEMENT (arts), gst_arts_loop);
- arts->wrapper = gst_arts_wrapper_new(arts->sinkpad,arts->srcpad);
+ arts->wrapper = gst_arts_wrapper_new (arts->sinkpad, arts->srcpad);
}
static void
-gst_arts_loop (GstElement *element)
+gst_arts_loop (GstElement * element)
{
- GstARTS *arts = (GstARTS*)element;
+ GstARTS *arts = (GstARTS *) element;
g_return_if_fail (arts != NULL);
- gst_arts_wrapper_do(arts->wrapper);
+ gst_arts_wrapper_do (arts->wrapper);
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
if (!gst_element_register (plugin, "gstarts", GST_RANK_NONE, GST_TYPE_ARTS))
return FALSE;
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "gst_arts",
- "arTs filter wrapper",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "gst_arts",
+ "arTs filter wrapper",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_ARTS \
(gst_arts_get_type())
#define GST_IS_ARTS_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ARTS))
-typedef struct _GstARTS GstARTS;
-typedef struct _GstARTSClass GstARTSClass;
+ typedef struct _GstARTS GstARTS;
+ typedef struct _GstARTSClass GstARTSClass;
-struct _GstARTS {
- GstElement element;
+ struct _GstARTS
+ {
+ GstElement element;
- GstPad *sinkpad, *srcpad;
- void *wrapper;
-};
+ GstPad *sinkpad, *srcpad;
+ void *wrapper;
+ };
-struct _GstARTSClass {
- GstElementClass parent_class;
-};
+ struct _GstARTSClass
+ {
+ GstElementClass parent_class;
+ };
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_ARTS_H__ */
+#endif /* __GST_ARTS_H__ */
#include <gst/gst.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
-void *gst_arts_wrapper_new(GstPad *sinkpad, GstPad *sourcepad);
-void gst_arts_wrapper_free(void *wrapper);
-void gst_arts_wrapper_do(void *wrapper);
+ void *gst_arts_wrapper_new (GstPad * sinkpad, GstPad * sourcepad);
+ void gst_arts_wrapper_free (void *wrapper);
+ void gst_arts_wrapper_do (void *wrapper);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
-
+#endif /* __cplusplus */
};
/* Signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_MUTE,
ARG_NAME,
};
-static GstStaticPadTemplate sink_factory =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (GST_AUDIO_INT_PAD_TEMPLATE_CAPS)
-);
-
-static void gst_artsdsink_base_init (gpointer g_class);
-static void gst_artsdsink_class_init (GstArtsdsinkClass *klass);
-static void gst_artsdsink_init (GstArtsdsink *artsdsink);
-
-static gboolean gst_artsdsink_open_audio (GstArtsdsink *sink);
-static void gst_artsdsink_close_audio (GstArtsdsink *sink);
-static GstElementStateReturn gst_artsdsink_change_state (GstElement *element);
-static gboolean gst_artsdsink_sync_parms (GstArtsdsink *artsdsink);
-static GstPadLinkReturn gst_artsdsink_link (GstPad *pad, const GstCaps *caps);
-static void gst_artsdsink_chain (GstPad *pad, GstData *_data);
-
-static void gst_artsdsink_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_artsdsink_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_AUDIO_INT_PAD_TEMPLATE_CAPS)
+ );
+
+static void gst_artsdsink_base_init (gpointer g_class);
+static void gst_artsdsink_class_init (GstArtsdsinkClass * klass);
+static void gst_artsdsink_init (GstArtsdsink * artsdsink);
+
+static gboolean gst_artsdsink_open_audio (GstArtsdsink * sink);
+static void gst_artsdsink_close_audio (GstArtsdsink * sink);
+static GstElementStateReturn gst_artsdsink_change_state (GstElement * element);
+static gboolean gst_artsdsink_sync_parms (GstArtsdsink * artsdsink);
+static GstPadLinkReturn gst_artsdsink_link (GstPad * pad, const GstCaps * caps);
+static void gst_artsdsink_chain (GstPad * pad, GstData * _data);
+
+static void gst_artsdsink_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_artsdsink_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_artsdsink_signals[LAST_SIGNAL] = { 0 }; */
GType
if (!artsdsink_type) {
static const GTypeInfo artsdsink_info = {
- sizeof(GstArtsdsinkClass),
+ sizeof (GstArtsdsinkClass),
gst_artsdsink_base_init,
NULL,
- (GClassInitFunc)gst_artsdsink_class_init,
+ (GClassInitFunc) gst_artsdsink_class_init,
NULL,
NULL,
- sizeof(GstArtsdsink),
+ sizeof (GstArtsdsink),
0,
- (GInstanceInitFunc)gst_artsdsink_init,
+ (GInstanceInitFunc) gst_artsdsink_init,
};
- artsdsink_type = g_type_register_static(GST_TYPE_ELEMENT, "GstArtsdsink", &artsdsink_info, 0);
+ artsdsink_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstArtsdsink",
+ &artsdsink_info, 0);
}
return artsdsink_type;
}
}
static void
-gst_artsdsink_class_init (GstArtsdsinkClass *klass)
+gst_artsdsink_class_init (GstArtsdsinkClass * 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);
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_MUTE,
- g_param_spec_boolean("mute","mute","mute",
- TRUE,G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MUTE, g_param_spec_boolean ("mute", "mute", "mute", TRUE, G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_NAME,
- g_param_spec_string("name","name","name",
- NULL, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NAME, g_param_spec_string ("name", "name", "name", NULL, G_PARAM_READWRITE)); /* CHECKME */
gobject_class->set_property = gst_artsdsink_set_property;
gobject_class->get_property = gst_artsdsink_get_property;
}
static void
-gst_artsdsink_init(GstArtsdsink *artsdsink)
+gst_artsdsink_init (GstArtsdsink * artsdsink)
{
- artsdsink->sinkpad = gst_pad_new_from_template (
- gst_element_get_pad_template (GST_ELEMENT (artsdsink), "sink"), "sink");
- gst_element_add_pad(GST_ELEMENT(artsdsink), artsdsink->sinkpad);
- gst_pad_set_chain_function(artsdsink->sinkpad, gst_artsdsink_chain);
- gst_pad_set_link_function(artsdsink->sinkpad, gst_artsdsink_link);
+ artsdsink->sinkpad =
+ gst_pad_new_from_template (gst_element_get_pad_template (GST_ELEMENT
+ (artsdsink), "sink"), "sink");
+ gst_element_add_pad (GST_ELEMENT (artsdsink), artsdsink->sinkpad);
+ gst_pad_set_chain_function (artsdsink->sinkpad, gst_artsdsink_chain);
+ gst_pad_set_link_function (artsdsink->sinkpad, gst_artsdsink_link);
artsdsink->connected = FALSE;
artsdsink->mute = FALSE;
}
static gboolean
-gst_artsdsink_sync_parms (GstArtsdsink *artsdsink)
+gst_artsdsink_sync_parms (GstArtsdsink * artsdsink)
{
g_return_val_if_fail (artsdsink != NULL, FALSE);
g_return_val_if_fail (GST_IS_ARTSDSINK (artsdsink), FALSE);
- if (!artsdsink->connected) return TRUE;
+ if (!artsdsink->connected)
+ return TRUE;
/* Need to set stream to use new parameters: only way to do this is to reopen. */
gst_artsdsink_close_audio (artsdsink);
}
static GstPadLinkReturn
-gst_artsdsink_link (GstPad *pad, const GstCaps *caps)
+gst_artsdsink_link (GstPad * pad, const GstCaps * caps)
{
GstArtsdsink *artsdsink = GST_ARTSDSINK (gst_pad_get_parent (pad));
GstStructure *structure;
}
static void
-gst_artsdsink_chain (GstPad *pad, GstData *_data)
+gst_artsdsink_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstArtsdsink *artsdsink;
- g_return_if_fail(pad != NULL);
- g_return_if_fail(GST_IS_PAD(pad));
- g_return_if_fail(buf != NULL);
+ g_return_if_fail (pad != NULL);
+ g_return_if_fail (GST_IS_PAD (pad));
+ g_return_if_fail (buf != NULL);
artsdsink = GST_ARTSDSINK (gst_pad_get_parent (pad));
if (GST_BUFFER_DATA (buf) != NULL) {
- gst_trace_add_entry(NULL, 0, GPOINTER_TO_INT(buf), "artsdsink: writing to server");
+ gst_trace_add_entry (NULL, 0, GPOINTER_TO_INT (buf),
+ "artsdsink: writing to server");
if (!artsdsink->mute && artsdsink->connected) {
int bytes;
- void * bufptr = GST_BUFFER_DATA (buf);
+ void *bufptr = GST_BUFFER_DATA (buf);
int bufsize = GST_BUFFER_SIZE (buf);
+
GST_DEBUG ("artsdsink: stream=%p data=%p size=%d",
- artsdsink->stream, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
+ artsdsink->stream, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
do {
bytes = arts_write (artsdsink->stream, bufptr, bufsize);
- if(bytes < 0) {
- fprintf(stderr,"arts_write error: %s\n", arts_error_text(bytes));
+ if (bytes < 0) {
+ fprintf (stderr, "arts_write error: %s\n", arts_error_text (bytes));
gst_buffer_unref (buf);
return;
}
}
static void
-gst_artsdsink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_artsdsink_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstArtsdsink *artsdsink;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_ARTSDSINK(object));
- artsdsink = GST_ARTSDSINK(object);
+ g_return_if_fail (GST_IS_ARTSDSINK (object));
+ artsdsink = GST_ARTSDSINK (object);
switch (prop_id) {
case ARG_MUTE:
artsdsink->mute = g_value_get_boolean (value);
break;
case ARG_NAME:
- if (artsdsink->connect_name != NULL) g_free(artsdsink->connect_name);
+ if (artsdsink->connect_name != NULL)
+ g_free (artsdsink->connect_name);
if (g_value_get_string (value) == NULL)
- artsdsink->connect_name = NULL;
+ artsdsink->connect_name = NULL;
else
- artsdsink->connect_name = g_strdup (g_value_get_string (value));
+ artsdsink->connect_name = g_strdup (g_value_get_string (value));
break;
default:
break;
}
static void
-gst_artsdsink_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_artsdsink_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstArtsdsink *artsdsink;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_ARTSDSINK(object));
- artsdsink = GST_ARTSDSINK(object);
+ g_return_if_fail (GST_IS_ARTSDSINK (object));
+ artsdsink = GST_ARTSDSINK (object);
switch (prop_id) {
case ARG_MUTE:
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- if (!gst_element_register (plugin, "artsdsink", GST_RANK_NONE, GST_TYPE_ARTSDSINK))
+ if (!gst_element_register (plugin, "artsdsink", GST_RANK_NONE,
+ GST_TYPE_ARTSDSINK))
return FALSE;
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "artsdsink",
- "Plays audio to an aRts server",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "artsdsink",
+ "Plays audio to an aRts server",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
-static gboolean
-gst_artsdsink_open_audio (GstArtsdsink *sink)
+ static gboolean gst_artsdsink_open_audio (GstArtsdsink * sink)
{
- const char * connname = "gstreamer";
+ const char *connname = "gstreamer";
int errcode;
/* Name used by aRtsd for this connection. */
- if (sink->connect_name != NULL) connname = sink->connect_name;
+ if (sink->connect_name != NULL)
+ connname = sink->connect_name;
/* FIXME: this should only ever happen once per process. */
/* Really, artsc needs to be made thread safe to fix this (and other related */
/* problems). */
- errcode = arts_init();
- if(errcode < 0) {
- fprintf(stderr,"arts_init error: %s\n", arts_error_text(errcode));
- return FALSE;
+ errcode = arts_init ();
+ if (errcode < 0) {
+ fprintf (stderr, "arts_init error: %s\n", arts_error_text (errcode));
+ return FALSE;
}
GST_DEBUG ("artsdsink: attempting to open connection to aRtsd server");
- sink->stream = arts_play_stream(sink->frequency, sink->depth,
- sink->channels, connname);
+ sink->stream = arts_play_stream (sink->frequency, sink->depth,
+ sink->channels, connname);
/* FIXME: check connection */
/* GST_DEBUG ("artsdsink: can't open connection to aRtsd server"); */
}
static void
-gst_artsdsink_close_audio (GstArtsdsink *sink)
+gst_artsdsink_close_audio (GstArtsdsink * sink)
{
- if (!sink->connected) return;
+ if (!sink->connected)
+ return;
- arts_close_stream(sink->stream);
- arts_free();
+ arts_close_stream (sink->stream);
+ arts_free ();
GST_FLAG_UNSET (sink, GST_ARTSDSINK_OPEN);
sink->connected = FALSE;
- g_print("artsdsink: closed connection\n");
+ g_print ("artsdsink: closed connection\n");
}
static GstElementStateReturn
-gst_artsdsink_change_state (GstElement *element)
+gst_artsdsink_change_state (GstElement * element)
{
g_return_val_if_fail (GST_IS_ARTSDSINK (element), FALSE);
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
return GST_STATE_SUCCESS;
}
-
#include <artsc.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_ARTSDSINK \
#define GST_IS_ARTSDSINK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ARTSDSINK))
-typedef enum {
- GST_ARTSDSINK_OPEN = GST_ELEMENT_FLAG_LAST,
- GST_ARTSDSINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST+2,
-} GstArtsdSinkFlags;
+ typedef enum
+ {
+ GST_ARTSDSINK_OPEN = GST_ELEMENT_FLAG_LAST,
+ GST_ARTSDSINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
+ } GstArtsdSinkFlags;
-typedef struct _GstArtsdsink GstArtsdsink;
-typedef struct _GstArtsdsinkClass GstArtsdsinkClass;
+ typedef struct _GstArtsdsink GstArtsdsink;
+ typedef struct _GstArtsdsinkClass GstArtsdsinkClass;
-struct _GstArtsdsink {
- GstElement element;
+ struct _GstArtsdsink
+ {
+ GstElement element;
- GstPad *sinkpad;
+ GstPad *sinkpad;
- gboolean connected;
- arts_stream_t stream;
- gboolean mute;
- gboolean signd;
- gint depth;
- gint channels;
- gint frequency;
- gchar* connect_name;
-};
+ gboolean connected;
+ arts_stream_t stream;
+ gboolean mute;
+ gboolean signd;
+ gint depth;
+ gint channels;
+ gint frequency;
+ gchar *connect_name;
+ };
-struct _GstArtsdsinkClass {
- GstElementClass parent_class;
-};
+ struct _GstArtsdsinkClass
+ {
+ GstElementClass parent_class;
+ };
-GType gst_artsdsink_get_type(void);
+ GType gst_artsdsink_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_ARTSDSINK_H__ */
+#endif /* __GST_ARTSDSINK_H__ */
#include "gstafsink.h"
#include "gstafparse.h"
-gboolean gst_aftypes_plugin_init (GstPlugin *plugin);
+gboolean gst_aftypes_plugin_init (GstPlugin * plugin);
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
if (!gst_library_load ("gstbytestream"))
return FALSE;
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "gstaf",
- "Audiofile plugin",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "gstaf",
+ "Audiofile plugin", plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
/* AFParse signals and args */
-enum {
+enum
+{
/* FILL ME */
SIGNAL_HANDOFF,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
};
/* added a src factory function to force audio/raw MIME type */
static GstStaticPadTemplate afparse_src_factory =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "audio/x-raw-int, "
- "rate = (int) [ 1, MAX ], "
- "channels = (int) [ 1, MAX ], "
- "endianness = (int) BYTE_ORDER, "
- "width = (int) { 8, 16 }, "
- "depth = (int) { 8, 16 }, "
- "signed = (boolean) { true, false }, "
- "buffer-frames = (int) [ 1, MAX ]"
- )
-);
+GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "rate = (int) [ 1, MAX ], "
+ "channels = (int) [ 1, MAX ], "
+ "endianness = (int) BYTE_ORDER, "
+ "width = (int) { 8, 16 }, "
+ "depth = (int) { 8, 16 }, "
+ "signed = (boolean) { true, false }, "
+ "buffer-frames = (int) [ 1, MAX ]")
+ );
static GstStaticPadTemplate afparse_sink_factory =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "audio/x-aiff; "
- "audio/x-wav; "
- "audio/x-au"
- )
-);
+ GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-aiff; " "audio/x-wav; " "audio/x-au")
+ );
static void gst_afparse_base_init (gpointer g_class);
-static void gst_afparse_class_init(GstAFParseClass *klass);
-static void gst_afparse_init (GstAFParse *afparse);
-
-static gboolean gst_afparse_open_file(GstAFParse *afparse);
-static void gst_afparse_close_file(GstAFParse *afparse);
-
-static void gst_afparse_loop(GstElement *element);
-static void gst_afparse_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void gst_afparse_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
-static ssize_t gst_afparse_vf_read (AFvirtualfile *vfile, void *data, size_t nbytes);
-static long gst_afparse_vf_length (AFvirtualfile *vfile);
-static ssize_t gst_afparse_vf_write (AFvirtualfile *vfile, const void *data, size_t nbytes);
-static void gst_afparse_vf_destroy(AFvirtualfile *vfile);
-static long gst_afparse_vf_seek (AFvirtualfile *vfile, long offset, int is_relative);
-static long gst_afparse_vf_tell (AFvirtualfile *vfile);
+static void gst_afparse_class_init (GstAFParseClass * klass);
+static void gst_afparse_init (GstAFParse * afparse);
+
+static gboolean gst_afparse_open_file (GstAFParse * afparse);
+static void gst_afparse_close_file (GstAFParse * afparse);
+
+static void gst_afparse_loop (GstElement * element);
+static void gst_afparse_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_afparse_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+static ssize_t gst_afparse_vf_read (AFvirtualfile * vfile, void *data,
+ size_t nbytes);
+static long gst_afparse_vf_length (AFvirtualfile * vfile);
+static ssize_t gst_afparse_vf_write (AFvirtualfile * vfile, const void *data,
+ size_t nbytes);
+static void gst_afparse_vf_destroy (AFvirtualfile * vfile);
+static long gst_afparse_vf_seek (AFvirtualfile * vfile, long offset,
+ int is_relative);
+static long gst_afparse_vf_tell (AFvirtualfile * vfile);
GType
-gst_afparse_get_type (void)
+gst_afparse_get_type (void)
{
static GType afparse_type = 0;
0,
(GInstanceInitFunc) gst_afparse_init,
};
- afparse_type = g_type_register_static (GST_TYPE_ELEMENT, "GstAFParse", &afparse_info, 0);
+ afparse_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstAFParse", &afparse_info,
+ 0);
}
return afparse_type;
}
}
static void
-gst_afparse_class_init (GstAFParseClass *klass)
+gst_afparse_class_init (GstAFParseClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- gobject_class = (GObjectClass*)klass;
- gstelement_class = (GstElementClass*)klass;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
gobject_class->set_property = gst_afparse_set_property;
gobject_class->get_property = gst_afparse_get_property;
}
-static void
-gst_afparse_init (GstAFParse *afparse)
+static void
+gst_afparse_init (GstAFParse * afparse)
{
- afparse->srcpad = gst_pad_new_from_template (
- gst_element_get_pad_template (GST_ELEMENT (afparse), "src"), "src");
+ afparse->srcpad =
+ gst_pad_new_from_template (gst_element_get_pad_template (GST_ELEMENT
+ (afparse), "src"), "src");
gst_pad_use_explicit_caps (afparse->srcpad);
gst_element_add_pad (GST_ELEMENT (afparse), afparse->srcpad);
- afparse->sinkpad = gst_pad_new_from_template (
- gst_element_get_pad_template (GST_ELEMENT (afparse), "sink"), "sink");
+ afparse->sinkpad =
+ gst_pad_new_from_template (gst_element_get_pad_template (GST_ELEMENT
+ (afparse), "sink"), "sink");
gst_element_add_pad (GST_ELEMENT (afparse), afparse->sinkpad);
gst_element_set_loop_function (GST_ELEMENT (afparse), gst_afparse_loop);
- afparse->vfile = af_virtual_file_new();
+ afparse->vfile = af_virtual_file_new ();
afparse->vfile->closure = NULL;
afparse->vfile->read = gst_afparse_vf_read;
afparse->vfile->length = gst_afparse_vf_length;
}
static void
-gst_afparse_loop(GstElement *element)
+gst_afparse_loop (GstElement * element)
{
GstAFParse *afparse;
GstBuffer *buf;
GstByteStream *bs;
int s_format, v_format, s_width, v_width;
- afparse = GST_AFPARSE(element);
+ afparse = GST_AFPARSE (element);
afparse->vfile->closure = bs = gst_bytestream_new (afparse->sinkpad);
/* just stop if we cannot open the file */
- if (!gst_afparse_open_file (afparse)){
+ if (!gst_afparse_open_file (afparse)) {
gst_bytestream_destroy ((GstByteStream *) afparse->vfile->closure);
- gst_pad_push (afparse->srcpad, GST_DATA(gst_event_new (GST_EVENT_EOS)));
+ gst_pad_push (afparse->srcpad, GST_DATA (gst_event_new (GST_EVENT_EOS)));
gst_element_set_eos (GST_ELEMENT (afparse));
return;
}
/* if audiofile changes the data in any way, we have to access
* the audio data via afReadFrames. Otherwise we can just access
* the data directly. */
- afGetSampleFormat(afparse->file, AF_DEFAULT_TRACK, &s_format, &s_width);
- afGetVirtualSampleFormat(afparse->file, AF_DEFAULT_TRACK, &v_format, &v_width);
- if (afGetCompression != AF_COMPRESSION_NONE ||
- afGetByteOrder(afparse->file, AF_DEFAULT_TRACK) != afGetVirtualByteOrder(afparse->file, AF_DEFAULT_TRACK) ||
- s_format != v_format ||
- s_width != v_width) {
+ afGetSampleFormat (afparse->file, AF_DEFAULT_TRACK, &s_format, &s_width);
+ afGetVirtualSampleFormat (afparse->file, AF_DEFAULT_TRACK, &v_format,
+ &v_width);
+ if (afGetCompression != AF_COMPRESSION_NONE
+ || afGetByteOrder (afparse->file,
+ AF_DEFAULT_TRACK) != afGetVirtualByteOrder (afparse->file,
+ AF_DEFAULT_TRACK) || s_format != v_format || s_width != v_width) {
bypass_afread = FALSE;
}
- if (bypass_afread){
- GST_DEBUG("will bypass afReadFrames\n");
+ if (bypass_afread) {
+ GST_DEBUG ("will bypass afReadFrames\n");
}
-
+
frames_to_bytes = afparse->channels * afparse->width / 8;
frames_per_read = afparse->frames_per_read;
bytes_per_read = frames_per_read * frames_to_bytes;
-
- afSeekFrame(afparse->file, AF_DEFAULT_TRACK, 0);
- if (bypass_afread){
- GstEvent *event = NULL;
- guint32 waiting;
- guint32 got_bytes;
+ afSeekFrame (afparse->file, AF_DEFAULT_TRACK, 0);
+
+ if (bypass_afread) {
+ GstEvent *event = NULL;
+ guint32 waiting;
+ guint32 got_bytes;
do {
got_bytes = gst_bytestream_read (bs, &buf, bytes_per_read);
if (got_bytes == 0) {
- /* we need to check for an event. */
- gst_bytestream_get_status (bs, &waiting, &event);
- if (event && GST_EVENT_TYPE(event) == GST_EVENT_EOS) {
- gst_pad_push (afparse->srcpad,
- GST_DATA (gst_event_new (GST_EVENT_EOS)));
- gst_element_set_eos (GST_ELEMENT (afparse));
- break;
- }
- }
- else {
- GST_BUFFER_TIMESTAMP(buf) = afparse->timestamp;
- gst_pad_push (afparse->srcpad, GST_DATA (buf));
- if (got_bytes != bytes_per_read){
+ /* we need to check for an event. */
+ gst_bytestream_get_status (bs, &waiting, &event);
+ if (event && GST_EVENT_TYPE (event) == GST_EVENT_EOS) {
+ gst_pad_push (afparse->srcpad,
+ GST_DATA (gst_event_new (GST_EVENT_EOS)));
+ gst_element_set_eos (GST_ELEMENT (afparse));
+ break;
+ }
+ } else {
+ GST_BUFFER_TIMESTAMP (buf) = afparse->timestamp;
+ gst_pad_push (afparse->srcpad, GST_DATA (buf));
+ if (got_bytes != bytes_per_read) {
/* this shouldn't happen very often */
/* FIXME calculate the timestamps based on the fewer bytes received */
- }
- else {
- afparse->timestamp += frames_per_read * 1E9 / afparse->rate;
+ } else {
+ afparse->timestamp += frames_per_read * 1E9 / afparse->rate;
}
}
}
while (TRUE);
- }
- else {
+ } else {
do {
buf = gst_buffer_new_and_alloc (bytes_per_read);
- GST_BUFFER_TIMESTAMP(buf) = afparse->timestamp;
- data = GST_BUFFER_DATA(buf);
- numframes = afReadFrames (afparse->file, AF_DEFAULT_TRACK, data, frames_per_read);
+ GST_BUFFER_TIMESTAMP (buf) = afparse->timestamp;
+ data = GST_BUFFER_DATA (buf);
+ numframes =
+ afReadFrames (afparse->file, AF_DEFAULT_TRACK, data, frames_per_read);
/* events are handled in gst_afparse_vf_read so if there are no
* frames it must be EOS */
- if (numframes < 1){
- gst_buffer_unref(buf);
+ if (numframes < 1) {
+ gst_buffer_unref (buf);
- gst_pad_push (afparse->srcpad, GST_DATA(gst_event_new (GST_EVENT_EOS)));
- gst_element_set_eos (GST_ELEMENT (afparse));
- break;
+ gst_pad_push (afparse->srcpad,
+ GST_DATA (gst_event_new (GST_EVENT_EOS)));
+ gst_element_set_eos (GST_ELEMENT (afparse));
+ break;
}
- GST_BUFFER_SIZE(buf) = numframes * frames_to_bytes;
+ GST_BUFFER_SIZE (buf) = numframes * frames_to_bytes;
gst_pad_push (afparse->srcpad, GST_DATA (buf));
afparse->timestamp += numframes * 1E9 / afparse->rate;
}
while (TRUE);
}
gst_afparse_close_file (afparse);
-
- gst_bytestream_destroy ((GstByteStream*) afparse->vfile->closure);
+
+ gst_bytestream_destroy ((GstByteStream *) afparse->vfile->closure);
}
static void
-gst_afparse_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
+gst_afparse_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstAFParse *afparse;
}
}
-static void
-gst_afparse_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
+static void
+gst_afparse_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
GstAFParse *afparse;
-
+
g_return_if_fail (GST_IS_AFPARSE (object));
-
+
afparse = GST_AFPARSE (object);
-
+
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
gboolean
-gst_afparse_plugin_init (GstPlugin *plugin)
+gst_afparse_plugin_init (GstPlugin * plugin)
{
- /* load audio support library */
+ /* load audio support library */
if (!gst_library_load ("gstaudio"))
return FALSE;
- if (!gst_element_register (plugin, "afparse", GST_RANK_NONE, GST_TYPE_AFPARSE))
+ if (!gst_element_register (plugin, "afparse", GST_RANK_NONE,
+ GST_TYPE_AFPARSE))
return FALSE;
return TRUE;
/* this is where we open the audiofile */
static gboolean
-gst_afparse_open_file (GstAFParse *afparse)
+gst_afparse_open_file (GstAFParse * afparse)
{
g_return_val_if_fail (!GST_FLAG_IS_SET (afparse, GST_AFPARSE_OPEN), FALSE);
/* open the file */
- GST_DEBUG("opening vfile %p\n", afparse->vfile);
+ GST_DEBUG ("opening vfile %p\n", afparse->vfile);
afparse->file = afOpenVirtualFile (afparse->vfile, "r", AF_NULL_FILESETUP);
- if (afparse->file == AF_NULL_FILEHANDLE)
- {
+ if (afparse->file == AF_NULL_FILEHANDLE) {
/* this should never happen */
g_warning ("ERROR: gstafparse: Could not open virtual file for reading\n");
return FALSE;
}
- GST_DEBUG("vfile opened\n");
+ GST_DEBUG ("vfile opened\n");
/* get the audiofile audio parameters */
{
int sampleFormat, sampleWidth;
+
afparse->channels = afGetChannels (afparse->file, AF_DEFAULT_TRACK);
- afGetSampleFormat (afparse->file, AF_DEFAULT_TRACK,
- &sampleFormat, &sampleWidth);
- switch (sampleFormat)
- {
+ afGetSampleFormat (afparse->file, AF_DEFAULT_TRACK,
+ &sampleFormat, &sampleWidth);
+ switch (sampleFormat) {
case AF_SAMPFMT_TWOSCOMP:
- afparse->is_signed = TRUE;
- break;
+ afparse->is_signed = TRUE;
+ break;
case AF_SAMPFMT_UNSIGNED:
- afparse->is_signed = FALSE;
- break;
+ afparse->is_signed = FALSE;
+ break;
case AF_SAMPFMT_FLOAT:
case AF_SAMPFMT_DOUBLE:
- GST_DEBUG ("ERROR: float data not supported yet !\n");
+ GST_DEBUG ("ERROR: float data not supported yet !\n");
}
afparse->rate = (guint) afGetRate (afparse->file, AF_DEFAULT_TRACK);
afparse->width = sampleWidth;
- GST_DEBUG (
- "input file: %d channels, %d width, %d rate, signed %s\n",
- afparse->channels, afparse->width, afparse->rate,
- afparse->is_signed ? "yes" : "no");
+ GST_DEBUG ("input file: %d channels, %d width, %d rate, signed %s\n",
+ afparse->channels, afparse->width, afparse->rate,
+ afparse->is_signed ? "yes" : "no");
}
-
+
/* set caps on src */
- /*FIXME: add all the possible formats, especially float ! */
- gst_pad_set_explicit_caps (afparse->srcpad,
- gst_caps_new_simple (
- "audio/x-raw-int",
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "signed", G_TYPE_BOOLEAN, afparse->is_signed,
- "width", G_TYPE_INT, afparse->width,
- "depth", G_TYPE_INT, afparse->width,
- "rate", G_TYPE_INT, afparse->rate,
- "channels", G_TYPE_INT, afparse->channels,
- NULL));
+ /*FIXME: add all the possible formats, especially float ! */
+ gst_pad_set_explicit_caps (afparse->srcpad,
+ gst_caps_new_simple ("audio/x-raw-int",
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "signed", G_TYPE_BOOLEAN, afparse->is_signed,
+ "width", G_TYPE_INT, afparse->width,
+ "depth", G_TYPE_INT, afparse->width,
+ "rate", G_TYPE_INT, afparse->rate,
+ "channels", G_TYPE_INT, afparse->channels, NULL));
GST_FLAG_SET (afparse, GST_AFPARSE_OPEN);
}
static void
-gst_afparse_close_file (GstAFParse *afparse)
+gst_afparse_close_file (GstAFParse * afparse)
{
g_return_if_fail (GST_FLAG_IS_SET (afparse, GST_AFPARSE_OPEN));
- if (afCloseFile (afparse->file) != 0)
- {
+ if (afCloseFile (afparse->file) != 0) {
g_warning ("afparse: oops, error closing !\n");
- }
- else {
+ } else {
GST_FLAG_UNSET (afparse, GST_AFPARSE_OPEN);
}
}
-static ssize_t
-gst_afparse_vf_read (AFvirtualfile *vfile, void *data, size_t nbytes)
+static ssize_t
+gst_afparse_vf_read (AFvirtualfile * vfile, void *data, size_t nbytes)
{
- GstByteStream *bs = (GstByteStream*)vfile->closure;
- guint8 *bytes = NULL;
- GstEvent *event = NULL;
- guint32 waiting;
- guint32 got_bytes;
- /*gchar *debug_str;*/
-
- got_bytes = gst_bytestream_peek_bytes(bs, &bytes, nbytes);
-
- while (got_bytes != nbytes){
+ GstByteStream *bs = (GstByteStream *) vfile->closure;
+ guint8 *bytes = NULL;
+ GstEvent *event = NULL;
+ guint32 waiting;
+ guint32 got_bytes;
+
+ /*gchar *debug_str; */
+
+ got_bytes = gst_bytestream_peek_bytes (bs, &bytes, nbytes);
+
+ while (got_bytes != nbytes) {
/* handle events */
gst_bytestream_get_status (bs, &waiting, &event);
/* FIXME this event handling isn't right yet */
- if (!event){
- /*g_print("no event found with %u bytes\n", got_bytes);*/
+ if (!event) {
+ /*g_print("no event found with %u bytes\n", got_bytes); */
return 0;
}
- switch (GST_EVENT_TYPE(event)) {
+ switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS:
- return 0;
+ return 0;
case GST_EVENT_FLUSH:
- GST_DEBUG("flush");
- break;
+ GST_DEBUG ("flush");
+ break;
case GST_EVENT_DISCONTINUOUS:
- GST_DEBUG("seek done");
- got_bytes = gst_bytestream_peek_bytes(bs, &bytes, nbytes);
- break;
+ GST_DEBUG ("seek done");
+ got_bytes = gst_bytestream_peek_bytes (bs, &bytes, nbytes);
+ break;
default:
- g_warning("unknown event %d", GST_EVENT_TYPE(event));
- got_bytes = gst_bytestream_peek_bytes(bs, &bytes, nbytes);
+ g_warning ("unknown event %d", GST_EVENT_TYPE (event));
+ got_bytes = gst_bytestream_peek_bytes (bs, &bytes, nbytes);
}
}
-
- memcpy(data, bytes, got_bytes);
- gst_bytestream_flush_fast(bs, got_bytes);
+
+ memcpy (data, bytes, got_bytes);
+ gst_bytestream_flush_fast (bs, got_bytes);
/* debug_str = g_strndup((gchar*)bytes, got_bytes);
- g_print("read %u bytes: %s\n", got_bytes, debug_str);
- */
+ g_print("read %u bytes: %s\n", got_bytes, debug_str);
+ */
return got_bytes;
}
-static long
-gst_afparse_vf_seek (AFvirtualfile *vfile, long offset, int is_relative)
+static long
+gst_afparse_vf_seek (AFvirtualfile * vfile, long offset, int is_relative)
{
- GstByteStream *bs = (GstByteStream*)vfile->closure;
+ GstByteStream *bs = (GstByteStream *) vfile->closure;
GstSeekType method;
- guint64 current_offset = gst_bytestream_tell(bs);
+ guint64 current_offset = gst_bytestream_tell (bs);
- if (!is_relative){
- if ((guint64)offset == current_offset) {
+ if (!is_relative) {
+ if ((guint64) offset == current_offset) {
/* this seems to happen before every read - bad audiofile */
return offset;
}
method = GST_SEEK_METHOD_SET;
+ } else {
+ if (offset == 0)
+ return current_offset;
+ method = GST_SEEK_METHOD_CUR;
}
- else {
- if (offset == 0) return current_offset;
- method = GST_SEEK_METHOD_CUR;
- }
-
- if (gst_bytestream_seek(bs, (gint64)offset, method)){
- GST_DEBUG("doing seek to %d", (gint)offset);
+
+ if (gst_bytestream_seek (bs, (gint64) offset, method)) {
+ GST_DEBUG ("doing seek to %d", (gint) offset);
return offset;
}
return 0;
}
-static long
-gst_afparse_vf_length (AFvirtualfile *vfile)
+static long
+gst_afparse_vf_length (AFvirtualfile * vfile)
{
- GstByteStream *bs = (GstByteStream*)vfile->closure;
+ GstByteStream *bs = (GstByteStream *) vfile->closure;
guint64 length;
- length = gst_bytestream_length(bs);
- GST_DEBUG("doing length: %" G_GUINT64_FORMAT, length);
+ length = gst_bytestream_length (bs);
+ GST_DEBUG ("doing length: %" G_GUINT64_FORMAT, length);
return length;
}
-static ssize_t
-gst_afparse_vf_write (AFvirtualfile *vfile, const void *data, size_t nbytes)
+static ssize_t
+gst_afparse_vf_write (AFvirtualfile * vfile, const void *data, size_t nbytes)
{
- /* GstByteStream *bs = (GstByteStream*)vfile->closure;*/
- g_warning("shouldn't write to a readonly pad");
+ /* GstByteStream *bs = (GstByteStream*)vfile->closure; */
+ g_warning ("shouldn't write to a readonly pad");
return 0;
}
-static void
-gst_afparse_vf_destroy(AFvirtualfile *vfile)
+static void
+gst_afparse_vf_destroy (AFvirtualfile * vfile)
{
- /* GstByteStream *bs = (GstByteStream*)vfile->closure;*/
+ /* GstByteStream *bs = (GstByteStream*)vfile->closure; */
- GST_DEBUG("doing destroy");
+ GST_DEBUG ("doing destroy");
}
-static long
-gst_afparse_vf_tell (AFvirtualfile *vfile)
+static long
+gst_afparse_vf_tell (AFvirtualfile * vfile)
{
- GstByteStream *bs = (GstByteStream*)vfile->closure;
+ GstByteStream *bs = (GstByteStream *) vfile->closure;
guint64 offset;
- offset = gst_bytestream_tell(bs);
- GST_DEBUG("doing tell: %" G_GUINT64_FORMAT, offset);
+ offset = gst_bytestream_tell (bs);
+ GST_DEBUG ("doing tell: %" G_GUINT64_FORMAT, offset);
return offset;
}
-
#include <gst/gst.h>
#include <gst/bytestream/bytestream.h>
-#include <audiofile.h> /* what else are we to do */
+#include <audiofile.h> /* what else are we to do */
#include <af_vfs.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
/*GstElementDetails gst_afparse_details;*/
#define GST_IS_AFPARSE_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AFPARSE))
-typedef struct _GstAFParse GstAFParse;
-typedef struct _GstAFParseClass GstAFParseClass;
-
-typedef enum {
- GST_AFPARSE_OPEN = GST_ELEMENT_FLAG_LAST,
-
- GST_AFPARSE_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
-} GstAFParseFlags;
-
-struct _GstAFParse {
- GstElement element;
- GstPad *srcpad;
- GstPad *sinkpad;
-
- AFvirtualfile *vfile;
- AFfilehandle file;
- int format;
- int channels;
- int width;
- unsigned int rate;
- gboolean is_signed;
- int type; /* type of output, compare to audiofile.h
- * RAW, AIFF, AIFFC, NEXTSND, WAVE
- */
- /* blocking */
- gulong curoffset;
- gulong bytes_per_read;
- gint frames_per_read;
-
- gulong seq;
- gint64 timestamp;
- /* FIXME : endianness is a little cryptic at this point */
- int endianness_data; /* 4321 or 1234 */
- int endianness_wanted; /* same thing, but what the output format wants */
- int endianness_output; /* what the output endianness will be */
-};
-
-struct _GstAFParseClass {
- GstElementClass parent_class;
-
- /* signals */
- void (*handoff) (GstElement *element,GstPad *pad);
-};
-
-gboolean gst_afparse_plugin_init (GstPlugin *plugin);
+ typedef struct _GstAFParse GstAFParse;
+ typedef struct _GstAFParseClass GstAFParseClass;
+
+ typedef enum
+ {
+ GST_AFPARSE_OPEN = GST_ELEMENT_FLAG_LAST,
+
+ GST_AFPARSE_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
+ } GstAFParseFlags;
+
+ struct _GstAFParse
+ {
+ GstElement element;
+ GstPad *srcpad;
+ GstPad *sinkpad;
+
+ AFvirtualfile *vfile;
+ AFfilehandle file;
+ int format;
+ int channels;
+ int width;
+ unsigned int rate;
+ gboolean is_signed;
+ int type; /* type of output, compare to audiofile.h
+ * RAW, AIFF, AIFFC, NEXTSND, WAVE
+ */
+ /* blocking */
+ gulong curoffset;
+ gulong bytes_per_read;
+ gint frames_per_read;
+
+ gulong seq;
+ gint64 timestamp;
+ /* FIXME : endianness is a little cryptic at this point */
+ int endianness_data; /* 4321 or 1234 */
+ int endianness_wanted; /* same thing, but what the output format wants */
+ int endianness_output; /* what the output endianness will be */
+ };
+
+ struct _GstAFParseClass
+ {
+ GstElementClass parent_class;
+
+ /* signals */
+ void (*handoff) (GstElement * element, GstPad * pad);
+ };
+
+ gboolean gst_afparse_plugin_init (GstPlugin * plugin);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_AFPARSE_H__ */
+#endif /* __GST_AFPARSE_H__ */
/* AFSink signals and args */
-enum {
+enum
+{
/* FILL ME */
SIGNAL_HANDOFF,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_TYPE,
ARG_OUTPUT_ENDIANNESS,
/* added a sink factory function to force audio/raw MIME type */
/* I think the caps can be broader, we need to change that somehow */
static GstStaticPadTemplate afsink_sink_factory =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-raw-int, "
- "rate = (int) [ 1, MAX ], "
- "channels = (int) [ 1, 2 ], "
- "endianness = (int) BYTE_ORDER, "
- "width = (int) { 8, 16 }, "
- "depth = (int) { 8, 16 }, "
- "signed = (boolean) { true, false }, "
- "buffer-frames = (int) [ 1, MAX ]"
- )
-);
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "rate = (int) [ 1, MAX ], "
+ "channels = (int) [ 1, 2 ], "
+ "endianness = (int) BYTE_ORDER, "
+ "width = (int) { 8, 16 }, "
+ "depth = (int) { 8, 16 }, "
+ "signed = (boolean) { true, false }, "
+ "buffer-frames = (int) [ 1, MAX ]")
+ );
/* we use an enum for the output type arg */
#define GST_TYPE_AFSINK_TYPES (gst_afsink_types_get_type())
/* FIXME: fix the string ints to be string-converted from the audiofile.h types */
static GType
-gst_afsink_types_get_type (void)
+gst_afsink_types_get_type (void)
{
static GType afsink_types_type = 0;
static GEnumValue afsink_types[] = {
{AF_FILE_RAWDATA, "0", "raw PCM"},
- {AF_FILE_AIFFC, "1", "AIFFC"},
- {AF_FILE_AIFF, "2", "AIFF"},
+ {AF_FILE_AIFFC, "1", "AIFFC"},
+ {AF_FILE_AIFF, "2", "AIFF"},
{AF_FILE_NEXTSND, "3", "Next/SND"},
- {AF_FILE_WAVE, "4", "Wave"},
+ {AF_FILE_WAVE, "4", "Wave"},
{0, NULL, NULL},
};
-
- if (!afsink_types_type)
- {
- afsink_types_type = g_enum_register_static ("GstAudiosinkTypes", afsink_types);
+
+ if (!afsink_types_type) {
+ afsink_types_type =
+ g_enum_register_static ("GstAudiosinkTypes", afsink_types);
}
return afsink_types_type;
}
-static void gst_afsink_base_init (gpointer g_class);
-static void gst_afsink_class_init (GstAFSinkClass *klass);
-static void gst_afsink_init (GstAFSink *afsink);
+static void gst_afsink_base_init (gpointer g_class);
+static void gst_afsink_class_init (GstAFSinkClass * klass);
+static void gst_afsink_init (GstAFSink * afsink);
-static gboolean gst_afsink_open_file (GstAFSink *sink);
-static void gst_afsink_close_file (GstAFSink *sink);
+static gboolean gst_afsink_open_file (GstAFSink * sink);
+static void gst_afsink_close_file (GstAFSink * sink);
-static void gst_afsink_chain (GstPad *pad,GstData *_data);
+static void gst_afsink_chain (GstPad * pad, GstData * _data);
-static void gst_afsink_set_property (GObject *object, guint prop_id, const GValue *value,
- GParamSpec *pspec);
-static void gst_afsink_get_property (GObject *object, guint prop_id, GValue *value,
- GParamSpec *pspec);
+static void gst_afsink_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_afsink_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static gboolean gst_afsink_handle_event (GstPad *pad, GstEvent *event);
+static gboolean gst_afsink_handle_event (GstPad * pad, GstEvent * event);
-static GstElementStateReturn gst_afsink_change_state (GstElement *element);
+static GstElementStateReturn gst_afsink_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
static guint gst_afsink_signals[LAST_SIGNAL] = { 0 };
GType
-gst_afsink_get_type (void)
+gst_afsink_get_type (void)
{
static GType afsink_type = 0;
0,
(GInstanceInitFunc) gst_afsink_init,
};
- afsink_type = g_type_register_static (GST_TYPE_ELEMENT, "GstAFSink", &afsink_info, 0);
+ afsink_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstAFSink", &afsink_info, 0);
}
return afsink_type;
}
}
static void
-gst_afsink_class_init (GstAFSinkClass *klass)
+gst_afsink_class_init (GstAFSinkClass * 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);
- gst_element_class_install_std_props (
- GST_ELEMENT_CLASS (klass),
- "location", ARG_LOCATION, G_PARAM_READWRITE,
- NULL);
-
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_TYPE,
- g_param_spec_enum("type","type","type",
- GST_TYPE_AFSINK_TYPES,0,G_PARAM_READWRITE)); /* CHECKME! */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_OUTPUT_ENDIANNESS,
- g_param_spec_int("endianness","endianness","endianness",
- G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); /* CHECKME */
-
+ gst_element_class_install_std_props (GST_ELEMENT_CLASS (klass),
+ "location", ARG_LOCATION, G_PARAM_READWRITE, NULL);
+
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TYPE, g_param_spec_enum ("type", "type", "type", GST_TYPE_AFSINK_TYPES, 0, G_PARAM_READWRITE)); /* CHECKME! */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_OUTPUT_ENDIANNESS, g_param_spec_int ("endianness", "endianness", "endianness", G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */
+
gst_afsink_signals[SIGNAL_HANDOFF] =
- g_signal_new ("handoff", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstAFSinkClass, handoff), NULL, NULL,
- g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstAFSinkClass, handoff), NULL, NULL,
+ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
gobject_class->set_property = gst_afsink_set_property;
gstelement_class->change_state = gst_afsink_change_state;
}
-static void
-gst_afsink_init (GstAFSink *afsink)
+static void
+gst_afsink_init (GstAFSink * afsink)
{
/* GstPad *pad; this is now done in the struct */
- afsink->sinkpad = gst_pad_new_from_template (
- gst_element_get_pad_template (GST_ELEMENT (afsink), "sink"), "sink");
+ afsink->sinkpad =
+ gst_pad_new_from_template (gst_element_get_pad_template (GST_ELEMENT
+ (afsink), "sink"), "sink");
gst_element_add_pad (GST_ELEMENT (afsink), afsink->sinkpad);
gst_pad_set_chain_function (afsink->sinkpad, gst_afsink_chain);
}
static void
-gst_afsink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_afsink_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstAFSink *sink;
case ARG_LOCATION:
/* the element must be stopped or paused in order to do this */
g_return_if_fail ((GST_STATE (sink) < GST_STATE_PLAYING)
- || (GST_STATE (sink) == GST_STATE_PAUSED));
+ || (GST_STATE (sink) == GST_STATE_PAUSED));
if (sink->filename)
g_free (sink->filename);
sink->filename = g_strdup (g_value_get_string (value));
- if ( (GST_STATE (sink) == GST_STATE_PAUSED)
- && (sink->filename != NULL))
- {
- gst_afsink_close_file (sink);
- gst_afsink_open_file (sink);
+ if ((GST_STATE (sink) == GST_STATE_PAUSED)
+ && (sink->filename != NULL)) {
+ gst_afsink_close_file (sink);
+ gst_afsink_open_file (sink);
}
break;
sink->type = g_value_get_enum (value);
break;
case ARG_OUTPUT_ENDIANNESS:
- {
- int end = g_value_get_int (value);
- if (end == 1234 || end == 4321)
- sink->endianness_output = end;
- }
+ {
+ int end = g_value_get_int (value);
+
+ if (end == 1234 || end == 4321)
+ sink->endianness_output = end;
+ }
break;
default:
break;
}
}
-static void
-gst_afsink_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+static void
+gst_afsink_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstAFSink *sink;
-
+
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_AFSINK (object));
-
+
sink = GST_AFSINK (object);
-
+
switch (prop_id) {
case ARG_LOCATION:
g_value_set_string (value, sink->filename);
}
gboolean
-gst_afsink_plugin_init (GstPlugin *plugin)
+gst_afsink_plugin_init (GstPlugin * plugin)
{
if (!gst_element_register (plugin, "afsink", GST_RANK_NONE, GST_TYPE_AFSINK))
return FALSE;
/* this is where we open the audiofile */
static gboolean
-gst_afsink_open_file (GstAFSink *sink)
+gst_afsink_open_file (GstAFSink * sink)
{
AFfilesetup outfilesetup;
const GstCaps *caps;
GstStructure *structure;
- int sample_format; /* audiofile's sample format, look in audiofile.h */
- int byte_order = 0; /* audiofile's byte order defines */
-
+ int sample_format; /* audiofile's sample format, look in audiofile.h */
+ int byte_order = 0; /* audiofile's byte order defines */
+
g_return_val_if_fail (!GST_FLAG_IS_SET (sink, GST_AFSINK_OPEN), FALSE);
/* get the audio parameters */
g_return_val_if_fail (GST_IS_PAD (sink->sinkpad), FALSE);
caps = GST_PAD_CAPS (sink->sinkpad);
-
+
if (caps == NULL) {
g_critical ("gstafsink chain : Could not get caps of pad !\n");
} else {
structure = gst_caps_get_structure (caps, 0);
- gst_structure_get_int (structure, "channels", &sink->channels);
- gst_structure_get_int (structure, "width", &sink->width);
- gst_structure_get_int (structure, "rate", &sink->rate);
+ gst_structure_get_int (structure, "channels", &sink->channels);
+ gst_structure_get_int (structure, "width", &sink->width);
+ gst_structure_get_int (structure, "rate", &sink->rate);
gst_structure_get_boolean (structure, "signed", &sink->is_signed);
gst_structure_get_int (structure, "endianness", &sink->endianness_data);
}
GST_DEBUG ("channels %d, width %d, rate %d, signed %s",
- sink->channels, sink->width, sink->rate,
- sink->is_signed ? "yes" : "no");
- GST_DEBUG ("endianness: data %d, output %d",
- sink->endianness_data, sink->endianness_output);
+ sink->channels, sink->width, sink->rate, sink->is_signed ? "yes" : "no");
+ GST_DEBUG ("endianness: data %d, output %d",
+ sink->endianness_data, sink->endianness_output);
/* setup the output file */
if (sink->is_signed)
sample_format = AF_SAMPFMT_TWOSCOMP;
sample_format = AF_SAMPFMT_UNSIGNED;
/* FIXME : this check didn't seem to work, so let the output endianness be set */
/*
- if (sink->endianness_data == sink->endianness_wanted)
- byte_order = AF_BYTEORDER_LITTLEENDIAN;
- else
- byte_order = AF_BYTEORDER_BIGENDIAN;
- */
+ if (sink->endianness_data == sink->endianness_wanted)
+ byte_order = AF_BYTEORDER_LITTLEENDIAN;
+ else
+ byte_order = AF_BYTEORDER_BIGENDIAN;
+ */
if (sink->endianness_output == 1234)
byte_order = AF_BYTEORDER_LITTLEENDIAN;
else
afInitFileFormat (outfilesetup, sink->type);
afInitChannels (outfilesetup, AF_DEFAULT_TRACK, sink->channels);
afInitRate (outfilesetup, AF_DEFAULT_TRACK, sink->rate);
- afInitSampleFormat (outfilesetup, AF_DEFAULT_TRACK,
- sample_format, sink->width);
+ afInitSampleFormat (outfilesetup, AF_DEFAULT_TRACK,
+ sample_format, sink->width);
/* open it */
sink->file = afOpenFile (sink->filename, "w", outfilesetup);
- if (sink->file == AF_NULL_FILEHANDLE)
- {
- GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE,
- (_("Could not open file \"%s\" for writing."), sink->filename),
- ("system error: %s", strerror (errno)));
+ if (sink->file == AF_NULL_FILEHANDLE) {
+ GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE,
+ (_("Could not open file \"%s\" for writing."), sink->filename),
+ ("system error: %s", strerror (errno)));
return FALSE;
- }
+ }
afFreeFileSetup (outfilesetup);
/* afSetVirtualByteOrder (sink->file, AF_DEFAULT_TRACK, byte_order); */
-
+
GST_FLAG_SET (sink, GST_AFSINK_OPEN);
return TRUE;
}
static void
-gst_afsink_close_file (GstAFSink *sink)
+gst_afsink_close_file (GstAFSink * sink)
{
/* g_print ("DEBUG: closing sinkfile...\n"); */
g_return_if_fail (GST_FLAG_IS_SET (sink, GST_AFSINK_OPEN));
/* g_print ("DEBUG: past flag test\n"); */
/* if (fclose (sink->file) != 0) */
- if (afCloseFile (sink->file) != 0)
- {
+ if (afCloseFile (sink->file) != 0) {
GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE,
- (_("Error closing file \"%s\"."), sink->filename),
- GST_ERROR_SYSTEM);
- }
- else {
+ (_("Error closing file \"%s\"."), sink->filename), GST_ERROR_SYSTEM);
+ } else {
GST_FLAG_UNSET (sink, GST_AFSINK_OPEN);
}
}
*
* take the buffer from the pad and write to file if it's open
*/
-static void
-gst_afsink_chain (GstPad *pad, GstData *_data)
+static void
+gst_afsink_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf;
GstAFSink *afsink;
}
*/
- if (!GST_FLAG_IS_SET (afsink, GST_AFSINK_OPEN))
- {
+ if (!GST_FLAG_IS_SET (afsink, GST_AFSINK_OPEN)) {
/* it's not open yet, open it */
if (!gst_afsink_open_file (afsink))
- g_print ("WARNING: gstafsink: can't open file !\n");
+ g_print ("WARNING: gstafsink: can't open file !\n");
/* return FALSE; Can't return value */
}
- if (GST_FLAG_IS_SET (afsink, GST_AFSINK_OPEN))
- {
+ if (GST_FLAG_IS_SET (afsink, GST_AFSINK_OPEN)) {
int frameCount = 0;
- frameCount = GST_BUFFER_SIZE (buf) / ((afsink->width / 8) * afsink->channels);
- /* g_print ("DEBUG: writing %d frames ", frameCount); */
- ret = afWriteFrames (afsink->file, AF_DEFAULT_TRACK,
- GST_BUFFER_DATA (buf), frameCount);
- if (ret == AF_BAD_WRITE || ret == AF_BAD_LSEEK)
- {
+ frameCount =
+ GST_BUFFER_SIZE (buf) / ((afsink->width / 8) * afsink->channels);
+ /* g_print ("DEBUG: writing %d frames ", frameCount); */
+ ret = afWriteFrames (afsink->file, AF_DEFAULT_TRACK,
+ GST_BUFFER_DATA (buf), frameCount);
+ if (ret == AF_BAD_WRITE || ret == AF_BAD_LSEEK) {
printf ("afsink : Warning : afWriteFrames returned an error (%d)\n", ret);
}
}
}
static GstElementStateReturn
-gst_afsink_change_state (GstElement *element)
+gst_afsink_change_state (GstElement * element)
{
g_return_val_if_fail (GST_IS_AFSINK (element), GST_STATE_FAILURE);
/* if going to NULL? then close the file */
- if (GST_STATE_PENDING (element) == GST_STATE_NULL)
- {
+ if (GST_STATE_PENDING (element) == GST_STATE_NULL) {
/* printf ("DEBUG: afsink state change: null pending\n"); */
- if (GST_FLAG_IS_SET (element, GST_AFSINK_OPEN))
- {
+ if (GST_FLAG_IS_SET (element, GST_AFSINK_OPEN)) {
/* g_print ("DEBUG: trying to close the sink file\n"); */
gst_afsink_close_file (GST_AFSINK (element));
}
- }
+ }
/*
else
/* this function was copied from sinesrc */
static gboolean
-gst_afsink_handle_event (GstPad *pad, GstEvent *event)
+gst_afsink_handle_event (GstPad * pad, GstEvent * event)
{
GstAFSink *afsink;
}
*/
-
#include <gst/gst.h>
-#include <audiofile.h> /* what else are we to do */
+#include <audiofile.h> /* what else are we to do */
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
/*GstElementDetails gst_afsink_details;*/
#define GST_IS_AFSINK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AFSINK))
-typedef struct _GstAFSink GstAFSink;
-typedef struct _GstAFSinkClass GstAFSinkClass;
+ typedef struct _GstAFSink GstAFSink;
+ typedef struct _GstAFSinkClass GstAFSinkClass;
-typedef enum {
- GST_AFSINK_OPEN = GST_ELEMENT_FLAG_LAST,
+ typedef enum
+ {
+ GST_AFSINK_OPEN = GST_ELEMENT_FLAG_LAST,
- GST_AFSINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
-} GstAFSinkFlags;
+ GST_AFSINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
+ } GstAFSinkFlags;
-struct _GstAFSink {
- GstElement element;
- GstPad *sinkpad;
+ struct _GstAFSink
+ {
+ GstElement element;
+ GstPad *sinkpad;
- gchar *filename;
+ gchar *filename;
/* FILE *file; */
/* AFfilesetup outfilesetup; */
- AFfilehandle file;
- int format;
- int channels;
- int width;
- unsigned int rate;
- gboolean is_signed;
- int type; /* type of output, compare to audiofile.h
- * RAW, AIFF, AIFFC, NEXTSND, WAVE
- */
- /* FIXME : endianness is a little cryptic at this point */
- int endianness_data; /* 4321 or 1234 */
- int endianness_wanted; /* same thing, but what the output format wants */
- int endianness_output; /* what the output endianness will be */
-};
-
-struct _GstAFSinkClass {
- GstElementClass parent_class;
-
- /* signals */
- void (*handoff) (GstElement *element,GstPad *pad);
-};
-
-GType gst_afsink_get_type (void);
-gboolean gst_afsink_plugin_init (GstPlugin *plugin);
+ AFfilehandle file;
+ int format;
+ int channels;
+ int width;
+ unsigned int rate;
+ gboolean is_signed;
+ int type; /* type of output, compare to audiofile.h
+ * RAW, AIFF, AIFFC, NEXTSND, WAVE
+ */
+ /* FIXME : endianness is a little cryptic at this point */
+ int endianness_data; /* 4321 or 1234 */
+ int endianness_wanted; /* same thing, but what the output format wants */
+ int endianness_output; /* what the output endianness will be */
+ };
+
+ struct _GstAFSinkClass
+ {
+ GstElementClass parent_class;
+
+ /* signals */
+ void (*handoff) (GstElement * element, GstPad * pad);
+ };
+
+ GType gst_afsink_get_type (void);
+ gboolean gst_afsink_plugin_init (GstPlugin * plugin);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_AFSINK_H__ */
+#endif /* __GST_AFSINK_H__ */
/* AFSrc signals and args */
-enum {
+enum
+{
/* FILL ME */
SIGNAL_HANDOFF,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_LOCATION
};
/* added a src factory function to force audio/raw MIME type */
/* I think the caps can be broader, we need to change that somehow */
-static GstStaticPadTemplate afsrc_src_factory =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-raw-int, "
- "rate = (int) [ 1, MAX ], "
- "channels = (int) [ 1, MAX ], "
- "endianness = (int) BYTE_ORDER, "
- "width = (int) { 8, 16 }, "
- "depth = (int) { 8, 16 }, "
- "signed = (boolean) { true, false }, "
- "buffer-frames = (int) [ 1, MAX ]"
- )
-);
+static GstStaticPadTemplate afsrc_src_factory = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "rate = (int) [ 1, MAX ], "
+ "channels = (int) [ 1, MAX ], "
+ "endianness = (int) BYTE_ORDER, "
+ "width = (int) { 8, 16 }, "
+ "depth = (int) { 8, 16 }, "
+ "signed = (boolean) { true, false }, "
+ "buffer-frames = (int) [ 1, MAX ]")
+ );
/* we use an enum for the output type arg */
return afsrc_types_type;
}
*/
-static void gst_afsrc_base_init (gpointer g_class);
-static void gst_afsrc_class_init (GstAFSrcClass *klass);
-static void gst_afsrc_init (GstAFSrc *afsrc);
+static void gst_afsrc_base_init (gpointer g_class);
+static void gst_afsrc_class_init (GstAFSrcClass * klass);
+static void gst_afsrc_init (GstAFSrc * afsrc);
-static gboolean gst_afsrc_open_file (GstAFSrc *src);
-static void gst_afsrc_close_file (GstAFSrc *src);
+static gboolean gst_afsrc_open_file (GstAFSrc * src);
+static void gst_afsrc_close_file (GstAFSrc * src);
-static GstData* gst_afsrc_get (GstPad *pad);
+static GstData *gst_afsrc_get (GstPad * pad);
-static void gst_afsrc_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_afsrc_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static void gst_afsrc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_afsrc_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static GstElementStateReturn gst_afsrc_change_state (GstElement *element);
+static GstElementStateReturn gst_afsrc_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
static guint gst_afsrc_signals[LAST_SIGNAL] = { 0 };
GType
-gst_afsrc_get_type (void)
+gst_afsrc_get_type (void)
{
static GType afsrc_type = 0;
0,
(GInstanceInitFunc) gst_afsrc_init,
};
- afsrc_type = g_type_register_static (GST_TYPE_ELEMENT, "GstAFSrc", &afsrc_info, 0);
+ afsrc_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstAFSrc", &afsrc_info, 0);
}
return afsrc_type;
}
}
static void
-gst_afsrc_class_init (GstAFSrcClass *klass)
+gst_afsrc_class_init (GstAFSrcClass * 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);
- gst_element_class_install_std_props (
- GST_ELEMENT_CLASS (klass),
- "location", ARG_LOCATION, G_PARAM_READWRITE,
- NULL);
-
+ gst_element_class_install_std_props (GST_ELEMENT_CLASS (klass),
+ "location", ARG_LOCATION, G_PARAM_READWRITE, NULL);
+
gst_afsrc_signals[SIGNAL_HANDOFF] =
- g_signal_new ("handoff", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstAFSrcClass, handoff), NULL, NULL,
- g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstAFSrcClass, handoff), NULL, NULL,
+ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
gobject_class->set_property = gst_afsrc_set_property;
gstelement_class->change_state = gst_afsrc_change_state;
}
-static void
-gst_afsrc_init (GstAFSrc *afsrc)
+static void
+gst_afsrc_init (GstAFSrc * afsrc)
{
/* no need for a template, caps are set based on file, right ? */
- afsrc->srcpad = gst_pad_new_from_template (
- gst_element_get_pad_template (GST_ELEMENT (afsrc), "src"), "src");
+ afsrc->srcpad =
+ gst_pad_new_from_template (gst_element_get_pad_template (GST_ELEMENT
+ (afsrc), "src"), "src");
gst_element_add_pad (GST_ELEMENT (afsrc), afsrc->srcpad);
gst_pad_use_explicit_caps (afsrc->srcpad);
gst_pad_set_get_function (afsrc->srcpad, gst_afsrc_get);
}
static GstData *
-gst_afsrc_get (GstPad *pad)
+gst_afsrc_get (GstPad * pad)
{
GstAFSrc *src;
GstBuffer *buf;
buf = gst_buffer_new ();
g_return_val_if_fail (buf, NULL);
-
+
GST_BUFFER_DATA (buf) = (gpointer) g_malloc (src->bytes_per_read);
-
+
/* calculate frameCount to read based on file info */
frameCount = src->bytes_per_read / (src->channels * src->width / 8);
/* g_print ("DEBUG: gstafsrc: going to read %ld frames\n", frameCount); */
readframes = afReadFrames (src->file, AF_DEFAULT_TRACK, GST_BUFFER_DATA (buf),
- frameCount);
+ frameCount);
readbytes = readframes * (src->channels * src->width / 8);
if (readbytes == 0) {
gst_element_set_eos (GST_ELEMENT (src));
- return GST_DATA (gst_event_new (GST_EVENT_EOS));
+ return GST_DATA (gst_event_new (GST_EVENT_EOS));
}
-
+
GST_BUFFER_SIZE (buf) = readbytes;
GST_BUFFER_OFFSET (buf) = src->curoffset;
src->framestamp += gst_audio_frame_length (src->srcpad, buf);
GST_BUFFER_TIMESTAMP (buf) = src->framestamp * 1E9
- / gst_audio_frame_rate (src->srcpad);
+ / gst_audio_frame_rate (src->srcpad);
printf ("DEBUG: afsrc: timestamp set on output buffer: %f sec\n",
- GST_BUFFER_TIMESTAMP (buf) / 1E9);
+ GST_BUFFER_TIMESTAMP (buf) / 1E9);
/* g_print("DEBUG: gstafsrc: pushed buffer of %ld bytes\n", readbytes); */
return GST_DATA (buf);
}
static void
-gst_afsrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_afsrc_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstAFSrc *src;
}
}
-static void
-gst_afsrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+static void
+gst_afsrc_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstAFSrc *src;
-
+
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_AFSRC (object));
-
+
src = GST_AFSRC (object);
-
+
switch (prop_id) {
case ARG_LOCATION:
g_value_set_string (value, src->filename);
}
gboolean
-gst_afsrc_plugin_init (GstPlugin *plugin)
+gst_afsrc_plugin_init (GstPlugin * plugin)
{
/* load audio support library */
if (!gst_library_load ("gstaudio"))
/* this is where we open the audiofile */
static gboolean
-gst_afsrc_open_file (GstAFSrc *src)
+gst_afsrc_open_file (GstAFSrc * src)
{
g_return_val_if_fail (!GST_FLAG_IS_SET (src, GST_AFSRC_OPEN), FALSE);
/* open the file */
src->file = afOpenFile (src->filename, "r", AF_NULL_FILESETUP);
- if (src->file == AF_NULL_FILEHANDLE)
- {
- GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
- (_("Could not open file \"%s\" for reading."), src->filename),
- ("system error: %s", strerror (errno)));
+ if (src->file == AF_NULL_FILEHANDLE) {
+ GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
+ (_("Could not open file \"%s\" for reading."), src->filename),
+ ("system error: %s", strerror (errno)));
return FALSE;
}
/* get the audiofile audio parameters */
{
int sampleFormat, sampleWidth;
+
src->channels = afGetChannels (src->file, AF_DEFAULT_TRACK);
- afGetSampleFormat (src->file, AF_DEFAULT_TRACK,
- &sampleFormat, &sampleWidth);
- switch (sampleFormat)
- {
- case AF_SAMPFMT_TWOSCOMP:
- src->is_signed = TRUE;
- break;
- case AF_SAMPFMT_UNSIGNED:
- src->is_signed = FALSE;
- break;
- case AF_SAMPFMT_FLOAT:
- case AF_SAMPFMT_DOUBLE:
- GST_DEBUG (
- "ERROR: float data not supported yet !\n");
- }
- src->rate = (guint) afGetRate (src->file, AF_DEFAULT_TRACK);
+ afGetSampleFormat (src->file, AF_DEFAULT_TRACK,
+ &sampleFormat, &sampleWidth);
+ switch (sampleFormat) {
+ case AF_SAMPFMT_TWOSCOMP:
+ src->is_signed = TRUE;
+ break;
+ case AF_SAMPFMT_UNSIGNED:
+ src->is_signed = FALSE;
+ break;
+ case AF_SAMPFMT_FLOAT:
+ case AF_SAMPFMT_DOUBLE:
+ GST_DEBUG ("ERROR: float data not supported yet !\n");
+ }
+ src->rate = (guint) afGetRate (src->file, AF_DEFAULT_TRACK);
src->width = sampleWidth;
- GST_DEBUG (
- "input file: %d channels, %d width, %d rate, signed %s\n",
- src->channels, src->width, src->rate,
- src->is_signed ? "yes" : "no");
+ GST_DEBUG ("input file: %d channels, %d width, %d rate, signed %s\n",
+ src->channels, src->width, src->rate, src->is_signed ? "yes" : "no");
}
-
+
/* set caps on src */
- gst_pad_set_explicit_caps (src->srcpad,
+ gst_pad_set_explicit_caps (src->srcpad,
gst_caps_new_simple ("audio/x-raw-int",
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "signed", G_TYPE_BOOLEAN, src->is_signed,
- "width", G_TYPE_INT, src->width,
- "depth", G_TYPE_INT, src->width,
- "rate", G_TYPE_INT, src->rate,
- "channels", G_TYPE_INT, src->channels,
- NULL));
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "signed", G_TYPE_BOOLEAN, src->is_signed,
+ "width", G_TYPE_INT, src->width,
+ "depth", G_TYPE_INT, src->width,
+ "rate", G_TYPE_INT, src->rate,
+ "channels", G_TYPE_INT, src->channels, NULL));
GST_FLAG_SET (src, GST_AFSRC_OPEN);
}
static void
-gst_afsrc_close_file (GstAFSrc *src)
+gst_afsrc_close_file (GstAFSrc * src)
{
/* g_print ("DEBUG: closing srcfile...\n"); */
g_return_if_fail (GST_FLAG_IS_SET (src, GST_AFSRC_OPEN));
/* g_print ("DEBUG: past flag test\n"); */
/* if (fclose (src->file) != 0) */
- if (afCloseFile (src->file) != 0)
- {
+ if (afCloseFile (src->file) != 0) {
GST_ELEMENT_ERROR (src, RESOURCE, CLOSE,
- (_("Error closing file \"%s\"."), src->filename),
- GST_ERROR_SYSTEM);
+ (_("Error closing file \"%s\"."), src->filename), GST_ERROR_SYSTEM);
} else {
GST_FLAG_UNSET (src, GST_AFSRC_OPEN);
}
}
static GstElementStateReturn
-gst_afsrc_change_state (GstElement *element)
+gst_afsrc_change_state (GstElement * element)
{
g_return_val_if_fail (GST_IS_AFSRC (element), GST_STATE_FAILURE);
/* if going to NULL then close the file */
- if (GST_STATE_PENDING (element) == GST_STATE_NULL)
- {
+ if (GST_STATE_PENDING (element) == GST_STATE_NULL) {
/* printf ("DEBUG: afsrc state change: null pending\n"); */
- if (GST_FLAG_IS_SET (element, GST_AFSRC_OPEN))
- {
+ if (GST_FLAG_IS_SET (element, GST_AFSRC_OPEN)) {
/* g_print ("DEBUG: trying to close the src file\n"); */
gst_afsrc_close_file (GST_AFSRC (element));
}
- }
- else if (GST_STATE_PENDING (element) == GST_STATE_READY)
- {
+ } else if (GST_STATE_PENDING (element) == GST_STATE_READY) {
/* g_print ("DEBUG: afsrc: ready state pending. This shouldn't happen at the *end* of a stream\n"); */
- if (!GST_FLAG_IS_SET (element, GST_AFSRC_OPEN))
- {
+ if (!GST_FLAG_IS_SET (element, GST_AFSRC_OPEN)) {
/* g_print ("DEBUG: GST_AFSRC_OPEN not set\n"); */
- if (!gst_afsrc_open_file (GST_AFSRC (element)))
- {
+ if (!gst_afsrc_open_file (GST_AFSRC (element))) {
/* g_print ("DEBUG: element tries to open file\n"); */
- return GST_STATE_FAILURE;
+ return GST_STATE_FAILURE;
}
}
}
#include <gst/gst.h>
-#include <audiofile.h> /* what else are we to do */
+#include <audiofile.h> /* what else are we to do */
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
/*GstElementDetails gst_afsrc_details;*/
#define GST_IS_AFSRC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AFSRC))
-typedef struct _GstAFSrc GstAFSrc;
-typedef struct _GstAFSrcClass GstAFSrcClass;
+ typedef struct _GstAFSrc GstAFSrc;
+ typedef struct _GstAFSrcClass GstAFSrcClass;
-typedef enum {
- GST_AFSRC_OPEN = GST_ELEMENT_FLAG_LAST,
+ typedef enum
+ {
+ GST_AFSRC_OPEN = GST_ELEMENT_FLAG_LAST,
- GST_AFSRC_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
-} GstAFSrcFlags;
+ GST_AFSRC_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
+ } GstAFSrcFlags;
-struct _GstAFSrc {
- GstElement element;
- GstPad *srcpad;
+ struct _GstAFSrc
+ {
+ GstElement element;
+ GstPad *srcpad;
- gchar *filename;
+ gchar *filename;
/* FILE *file; */
/* AFfilesetup outfilesetup; */
- AFfilehandle file;
- int format;
- int channels;
- int width;
- unsigned int rate;
- gboolean is_signed;
- int type; /* type of output, compare to audiofile.h
- * RAW, AIFF, AIFFC, NEXTSND, WAVE
- */
- /* blocking */
- gulong curoffset;
- gulong bytes_per_read;
+ AFfilehandle file;
+ int format;
+ int channels;
+ int width;
+ unsigned int rate;
+ gboolean is_signed;
+ int type; /* type of output, compare to audiofile.h
+ * RAW, AIFF, AIFFC, NEXTSND, WAVE
+ */
+ /* blocking */
+ gulong curoffset;
+ gulong bytes_per_read;
- gulong seq;
- guint64 framestamp;
- /* FIXME : endianness is a little cryptic at this point */
- int endianness_data; /* 4321 or 1234 */
- int endianness_wanted; /* same thing, but what the output format wants */
- int endianness_output; /* what the output endianness will be */
-};
+ gulong seq;
+ guint64 framestamp;
+ /* FIXME : endianness is a little cryptic at this point */
+ int endianness_data; /* 4321 or 1234 */
+ int endianness_wanted; /* same thing, but what the output format wants */
+ int endianness_output; /* what the output endianness will be */
+ };
-struct _GstAFSrcClass {
- GstElementClass parent_class;
+ struct _GstAFSrcClass
+ {
+ GstElementClass parent_class;
- /* signals */
- void (*handoff) (GstElement *element,GstPad *pad);
-};
+ /* signals */
+ void (*handoff) (GstElement * element, GstPad * pad);
+ };
-GType gst_afsrc_get_type (void);
-gboolean gst_afsrc_plugin_init (GstPlugin *plugin);
+ GType gst_afsrc_get_type (void);
+ gboolean gst_afsrc_plugin_init (GstPlugin * plugin);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_AFSRC_H__ */
+#endif /* __GST_AFSRC_H__ */
typedef struct _GstCDAudio GstCDAudio;
typedef struct _GstCDAudioClass GstCDAudioClass;
-struct _GstCDAudio {
- GstBin element;
-
+struct _GstCDAudio
+{
+ GstBin element;
+
/* properties */
- gchar *device;
+ gchar *device;
- gint cd_desc;
- gulong discid;
+ gint cd_desc;
+ gulong discid;
- gboolean was_playing;
+ gboolean was_playing;
- struct disc_info info;
- struct disc_volume volume;
+ struct disc_info info;
+ struct disc_volume volume;
- GTimer *timer;
+ GTimer *timer;
};
-struct _GstCDAudioClass {
- GstBinClass parent_class;
+struct _GstCDAudioClass
+{
+ GstBinClass parent_class;
- void (*close_tray) (GstElement *element);
+ void (*close_tray) (GstElement * element);
/* signal callbacks */
- void (*track_change) (GstElement *element, guint track);
+ void (*track_change) (GstElement * element, guint track);
};
/* props */
LAST_SIGNAL,
};
-static void gst_cdaudio_class_init (GstCDAudioClass *klass);
-static void gst_cdaudio_init (GstCDAudio *cdaudio);
-static void gst_cdaudio_dispose (GObject *object);
-
-static void gst_cdaudio_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *spec);
-static void gst_cdaudio_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *spec);
-static GstElementStateReturn
- gst_cdaudio_change_state (GstElement * element);
-
-static const GstEventMask* gst_cdaudio_get_event_masks (GstElement *element);
-static gboolean gst_cdaudio_send_event (GstElement *element, GstEvent *event);
-static const GstFormat* gst_cdaudio_get_formats (GstElement *element);
-static gboolean gst_cdaudio_convert (GstElement *element,
- GstFormat src_format, gint64 src_value,
- GstFormat *dest_format, gint64 *dest_value);
-static const GstQueryType* gst_cdaudio_get_query_types (GstElement *element);
-static gboolean gst_cdaudio_query (GstElement *element, GstQueryType type,
- GstFormat *format, gint64 *value);
+static void gst_cdaudio_class_init (GstCDAudioClass * klass);
+static void gst_cdaudio_init (GstCDAudio * cdaudio);
+static void gst_cdaudio_dispose (GObject * object);
+
+static void gst_cdaudio_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * spec);
+static void gst_cdaudio_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * spec);
+static GstElementStateReturn gst_cdaudio_change_state (GstElement * element);
+
+static const GstEventMask *gst_cdaudio_get_event_masks (GstElement * element);
+static gboolean gst_cdaudio_send_event (GstElement * element, GstEvent * event);
+static const GstFormat *gst_cdaudio_get_formats (GstElement * element);
+static gboolean gst_cdaudio_convert (GstElement * element,
+ GstFormat src_format, gint64 src_value,
+ GstFormat * dest_format, gint64 * dest_value);
+static const GstQueryType *gst_cdaudio_get_query_types (GstElement * element);
+static gboolean gst_cdaudio_query (GstElement * element, GstQueryType type,
+ GstFormat * format, gint64 * value);
static GstFormat track_format;
static GstFormat sector_format;
-
+
static GstElementClass *parent_class;
static guint gst_cdaudio_signals[LAST_SIGNAL] = { 0 };
(GInstanceInitFunc) gst_cdaudio_init,
NULL
};
- gst_cdaudio_type = g_type_register_static (GST_TYPE_BIN, "GstCDAudio", &gst_cdaudio_info, 0);
+ gst_cdaudio_type =
+ g_type_register_static (GST_TYPE_BIN, "GstCDAudio", &gst_cdaudio_info,
+ 0);
track_format = gst_format_register ("track", "CD track");
sector_format = gst_format_register ("sector", "CD sector");
gobject_klass->get_property = gst_cdaudio_get_property;
g_object_class_install_property (gobject_klass, ARG_DEVICE,
- g_param_spec_string ("device", "Device", "CDROM device",
- NULL, G_PARAM_READWRITE));
+ g_param_spec_string ("device", "Device", "CDROM device",
+ NULL, G_PARAM_READWRITE));
g_object_class_install_property (gobject_klass, ARG_DISCID,
- g_param_spec_ulong ("discid", "Disc ID", "CDDB Disc ID",
- 0, G_MAXULONG, 0, G_PARAM_READABLE));
+ g_param_spec_ulong ("discid", "Disc ID", "CDDB Disc ID",
+ 0, G_MAXULONG, 0, G_PARAM_READABLE));
g_object_class_install_property (gobject_klass, ARG_VOLUME_FL,
- g_param_spec_int ("volume_fl", "Volume fl", "Front left volume",
- 0, 255, 255, G_PARAM_READWRITE));
+ g_param_spec_int ("volume_fl", "Volume fl", "Front left volume",
+ 0, 255, 255, G_PARAM_READWRITE));
g_object_class_install_property (gobject_klass, ARG_VOLUME_FR,
- g_param_spec_int ("volume_fr", "Volume fr", "Front right volume",
- 0, 255, 255, G_PARAM_READWRITE));
+ g_param_spec_int ("volume_fr", "Volume fr", "Front right volume",
+ 0, 255, 255, G_PARAM_READWRITE));
g_object_class_install_property (gobject_klass, ARG_VOLUME_BL,
- g_param_spec_int ("volume_bl", "Volume bl", "Back left volume",
- 0, 255, 255, G_PARAM_READWRITE));
+ g_param_spec_int ("volume_bl", "Volume bl", "Back left volume",
+ 0, 255, 255, G_PARAM_READWRITE));
g_object_class_install_property (gobject_klass, ARG_VOLUME_BR,
- g_param_spec_int ("volume_br", "Volume br", "Back right volume",
- 0, 255, 255, G_PARAM_READWRITE));
+ g_param_spec_int ("volume_br", "Volume br", "Back right volume",
+ 0, 255, 255, G_PARAM_READWRITE));
gst_cdaudio_signals[TRACK_CHANGE] =
- g_signal_new ("track-change", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstCDAudioClass, track_change), NULL, NULL,
- gst_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
+ g_signal_new ("track-change", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstCDAudioClass, track_change), NULL,
+ NULL, gst_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
gobject_klass->dispose = GST_DEBUG_FUNCPTR (gst_cdaudio_dispose);
- gstelement_klass->change_state = GST_DEBUG_FUNCPTR (gst_cdaudio_change_state);
- gstelement_klass->get_event_masks = GST_DEBUG_FUNCPTR (gst_cdaudio_get_event_masks);
- gstelement_klass->send_event = GST_DEBUG_FUNCPTR (gst_cdaudio_send_event);
- gstelement_klass->get_formats = GST_DEBUG_FUNCPTR (gst_cdaudio_get_formats);
- gstelement_klass->convert = GST_DEBUG_FUNCPTR (gst_cdaudio_convert);
- gstelement_klass->get_query_types = GST_DEBUG_FUNCPTR (gst_cdaudio_get_query_types);
- gstelement_klass->query = GST_DEBUG_FUNCPTR (gst_cdaudio_query);
+ gstelement_klass->change_state = GST_DEBUG_FUNCPTR (gst_cdaudio_change_state);
+ gstelement_klass->get_event_masks =
+ GST_DEBUG_FUNCPTR (gst_cdaudio_get_event_masks);
+ gstelement_klass->send_event = GST_DEBUG_FUNCPTR (gst_cdaudio_send_event);
+ gstelement_klass->get_formats = GST_DEBUG_FUNCPTR (gst_cdaudio_get_formats);
+ gstelement_klass->convert = GST_DEBUG_FUNCPTR (gst_cdaudio_convert);
+ gstelement_klass->get_query_types =
+ GST_DEBUG_FUNCPTR (gst_cdaudio_get_query_types);
+ gstelement_klass->query = GST_DEBUG_FUNCPTR (gst_cdaudio_query);
}
static void
}
static void
-gst_cdaudio_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * spec)
+gst_cdaudio_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * spec)
{
GstCDAudio *cdaudio;
}
static void
-gst_cdaudio_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * spec)
+gst_cdaudio_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * spec)
{
GstCDAudio *cdaudio;
}
static void
-print_track_info (GstCDAudio *cdaudio)
+print_track_info (GstCDAudio * cdaudio)
{
gint i;
for (i = 0; i < cdaudio->info.disc_total_tracks; i++) {
- g_print ("%d %d %d %d:%02d\n", i,
- cdaudio->info.disc_track[i].track_length.frames,
- cdaudio->info.disc_track[i].track_pos.frames,
- cdaudio->info.disc_track[i].track_length.minutes,
- cdaudio->info.disc_track[i].track_length.seconds);
+ g_print ("%d %d %d %d:%02d\n", i,
+ cdaudio->info.disc_track[i].track_length.frames,
+ cdaudio->info.disc_track[i].track_pos.frames,
+ cdaudio->info.disc_track[i].track_length.minutes,
+ cdaudio->info.disc_track[i].track_length.seconds);
}
}
case GST_STATE_NULL_TO_READY:
break;
case GST_STATE_READY_TO_PAUSED:
- cdaudio->cd_desc = cd_init_device(cdaudio->device);
- if (cdaudio->cd_desc < 0)
+ cdaudio->cd_desc = cd_init_device (cdaudio->device);
+ if (cdaudio->cd_desc < 0)
return GST_STATE_FAILURE;
/* close tray */
gint res;
if (cdaudio->was_playing)
- res = cd_resume (cdaudio->cd_desc);
+ res = cd_resume (cdaudio->cd_desc);
else
- res = cd_play (cdaudio->cd_desc, 1);
+ res = cd_play (cdaudio->cd_desc, 1);
- if (res < 0)
+ if (res < 0)
return GST_STATE_FAILURE;
cdaudio->was_playing = TRUE;
}
GST_ELEMENT_EVENT_MASK_FUNCTION (gst_cdaudio_get_event_masks,
- { GST_EVENT_SEEK, GST_SEEK_FLAG_FLUSH },
- { GST_EVENT_SEEK_SEGMENT, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SEGMENT_LOOP }
+ {
+ GST_EVENT_SEEK, GST_SEEK_FLAG_FLUSH}
+
+ , {
+ GST_EVENT_SEEK_SEGMENT, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SEGMENT_LOOP}
+
)
-gboolean
-gst_cdaudio_send_event (GstElement *element, GstEvent *event)
+ gboolean
+gst_cdaudio_send_event (GstElement * element, GstEvent * event)
{
GstCDAudio *cdaudio;
gboolean res = TRUE;
case GST_EVENT_SEEK:
switch (GST_EVENT_SEEK_FORMAT (event)) {
case GST_FORMAT_TIME:
- {
- cd_play_pos (cdaudio->cd_desc, 1, GST_EVENT_SEEK_OFFSET (event) / (60 * GST_SECOND));
- break;
+ {
+ cd_play_pos (cdaudio->cd_desc, 1,
+ GST_EVENT_SEEK_OFFSET (event) / (60 * GST_SECOND));
+ break;
}
- default:
- res = FALSE;
- break;
+ default:
+ res = FALSE;
+ break;
}
break;
default:
return res;
}
-const GstFormat*
-gst_cdaudio_get_formats (GstElement *element)
+const GstFormat *
+gst_cdaudio_get_formats (GstElement * element)
{
static GstFormat formats[] = {
GST_FORMAT_TIME,
GST_FORMAT_BYTES,
GST_FORMAT_DEFAULT,
- 0, /* fillted below */
- 0, /* fillted below */
+ 0, /* fillted below */
+ 0, /* fillted below */
0,
};
}
gboolean
-gst_cdaudio_convert (GstElement *element,
- GstFormat src_format, gint64 src_value,
- GstFormat *dest_format, gint64 *dest_value)
+gst_cdaudio_convert (GstElement * element,
+ GstFormat src_format, gint64 src_value,
+ GstFormat * dest_format, gint64 * dest_value)
{
return FALSE;
}
-const GstQueryType*
-gst_cdaudio_get_query_types (GstElement *element)
+const GstQueryType *
+gst_cdaudio_get_query_types (GstElement * element)
{
static const GstQueryType query_types[] = {
GST_QUERY_TOTAL,
}
gboolean
-gst_cdaudio_query (GstElement *element, GstQueryType type,
- GstFormat *format, gint64 *value)
+gst_cdaudio_query (GstElement * element, GstQueryType type,
+ GstFormat * format, gint64 * value)
{
GstCDAudio *cdaudio;
gboolean res = TRUE;
case GST_QUERY_TOTAL:
switch (*format) {
case GST_FORMAT_TIME:
- *value = (cdaudio->info.disc_length.minutes * 60 +
- cdaudio->info.disc_length.seconds) * GST_SECOND;
+ *value = (cdaudio->info.disc_length.minutes * 60 +
+ cdaudio->info.disc_length.seconds) * GST_SECOND;
break;
default:
{
- if (*format == track_format) {
- *value = cdaudio->info.disc_total_tracks;
- }
- else {
- res = FALSE;
+ if (*format == track_format) {
+ *value = cdaudio->info.disc_total_tracks;
+ } else {
+ res = FALSE;
}
break;
}
case GST_QUERY_POSITION:
switch (*format) {
case GST_FORMAT_TIME:
- *value = (cdaudio->info.disc_time.minutes * 60 +
- cdaudio->info.disc_time.seconds) * GST_SECOND;
+ *value = (cdaudio->info.disc_time.minutes * 60 +
+ cdaudio->info.disc_time.seconds) * GST_SECOND;
break;
default:
{
- if (*format == track_format) {
- *value = cdaudio->info.disc_current_track;
- }
- else {
- res = FALSE;
+ if (*format == track_format) {
+ *value = cdaudio->info.disc_current_track;
+ } else {
+ res = FALSE;
}
break;
}
{
GstElementFactory *factory;
- factory = gst_element_factory_new ("cdaudio", GST_TYPE_CDAUDIO, &gst_cdaudio_details);
+ factory =
+ gst_element_factory_new ("cdaudio", GST_TYPE_CDAUDIO,
+ &gst_cdaudio_details);
g_return_val_if_fail (factory != NULL, FALSE);
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
#include <decore.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_DIVXDEC \
#define GST_IS_DIVXDEC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_DIVXDEC))
-typedef struct _GstDivxDec GstDivxDec;
-typedef struct _GstDivxDecClass GstDivxDecClass;
+ typedef struct _GstDivxDec GstDivxDec;
+ typedef struct _GstDivxDecClass GstDivxDecClass;
-struct _GstDivxDec {
- GstElement element;
+ struct _GstDivxDec
+ {
+ GstElement element;
- /* pads */
- GstPad *sinkpad, *srcpad;
+ /* pads */
+ GstPad *sinkpad, *srcpad;
- /* divx handle */
- void *handle;
+ /* divx handle */
+ void *handle;
- /* video (output) settings */
- guint32 csp;
- int bitcnt, bpp;
- int version;
- int width, height;
- gdouble fps;
-};
+ /* video (output) settings */
+ guint32 csp;
+ int bitcnt, bpp;
+ int version;
+ int width, height;
+ gdouble fps;
+ };
-struct _GstDivxDecClass {
- GstElementClass parent_class;
-};
+ struct _GstDivxDecClass
+ {
+ GstElementClass parent_class;
+ };
-GType gst_divxdec_get_type(void);
+ GType gst_divxdec_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_DIVXDEC_H__ */
+#endif /* __GST_DIVXDEC_H__ */
#include <gst/gst.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_DIVXENC \
#define GST_IS_DIVXENC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_DIVXENC))
-typedef struct _GstDivxEnc GstDivxEnc;
-typedef struct _GstDivxEncClass GstDivxEncClass;
+ typedef struct _GstDivxEnc GstDivxEnc;
+ typedef struct _GstDivxEncClass GstDivxEncClass;
-struct _GstDivxEnc {
- GstElement element;
+ struct _GstDivxEnc
+ {
+ GstElement element;
- /* pads */
- GstPad *sinkpad, *srcpad;
+ /* pads */
+ GstPad *sinkpad, *srcpad;
- /* quality of encoded image */
- gulong bitrate;
+ /* quality of encoded image */
+ gulong bitrate;
- /* size of the buffers */
- gulong buffer_size;
+ /* size of the buffers */
+ gulong buffer_size;
- /* max key interval */
- gint max_key_interval;
+ /* max key interval */
+ gint max_key_interval;
- /* amount of motion estimation to do */
- gint quality;
+ /* amount of motion estimation to do */
+ gint quality;
- /* divx handle */
- void *handle;
- guint32 csp;
- gint bitcnt;
- gint width, height;
- gfloat fps;
-};
+ /* divx handle */
+ void *handle;
+ guint32 csp;
+ gint bitcnt;
+ gint width, height;
+ gfloat fps;
+ };
-struct _GstDivxEncClass {
- GstElementClass parent_class;
+ struct _GstDivxEncClass
+ {
+ GstElementClass parent_class;
- /* signals */
- void (*frame_encoded) (GstElement *element);
-};
+ /* signals */
+ void (*frame_encoded) (GstElement * element);
+ };
-GType gst_divxenc_get_type(void);
+ GType gst_divxenc_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_DIVXENC_H__ */
+#endif /* __GST_DIVXENC_H__ */
#include "gstfaac.h"
-static GstStaticPadTemplate src_template =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "audio/mpeg, "
- "mpegversion = (int) { 4, 2 }, "
- "channels = (int) [ 1, 6 ], "
- "rate = (int) [ 8000, 96000 ]"
- )
-);
-
-static GstStaticPadTemplate sink_template =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "audio/x-raw-int, "
- "endianness = (int) BYTE_ORDER, "
- "signed = (boolean) TRUE, "
- "width = (int) 16, "
- "depth = (int) 16, "
- "rate = (int) [ 8000, 96000 ], "
- "channels = (int) [ 1, 6]; "
- "audio/x-raw-int, "
- "endianness = (int) BYTE_ORDER, "
- "signed = (boolean) TRUE, "
- "width = (int) 32, "
- "depth = (int) 24, "
- "rate = (int) [ 8000, 96000], "
- "channels = (int) [ 1, 6]; "
- "audio/x-raw-float, "
- "endianness = (int) BYTE_ORDER, "
- "depth = (int) 32, " /* sizeof (gfloat) */
- "rate = (int) [ 8000, 96000], "
- "channels = (int) [ 1, 6]"
- )
-);
-
-enum {
+static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/mpeg, "
+ "mpegversion = (int) { 4, 2 }, "
+ "channels = (int) [ 1, 6 ], " "rate = (int) [ 8000, 96000 ]")
+ );
+
+static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-int, " "endianness = (int) BYTE_ORDER, " "signed = (boolean) TRUE, " "width = (int) 16, " "depth = (int) 16, " "rate = (int) [ 8000, 96000 ], " "channels = (int) [ 1, 6]; " "audio/x-raw-int, " "endianness = (int) BYTE_ORDER, " "signed = (boolean) TRUE, " "width = (int) 32, " "depth = (int) 24, " "rate = (int) [ 8000, 96000], " "channels = (int) [ 1, 6]; " "audio/x-raw-float, " "endianness = (int) BYTE_ORDER, " "depth = (int) 32, " /* sizeof (gfloat) */
+ "rate = (int) [ 8000, 96000], " "channels = (int) [ 1, 6]")
+ );
+
+enum
+{
ARG_0,
ARG_BITRATE,
ARG_PROFILE,
ARG_TNS,
ARG_MIDSIDE,
ARG_SHORTCTL
- /* FILL ME */
+ /* FILL ME */
};
-static void gst_faac_base_init (GstFaacClass *klass);
-static void gst_faac_class_init (GstFaacClass *klass);
-static void gst_faac_init (GstFaac *faac);
+static void gst_faac_base_init (GstFaacClass * klass);
+static void gst_faac_class_init (GstFaacClass * klass);
+static void gst_faac_init (GstFaac * faac);
-static void gst_faac_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gst_faac_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
+static void gst_faac_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+static void gst_faac_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
static GstPadLinkReturn
- gst_faac_sinkconnect (GstPad *pad,
- const GstCaps *caps);
+gst_faac_sinkconnect (GstPad * pad, const GstCaps * caps);
static GstPadLinkReturn
- gst_faac_srcconnect (GstPad *pad,
- const GstCaps *caps);
-static void gst_faac_chain (GstPad *pad,
- GstData *data);
-static GstElementStateReturn
- gst_faac_change_state (GstElement *element);
+gst_faac_srcconnect (GstPad * pad, const GstCaps * caps);
+static void gst_faac_chain (GstPad * pad, GstData * data);
+static GstElementStateReturn gst_faac_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
+
/* static guint gst_faac_signals[LAST_SIGNAL] = { 0 }; */
GType
if (!gst_faac_type) {
static const GTypeInfo gst_faac_info = {
- sizeof (GstFaacClass),
+ sizeof (GstFaacClass),
(GBaseInitFunc) gst_faac_base_init,
NULL,
(GClassInitFunc) gst_faac_class_init,
NULL,
NULL,
- sizeof(GstFaac),
+ sizeof (GstFaac),
0,
(GInstanceInitFunc) gst_faac_init,
};
gst_faac_type = g_type_register_static (GST_TYPE_ELEMENT,
- "GstFaac",
- &gst_faac_info, 0);
+ "GstFaac", &gst_faac_info, 0);
}
return gst_faac_type;
}
static void
-gst_faac_base_init (GstFaacClass *klass)
+gst_faac_base_init (GstFaacClass * klass)
{
GstElementDetails gst_faac_details = {
"Free AAC Encoder (FAAC)",
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&src_template));
+ gst_static_pad_template_get (&src_template));
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&sink_template));
+ gst_static_pad_template_get (&sink_template));
gst_element_class_set_details (element_class, &gst_faac_details);
}
if (!gst_faac_profile_type) {
static GEnumValue gst_faac_profile[] = {
- { MAIN, "MAIN", "Main profile" },
- { LOW, "LOW", "Low complexity profile" },
- { SSR, "SSR", "Scalable sampling rate profile" },
- { LTP, "LTP", "Long term prediction profile" },
- { 0, NULL, NULL },
+ {MAIN, "MAIN", "Main profile"},
+ {LOW, "LOW", "Low complexity profile"},
+ {SSR, "SSR", "Scalable sampling rate profile"},
+ {LTP, "LTP", "Long term prediction profile"},
+ {0, NULL, NULL},
};
gst_faac_profile_type = g_enum_register_static ("GstFaacProfile",
- gst_faac_profile);
+ gst_faac_profile);
}
return gst_faac_profile_type;
if (!gst_faac_shortctl_type) {
static GEnumValue gst_faac_shortctl[] = {
- { SHORTCTL_NORMAL, "SHORTCTL_NORMAL", "Normal block type" },
- { SHORTCTL_NOSHORT, "SHORTCTL_NOSHORT", "No short blocks" },
- { SHORTCTL_NOLONG, "SHORTCTL_NOLONG", "No long blocks" },
- { 0, NULL, NULL },
+ {SHORTCTL_NORMAL, "SHORTCTL_NORMAL", "Normal block type"},
+ {SHORTCTL_NOSHORT, "SHORTCTL_NOSHORT", "No short blocks"},
+ {SHORTCTL_NOLONG, "SHORTCTL_NOLONG", "No long blocks"},
+ {0, NULL, NULL},
};
gst_faac_shortctl_type = g_enum_register_static ("GstFaacShortCtl",
- gst_faac_shortctl);
+ gst_faac_shortctl);
}
return gst_faac_shortctl_type;
}
static void
-gst_faac_class_init (GstFaacClass *klass)
+gst_faac_class_init (GstFaacClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
/* properties */
g_object_class_install_property (gobject_class, ARG_BITRATE,
- g_param_spec_int ("bitrate", "Bitrate (bps)", "Bitrate in bits/sec",
- 8 * 1024, 320 * 1024, 128 * 1024, G_PARAM_READWRITE));
+ g_param_spec_int ("bitrate", "Bitrate (bps)", "Bitrate in bits/sec",
+ 8 * 1024, 320 * 1024, 128 * 1024, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_PROFILE,
- g_param_spec_enum ("profile", "Profile", "MPEG/AAC encoding profile",
- GST_TYPE_FAAC_PROFILE, MAIN, G_PARAM_READWRITE));
+ g_param_spec_enum ("profile", "Profile", "MPEG/AAC encoding profile",
+ GST_TYPE_FAAC_PROFILE, MAIN, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_TNS,
- g_param_spec_boolean ("tns", "TNS", "Use temporal noise shaping",
- FALSE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("tns", "TNS", "Use temporal noise shaping",
+ FALSE, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_MIDSIDE,
- g_param_spec_boolean ("midside", "Midside", "Allow mid/side encoding",
- TRUE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("midside", "Midside", "Allow mid/side encoding",
+ TRUE, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_SHORTCTL,
- g_param_spec_enum ("shortctl", "Block type",
- "Block type encorcing",
- GST_TYPE_FAAC_SHORTCTL, MAIN, G_PARAM_READWRITE));
+ g_param_spec_enum ("shortctl", "Block type",
+ "Block type encorcing",
+ GST_TYPE_FAAC_SHORTCTL, MAIN, G_PARAM_READWRITE));
/* virtual functions */
gstelement_class->change_state = gst_faac_change_state;
}
static void
-gst_faac_init (GstFaac *faac)
+gst_faac_init (GstFaac * faac)
{
faac->handle = NULL;
faac->samplerate = -1;
GST_FLAG_SET (faac, GST_ELEMENT_EVENT_AWARE);
- faac->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&sink_template), "sink");
+ faac->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get (&sink_template),
+ "sink");
gst_element_add_pad (GST_ELEMENT (faac), faac->sinkpad);
gst_pad_set_chain_function (faac->sinkpad, gst_faac_chain);
gst_pad_set_link_function (faac->sinkpad, gst_faac_sinkconnect);
- faac->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&src_template), "src");
+ faac->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get (&src_template),
+ "src");
gst_element_add_pad (GST_ELEMENT (faac), faac->srcpad);
gst_pad_set_link_function (faac->srcpad, gst_faac_srcconnect);
}
static GstPadLinkReturn
-gst_faac_sinkconnect (GstPad *pad,
- const GstCaps *caps)
+gst_faac_sinkconnect (GstPad * pad, const GstCaps * caps)
{
GstFaac *faac = GST_FAAC (gst_pad_get_parent (pad));
GstStructure *structure = gst_caps_get_structure (caps, 0);
gst_structure_get_int (structure, "depth", &depth);
/* open a new handle to the encoder */
- if (!(handle = faacEncOpen (samplerate, channels,
- &samples, &bytes)))
+ if (!(handle = faacEncOpen (samplerate, channels, &samples, &bytes)))
return GST_PAD_LINK_REFUSED;
switch (depth) {
bps = 2;
break;
case 24:
- fmt = FAAC_INPUT_32BIT; /* 24-in-32, actually */
+ fmt = FAAC_INPUT_32BIT; /* 24-in-32, actually */
bps = 4;
break;
case 32:
- fmt = FAAC_INPUT_FLOAT; /* see template, this is right */
+ fmt = FAAC_INPUT_FLOAT; /* see template, this is right */
bps = 4;
break;
}
/* if the other side was already set-up, redo that */
if (GST_PAD_CAPS (faac->srcpad))
return gst_faac_srcconnect (faac->srcpad,
- gst_pad_get_allowed_caps (faac->srcpad));
+ gst_pad_get_allowed_caps (faac->srcpad));
/* else, that'll be done later */
return GST_PAD_LINK_OK;
}
static GstPadLinkReturn
-gst_faac_srcconnect (GstPad *pad,
- const GstCaps *caps)
+gst_faac_srcconnect (GstPad * pad, const GstCaps * caps)
{
GstFaac *faac = GST_FAAC (gst_pad_get_parent (pad));
gint n;
- if (!faac->handle ||
- (faac->samplerate == -1 || faac->channels == -1)) {
+ if (!faac->handle || (faac->samplerate == -1 || faac->channels == -1)) {
return GST_PAD_LINK_DELAYED;
}
/* we do samplerate/channels ourselves */
for (n = 0; n < gst_caps_get_size (caps); n++) {
GstStructure *structure = gst_caps_get_structure (caps, n);
+
gst_structure_remove_field (structure, "rate");
gst_structure_remove_field (structure, "channels");
}
* that (that the next element is filesink or any element
* that does want ADTS headers). */
- conf->outputFormat = 0; /* raw, no ADTS headers */
+ conf->outputFormat = 0; /* raw, no ADTS headers */
conf->shortctl = faac->shortctl;
if (!faacEncSetConfiguration (faac->handle, conf)) {
GST_WARNING ("Faac doesn't support the current conf");
}
newcaps = gst_caps_new_simple ("audio/mpeg",
- "mpegversion", G_TYPE_INT, mpegversion,
- "channels", G_TYPE_INT, faac->channels,
- "rate", G_TYPE_INT, faac->samplerate,
- NULL);
+ "mpegversion", G_TYPE_INT, mpegversion,
+ "channels", G_TYPE_INT, faac->channels,
+ "rate", G_TYPE_INT, faac->samplerate, NULL);
ret = gst_pad_try_set_caps (faac->srcpad, newcaps);
switch (ret) {
case GST_PAD_LINK_OK:
case GST_PAD_LINK_DONE:
- return GST_PAD_LINK_DONE;
+ return GST_PAD_LINK_DONE;
case GST_PAD_LINK_DELAYED:
- return GST_PAD_LINK_DELAYED;
+ return GST_PAD_LINK_DELAYED;
default:
- break;
+ break;
}
}
}
static void
-gst_faac_chain (GstPad *pad,
- GstData *data)
+gst_faac_chain (GstPad * pad, GstData * data)
{
GstFaac *faac = GST_FAAC (gst_pad_get_parent (pad));
GstBuffer *inbuf, *outbuf, *subbuf;
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS:
- /* flush first */
- while (1) {
- outbuf = gst_buffer_new_and_alloc (faac->bytes);
- if ((ret_size = faacEncEncode (faac->handle,
- NULL, 0,
- GST_BUFFER_DATA (outbuf),
- faac->bytes)) < 0) {
- GST_ELEMENT_ERROR (faac, LIBRARY, ENCODE, (NULL), (NULL));
- gst_event_unref (event);
- gst_buffer_unref (outbuf);
- return;
- }
-
- if (ret_size > 0) {
- GST_BUFFER_SIZE (outbuf) = ret_size;
- GST_BUFFER_TIMESTAMP (outbuf) = 0;
- GST_BUFFER_DURATION (outbuf) = 0;
- gst_pad_push (faac->srcpad, GST_DATA (outbuf));
- } else {
- break;
- }
- }
-
- gst_element_set_eos (GST_ELEMENT (faac));
- gst_pad_push (faac->srcpad, data);
- return;
+ /* flush first */
+ while (1) {
+ outbuf = gst_buffer_new_and_alloc (faac->bytes);
+ if ((ret_size = faacEncEncode (faac->handle,
+ NULL, 0, GST_BUFFER_DATA (outbuf), faac->bytes)) < 0) {
+ GST_ELEMENT_ERROR (faac, LIBRARY, ENCODE, (NULL), (NULL));
+ gst_event_unref (event);
+ gst_buffer_unref (outbuf);
+ return;
+ }
+
+ if (ret_size > 0) {
+ GST_BUFFER_SIZE (outbuf) = ret_size;
+ GST_BUFFER_TIMESTAMP (outbuf) = 0;
+ GST_BUFFER_DURATION (outbuf) = 0;
+ gst_pad_push (faac->srcpad, GST_DATA (outbuf));
+ } else {
+ break;
+ }
+ }
+
+ gst_element_set_eos (GST_ELEMENT (faac));
+ gst_pad_push (faac->srcpad, data);
+ return;
default:
gst_pad_event_default (pad, event);
- return;
+ return;
}
}
if (!faac->handle) {
GST_ELEMENT_ERROR (faac, CORE, NEGOTIATION, (NULL),
- ("format wasn't negotiated before chain function"));
+ ("format wasn't negotiated before chain function"));
gst_buffer_unref (inbuf);
return;
}
if (!GST_PAD_CAPS (faac->srcpad)) {
if (gst_faac_srcconnect (faac->srcpad,
- gst_pad_get_allowed_caps (faac->srcpad)) <= 0) {
+ gst_pad_get_allowed_caps (faac->srcpad)) <= 0) {
GST_ELEMENT_ERROR (faac, CORE, NEGOTIATION, (NULL),
- ("failed to negotiate MPEG/AAC format with next element"));
+ ("failed to negotiate MPEG/AAC format with next element"));
gst_buffer_unref (inbuf);
return;
}
if (in_size / faac->bps < faac->samples) {
if (in_size > size) {
GstBuffer *merge;
- /* this is panic! we got a buffer, but still don't have enough
- * data. Merge them and retry in the next cycle... */
- merge = gst_buffer_merge (faac->cache, inbuf);
+
+ /* this is panic! we got a buffer, but still don't have enough
+ * data. Merge them and retry in the next cycle... */
+ merge = gst_buffer_merge (faac->cache, inbuf);
gst_buffer_unref (faac->cache);
gst_buffer_unref (inbuf);
faac->cache = merge;
} else if (in_size == size) {
- /* this shouldn't happen, but still... */
- faac->cache = inbuf;
+ /* this shouldn't happen, but still... */
+ faac->cache = inbuf;
} else if (in_size > 0) {
- faac->cache = gst_buffer_create_sub (inbuf, size - in_size,
- in_size);
- GST_BUFFER_DURATION (faac->cache) =
- GST_BUFFER_DURATION (inbuf) * GST_BUFFER_SIZE (faac->cache) / size;
- GST_BUFFER_TIMESTAMP (faac->cache) =
- GST_BUFFER_TIMESTAMP (inbuf) + (GST_BUFFER_DURATION (inbuf) *
+ faac->cache = gst_buffer_create_sub (inbuf, size - in_size, in_size);
+ GST_BUFFER_DURATION (faac->cache) =
+ GST_BUFFER_DURATION (inbuf) * GST_BUFFER_SIZE (faac->cache) / size;
+ GST_BUFFER_TIMESTAMP (faac->cache) =
+ GST_BUFFER_TIMESTAMP (inbuf) + (GST_BUFFER_DURATION (inbuf) *
(size - in_size) / size);
- gst_buffer_unref (inbuf);
+ gst_buffer_unref (inbuf);
} else {
- gst_buffer_unref (inbuf);
+ gst_buffer_unref (inbuf);
}
-
+
return;
}
/* create the frame */
if (in_size > size) {
GstBuffer *merge;
+
/* merge */
subbuf = gst_buffer_create_sub (inbuf, 0, frame_size - (in_size - size));
GST_BUFFER_DURATION (subbuf) =
- GST_BUFFER_DURATION (inbuf) * GST_BUFFER_SIZE (subbuf) / size;
+ GST_BUFFER_DURATION (inbuf) * GST_BUFFER_SIZE (subbuf) / size;
merge = gst_buffer_merge (faac->cache, subbuf);
gst_buffer_unref (faac->cache);
gst_buffer_unref (subbuf);
} else {
subbuf = gst_buffer_create_sub (inbuf, size - in_size, frame_size);
GST_BUFFER_DURATION (subbuf) =
- GST_BUFFER_DURATION (inbuf) * GST_BUFFER_SIZE (subbuf) / size;
+ GST_BUFFER_DURATION (inbuf) * GST_BUFFER_SIZE (subbuf) / size;
GST_BUFFER_TIMESTAMP (subbuf) =
- GST_BUFFER_TIMESTAMP (inbuf) + (GST_BUFFER_DURATION (inbuf) *
+ GST_BUFFER_TIMESTAMP (inbuf) + (GST_BUFFER_DURATION (inbuf) *
(size - in_size) / size);
}
outbuf = gst_buffer_new_and_alloc (faac->bytes);
if ((ret_size = faacEncEncode (faac->handle,
- (gint32 *) GST_BUFFER_DATA (subbuf),
- GST_BUFFER_SIZE (subbuf) / faac->bps,
- GST_BUFFER_DATA (outbuf),
- faac->bytes)) < 0) {
+ (gint32 *) GST_BUFFER_DATA (subbuf),
+ GST_BUFFER_SIZE (subbuf) / faac->bps,
+ GST_BUFFER_DATA (outbuf), faac->bytes)) < 0) {
GST_ELEMENT_ERROR (faac, LIBRARY, ENCODE, (NULL), (NULL));
gst_buffer_unref (inbuf);
gst_buffer_unref (subbuf);
if (ret_size > 0) {
GST_BUFFER_SIZE (outbuf) = ret_size;
if (faac->cache_time != GST_CLOCK_TIME_NONE) {
- GST_BUFFER_TIMESTAMP (outbuf) = faac->cache_time;
- faac->cache_time = GST_CLOCK_TIME_NONE;
+ GST_BUFFER_TIMESTAMP (outbuf) = faac->cache_time;
+ faac->cache_time = GST_CLOCK_TIME_NONE;
} else
- GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (subbuf);
+ GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (subbuf);
GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (subbuf);
if (faac->cache_duration) {
- GST_BUFFER_DURATION (outbuf) += faac->cache_duration;
- faac->cache_duration = 0;
+ GST_BUFFER_DURATION (outbuf) += faac->cache_duration;
+ faac->cache_duration = 0;
}
gst_pad_push (faac->srcpad, GST_DATA (outbuf));
} else {
gst_buffer_unref (outbuf);
if (faac->cache_time != GST_CLOCK_TIME_NONE)
- faac->cache_time = GST_BUFFER_TIMESTAMP (subbuf);
+ faac->cache_time = GST_BUFFER_TIMESTAMP (subbuf);
faac->cache_duration += GST_BUFFER_DURATION (subbuf);
}
}
static void
-gst_faac_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+gst_faac_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec)
{
GstFaac *faac = GST_FAAC (object);
}
static void
-gst_faac_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+gst_faac_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec)
{
GstFaac *faac = GST_FAAC (object);
}
static GstElementStateReturn
-gst_faac_change_state (GstElement *element)
+gst_faac_change_state (GstElement * element)
{
GstFaac *faac = GST_FAAC (element);
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_PAUSED_TO_READY:
if (faac->handle) {
- faacEncClose (faac->handle);
- faac->handle = NULL;
+ faacEncClose (faac->handle);
+ faac->handle = NULL;
}
if (faac->cache) {
- gst_buffer_unref (faac->cache);
- faac->cache = NULL;
+ gst_buffer_unref (faac->cache);
+ faac->cache = NULL;
}
faac->cache_time = GST_CLOCK_TIME_NONE;
faac->cache_duration = 0;
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- return gst_element_register (plugin, "faac",
- GST_RANK_NONE,
- GST_TYPE_FAAC);
+ return gst_element_register (plugin, "faac", GST_RANK_NONE, GST_TYPE_FAAC);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "faac",
- "Free AAC Encoder (FAAC)",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "faac",
+ "Free AAC Encoder (FAAC)",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
#include <faac.h>
G_BEGIN_DECLS
-
#define GST_TYPE_FAAC \
(gst_faac_get_type ())
#define GST_FAAC(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_FAAC))
#define GST_IS_FAAC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_FAAC))
-
-typedef struct _GstFaac {
+ typedef struct _GstFaac
+{
GstElement element;
/* pads */
GstPad *srcpad, *sinkpad;
/* stream properties */
- gint samplerate,
- channels,
- format,
- bps,
- bitrate,
- profile,
- shortctl;
- gboolean tns,
- midside;
- gulong bytes,
- samples;
+ gint samplerate, channels, format, bps, bitrate, profile, shortctl;
+ gboolean tns, midside;
+ gulong bytes, samples;
/* FAAC object */
faacEncHandle handle;
guint64 cache_time, cache_duration;
} GstFaac;
-typedef struct _GstFaacClass {
+typedef struct _GstFaacClass
+{
GstElementClass parent_class;
} GstFaacClass;
GType gst_faac_get_type (void);
G_END_DECLS
-
#endif /* __GST_FAAC_H__ */
#include "gstfaad.h"
-GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/mpeg, "
- "systemstream = (bool) FALSE, "
- "mpegversion = { (int) 2, (int) 4 }"
- )
-);
-
-GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-raw-int, "
- "endianness = (int) BYTE_ORDER, "
- "signed = (bool) TRUE, "
- "width = (int) { 16, 24, 32 }, "
- "depth = (int) { 16, 24, 32 }, "
- "rate = (int) [ 8000, 96000 ], "
- "channels = (int) [ 1, 6 ]; "
- "audio/x-raw-float, "
- "endianness = (int) BYTE_ORDER, "
- "depth = (int) { 32, 64 }, "
- "rate = (int) [ 8000, 96000 ], "
- "channels = (int) [ 1, 6 ]"
- )
-);
-
-static void gst_faad_base_init (GstFaadClass *klass);
-static void gst_faad_class_init (GstFaadClass *klass);
-static void gst_faad_init (GstFaad *faad);
+GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/mpeg, "
+ "systemstream = (bool) FALSE, " "mpegversion = { (int) 2, (int) 4 }")
+ );
+
+GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "endianness = (int) BYTE_ORDER, "
+ "signed = (bool) TRUE, "
+ "width = (int) { 16, 24, 32 }, "
+ "depth = (int) { 16, 24, 32 }, "
+ "rate = (int) [ 8000, 96000 ], "
+ "channels = (int) [ 1, 6 ]; "
+ "audio/x-raw-float, "
+ "endianness = (int) BYTE_ORDER, "
+ "depth = (int) { 32, 64 }, "
+ "rate = (int) [ 8000, 96000 ], " "channels = (int) [ 1, 6 ]")
+ );
+
+static void gst_faad_base_init (GstFaadClass * klass);
+static void gst_faad_class_init (GstFaadClass * klass);
+static void gst_faad_init (GstFaad * faad);
static GstPadLinkReturn
- gst_faad_sinkconnect (GstPad *pad,
- const GstCaps *caps);
+gst_faad_sinkconnect (GstPad * pad, const GstCaps * caps);
static GstPadLinkReturn
- gst_faad_srcconnect (GstPad *pad,
- const GstCaps *caps);
-static GstCaps *gst_faad_srcgetcaps (GstPad *pad);
-static void gst_faad_chain (GstPad *pad,
- GstData *data);
-static GstElementStateReturn
- gst_faad_change_state (GstElement *element);
+gst_faad_srcconnect (GstPad * pad, const GstCaps * caps);
+static GstCaps *gst_faad_srcgetcaps (GstPad * pad);
+static void gst_faad_chain (GstPad * pad, GstData * data);
+static GstElementStateReturn gst_faad_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
+
/* static guint gst_faad_signals[LAST_SIGNAL] = { 0 }; */
GType
if (!gst_faad_type) {
static const GTypeInfo gst_faad_info = {
- sizeof (GstFaadClass),
+ sizeof (GstFaadClass),
(GBaseInitFunc) gst_faad_base_init,
NULL,
(GClassInitFunc) gst_faad_class_init,
NULL,
NULL,
- sizeof(GstFaad),
+ sizeof (GstFaad),
0,
(GInstanceInitFunc) gst_faad_init,
};
gst_faad_type = g_type_register_static (GST_TYPE_ELEMENT,
- "GstFaad",
- &gst_faad_info, 0);
+ "GstFaad", &gst_faad_info, 0);
}
return gst_faad_type;
}
static void
-gst_faad_base_init (GstFaadClass *klass)
+gst_faad_base_init (GstFaadClass * klass)
{
GstElementDetails gst_faad_details = {
"Free AAC Decoder (FAAD)",
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&src_template));
+ gst_static_pad_template_get (&src_template));
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&sink_template));
+ gst_static_pad_template_get (&sink_template));
gst_element_class_set_details (element_class, &gst_faad_details);
}
static void
-gst_faad_class_init (GstFaadClass *klass)
+gst_faad_class_init (GstFaadClass * klass)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
}
static void
-gst_faad_init (GstFaad *faad)
+gst_faad_init (GstFaad * faad)
{
faad->handle = NULL;
faad->samplerate = -1;
GST_FLAG_SET (faad, GST_ELEMENT_EVENT_AWARE);
- faad->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&sink_template), "sink");
+ faad->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get (&sink_template),
+ "sink");
gst_element_add_pad (GST_ELEMENT (faad), faad->sinkpad);
gst_pad_set_chain_function (faad->sinkpad, gst_faad_chain);
gst_pad_set_link_function (faad->sinkpad, gst_faad_sinkconnect);
- faad->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&src_template), "src");
+ faad->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get (&src_template),
+ "src");
gst_element_add_pad (GST_ELEMENT (faad), faad->srcpad);
gst_pad_set_link_function (faad->srcpad, gst_faad_srcconnect);
}
static GstPadLinkReturn
-gst_faad_sinkconnect (GstPad *pad,
- const GstCaps *caps)
+gst_faad_sinkconnect (GstPad * pad, const GstCaps * caps)
{
/* oh, we really don't care what's in here. We'll
* get AAC audio (MPEG-2/4) anyway, so why bother? */
}
static GstCaps *
-gst_faad_srcgetcaps (GstPad *pad)
+gst_faad_srcgetcaps (GstPad * pad)
{
GstFaad *faad = GST_FAAD (gst_pad_get_parent (pad));
- if (faad->handle != NULL &&
- faad->channels != -1 && faad->samplerate != -1) {
+ if (faad->handle != NULL && faad->channels != -1 && faad->samplerate != -1) {
GstCaps *caps = gst_caps_new_empty ();
GstStructure *str;
gint fmt[] = {
FAAD_FMT_FLOAT,
FAAD_FMT_DOUBLE,
-1
- }, n;
+ }
+ , n;
for (n = 0; fmt[n] != -1; n++) {
switch (n) {
- case FAAD_FMT_16BIT:
- str = gst_structure_new ("audio/x-raw-int",
- "signed", G_TYPE_BOOLEAN, TRUE,
- "width", G_TYPE_INT, 16,
- "depth", G_TYPE_INT, 16,
- NULL);
- break;
- case FAAD_FMT_24BIT:
- str = gst_structure_new ("audio/x-raw-int",
- "signed", G_TYPE_BOOLEAN, TRUE,
- "width", G_TYPE_INT, 24,
- "depth", G_TYPE_INT, 24,
- NULL);
- break;
- case FAAD_FMT_32BIT:
- str = gst_structure_new ("audio/x-raw-int",
- "signed", G_TYPE_BOOLEAN, TRUE,
- "width", G_TYPE_INT, 32,
- "depth", G_TYPE_INT, 32,
- NULL);
- break;
- case FAAD_FMT_FLOAT:
- str = gst_structure_new ("audio/x-raw-float",
- "depth", G_TYPE_INT, 32,
- NULL);
- break;
- case FAAD_FMT_DOUBLE:
- str = gst_structure_new ("audio/x-raw-float",
- "depth", G_TYPE_INT, 64,
- NULL);
- break;
- default:
- str = NULL;
- break;
+ case FAAD_FMT_16BIT:
+ str = gst_structure_new ("audio/x-raw-int",
+ "signed", G_TYPE_BOOLEAN, TRUE,
+ "width", G_TYPE_INT, 16, "depth", G_TYPE_INT, 16, NULL);
+ break;
+ case FAAD_FMT_24BIT:
+ str = gst_structure_new ("audio/x-raw-int",
+ "signed", G_TYPE_BOOLEAN, TRUE,
+ "width", G_TYPE_INT, 24, "depth", G_TYPE_INT, 24, NULL);
+ break;
+ case FAAD_FMT_32BIT:
+ str = gst_structure_new ("audio/x-raw-int",
+ "signed", G_TYPE_BOOLEAN, TRUE,
+ "width", G_TYPE_INT, 32, "depth", G_TYPE_INT, 32, NULL);
+ break;
+ case FAAD_FMT_FLOAT:
+ str = gst_structure_new ("audio/x-raw-float",
+ "depth", G_TYPE_INT, 32, NULL);
+ break;
+ case FAAD_FMT_DOUBLE:
+ str = gst_structure_new ("audio/x-raw-float",
+ "depth", G_TYPE_INT, 64, NULL);
+ break;
+ default:
+ str = NULL;
+ break;
}
if (!str)
- continue;
+ continue;
if (faad->samplerate != -1) {
- gst_structure_set (str,
- "rate", G_TYPE_INT, faad->samplerate,
- NULL);
+ gst_structure_set (str, "rate", G_TYPE_INT, faad->samplerate, NULL);
} else {
- gst_structure_set (str,
- "rate", GST_TYPE_INT_RANGE, 8000, 96000,
- NULL);
+ gst_structure_set (str, "rate", GST_TYPE_INT_RANGE, 8000, 96000, NULL);
}
if (faad->channels != -1) {
- gst_structure_set (str,
- "channels", G_TYPE_INT, faad->channels,
- NULL);
+ gst_structure_set (str, "channels", G_TYPE_INT, faad->channels, NULL);
} else {
- gst_structure_set (str,
- "channels", GST_TYPE_INT_RANGE, 1, 6,
- NULL);
+ gst_structure_set (str, "channels", GST_TYPE_INT_RANGE, 1, 6, NULL);
}
- gst_structure_set (str,
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- NULL);
+ gst_structure_set (str, "endianness", G_TYPE_INT, G_BYTE_ORDER, NULL);
gst_caps_append_structure (caps, str);
}
}
static GstPadLinkReturn
-gst_faad_srcconnect (GstPad *pad,
- const GstCaps *caps)
+gst_faad_srcconnect (GstPad * pad, const GstCaps * caps)
{
GstStructure *structure;
const gchar *mimetype;
gint depth, rate, channels;
GstFaad *faad = GST_FAAD (gst_pad_get_parent (pad));
- if (!faad->handle ||
- (faad->samplerate == -1 || faad->channels == -1)) {
+ if (!faad->handle || (faad->samplerate == -1 || faad->channels == -1)) {
return GST_PAD_LINK_DELAYED;
}
rate != faad->samplerate || channels != faad->channels) {
return GST_PAD_LINK_REFUSED;
}
-
+
if (!strcmp (mimetype, "audio/x-raw-int")) {
gint width;
break;
case 64:
fmt = FAAD_FMT_DOUBLE;
- break;
+ break;
}
}
}
static void
-gst_faad_chain (GstPad *pad,
- GstData *data)
+gst_faad_chain (GstPad * pad, GstData * data)
{
GstFaad *faad = GST_FAAD (gst_pad_get_parent (pad));
GstBuffer *buf, *outbuf;
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS:
- gst_element_set_eos (GST_ELEMENT (faad));
- gst_pad_push (faad->srcpad, data);
- return;
+ gst_element_set_eos (GST_ELEMENT (faad));
+ gst_pad_push (faad->srcpad, data);
+ return;
default:
gst_pad_event_default (pad, event);
- return;
+ return;
}
}
guchar channels;
faacDecInit (faad->handle,
- GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf),
- &samplerate, &channels);
+ GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf), &samplerate, &channels);
faad->samplerate = samplerate;
faad->channels = channels;
ret = gst_pad_renegotiate (faad->srcpad);
}
out = faacDecDecode (faad->handle, &info,
- GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
+ GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
if (info.error) {
GST_ELEMENT_ERROR (faad, STREAM, DECODE, (NULL),
- ("Failed to decode buffer: %s",
- faacDecGetErrorMessage (info.error)));
+ ("Failed to decode buffer: %s", faacDecGetErrorMessage (info.error)));
gst_buffer_unref (buf);
return;
}
- if (info.samplerate != faad->samplerate ||
- info.channels != faad->channels) {
+ if (info.samplerate != faad->samplerate || info.channels != faad->channels) {
GstPadLinkReturn ret;
faad->samplerate = info.samplerate;
}
static GstElementStateReturn
-gst_faad_change_state (GstElement *element)
+gst_faad_change_state (GstElement * element)
{
GstFaad *faad = GST_FAAD (element);
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY:
if (!(faad->handle = faacDecOpen ()))
- return GST_STATE_FAILURE;
+ return GST_STATE_FAILURE;
else {
- faacDecConfiguration *conf;
+ faacDecConfiguration *conf;
- conf = faacDecGetCurrentConfiguration (faad->handle);
- conf->defObjectType = LC;
- faacDecSetConfiguration (faad->handle, conf);
+ conf = faacDecGetCurrentConfiguration (faad->handle);
+ conf->defObjectType = LC;
+ faacDecSetConfiguration (faad->handle, conf);
}
break;
case GST_STATE_PAUSED_TO_READY:
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- return gst_element_register (plugin, "faad",
- GST_RANK_PRIMARY,
- GST_TYPE_FAAD);
+ return gst_element_register (plugin, "faad", GST_RANK_PRIMARY, GST_TYPE_FAAD);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "faad",
- "Free AAC Decoder (FAAD)",
- plugin_init,
- VERSION,
- "GPL",
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "faad",
+ "Free AAC Decoder (FAAD)",
+ plugin_init, VERSION, "GPL", GST_PACKAGE, GST_ORIGIN)
#include <faad.h>
G_BEGIN_DECLS
-
#define GST_TYPE_FAAD \
(gst_faad_get_type ())
#define GST_FAAD(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_FAAD))
#define GST_IS_FAAD_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_FAAD))
-
-typedef struct _GstFaad {
+ typedef struct _GstFaad
+{
GstElement element;
/* pads */
GstPad *srcpad, *sinkpad;
/* cache for latest MPEG-frame */
- gint samplerate,
- channels,
- bps;
+ gint samplerate, channels, bps;
/* FAAD object */
faacDecHandle handle;
} GstFaad;
-typedef struct _GstFaadClass {
+typedef struct _GstFaadClass
+{
GstElementClass parent_class;
} GstFaadClass;
GType gst_faad_get_type (void);
G_END_DECLS
-
#endif /* __GST_FAAD_H__ */
#include "gstgsmenc.h"
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
if (!gst_element_register (plugin, "gsmenc", GST_RANK_NONE, GST_TYPE_GSMENC))
return FALSE;
- if (!gst_element_register (plugin, "gsmdec", GST_RANK_PRIMARY, GST_TYPE_GSMDEC))
+ if (!gst_element_register (plugin, "gsmdec", GST_RANK_PRIMARY,
+ GST_TYPE_GSMDEC))
return FALSE;
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "gsm",
- "GSM Elements Plugin",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "gsm",
+ "GSM Elements Plugin",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
};
/* GSMDec signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
/* FILL ME */
};
-static void gst_gsmdec_base_init (gpointer g_class);
-static void gst_gsmdec_class_init (GstGSMDec *klass);
-static void gst_gsmdec_init (GstGSMDec *gsmdec);
+static void gst_gsmdec_base_init (gpointer g_class);
+static void gst_gsmdec_class_init (GstGSMDec * klass);
+static void gst_gsmdec_init (GstGSMDec * gsmdec);
-static void gst_gsmdec_chain (GstPad *pad, GstData *_data);
-static GstPadLinkReturn gst_gsmdec_sinkconnect (GstPad *pad, const GstCaps *caps);
+static void gst_gsmdec_chain (GstPad * pad, GstData * _data);
+static GstPadLinkReturn gst_gsmdec_sinkconnect (GstPad * pad,
+ const GstCaps * caps);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_gsmdec_signals[LAST_SIGNAL] = { 0 }; */
GType
-gst_gsmdec_get_type(void) {
+gst_gsmdec_get_type (void)
+{
static GType gsmdec_type = 0;
if (!gsmdec_type) {
static const GTypeInfo gsmdec_info = {
- sizeof(GstGSMDecClass),
+ sizeof (GstGSMDecClass),
gst_gsmdec_base_init,
NULL,
- (GClassInitFunc)gst_gsmdec_class_init,
+ (GClassInitFunc) gst_gsmdec_class_init,
NULL,
NULL,
- sizeof(GstGSMDec),
+ sizeof (GstGSMDec),
0,
- (GInstanceInitFunc)gst_gsmdec_init,
+ (GInstanceInitFunc) gst_gsmdec_init,
};
- gsmdec_type = g_type_register_static(GST_TYPE_ELEMENT, "GstGSMDec", &gsmdec_info, 0);
+ gsmdec_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstGSMDec", &gsmdec_info, 0);
}
return gsmdec_type;
}
static GstStaticPadTemplate gsmdec_sink_template =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
+GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "audio/x-gsm, "
- "rate = (int) [ 1000, 48000 ], "
- "channels = (int) 1"
- )
-);
+ GST_STATIC_CAPS ("audio/x-gsm, "
+ "rate = (int) [ 1000, 48000 ], " "channels = (int) 1")
+ );
static GstStaticPadTemplate gsmdec_src_template =
-GST_STATIC_PAD_TEMPLATE (
- "src",
+GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "audio/x-raw-int, "
- "endianness = (int) BYTE_ORDER, "
- "signed = (boolean) true, "
- "width = (int) 16, "
- "depth = (int) 16, "
- "rate = (int) [ 1000, 48000 ], "
- "channels = (int) 1"
- )
-);
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "endianness = (int) BYTE_ORDER, "
+ "signed = (boolean) true, "
+ "width = (int) 16, "
+ "depth = (int) 16, "
+ "rate = (int) [ 1000, 48000 ], " "channels = (int) 1")
+ );
static void
gst_gsmdec_base_init (gpointer g_class)
}
static void
-gst_gsmdec_class_init (GstGSMDec *klass)
+gst_gsmdec_class_init (GstGSMDec * klass)
{
GstElementClass *gstelement_class;
- gstelement_class = (GstElementClass*)klass;
+ gstelement_class = (GstElementClass *) klass;
- parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
+ parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
}
static void
-gst_gsmdec_init (GstGSMDec *gsmdec)
+gst_gsmdec_init (GstGSMDec * gsmdec)
{
GST_DEBUG ("gst_gsmdec_init: initializing");
/* create the sink and src pads */
- gsmdec->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&gsmdec_sink_template), "sink");
+ gsmdec->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gsmdec_sink_template), "sink");
gst_element_add_pad (GST_ELEMENT (gsmdec), gsmdec->sinkpad);
gst_pad_set_chain_function (gsmdec->sinkpad, gst_gsmdec_chain);
gst_pad_set_link_function (gsmdec->sinkpad, gst_gsmdec_sinkconnect);
- gsmdec->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&gsmdec_src_template), "src");
+ gsmdec->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gsmdec_src_template), "src");
gst_element_add_pad (GST_ELEMENT (gsmdec), gsmdec->srcpad);
gsmdec->state = gsm_create ();
}
static GstPadLinkReturn
-gst_gsmdec_sinkconnect (GstPad *pad, const GstCaps *caps)
+gst_gsmdec_sinkconnect (GstPad * pad, const GstCaps * caps)
{
GstGSMDec *gsmdec;
gint rate;
GstStructure *structure;
-
+
gsmdec = GST_GSMDEC (gst_pad_get_parent (pad));
structure = gst_caps_get_structure (caps, 0);
- gst_structure_get_int (structure, "rate", &rate);
-
- if (gst_pad_try_set_caps (gsmdec->srcpad,
- 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", G_TYPE_INT, rate,
- "channels", G_TYPE_INT, 1,
- NULL)) > 0)
- {
+ gst_structure_get_int (structure, "rate", &rate);
+
+ if (gst_pad_try_set_caps (gsmdec->srcpad,
+ 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", G_TYPE_INT, rate, "channels", G_TYPE_INT, 1, NULL)) > 0) {
return GST_PAD_LINK_OK;
}
return GST_PAD_LINK_REFUSED;
}
static void
-gst_gsmdec_chain (GstPad *pad, GstData *_data)
+gst_gsmdec_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstGSMDec *gsmdec;
gsm_byte *data;
guint size;
- g_return_if_fail(pad != NULL);
- g_return_if_fail(GST_IS_PAD(pad));
- g_return_if_fail(buf != NULL);
+ g_return_if_fail (pad != NULL);
+ g_return_if_fail (GST_IS_PAD (pad));
+ g_return_if_fail (buf != NULL);
/*g_return_if_fail(GST_IS_BUFFER(buf)); */
gsmdec = GST_GSMDEC (gst_pad_get_parent (pad));
- data = (gsm_byte*) GST_BUFFER_DATA (buf);
+ data = (gsm_byte *) GST_BUFFER_DATA (buf);
size = GST_BUFFER_SIZE (buf);
if (gsmdec->bufsize && (gsmdec->bufsize + size >= 33)) {
GstBuffer *outbuf;
- memcpy (gsmdec->buffer + gsmdec->bufsize, data, (33 - gsmdec->bufsize) * sizeof (gsm_byte));
+ memcpy (gsmdec->buffer + gsmdec->bufsize, data,
+ (33 - gsmdec->bufsize) * sizeof (gsm_byte));
outbuf = gst_buffer_new ();
GST_BUFFER_DATA (outbuf) = g_malloc (160 * sizeof (gsm_signal));
GST_BUFFER_SIZE (outbuf) = 160 * sizeof (gsm_signal);
- gsm_decode (gsmdec->state, gsmdec->buffer, (gsm_signal *) GST_BUFFER_DATA (outbuf));
+ gsm_decode (gsmdec->state, gsmdec->buffer,
+ (gsm_signal *) GST_BUFFER_DATA (outbuf));
gst_pad_push (gsmdec->srcpad, GST_DATA (outbuf));
outbuf = gst_buffer_new ();
GST_BUFFER_DATA (outbuf) = g_malloc (160 * sizeof (gsm_signal));
GST_BUFFER_SIZE (outbuf) = 160 * sizeof (gsm_signal);
-
- gsm_decode (gsmdec->state, data, (gsm_signal *)GST_BUFFER_DATA (outbuf));
+
+ gsm_decode (gsmdec->state, data, (gsm_signal *) GST_BUFFER_DATA (outbuf));
gst_pad_push (gsmdec->srcpad, GST_DATA (outbuf));
gsmdec->bufsize += size;
}
- gst_buffer_unref(buf);
+ gst_buffer_unref (buf);
}
-
#endif
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_GSMDEC \
#define GST_IS_GSMDEC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GSMDEC))
-typedef struct _GstGSMDec GstGSMDec;
-typedef struct _GstGSMDecClass GstGSMDecClass;
+ typedef struct _GstGSMDec GstGSMDec;
+ typedef struct _GstGSMDecClass GstGSMDecClass;
-struct _GstGSMDec {
- GstElement element;
+ struct _GstGSMDec
+ {
+ GstElement element;
- /* pads */
- GstPad *sinkpad,*srcpad;
+ /* pads */
+ GstPad *sinkpad, *srcpad;
- gsm state;
- gsm_byte buffer[33];
- gint bufsize;
-};
+ gsm state;
+ gsm_byte buffer[33];
+ gint bufsize;
+ };
-struct _GstGSMDecClass {
- GstElementClass parent_class;
-};
+ struct _GstGSMDecClass
+ {
+ GstElementClass parent_class;
+ };
-GType gst_gsmdec_get_type(void);
+ GType gst_gsmdec_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_GSMDEC_H__ */
+#endif /* __GST_GSMDEC_H__ */
};
/* GSMEnc signals and args */
-enum {
+enum
+{
FRAME_ENCODED,
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
/* FILL ME */
};
-static void gst_gsmenc_base_init (gpointer g_class);
-static void gst_gsmenc_class_init (GstGSMEnc *klass);
-static void gst_gsmenc_init (GstGSMEnc *gsmenc);
+static void gst_gsmenc_base_init (gpointer g_class);
+static void gst_gsmenc_class_init (GstGSMEnc * klass);
+static void gst_gsmenc_init (GstGSMEnc * gsmenc);
-static void gst_gsmenc_chain (GstPad *pad,GstData *_data);
-static GstPadLinkReturn gst_gsmenc_sinkconnect (GstPad *pad, const GstCaps *caps);
+static void gst_gsmenc_chain (GstPad * pad, GstData * _data);
+static GstPadLinkReturn gst_gsmenc_sinkconnect (GstPad * pad,
+ const GstCaps * caps);
static GstElementClass *parent_class = NULL;
static guint gst_gsmenc_signals[LAST_SIGNAL] = { 0 };
if (!gsmenc_type) {
static const GTypeInfo gsmenc_info = {
sizeof (GstGSMEncClass),
- gst_gsmenc_base_init,
+ gst_gsmenc_base_init,
NULL,
(GClassInitFunc) gst_gsmenc_class_init,
NULL,
0,
(GInstanceInitFunc) gst_gsmenc_init,
};
- gsmenc_type = g_type_register_static (GST_TYPE_ELEMENT, "GstGSMEnc", &gsmenc_info, 0);
+ gsmenc_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstGSMEnc", &gsmenc_info, 0);
}
return gsmenc_type;
}
static GstStaticPadTemplate gsmenc_src_template =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "audio/x-gsm, "
- "rate = (int) [ 1000, 48000 ], "
- "channels = (int) 1"
- )
-);
+GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-gsm, "
+ "rate = (int) [ 1000, 48000 ], " "channels = (int) 1")
+ );
static GstStaticPadTemplate gsmenc_sink_template =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "audio/x-raw-int, "
- "endianness = (int) BYTE_ORDER, "
- "signed = (boolean) true, "
- "width = (int) 16, "
- "depth = (int) 16, "
- "rate = (int) [ 1000, 48000 ], "
- "channels = (int) 1"
- )
-);
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "endianness = (int) BYTE_ORDER, "
+ "signed = (boolean) true, "
+ "width = (int) 16, "
+ "depth = (int) 16, "
+ "rate = (int) [ 1000, 48000 ], " "channels = (int) 1")
+ );
static void
gst_gsmenc_base_init (gpointer g_class)
gst_static_pad_template_get (&gsmenc_src_template));
gst_element_class_set_details (element_class, &gst_gsmenc_details);
}
-
+
static void
-gst_gsmenc_class_init (GstGSMEnc *klass)
+gst_gsmenc_class_init (GstGSMEnc * 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);
gst_gsmenc_signals[FRAME_ENCODED] =
- g_signal_new ("frame-encoded", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstGSMEncClass, frame_encoded), NULL, NULL,
- g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("frame-encoded", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstGSMEncClass, frame_encoded), NULL,
+ NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}
static void
-gst_gsmenc_init (GstGSMEnc *gsmenc)
+gst_gsmenc_init (GstGSMEnc * gsmenc)
{
/* create the sink and src pads */
- gsmenc->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&gsmenc_sink_template), "sink");
+ gsmenc->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gsmenc_sink_template), "sink");
gst_element_add_pad (GST_ELEMENT (gsmenc), gsmenc->sinkpad);
gst_pad_set_chain_function (gsmenc->sinkpad, gst_gsmenc_chain);
gst_pad_set_link_function (gsmenc->sinkpad, gst_gsmenc_sinkconnect);
- gsmenc->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&gsmenc_src_template), "src");
+ gsmenc->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gsmenc_src_template), "src");
gst_element_add_pad (GST_ELEMENT (gsmenc), gsmenc->srcpad);
gsmenc->state = gsm_create ();
}
static GstPadLinkReturn
-gst_gsmenc_sinkconnect (GstPad *pad, const GstCaps *caps)
+gst_gsmenc_sinkconnect (GstPad * pad, const GstCaps * caps)
{
GstGSMEnc *gsmenc;
GstStructure *structure;
gsmenc = GST_GSMENC (gst_pad_get_parent (pad));
structure = gst_caps_get_structure (caps, 0);
- gst_structure_get_int (structure, "rate", &gsmenc->rate);
+ gst_structure_get_int (structure, "rate", &gsmenc->rate);
if (gst_pad_try_set_caps (gsmenc->srcpad,
- gst_caps_new_simple("audio/x-gsm",
- "rate", G_TYPE_INT, gsmenc->rate,
- "channels", G_TYPE_INT, 1,
- NULL)) > 0)
- {
+ gst_caps_new_simple ("audio/x-gsm",
+ "rate", G_TYPE_INT, gsmenc->rate,
+ "channels", G_TYPE_INT, 1, NULL)) > 0) {
return GST_PAD_LINK_OK;
}
return GST_PAD_LINK_REFUSED;
}
static void
-gst_gsmenc_chain (GstPad *pad, GstData *_data)
+gst_gsmenc_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstGSMEnc *gsmenc;
g_return_if_fail (buf != NULL);
gsmenc = GST_GSMENC (GST_OBJECT_PARENT (pad));
-
- data = (gsm_signal*) GST_BUFFER_DATA (buf);
+
+ data = (gsm_signal *) GST_BUFFER_DATA (buf);
size = GST_BUFFER_SIZE (buf) / sizeof (gsm_signal);
if (gsmenc->bufsize && (gsmenc->bufsize + size >= 160)) {
GstBuffer *outbuf;
- memcpy (gsmenc->buffer + gsmenc->bufsize, data, (160 - gsmenc->bufsize) * sizeof (gsm_signal));
+ memcpy (gsmenc->buffer + gsmenc->bufsize, data,
+ (160 - gsmenc->bufsize) * sizeof (gsm_signal));
outbuf = gst_buffer_new ();
GST_BUFFER_DATA (outbuf) = g_malloc (33 * sizeof (gsm_byte));
GST_BUFFER_SIZE (outbuf) = 33 * sizeof (gsm_byte);
- gsm_encode (gsmenc->state, gsmenc->buffer, (gsm_byte *) GST_BUFFER_DATA (outbuf));
+ gsm_encode (gsmenc->state, gsmenc->buffer,
+ (gsm_byte *) GST_BUFFER_DATA (outbuf));
GST_BUFFER_TIMESTAMP (outbuf) = gsmenc->next_ts;
gst_pad_push (gsmenc->srcpad, GST_DATA (outbuf));
gsmenc->next_ts += (160.0 / gsmenc->rate) * 1000000;
- size -= (160 - gsmenc->bufsize);
+ size -= (160 - gsmenc->bufsize);
data += (160 - gsmenc->bufsize);
gsmenc->bufsize = 0;
}
gsmenc->bufsize += size;
}
- gst_buffer_unref(buf);
+ gst_buffer_unref (buf);
}
#endif
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_GSMENC \
#define GST_IS_GSMENC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GSMENC))
-typedef struct _GstGSMEnc GstGSMEnc;
-typedef struct _GstGSMEncClass GstGSMEncClass;
+ typedef struct _GstGSMEnc GstGSMEnc;
+ typedef struct _GstGSMEncClass GstGSMEncClass;
-struct _GstGSMEnc {
- GstElement element;
+ struct _GstGSMEnc
+ {
+ GstElement element;
- /* pads */
- GstPad *sinkpad,*srcpad;
+ /* pads */
+ GstPad *sinkpad, *srcpad;
- gsm state;
- gsm_signal buffer[160];
- gint bufsize;
+ gsm state;
+ gsm_signal buffer[160];
+ gint bufsize;
- guint64 next_ts;
- gint rate;
-};
+ guint64 next_ts;
+ gint rate;
+ };
-struct _GstGSMEncClass {
- GstElementClass parent_class;
+ struct _GstGSMEncClass
+ {
+ GstElementClass parent_class;
- /* signals */
- void (*frame_encoded) (GstElement *element);
-};
+ /* signals */
+ void (*frame_encoded) (GstElement * element);
+ };
-GType gst_gsmenc_get_type(void);
+ GType gst_gsmenc_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_GSMENC_H__ */
+#endif /* __GST_GSMENC_H__ */
typedef struct _GstHermesColorspace GstHermesColorspace;
typedef struct _GstHermesColorspaceClass GstHermesColorspaceClass;
-typedef enum {
+typedef enum
+{
GST_HERMES_COLORSPACE_NONE,
GST_HERMES_COLORSPACE_HERMES,
GST_HERMES_COLORSPACE_YUV_RGB,
GST_HERMES_COLORSPACE_420_SWAP,
} GstColorSpaceConverterType;
-struct _GstHermesColorspace {
+struct _GstHermesColorspace
+{
GstElement element;
- GstPad *sinkpad,*srcpad;
+ GstPad *sinkpad, *srcpad;
HermesHandle h_handle;
HermesFormat sink_format;
int src_size;
int sink_size;
-
+
int src_stride;
int sink_stride;
gboolean passthru;
};
-struct _GstHermesColorspaceClass {
+struct _GstHermesColorspaceClass
+{
GstElementClass parent_class;
};
-GType gst_hermes_colorspace_get_type(void);
+GType gst_hermes_colorspace_get_type (void);
-typedef struct _GstHermesColorspaceFormat {
+typedef struct _GstHermesColorspaceFormat
+{
GstStaticCaps caps;
} GstHermesColorspaceFormat;
static GstHermesColorspaceFormat gst_hermes_colorspace_formats[] = {
- { GST_STATIC_CAPS (GST_VIDEO_CAPS_xRGB) },
- { GST_STATIC_CAPS (GST_VIDEO_CAPS_RGBx) },
- { GST_STATIC_CAPS (GST_VIDEO_CAPS_BGRx) },
- { GST_STATIC_CAPS (GST_VIDEO_CAPS_xBGR) },
- { GST_STATIC_CAPS (GST_VIDEO_CAPS_BGR) },
- { GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB) },
- { GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB_15) },
- { GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB_16) },
+ {GST_STATIC_CAPS (GST_VIDEO_CAPS_xRGB)},
+ {GST_STATIC_CAPS (GST_VIDEO_CAPS_RGBx)},
+ {GST_STATIC_CAPS (GST_VIDEO_CAPS_BGRx)},
+ {GST_STATIC_CAPS (GST_VIDEO_CAPS_xBGR)},
+ {GST_STATIC_CAPS (GST_VIDEO_CAPS_BGR)},
+ {GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB)},
+ {GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB_15)},
+ {GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB_16)},
};
static GstElementDetails colorspace_details = {
/* Stereo signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_SOURCE,
ARG_DEST,
};
-static void gst_hermes_colorspace_base_init (gpointer g_class);
-static void gst_hermes_colorspace_class_init (GstHermesColorspaceClass *klass);
-static void gst_hermes_colorspace_init (GstHermesColorspace *space);
+static void gst_hermes_colorspace_base_init (gpointer g_class);
+static void gst_hermes_colorspace_class_init (GstHermesColorspaceClass * klass);
+static void gst_hermes_colorspace_init (GstHermesColorspace * space);
-static void gst_hermes_colorspace_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_hermes_colorspace_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static void gst_hermes_colorspace_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_hermes_colorspace_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
static GstPadLinkReturn
- gst_hermes_colorspace_link (GstPad *pad, const GstCaps *caps);
-static void gst_hermes_colorspace_chain (GstPad *pad, GstData *_data);
+gst_hermes_colorspace_link (GstPad * pad, const GstCaps * caps);
+static void gst_hermes_colorspace_chain (GstPad * pad, GstData * _data);
static GstElementStateReturn
- gst_hermes_colorspace_change_state (GstElement *element);
+gst_hermes_colorspace_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_hermes_colorspace_signals[LAST_SIGNAL] = { 0 }; */
#if 0
-static gboolean
-colorspace_setup_converter (GstHermesColorspace *space, GstCaps *from_caps, GstCaps *to_caps)
+static gboolean
+colorspace_setup_converter (GstHermesColorspace * space, GstCaps * from_caps,
+ GstCaps * to_caps)
{
guint32 from_space, to_space;
GstStructure *from_struct;
from_struct = gst_caps_get_structure (from_caps, 0);
to_struct = gst_caps_get_structure (to_caps, 0);
- from_space = GST_MAKE_FOURCC ('R','G','B',' ');
+ from_space = GST_MAKE_FOURCC ('R', 'G', 'B', ' ');
gst_structure_get_fourcc (from_struct, "format", &from_space);
- to_space = GST_MAKE_FOURCC ('R','G','B',' ');
+ to_space = GST_MAKE_FOURCC ('R', 'G', 'B', ' ');
gst_structure_get_fourcc (to_struct, "format", &to_space);
- GST_INFO ("set up converter for " GST_FOURCC_FORMAT
- " (%08x) to " GST_FOURCC_FORMAT " (%08x)",
- GST_FOURCC_ARGS (from_space), from_space,
- GST_FOURCC_ARGS (to_space), to_space);
+ GST_INFO ("set up converter for " GST_FOURCC_FORMAT
+ " (%08x) to " GST_FOURCC_FORMAT " (%08x)",
+ GST_FOURCC_ARGS (from_space), from_space,
+ GST_FOURCC_ARGS (to_space), to_space);
switch (from_space) {
- case GST_MAKE_FOURCC ('R','G','B',' '):
+ case GST_MAKE_FOURCC ('R', 'G', 'B', ' '):
{
gint from_bpp;
-
+
gst_structure_get_int (from_struct, "bpp", &from_bpp);
switch (to_space) {
- case GST_MAKE_FOURCC ('R','G','B',' '):
+ case GST_MAKE_FOURCC ('R', 'G', 'B', ' '):
#ifdef HAVE_HERMES
- {
- gint to_bpp;
-
- gst_structure_get_int (to_struct, "bpp", &to_bpp);
+ {
+ gint to_bpp;
- gst_structure_get_int (from_struct, "red_mask", &space->source.r);
+ gst_structure_get_int (to_struct, "bpp", &to_bpp);
+
+ gst_structure_get_int (from_struct, "red_mask", &space->source.r);
gst_structure_get_int (from_struct, "green_mask", &space->source.g);
- gst_structure_get_int (from_struct, "blue_mask", &space->source.b);
+ gst_structure_get_int (from_struct, "blue_mask", &space->source.b);
space->source.a = 0;
space->srcbpp = space->source.bits = from_bpp;
space->source.indexed = 0;
space->source.has_colorkey = 0;
- GST_INFO ( "source red mask %08x", space->source.r);
- GST_INFO ( "source green mask %08x", space->source.g);
- GST_INFO ( "source blue mask %08x", space->source.b);
- GST_INFO ( "source bpp %08x", space->srcbpp);
+ GST_INFO ("source red mask %08x", space->source.r);
+ GST_INFO ("source green mask %08x", space->source.g);
+ GST_INFO ("source blue mask %08x", space->source.b);
+ GST_INFO ("source bpp %08x", space->srcbpp);
- gst_structure_get_int (to_struct, "red_mask", &space->dest.r);
+ gst_structure_get_int (to_struct, "red_mask", &space->dest.r);
gst_structure_get_int (to_struct, "green_mask", &space->dest.g);
- gst_structure_get_int (to_struct, "blue_mask", &space->dest.b);
+ gst_structure_get_int (to_struct, "blue_mask", &space->dest.b);
space->dest.a = 0;
space->destbpp = space->dest.bits = to_bpp;
space->dest.indexed = 0;
space->dest.has_colorkey = 0;
- GST_INFO ( "dest red mask %08x", space->dest.r);
- GST_INFO ( "dest green mask %08x", space->dest.g);
- GST_INFO ( "dest blue mask %08x", space->dest.b);
- GST_INFO ( "dest bpp %08x", space->destbpp);
+ GST_INFO ("dest red mask %08x", space->dest.r);
+ GST_INFO ("dest green mask %08x", space->dest.g);
+ GST_INFO ("dest blue mask %08x", space->dest.b);
+ GST_INFO ("dest bpp %08x", space->destbpp);
- if (!Hermes_ConverterRequest (space->h_handle, &space->source, &space->dest)) {
+ if (!Hermes_ConverterRequest (space->h_handle, &space->source,
+ &space->dest)) {
g_warning ("Hermes: could not get converter\n");
return FALSE;
}
- GST_INFO ( "converter set up");
- space->type = GST_HERMES_COLORSPACE_HERMES;
+ GST_INFO ("converter set up");
+ space->type = GST_HERMES_COLORSPACE_HERMES;
return TRUE;
}
#else
g_warning ("colorspace: compiled without hermes!");
return FALSE;
#endif
- case GST_MAKE_FOURCC ('Y','V','1','2'):
+ case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
if (from_bpp == 32) {
- space->type = GST_HERMES_COLORSPACE_RGB32_YV12;
+ space->type = GST_HERMES_COLORSPACE_RGB32_YV12;
space->destbpp = 12;
return TRUE;
}
- case GST_MAKE_FOURCC ('I','4','2','0'):
+ case GST_MAKE_FOURCC ('I', '4', '2', '0'):
if (from_bpp == 32) {
- space->type = GST_HERMES_COLORSPACE_RGB32_I420;
+ space->type = GST_HERMES_COLORSPACE_RGB32_I420;
space->destbpp = 12;
return TRUE;
}
- case GST_MAKE_FOURCC ('Y','U','Y','2'):
- GST_INFO ( "colorspace: RGB to YUV with bpp %d not implemented!!", from_bpp);
+ case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
+ GST_INFO ("colorspace: RGB to YUV with bpp %d not implemented!!",
+ from_bpp);
return FALSE;
}
break;
}
- case GST_MAKE_FOURCC ('I','4','2','0'):
+ case GST_MAKE_FOURCC ('I', '4', '2', '0'):
switch (to_space) {
- case GST_MAKE_FOURCC ('R','G','B',' '):
- GST_INFO ( "colorspace: YUV to RGB");
+ case GST_MAKE_FOURCC ('R', 'G', 'B', ' '):
+ GST_INFO ("colorspace: YUV to RGB");
gst_structure_get_int (to_struct, "bpp", &space->destbpp);
- space->converter = gst_hermes_colorspace_yuv2rgb_get_converter (from_caps, to_caps);
- space->type = GST_HERMES_COLORSPACE_YUV_RGB;
+ space->converter =
+ gst_hermes_colorspace_yuv2rgb_get_converter (from_caps, to_caps);
+ space->type = GST_HERMES_COLORSPACE_YUV_RGB;
return TRUE;
- case GST_MAKE_FOURCC ('I','4','2','0'):
- space->type = GST_HERMES_COLORSPACE_NONE;
+ case GST_MAKE_FOURCC ('I', '4', '2', '0'):
+ space->type = GST_HERMES_COLORSPACE_NONE;
space->destbpp = 12;
return TRUE;
- case GST_MAKE_FOURCC ('Y','V','1','2'):
- space->type = GST_HERMES_COLORSPACE_420_SWAP;
+ case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
+ space->type = GST_HERMES_COLORSPACE_420_SWAP;
space->destbpp = 12;
return TRUE;
}
break;
- case GST_MAKE_FOURCC ('Y','U','Y','2'):
+ case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
switch (to_space) {
- case GST_MAKE_FOURCC ('I','4','2','0'):
- space->type = GST_HERMES_COLORSPACE_YUY2_I420;
+ case GST_MAKE_FOURCC ('I', '4', '2', '0'):
+ space->type = GST_HERMES_COLORSPACE_YUY2_I420;
space->destbpp = 12;
return TRUE;
- case GST_MAKE_FOURCC ('Y','U','Y','2'):
- space->type = GST_HERMES_COLORSPACE_NONE;
+ case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
+ space->type = GST_HERMES_COLORSPACE_NONE;
space->destbpp = 16;
return TRUE;
- case GST_MAKE_FOURCC ('R','G','B',' '):
- GST_INFO ( "colorspace: YUY2 to RGB not implemented!!");
+ case GST_MAKE_FOURCC ('R', 'G', 'B', ' '):
+ GST_INFO ("colorspace: YUY2 to RGB not implemented!!");
return FALSE;
}
break;
- case GST_MAKE_FOURCC ('Y','V','1','2'):
+ case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
switch (to_space) {
- case GST_MAKE_FOURCC ('R','G','B',' '):
- GST_INFO ( "colorspace: YV12 to RGB");
+ case GST_MAKE_FOURCC ('R', 'G', 'B', ' '):
+ GST_INFO ("colorspace: YV12 to RGB");
gst_structure_get_int (to_struct, "bpp", &space->destbpp);
- space->converter = gst_hermes_colorspace_yuv2rgb_get_converter (from_caps, to_caps);
- space->type = GST_HERMES_COLORSPACE_YUV_RGB;
+ space->converter =
+ gst_hermes_colorspace_yuv2rgb_get_converter (from_caps, to_caps);
+ space->type = GST_HERMES_COLORSPACE_YUV_RGB;
return TRUE;
- case GST_MAKE_FOURCC ('I','4','2','0'):
- space->type = GST_HERMES_COLORSPACE_420_SWAP;
+ case GST_MAKE_FOURCC ('I', '4', '2', '0'):
+ space->type = GST_HERMES_COLORSPACE_420_SWAP;
space->destbpp = 12;
return TRUE;
- case GST_MAKE_FOURCC ('Y','V','1','2'):
- space->type = GST_HERMES_COLORSPACE_NONE;
+ case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
+ space->type = GST_HERMES_COLORSPACE_NONE;
space->destbpp = 12;
return TRUE;
}
#endif
static GstCaps *
-gst_hermes_colorspace_caps_remove_format_info (GstCaps *caps)
+gst_hermes_colorspace_caps_remove_format_info (GstCaps * caps)
{
int i;
GstStructure *structure;
GstCaps *rgbcaps;
- for (i=0; i<gst_caps_get_size (caps); i++) {
+ for (i = 0; i < gst_caps_get_size (caps); i++) {
structure = gst_caps_get_structure (caps, i);
gst_structure_remove_field (structure, "format");
}
static void
-gst_hermes_colorspace_structure_to_hermes_format (HermesFormat *format,
- GstStructure *structure)
+gst_hermes_colorspace_structure_to_hermes_format (HermesFormat * format,
+ GstStructure * structure)
{
- gst_structure_get_int (structure, "red_mask", &format->r);
+ gst_structure_get_int (structure, "red_mask", &format->r);
gst_structure_get_int (structure, "green_mask", &format->g);
- gst_structure_get_int (structure, "blue_mask", &format->b);
+ gst_structure_get_int (structure, "blue_mask", &format->b);
format->a = 0;
- gst_structure_get_int (structure, "bpp", &format->bits);
+ gst_structure_get_int (structure, "bpp", &format->bits);
format->indexed = 0;
format->has_colorkey = 0;
}
-static GstCaps*
-gst_hermes_colorspace_getcaps (GstPad *pad)
+static GstCaps *
+gst_hermes_colorspace_getcaps (GstPad * pad)
{
GstHermesColorspace *space;
GstPad *otherpad;
GstCaps *othercaps;
GstCaps *caps;
-
+
space = GST_HERMES_COLORSPACE (gst_pad_get_parent (pad));
otherpad = (pad == space->srcpad) ? space->sinkpad : space->srcpad;
}
static GstPadLinkReturn
-gst_hermes_colorspace_link (GstPad *pad, const GstCaps *caps)
+gst_hermes_colorspace_link (GstPad * pad, const GstCaps * caps)
{
GstHermesColorspace *space;
GstPad *otherpad;
structure = gst_caps_get_structure (caps, 0);
- for(i=0; i<G_N_ELEMENTS (gst_hermes_colorspace_formats); i++) {
+ for (i = 0; i < G_N_ELEMENTS (gst_hermes_colorspace_formats); i++) {
GstCaps *icaps;
GstCaps *fcaps;
-
- fcaps = gst_caps_copy (gst_static_caps_get (
- &gst_hermes_colorspace_formats[i].caps));
+
+ fcaps =
+ gst_caps_copy (gst_static_caps_get (&gst_hermes_colorspace_formats[i].
+ caps));
icaps = gst_caps_intersect (caps, fcaps);
if (!gst_caps_is_empty (icaps)) {
}
gst_caps_free (icaps);
}
- if (i==G_N_ELEMENTS (gst_hermes_colorspace_formats)) {
+ if (i == G_N_ELEMENTS (gst_hermes_colorspace_formats)) {
g_assert_not_reached ();
return GST_PAD_LINK_REFUSED;
}
gst_structure_get_int (structure, "height", &height);
gst_structure_get_double (structure, "framerate", &fps);
- GST_INFO ( "size: %dx%d", space->width, space->height);
+ GST_INFO ("size: %dx%d", space->width, space->height);
if (gst_pad_is_negotiated (otherpad)) {
GstCaps *othercaps;
-
+
othercaps = gst_caps_copy (gst_pad_get_negotiated_caps (otherpad));
gst_caps_set_simple (othercaps,
- "width", G_TYPE_INT, width,
- "height", G_TYPE_INT, height,
- "framerate", G_TYPE_DOUBLE, fps, NULL);
+ "width", G_TYPE_INT, width,
+ "height", G_TYPE_INT, height, "framerate", G_TYPE_DOUBLE, fps, NULL);
link_ret = gst_pad_try_set_caps (otherpad, othercaps);
if (link_ret != GST_PAD_LINK_OK) {
if (pad == space->srcpad) {
space->src_format_index = i;
- gst_hermes_colorspace_structure_to_hermes_format (&space->src_format, structure);
+ gst_hermes_colorspace_structure_to_hermes_format (&space->src_format,
+ structure);
} else {
space->sink_format_index = i;
- gst_hermes_colorspace_structure_to_hermes_format (&space->sink_format, structure);
+ gst_hermes_colorspace_structure_to_hermes_format (&space->sink_format,
+ structure);
}
- space->sink_stride = width*(space->sink_format.bits/8);
- space->src_stride = width*(space->src_format.bits/8);
+ space->sink_stride = width * (space->sink_format.bits / 8);
+ space->src_stride = width * (space->src_format.bits / 8);
space->sink_size = space->sink_stride * height;
space->src_size = space->src_stride * height;
space->width = width;
if (gst_pad_is_negotiated (otherpad)) {
if (!Hermes_ConverterRequest (space->h_handle, &space->sink_format,
- &space->src_format)) {
+ &space->src_format)) {
g_warning ("Hermes: could not get converter\n");
return GST_PAD_LINK_REFUSED;
}
-g_print("inited\n");
+ g_print ("inited\n");
}
return GST_PAD_LINK_OK;
if (!colorspace_type) {
static const GTypeInfo colorspace_info = {
- sizeof(GstHermesColorspaceClass),
+ sizeof (GstHermesColorspaceClass),
gst_hermes_colorspace_base_init,
NULL,
- (GClassInitFunc)gst_hermes_colorspace_class_init,
+ (GClassInitFunc) gst_hermes_colorspace_class_init,
NULL,
NULL,
- sizeof(GstHermesColorspace),
+ sizeof (GstHermesColorspace),
0,
- (GInstanceInitFunc)gst_hermes_colorspace_init,
+ (GInstanceInitFunc) gst_hermes_colorspace_init,
};
- colorspace_type = g_type_register_static(GST_TYPE_ELEMENT, "GstHermesColorspace", &colorspace_info, 0);
+ colorspace_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstHermesColorspace",
+ &colorspace_info, 0);
}
return colorspace_type;
}
-static GstStaticPadTemplate gst_hermes_colorspace_src_pad_template =
-GST_STATIC_PAD_TEMPLATE (
- "src",
+static GstStaticPadTemplate gst_hermes_colorspace_src_pad_template =
+ GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- GST_VIDEO_CAPS_xRGB "; "
- GST_VIDEO_CAPS_RGBx "; "
- GST_VIDEO_CAPS_BGRx "; "
- GST_VIDEO_CAPS_xBGR "; "
- GST_VIDEO_CAPS_BGR "; "
- GST_VIDEO_CAPS_RGB "; "
- GST_VIDEO_CAPS_RGB_16 "; "
- GST_VIDEO_CAPS_RGB_15)
-);
-
-static GstStaticPadTemplate gst_hermes_colorspace_sink_pad_template =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_xRGB "; "
+ GST_VIDEO_CAPS_RGBx "; "
+ GST_VIDEO_CAPS_BGRx "; "
+ GST_VIDEO_CAPS_xBGR "; "
+ GST_VIDEO_CAPS_BGR "; "
+ GST_VIDEO_CAPS_RGB "; "
+ GST_VIDEO_CAPS_RGB_16 "; " GST_VIDEO_CAPS_RGB_15)
+ );
+
+static GstStaticPadTemplate gst_hermes_colorspace_sink_pad_template =
+ GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- GST_VIDEO_CAPS_xRGB "; "
- GST_VIDEO_CAPS_RGBx "; "
- GST_VIDEO_CAPS_BGRx "; "
- GST_VIDEO_CAPS_xBGR "; "
- GST_VIDEO_CAPS_BGR "; "
- GST_VIDEO_CAPS_RGB "; "
- GST_VIDEO_CAPS_RGB_16 "; "
- GST_VIDEO_CAPS_RGB_15)
-);
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_xRGB "; "
+ GST_VIDEO_CAPS_RGBx "; "
+ GST_VIDEO_CAPS_BGRx "; "
+ GST_VIDEO_CAPS_xBGR "; "
+ GST_VIDEO_CAPS_BGR "; "
+ GST_VIDEO_CAPS_RGB "; "
+ GST_VIDEO_CAPS_RGB_16 "; " GST_VIDEO_CAPS_RGB_15)
+ );
static void
gst_hermes_colorspace_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
+
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_hermes_colorspace_src_pad_template));
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&gst_hermes_colorspace_sink_pad_template));
+ gst_static_pad_template_get (&gst_hermes_colorspace_sink_pad_template));
gst_element_class_set_details (element_class, &colorspace_details);
}
-
+
static void
-gst_hermes_colorspace_class_init (GstHermesColorspaceClass *klass)
+gst_hermes_colorspace_class_init (GstHermesColorspaceClass * 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);
gobject_class->set_property = gst_hermes_colorspace_set_property;
gobject_class->get_property = gst_hermes_colorspace_get_property;
}
static void
-gst_hermes_colorspace_init (GstHermesColorspace *space)
+gst_hermes_colorspace_init (GstHermesColorspace * space)
{
- space->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&gst_hermes_colorspace_sink_pad_template),
- "sink");
+ space->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_hermes_colorspace_sink_pad_template), "sink");
gst_pad_set_link_function (space->sinkpad, gst_hermes_colorspace_link);
gst_pad_set_getcaps_function (space->sinkpad, gst_hermes_colorspace_getcaps);
- gst_pad_set_chain_function(space->sinkpad,gst_hermes_colorspace_chain);
- gst_element_add_pad(GST_ELEMENT(space),space->sinkpad);
+ gst_pad_set_chain_function (space->sinkpad, gst_hermes_colorspace_chain);
+ gst_element_add_pad (GST_ELEMENT (space), space->sinkpad);
- space->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&gst_hermes_colorspace_src_pad_template),
- "src");
- gst_element_add_pad(GST_ELEMENT(space),space->srcpad);
+ space->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_hermes_colorspace_src_pad_template), "src");
+ gst_element_add_pad (GST_ELEMENT (space), space->srcpad);
gst_pad_set_link_function (space->srcpad, gst_hermes_colorspace_link);
space->h_handle = Hermes_ConverterInstance (0);
}
static void
-gst_hermes_colorspace_chain (GstPad *pad,GstData *_data)
+gst_hermes_colorspace_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstHermesColorspace *space;
g_return_if_fail (buf != NULL);
space = GST_HERMES_COLORSPACE (gst_pad_get_parent (pad));
-
+
g_return_if_fail (space != NULL);
g_return_if_fail (GST_IS_COLORSPACE (space));
outbuf = gst_pad_alloc_buffer (space->srcpad, GST_BUFFER_OFFSET_NONE,
space->src_size);
-
- Hermes_ConverterCopy (space->h_handle,
+
+ Hermes_ConverterCopy (space->h_handle,
GST_BUFFER_DATA (buf), 0, 0, space->width, space->height,
space->sink_stride, GST_BUFFER_DATA (outbuf), 0, 0,
space->width, space->height, space->src_stride);
}
static GstElementStateReturn
-gst_hermes_colorspace_change_state (GstElement *element)
+gst_hermes_colorspace_change_state (GstElement * element)
{
GstHermesColorspace *space;
}
static void
-gst_hermes_colorspace_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_hermes_colorspace_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstHermesColorspace *space;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_COLORSPACE(object));
- space = GST_HERMES_COLORSPACE(object);
+ g_return_if_fail (GST_IS_COLORSPACE (object));
+ space = GST_HERMES_COLORSPACE (object);
switch (prop_id) {
default:
}
static void
-gst_hermes_colorspace_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_hermes_colorspace_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
GstHermesColorspace *space;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_COLORSPACE(object));
- space = GST_HERMES_COLORSPACE(object);
+ g_return_if_fail (GST_IS_COLORSPACE (object));
+ space = GST_HERMES_COLORSPACE (object);
switch (prop_id) {
default:
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
gint hermes_res;
- hermes_res = Hermes_Init();
+ hermes_res = Hermes_Init ();
g_return_val_if_fail (hermes_res != 0, FALSE);
if (!gst_element_register (plugin, "hermescolorspace", GST_RANK_PRIMARY,
- GST_TYPE_COLORSPACE))
+ GST_TYPE_COLORSPACE))
return FALSE;
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "hermescolorspace",
- "Hermes colorspace converter",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "hermescolorspace",
+ "Hermes colorspace converter",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
#include <vorbisenc.h>
-extern GType ivorbisfile_get_type(void);
+extern GType ivorbisfile_get_type (void);
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
if (!gst_library_load ("gstbytestream"))
return FALSE;
- if (!gst_element_register (plugin, "tremor", GST_RANK_PRIMARY, ivorbisfile_get_type ()))
+ if (!gst_element_register (plugin, "tremor", GST_RANK_PRIMARY,
+ ivorbisfile_get_type ()))
return FALSE;
-
+
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "tremor",
- "OGG Vorbis Tremor plugins element",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "tremor",
+ "OGG Vorbis Tremor plugins element",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
#include <tremor/ivorbiscodec.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_VORBISENC \
(vorbisenc_get_type())
#define GST_IS_VORBISENC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VORBISENC))
-typedef struct _VorbisEnc VorbisEnc;
-typedef struct _VorbisEncClass VorbisEncClass;
+ typedef struct _VorbisEnc VorbisEnc;
+ typedef struct _VorbisEncClass VorbisEncClass;
-struct _VorbisEnc {
- GstElement element;
+ struct _VorbisEnc
+ {
+ GstElement element;
- GstPad *sinkpad,
- *srcpad;
+ GstPad *sinkpad, *srcpad;
- 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 */
+ 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_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 */
+ vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */
+ vorbis_block vb; /* local working space for packet->PCM decode */
- gboolean eos;
+ gboolean eos;
- gboolean managed;
- gint bitrate;
- gint min_bitrate;
- gint max_bitrate;
- gfloat quality;
- gboolean quality_set;
- gint serial;
+ gboolean managed;
+ gint bitrate;
+ gint min_bitrate;
+ gint max_bitrate;
+ gfloat quality;
+ gboolean quality_set;
+ gint serial;
- gint channels;
- gint frequency;
+ gint channels;
+ gint frequency;
- guint64 samples_in;
- guint64 bytes_out;
+ guint64 samples_in;
+ guint64 bytes_out;
- GstCaps *metadata;
+ GstCaps *metadata;
- gboolean setup;
- gboolean flush_header;
- gchar *last_message;
-};
+ gboolean setup;
+ gboolean flush_header;
+ gchar *last_message;
+ };
-struct _VorbisEncClass {
- GstElementClass parent_class;
-};
+ struct _VorbisEncClass
+ {
+ GstElementClass parent_class;
+ };
-GType vorbisenc_get_type(void);
+ GType vorbisenc_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __VORBISENC_H__ */
+#endif /* __VORBISENC_H__ */
typedef struct _Ivorbisfile Ivorbisfile;
typedef struct _IvorbisfileClass IvorbisfileClass;
-struct _Ivorbisfile {
- GstElement element;
+struct _Ivorbisfile
+{
+ GstElement element;
- GstPad *sinkpad,
- *srcpad;
+ GstPad *sinkpad, *srcpad;
GstByteStream *bs;
OggVorbis_File vf;
- gint current_link;
-
- gboolean restart;
- gboolean need_discont;
- gboolean eos;
- gboolean seek_pending;
- gint64 seek_value;
- GstFormat seek_format;
- gboolean seek_accurate;
-
- gboolean may_eos;
- guint64 total_bytes;
- guint64 offset;
-
- GstCaps *metadata;
- GstCaps *streaminfo;
+ gint current_link;
+
+ gboolean restart;
+ gboolean need_discont;
+ gboolean eos;
+ gboolean seek_pending;
+ gint64 seek_value;
+ GstFormat seek_format;
+ gboolean seek_accurate;
+
+ gboolean may_eos;
+ guint64 total_bytes;
+ guint64 offset;
+
+ GstCaps *metadata;
+ GstCaps *streaminfo;
};
-struct _IvorbisfileClass {
+struct _IvorbisfileClass
+{
GstElementClass parent_class;
};
static GstPadTemplate *gst_vorbisdec_src_template, *gst_vorbisdec_sink_template;
/* elementfactory information */
-GstElementDetails ivorbisfile_details =
-{
+GstElementDetails ivorbisfile_details = {
"Ogg Vorbis decoder",
"Codec/Audio/Decoder",
"Decodes OGG Vorbis audio using the Tremor vorbisfile API",
- "Monty <monty@xiph.org>\n"
- "Wim Taymans <wim.taymans@chello.be>\n"
- "Amaury Jacquot <sxpert@esitcom.org>",
+ "Monty <monty@xiph.org>\n"
+ "Wim Taymans <wim.taymans@chello.be>\n"
+ "Amaury Jacquot <sxpert@esitcom.org>",
};
/* Ivorbisfile signals and args */
ARG_STREAMINFO
};
-static void gst_ivorbisfile_base_init (gpointer g_class);
-static void
- gst_ivorbisfile_class_init (IvorbisfileClass *klass);
-static void gst_ivorbisfile_init (Ivorbisfile *ivorbisfile);
+static void gst_ivorbisfile_base_init (gpointer g_class);
+static void gst_ivorbisfile_class_init (IvorbisfileClass * klass);
+static void gst_ivorbisfile_init (Ivorbisfile * ivorbisfile);
static GstElementStateReturn
- gst_ivorbisfile_change_state (GstElement *element);
-
-static const
-GstFormat* gst_ivorbisfile_get_formats (GstPad *pad);
-static gboolean gst_ivorbisfile_src_convert (GstPad *pad,
- GstFormat src_format,
- gint64 src_value,
- GstFormat *dest_format,
- gint64 *dest_value);
-static gboolean gst_ivorbisfile_sink_convert (GstPad *pad,
- GstFormat src_format,
- gint64 src_value,
- GstFormat *dest_format,
- gint64 *dest_value);
-static const GstQueryType*
- gst_ivorbisfile_get_query_types (GstPad *pad);
-
-static gboolean gst_ivorbisfile_src_query (GstPad *pad,
- GstQueryType type,
- GstFormat *format,
- gint64 *value);
-static const
-GstEventMask* gst_ivorbisfile_get_event_masks (GstPad *pad);
-static gboolean gst_ivorbisfile_src_event (GstPad *pad, GstEvent *event);
-
-static void gst_ivorbisfile_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static void gst_ivorbisfile_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-
-static void gst_ivorbisfile_loop (GstElement *element);
+gst_ivorbisfile_change_state (GstElement * element);
+
+static const GstFormat *gst_ivorbisfile_get_formats (GstPad * pad);
+static gboolean gst_ivorbisfile_src_convert (GstPad * pad,
+ GstFormat src_format,
+ gint64 src_value, GstFormat * dest_format, gint64 * dest_value);
+static gboolean gst_ivorbisfile_sink_convert (GstPad * pad,
+ GstFormat src_format,
+ gint64 src_value, GstFormat * dest_format, gint64 * dest_value);
+static const GstQueryType *gst_ivorbisfile_get_query_types (GstPad * pad);
+
+static gboolean gst_ivorbisfile_src_query (GstPad * pad,
+ GstQueryType type, GstFormat * format, gint64 * value);
+static const GstEventMask *gst_ivorbisfile_get_event_masks (GstPad * pad);
+static gboolean gst_ivorbisfile_src_event (GstPad * pad, GstEvent * event);
+
+static void gst_ivorbisfile_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
+static void gst_ivorbisfile_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+
+static void gst_ivorbisfile_loop (GstElement * element);
static GstElementClass *parent_class = NULL;
+
//static guint gst_ivorbisfile_signals[LAST_SIGNAL] = { 0 };
static GstFormat logical_stream_format;
(GInstanceInitFunc) gst_ivorbisfile_init,
};
- ivorbisfile_type = g_type_register_static (GST_TYPE_ELEMENT, "Ivorbisfile",
- &ivorbisfile_info, 0);
+ ivorbisfile_type = g_type_register_static (GST_TYPE_ELEMENT, "Ivorbisfile",
+ &ivorbisfile_info, 0);
+
+ logical_stream_format =
+ gst_format_register ("logical_stream", "The logical stream");
- logical_stream_format = gst_format_register ("logical_stream", "The logical stream");
-
- GST_DEBUG_CATEGORY_INIT (ivorbisfile_debug, "ivorbisfile", 0,
- "vorbis in ogg decoding element (integer arithmetic)");
+ GST_DEBUG_CATEGORY_INIT (ivorbisfile_debug, "ivorbisfile", 0,
+ "vorbis in ogg decoding element (integer arithmetic)");
}
return ivorbisfile_type;
}
-static GstCaps*
+static GstCaps *
vorbis_caps_factory (void)
{
- return
- gst_caps_new_simple (
- "application/ogg",
- NULL);
+ return gst_caps_new_simple ("application/ogg", NULL);
}
-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);
+ 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);
}
-static GstCaps*
+static GstCaps *
raw_caps2_factory (void)
{
return
- gst_caps_new_simple (
- "audio/x-raw-float",
- "depth", G_TYPE_INT, 32,
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "rate", GST_TYPE_INT_RANGE, 11025, 48000,
- "channels", G_TYPE_INT, 2,
- NULL);
+ gst_caps_new_simple ("audio/x-raw-float",
+ "depth", G_TYPE_INT, 32,
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "rate", GST_TYPE_INT_RANGE, 11025, 48000,
+ "channels", G_TYPE_INT, 2, NULL);
}
vorbis_caps = vorbis_caps_factory ();
/* register sink pads */
- gst_vorbisdec_sink_template = gst_pad_template_new ("sink", GST_PAD_SINK,
- GST_PAD_ALWAYS,
- vorbis_caps);
+ gst_vorbisdec_sink_template = gst_pad_template_new ("sink", GST_PAD_SINK,
+ GST_PAD_ALWAYS, vorbis_caps);
gst_caps_append (raw_caps2, raw_caps);
/* register src pads */
- gst_vorbisdec_src_template = gst_pad_template_new ("src", GST_PAD_SRC,
- GST_PAD_ALWAYS,
- raw_caps2);
- gst_element_class_add_pad_template (element_class, gst_vorbisdec_sink_template);
- gst_element_class_add_pad_template (element_class, gst_vorbisdec_src_template);
+ gst_vorbisdec_src_template = gst_pad_template_new ("src", GST_PAD_SRC,
+ GST_PAD_ALWAYS, raw_caps2);
+ gst_element_class_add_pad_template (element_class,
+ gst_vorbisdec_sink_template);
+ gst_element_class_add_pad_template (element_class,
+ gst_vorbisdec_src_template);
gst_element_class_set_details (element_class, &ivorbisfile_details);
}
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- gobject_class = (GObjectClass*) klass;
+ gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
g_object_class_install_property (gobject_class, ARG_METADATA,
- g_param_spec_boxed ("metadata", "Metadata", "(logical) Stream metadata",
- GST_TYPE_CAPS, G_PARAM_READABLE));
+ g_param_spec_boxed ("metadata", "Metadata", "(logical) Stream metadata",
+ GST_TYPE_CAPS, G_PARAM_READABLE));
g_object_class_install_property (gobject_class, ARG_STREAMINFO,
- g_param_spec_boxed ("streaminfo", "stream", "(logical) Stream information",
- GST_TYPE_CAPS, G_PARAM_READABLE));
+ g_param_spec_boxed ("streaminfo", "stream",
+ "(logical) Stream information", GST_TYPE_CAPS, G_PARAM_READABLE));
gobject_class->get_property = gst_ivorbisfile_get_property;
gobject_class->set_property = gst_ivorbisfile_set_property;
gst_ivorbisfile_init (Ivorbisfile * ivorbisfile)
{
ivorbisfile->sinkpad = gst_pad_new_from_template (gst_vorbisdec_sink_template,
- "sink");
+ "sink");
gst_element_add_pad (GST_ELEMENT (ivorbisfile), ivorbisfile->sinkpad);
- gst_pad_set_formats_function (ivorbisfile->sinkpad, gst_ivorbisfile_get_formats);
- gst_pad_set_convert_function (ivorbisfile->sinkpad, gst_ivorbisfile_sink_convert);
-
- gst_element_set_loop_function (GST_ELEMENT (ivorbisfile), gst_ivorbisfile_loop);
- ivorbisfile->srcpad = gst_pad_new_from_template (gst_vorbisdec_src_template,
- "src");
+ gst_pad_set_formats_function (ivorbisfile->sinkpad,
+ gst_ivorbisfile_get_formats);
+ gst_pad_set_convert_function (ivorbisfile->sinkpad,
+ gst_ivorbisfile_sink_convert);
+
+ gst_element_set_loop_function (GST_ELEMENT (ivorbisfile),
+ gst_ivorbisfile_loop);
+ ivorbisfile->srcpad =
+ gst_pad_new_from_template (gst_vorbisdec_src_template, "src");
gst_element_add_pad (GST_ELEMENT (ivorbisfile), ivorbisfile->srcpad);
- gst_pad_set_formats_function (ivorbisfile->srcpad, gst_ivorbisfile_get_formats);
- gst_pad_set_query_type_function (ivorbisfile->srcpad,
- gst_ivorbisfile_get_query_types);
+ gst_pad_set_formats_function (ivorbisfile->srcpad,
+ gst_ivorbisfile_get_formats);
+ gst_pad_set_query_type_function (ivorbisfile->srcpad,
+ gst_ivorbisfile_get_query_types);
gst_pad_set_query_function (ivorbisfile->srcpad, gst_ivorbisfile_src_query);
- gst_pad_set_event_mask_function (ivorbisfile->srcpad,
- gst_ivorbisfile_get_event_masks);
+ gst_pad_set_event_mask_function (ivorbisfile->srcpad,
+ gst_ivorbisfile_get_event_masks);
gst_pad_set_event_function (ivorbisfile->srcpad, gst_ivorbisfile_src_event);
- gst_pad_set_convert_function (ivorbisfile->srcpad, gst_ivorbisfile_src_convert);
+ gst_pad_set_convert_function (ivorbisfile->srcpad,
+ gst_ivorbisfile_src_convert);
ivorbisfile->total_bytes = 0;
ivorbisfile->offset = 0;
GST_DEBUG ("read %d", read_size);
/* make sure we don't go to EOS */
- if (!ivorbisfile->may_eos && ivorbisfile->total_bytes &&
- ivorbisfile->offset + read_size > ivorbisfile->total_bytes)
- {
+ if (!ivorbisfile->may_eos && ivorbisfile->total_bytes &&
+ ivorbisfile->offset + read_size > ivorbisfile->total_bytes) {
read_size = ivorbisfile->total_bytes - ivorbisfile->offset;
}
if (read_size == 0 || ivorbisfile->eos)
return 0;
-
+
while (got_bytes == 0) {
got_bytes = gst_bytestream_peek_bytes (ivorbisfile->bs, &data, read_size);
if (got_bytes < read_size) {
GstEvent *event;
guint32 avail;
-
- gst_bytestream_get_status (ivorbisfile->bs, &avail, &event);
+
+ gst_bytestream_get_status (ivorbisfile->bs, &avail, &event);
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS:
GST_DEBUG ("eos");
- ivorbisfile->eos = TRUE;
- if (avail == 0) {
- gst_event_unref (event);
- return 0;
+ ivorbisfile->eos = TRUE;
+ if (avail == 0) {
+ gst_event_unref (event);
+ return 0;
}
break;
case GST_EVENT_DISCONTINUOUS:
GST_DEBUG ("discont");
ivorbisfile->need_discont = TRUE;
default:
- break;
+ break;
}
gst_event_unref (event);
- if (avail > 0)
- got_bytes = gst_bytestream_peek_bytes (ivorbisfile->bs, &data, avail);
+ if (avail > 0)
+ got_bytes = gst_bytestream_peek_bytes (ivorbisfile->bs, &data, avail);
else
got_bytes = 0;
}
if (!ivorbisfile->vf.seekable) {
return -1;
}
-
+
GST_DEBUG ("seek %lld %d", offset, whence);
if (whence == SEEK_SET) {
method = GST_SEEK_METHOD_SET;
pending_offset = offset;
- }
- else if (whence == SEEK_CUR) {
+ } else if (whence == SEEK_CUR) {
method = GST_SEEK_METHOD_CUR;
pending_offset += offset;
- }
- else if (whence == SEEK_END) {
+ } else if (whence == SEEK_END) {
method = GST_SEEK_METHOD_END;
need_total = TRUE;
pending_offset = ivorbisfile->total_bytes - offset;
- }
- else
+ } else
return -1;
-
+
if (!gst_bytestream_seek (ivorbisfile->bs, offset, method))
return -1;
return result;
}
-ov_callbacks ivorbisfile_ov_callbacks =
-{
+ov_callbacks ivorbisfile_ov_callbacks = {
gst_ivorbisfile_read,
gst_ivorbisfile_seek,
gst_ivorbisfile_close,
* returns TRUE if caps could be set,
* FALSE if they couldn't be read somehow */
static gboolean
-gst_ivorbisfile_update_metadata (Ivorbisfile *ivorbisfile, gint link)
+gst_ivorbisfile_update_metadata (Ivorbisfile * ivorbisfile, gint link)
{
OggVorbis_File *vf = &ivorbisfile->vf;
gchar **ptr;
while (*ptr) {
value = strstr (*ptr, "=");
if (value) {
- name = g_strndup (*ptr, value-*ptr);
- entry = gst_props_entry_new (name, GST_PROPS_STRING_TYPE, value+1);
+ name = g_strndup (*ptr, value - *ptr);
+ entry = gst_props_entry_new (name, GST_PROPS_STRING_TYPE, value + 1);
gst_props_add_entry (props, (GstPropsEntry *) entry);
}
ptr++;
}
ivorbisfile->metadata = gst_caps_new ("ivorbisfile_metadata",
- "application/x-gst-metadata",
- props);
+ "application/x-gst-metadata", props);
g_object_notify (G_OBJECT (ivorbisfile), "metadata");
* returns TRUE if caps could be set,
* FALSE if they couldn't be read somehow */
static gboolean
-gst_ivorbisfile_update_streaminfo (Ivorbisfile *ivorbisfile, gint link)
+gst_ivorbisfile_update_streaminfo (Ivorbisfile * ivorbisfile, gint link)
{
OggVorbis_File *vf = &ivorbisfile->vf;
vorbis_info *vi;
vi = ov_info (vf, link);
entry = gst_props_entry_new ("version", GST_PROPS_INT_TYPE, vi->version);
gst_props_add_entry (props, (GstPropsEntry *) entry);
- entry = gst_props_entry_new ("bitrate_upper", GST_PROPS_INT_TYPE,
- vi->bitrate_upper);
+ entry = gst_props_entry_new ("bitrate_upper", GST_PROPS_INT_TYPE,
+ vi->bitrate_upper);
gst_props_add_entry (props, (GstPropsEntry *) entry);
- entry = gst_props_entry_new ("bitrate_nominal", GST_PROPS_INT_TYPE,
- vi->bitrate_nominal);
+ entry = gst_props_entry_new ("bitrate_nominal", GST_PROPS_INT_TYPE,
+ vi->bitrate_nominal);
gst_props_add_entry (props, (GstPropsEntry *) entry);
- entry = gst_props_entry_new ("bitrate_lower", GST_PROPS_INT_TYPE,
- vi->bitrate_lower);
+ entry = gst_props_entry_new ("bitrate_lower", GST_PROPS_INT_TYPE,
+ vi->bitrate_lower);
gst_props_add_entry (props, (GstPropsEntry *) entry);
- entry = gst_props_entry_new ("serial", GST_PROPS_INT_TYPE,
- ov_serialnumber (vf, link));
+ entry = gst_props_entry_new ("serial", GST_PROPS_INT_TYPE,
+ ov_serialnumber (vf, link));
gst_props_add_entry (props, (GstPropsEntry *) entry);
- entry = gst_props_entry_new ("bitrate", GST_PROPS_INT_TYPE,
- ov_bitrate (vf, link));
+ entry = gst_props_entry_new ("bitrate", GST_PROPS_INT_TYPE,
+ ov_bitrate (vf, link));
gst_props_add_entry (props, (GstPropsEntry *) entry);
ivorbisfile->streaminfo = gst_caps_new ("ivorbisfile_streaminfo",
- "application/x-gst-streaminfo",
- props);
+ "application/x-gst-streaminfo", props);
g_object_notify (G_OBJECT (ivorbisfile), "streaminfo");
#endif
static gboolean
-gst_ivorbisfile_new_link (Ivorbisfile *ivorbisfile, gint link)
+gst_ivorbisfile_new_link (Ivorbisfile * ivorbisfile, gint link)
{
vorbis_info *vi = ov_info (&ivorbisfile->vf, link);
GstCaps *caps;
ivorbisfile->current_link = link;
caps = 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", G_TYPE_INT, vi->rate,
- "channels", G_TYPE_INT, vi->channels,
- NULL);
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "signed", G_TYPE_BOOLEAN, TRUE,
+ "width", G_TYPE_INT, 16,
+ "depth", G_TYPE_INT, 16,
+ "rate", G_TYPE_INT, vi->rate, "channels", G_TYPE_INT, vi->channels, NULL);
if (gst_pad_try_set_caps (ivorbisfile->srcpad, caps) <= 0) {
- res = FALSE;
+ res = FALSE;
}
gst_caps_free (caps);
-
+
return TRUE;
}
static void
-gst_ivorbisfile_loop (GstElement *element)
+gst_ivorbisfile_loop (GstElement * element)
{
Ivorbisfile *ivorbisfile = GST_IVORBISFILE (element);
GstBuffer *outbuf;
ivorbisfile->total_bytes = 0;
ivorbisfile->may_eos = FALSE;
ivorbisfile->vf.seekable = gst_bytestream_seek (ivorbisfile->bs, 0,
- GST_SEEK_METHOD_SET);
+ GST_SEEK_METHOD_SET);
GST_DEBUG ("ivorbisfile: seekable: %s\n",
- ivorbisfile->vf.seekable ? "yes" : "no");
+ ivorbisfile->vf.seekable ? "yes" : "no");
/* open our custom ivorbisfile data object with the callbacks we provide */
if (ov_open_callbacks (ivorbisfile, &ivorbisfile->vf, NULL, 0,
- ivorbisfile_ov_callbacks) < 0) {
+ ivorbisfile_ov_callbacks) < 0) {
GST_ELEMENT_ERROR (element, STREAM, DECODE, (NULL), (NULL));
return;
}
switch (ivorbisfile->seek_format) {
case GST_FORMAT_TIME:
{
- gdouble seek_to = (gdouble) ivorbisfile->seek_value / GST_SECOND;
+ gdouble seek_to = (gdouble) ivorbisfile->seek_value / GST_SECOND;
if (ivorbisfile->seek_accurate) {
- if (ov_time_seek (&ivorbisfile->vf, seek_to) == 0) {
- ivorbisfile->need_discont = TRUE;
- }
- }
- else {
- if (ov_time_seek_page (&ivorbisfile->vf, seek_to) == 0) {
- ivorbisfile->need_discont = TRUE;
- }
+ if (ov_time_seek (&ivorbisfile->vf, seek_to) == 0) {
+ ivorbisfile->need_discont = TRUE;
+ }
+ } else {
+ if (ov_time_seek_page (&ivorbisfile->vf, seek_to) == 0) {
+ ivorbisfile->need_discont = TRUE;
+ }
}
break;
}
case GST_FORMAT_DEFAULT:
if (ivorbisfile->seek_accurate) {
- if (ov_pcm_seek (&ivorbisfile->vf, ivorbisfile->seek_value) == 0) {
- ivorbisfile->need_discont = TRUE;
- }
- }
- else {
- if (ov_pcm_seek_page (&ivorbisfile->vf, ivorbisfile->seek_value) == 0) {
- ivorbisfile->need_discont = TRUE;
- }
+ if (ov_pcm_seek (&ivorbisfile->vf, ivorbisfile->seek_value) == 0) {
+ ivorbisfile->need_discont = TRUE;
+ }
+ } else {
+ if (ov_pcm_seek_page (&ivorbisfile->vf, ivorbisfile->seek_value) == 0) {
+ ivorbisfile->need_discont = TRUE;
+ }
}
break;
default:
if (ivorbisfile->seek_format == logical_stream_format) {
- gint64 seek_to;
-
+ gint64 seek_to;
+
seek_to = ivorbisfile->vf.offsets[ivorbisfile->seek_value];
- if (ov_raw_seek (&ivorbisfile->vf, seek_to) == 0) {
- ivorbisfile->need_discont = TRUE;
- ivorbisfile->current_link = -1;
- }
- else {
+ if (ov_raw_seek (&ivorbisfile->vf, seek_to) == 0) {
+ ivorbisfile->need_discont = TRUE;
+ ivorbisfile->current_link = -1;
+ } else {
g_warning ("raw seek failed");
}
- }
- else
+ } else
g_warning ("unknown seek method, implement me !");
break;
}
/* get current time for discont and buffer timestamp */
time = (GstClockTime) (ov_time_tell (&ivorbisfile->vf) * GST_SECOND);
- ret = ov_read (&ivorbisfile->vf,
- GST_BUFFER_DATA (outbuf), GST_BUFFER_SIZE (outbuf),
- &link);
+ ret = ov_read (&ivorbisfile->vf,
+ GST_BUFFER_DATA (outbuf), GST_BUFFER_SIZE (outbuf), &link);
if (ret == 0) {
GST_DEBUG ("eos");
/* send EOS event */
- /*ov_clear (&ivorbisfile->vf);*/
+ /*ov_clear (&ivorbisfile->vf); */
ivorbisfile->restart = TRUE;
gst_buffer_unref (outbuf);
/* if the pad is not usable, don't push it out */
if (GST_PAD_IS_USABLE (ivorbisfile->srcpad)) {
- gst_pad_push (ivorbisfile->srcpad,
- GST_DATA (gst_event_new (GST_EVENT_EOS)));
+ gst_pad_push (ivorbisfile->srcpad,
+ GST_DATA (gst_event_new (GST_EVENT_EOS)));
}
gst_element_set_eos (element);
return;
- }
- else if (ret < 0) {
+ } else if (ret < 0) {
g_warning ("ivorbisfile: decoding error");
gst_buffer_unref (outbuf);
return;
- }
- else {
+ } else {
if (ivorbisfile->need_discont) {
GstEvent *discont;
/* if the pad is not usable, don't push it out */
if (GST_PAD_IS_USABLE (ivorbisfile->srcpad)) {
- /* get stream stats */
- samples = (gint64) (ov_pcm_tell (&ivorbisfile->vf));
+ /* get stream stats */
+ samples = (gint64) (ov_pcm_tell (&ivorbisfile->vf));
- discont = gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME, time,
- GST_FORMAT_DEFAULT, samples, NULL);
+ discont = gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME, time,
+ GST_FORMAT_DEFAULT, samples, NULL);
- gst_pad_push (ivorbisfile->srcpad, GST_DATA (discont));
+ gst_pad_push (ivorbisfile->srcpad, GST_DATA (discont));
}
}
if (!ivorbisfile->vf.seekable) {
ivorbisfile->total_bytes += GST_BUFFER_SIZE (outbuf);
}
-
- if (GST_PAD_IS_USABLE (ivorbisfile->srcpad))
+
+ if (GST_PAD_IS_USABLE (ivorbisfile->srcpad))
gst_pad_push (ivorbisfile->srcpad, GST_DATA (outbuf));
else
gst_buffer_unref (outbuf);
}
}
-static const GstFormat*
-gst_ivorbisfile_get_formats (GstPad *pad)
+static const GstFormat *
+gst_ivorbisfile_get_formats (GstPad * pad)
{
static GstFormat src_formats[] = {
GST_FORMAT_TIME,
src_formats[3] = logical_stream_format;
sink_formats[2] = logical_stream_format;
-
+
return (GST_PAD_IS_SRC (pad) ? src_formats : sink_formats);
}
static gboolean
-gst_ivorbisfile_src_convert (GstPad *pad,
- GstFormat src_format, gint64 src_value,
- GstFormat *dest_format, gint64 *dest_value)
+gst_ivorbisfile_src_convert (GstPad * pad,
+ GstFormat src_format, gint64 src_value,
+ GstFormat * dest_format, gint64 * dest_value)
{
gboolean res = TRUE;
guint scale = 1;
gint bytes_per_sample;
- Ivorbisfile *ivorbisfile;
+ Ivorbisfile *ivorbisfile;
vorbis_info *vi;
-
+
ivorbisfile = GST_IVORBISFILE (gst_pad_get_parent (pad));
vi = ov_info (&ivorbisfile->vf, -1);
switch (src_format) {
case GST_FORMAT_BYTES:
switch (*dest_format) {
- case GST_FORMAT_DEFAULT:
- *dest_value = src_value / (vi->channels * 2);
- break;
- case GST_FORMAT_TIME:
- {
- gint byterate = bytes_per_sample * vi->rate;
-
- if (byterate == 0)
- return FALSE;
- *dest_value = src_value * GST_SECOND / byterate;
- break;
- }
- default:
- res = FALSE;
+ case GST_FORMAT_DEFAULT:
+ *dest_value = src_value / (vi->channels * 2);
+ break;
+ case GST_FORMAT_TIME:
+ {
+ gint byterate = bytes_per_sample * vi->rate;
+
+ if (byterate == 0)
+ return FALSE;
+ *dest_value = src_value * GST_SECOND / byterate;
+ break;
+ }
+ default:
+ res = FALSE;
}
case GST_FORMAT_DEFAULT:
switch (*dest_format) {
- case GST_FORMAT_BYTES:
+ case GST_FORMAT_BYTES:
*dest_value = src_value * bytes_per_sample;
- break;
- case GST_FORMAT_TIME:
+ break;
+ case GST_FORMAT_TIME:
if (vi->rate == 0)
return FALSE;
*dest_value = src_value * GST_SECOND / vi->rate;
- break;
- default:
- res = FALSE;
+ break;
+ default:
+ res = FALSE;
}
break;
case GST_FORMAT_TIME:
switch (*dest_format) {
- case GST_FORMAT_BYTES:
+ case GST_FORMAT_BYTES:
scale = bytes_per_sample;
- case GST_FORMAT_DEFAULT:
+ case GST_FORMAT_DEFAULT:
*dest_value = src_value * scale * vi->rate / GST_SECOND;
- break;
- default:
- res = FALSE;
+ break;
+ default:
+ res = FALSE;
}
break;
default:
gint i;
gint64 count = 0;
- switch (*dest_format) {
- case GST_FORMAT_BYTES:
- res = FALSE;
- break;
- case GST_FORMAT_DEFAULT:
+ switch (*dest_format) {
+ case GST_FORMAT_BYTES:
+ res = FALSE;
+ break;
+ case GST_FORMAT_DEFAULT:
if (src_value > ivorbisfile->vf.links) {
src_value = ivorbisfile->vf.links;
}
count += ov_pcm_total (&ivorbisfile->vf, i);
}
*dest_value = count;
- break;
- case GST_FORMAT_TIME:
+ break;
+ case GST_FORMAT_TIME:
{
if (src_value > ivorbisfile->vf.links) {
src_value = ivorbisfile->vf.links;
}
for (i = 0; i < src_value; i++) {
vi = ov_info (&ivorbisfile->vf, i);
- if (vi->rate)
- count += ov_pcm_total (&ivorbisfile->vf, i) * GST_SECOND / vi->rate;
+ if (vi->rate)
+ count +=
+ ov_pcm_total (&ivorbisfile->vf, i) * GST_SECOND / vi->rate;
else
- count += ov_time_total (&ivorbisfile->vf, i) * GST_SECOND;
+ count += ov_time_total (&ivorbisfile->vf, i) * GST_SECOND;
}
/* we use the pcm totals to get the total time, it's more accurate */
*dest_value = count;
- break;
+ break;
}
- default:
- res = FALSE;
+ default:
+ res = FALSE;
}
- }
- else
- res = FALSE;
+ } else
+ res = FALSE;
break;
}
return res;
}
static gboolean
-gst_ivorbisfile_sink_convert (GstPad *pad,
- GstFormat src_format, gint64 src_value,
- GstFormat *dest_format, gint64 *dest_value)
+gst_ivorbisfile_sink_convert (GstPad * pad,
+ GstFormat src_format, gint64 src_value,
+ GstFormat * dest_format, gint64 * dest_value)
{
gboolean res = TRUE;
- Ivorbisfile *ivorbisfile;
-
+ Ivorbisfile *ivorbisfile;
+
ivorbisfile = GST_IVORBISFILE (gst_pad_get_parent (pad));
switch (src_format) {
case GST_FORMAT_BYTES:
switch (*dest_format) {
- case GST_FORMAT_TIME:
- break;
- default:
- if (*dest_format == logical_stream_format) {
- }
- else
- res = FALSE;
+ case GST_FORMAT_TIME:
+ break;
+ default:
+ if (*dest_format == logical_stream_format) {
+ } else
+ res = FALSE;
}
case GST_FORMAT_TIME:
switch (*dest_format) {
- case GST_FORMAT_BYTES:
- break;
- default:
- if (*dest_format == logical_stream_format) {
- }
- else
- res = FALSE;
+ case GST_FORMAT_BYTES:
+ break;
+ default:
+ if (*dest_format == logical_stream_format) {
+ } else
+ res = FALSE;
}
default:
if (src_format == logical_stream_format) {
- switch (*dest_format) {
- case GST_FORMAT_TIME:
- break;
- case GST_FORMAT_BYTES:
- break;
- default:
- res = FALSE;
- }
- }
- else
- res = FALSE;
+ switch (*dest_format) {
+ case GST_FORMAT_TIME:
+ break;
+ case GST_FORMAT_BYTES:
+ break;
+ default:
+ res = FALSE;
+ }
+ } else
+ res = FALSE;
break;
}
return res;
}
-static const GstQueryType*
-gst_ivorbisfile_get_query_types (GstPad *pad)
+static const GstQueryType *
+gst_ivorbisfile_get_query_types (GstPad * pad)
{
static const GstQueryType types[] = {
GST_QUERY_TOTAL,
/* handles queries for location in the stream in the requested format */
static gboolean
-gst_ivorbisfile_src_query (GstPad *pad, GstQueryType type,
- GstFormat *format, gint64 *value)
+gst_ivorbisfile_src_query (GstPad * pad, GstQueryType type,
+ GstFormat * format, gint64 * value)
{
gboolean res = TRUE;
- Ivorbisfile *ivorbisfile;
+ Ivorbisfile *ivorbisfile;
vorbis_info *vi;
-
+
ivorbisfile = GST_IVORBISFILE (gst_pad_get_parent (pad));
vi = ov_info (&ivorbisfile->vf, -1);
case GST_QUERY_TOTAL:
{
switch (*format) {
- case GST_FORMAT_DEFAULT:
- if (ivorbisfile->vf.seekable)
+ case GST_FORMAT_DEFAULT:
+ if (ivorbisfile->vf.seekable)
*value = ov_pcm_total (&ivorbisfile->vf, -1);
else
return FALSE;
break;
- case GST_FORMAT_BYTES:
- if (ivorbisfile->vf.seekable)
+ case GST_FORMAT_BYTES:
+ if (ivorbisfile->vf.seekable)
*value = ov_pcm_total (&ivorbisfile->vf, -1) * vi->channels * 2;
else
return FALSE;
break;
- case GST_FORMAT_TIME:
- if (ivorbisfile->vf.seekable)
- *value = (gint64) (ov_time_total (&ivorbisfile->vf, -1) * GST_SECOND);
+ case GST_FORMAT_TIME:
+ if (ivorbisfile->vf.seekable)
+ *value =
+ (gint64) (ov_time_total (&ivorbisfile->vf, -1) * GST_SECOND);
else
return FALSE;
break;
default:
if (*format == logical_stream_format) {
- if (ivorbisfile->vf.seekable)
+ if (ivorbisfile->vf.seekable)
*value = ivorbisfile->vf.links;
else
- return FALSE;
- }
- else
- res = FALSE;
- break;
+ return FALSE;
+ } else
+ res = FALSE;
+ break;
}
break;
}
case GST_QUERY_POSITION:
switch (*format) {
- case GST_FORMAT_TIME:
- if (ivorbisfile->vf.seekable)
+ case GST_FORMAT_TIME:
+ if (ivorbisfile->vf.seekable)
*value = (gint64) (ov_time_tell (&ivorbisfile->vf) * GST_SECOND);
else
- *value = ivorbisfile->total_bytes * GST_SECOND
- / (vi->rate * vi->channels * 2);
+ *value = ivorbisfile->total_bytes * GST_SECOND
+ / (vi->rate * vi->channels * 2);
break;
- case GST_FORMAT_BYTES:
- if (ivorbisfile->vf.seekable)
+ case GST_FORMAT_BYTES:
+ if (ivorbisfile->vf.seekable)
*value = ov_pcm_tell (&ivorbisfile->vf) * vi->channels * 2;
else
- *value = ivorbisfile->total_bytes;
+ *value = ivorbisfile->total_bytes;
break;
- case GST_FORMAT_DEFAULT:
- if (ivorbisfile->vf.seekable)
+ case GST_FORMAT_DEFAULT:
+ if (ivorbisfile->vf.seekable)
*value = ov_pcm_tell (&ivorbisfile->vf);
else
- *value = ivorbisfile->total_bytes / (vi->channels * 2);
+ *value = ivorbisfile->total_bytes / (vi->channels * 2);
break;
- default:
+ default:
if (*format == logical_stream_format) {
- if (ivorbisfile->vf.seekable)
+ if (ivorbisfile->vf.seekable)
*value = ivorbisfile->current_link;
else
- return FALSE;
- }
- else
- res = FALSE;
- break;
+ return FALSE;
+ } else
+ res = FALSE;
+ break;
}
break;
default:
return res;
}
-static const GstEventMask*
-gst_ivorbisfile_get_event_masks (GstPad *pad)
+static const GstEventMask *
+gst_ivorbisfile_get_event_masks (GstPad * pad)
{
static const GstEventMask masks[] = {
- { GST_EVENT_SEEK, GST_SEEK_METHOD_SET | GST_SEEK_FLAG_ACCURATE },
- { 0, }
+ {GST_EVENT_SEEK, GST_SEEK_METHOD_SET | GST_SEEK_FLAG_ACCURATE},
+ {0,}
};
return masks;
}
/* handle events on src pad */
static gboolean
-gst_ivorbisfile_src_event (GstPad *pad, GstEvent *event)
+gst_ivorbisfile_src_event (GstPad * pad, GstEvent * event)
{
gboolean res = TRUE;
- Ivorbisfile *ivorbisfile;
-
+ Ivorbisfile *ivorbisfile;
+
ivorbisfile = GST_IVORBISFILE (gst_pad_get_parent (pad));
switch (GST_EVENT_TYPE (event)) {
gint64 offset;
vorbis_info *vi;
GstFormat format;
-
+
GST_DEBUG ("ivorbisfile: handling seek event on pad %s:%s",
- GST_DEBUG_PAD_NAME (pad));
+ GST_DEBUG_PAD_NAME (pad));
if (!ivorbisfile->vf.seekable) {
gst_event_unref (event);
GST_DEBUG ("vorbis stream is not seekable");
- return FALSE;
+ return FALSE;
}
offset = GST_EVENT_SEEK_OFFSET (event);
ivorbisfile->seek_pending = TRUE;
ivorbisfile->seek_value = offset;
ivorbisfile->seek_format = format;
- ivorbisfile->seek_accurate = GST_EVENT_SEEK_FLAGS (event)
- & GST_SEEK_FLAG_ACCURATE;
+ ivorbisfile->seek_accurate = GST_EVENT_SEEK_FLAGS (event)
+ & GST_SEEK_FLAG_ACCURATE;
break;
case GST_FORMAT_BYTES:
- vi = ov_info (&ivorbisfile->vf, -1);
+ vi = ov_info (&ivorbisfile->vf, -1);
if (vi->channels == 0) {
GST_DEBUG ("vorbis stream has 0 channels ?");
res = FALSE;
- goto done;
+ goto done;
}
- offset /= vi->channels * 2;
+ offset /= vi->channels * 2;
/* fallthrough */
case GST_FORMAT_DEFAULT:
ivorbisfile->seek_pending = TRUE;
ivorbisfile->seek_value = offset;
ivorbisfile->seek_format = format;
- ivorbisfile->seek_accurate = GST_EVENT_SEEK_FLAGS (event)
- & GST_SEEK_FLAG_ACCURATE;
+ ivorbisfile->seek_accurate = GST_EVENT_SEEK_FLAGS (event)
+ & GST_SEEK_FLAG_ACCURATE;
break;
default:
if (format == logical_stream_format) {
ivorbisfile->seek_pending = TRUE;
ivorbisfile->seek_value = offset;
ivorbisfile->seek_format = format;
- ivorbisfile->seek_accurate = GST_EVENT_SEEK_FLAGS (event)
- & GST_SEEK_FLAG_ACCURATE;
- }
- else
- {
+ ivorbisfile->seek_accurate = GST_EVENT_SEEK_FLAGS (event)
+ & GST_SEEK_FLAG_ACCURATE;
+ } else {
GST_DEBUG ("unhandled seek format");
res = FALSE;
}
}
static GstElementStateReturn
-gst_ivorbisfile_change_state (GstElement *element)
+gst_ivorbisfile_change_state (GstElement * element)
{
Ivorbisfile *ivorbisfile = GST_IVORBISFILE (element);
-
+
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY:
case GST_STATE_READY_TO_PAUSED:
if (GST_ELEMENT_CLASS (parent_class)->change_state)
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
-
+
return GST_STATE_SUCCESS;
}
static void
-gst_ivorbisfile_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
+gst_ivorbisfile_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
Ivorbisfile *ivorbisfile;
-
+
g_return_if_fail (GST_IS_IVORBISFILE (object));
ivorbisfile = GST_IVORBISFILE (object);
}
}
-static void
-gst_ivorbisfile_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
+static void
+gst_ivorbisfile_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
Ivorbisfile *ivorbisfile;
-
+
g_return_if_fail (GST_IS_IVORBISFILE (object));
ivorbisfile = GST_IVORBISFILE (object);
/* elementfactory information */
static GstElementDetails gst_jack_bin_details = {
- "Jack Bin",
- "Generic/Bin",
- "Jack processing bin",
- "Andy Wingo <wingo@pobox.com>",
+ "Jack Bin",
+ "Generic/Bin",
+ "Jack processing bin",
+ "Andy Wingo <wingo@pobox.com>",
};
-static GstElementDetails gst_jack_sink_details = {
- "Jack Sink",
- "Sink/Audio",
- "Output to a Jack processing network",
- "Andy Wingo <wingo@pobox.com>",
+static GstElementDetails gst_jack_sink_details = {
+ "Jack Sink",
+ "Sink/Audio",
+ "Output to a Jack processing network",
+ "Andy Wingo <wingo@pobox.com>",
};
-static GstElementDetails gst_jack_src_details = {
- "Jack Src",
- "Source/Audio",
- "Input from a Jack processing network",
- "Andy Wingo <wingo@pobox.com>",
+static GstElementDetails gst_jack_src_details = {
+ "Jack Src",
+ "Source/Audio",
+ "Input from a Jack processing network",
+ "Andy Wingo <wingo@pobox.com>",
};
static GHashTable *port_name_counts = NULL;
static GstElementClass *parent_class = NULL;
-static void gst_jack_base_init (gpointer g_class);
-static void gst_jack_src_base_init (gpointer g_class);
-static void gst_jack_sink_base_init (gpointer g_class);
-static void gst_jack_init(GstJack *this);
-static void gst_jack_class_init(GstJackClass *klass);
-static void gst_jack_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_jack_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
-
-static GstPadTemplate* gst_jack_src_request_pad_factory();
-static GstPadTemplate* gst_jack_sink_request_pad_factory();
-static GstPad* gst_jack_request_new_pad (GstElement *element, GstPadTemplate *templ,
- const gchar *name);
-static GstElementStateReturn gst_jack_change_state (GstElement *element);
-static GstPadLinkReturn gst_jack_link (GstPad *pad, const GstCaps *caps);
-
-static void gst_jack_loop (GstElement *element);
-
-
-enum {
- ARG_0,
- ARG_PORT_NAME_PREFIX,
+static void gst_jack_base_init (gpointer g_class);
+static void gst_jack_src_base_init (gpointer g_class);
+static void gst_jack_sink_base_init (gpointer g_class);
+static void gst_jack_init (GstJack * this);
+static void gst_jack_class_init (GstJackClass * klass);
+static void gst_jack_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_jack_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+
+static GstPadTemplate *gst_jack_src_request_pad_factory ();
+static GstPadTemplate *gst_jack_sink_request_pad_factory ();
+static GstPad *gst_jack_request_new_pad (GstElement * element,
+ GstPadTemplate * templ, const gchar * name);
+static GstElementStateReturn gst_jack_change_state (GstElement * element);
+static GstPadLinkReturn gst_jack_link (GstPad * pad, const GstCaps * caps);
+
+static void gst_jack_loop (GstElement * element);
+
+
+enum
+{
+ ARG_0,
+ ARG_PORT_NAME_PREFIX,
};
GType
-gst_jack_get_type (void)
+gst_jack_get_type (void)
{
static GType jack_type = 0;
if (!jack_type) {
static const GTypeInfo jack_info = {
- sizeof(GstJackClass),
+ sizeof (GstJackClass),
gst_jack_base_init,
NULL,
NULL,
NULL,
NULL,
- sizeof(GstJack),
+ sizeof (GstJack),
0,
NULL,
};
- jack_type = g_type_register_static (GST_TYPE_ELEMENT, "GstJack", &jack_info, 0);
+ jack_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstJack", &jack_info, 0);
}
return jack_type;
}
GType
-gst_jack_sink_get_type (void)
+gst_jack_sink_get_type (void)
{
static GType jack_type = 0;
-
+
if (!jack_type) {
static const GTypeInfo jack_info = {
- sizeof(GstJackClass),
+ sizeof (GstJackClass),
gst_jack_sink_base_init,
NULL,
- (GClassInitFunc)gst_jack_class_init,
+ (GClassInitFunc) gst_jack_class_init,
NULL,
NULL,
- sizeof(GstJack),
+ sizeof (GstJack),
0,
- (GInstanceInitFunc)gst_jack_init,
+ (GInstanceInitFunc) gst_jack_init,
};
- jack_type = g_type_register_static (GST_TYPE_JACK, "GstJackSink", &jack_info, 0);
+ jack_type =
+ g_type_register_static (GST_TYPE_JACK, "GstJackSink", &jack_info, 0);
}
return jack_type;
}
GType
-gst_jack_src_get_type (void)
+gst_jack_src_get_type (void)
{
static GType jack_type = 0;
-
+
if (!jack_type) {
static const GTypeInfo jack_info = {
- sizeof(GstJackClass),
+ sizeof (GstJackClass),
gst_jack_src_base_init,
NULL,
- (GClassInitFunc)gst_jack_class_init,
+ (GClassInitFunc) gst_jack_class_init,
NULL,
NULL,
- sizeof(GstJack),
+ sizeof (GstJack),
0,
- (GInstanceInitFunc)gst_jack_init,
+ (GInstanceInitFunc) gst_jack_init,
};
- jack_type = g_type_register_static (GST_TYPE_JACK, "GstJackSrc", &jack_info, 0);
+ jack_type =
+ g_type_register_static (GST_TYPE_JACK, "GstJackSrc", &jack_info, 0);
}
return jack_type;
}
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_pad_template (element_class, gst_jack_src_request_pad_factory ());
+ gst_element_class_add_pad_template (element_class,
+ gst_jack_src_request_pad_factory ());
gst_element_class_set_details (element_class, &gst_jack_src_details);
}
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_pad_template (element_class, gst_jack_sink_request_pad_factory ());
+ gst_element_class_add_pad_template (element_class,
+ gst_jack_sink_request_pad_factory ());
gst_element_class_set_details (element_class, &gst_jack_sink_details);
}
static void
-gst_jack_class_init(GstJackClass *klass)
+gst_jack_class_init (GstJackClass * klass)
{
- GObjectClass *object_class;
- GstElementClass *element_class;
- GParamSpec *pspec;
- gchar *prefix;
-
- object_class = (GObjectClass *)klass;
- element_class = (GstElementClass *)klass;
-
- if (parent_class == NULL)
- parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
-
- object_class->get_property = gst_jack_get_property;
- object_class->set_property = gst_jack_set_property;
-
- if (GST_IS_JACK_SINK_CLASS (klass))
- prefix = "gst-out-";
- else
- prefix = "gst-in-";
-
- pspec = g_param_spec_string ("port-name-prefix", "Port name prefix",
- "String to prepend to jack port names",
- prefix, G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
- g_object_class_install_property (object_class, ARG_PORT_NAME_PREFIX, pspec);
-
- element_class->change_state = gst_jack_change_state;
-
- element_class->request_new_pad = gst_jack_request_new_pad;
+ GObjectClass *object_class;
+ GstElementClass *element_class;
+ GParamSpec *pspec;
+ gchar *prefix;
+
+ object_class = (GObjectClass *) klass;
+ element_class = (GstElementClass *) klass;
+
+ if (parent_class == NULL)
+ parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
+
+ object_class->get_property = gst_jack_get_property;
+ object_class->set_property = gst_jack_set_property;
+
+ if (GST_IS_JACK_SINK_CLASS (klass))
+ prefix = "gst-out-";
+ else
+ prefix = "gst-in-";
+
+ pspec = g_param_spec_string ("port-name-prefix", "Port name prefix",
+ "String to prepend to jack port names",
+ prefix, G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
+ g_object_class_install_property (object_class, ARG_PORT_NAME_PREFIX, pspec);
+
+ element_class->change_state = gst_jack_change_state;
+
+ element_class->request_new_pad = gst_jack_request_new_pad;
}
static void
-gst_jack_init(GstJack *this)
+gst_jack_init (GstJack * this)
{
- if (G_OBJECT_TYPE (this) == GST_TYPE_JACK_SRC)
- this->direction = GST_PAD_SRC;
- else if (G_OBJECT_TYPE (this) == GST_TYPE_JACK_SINK)
- this->direction = GST_PAD_SINK;
- else
- g_assert_not_reached ();
-
- gst_element_set_loop_function (GST_ELEMENT (this), gst_jack_loop);
+ if (G_OBJECT_TYPE (this) == GST_TYPE_JACK_SRC)
+ this->direction = GST_PAD_SRC;
+ else if (G_OBJECT_TYPE (this) == GST_TYPE_JACK_SINK)
+ this->direction = GST_PAD_SINK;
+ else
+ g_assert_not_reached ();
+
+ gst_element_set_loop_function (GST_ELEMENT (this), gst_jack_loop);
}
static void
-gst_jack_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_jack_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
- GstJack *this = (GstJack*)object;
+ GstJack *this = (GstJack *) object;
- switch (prop_id) {
+ switch (prop_id) {
case ARG_PORT_NAME_PREFIX:
- if (this->port_name_prefix)
- g_free (this->port_name_prefix);
- this->port_name_prefix = g_strdup (g_value_get_string (value));
- break;
+ if (this->port_name_prefix)
+ g_free (this->port_name_prefix);
+ this->port_name_prefix = g_strdup (g_value_get_string (value));
+ break;
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- return;
- }
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ return;
+ }
}
static void
-gst_jack_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_jack_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
- GstJack *this = (GstJack*)object;
+ GstJack *this = (GstJack *) object;
- switch (prop_id) {
+ switch (prop_id) {
case ARG_PORT_NAME_PREFIX:
- g_value_set_string (value, this->port_name_prefix);
- break;
+ g_value_set_string (value, this->port_name_prefix);
+ break;
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
-static GstPadTemplate*
+static GstPadTemplate *
gst_jack_src_request_pad_factory (void)
{
- static GstPadTemplate *template = NULL;
-
- if (!template) {
- GstCaps *caps;
- caps = gst_caps_from_string (GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS);
- template = gst_pad_template_new ("%s", GST_PAD_SRC,
- GST_PAD_REQUEST, caps);
- }
-
- return template;
+ static GstPadTemplate *template = NULL;
+
+ if (!template) {
+ GstCaps *caps;
+
+ caps = gst_caps_from_string (GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS);
+ template = gst_pad_template_new ("%s", GST_PAD_SRC, GST_PAD_REQUEST, caps);
+ }
+
+ return template;
}
-static GstPadTemplate*
+static GstPadTemplate *
gst_jack_sink_request_pad_factory (void)
{
- static GstPadTemplate *template = NULL;
-
- if (!template) {
- GstCaps *caps;
- caps = gst_caps_from_string (GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS);
- template = gst_pad_template_new ("%s", GST_PAD_SINK,
- GST_PAD_REQUEST, caps);
- }
-
- return template;
+ static GstPadTemplate *template = NULL;
+
+ if (!template) {
+ GstCaps *caps;
+
+ caps = gst_caps_from_string (GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS);
+ template = gst_pad_template_new ("%s", GST_PAD_SINK, GST_PAD_REQUEST, caps);
+ }
+
+ return template;
}
-static GstPad*
-gst_jack_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar *name)
+static GstPad *
+gst_jack_request_new_pad (GstElement * element, GstPadTemplate * templ,
+ const gchar * name)
{
- GstJack *this;
- gchar *newname;
- GList *l, **pad_list;
- GstJackPad *pad;
- gint count;
-
- g_return_val_if_fail ((this = GST_JACK (element)), NULL);
-
- if (!this->bin)
- pad_list = &this->pads;
- else if (this->direction == GST_PAD_SRC)
- pad_list = &this->bin->src_pads;
- else
- pad_list = &this->bin->sink_pads;
-
- if (name) {
- l = *pad_list;
- while (l) {
- if (strcmp (GST_JACK_PAD(l)->name, name) == 0) {
- g_warning("requested port name %s already in use.", name);
- return NULL;
- }
- l = l->next;
- }
- newname = g_strdup (name);
- } else {
- if (this->direction == GST_PAD_SINK)
- newname = g_strdup ("alsa_pcm:playback_1");
- else
- newname = g_strdup ("alsa_pcm:capture_1");
+ GstJack *this;
+ gchar *newname;
+ GList *l, **pad_list;
+ GstJackPad *pad;
+ gint count;
+
+ g_return_val_if_fail ((this = GST_JACK (element)), NULL);
+
+ if (!this->bin)
+ pad_list = &this->pads;
+ else if (this->direction == GST_PAD_SRC)
+ pad_list = &this->bin->src_pads;
+ else
+ pad_list = &this->bin->sink_pads;
+
+ if (name) {
+ l = *pad_list;
+ while (l) {
+ if (strcmp (GST_JACK_PAD (l)->name, name) == 0) {
+ g_warning ("requested port name %s already in use.", name);
+ return NULL;
+ }
+ l = l->next;
}
-
- pad = g_new0 (GstJackPad, 1);
-
- if (!port_name_counts)
- port_name_counts = g_hash_table_new (g_str_hash, g_str_equal);
-
- count = GPOINTER_TO_INT (g_hash_table_lookup (port_name_counts, this->port_name_prefix));
- g_hash_table_insert (port_name_counts, g_strdup (this->port_name_prefix), GINT_TO_POINTER (count+1));
-
- pad->name = g_strdup_printf ("%s%d", this->port_name_prefix, count);
-
- pad->peer_name = newname;
- pad->pad = gst_pad_new_from_template (templ, newname);
- gst_element_add_pad (GST_ELEMENT (this), pad->pad);
- gst_pad_set_link_function (pad->pad, gst_jack_link);
-
- this->pads = g_list_append (this->pads, pad);
-
- g_print ("returning from request_new_pad, pad %s created, to connect to %s\n", pad->name, pad->peer_name);
- return pad->pad;
+ newname = g_strdup (name);
+ } else {
+ if (this->direction == GST_PAD_SINK)
+ newname = g_strdup ("alsa_pcm:playback_1");
+ else
+ newname = g_strdup ("alsa_pcm:capture_1");
+ }
+
+ pad = g_new0 (GstJackPad, 1);
+
+ if (!port_name_counts)
+ port_name_counts = g_hash_table_new (g_str_hash, g_str_equal);
+
+ count =
+ GPOINTER_TO_INT (g_hash_table_lookup (port_name_counts,
+ this->port_name_prefix));
+ g_hash_table_insert (port_name_counts, g_strdup (this->port_name_prefix),
+ GINT_TO_POINTER (count + 1));
+
+ pad->name = g_strdup_printf ("%s%d", this->port_name_prefix, count);
+
+ pad->peer_name = newname;
+ pad->pad = gst_pad_new_from_template (templ, newname);
+ gst_element_add_pad (GST_ELEMENT (this), pad->pad);
+ gst_pad_set_link_function (pad->pad, gst_jack_link);
+
+ this->pads = g_list_append (this->pads, pad);
+
+ g_print ("returning from request_new_pad, pad %s created, to connect to %s\n",
+ pad->name, pad->peer_name);
+ return pad->pad;
}
static GstElementStateReturn
-gst_jack_change_state (GstElement *element)
+gst_jack_change_state (GstElement * element)
{
- GstJack *this;
- GList *l = NULL, **pads;
- GstJackPad *pad;
- GstCaps *caps;
-
- g_return_val_if_fail (element != NULL, FALSE);
- this = GST_JACK (element);
-
- switch (GST_STATE_PENDING (element)) {
+ GstJack *this;
+ GList *l = NULL, **pads;
+ GstJackPad *pad;
+ GstCaps *caps;
+
+ g_return_val_if_fail (element != NULL, FALSE);
+ this = GST_JACK (element);
+
+ switch (GST_STATE_PENDING (element)) {
case GST_STATE_NULL:
- JACK_DEBUG ("%s: NULL", GST_OBJECT_NAME (GST_OBJECT (this)));
+ JACK_DEBUG ("%s: NULL", GST_OBJECT_NAME (GST_OBJECT (this)));
+
+ break;
- break;
-
case GST_STATE_READY:
- JACK_DEBUG ("%s: READY", GST_OBJECT_NAME (GST_OBJECT (this)));
-
- if (!this->bin) {
- if (!(this->bin = (GstJackBin*)gst_element_get_managing_bin (element))
- || !GST_IS_JACK_BIN (this->bin)) {
- this->bin = NULL;
- g_warning ("jack element %s needs to be contained in a jack bin.",
- GST_OBJECT_NAME (element));
- return GST_STATE_FAILURE;
- }
-
- /* fixme: verify that all names are unique */
- l = this->pads;
- pads = (this->direction == GST_PAD_SRC) ? &this->bin->src_pads : &this->bin->sink_pads;
- while (l) {
- pad = GST_JACK_PAD (l);
- JACK_DEBUG ("%s: appending pad %s:%s to list", GST_OBJECT_NAME (this), pad->name, pad->peer_name);
- *pads = g_list_append (*pads, pad);
- l = g_list_next (l);
- }
- }
- break;
-
+ JACK_DEBUG ("%s: READY", GST_OBJECT_NAME (GST_OBJECT (this)));
+
+ if (!this->bin) {
+ if (!(this->bin = (GstJackBin *) gst_element_get_managing_bin (element))
+ || !GST_IS_JACK_BIN (this->bin)) {
+ this->bin = NULL;
+ g_warning ("jack element %s needs to be contained in a jack bin.",
+ GST_OBJECT_NAME (element));
+ return GST_STATE_FAILURE;
+ }
+
+ /* fixme: verify that all names are unique */
+ l = this->pads;
+ pads =
+ (this->direction ==
+ GST_PAD_SRC) ? &this->bin->src_pads : &this->bin->sink_pads;
+ while (l) {
+ pad = GST_JACK_PAD (l);
+ JACK_DEBUG ("%s: appending pad %s:%s to list", GST_OBJECT_NAME (this),
+ pad->name, pad->peer_name);
+ *pads = g_list_append (*pads, pad);
+ l = g_list_next (l);
+ }
+ }
+ break;
+
case GST_STATE_PAUSED:
- JACK_DEBUG ("%s: PAUSED", GST_OBJECT_NAME (GST_OBJECT (this)));
-
- if (GST_STATE (element) == GST_STATE_READY) {
- /* we're in READY->PAUSED */
- l = this->pads;
- while (l) {
- pad = GST_JACK_PAD (l);
- caps = gst_caps_copy (gst_pad_get_negotiated_caps (pad->pad));
- gst_caps_set_simple (caps,
- "rate", G_TYPE_INT, (int)this->bin->rate,
- "buffer-frames", G_TYPE_INT, (gint)this->bin->nframes,
- NULL);
- if (gst_pad_try_set_caps (pad->pad, caps) <= 0)
- return GST_STATE_FAILURE;
- l = g_list_next (l);
- }
- }
- break;
+ JACK_DEBUG ("%s: PAUSED", GST_OBJECT_NAME (GST_OBJECT (this)));
+
+ if (GST_STATE (element) == GST_STATE_READY) {
+ /* we're in READY->PAUSED */
+ l = this->pads;
+ while (l) {
+ pad = GST_JACK_PAD (l);
+ caps = gst_caps_copy (gst_pad_get_negotiated_caps (pad->pad));
+ gst_caps_set_simple (caps,
+ "rate", G_TYPE_INT, (int) this->bin->rate,
+ "buffer-frames", G_TYPE_INT, (gint) this->bin->nframes, NULL);
+ if (gst_pad_try_set_caps (pad->pad, caps) <= 0)
+ return GST_STATE_FAILURE;
+ l = g_list_next (l);
+ }
+ }
+ break;
case GST_STATE_PLAYING:
- JACK_DEBUG ("%s: PLAYING", GST_OBJECT_NAME (GST_OBJECT (this)));
- break;
- }
-
- JACK_DEBUG ("%s: state change finished", GST_OBJECT_NAME (this));
-
- if (GST_ELEMENT_CLASS (parent_class)->change_state)
- return GST_ELEMENT_CLASS (parent_class)->change_state (element);
+ JACK_DEBUG ("%s: PLAYING", GST_OBJECT_NAME (GST_OBJECT (this)));
+ break;
+ }
+
+ JACK_DEBUG ("%s: state change finished", GST_OBJECT_NAME (this));
- return GST_STATE_SUCCESS;
+ if (GST_ELEMENT_CLASS (parent_class)->change_state)
+ return GST_ELEMENT_CLASS (parent_class)->change_state (element);
+
+ return GST_STATE_SUCCESS;
}
static GstPadLinkReturn
-gst_jack_link (GstPad *pad, const GstCaps *caps)
+gst_jack_link (GstPad * pad, const GstCaps * caps)
{
GstJack *this;
gint rate, buffer_frames;
GstStructure *structure;
-
+
this = GST_JACK (GST_OBJECT_PARENT (pad));
-
+
structure = gst_caps_get_structure (caps, 0);
- gst_structure_get_int (structure, "rate", &rate);
- gst_structure_get_int (structure, "buffer-frames", &buffer_frames);
+ gst_structure_get_int (structure, "rate", &rate);
+ gst_structure_get_int (structure, "buffer-frames", &buffer_frames);
if (this->bin && (rate != this->bin->rate ||
- buffer_frames != this->bin->nframes))
- return GST_PAD_LINK_REFUSED;
-
+ buffer_frames != this->bin->nframes))
+ return GST_PAD_LINK_REFUSED;
+
return GST_PAD_LINK_OK;
}
static void
-gst_jack_loop (GstElement *element)
+gst_jack_loop (GstElement * element)
{
- GstJack *this;
- GList *pads;
- gint len;
- GstJackPad *pad;
- GstBuffer *buffer;
-
- this = GST_JACK (element);
-
- len = this->bin->nframes * sizeof (sample_t);
-
- pads = this->pads;
- while (pads) {
- pad = GST_JACK_PAD (pads);
-
- if (this->direction == GST_PAD_SINK) {
- buffer = GST_BUFFER (gst_pad_pull (pad->pad));
-
- if (GST_IS_EVENT (buffer)) {
- GstEvent *event = GST_EVENT (buffer);
- switch (GST_EVENT_TYPE (buffer)) {
- case GST_EVENT_EOS:
- gst_element_set_eos (element);
- gst_event_unref (event);
- return;
- default:
- gst_pad_event_default (pad->pad, event);
- return;
- }
- }
-
- /* if the other plugins only give out buffer-frames or less (as
- they should), if the length of the GstBuffer is different
- from nframes then the buffer is short and we will get EOS
- next */
- memcpy (pad->data, GST_BUFFER_DATA (buffer),
- GST_BUFFER_SIZE (buffer));
- if (len != GST_BUFFER_SIZE (buffer))
- memset (pad->data + GST_BUFFER_SIZE (buffer), 0,
- len - GST_BUFFER_SIZE (buffer));
-
- gst_buffer_unref (buffer);
- } else {
- buffer = gst_buffer_new ();
- gst_buffer_set_data (buffer, pad->data, len);
- GST_BUFFER_FLAG_SET(buffer, GST_BUFFER_DONTFREE);
-
- gst_pad_push (pad->pad, GST_DATA (buffer));
- }
- pads = g_list_next (pads);
+ GstJack *this;
+ GList *pads;
+ gint len;
+ GstJackPad *pad;
+ GstBuffer *buffer;
+
+ this = GST_JACK (element);
+
+ len = this->bin->nframes * sizeof (sample_t);
+
+ pads = this->pads;
+ while (pads) {
+ pad = GST_JACK_PAD (pads);
+
+ if (this->direction == GST_PAD_SINK) {
+ buffer = GST_BUFFER (gst_pad_pull (pad->pad));
+
+ if (GST_IS_EVENT (buffer)) {
+ GstEvent *event = GST_EVENT (buffer);
+
+ switch (GST_EVENT_TYPE (buffer)) {
+ case GST_EVENT_EOS:
+ gst_element_set_eos (element);
+ gst_event_unref (event);
+ return;
+ default:
+ gst_pad_event_default (pad->pad, event);
+ return;
+ }
+ }
+
+ /* if the other plugins only give out buffer-frames or less (as
+ they should), if the length of the GstBuffer is different
+ from nframes then the buffer is short and we will get EOS
+ next */
+ memcpy (pad->data, GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer));
+ if (len != GST_BUFFER_SIZE (buffer))
+ memset (pad->data + GST_BUFFER_SIZE (buffer), 0,
+ len - GST_BUFFER_SIZE (buffer));
+
+ gst_buffer_unref (buffer);
+ } else {
+ buffer = gst_buffer_new ();
+ gst_buffer_set_data (buffer, pad->data, len);
+ GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_DONTFREE);
+
+ gst_pad_push (pad->pad, GST_DATA (buffer));
}
+ pads = g_list_next (pads);
+ }
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- if (!gst_element_register (plugin, "jackbin", GST_RANK_NONE, GST_TYPE_JACK_BIN))
+ if (!gst_element_register (plugin, "jackbin", GST_RANK_NONE,
+ GST_TYPE_JACK_BIN))
return FALSE;
- if (!gst_element_register (plugin, "jacksrc", GST_RANK_NONE, GST_TYPE_JACK_SRC))
+ if (!gst_element_register (plugin, "jacksrc", GST_RANK_NONE,
+ GST_TYPE_JACK_SRC))
return FALSE;
- if (!gst_element_register (plugin, "jacksink", GST_RANK_NONE, GST_TYPE_JACK_SINK))
+ if (!gst_element_register (plugin, "jacksink", GST_RANK_NONE,
+ GST_TYPE_JACK_SINK))
return FALSE;
-
+
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "jack",
- "Jack Plugin Library",
- plugin_init,
- VERSION,
- "GPL",
- GST_PACKAGE,
- GST_ORIGIN)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "jack",
+ "Jack Plugin Library", plugin_init, VERSION, "GPL", GST_PACKAGE, GST_ORIGIN)
#define GST_IS_JACK_BIN_CLASS(klass) G_TYPE_CHECK_CLASS_TYPE(klass, GST_TYPE_JACK_BIN)
#define GST_TYPE_JACK_BIN gst_jack_bin_get_type()
-#define GST_JACK_PAD(l) ((GstJackPad*)l->data) /* l is a GList */
+#define GST_JACK_PAD(l) ((GstJackPad*)l->data) /* l is a GList */
typedef struct _GstJack GstJack;
typedef GstJackClass GstJackSrcClass;
-enum {
- GST_JACK_OPEN = GST_BIN_FLAG_LAST,
- GST_JACK_ACTIVE,
- GST_JACK_FLAG_LAST = GST_BIN_FLAG_LAST + 3,
+enum
+{
+ GST_JACK_OPEN = GST_BIN_FLAG_LAST,
+ GST_JACK_ACTIVE,
+ GST_JACK_FLAG_LAST = GST_BIN_FLAG_LAST + 3,
};
typedef jack_default_audio_sample_t sample_t;
-typedef struct {
- GstPad *pad;
- void *data;
- const gchar *name;
- const gchar *peer_name;
- jack_port_t *port;
+typedef struct
+{
+ GstPad *pad;
+ void *data;
+ const gchar *name;
+ const gchar *peer_name;
+ jack_port_t *port;
} GstJackPad;
-struct _GstJack {
- GstElement element;
+struct _GstJack
+{
+ GstElement element;
- /* list of GstJackPads */
- GList *pads;
+ /* list of GstJackPads */
+ GList *pads;
- /* for convenience */
- GstPadDirection direction;
+ /* for convenience */
+ GstPadDirection direction;
- gchar *port_name_prefix;
+ gchar *port_name_prefix;
- GstJackBin *bin;
+ GstJackBin *bin;
};
-struct _GstJackClass {
- GstElementClass parent_class;
+struct _GstJackClass
+{
+ GstElementClass parent_class;
};
-struct _GstJackBin {
- GstBin bin;
+struct _GstJackBin
+{
+ GstBin bin;
- jack_client_t *client;
- gint default_new_port_number;
+ jack_client_t *client;
+ gint default_new_port_number;
- /* lists of GstJackPads */
- GList *sink_pads;
- GList *src_pads;
+ /* lists of GstJackPads */
+ GList *sink_pads;
+ GList *src_pads;
- gchar *client_name;
+ gchar *client_name;
- guint rate;
- jack_nframes_t nframes;
+ guint rate;
+ jack_nframes_t nframes;
};
-struct _GstJackBinClass {
- GstBinClass parent_class;
+struct _GstJackBinClass
+{
+ GstBinClass parent_class;
};
static GstBinClass *parent_class = NULL;
-static void gst_jack_bin_init(GstJackBin *this);
-static void gst_jack_bin_class_init(GstJackBinClass *klass);
+static void gst_jack_bin_init (GstJackBin * this);
+static void gst_jack_bin_class_init (GstJackBinClass * klass);
-static GstElementStateReturn gst_jack_bin_change_state(GstElement *element);
+static GstElementStateReturn gst_jack_bin_change_state (GstElement * element);
/* jack callbacks */
static int process (jack_nframes_t nframes, void *arg);
* so set the state of the bin to READY. */
GType
-gst_jack_bin_get_type (void)
+gst_jack_bin_get_type (void)
{
- static GType jack_bin_type = 0;
-if (!jack_bin_type) {
- static const GTypeInfo jack_bin_info = {
- sizeof(GstJackBinClass),
- NULL,
- NULL,
- (GClassInitFunc)gst_jack_bin_class_init,
- NULL,
- NULL,
- sizeof(GstJackBin),
- 0,
- (GInstanceInitFunc)gst_jack_bin_init,
- };
- jack_bin_type = g_type_register_static (GST_TYPE_BIN, "GstJackBin", &jack_bin_info, 0);
- }
- return jack_bin_type;
+ static GType jack_bin_type = 0;
+
+ if (!jack_bin_type) {
+ static const GTypeInfo jack_bin_info = {
+ sizeof (GstJackBinClass),
+ NULL,
+ NULL,
+ (GClassInitFunc) gst_jack_bin_class_init,
+ NULL,
+ NULL,
+ sizeof (GstJackBin),
+ 0,
+ (GInstanceInitFunc) gst_jack_bin_init,
+ };
+ jack_bin_type =
+ g_type_register_static (GST_TYPE_BIN, "GstJackBin", &jack_bin_info, 0);
+ }
+ return jack_bin_type;
}
static void
-gst_jack_bin_class_init(GstJackBinClass *klass)
+gst_jack_bin_class_init (GstJackBinClass * klass)
{
- GObjectClass *object_class;
- GstElementClass *element_class;
-
- object_class = (GObjectClass *)klass;
- element_class = (GstElementClass *)klass;
-
- parent_class = g_type_class_ref(GST_TYPE_BIN);
-
- element_class->change_state = gst_jack_bin_change_state;
+ GObjectClass *object_class;
+ GstElementClass *element_class;
+
+ object_class = (GObjectClass *) klass;
+ element_class = (GstElementClass *) klass;
+
+ parent_class = g_type_class_ref (GST_TYPE_BIN);
+
+ element_class->change_state = gst_jack_bin_change_state;
}
static void
-gst_jack_bin_init(GstJackBin *this)
+gst_jack_bin_init (GstJackBin * this)
{
- GST_DEBUG ("initializing jack bin");
-
- /* jack bins are managing bins and iterate themselves */
- GST_FLAG_SET (this, GST_BIN_FLAG_MANAGER);
- GST_FLAG_SET (this, GST_BIN_SELF_SCHEDULABLE);
-
- /* make a new scheduler and associate it with the bin */
- gst_scheduler_factory_make (NULL, GST_ELEMENT (this));
+ GST_DEBUG ("initializing jack bin");
+
+ /* jack bins are managing bins and iterate themselves */
+ GST_FLAG_SET (this, GST_BIN_FLAG_MANAGER);
+ GST_FLAG_SET (this, GST_BIN_SELF_SCHEDULABLE);
+
+ /* make a new scheduler and associate it with the bin */
+ gst_scheduler_factory_make (NULL, GST_ELEMENT (this));
}
static GstElementStateReturn
-gst_jack_bin_change_state (GstElement *element)
+gst_jack_bin_change_state (GstElement * element)
{
- GstJackBin *this;
- GList *l = NULL;
- GstJackPad *pad;
-
- g_return_val_if_fail (element != NULL, FALSE);
- this = GST_JACK_BIN (element);
-
- switch (GST_STATE_PENDING (element)) {
+ GstJackBin *this;
+ GList *l = NULL;
+ GstJackPad *pad;
+
+ g_return_val_if_fail (element != NULL, FALSE);
+ this = GST_JACK_BIN (element);
+
+ switch (GST_STATE_PENDING (element)) {
case GST_STATE_NULL:
- JACK_DEBUG ("jackbin: NULL state");
- if (this->client) {
- JACK_DEBUG ("jackbin: closing client");
- jack_client_close (this->client);
- this->client = NULL;
- }
-
- if (_jackbin)
- signal (SIGHUP, SIG_DFL);
- _jackbin = NULL;
-
- if (GST_ELEMENT_CLASS (parent_class)->change_state)
- return GST_ELEMENT_CLASS (parent_class)->change_state (element);
- break;
-
+ JACK_DEBUG ("jackbin: NULL state");
+ if (this->client) {
+ JACK_DEBUG ("jackbin: closing client");
+ jack_client_close (this->client);
+ this->client = NULL;
+ }
+
+ if (_jackbin)
+ signal (SIGHUP, SIG_DFL);
+ _jackbin = NULL;
+
+ if (GST_ELEMENT_CLASS (parent_class)->change_state)
+ return GST_ELEMENT_CLASS (parent_class)->change_state (element);
+ break;
+
case GST_STATE_READY:
- JACK_DEBUG ("jackbin: READY");
-
- _jackbin = this;
- signal (SIGHUP, sighup_handler);
-
- if (!this->client) {
- if (!(this->client = jack_client_new ("gst-jack"))) {
- g_warning ("jack server not running?");
- return GST_STATE_FAILURE;
- }
-
- gst_scheduler_setup (GST_ELEMENT_SCHED (this));
-
- jack_set_process_callback (this->client, process, this);
- jack_set_sample_rate_callback (this->client, sample_rate, this);
- jack_set_buffer_size_callback (this->client, buffer_size, this);
- this->nframes = jack_get_buffer_size (this->client);
- jack_on_shutdown (this->client, shutdown, this);
- }
-
- if (GST_FLAG_IS_SET (GST_OBJECT (this), GST_JACK_OPEN)) {
- l = this->src_pads;
- while (l) {
- JACK_DEBUG ("jackbin: unregistering pad %s:%s", GST_JACK_PAD (l)->name, GST_JACK_PAD (l)->peer_name);
- jack_port_unregister (this->client, GST_JACK_PAD (l)->port);
- l = g_list_next (l);
- }
- l = this->sink_pads;
- while (l) {
- JACK_DEBUG ("jackbin: unregistering pad %s:%s", GST_JACK_PAD (l)->name, GST_JACK_PAD (l)->peer_name);
- jack_port_unregister (this->client, GST_JACK_PAD (l)->port);
- l = g_list_next (l);
- }
- GST_FLAG_UNSET (GST_OBJECT (this), GST_JACK_OPEN);
-
- if (GST_FLAG_IS_SET (GST_OBJECT (this), GST_JACK_ACTIVE)) {
- JACK_DEBUG ("jackbin: deactivating client");
- jack_deactivate (this->client);
- GST_FLAG_UNSET (GST_OBJECT (this), GST_JACK_ACTIVE);
- }
- }
-
- if (GST_ELEMENT_CLASS (parent_class)->change_state)
- return GST_ELEMENT_CLASS (parent_class)->change_state (element);
- break;
-
+ JACK_DEBUG ("jackbin: READY");
+
+ _jackbin = this;
+ signal (SIGHUP, sighup_handler);
+
+ if (!this->client) {
+ if (!(this->client = jack_client_new ("gst-jack"))) {
+ g_warning ("jack server not running?");
+ return GST_STATE_FAILURE;
+ }
+
+ gst_scheduler_setup (GST_ELEMENT_SCHED (this));
+
+ jack_set_process_callback (this->client, process, this);
+ jack_set_sample_rate_callback (this->client, sample_rate, this);
+ jack_set_buffer_size_callback (this->client, buffer_size, this);
+ this->nframes = jack_get_buffer_size (this->client);
+ jack_on_shutdown (this->client, shutdown, this);
+ }
+
+ if (GST_FLAG_IS_SET (GST_OBJECT (this), GST_JACK_OPEN)) {
+ l = this->src_pads;
+ while (l) {
+ JACK_DEBUG ("jackbin: unregistering pad %s:%s",
+ GST_JACK_PAD (l)->name, GST_JACK_PAD (l)->peer_name);
+ jack_port_unregister (this->client, GST_JACK_PAD (l)->port);
+ l = g_list_next (l);
+ }
+ l = this->sink_pads;
+ while (l) {
+ JACK_DEBUG ("jackbin: unregistering pad %s:%s",
+ GST_JACK_PAD (l)->name, GST_JACK_PAD (l)->peer_name);
+ jack_port_unregister (this->client, GST_JACK_PAD (l)->port);
+ l = g_list_next (l);
+ }
+ GST_FLAG_UNSET (GST_OBJECT (this), GST_JACK_OPEN);
+
+ if (GST_FLAG_IS_SET (GST_OBJECT (this), GST_JACK_ACTIVE)) {
+ JACK_DEBUG ("jackbin: deactivating client");
+ jack_deactivate (this->client);
+ GST_FLAG_UNSET (GST_OBJECT (this), GST_JACK_ACTIVE);
+ }
+ }
+
+ if (GST_ELEMENT_CLASS (parent_class)->change_state)
+ return GST_ELEMENT_CLASS (parent_class)->change_state (element);
+ break;
+
case GST_STATE_PAUSED:
- JACK_DEBUG ("jackbin: PAUSED");
-
- if (!GST_FLAG_IS_SET (GST_OBJECT (this), GST_JACK_OPEN)) {
- l = this->src_pads;
- while (l) {
- pad = GST_JACK_PAD (l);
- JACK_DEBUG ("jackbin: registering input port %s (peer %s)", pad->name, pad->peer_name);
- pad->port = jack_port_register (this->client, pad->name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput|JackPortIsTerminal, 0);
- l = g_list_next (l);
- }
- l = this->sink_pads;
- while (l) {
- pad = GST_JACK_PAD (l);
- JACK_DEBUG ("jackbin: registering output port %s (peer %s)", pad->name, pad->peer_name);
- pad->port = jack_port_register (this->client, pad->name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput|JackPortIsTerminal, 0);
- l = g_list_next (l);
- }
-
- /* must activate before connecting */
- if (!GST_FLAG_IS_SET (GST_OBJECT (this), GST_JACK_ACTIVE)) {
- JACK_DEBUG ("jackbin: activating client");
- jack_activate (this->client);
- GST_FLAG_SET (GST_OBJECT (this), GST_JACK_ACTIVE);
- }
-
- l = this->src_pads;
- while (l) {
- pad = GST_JACK_PAD (l);
- JACK_DEBUG ("connecting jack port %s to gst jack port %s", pad->peer_name, jack_port_name (pad->port));
- if (jack_connect (this->client, pad->peer_name, jack_port_name (pad->port))) {
- g_warning ("jackbin: could not connect %s and %s", pad->peer_name, jack_port_name (pad->port));
- return GST_STATE_FAILURE;
- }
- l = g_list_next (l);
- }
- l = this->sink_pads;
- while (l) {
- pad = GST_JACK_PAD (l);
- JACK_DEBUG ("connecting gst jack port %s to jack port %s", jack_port_name (pad->port), pad->peer_name);
- if (jack_connect (this->client, jack_port_name (pad->port), pad->peer_name)) {
- g_warning ("jackbin: could not connect %s and %s", pad->peer_name, jack_port_name (pad->port));
- return GST_STATE_FAILURE;
- }
- l = g_list_next (l);
- }
-
- JACK_DEBUG ("jackbin: setting OPEN flag");
- GST_FLAG_SET (GST_OBJECT (this), GST_JACK_OPEN);
-
- if (GST_ELEMENT_CLASS (parent_class)->change_state)
- return GST_ELEMENT_CLASS (parent_class)->change_state (element);
- } else {
- if (GST_ELEMENT_CLASS (parent_class)->change_state)
- return GST_ELEMENT_CLASS (parent_class)->change_state (element);
- }
-
- break;
+ JACK_DEBUG ("jackbin: PAUSED");
+
+ if (!GST_FLAG_IS_SET (GST_OBJECT (this), GST_JACK_OPEN)) {
+ l = this->src_pads;
+ while (l) {
+ pad = GST_JACK_PAD (l);
+ JACK_DEBUG ("jackbin: registering input port %s (peer %s)", pad->name,
+ pad->peer_name);
+ pad->port =
+ jack_port_register (this->client, pad->name,
+ JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput | JackPortIsTerminal, 0);
+ l = g_list_next (l);
+ }
+ l = this->sink_pads;
+ while (l) {
+ pad = GST_JACK_PAD (l);
+ JACK_DEBUG ("jackbin: registering output port %s (peer %s)",
+ pad->name, pad->peer_name);
+ pad->port =
+ jack_port_register (this->client, pad->name,
+ JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput | JackPortIsTerminal,
+ 0);
+ l = g_list_next (l);
+ }
+
+ /* must activate before connecting */
+ if (!GST_FLAG_IS_SET (GST_OBJECT (this), GST_JACK_ACTIVE)) {
+ JACK_DEBUG ("jackbin: activating client");
+ jack_activate (this->client);
+ GST_FLAG_SET (GST_OBJECT (this), GST_JACK_ACTIVE);
+ }
+
+ l = this->src_pads;
+ while (l) {
+ pad = GST_JACK_PAD (l);
+ JACK_DEBUG ("connecting jack port %s to gst jack port %s",
+ pad->peer_name, jack_port_name (pad->port));
+ if (jack_connect (this->client, pad->peer_name,
+ jack_port_name (pad->port))) {
+ g_warning ("jackbin: could not connect %s and %s", pad->peer_name,
+ jack_port_name (pad->port));
+ return GST_STATE_FAILURE;
+ }
+ l = g_list_next (l);
+ }
+ l = this->sink_pads;
+ while (l) {
+ pad = GST_JACK_PAD (l);
+ JACK_DEBUG ("connecting gst jack port %s to jack port %s",
+ jack_port_name (pad->port), pad->peer_name);
+ if (jack_connect (this->client, jack_port_name (pad->port),
+ pad->peer_name)) {
+ g_warning ("jackbin: could not connect %s and %s", pad->peer_name,
+ jack_port_name (pad->port));
+ return GST_STATE_FAILURE;
+ }
+ l = g_list_next (l);
+ }
+
+ JACK_DEBUG ("jackbin: setting OPEN flag");
+ GST_FLAG_SET (GST_OBJECT (this), GST_JACK_OPEN);
+
+ if (GST_ELEMENT_CLASS (parent_class)->change_state)
+ return GST_ELEMENT_CLASS (parent_class)->change_state (element);
+ } else {
+ if (GST_ELEMENT_CLASS (parent_class)->change_state)
+ return GST_ELEMENT_CLASS (parent_class)->change_state (element);
+ }
+
+ break;
case GST_STATE_PLAYING:
- JACK_DEBUG ("jackbin: PLAYING");
-
- if (GST_ELEMENT_CLASS (parent_class)->change_state)
- return GST_ELEMENT_CLASS (parent_class)->change_state (element);
- break;
- }
-
- JACK_DEBUG ("jackbin: state change finished");
-
- return GST_STATE_SUCCESS;
+ JACK_DEBUG ("jackbin: PLAYING");
+
+ if (GST_ELEMENT_CLASS (parent_class)->change_state)
+ return GST_ELEMENT_CLASS (parent_class)->change_state (element);
+ break;
+ }
+
+ JACK_DEBUG ("jackbin: state change finished");
+
+ return GST_STATE_SUCCESS;
}
/* jack callbacks */
static int
process (jack_nframes_t nframes, void *arg)
{
- GstJackBin *bin = (GstJackBin*) arg;
- GstJackPad *pad;
- GList *l;
-
- g_assert (bin);
-
- JACK_DEBUG ("jackbin: process()");
-
- if (GST_STATE (bin) != GST_STATE_PLAYING) {
- JACK_DEBUG ("jackbin: bin is not PLAYING yet, returning");
- return 0;
- } else {
- JACK_DEBUG ("jackbin: we are PLAYING, let's process()");
- }
-
- l = bin->src_pads;
- while (l) {
- pad = GST_JACK_PAD (l);
- pad->data = jack_port_get_buffer (pad->port, nframes);
- l = g_list_next (l);
- }
-
- l = bin->sink_pads;
- while (l) {
- pad = GST_JACK_PAD (l);
- pad->data = jack_port_get_buffer (pad->port, nframes);
- l = g_list_next (l);
- }
-
- bin->nframes = nframes;
-
- JACK_DEBUG ("jackbin: iterating to process %ld frames of audio...", nframes);
- if (!gst_bin_iterate (GST_BIN (bin))) {
- g_warning ("bin failed to iterate");
- return -1;
- }
-
- /* that's all folks */
-
- return 0;
+ GstJackBin *bin = (GstJackBin *) arg;
+ GstJackPad *pad;
+ GList *l;
+
+ g_assert (bin);
+
+ JACK_DEBUG ("jackbin: process()");
+
+ if (GST_STATE (bin) != GST_STATE_PLAYING) {
+ JACK_DEBUG ("jackbin: bin is not PLAYING yet, returning");
+ return 0;
+ } else {
+ JACK_DEBUG ("jackbin: we are PLAYING, let's process()");
+ }
+
+ l = bin->src_pads;
+ while (l) {
+ pad = GST_JACK_PAD (l);
+ pad->data = jack_port_get_buffer (pad->port, nframes);
+ l = g_list_next (l);
+ }
+
+ l = bin->sink_pads;
+ while (l) {
+ pad = GST_JACK_PAD (l);
+ pad->data = jack_port_get_buffer (pad->port, nframes);
+ l = g_list_next (l);
+ }
+
+ bin->nframes = nframes;
+
+ JACK_DEBUG ("jackbin: iterating to process %ld frames of audio...", nframes);
+ if (!gst_bin_iterate (GST_BIN (bin))) {
+ g_warning ("bin failed to iterate");
+ return -1;
+ }
+
+ /* that's all folks */
+
+ return 0;
}
static int
sample_rate (jack_nframes_t nframes, void *arg)
{
- GstJackBin *bin = (GstJackBin*) arg;
- JACK_DEBUG ("the sample rate is now %lu/sec\n", nframes);
- bin->rate = nframes;
- return 0;
+ GstJackBin *bin = (GstJackBin *) arg;
+
+ JACK_DEBUG ("the sample rate is now %lu/sec\n", nframes);
+ bin->rate = nframes;
+ return 0;
}
static int
buffer_size (jack_nframes_t nframes, void *arg)
{
- GstJackBin *bin = (GstJackBin*) arg;
- JACK_DEBUG ("the buffer size is now %lu\n", nframes);
- bin->nframes = nframes;
- return 0;
+ GstJackBin *bin = (GstJackBin *) arg;
+
+ JACK_DEBUG ("the buffer size is now %lu\n", nframes);
+ bin->nframes = nframes;
+ return 0;
}
static void
shutdown (void *arg)
{
/* GstJackClient *client = (GstJackClient*) arg; */
- printf ("shutdown %p\n", arg);
+ printf ("shutdown %p\n", arg);
/* gst_element_set_state (GST_ELEMENT (client->manager), GST_STATE_READY); */
}
-static void sighup_handler (int sig)
+static void
+sighup_handler (int sig)
{
- g_message ("got sighup, setting state to READY");
- watchdog_please_set_the_jackbin_to_ready = TRUE;
+ g_message ("got sighup, setting state to READY");
+ watchdog_please_set_the_jackbin_to_ready = TRUE;
}
#include <gst/audio/audio.h>
#include "gstladspa.h"
-#include <ladspa.h> /* main ladspa sdk include file */
-#include "utils.h" /* ladspa sdk utility functions */
+#include <ladspa.h> /* main ladspa sdk include file */
+#include "utils.h" /* ladspa sdk utility functions */
/* 1.0 and the 1.1 preliminary headers don't define a version, but 1.1 final
does */
static GstStaticCaps ladspa_pad_caps =
GST_STATIC_CAPS (GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS);
-static void gst_ladspa_class_init (GstLADSPAClass *klass);
-static void gst_ladspa_base_init (GstLADSPAClass *klass);
-static void gst_ladspa_init (GstLADSPA *ladspa);
+static void gst_ladspa_class_init (GstLADSPAClass * klass);
+static void gst_ladspa_base_init (GstLADSPAClass * klass);
+static void gst_ladspa_init (GstLADSPA * ladspa);
-static void gst_ladspa_update_int (const GValue *value, gpointer data);
-static GstPadLinkReturn gst_ladspa_link (GstPad *pad, const GstCaps *caps);
+static void gst_ladspa_update_int (const GValue * value, gpointer data);
+static GstPadLinkReturn gst_ladspa_link (GstPad * pad, const GstCaps * caps);
-static void gst_ladspa_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void gst_ladspa_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+static void gst_ladspa_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_ladspa_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static gboolean gst_ladspa_instantiate (GstLADSPA *ladspa);
-static void gst_ladspa_activate (GstLADSPA *ladspa);
-static void gst_ladspa_deactivate (GstLADSPA *ladspa);
+static gboolean gst_ladspa_instantiate (GstLADSPA * ladspa);
+static void gst_ladspa_activate (GstLADSPA * ladspa);
+static void gst_ladspa_deactivate (GstLADSPA * ladspa);
-static GstElementStateReturn gst_ladspa_change_state (GstElement *element);
-static void gst_ladspa_loop (GstElement *element);
-static void gst_ladspa_chain (GstPad *pad,GstData *_data);
-static GstData * gst_ladspa_get (GstPad *pad);
+static GstElementStateReturn gst_ladspa_change_state (GstElement * element);
+static void gst_ladspa_loop (GstElement * element);
+static void gst_ladspa_chain (GstPad * pad, GstData * _data);
+static GstData *gst_ladspa_get (GstPad * pad);
static GstElementClass *parent_class = NULL;
static GstPlugin *ladspa_plugin;
static GHashTable *ladspa_descriptors;
-enum {
+enum
+{
ARG_0,
ARG_SAMPLERATE,
ARG_BUFFERSIZE,
GST_CAT_LEVEL_LOG (ladspa_debug, GST_LEVEL_DEBUG, obj, __VA_ARGS__)
static void
-gst_ladspa_base_init (GstLADSPAClass *klass)
+gst_ladspa_base_init (GstLADSPAClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
GstPadTemplate *templ;
GstElementDetails *details;
LADSPA_Descriptor *desc;
- gint j, sinkcount,srccount;
+ gint j, sinkcount, srccount;
- desc = g_hash_table_lookup(ladspa_descriptors,
- GINT_TO_POINTER(G_TYPE_FROM_CLASS(klass)));
+ desc = g_hash_table_lookup (ladspa_descriptors,
+ GINT_TO_POINTER (G_TYPE_FROM_CLASS (klass)));
if (!desc)
- desc = g_hash_table_lookup(ladspa_descriptors, GINT_TO_POINTER(0));
+ desc = g_hash_table_lookup (ladspa_descriptors, GINT_TO_POINTER (0));
g_assert (desc);
/* pad templates */
klass->numports = desc->PortCount;
klass->numsinkpads = 0;
klass->numsrcpads = 0;
- for (j=0;j<desc->PortCount;j++) {
- if (LADSPA_IS_PORT_AUDIO(desc->PortDescriptors[j])) {
- gchar *name = g_strdup((gchar *)desc->PortNames[j]);
+ for (j = 0; j < desc->PortCount; j++) {
+ if (LADSPA_IS_PORT_AUDIO (desc->PortDescriptors[j])) {
+ gchar *name = g_strdup ((gchar *) desc->PortNames[j]);
+
g_strcanon (name, G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "-", '-');
/* the factories take ownership of the name */
- if (LADSPA_IS_PORT_INPUT(desc->PortDescriptors[j])) {
- templ = gst_pad_template_new (name, GST_PAD_SINK, GST_PAD_ALWAYS,
- gst_caps_copy (gst_static_caps_get (&ladspa_pad_caps)));
- klass->numsinkpads++;
+ if (LADSPA_IS_PORT_INPUT (desc->PortDescriptors[j])) {
+ templ = gst_pad_template_new (name, GST_PAD_SINK, GST_PAD_ALWAYS,
+ gst_caps_copy (gst_static_caps_get (&ladspa_pad_caps)));
+ klass->numsinkpads++;
} else {
- templ = gst_pad_template_new (name, GST_PAD_SRC, GST_PAD_ALWAYS,
- gst_caps_copy (gst_static_caps_get (&ladspa_pad_caps)));
- klass->numsrcpads++;
+ templ = gst_pad_template_new (name, GST_PAD_SRC, GST_PAD_ALWAYS,
+ gst_caps_copy (gst_static_caps_get (&ladspa_pad_caps)));
+ klass->numsrcpads++;
}
gst_element_class_add_pad_template (element_class, templ);
}
/* construct the element details struct */
- details = g_new0(GstElementDetails,1);
- details->longname = g_strdup(desc->Name);
+ details = g_new0 (GstElementDetails, 1);
+ details->longname = g_strdup (desc->Name);
details->description = details->longname;
- details->author = g_strdup(desc->Maker);
- if ((klass->numsinkpads >0) && (klass->numsrcpads >0)) details->klass = "Filter/Effect/Audio/LADSPA";
- else if((klass->numsinkpads==0) && (klass->numsrcpads >0)) details->klass = "Source/Audio/LADSPA";
- else if((klass->numsinkpads >0) && (klass->numsrcpads==0)) details->klass = "Sink/Audio/LADSPA";
- else details->klass = "Filter/Effect/Audio/LADSPA"; /* whatever this is */
+ details->author = g_strdup (desc->Maker);
+ if ((klass->numsinkpads > 0) && (klass->numsrcpads > 0))
+ details->klass = "Filter/Effect/Audio/LADSPA";
+ else if ((klass->numsinkpads == 0) && (klass->numsrcpads > 0))
+ details->klass = "Source/Audio/LADSPA";
+ else if ((klass->numsinkpads > 0) && (klass->numsrcpads == 0))
+ details->klass = "Sink/Audio/LADSPA";
+ else
+ details->klass = "Filter/Effect/Audio/LADSPA"; /* whatever this is */
gst_element_class_set_details (element_class, details);
- klass->srcpad_portnums = g_new0(gint,klass->numsrcpads);
- klass->sinkpad_portnums = g_new0(gint,klass->numsinkpads);
+ klass->srcpad_portnums = g_new0 (gint, klass->numsrcpads);
+ klass->sinkpad_portnums = g_new0 (gint, klass->numsinkpads);
sinkcount = 0;
srccount = 0;
/* walk through the ports, note the portnums for srcpads, sinkpads */
- for (j=0; j<desc->PortCount; j++) {
- if (LADSPA_IS_PORT_AUDIO(desc->PortDescriptors[j])) {
- if (LADSPA_IS_PORT_INPUT(desc->PortDescriptors[j]))
- klass->sinkpad_portnums[sinkcount++] = j;
+ for (j = 0; j < desc->PortCount; j++) {
+ if (LADSPA_IS_PORT_AUDIO (desc->PortDescriptors[j])) {
+ if (LADSPA_IS_PORT_INPUT (desc->PortDescriptors[j]))
+ klass->sinkpad_portnums[sinkcount++] = j;
else
- klass->srcpad_portnums[srccount++] = j;
+ klass->srcpad_portnums[srccount++] = j;
}
}
}
static void
-gst_ladspa_class_init (GstLADSPAClass *klass)
+gst_ladspa_class_init (GstLADSPAClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
LADSPA_Descriptor *desc;
- gint i,current_portnum,controlcount;
+ gint i, current_portnum, controlcount;
gint hintdesc;
- gint argtype,argperms;
+ gint argtype, argperms;
GParamSpec *paramspec = NULL;
gchar *argname, *tempstr, *paren;
- gobject_class = (GObjectClass*)klass;
- gstelement_class = (GstElementClass*)klass;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
gobject_class->set_property = gst_ladspa_set_property;
gobject_class->get_property = gst_ladspa_get_property;
gstelement_class->change_state = gst_ladspa_change_state;
/* look up and store the ladspa descriptor */
- desc = g_hash_table_lookup(ladspa_descriptors,
- GINT_TO_POINTER(G_TYPE_FROM_CLASS(klass)));
+ desc = g_hash_table_lookup (ladspa_descriptors,
+ GINT_TO_POINTER (G_TYPE_FROM_CLASS (klass)));
if (!desc)
- desc = g_hash_table_lookup(ladspa_descriptors, GINT_TO_POINTER(0));
+ desc = g_hash_table_lookup (ladspa_descriptors, GINT_TO_POINTER (0));
g_assert (desc);
klass->numcontrols = 0;
/* walk through the ports, count the input, output and control ports */
- for (i=0; i<desc->PortCount; i++) {
- if (!LADSPA_IS_PORT_AUDIO(desc->PortDescriptors[i]) &&
- LADSPA_IS_PORT_INPUT(desc->PortDescriptors[i]))
+ for (i = 0; i < desc->PortCount; i++) {
+ if (!LADSPA_IS_PORT_AUDIO (desc->PortDescriptors[i]) &&
+ LADSPA_IS_PORT_INPUT (desc->PortDescriptors[i]))
klass->numcontrols++;
}
DEBUG ("ladspa element class: init %s with %d sink, %d src, %d control\n",
- g_type_name (G_TYPE_FROM_CLASS (klass)),
- klass->numsinkpads, klass->numsrcpads, klass->numcontrols);
+ g_type_name (G_TYPE_FROM_CLASS (klass)),
+ klass->numsinkpads, klass->numsrcpads, klass->numcontrols);
- klass->control_portnums = g_new0(gint,klass->numcontrols);
+ klass->control_portnums = g_new0 (gint, klass->numcontrols);
controlcount = 0;
/* walk through the ports, note the portnums for control params */
- for (i=0; i<desc->PortCount; i++) {
- if (!LADSPA_IS_PORT_AUDIO(desc->PortDescriptors[i]) &&
- LADSPA_IS_PORT_INPUT(desc->PortDescriptors[i]))
+ for (i = 0; i < desc->PortCount; i++) {
+ if (!LADSPA_IS_PORT_AUDIO (desc->PortDescriptors[i]) &&
+ LADSPA_IS_PORT_INPUT (desc->PortDescriptors[i]))
klass->control_portnums[controlcount++] = i;
}
/* now build the control info from the control ports */
- klass->control_info = g_new0(ladspa_control_info,klass->numcontrols);
-
- for (i=0;i<klass->numcontrols;i++) {
+ klass->control_info = g_new0 (ladspa_control_info, klass->numcontrols);
+
+ for (i = 0; i < klass->numcontrols; i++) {
current_portnum = klass->control_portnums[i];
-
+
/* short name for hint descriptor */
hintdesc = desc->PortRangeHints[current_portnum].HintDescriptor;
/* get the various bits */
- if (LADSPA_IS_HINT_TOGGLED(hintdesc))
+ if (LADSPA_IS_HINT_TOGGLED (hintdesc))
klass->control_info[i].toggled = TRUE;
- if (LADSPA_IS_HINT_LOGARITHMIC(hintdesc))
+ if (LADSPA_IS_HINT_LOGARITHMIC (hintdesc))
klass->control_info[i].logarithmic = TRUE;
- if (LADSPA_IS_HINT_INTEGER(hintdesc))
+ if (LADSPA_IS_HINT_INTEGER (hintdesc))
klass->control_info[i].integer = TRUE;
/* figure out the argument details */
- if (klass->control_info[i].toggled) argtype = G_TYPE_BOOLEAN;
- else if (klass->control_info[i].integer) argtype = G_TYPE_INT;
- else argtype = G_TYPE_FLOAT;
+ if (klass->control_info[i].toggled)
+ argtype = G_TYPE_BOOLEAN;
+ else if (klass->control_info[i].integer)
+ argtype = G_TYPE_INT;
+ else
+ argtype = G_TYPE_FLOAT;
/* grab the bounds */
- if (LADSPA_IS_HINT_BOUNDED_BELOW(hintdesc)) {
+ if (LADSPA_IS_HINT_BOUNDED_BELOW (hintdesc)) {
klass->control_info[i].lower = TRUE;
klass->control_info[i].lowerbound =
- desc->PortRangeHints[current_portnum].LowerBound;
+ desc->PortRangeHints[current_portnum].LowerBound;
} else {
- if (argtype==G_TYPE_INT) klass->control_info[i].lowerbound = (gfloat)G_MININT;
- if (argtype==G_TYPE_FLOAT) klass->control_info[i].lowerbound = -G_MAXFLOAT;
+ if (argtype == G_TYPE_INT)
+ klass->control_info[i].lowerbound = (gfloat) G_MININT;
+ if (argtype == G_TYPE_FLOAT)
+ klass->control_info[i].lowerbound = -G_MAXFLOAT;
}
-
- if (LADSPA_IS_HINT_BOUNDED_ABOVE(hintdesc)) {
+
+ if (LADSPA_IS_HINT_BOUNDED_ABOVE (hintdesc)) {
klass->control_info[i].upper = TRUE;
klass->control_info[i].upperbound =
- desc->PortRangeHints[current_portnum].UpperBound;
- if (LADSPA_IS_HINT_SAMPLE_RATE(hintdesc)) {
- klass->control_info[i].samplerate = TRUE;
- klass->control_info[i].upperbound *= 44100; /* FIXME? */
+ desc->PortRangeHints[current_portnum].UpperBound;
+ if (LADSPA_IS_HINT_SAMPLE_RATE (hintdesc)) {
+ klass->control_info[i].samplerate = TRUE;
+ klass->control_info[i].upperbound *= 44100; /* FIXME? */
}
} else {
- if (argtype==G_TYPE_INT) klass->control_info[i].upperbound = (gfloat)G_MAXINT;
- if (argtype==G_TYPE_FLOAT) klass->control_info[i].upperbound = G_MAXFLOAT;
+ if (argtype == G_TYPE_INT)
+ klass->control_info[i].upperbound = (gfloat) G_MAXINT;
+ if (argtype == G_TYPE_FLOAT)
+ klass->control_info[i].upperbound = G_MAXFLOAT;
}
/* use the lowerbound as the default value */
/* figure out the defaults */
if (LADSPA_IS_HINT_HAS_DEFAULT (hintdesc)) {
if (LADSPA_IS_HINT_DEFAULT_MINIMUM (hintdesc))
- klass->control_info[i].def = klass->control_info[i].lowerbound;
+ klass->control_info[i].def = klass->control_info[i].lowerbound;
else if (LADSPA_IS_HINT_DEFAULT_LOW (hintdesc))
- if (LADSPA_IS_HINT_LOGARITHMIC (hintdesc))
- klass->control_info[i].def = exp (0.75*log(klass->control_info[i].lowerbound) +
- 0.25*log(klass->control_info[i].upperbound));
- else
- klass->control_info[i].def = (0.75*klass->control_info[i].lowerbound +
- 0.25*klass->control_info[i].upperbound);
+ if (LADSPA_IS_HINT_LOGARITHMIC (hintdesc))
+ klass->control_info[i].def =
+ exp (0.75 * log (klass->control_info[i].lowerbound) +
+ 0.25 * log (klass->control_info[i].upperbound));
+ else
+ klass->control_info[i].def =
+ (0.75 * klass->control_info[i].lowerbound +
+ 0.25 * klass->control_info[i].upperbound);
else if (LADSPA_IS_HINT_DEFAULT_MIDDLE (hintdesc))
- if (LADSPA_IS_HINT_LOGARITHMIC (hintdesc))
- klass->control_info[i].def = exp (0.5*log(klass->control_info[i].lowerbound) +
- 0.5*log(klass->control_info[i].upperbound));
- else
- klass->control_info[i].def = (0.5*klass->control_info[i].lowerbound +
- 0.5*klass->control_info[i].upperbound);
+ if (LADSPA_IS_HINT_LOGARITHMIC (hintdesc))
+ klass->control_info[i].def =
+ exp (0.5 * log (klass->control_info[i].lowerbound) +
+ 0.5 * log (klass->control_info[i].upperbound));
+ else
+ klass->control_info[i].def =
+ (0.5 * klass->control_info[i].lowerbound +
+ 0.5 * klass->control_info[i].upperbound);
else if (LADSPA_IS_HINT_DEFAULT_HIGH (hintdesc))
- if (LADSPA_IS_HINT_LOGARITHMIC (hintdesc))
- klass->control_info[i].def = exp (0.25*log(klass->control_info[i].lowerbound) +
- 0.75*log(klass->control_info[i].upperbound));
- else
- klass->control_info[i].def = (0.25*klass->control_info[i].lowerbound +
- 0.75*klass->control_info[i].upperbound);
+ if (LADSPA_IS_HINT_LOGARITHMIC (hintdesc))
+ klass->control_info[i].def =
+ exp (0.25 * log (klass->control_info[i].lowerbound) +
+ 0.75 * log (klass->control_info[i].upperbound));
+ else
+ klass->control_info[i].def =
+ (0.25 * klass->control_info[i].lowerbound +
+ 0.75 * klass->control_info[i].upperbound);
else if (LADSPA_IS_HINT_DEFAULT_MAXIMUM (hintdesc))
- klass->control_info[i].def = klass->control_info[i].upperbound;
+ klass->control_info[i].def = klass->control_info[i].upperbound;
else if (LADSPA_IS_HINT_DEFAULT_0 (hintdesc))
- klass->control_info[i].def = 0.0;
+ klass->control_info[i].def = 0.0;
else if (LADSPA_IS_HINT_DEFAULT_1 (hintdesc))
- klass->control_info[i].def = 1.0;
+ klass->control_info[i].def = 1.0;
else if (LADSPA_IS_HINT_DEFAULT_100 (hintdesc))
- klass->control_info[i].def = 100.0;
+ klass->control_info[i].def = 100.0;
else if (LADSPA_IS_HINT_DEFAULT_440 (hintdesc))
- klass->control_info[i].def = 440.0;
+ klass->control_info[i].def = 440.0;
}
#endif /* LADSPA_IS_HINT_HAS_DEFAULT */
- klass->control_info[i].def = CLAMP(klass->control_info[i].def,
- klass->control_info[i].lowerbound,
- klass->control_info[i].upperbound);
-
- if (LADSPA_IS_PORT_INPUT(desc->PortDescriptors[current_portnum])) {
+ klass->control_info[i].def = CLAMP (klass->control_info[i].def,
+ klass->control_info[i].lowerbound, klass->control_info[i].upperbound);
+
+ if (LADSPA_IS_PORT_INPUT (desc->PortDescriptors[current_portnum])) {
argperms = G_PARAM_READWRITE;
klass->control_info[i].writable = TRUE;
} else {
klass->control_info[i].writable = FALSE;
}
- klass->control_info[i].name = g_strdup(desc->PortNames[current_portnum]);
- argname = g_strdup(klass->control_info[i].name);
+ klass->control_info[i].name = g_strdup (desc->PortNames[current_portnum]);
+ argname = g_strdup (klass->control_info[i].name);
/* find out if there is a (unitname) at the end of the argname and get rid
of it */
paren = g_strrstr (argname, " (");
/* this is the same thing that param_spec_* will do */
g_strcanon (argname, G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "-", '-');
/* satisfy glib2 (argname[0] must be [A-Za-z]) */
- if (!((argname[0] >= 'a' && argname[0] <= 'z') || (argname[0] >= 'A' && argname[0] <= 'Z'))) {
+ if (!((argname[0] >= 'a' && argname[0] <= 'z') || (argname[0] >= 'A'
+ && argname[0] <= 'Z'))) {
tempstr = argname;
- argname = g_strconcat("param-", argname, NULL);
+ argname = g_strconcat ("param-", argname, NULL);
g_free (tempstr);
}
-
+
/* check for duplicate property names */
- if (g_object_class_find_property(G_OBJECT_CLASS(klass), argname) != NULL){
- gint numarg=1;
- gchar *numargname = g_strdup_printf("%s_%d",argname,numarg++);
- while (g_object_class_find_property(G_OBJECT_CLASS(klass), numargname) != NULL){
- g_free(numargname);
- numargname = g_strdup_printf("%s_%d",argname,numarg++);
+ if (g_object_class_find_property (G_OBJECT_CLASS (klass), argname) != NULL) {
+ gint numarg = 1;
+ gchar *numargname = g_strdup_printf ("%s_%d", argname, numarg++);
+
+ while (g_object_class_find_property (G_OBJECT_CLASS (klass),
+ numargname) != NULL) {
+ g_free (numargname);
+ numargname = g_strdup_printf ("%s_%d", argname, numarg++);
}
argname = numargname;
}
-
+
klass->control_info[i].param_name = argname;
-
+
DEBUG ("adding arg %s from %s", argname, klass->control_info[i].name);
-
- if (argtype==G_TYPE_BOOLEAN){
- paramspec = g_param_spec_boolean(argname,argname,argname, FALSE, argperms);
- } else if (argtype==G_TYPE_INT){
- paramspec = g_param_spec_int(argname,argname,argname,
- (gint)klass->control_info[i].lowerbound,
- (gint)klass->control_info[i].upperbound,
- (gint)klass->control_info[i].def, argperms);
- } else if (klass->control_info[i].samplerate){
- paramspec = g_param_spec_float(argname,argname,argname,
- 0.0, G_MAXFLOAT,
- 0.0, argperms);
+
+ if (argtype == G_TYPE_BOOLEAN) {
+ paramspec =
+ g_param_spec_boolean (argname, argname, argname, FALSE, argperms);
+ } else if (argtype == G_TYPE_INT) {
+ paramspec = g_param_spec_int (argname, argname, argname,
+ (gint) klass->control_info[i].lowerbound,
+ (gint) klass->control_info[i].upperbound,
+ (gint) klass->control_info[i].def, argperms);
+ } else if (klass->control_info[i].samplerate) {
+ paramspec = g_param_spec_float (argname, argname, argname,
+ 0.0, G_MAXFLOAT, 0.0, argperms);
} else {
- paramspec = g_param_spec_float(argname,argname,argname,
- klass->control_info[i].lowerbound, klass->control_info[i].upperbound,
- klass->control_info[i].def, argperms);
+ paramspec = g_param_spec_float (argname, argname, argname,
+ klass->control_info[i].lowerbound, klass->control_info[i].upperbound,
+ klass->control_info[i].def, argperms);
}
-
+
/* properties have an offset of 1 */
- g_object_class_install_property(G_OBJECT_CLASS(klass), i+1, paramspec);
+ g_object_class_install_property (G_OBJECT_CLASS (klass), i + 1, paramspec);
}
}
static void
-gst_ladspa_init (GstLADSPA *ladspa)
+gst_ladspa_init (GstLADSPA * ladspa)
{
GstLADSPAClass *oclass;
ladspa_control_info cinfo;
GList *l;
LADSPA_Descriptor *desc;
- gint i,sinkcount,srccount;
+ gint i, sinkcount, srccount;
- oclass = (GstLADSPAClass*)G_OBJECT_GET_CLASS (ladspa);
+ oclass = (GstLADSPAClass *) G_OBJECT_GET_CLASS (ladspa);
desc = oclass->descriptor;
ladspa->descriptor = oclass->descriptor;
-
+
/* allocate the various arrays */
- ladspa->srcpads = g_new0(GstPad*,oclass->numsrcpads);
- ladspa->sinkpads = g_new0(GstPad*,oclass->numsinkpads);
- ladspa->controls = g_new(gfloat,oclass->numcontrols);
- ladspa->dpman = gst_dpman_new ("ladspa_dpman", GST_ELEMENT(ladspa));
-
+ ladspa->srcpads = g_new0 (GstPad *, oclass->numsrcpads);
+ ladspa->sinkpads = g_new0 (GstPad *, oclass->numsinkpads);
+ ladspa->controls = g_new (gfloat, oclass->numcontrols);
+ ladspa->dpman = gst_dpman_new ("ladspa_dpman", GST_ELEMENT (ladspa));
+
/* set up pads */
sinkcount = 0;
srccount = 0;
- for (l=GST_ELEMENT_CLASS (oclass)->padtemplates; l; l=l->next) {
+ for (l = GST_ELEMENT_CLASS (oclass)->padtemplates; l; l = l->next) {
GstPad *pad = gst_pad_new_from_template (GST_PAD_TEMPLATE (l->data),
- GST_PAD_TEMPLATE_NAME_TEMPLATE (l->data));
+ GST_PAD_TEMPLATE_NAME_TEMPLATE (l->data));
+
gst_pad_set_link_function (pad, gst_ladspa_link);
- gst_element_add_pad ((GstElement*)ladspa, pad);
+ gst_element_add_pad ((GstElement *) ladspa, pad);
if (GST_PAD_DIRECTION (pad) == GST_PAD_SINK)
ladspa->sinkpads[sinkcount++] = pad;
else
ladspa->srcpads[srccount++] = pad;
}
-
+
/* set up dparams */
- for (i=0; i<oclass->numcontrols; i++) {
- if (LADSPA_IS_PORT_INPUT(desc->PortDescriptors[i])) {
+ for (i = 0; i < oclass->numcontrols; i++) {
+ if (LADSPA_IS_PORT_INPUT (desc->PortDescriptors[i])) {
cinfo = oclass->control_info[i];
- ladspa->controls[i]=cinfo.def;
-
- if (cinfo.toggled){
- gst_dpman_add_required_dparam_callback (
- ladspa->dpman,
- g_param_spec_int(cinfo.param_name, cinfo.name, cinfo.name,
- 0, 1, (gint)(ladspa->controls[i]), G_PARAM_READWRITE),
- "int", gst_ladspa_update_int, &(ladspa->controls[i])
- );
- }
- else if (cinfo.integer){
- gst_dpman_add_required_dparam_callback (
- ladspa->dpman,
- g_param_spec_int(cinfo.param_name, cinfo.name, cinfo.name,
- (gint)cinfo.lowerbound, (gint)cinfo.upperbound,
- (gint)ladspa->controls[i], G_PARAM_READWRITE),
- "int", gst_ladspa_update_int, &(ladspa->controls[i])
- );
- }
- else if (cinfo.samplerate){
- gst_dpman_add_required_dparam_direct (
- ladspa->dpman,
- g_param_spec_float(cinfo.param_name, cinfo.name, cinfo.name,
- cinfo.lowerbound, cinfo.upperbound,
- ladspa->controls[i], G_PARAM_READWRITE),
- "hertz-rate-bound", &(ladspa->controls[i])
- );
- }
- else {
- gst_dpman_add_required_dparam_direct (
- ladspa->dpman,
- g_param_spec_float(cinfo.param_name, cinfo.name, cinfo.name,
- cinfo.lowerbound, cinfo.upperbound,
- ladspa->controls[i], G_PARAM_READWRITE),
- "float", &(ladspa->controls[i])
- );
+ ladspa->controls[i] = cinfo.def;
+
+ if (cinfo.toggled) {
+ gst_dpman_add_required_dparam_callback (ladspa->dpman,
+ g_param_spec_int (cinfo.param_name, cinfo.name, cinfo.name,
+ 0, 1, (gint) (ladspa->controls[i]), G_PARAM_READWRITE),
+ "int", gst_ladspa_update_int, &(ladspa->controls[i])
+ );
+ } else if (cinfo.integer) {
+ gst_dpman_add_required_dparam_callback (ladspa->dpman,
+ g_param_spec_int (cinfo.param_name, cinfo.name, cinfo.name,
+ (gint) cinfo.lowerbound, (gint) cinfo.upperbound,
+ (gint) ladspa->controls[i], G_PARAM_READWRITE),
+ "int", gst_ladspa_update_int, &(ladspa->controls[i])
+ );
+ } else if (cinfo.samplerate) {
+ gst_dpman_add_required_dparam_direct (ladspa->dpman,
+ g_param_spec_float (cinfo.param_name, cinfo.name, cinfo.name,
+ cinfo.lowerbound, cinfo.upperbound,
+ ladspa->controls[i], G_PARAM_READWRITE),
+ "hertz-rate-bound", &(ladspa->controls[i])
+ );
+ } else {
+ gst_dpman_add_required_dparam_direct (ladspa->dpman,
+ g_param_spec_float (cinfo.param_name, cinfo.name, cinfo.name,
+ cinfo.lowerbound, cinfo.upperbound,
+ ladspa->controls[i], G_PARAM_READWRITE),
+ "float", &(ladspa->controls[i])
+ );
}
}
}
/* nonzero default needed to instantiate() some plugins */
ladspa->samplerate = 44100;
- ladspa->buffer_frames = 0; /* should be set with caps */
+ ladspa->buffer_frames = 0; /* should be set with caps */
ladspa->activated = FALSE;
- ladspa->inplace_broken = LADSPA_IS_INPLACE_BROKEN(ladspa->descriptor->Properties);
+ ladspa->inplace_broken =
+ LADSPA_IS_INPLACE_BROKEN (ladspa->descriptor->Properties);
- if (sinkcount==0 && srccount == 1) {
+ if (sinkcount == 0 && srccount == 1) {
/* get mode (no sink pads) */
DEBUG_OBJ (ladspa, "mono get mode with 1 src pad");
gst_pad_set_get_function (ladspa->srcpads[0], gst_ladspa_get);
- } else if (sinkcount==1){
+ } else if (sinkcount == 1) {
/* with one sink we can use the chain function */
DEBUG_OBJ (ladspa, "chain mode");
gst_pad_set_chain_function (ladspa->sinkpads[0], gst_ladspa_chain);
- } else if (sinkcount > 1){
+ } else if (sinkcount > 1) {
/* more than one sink pad needs loop mode */
- DEBUG_OBJ (ladspa, "loop mode with %d sink pads and %d src pads", sinkcount, srccount);
+ DEBUG_OBJ (ladspa, "loop mode with %d sink pads and %d src pads", sinkcount,
+ srccount);
gst_element_set_loop_function (GST_ELEMENT (ladspa), gst_ladspa_loop);
- } else if (sinkcount==0 && srccount == 0) {
+ } else if (sinkcount == 0 && srccount == 0) {
/* for example, a plugin with only control inputs and output -- just ignore
* it for now */
} else {
- g_warning ("%d sink pads, %d src pads not yet supported", sinkcount, srccount);
+ g_warning ("%d sink pads, %d src pads not yet supported", sinkcount,
+ srccount);
}
gst_ladspa_instantiate (ladspa);
}
static void
-gst_ladspa_update_int(const GValue *value, gpointer data)
+gst_ladspa_update_int (const GValue * value, gpointer data)
{
- gfloat *target = (gfloat*) data;
- *target = (gfloat)g_value_get_int(value);
+ gfloat *target = (gfloat *) data;
+
+ *target = (gfloat) g_value_get_int (value);
}
static GstPadLinkReturn
-gst_ladspa_link (GstPad *pad, const GstCaps *caps)
+gst_ladspa_link (GstPad * pad, const GstCaps * caps)
{
- GstElement *element = (GstElement*)GST_PAD_PARENT (pad);
- GstLADSPA *ladspa = (GstLADSPA*)element;
+ GstElement *element = (GstElement *) GST_PAD_PARENT (pad);
+ GstLADSPA *ladspa = (GstLADSPA *) element;
const GList *l = NULL;
gint rate;
GstStructure *structure;
/* if this fails in some other plugin, the graph is left in an inconsistent
state */
- for (l=gst_element_get_pad_list (element); l; l=l->next)
- if (pad != (GstPad*)l->data)
- if (gst_pad_try_set_caps ((GstPad*)l->data, caps) <= 0)
- return GST_PAD_LINK_REFUSED;
-
+ for (l = gst_element_get_pad_list (element); l; l = l->next)
+ if (pad != (GstPad *) l->data)
+ if (gst_pad_try_set_caps ((GstPad *) l->data, caps) <= 0)
+ return GST_PAD_LINK_REFUSED;
+
/* we assume that the ladspa plugin can handle any sample rate, so this
check gets put last */
structure = gst_caps_get_structure (caps, 0);
/* have to instantiate ladspa plugin when samplerate changes (groan) */
if (ladspa->samplerate != rate) {
ladspa->samplerate = rate;
- if (! gst_ladspa_instantiate(ladspa))
+ if (!gst_ladspa_instantiate (ladspa))
return GST_PAD_LINK_REFUSED;
}
-
- gst_structure_get_int (structure, "buffer-frames", &ladspa->buffer_frames);
-
+
+ gst_structure_get_int (structure, "buffer-frames", &ladspa->buffer_frames);
+
return GST_PAD_LINK_OK;
}
#if 0
static void
-gst_ladspa_force_src_caps(GstLADSPA *ladspa, GstPad *pad)
+gst_ladspa_force_src_caps (GstLADSPA * ladspa, GstPad * pad)
{
if (!ladspa->buffer_frames) {
- ladspa->buffer_frames = 256; /* 5 ms at 44100 kHz (just a default...) */
+ ladspa->buffer_frames = 256; /* 5 ms at 44100 kHz (just a default...) */
}
DEBUG_OBJ (ladspa, "forcing caps with rate=%d, buffer-frames=%d",
- ladspa->samplerate, ladspa->buffer_frames);
+ ladspa->samplerate, ladspa->buffer_frames);
gst_pad_try_set_caps (pad,
- gst_caps_new (
- "ladspa_src_caps",
- "audio/x-raw-float",
- gst_props_new (
- "width", G_TYPE_INT (32),
- "endianness", G_TYPE_INT (G_BYTE_ORDER),
- "rate", G_TYPE_INT (ladspa->samplerate),
- "buffer-frames", G_TYPE_INT (ladspa->buffer_frames),
- "channels", G_TYPE_INT (1),
- NULL)));
+ gst_caps_new ("ladspa_src_caps",
+ "audio/x-raw-float",
+ gst_props_new ("width", G_TYPE_INT (32),
+ "endianness", G_TYPE_INT (G_BYTE_ORDER),
+ "rate", G_TYPE_INT (ladspa->samplerate),
+ "buffer-frames", G_TYPE_INT (ladspa->buffer_frames),
+ "channels", G_TYPE_INT (1), NULL)));
}
#endif
static void
-gst_ladspa_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_ladspa_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
- GstLADSPA *ladspa = (GstLADSPA*)object;
+ GstLADSPA *ladspa = (GstLADSPA *) object;
GstLADSPAClass *oclass;
ladspa_control_info *control_info;
- oclass = (GstLADSPAClass*)(G_OBJECT_GET_CLASS (object));
+ oclass = (GstLADSPAClass *) (G_OBJECT_GET_CLASS (object));
/* remember, properties have an offset of 1 */
prop_id--;
else
ladspa->controls[prop_id] = g_value_get_float (value);
- DEBUG_OBJ (object, "set arg %s to %f", control_info->name, ladspa->controls[prop_id]);
+ DEBUG_OBJ (object, "set arg %s to %f", control_info->name,
+ ladspa->controls[prop_id]);
}
static void
-gst_ladspa_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_ladspa_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
- GstLADSPA *ladspa = (GstLADSPA*)object;
- GstLADSPAClass *oclass = (GstLADSPAClass*)(G_OBJECT_GET_CLASS (object));
+ GstLADSPA *ladspa = (GstLADSPA *) object;
+ GstLADSPAClass *oclass = (GstLADSPAClass *) (G_OBJECT_GET_CLASS (object));
ladspa_control_info *control_info;
/* remember, properties have an offset of 1 */
if (control_info->toggled)
g_value_set_boolean (value, ladspa->controls[prop_id] == 1.0);
else if (control_info->integer)
- g_value_set_int (value, (gint)ladspa->controls[prop_id]);
+ g_value_set_int (value, (gint) ladspa->controls[prop_id]);
else
g_value_set_float (value, ladspa->controls[prop_id]);
- DEBUG_OBJ (object, "got arg %s as %f", control_info->name, ladspa->controls[prop_id]);
+ DEBUG_OBJ (object, "got arg %s as %f", control_info->name,
+ ladspa->controls[prop_id]);
}
static gboolean
-gst_ladspa_instantiate (GstLADSPA *ladspa)
+gst_ladspa_instantiate (GstLADSPA * ladspa)
{
LADSPA_Descriptor *desc;
int i;
- GstLADSPAClass *oclass = (GstLADSPAClass*)(G_OBJECT_GET_CLASS (ladspa));
+ GstLADSPAClass *oclass = (GstLADSPAClass *) (G_OBJECT_GET_CLASS (ladspa));
gboolean was_activated;
-
+
desc = ladspa->descriptor;
-
+
/* check for old handle */
was_activated = ladspa->activated;
- if (ladspa->handle != NULL){
- gst_ladspa_deactivate(ladspa);
- desc->cleanup(ladspa->handle);
+ if (ladspa->handle != NULL) {
+ gst_ladspa_deactivate (ladspa);
+ desc->cleanup (ladspa->handle);
}
-
- /* instantiate the plugin */
+
+ /* instantiate the plugin */
DEBUG_OBJ (ladspa, "instantiating the plugin at %d Hz", ladspa->samplerate);
-
- ladspa->handle = desc->instantiate(desc,ladspa->samplerate);
+
+ ladspa->handle = desc->instantiate (desc, ladspa->samplerate);
g_return_val_if_fail (ladspa->handle != NULL, FALSE);
/* connect the control ports */
- for (i=0;i<oclass->numcontrols;i++)
- desc->connect_port(ladspa->handle,
- oclass->control_portnums[i],
- &(ladspa->controls[i]));
+ for (i = 0; i < oclass->numcontrols; i++)
+ desc->connect_port (ladspa->handle,
+ oclass->control_portnums[i], &(ladspa->controls[i]));
/* reactivate if it was activated before the reinstantiation */
if (was_activated)
- gst_ladspa_activate(ladspa);
+ gst_ladspa_activate (ladspa);
return TRUE;
}
static GstElementStateReturn
-gst_ladspa_change_state (GstElement *element)
+gst_ladspa_change_state (GstElement * element)
{
LADSPA_Descriptor *desc;
- GstLADSPA *ladspa = (GstLADSPA*)element;
+ GstLADSPA *ladspa = (GstLADSPA *) element;
+
desc = ladspa->descriptor;
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY:
- gst_ladspa_activate(ladspa);
+ gst_ladspa_activate (ladspa);
break;
case GST_STATE_READY_TO_NULL:
- gst_ladspa_deactivate(ladspa);
+ gst_ladspa_deactivate (ladspa);
break;
default:
break;
}
static void
-gst_ladspa_activate (GstLADSPA *ladspa)
+gst_ladspa_activate (GstLADSPA * ladspa)
{
LADSPA_Descriptor *desc;
+
desc = ladspa->descriptor;
-
+
if (ladspa->activated)
- gst_ladspa_deactivate(ladspa);
-
+ gst_ladspa_deactivate (ladspa);
+
DEBUG_OBJ (ladspa, "activating");
/* activate the plugin (function might be null) */
if (desc->activate != NULL)
- desc->activate(ladspa->handle);
+ desc->activate (ladspa->handle);
ladspa->activated = TRUE;
}
static void
-gst_ladspa_deactivate (GstLADSPA *ladspa)
+gst_ladspa_deactivate (GstLADSPA * ladspa)
{
LADSPA_Descriptor *desc;
+
desc = ladspa->descriptor;
DEBUG_OBJ (ladspa, "deactivating");
/* deactivate the plugin (function might be null) */
if (ladspa->activated && (desc->deactivate != NULL))
- desc->deactivate(ladspa->handle);
+ desc->deactivate (ladspa->handle);
ladspa->activated = FALSE;
}
static void
-gst_ladspa_loop (GstElement *element)
+gst_ladspa_loop (GstElement * element)
{
- guint i, j, numsrcpads, numsinkpads;
- guint num_processed, num_to_process;
- gint largest_buffer;
- LADSPA_Data **data_in, **data_out;
- GstBuffer **buffers_in, **buffers_out;
-
- GstLADSPA *ladspa = (GstLADSPA *)element;
- GstLADSPAClass *oclass = (GstLADSPAClass*)(G_OBJECT_GET_CLASS (ladspa));
+ guint i, j, numsrcpads, numsinkpads;
+ guint num_processed, num_to_process;
+ gint largest_buffer;
+ LADSPA_Data **data_in, **data_out;
+ GstBuffer **buffers_in, **buffers_out;
+
+ GstLADSPA *ladspa = (GstLADSPA *) element;
+ GstLADSPAClass *oclass = (GstLADSPAClass *) (G_OBJECT_GET_CLASS (ladspa));
LADSPA_Descriptor *desc = ladspa->descriptor;
numsinkpads = oclass->numsinkpads;
numsrcpads = oclass->numsrcpads;
-
+
/* fixme: these mallocs need to die */
- data_in = g_new0(LADSPA_Data*, numsinkpads);
- data_out = g_new0(LADSPA_Data*, numsrcpads);
- buffers_in = g_new0(GstBuffer*, numsinkpads);
- buffers_out = g_new0(GstBuffer*, numsrcpads);
-
+ data_in = g_new0 (LADSPA_Data *, numsinkpads);
+ data_out = g_new0 (LADSPA_Data *, numsrcpads);
+ buffers_in = g_new0 (GstBuffer *, numsinkpads);
+ buffers_out = g_new0 (GstBuffer *, numsrcpads);
+
largest_buffer = -1;
/* first get all the necessary data from the input ports */
- for (i=0 ; i<numsinkpads ; i++){
+ for (i = 0; i < numsinkpads; i++) {
get_buffer:
buffers_in[i] = GST_BUFFER (gst_pad_pull (ladspa->sinkpads[i]));
-
+
if (GST_IS_EVENT (buffers_in[i])) {
/* push it out on all pads */
- gst_data_ref_by_count ((GstData*)buffers_in[i], numsrcpads);
- for (j=0; j<numsrcpads; j++)
- gst_pad_push (ladspa->srcpads[j], GST_DATA (buffers_in[i]));
+ gst_data_ref_by_count ((GstData *) buffers_in[i], numsrcpads);
+ for (j = 0; j < numsrcpads; j++)
+ gst_pad_push (ladspa->srcpads[j], GST_DATA (buffers_in[i]));
if (GST_EVENT_TYPE (buffers_in[i]) == GST_EVENT_EOS) {
- /* shut down */
- gst_element_set_eos (element);
- return;
+ /* shut down */
+ gst_element_set_eos (element);
+ return;
} else {
- goto get_buffer;
+ goto get_buffer;
}
}
if (largest_buffer < 0)
- largest_buffer = GST_BUFFER_SIZE (buffers_in[i])/sizeof(gfloat);
+ largest_buffer = GST_BUFFER_SIZE (buffers_in[i]) / sizeof (gfloat);
else
- largest_buffer = MIN (GST_BUFFER_SIZE (buffers_in[i])/sizeof(gfloat), largest_buffer);
- data_in[i] = (LADSPA_Data *) GST_BUFFER_DATA(buffers_in[i]);
- GST_BUFFER_TIMESTAMP(buffers_in[i]) = ladspa->timestamp;
+ largest_buffer =
+ MIN (GST_BUFFER_SIZE (buffers_in[i]) / sizeof (gfloat),
+ largest_buffer);
+ data_in[i] = (LADSPA_Data *) GST_BUFFER_DATA (buffers_in[i]);
+ GST_BUFFER_TIMESTAMP (buffers_in[i]) = ladspa->timestamp;
}
- i=0;
+ i = 0;
if (!ladspa->inplace_broken) {
- for (; i<numsrcpads && i<numsinkpads; i++) {
+ for (; i < numsrcpads && i < numsinkpads; i++) {
/* reuse input buffers */
buffers_out[i] = buffers_in[i];
data_out[i] = data_in[i];
}
}
- for (; i<numsrcpads; i++) {
- buffers_out[i] = gst_buffer_new_and_alloc (ladspa->buffer_frames * sizeof(gfloat));
+ for (; i < numsrcpads; i++) {
+ buffers_out[i] =
+ gst_buffer_new_and_alloc (ladspa->buffer_frames * sizeof (gfloat));
GST_BUFFER_TIMESTAMP (buffers_out[i]) = ladspa->timestamp;
- data_out[i] = (LADSPA_Data*)GST_BUFFER_DATA (buffers_out[i]);
+ data_out[i] = (LADSPA_Data *) GST_BUFFER_DATA (buffers_out[i]);
}
-
- GST_DPMAN_PREPROCESS(ladspa->dpman, largest_buffer, ladspa->timestamp);
+
+ GST_DPMAN_PREPROCESS (ladspa->dpman, largest_buffer, ladspa->timestamp);
num_processed = 0;
/* split up processing of the buffer into chunks so that dparams can
* In many cases the buffer will be processed in one chunk anyway.
*/
while (GST_DPMAN_PROCESS (ladspa->dpman, num_processed)) {
- num_to_process = GST_DPMAN_FRAMES_TO_PROCESS(ladspa->dpman);
+ num_to_process = GST_DPMAN_FRAMES_TO_PROCESS (ladspa->dpman);
- for (i=0 ; i<numsinkpads ; i++)
- desc->connect_port (ladspa->handle, oclass->sinkpad_portnums[i], data_in[i]);
- for (i=0 ; i<numsrcpads ; i++)
- desc->connect_port (ladspa->handle, oclass->srcpad_portnums[i], data_out[i]);
+ for (i = 0; i < numsinkpads; i++)
+ desc->connect_port (ladspa->handle, oclass->sinkpad_portnums[i],
+ data_in[i]);
+ for (i = 0; i < numsrcpads; i++)
+ desc->connect_port (ladspa->handle, oclass->srcpad_portnums[i],
+ data_out[i]);
- desc->run(ladspa->handle, num_to_process);
+ desc->run (ladspa->handle, num_to_process);
- for (i=0 ; i<numsinkpads ; i++)
+ for (i = 0; i < numsinkpads; i++)
data_in[i] += num_to_process;
- for (i=0 ; i<numsrcpads ; i++)
+ for (i = 0; i < numsrcpads; i++)
data_out[i] += num_to_process;
-
+
num_processed += num_to_process;
}
-
- for (i=0 ; i<numsinkpads ; i++) {
+
+ for (i = 0; i < numsinkpads; i++) {
if (i >= numsrcpads || buffers_out[i] != buffers_in[i])
- gst_buffer_unref(buffers_in[i]);
+ gst_buffer_unref (buffers_in[i]);
data_in[i] = NULL;
buffers_in[i] = NULL;
- }
- for (i=0 ; i<numsrcpads ; i++) {
+ }
+ for (i = 0; i < numsrcpads; i++) {
DEBUG_OBJ (ladspa, "pushing buffer (%p) on src pad %d", buffers_out[i], i);
gst_pad_push (ladspa->srcpads[i], GST_DATA (buffers_out[i]));
-
+
data_out[i] = NULL;
buffers_out[i] = NULL;
}
-
+
ladspa->timestamp += ladspa->buffer_frames * GST_SECOND / ladspa->samplerate;
/* FIXME: move these mallocs and frees to the state-change handler */
}
static void
-gst_ladspa_chain (GstPad *pad, GstData *_data)
+gst_ladspa_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buffer_in = GST_BUFFER (_data);
LADSPA_Descriptor *desc;
GstLADSPA *ladspa;
GstLADSPAClass *oclass;
- ladspa = (GstLADSPA*)GST_OBJECT_PARENT (pad);
+ ladspa = (GstLADSPA *) GST_OBJECT_PARENT (pad);
oclass = (GstLADSPAClass *) (G_OBJECT_GET_CLASS (ladspa));
- data_in = (LADSPA_Data *) GST_BUFFER_DATA(buffer_in);
- num_samples = GST_BUFFER_SIZE(buffer_in) / sizeof(gfloat);
+ data_in = (LADSPA_Data *) GST_BUFFER_DATA (buffer_in);
+ num_samples = GST_BUFFER_SIZE (buffer_in) / sizeof (gfloat);
numsrcpads = oclass->numsrcpads;
desc = ladspa->descriptor;
/* we shouldn't get events here... */
g_return_if_fail (GST_IS_BUFFER (buffer_in));
-
+
/* FIXME: this function shouldn't need to malloc() anything */
if (numsrcpads > 0) {
- buffers_out = g_new(GstBuffer*, numsrcpads);
- data_out = g_new(LADSPA_Data*, numsrcpads);
+ buffers_out = g_new (GstBuffer *, numsrcpads);
+ data_out = g_new (LADSPA_Data *, numsrcpads);
}
- i=0;
+ i = 0;
if (!ladspa->inplace_broken && numsrcpads) {
/* reuse the first (chained) buffer */
buffers_out[i] = buffer_in;
data_out[i] = data_in;
i++;
}
- for (; i<numsrcpads; i++) {
- buffers_out[i] = gst_buffer_new_and_alloc (GST_BUFFER_SIZE(buffer_in));
+ for (; i < numsrcpads; i++) {
+ buffers_out[i] = gst_buffer_new_and_alloc (GST_BUFFER_SIZE (buffer_in));
DEBUG ("new %d", GST_BUFFER_SIZE (buffer_in));
GST_BUFFER_TIMESTAMP (buffers_out[i]) = ladspa->timestamp;
- data_out[i] = (LADSPA_Data*)GST_BUFFER_DATA (buffers_out[i]);
+ data_out[i] = (LADSPA_Data *) GST_BUFFER_DATA (buffers_out[i]);
}
- GST_DPMAN_PREPROCESS(ladspa->dpman, num_samples, GST_BUFFER_TIMESTAMP(buffer_in));
+ GST_DPMAN_PREPROCESS (ladspa->dpman, num_samples,
+ GST_BUFFER_TIMESTAMP (buffer_in));
num_processed = 0;
/* split up processing of the buffer into chunks so that dparams can
* be updated when required.
* In many cases the buffer will be processed in one chunk anyway.
*/
- while(GST_DPMAN_PROCESS(ladspa->dpman, num_processed)) {
- num_to_process = GST_DPMAN_FRAMES_TO_PROCESS(ladspa->dpman);
+ while (GST_DPMAN_PROCESS (ladspa->dpman, num_processed)) {
+ num_to_process = GST_DPMAN_FRAMES_TO_PROCESS (ladspa->dpman);
+
+ desc->connect_port (ladspa->handle, oclass->sinkpad_portnums[0], data_in);
+ for (i = 0; i < numsrcpads; i++)
+ desc->connect_port (ladspa->handle, oclass->srcpad_portnums[i],
+ data_out[i]);
- desc->connect_port(ladspa->handle,oclass->sinkpad_portnums[0],data_in);
- for (i=0 ; i<numsrcpads ; i++)
- desc->connect_port(ladspa->handle,oclass->srcpad_portnums[i],data_out[i]);
+ desc->run (ladspa->handle, num_to_process);
- desc->run(ladspa->handle, num_to_process);
-
data_in += num_to_process;
- for (i=0 ; i<numsrcpads ; i++)
+ for (i = 0; i < numsrcpads; i++)
data_out[i] += num_to_process;
num_processed += num_to_process;
}
if (!numsrcpads || buffers_out[0] != buffer_in)
- gst_buffer_unref(buffer_in);
+ gst_buffer_unref (buffer_in);
if (numsrcpads) {
- for (i=0; i<numsrcpads; i++) {
+ for (i = 0; i < numsrcpads; i++) {
DEBUG_OBJ (ladspa, "pushing buffer (%p, length %u bytes) on src pad %d",
- buffers_out[i], GST_BUFFER_SIZE (buffers_out[i]), i);
+ buffers_out[i], GST_BUFFER_SIZE (buffers_out[i]), i);
gst_pad_push (ladspa->srcpads[i], GST_DATA (buffers_out[i]));
}
- g_free(buffers_out);
- g_free(data_out);
+ g_free (buffers_out);
+ g_free (data_out);
}
}
static GstData *
-gst_ladspa_get(GstPad *pad)
-{
+gst_ladspa_get (GstPad * pad)
+{
GstLADSPA *ladspa;
GstLADSPAClass *oclass;
GstBuffer *buf;
LADSPA_Descriptor *desc;
guint num_to_process, num_processed;
- ladspa = (GstLADSPA *)gst_pad_get_parent (pad);
- oclass = (GstLADSPAClass*)(G_OBJECT_GET_CLASS(ladspa));
+ ladspa = (GstLADSPA *) gst_pad_get_parent (pad);
+ oclass = (GstLADSPAClass *) (G_OBJECT_GET_CLASS (ladspa));
desc = ladspa->descriptor;
/* 4096 is arbitrary */
buf = gst_buffer_new_and_alloc (4096);
- GST_BUFFER_TIMESTAMP(buf) = ladspa->timestamp;
- data = (LADSPA_Data *) GST_BUFFER_DATA(buf);
+ GST_BUFFER_TIMESTAMP (buf) = ladspa->timestamp;
+ data = (LADSPA_Data *) GST_BUFFER_DATA (buf);
- GST_DPMAN_PREPROCESS(ladspa->dpman, ladspa->buffer_frames, ladspa->timestamp);
+ GST_DPMAN_PREPROCESS (ladspa->dpman, ladspa->buffer_frames,
+ ladspa->timestamp);
num_processed = 0;
/* split up processing of the buffer into chunks so that dparams can
* be updated when required.
* In many cases the buffer will be processed in one chunk anyway.
*/
- while(GST_DPMAN_PROCESS(ladspa->dpman, num_processed)) {
- num_to_process = GST_DPMAN_FRAMES_TO_PROCESS(ladspa->dpman);
+ while (GST_DPMAN_PROCESS (ladspa->dpman, num_processed)) {
+ num_to_process = GST_DPMAN_FRAMES_TO_PROCESS (ladspa->dpman);
- /* update timestamp */
+ /* update timestamp */
ladspa->timestamp += num_to_process * GST_SECOND / ladspa->samplerate;
- desc->connect_port(ladspa->handle,oclass->srcpad_portnums[0],data);
+ desc->connect_port (ladspa->handle, oclass->srcpad_portnums[0], data);
+
+ desc->run (ladspa->handle, num_to_process);
- desc->run(ladspa->handle, num_to_process);
-
data += num_to_process;
num_processed = num_to_process;
}
-
+
return GST_DATA (buf);
}
static void
-ladspa_describe_plugin(const char *pcFullFilename,
- void *pvPluginHandle,
- LADSPA_Descriptor_Function pfDescriptorFunction)
+ladspa_describe_plugin (const char *pcFullFilename,
+ void *pvPluginHandle, LADSPA_Descriptor_Function pfDescriptorFunction)
{
const LADSPA_Descriptor *desc;
gint i;
GTypeInfo typeinfo = {
- sizeof(GstLADSPAClass),
- (GBaseInitFunc)gst_ladspa_base_init,
- NULL,
- (GClassInitFunc)gst_ladspa_class_init,
- NULL,
- NULL,
- sizeof(GstLADSPA),
- 0,
- (GInstanceInitFunc)gst_ladspa_init,
+ sizeof (GstLADSPAClass),
+ (GBaseInitFunc) gst_ladspa_base_init,
+ NULL,
+ (GClassInitFunc) gst_ladspa_class_init,
+ NULL,
+ NULL,
+ sizeof (GstLADSPA),
+ 0,
+ (GInstanceInitFunc) gst_ladspa_init,
};
GType type;
/* walk through all the plugins in this pluginlibrary */
i = 0;
- while ((desc = pfDescriptorFunction(i++))) {
+ while ((desc = pfDescriptorFunction (i++))) {
gchar *type_name;
/* construct the type */
- type_name = g_strdup_printf("ladspa-%s",desc->Label);
+ type_name = g_strdup_printf ("ladspa-%s", desc->Label);
g_strcanon (type_name, G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "-+", '-');
/* if it's already registered, drop it */
- if (g_type_from_name(type_name)) {
- g_free(type_name);
+ if (g_type_from_name (type_name)) {
+ g_free (type_name);
continue;
}
/* base-init temp alloc */
- g_hash_table_insert(ladspa_descriptors,
- GINT_TO_POINTER(0),
- (gpointer)desc);
+ g_hash_table_insert (ladspa_descriptors,
+ GINT_TO_POINTER (0), (gpointer) desc);
/* create the type now */
- type = g_type_register_static(GST_TYPE_ELEMENT, type_name, &typeinfo, 0);
+ type = g_type_register_static (GST_TYPE_ELEMENT, type_name, &typeinfo, 0);
if (!gst_element_register (ladspa_plugin, type_name, GST_RANK_NONE, type))
continue;
/* add this plugin to the hash */
- g_hash_table_insert(ladspa_descriptors,
- GINT_TO_POINTER(type),
- (gpointer)desc);
+ g_hash_table_insert (ladspa_descriptors,
+ GINT_TO_POINTER (type), (gpointer) desc);
}
g_hash_table_remove (ladspa_descriptors, GINT_TO_POINTER (0));
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
GST_DEBUG_CATEGORY_INIT (ladspa_debug, "ladspa",
- GST_DEBUG_FG_GREEN | GST_DEBUG_BG_BLACK | GST_DEBUG_BOLD,
- "LADSPA");
+ GST_DEBUG_FG_GREEN | GST_DEBUG_BG_BLACK | GST_DEBUG_BOLD, "LADSPA");
- ladspa_descriptors = g_hash_table_new(NULL,NULL);
- parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
+ ladspa_descriptors = g_hash_table_new (NULL, NULL);
+ parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
ladspa_plugin = plugin;
- LADSPAPluginSearch(ladspa_describe_plugin);
+ LADSPAPluginSearch (ladspa_describe_plugin);
/* initialize dparam support library */
- gst_control_init(NULL,NULL);
-
+ gst_control_init (NULL, NULL);
+
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "ladspa",
- "All LADSPA plugins",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "ladspa",
+ "All LADSPA plugins",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
-typedef struct _ladspa_control_info {
- gchar *name;
- gchar *param_name;
- gfloat lowerbound, upperbound;
- gfloat def;
- gboolean lower,upper,samplerate;
- gboolean toggled, logarithmic, integer, writable;
-} ladspa_control_info;
+ typedef struct _ladspa_control_info
+ {
+ gchar *name;
+ gchar *param_name;
+ gfloat lowerbound, upperbound;
+ gfloat def;
+ gboolean lower, upper, samplerate;
+ gboolean toggled, logarithmic, integer, writable;
+ } ladspa_control_info;
-typedef struct _GstLADSPA GstLADSPA;
-typedef struct _GstLADSPAClass GstLADSPAClass;
+ typedef struct _GstLADSPA GstLADSPA;
+ typedef struct _GstLADSPAClass GstLADSPAClass;
-struct _GstLADSPA {
- GstElement element;
+ struct _GstLADSPA
+ {
+ GstElement element;
- LADSPA_Descriptor *descriptor;
- LADSPA_Handle *handle;
+ LADSPA_Descriptor *descriptor;
+ LADSPA_Handle *handle;
- GstDParamManager *dpman;
+ GstDParamManager *dpman;
- gfloat *controls;
-
- GstPad **sinkpads,
- **srcpads;
+ gfloat *controls;
- gboolean activated;
+ GstPad **sinkpads, **srcpads;
- gint samplerate, buffer_frames;
- gint64 timestamp;
- gboolean inplace_broken;
-};
+ gboolean activated;
-struct _GstLADSPAClass {
- GstElementClass parent_class;
+ gint samplerate, buffer_frames;
+ gint64 timestamp;
+ gboolean inplace_broken;
+ };
- LADSPA_Descriptor *descriptor;
+ struct _GstLADSPAClass
+ {
+ GstElementClass parent_class;
- gint numports,
- numsinkpads,
- numsrcpads,
- numcontrols;
+ LADSPA_Descriptor *descriptor;
- gint *sinkpad_portnums,
- *srcpad_portnums,
- *control_portnums;
+ gint numports, numsinkpads, numsrcpads, numcontrols;
- ladspa_control_info *control_info;
-};
+ gint *sinkpad_portnums, *srcpad_portnums, *control_portnums;
+
+ ladspa_control_info *control_info;
+ };
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_LADSPA_H__ */
+#endif /* __GST_LADSPA_H__ */
not an absolute path (i.e. does not begin with / character), this
routine will search the LADSPA_PATH for the file. */
static void *
-dlopenLADSPA(const char * pcFilename, int iFlag) {
+dlopenLADSPA (const char *pcFilename, int iFlag)
+{
- char * pcBuffer;
- const char * pcEnd;
- const char * pcLADSPAPath;
- const char * pcStart;
+ char *pcBuffer;
+ const char *pcEnd;
+ const char *pcLADSPAPath;
+ const char *pcStart;
int iEndsInSO;
int iNeedSlash;
size_t iFilenameLength;
- void * pvResult;
+ void *pvResult;
- iFilenameLength = strlen(pcFilename);
+ iFilenameLength = strlen (pcFilename);
pvResult = NULL;
if (pcFilename[0] == '/') {
/* The filename is absolute. Assume the user knows what he/she is
doing and simply dlopen() it. */
- pvResult = dlopen(pcFilename, iFlag);
+ pvResult = dlopen (pcFilename, iFlag);
if (pvResult != NULL)
return pvResult;
- }
- else {
+ } else {
/* If the filename is not absolute then we wish to check along the
LADSPA_PATH path to see if we can find the file there. We do
*/
pcLADSPAPath = g_strdup_printf ("%s:/usr/lib/ladspa:/usr/local/lib/ladspa",
- getenv("LADSPA_PATH"));
-
+ getenv ("LADSPA_PATH"));
+
if (pcLADSPAPath) {
pcStart = pcLADSPAPath;
pcEnd = pcStart;
while (*pcEnd != ':' && *pcEnd != '\0')
pcEnd++;
-
- pcBuffer = malloc(iFilenameLength + 2 + (pcEnd - pcStart));
+
+ pcBuffer = malloc (iFilenameLength + 2 + (pcEnd - pcStart));
if (pcEnd > pcStart)
- strncpy(pcBuffer, pcStart, pcEnd - pcStart);
+ strncpy (pcBuffer, pcStart, pcEnd - pcStart);
iNeedSlash = 0;
if (pcEnd > pcStart)
if (*(pcEnd - 1) != '/') {
iNeedSlash = 1;
pcBuffer[pcEnd - pcStart] = '/';
}
- strcpy(pcBuffer + iNeedSlash + (pcEnd - pcStart), pcFilename);
-
- pvResult = dlopen(pcBuffer, iFlag);
-
+ strcpy (pcBuffer + iNeedSlash + (pcEnd - pcStart), pcFilename);
+
+ pvResult = dlopen (pcBuffer, iFlag);
+
free (pcBuffer);
if (pvResult != NULL)
return pvResult;
-
+
pcStart = pcEnd;
if (*pcStart == ':')
pcStart++;
".so". In this case, add this suffix and recurse. */
iEndsInSO = 0;
if (iFilenameLength > 3)
- iEndsInSO = (strcmp(pcFilename + iFilenameLength - 3, ".so") == 0);
+ iEndsInSO = (strcmp (pcFilename + iFilenameLength - 3, ".so") == 0);
if (!iEndsInSO) {
- pcBuffer = malloc(iFilenameLength + 4);
- strcpy(pcBuffer, pcFilename);
- strcat(pcBuffer, ".so");
- pvResult = dlopenLADSPA(pcBuffer, iFlag);
- free(pcBuffer);
+ pcBuffer = malloc (iFilenameLength + 4);
+ strcpy (pcBuffer, pcFilename);
+ strcat (pcBuffer, ".so");
+ pvResult = dlopenLADSPA (pcBuffer, iFlag);
+ free (pcBuffer);
}
if (pvResult != NULL)
will be kept when multiple calls are made to dlopen(). We've
covered the former case - now we can handle the latter by calling
dlopen() again here. */
- return dlopen(pcFilename, iFlag);
+ return dlopen (pcFilename, iFlag);
}
/*****************************************************************************/
void *
-loadLADSPAPluginLibrary(const char * pcPluginFilename) {
+loadLADSPAPluginLibrary (const char *pcPluginFilename)
+{
- void * pvPluginHandle;
+ void *pvPluginHandle;
- pvPluginHandle = dlopenLADSPA(pcPluginFilename, RTLD_NOW);
+ pvPluginHandle = dlopenLADSPA (pcPluginFilename, RTLD_NOW);
if (!pvPluginHandle) {
- fprintf(stderr,
- "Failed to load plugin \"%s\": %s\n",
- pcPluginFilename,
- dlerror());
- exit(1);
+ fprintf (stderr,
+ "Failed to load plugin \"%s\": %s\n", pcPluginFilename, dlerror ());
+ exit (1);
}
return pvPluginHandle;
/*****************************************************************************/
-void
-unloadLADSPAPluginLibrary(void * pvLADSPAPluginLibrary) {
- dlclose(pvLADSPAPluginLibrary);
+void
+unloadLADSPAPluginLibrary (void *pvLADSPAPluginLibrary)
+{
+ dlclose (pvLADSPAPluginLibrary);
}
/*****************************************************************************/
const LADSPA_Descriptor *
-findLADSPAPluginDescriptor(void * pvLADSPAPluginLibrary,
- const char * pcPluginLibraryFilename,
- const char * pcPluginLabel) {
+findLADSPAPluginDescriptor (void *pvLADSPAPluginLibrary,
+ const char *pcPluginLibraryFilename, const char *pcPluginLabel)
+{
- const LADSPA_Descriptor * psDescriptor;
+ const LADSPA_Descriptor *psDescriptor;
LADSPA_Descriptor_Function pfDescriptorFunction;
unsigned long lPluginIndex;
- dlerror();
- pfDescriptorFunction
- = (LADSPA_Descriptor_Function)dlsym(pvLADSPAPluginLibrary,
- "ladspa_descriptor");
+ dlerror ();
+ pfDescriptorFunction
+ = (LADSPA_Descriptor_Function) dlsym (pvLADSPAPluginLibrary,
+ "ladspa_descriptor");
if (!pfDescriptorFunction) {
- const char * pcError = dlerror();
+ const char *pcError = dlerror ();
+
if (pcError) {
- fprintf(stderr,
- "Unable to find ladspa_descriptor() function in plugin "
- "library file \"%s\": %s.\n"
- "Are you sure this is a LADSPA plugin file?\n",
- pcPluginLibraryFilename,
- pcError);
- exit(1);
+ fprintf (stderr,
+ "Unable to find ladspa_descriptor() function in plugin "
+ "library file \"%s\": %s.\n"
+ "Are you sure this is a LADSPA plugin file?\n",
+ pcPluginLibraryFilename, pcError);
+ exit (1);
}
}
for (lPluginIndex = 0;; lPluginIndex++) {
- psDescriptor = pfDescriptorFunction(lPluginIndex);
+ psDescriptor = pfDescriptorFunction (lPluginIndex);
if (psDescriptor == NULL) {
- fprintf(stderr,
- "Unable to find label \"%s\" in plugin library file \"%s\".\n",
- pcPluginLabel,
- pcPluginLibraryFilename);
- exit(1);
+ fprintf (stderr,
+ "Unable to find label \"%s\" in plugin library file \"%s\".\n",
+ pcPluginLabel, pcPluginLibraryFilename);
+ exit (1);
}
- if (strcmp(psDescriptor->Label, pcPluginLabel) == 0)
+ if (strcmp (psDescriptor->Label, pcPluginLabel) == 0)
return psDescriptor;
}
}
/* Search just the one directory. */
static void
-LADSPADirectoryPluginSearch
-(const char * pcDirectory,
- LADSPAPluginSearchCallbackFunction fCallbackFunction) {
+ LADSPADirectoryPluginSearch
+ (const char *pcDirectory,
+ LADSPAPluginSearchCallbackFunction fCallbackFunction)
+{
- char * pcFilename;
- DIR * psDirectory;
+ char *pcFilename;
+ DIR *psDirectory;
LADSPA_Descriptor_Function fDescriptorFunction;
long lDirLength;
long iNeedSlash;
- struct dirent * psDirectoryEntry;
- void * pvPluginHandle;
+ struct dirent *psDirectoryEntry;
+ void *pvPluginHandle;
- lDirLength = strlen(pcDirectory);
+ lDirLength = strlen (pcDirectory);
if (!lDirLength)
return;
if (pcDirectory[lDirLength - 1] == '/')
else
iNeedSlash = 1;
- psDirectory = opendir(pcDirectory);
+ psDirectory = opendir (pcDirectory);
if (!psDirectory)
return;
while (1) {
- psDirectoryEntry = readdir(psDirectory);
+ psDirectoryEntry = readdir (psDirectory);
if (!psDirectoryEntry) {
- closedir(psDirectory);
+ closedir (psDirectory);
return;
}
- pcFilename = malloc(lDirLength
- + strlen(psDirectoryEntry->d_name)
- + 1 + iNeedSlash);
- strcpy(pcFilename, pcDirectory);
+ pcFilename = malloc (lDirLength + strlen (psDirectoryEntry->d_name)
+ + 1 + iNeedSlash);
+ strcpy (pcFilename, pcDirectory);
if (iNeedSlash)
- strcat(pcFilename, "/");
- strcat(pcFilename, psDirectoryEntry->d_name);
-
- pvPluginHandle = dlopen(pcFilename, RTLD_LAZY);
+ strcat (pcFilename, "/");
+ strcat (pcFilename, psDirectoryEntry->d_name);
+
+ pvPluginHandle = dlopen (pcFilename, RTLD_LAZY);
if (pvPluginHandle) {
/* This is a file and the file is a shared library! */
- dlerror();
+ dlerror ();
fDescriptorFunction
- = (LADSPA_Descriptor_Function)dlsym(pvPluginHandle,
- "ladspa_descriptor");
- if (dlerror() == NULL && fDescriptorFunction) {
+ = (LADSPA_Descriptor_Function) dlsym (pvPluginHandle,
+ "ladspa_descriptor");
+ if (dlerror () == NULL && fDescriptorFunction) {
/* We've successfully found a ladspa_descriptor function. Pass
- it to the callback function. */
- fCallbackFunction(pcFilename,
- pvPluginHandle,
- fDescriptorFunction);
- }
- else {
+ it to the callback function. */
+ fCallbackFunction (pcFilename, pvPluginHandle, fDescriptorFunction);
+ } else {
/* It was a library, but not a LADSPA one. Unload it. */
- dlclose(pcFilename);
+ dlclose (pcFilename);
}
}
- free(pcFilename);
+ free (pcFilename);
}
}
/*****************************************************************************/
-void
-LADSPAPluginSearch(LADSPAPluginSearchCallbackFunction fCallbackFunction) {
+void
+LADSPAPluginSearch (LADSPAPluginSearchCallbackFunction fCallbackFunction)
+{
- char * pcBuffer;
- const char * pcEnd;
- const char * pcLADSPAPath;
- const char * pcStart;
+ char *pcBuffer;
+ const char *pcEnd;
+ const char *pcLADSPAPath;
+ const char *pcStart;
/* thomasvs: I'm sorry, but I'm going to add glib stuff here.
- * I'm appending logical values for LADSPA_PATH here
- */
+ * I'm appending logical values for LADSPA_PATH here
+ */
pcLADSPAPath = g_strdup_printf ("%s:/usr/lib/ladspa:/usr/local/lib/ladspa",
- getenv("LADSPA_PATH"));
+ getenv ("LADSPA_PATH"));
if (!pcLADSPAPath) {
/* fprintf(stderr, */
/* "environment variable set.\n"); */
return;
}
-
+
pcStart = pcLADSPAPath;
while (*pcStart != '\0') {
pcEnd = pcStart;
while (*pcEnd != ':' && *pcEnd != '\0')
pcEnd++;
-
- pcBuffer = malloc(1 + pcEnd - pcStart);
+
+ pcBuffer = malloc (1 + pcEnd - pcStart);
if (pcEnd > pcStart)
- strncpy(pcBuffer, pcStart, pcEnd - pcStart);
+ strncpy (pcBuffer, pcStart, pcEnd - pcStart);
pcBuffer[pcEnd - pcStart] = '\0';
-
- LADSPADirectoryPluginSearch(pcBuffer, fCallbackFunction);
- free(pcBuffer);
+
+ LADSPADirectoryPluginSearch (pcBuffer, fCallbackFunction);
+ free (pcBuffer);
pcStart = pcEnd;
if (*pcStart == ':')
unloadLADSPAPluginLibrary(). Errors are handled by writing a
message to stderr and calling exit(1). It is alright (although
inefficient) to call this more than once for the same file. */
-void * loadLADSPAPluginLibrary(const char * pcPluginFilename);
+void *loadLADSPAPluginLibrary (const char *pcPluginFilename);
/* This function unloads a LADSPA plugin library. */
-void unloadLADSPAPluginLibrary(void * pvLADSPAPluginLibrary);
+void unloadLADSPAPluginLibrary (void *pvLADSPAPluginLibrary);
/* This function locates a LADSPA plugin within a plugin library
loaded with loadLADSPAPluginLibrary(). Errors are handled by
writing a message to stderr and calling exit(1). Note that the
plugin library filename is only included to help provide
informative error messages. */
-const LADSPA_Descriptor *
-findLADSPAPluginDescriptor(void * pvLADSPAPluginLibrary,
- const char * pcPluginLibraryFilename,
- const char * pcPluginLabel);
+const LADSPA_Descriptor *findLADSPAPluginDescriptor (void
+ *pvLADSPAPluginLibrary, const char *pcPluginLibraryFilename,
+ const char *pcPluginLabel);
/*****************************************************************************/
style) and a LADSPA_DescriptorFunction (from which
LADSPA_Descriptors can be acquired). */
typedef void LADSPAPluginSearchCallbackFunction
-(const char * pcFullFilename,
- void * pvPluginHandle,
- LADSPA_Descriptor_Function fDescriptorFunction);
+ (const char *pcFullFilename,
+ void *pvPluginHandle, LADSPA_Descriptor_Function fDescriptorFunction);
/* Search through the $(LADSPA_PATH) (or a default path) for any
LADSPA plugin libraries. Each plugin library is tested using
dlopen() and dlsym(,"ladspa_descriptor"). After loading each
library, the callback function is called to process it. This
function leaves items passed to the callback function open. */
-void LADSPAPluginSearch(LADSPAPluginSearchCallbackFunction fCallbackFunction);
+void LADSPAPluginSearch (LADSPAPluginSearchCallbackFunction fCallbackFunction);
/*****************************************************************************/
typedef struct _GstColorspace GstColorspace;
typedef struct _GstColorspaceClass GstColorspaceClass;
-struct _GstColorspace {
- GstElement element;
+struct _GstColorspace
+{
+ GstElement element;
+
+ GstPad *sinkpad, *srcpad;
- GstPad *sinkpad, *srcpad;
+ LCSConverter *converter;
- LCSConverter *converter;
-
- gboolean passthrough;
- gint width, height;
- double framerate;
- gboolean disabled;
+ gboolean passthrough;
+ gint width, height;
+ double framerate;
+ gboolean disabled;
};
-struct _GstColorspaceClass {
+struct _GstColorspaceClass
+{
GstElementClass parent_class;
};
/* Stereo signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_SOURCE,
ARG_DEST,
};
-static GType gst_colorspace_get_type (void);
+static GType gst_colorspace_get_type (void);
-static void gst_colorspace_class_init (GstColorspaceClass *klass);
-static void gst_colorspace_base_init (GstColorspaceClass *klass);
-static void gst_colorspace_init (GstColorspace *space);
+static void gst_colorspace_class_init (GstColorspaceClass * klass);
+static void gst_colorspace_base_init (GstColorspaceClass * klass);
+static void gst_colorspace_init (GstColorspace * space);
-static void gst_colorspace_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_colorspace_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static void gst_colorspace_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_colorspace_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
static GstPadLinkReturn
- gst_colorspace_link (GstPad *pad, const GstCaps *caps);
-static void gst_colorspace_chain (GstPad *pad, GstData *_data);
-static GstElementStateReturn
- gst_colorspace_change_state (GstElement *element);
+gst_colorspace_link (GstPad * pad, const GstCaps * caps);
+static void gst_colorspace_chain (GstPad * pad, GstData * _data);
+static GstElementStateReturn gst_colorspace_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_colorspace_signals[LAST_SIGNAL] = { 0 }; */
static GstStaticPadTemplate gst_colorspace_src_template =
-GST_STATIC_PAD_TEMPLATE (
- "src",
+ GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- GST_VIDEO_CAPS_RGB "; "
- GST_VIDEO_CAPS_BGR "; "
- GST_VIDEO_CAPS_RGBx "; "
- GST_VIDEO_CAPS_xRGB "; "
- GST_VIDEO_CAPS_BGRx "; "
- GST_VIDEO_CAPS_xBGR "; "
- GST_VIDEO_CAPS_RGB_16 "; "
- GST_VIDEO_CAPS_RGB_15 "; "
- GST_VIDEO_CAPS_YUV("{ I420, YV12, YUY2, YVYU, UYVY, YUV9, YVU9, "
- "Y800, Y41P, Y41B, Y42B, IUY2 }")
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB "; "
+ GST_VIDEO_CAPS_BGR "; "
+ GST_VIDEO_CAPS_RGBx "; "
+ GST_VIDEO_CAPS_xRGB "; "
+ GST_VIDEO_CAPS_BGRx "; "
+ GST_VIDEO_CAPS_xBGR "; "
+ GST_VIDEO_CAPS_RGB_16 "; "
+ GST_VIDEO_CAPS_RGB_15 "; "
+ GST_VIDEO_CAPS_YUV ("{ I420, YV12, YUY2, YVYU, UYVY, YUV9, YVU9, "
+ "Y800, Y41P, Y41B, Y42B, IUY2 }")
)
-);
+ );
static GstStaticPadTemplate gst_colorspace_sink_template =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
+ GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- GST_VIDEO_CAPS_RGB "; "
- GST_VIDEO_CAPS_BGR "; "
- GST_VIDEO_CAPS_RGBx "; "
- GST_VIDEO_CAPS_xRGB "; "
- GST_VIDEO_CAPS_BGRx "; "
- GST_VIDEO_CAPS_xBGR "; "
- GST_VIDEO_CAPS_RGB_16 "; "
- GST_VIDEO_CAPS_RGB_15 "; "
- GST_VIDEO_CAPS_YUV("{ I420, YV12, YUY2, YVYU, UYVY, YUV9, YVU9, "
- "Y800, Y41P, Y41B, Y42B, IUY2 }")
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB "; "
+ GST_VIDEO_CAPS_BGR "; "
+ GST_VIDEO_CAPS_RGBx "; "
+ GST_VIDEO_CAPS_xRGB "; "
+ GST_VIDEO_CAPS_BGRx "; "
+ GST_VIDEO_CAPS_xBGR "; "
+ GST_VIDEO_CAPS_RGB_16 "; "
+ GST_VIDEO_CAPS_RGB_15 "; "
+ GST_VIDEO_CAPS_YUV ("{ I420, YV12, YUY2, YVYU, UYVY, YUV9, YVU9, "
+ "Y800, Y41P, Y41B, Y42B, IUY2 }")
)
-);
+ );
-static const LCSFormat*
-colorspace_find_lcs_format (const GstCaps *caps)
+static const LCSFormat *
+colorspace_find_lcs_format (const GstCaps * caps)
{
const LCSFormat *format = NULL;
const char *name;
((LCSFormat *) rgb_fmt)->type = LCS_FORMAT_RGB_PACKED;
gst_structure_get_int (structure, "bpp",
- &((LCSFormat *) rgb_fmt)->bits_per_pixel);
+ &((LCSFormat *) rgb_fmt)->bits_per_pixel);
gst_structure_get_int (structure, "red_mask", &mask);
lcs_utils_mask_to_shift (mask, &rgb_fmt->bits_per_component[LCS_R],
- &rgb_fmt->component_bit_offset[LCS_R]);
+ &rgb_fmt->component_bit_offset[LCS_R]);
gst_structure_get_int (structure, "green_mask", &mask);
lcs_utils_mask_to_shift (mask, &rgb_fmt->bits_per_component[LCS_G],
- &rgb_fmt->component_bit_offset[LCS_G]);
+ &rgb_fmt->component_bit_offset[LCS_G]);
gst_structure_get_int (structure, "blue_mask", &mask);
lcs_utils_mask_to_shift (mask, &rgb_fmt->bits_per_component[LCS_B],
- &rgb_fmt->component_bit_offset[LCS_B]);
+ &rgb_fmt->component_bit_offset[LCS_B]);
rgb_fmt->bits_per_component[LCS_A] = 0;
rgb_fmt->component_bit_offset[LCS_A] = 0;
gst_structure_get_int (structure, "endianness", &endianness);
format_name = g_strdup_printf ("GST_RGB_%d", format->bits_per_pixel);
lcs_register_format (format_name, (LCSFormat *) rgb_fmt, 1);
- }
- else if (strcmp (name, "video/x-raw-yuv") == 0) {
+ } else if (strcmp (name, "video/x-raw-yuv") == 0) {
guint32 space;
gchar fourcc[5];
fourcc[4] = '\0';
format = lcs_find_format (fourcc);
} else {
- g_assert_not_reached();
+ g_assert_not_reached ();
}
return format;
}
static guint32
-gst_colorspace_caps_get_fourcc (const GstCaps *caps)
+gst_colorspace_caps_get_fourcc (const GstCaps * caps)
{
guint32 format;
GstStructure *structure;
structure = gst_caps_get_structure (caps, 0);
if (strcmp (gst_structure_get_name (structure), "video/x-raw-rgb") == 0) {
- format = GST_MAKE_FOURCC ('R','G','B',' ');
+ format = GST_MAKE_FOURCC ('R', 'G', 'B', ' ');
} else {
gst_structure_get_fourcc (structure, "format", &format);
}
return format;
}
-static gboolean
-colorspace_setup_converter (GstColorspace *space, const GstCaps *from_caps,
- const GstCaps *to_caps)
+static gboolean
+colorspace_setup_converter (GstColorspace * space, const GstCaps * from_caps,
+ const GstCaps * to_caps)
{
const LCSFormat *from_format = NULL;
const LCSFormat *to_format = NULL;
from_space = gst_colorspace_caps_get_fourcc (from_caps);
to_space = gst_colorspace_caps_get_fourcc (to_caps);
- from_format = colorspace_find_lcs_format (from_caps);
- to_format = colorspace_find_lcs_format (to_caps);
-
+ from_format = colorspace_find_lcs_format (from_caps);
+ to_format = colorspace_find_lcs_format (to_caps);
+
GST_DEBUG ("trying from " GST_FOURCC_FORMAT " to " GST_FOURCC_FORMAT,
- GST_FOURCC_ARGS (from_space),
- GST_FOURCC_ARGS (to_space));
+ GST_FOURCC_ARGS (from_space), GST_FOURCC_ARGS (to_space));
space->converter = lcs_find_converter (from_format, to_format, LCS_FLAG_FAST);
if (space->converter) {
GST_DEBUG ("trying from " GST_FOURCC_FORMAT " to " GST_FOURCC_FORMAT,
- GST_FOURCC_ARGS (from_space),
- GST_FOURCC_ARGS (to_space));
+ GST_FOURCC_ARGS (from_space), GST_FOURCC_ARGS (to_space));
space->disabled = FALSE;
return TRUE;
}
return FALSE;
}
-static GstCaps*
-gst_colorspace_getcaps (GstPad *pad)
+static GstCaps *
+gst_colorspace_getcaps (GstPad * pad)
{
#if unused
GstColorspace *space;
GstCaps *result;
GstCaps *peercaps;
GstCaps *ourcaps;
-
+
space = GST_COLORSPACE (gst_pad_get_parent (pad));
/* we can do everything our peer can... */
}
static GstPadLinkReturn
-gst_colorspace_link (GstPad *pad, const GstCaps *caps)
+gst_colorspace_link (GstPad * pad, const GstCaps * caps)
{
GstStructure *structure;
GstPad *otherpad;
othercaps = gst_caps_copy (gst_pad_get_negotiated_caps (otherpad));
gst_caps_set_simple (othercaps,
- "width", G_TYPE_INT, width,
- "height", G_TYPE_INT, height,
- "framerate", G_TYPE_DOUBLE, framerate,
- NULL);
+ "width", G_TYPE_INT, width,
+ "height", G_TYPE_INT, height,
+ "framerate", G_TYPE_DOUBLE, framerate, NULL);
ret = gst_pad_try_set_caps (otherpad, othercaps);
if (!GST_PAD_LINK_SUCCESSFUL (ret)) {
return GST_PAD_LINK_REFUSED;
}
}
-
+
return GST_PAD_LINK_OK;
}
if (!colorspace_type) {
static const GTypeInfo colorspace_info = {
- sizeof(GstColorspaceClass),
- (GBaseInitFunc)gst_colorspace_base_init,
+ sizeof (GstColorspaceClass),
+ (GBaseInitFunc) gst_colorspace_base_init,
NULL,
- (GClassInitFunc)gst_colorspace_class_init,
+ (GClassInitFunc) gst_colorspace_class_init,
NULL,
NULL,
- sizeof(GstColorspace),
+ sizeof (GstColorspace),
0,
- (GInstanceInitFunc)gst_colorspace_init,
+ (GInstanceInitFunc) gst_colorspace_init,
};
- colorspace_type = g_type_register_static(GST_TYPE_ELEMENT, "GstColorspaceLCS", &colorspace_info, 0);
+ colorspace_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstColorspaceLCS",
+ &colorspace_info, 0);
}
return colorspace_type;
}
static void
-gst_colorspace_base_init (GstColorspaceClass *klass)
+gst_colorspace_base_init (GstColorspaceClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
}
static void
-gst_colorspace_class_init (GstColorspaceClass *klass)
+gst_colorspace_class_init (GstColorspaceClass * 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);
gobject_class->set_property = gst_colorspace_set_property;
gobject_class->get_property = gst_colorspace_get_property;
}
static void
-gst_colorspace_init (GstColorspace *space)
+gst_colorspace_init (GstColorspace * space)
{
- space->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get(&gst_colorspace_sink_template), "sink");
+ space->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_colorspace_sink_template), "sink");
gst_pad_set_link_function (space->sinkpad, gst_colorspace_link);
gst_pad_set_getcaps_function (space->sinkpad, gst_colorspace_getcaps);
- gst_pad_set_chain_function(space->sinkpad,gst_colorspace_chain);
- gst_element_add_pad(GST_ELEMENT(space),space->sinkpad);
+ gst_pad_set_chain_function (space->sinkpad, gst_colorspace_chain);
+ gst_element_add_pad (GST_ELEMENT (space), space->sinkpad);
- space->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get(&gst_colorspace_src_template), "src");
- gst_element_add_pad(GST_ELEMENT(space),space->srcpad);
+ space->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_colorspace_src_template), "src");
+ gst_element_add_pad (GST_ELEMENT (space), space->srcpad);
gst_pad_set_link_function (space->srcpad, gst_colorspace_link);
space->disabled = TRUE;
}
static void
-gst_colorspace_chain (GstPad *pad,GstData *_data)
+gst_colorspace_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstColorspace *space;
g_return_if_fail (buf != NULL);
space = GST_COLORSPACE (gst_pad_get_parent (pad));
-
+
g_return_if_fail (space != NULL);
g_return_if_fail (GST_IS_COLORSPACE (space));
if (space->passthrough) {
outbuf = buf;
- }
- else {
+ } else {
unsigned long size;
- lcs_format_buffer_size (
- lcs_converter_get_dest_format (space->converter),
- space->width, space->height, &size);
+ lcs_format_buffer_size (lcs_converter_get_dest_format (space->converter),
+ space->width, space->height, &size);
outbuf = gst_pad_alloc_buffer (space->srcpad, GST_BUFFER_OFFSET_NONE, size);
- lcs_convert_auto (space->converter,
- GST_BUFFER_DATA (buf),
- GST_BUFFER_DATA (outbuf),
- space->width, space->height);
+ lcs_convert_auto (space->converter,
+ GST_BUFFER_DATA (buf),
+ GST_BUFFER_DATA (outbuf), space->width, space->height);
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buf);
}
static GstElementStateReturn
-gst_colorspace_change_state (GstElement *element)
+gst_colorspace_change_state (GstElement * element)
{
GstColorspace *space;
}
static void
-gst_colorspace_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_colorspace_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstColorspace *space;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_COLORSPACE(object));
- space = GST_COLORSPACE(object);
+ g_return_if_fail (GST_IS_COLORSPACE (object));
+ space = GST_COLORSPACE (object);
switch (prop_id) {
default:
}
static void
-gst_colorspace_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_colorspace_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstColorspace *space;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_COLORSPACE(object));
- space = GST_COLORSPACE(object);
+ g_return_if_fail (GST_IS_COLORSPACE (object));
+ space = GST_COLORSPACE (object);
switch (prop_id) {
default:
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
lcs_init (NULL, NULL);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "colorspacelcs",
- "LCS colorspace convertor",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "colorspacelcs",
+ "LCS colorspace convertor",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
#include "gstlibfame.h"
#include <gst/video/video.h>
-#define FAMEENC_BUFFER_SIZE (300 * 1024)
+#define FAMEENC_BUFFER_SIZE (300 * 1024)
/* elementfactory information */
static GstElementDetails gst_fameenc_details = {
/* FameEnc signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_VERSION,
ARG_BITRATE,
ARG_FRAMES_PER_SEQUENCE,
/* dynamically generated properties start here */
ARG_FAME_PROPS_START
- /* FILL ME */
+ /* FILL ME */
};
-static GstStaticPadTemplate sink_template =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "video/x-raw-yuv, "
- "format = (fourcc) I420, "
- "width = (int) [ 16, 4096 ], "
- "height = (int) [ 16, 4096 ], "
- "framerate = (double) { 23.976024, 24.0, 25.0, 29.970030, 30.0, "
- " 50.0, 59.940060, 60.0 }"
- )
-);
-
-static GstStaticPadTemplate src_template =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "video/mpeg, "
- "mpegversion = (int) { 1, 4 }, "
- "systemstream = (boolean) FALSE, "
- "width = (int) [ 16, 4096 ], "
- "height = (int) [ 16, 4096 ], "
- "framerate = (double) { 23.976024, 24.0, 25.0, 29.970030, 30.0, "
- " 50.0, 59.940060, 60.0 }"
- )
-);
+static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/x-raw-yuv, "
+ "format = (fourcc) I420, "
+ "width = (int) [ 16, 4096 ], "
+ "height = (int) [ 16, 4096 ], "
+ "framerate = (double) { 23.976024, 24.0, 25.0, 29.970030, 30.0, "
+ " 50.0, 59.940060, 60.0 }")
+ );
+
+static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/mpeg, "
+ "mpegversion = (int) { 1, 4 }, "
+ "systemstream = (boolean) FALSE, "
+ "width = (int) [ 16, 4096 ], "
+ "height = (int) [ 16, 4096 ], "
+ "framerate = (double) { 23.976024, 24.0, 25.0, 29.970030, 30.0, "
+ " 50.0, 59.940060, 60.0 }")
+ );
#define MAX_FRAME_RATES 9
typedef struct
gint den;
} frame_rate_entry;
-static const frame_rate_entry frame_rates[] =
-{
- { 0, 0 },
- { 24000, 1001 },
- { 24, 1 },
- { 25, 1 },
- { 30000, 1001 },
- { 30, 1 },
- { 50, 1 },
- { 60000, 1001 },
- { 60, 1 },
+static const frame_rate_entry frame_rates[] = {
+ {0, 0},
+ {24000, 1001},
+ {24, 1},
+ {25, 1},
+ {30000, 1001},
+ {30, 1},
+ {50, 1},
+ {60000, 1001},
+ {60, 1},
};
static gint
{
gint i;
gint idx = -1;
-
+
for (i = 1; i < MAX_FRAME_RATES; i++) {
if (idx == -1) {
idx = i;
} else {
- gfloat old_diff = fabs((1. * frame_rates[idx].num /
- frame_rates[idx].den) - fps),
- new_diff = fabs((1. * frame_rates[i].num /
- frame_rates[i].den) - fps);
+ gfloat old_diff = fabs ((1. * frame_rates[idx].num /
+ frame_rates[idx].den) - fps),
+ new_diff = fabs ((1. * frame_rates[i].num /
+ frame_rates[i].den) - fps);
if (new_diff < old_diff) {
- idx = i;
+ idx = i;
}
}
}
return idx;
}
-static void gst_fameenc_class_init (GstFameEncClass *klass);
-static void gst_fameenc_base_init (GstFameEncClass *klass);
-static void gst_fameenc_init (GstFameEnc *fameenc);
-static void gst_fameenc_dispose (GObject *object);
+static void gst_fameenc_class_init (GstFameEncClass * klass);
+static void gst_fameenc_base_init (GstFameEncClass * klass);
+static void gst_fameenc_init (GstFameEnc * fameenc);
+static void gst_fameenc_dispose (GObject * object);
-static void gst_fameenc_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_fameenc_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static void gst_fameenc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_fameenc_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static void gst_fameenc_chain (GstPad *pad, GstData *_data);
+static void gst_fameenc_chain (GstPad * pad, GstData * _data);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_fameenc_signals[LAST_SIGNAL] = { 0 };*/
GType
if (!fameenc_type) {
static const GTypeInfo fameenc_info = {
- sizeof (GstFameEncClass),
+ sizeof (GstFameEncClass),
(GBaseInitFunc) gst_fameenc_base_init,
NULL,
(GClassInitFunc) gst_fameenc_class_init,
0,
(GInstanceInitFunc) gst_fameenc_init,
};
- fameenc_type = g_type_register_static (GST_TYPE_ELEMENT,
- "GstFameEnc", &fameenc_info, 0);
+ fameenc_type = g_type_register_static (GST_TYPE_ELEMENT,
+ "GstFameEnc", &fameenc_info, 0);
}
return fameenc_type;
}
static int
-gst_fameenc_item_compare (fame_list_t *item1, fame_list_t *item2)
+gst_fameenc_item_compare (fame_list_t * item1, fame_list_t * item2)
{
return strcmp (item1->type, item2->type);
}
static void
-gst_fameenc_base_init (GstFameEncClass *klass)
+gst_fameenc_base_init (GstFameEncClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&sink_template));
+ gst_static_pad_template_get (&sink_template));
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&src_template));
+ gst_static_pad_template_get (&src_template));
gst_element_class_set_details (element_class, &gst_fameenc_details);
}
static void
-gst_fameenc_class_init (GstFameEncClass *klass)
+gst_fameenc_class_init (GstFameEncClass * klass)
{
GObjectClass *gobject_class = NULL;
GstElementClass *gstelement_class = NULL;
GList *props = NULL, *props_walk;
gint current_prop = ARG_FAME_PROPS_START;
- 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);
/* first sort the list */
walk = context->type_list;
while (walk) {
- props = g_list_insert_sorted (props, walk, (GCompareFunc)gst_fameenc_item_compare);
+ props =
+ g_list_insert_sorted (props, walk,
+ (GCompareFunc) gst_fameenc_item_compare);
walk = walk->next;
}
fame_object_t *current_default;
gint default_index;
- walk = (fame_list_t *)props_walk->data;
+ walk = (fame_list_t *) props_walk->data;
array = g_array_new (TRUE, FALSE, sizeof (GEnumValue));
current_type = walk->type;
if (strstr (walk->type, "/")) {
GEnumValue value;
- if (current_default == walk->item)
- default_index = current_value;
+ if (current_default == walk->item)
+ default_index = current_value;
value.value = current_value++;
value.value_name = g_strdup (walk->type);
value.value_nick = g_strdup (walk->item->name);
-
+
g_array_append_val (array, value);
}
props_walk = g_list_next (props_walk);
if (props_walk)
- walk = (fame_list_t *)props_walk->data;
+ walk = (fame_list_t *) props_walk->data;
} while (props_walk && !strncmp (walk->type, current_type, current_len));
if (array->len > 0) {
GType type;
GParamSpec *pspec;
-
- type = g_enum_register_static (g_strdup_printf ("GstFameEnc_%s", current_type), (GEnumValue *)array->data);
- pspec = g_param_spec_enum (current_type, current_type, g_strdup_printf ("The FAME \"%s\" object", current_type),
- type, default_index, G_PARAM_READWRITE);
+ type =
+ g_enum_register_static (g_strdup_printf ("GstFameEnc_%s",
+ current_type), (GEnumValue *) array->data);
+
+ pspec =
+ g_param_spec_enum (current_type, current_type,
+ g_strdup_printf ("The FAME \"%s\" object", current_type), type,
+ default_index, G_PARAM_READWRITE);
g_param_spec_set_qdata (pspec, fame_object_name, (gpointer) current_type);
-
- g_object_class_install_property (G_OBJECT_CLASS (klass), current_prop++, pspec);
+
+ g_object_class_install_property (G_OBJECT_CLASS (klass), current_prop++,
+ pspec);
}
}
g_object_class_install_property (gobject_class, ARG_BITRATE,
- g_param_spec_int ("bitrate", "Bitrate", "Target bitrate (0 = VBR)",
- 0, 5000000, 0, G_PARAM_READWRITE));
+ g_param_spec_int ("bitrate", "Bitrate", "Target bitrate (0 = VBR)",
+ 0, 5000000, 0, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_QUALITY,
- g_param_spec_int ("quality", "Quality", "Percentage of quality of compression (versus size)",
- 0, 100, 75, G_PARAM_READWRITE));
+ g_param_spec_int ("quality", "Quality",
+ "Percentage of quality of compression (versus size)", 0, 100, 75,
+ G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_PATTERN,
- g_param_spec_string ("pattern", "Pattern", "Encoding pattern of I, P, and B frames",
- "IPPPPPPPPPPP", G_PARAM_READWRITE));
+ g_param_spec_string ("pattern", "Pattern",
+ "Encoding pattern of I, P, and B frames", "IPPPPPPPPPPP",
+ G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_FRAMES_PER_SEQUENCE,
- g_param_spec_int ("frames_per_sequence", "Frames Per Sequence",
- "The number of frames in one sequence",
- 1, G_MAXINT, 12, G_PARAM_READWRITE));
+ g_param_spec_int ("frames_per_sequence", "Frames Per Sequence",
+ "The number of frames in one sequence", 1, G_MAXINT, 12,
+ G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_FAME_VERBOSE,
- g_param_spec_boolean ("fame_verbose", "Fame Verbose", "Make FAME produce verbose output",
- FALSE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("fame_verbose", "Fame Verbose",
+ "Make FAME produce verbose output", FALSE, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_BUFFER_SIZE,
- g_param_spec_int ("buffer_size", "Buffer Size", "Set the decoding output buffer size",
- 0, 1024*1024, FAMEENC_BUFFER_SIZE, G_PARAM_READWRITE));
+ g_param_spec_int ("buffer_size", "Buffer Size",
+ "Set the decoding output buffer size", 0, 1024 * 1024,
+ FAMEENC_BUFFER_SIZE, G_PARAM_READWRITE));
}
static GstPadLinkReturn
-gst_fameenc_sink_link (GstPad *pad, const GstCaps *caps)
+gst_fameenc_sink_link (GstPad * pad, const GstCaps * caps)
{
gint width, height, fps_idx;
gdouble fps;
gst_structure_get_int (structure, "width", &width);
gst_structure_get_int (structure, "height", &height);
gst_structure_get_double (structure, "framerate", &fps);
-
+
/* fameenc requires width and height to be multiples of 16 */
if (width % 16 != 0 || height % 16 != 0)
return GST_PAD_LINK_REFUSED;
fameenc->initialized = TRUE;
fameenc->time_interval = 0;
-
+
return GST_PAD_LINK_OK;
}
static void
-gst_fameenc_init (GstFameEnc *fameenc)
+gst_fameenc_init (GstFameEnc * fameenc)
{
g_assert (fameenc != NULL);
g_assert (GST_IS_FAMEENC (fameenc));
g_assert (fameenc->fc != NULL);
/* create the sink and src pads */
- fameenc->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&sink_template), "sink");
+ fameenc->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get (&sink_template),
+ "sink");
gst_element_add_pad (GST_ELEMENT (fameenc), fameenc->sinkpad);
gst_pad_set_chain_function (fameenc->sinkpad, gst_fameenc_chain);
gst_pad_set_link_function (fameenc->sinkpad, gst_fameenc_sink_link);
- fameenc->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&src_template), "src");
+ fameenc->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get (&src_template),
+ "src");
gst_element_add_pad (GST_ELEMENT (fameenc), fameenc->srcpad);
/* FIXME: set some more handler functions here */
fameenc->fp.bitrate = 0;
fameenc->fp.quality = 75;
fameenc->fp.frame_rate_num = 25;
- fameenc->fp.frame_rate_den = 1; /* avoid floating point exceptions */
- fameenc->fp.frames_per_sequence = 12;
+ fameenc->fp.frame_rate_den = 1; /* avoid floating point exceptions */
+ fameenc->fp.frames_per_sequence = 12;
fameenc->pattern = g_strdup ("IPPPPPPPPPP");
/* allocate space for the buffer */
- fameenc->buffer_size = FAMEENC_BUFFER_SIZE; /* FIXME */
+ fameenc->buffer_size = FAMEENC_BUFFER_SIZE; /* FIXME */
fameenc->buffer = (unsigned char *) g_malloc (fameenc->buffer_size);
-
- fameenc->next_time = 0;
+
+ fameenc->next_time = 0;
fameenc->time_interval = 0;
}
static void
-gst_fameenc_dispose (GObject *object)
+gst_fameenc_dispose (GObject * object)
{
GstFameEnc *fameenc = GST_FAMEENC (object);
}
static void
-gst_fameenc_chain (GstPad *pad, GstData *_data)
+gst_fameenc_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstFameEnc *fameenc;
data = (guchar *) GST_BUFFER_DATA (buf);
size = GST_BUFFER_SIZE (buf);
- GST_DEBUG ("gst_fameenc_chain: got buffer of %ld bytes in '%s'",
- size, GST_OBJECT_NAME (fameenc));
+ GST_DEBUG ("gst_fameenc_chain: got buffer of %ld bytes in '%s'",
+ size, GST_OBJECT_NAME (fameenc));
/* the data contains the three planes side by side, with size w * h, w * h /4,
* w * h / 4 */
frame_size = fameenc->fp.width * fameenc->fp.height;
- fameenc->fy.p = 0;
+ fameenc->fy.p = 0;
fameenc->fy.y = data;
fameenc->fy.u = data + frame_size;
fameenc->fy.v = fameenc->fy.u + (frame_size >> 2);
/* FIXME: safeguard, remove me when a better way is found */
if (length > FAMEENC_BUFFER_SIZE)
- g_warning ("FAMEENC_BUFFER_SIZE is defined too low, encoded slice has size %d !\n", length);
+ g_warning
+ ("FAMEENC_BUFFER_SIZE is defined too low, encoded slice has size %d !\n",
+ length);
if (!fameenc->time_interval) {
- fameenc->time_interval = GST_SECOND * fameenc->fp.frame_rate_den / fameenc->fp.frame_rate_num;
+ fameenc->time_interval =
+ GST_SECOND * fameenc->fp.frame_rate_den / fameenc->fp.frame_rate_num;
}
fameenc->next_time += fameenc->time_interval;
GST_BUFFER_SIZE (outbuf) = length;
GST_BUFFER_TIMESTAMP (outbuf) = fameenc->next_time;
GST_BUFFER_DATA (outbuf) = g_malloc (length);
- memcpy (GST_BUFFER_DATA(outbuf), fameenc->buffer, length);
+ memcpy (GST_BUFFER_DATA (outbuf), fameenc->buffer, length);
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
GST_DEBUG ("gst_fameenc_chain: pushing buffer of size %d",
- GST_BUFFER_SIZE(outbuf));
+ GST_BUFFER_SIZE (outbuf));
gst_pad_push (fameenc->srcpad, GST_DATA (outbuf));
}
- fame_end_frame (fameenc->fc, NULL);
+ fame_end_frame (fameenc->fc, NULL);
- gst_buffer_unref(buf);
+ gst_buffer_unref (buf);
}
static void
-gst_fameenc_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
+gst_fameenc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstFameEnc *fameenc;
fameenc = GST_FAMEENC (object);
if (fameenc->initialized) {
- GST_DEBUG ("error: fameenc encoder already initialized, cannot set properties !");
+ GST_DEBUG
+ ("error: fameenc encoder already initialized, cannot set properties !");
return;
}
values = G_ENUM_CLASS (g_type_class_ref (pspec->value_type))->values;
name = (gchar *) g_param_spec_get_qdata (pspec, fame_object_name);
-
- fame_register (fameenc->fc, name, fame_get_object (fameenc->fc, values[index].value_name));
- }
- else
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+
+ fame_register (fameenc->fc, name, fame_get_object (fameenc->fc,
+ values[index].value_name));
+ } else
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
-gst_fameenc_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
+gst_fameenc_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
GstFameEnc *fameenc;
values = G_ENUM_CLASS (g_type_class_ref (pspec->value_type))->values;
name = (gchar *) g_param_spec_get_qdata (pspec, fame_object_name);
-
+
f_object = fame_get_object (fameenc->fc, name);
while (values[index].value_name) {
if (!strcmp (values[index].value_nick, f_object->name)) {
- g_value_set_enum (value, index);
+ g_value_set_enum (value, index);
return;
}
index++;
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
return gst_element_register (plugin, "fameenc",
- GST_RANK_NONE, GST_TYPE_FAMEENC);
+ GST_RANK_NONE, GST_TYPE_FAMEENC);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "fameenc",
- "Fast Assembly MPEG Encoder",
- plugin_init,
- LIBFAME_VERSION,
- "LGPL",
- "libfame",
- "http://fame.sourceforge.net/"
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "fameenc",
+ "Fast Assembly MPEG Encoder",
+ plugin_init,
+ LIBFAME_VERSION, "LGPL", "libfame", "http://fame.sourceforge.net/")
#include <fame.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_FAMEENC \
#define GST_IS_FAMEENC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FAMEENC))
-typedef struct _GstFameEnc GstFameEnc;
-typedef struct _GstFameEncClass GstFameEncClass;
+ typedef struct _GstFameEnc GstFameEnc;
+ typedef struct _GstFameEncClass GstFameEncClass;
-struct _GstFameEnc {
- GstElement element;
+ struct _GstFameEnc
+ {
+ GstElement element;
- /* pads */
- GstPad *sinkpad, *srcpad;
+ /* pads */
+ GstPad *sinkpad, *srcpad;
- /* the timestamp of the next frame */
- guint64 next_time;
- /* the interval between frames */
- guint64 time_interval;
+ /* the timestamp of the next frame */
+ guint64 next_time;
+ /* the interval between frames */
+ guint64 time_interval;
- /* video state */
- gint format;
- /* the size of the output buffer */
- gint outsize;
+ /* video state */
+ gint format;
+ /* the size of the output buffer */
+ gint outsize;
- /* encoding pattern string */
- gchar *pattern;
+ /* encoding pattern string */
+ gchar *pattern;
- /* fameenc stuff */
- gboolean verbose;
- fame_context_t *fc;
- fame_parameters_t fp;
- fame_yuv_t fy;
- gulong buffer_size;
- unsigned char *buffer;
- gboolean initialized;
-};
+ /* fameenc stuff */
+ gboolean verbose;
+ fame_context_t *fc;
+ fame_parameters_t fp;
+ fame_yuv_t fy;
+ gulong buffer_size;
+ unsigned char *buffer;
+ gboolean initialized;
+ };
-struct _GstFameEncClass {
- GstElementClass parent_class;
-};
+ struct _GstFameEncClass
+ {
+ GstElementClass parent_class;
+ };
-GType gst_fameenc_get_type (void);
+ GType gst_fameenc_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_FAMEENC_H__ */
+#endif /* __GST_FAMEENC_H__ */
#include "gsttrm.h"
/* musicbrainz signals and args */
-enum {
+enum
+{
SIGNAL_SIGNATURE_AVAILABLE,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_SIGNATURE,
ARG_ASCII_SIGNATURE
};
-GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-raw-int, "
- "endianness = (int) BYTE_ORDER, "
- "signed = (bool) TRUE, "
- "width = (int) { 8, 16 }, "
- "depth = (int) { 8, 16 }, "
- "rate = (int) [ 8000, 96000 ], "
- "channels = (int) [ 1, 2 ]"
- )
-);
-
-
-GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-raw-int, "
- "endianness = (int) BYTE_ORDER, "
- "signed = (bool) TRUE, "
- "width = (int) { 8, 16 }, "
- "depth = (int) { 8, 16 }, "
- "rate = (int) [ 8000, 96000 ], "
- "channels = (int) [ 1, 2 ]"
- )
-);
-
-
-static void gst_musicbrainz_class_init (GstMusicBrainzClass *klass);
-static void gst_musicbrainz_base_init (GstMusicBrainzClass *klass);
-static void gst_musicbrainz_init (GstMusicBrainz *musicbrainz);
-
-static void gst_musicbrainz_chain (GstPad *pad, GstData *data);
-
-static void gst_musicbrainz_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_musicbrainz_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
-
-static GstElementStateReturn
- gst_musicbrainz_change_state (GstElement *element);
+GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "endianness = (int) BYTE_ORDER, "
+ "signed = (bool) TRUE, "
+ "width = (int) { 8, 16 }, "
+ "depth = (int) { 8, 16 }, "
+ "rate = (int) [ 8000, 96000 ], " "channels = (int) [ 1, 2 ]")
+ );
+
+
+GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "endianness = (int) BYTE_ORDER, "
+ "signed = (bool) TRUE, "
+ "width = (int) { 8, 16 }, "
+ "depth = (int) { 8, 16 }, "
+ "rate = (int) [ 8000, 96000 ], " "channels = (int) [ 1, 2 ]")
+ );
+
+
+static void gst_musicbrainz_class_init (GstMusicBrainzClass * klass);
+static void gst_musicbrainz_base_init (GstMusicBrainzClass * klass);
+static void gst_musicbrainz_init (GstMusicBrainz * musicbrainz);
+
+static void gst_musicbrainz_chain (GstPad * pad, GstData * data);
+
+static void gst_musicbrainz_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_musicbrainz_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+
+static GstElementStateReturn
+gst_musicbrainz_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
if (!musicbrainz_type) {
static const GTypeInfo musicbrainz_info = {
- sizeof(GstMusicBrainzClass),
+ sizeof (GstMusicBrainzClass),
(GBaseInitFunc) gst_musicbrainz_base_init,
NULL,
(GClassInitFunc) gst_musicbrainz_class_init,
NULL,
NULL,
- sizeof(GstMusicBrainz),
+ sizeof (GstMusicBrainz),
0,
- (GInstanceInitFunc)gst_musicbrainz_init,
+ (GInstanceInitFunc) gst_musicbrainz_init,
};
- musicbrainz_type = g_type_register_static (GST_TYPE_ELEMENT,
- "GstMusicBrainz",
- &musicbrainz_info, 0);
+ musicbrainz_type = g_type_register_static (GST_TYPE_ELEMENT,
+ "GstMusicBrainz", &musicbrainz_info, 0);
}
return musicbrainz_type;
}
static void
-gst_musicbrainz_base_init (GstMusicBrainzClass *klass)
+gst_musicbrainz_base_init (GstMusicBrainzClass * klass)
{
GstElementDetails gst_musicbrainz_details = {
"Compute TRM Id",
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&src_template));
+ gst_static_pad_template_get (&src_template));
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&sink_template));
+ gst_static_pad_template_get (&sink_template));
gst_element_class_set_details (element_class, &gst_musicbrainz_details);
}
static void
-gst_musicbrainz_class_init (GstMusicBrainzClass *klass)
+gst_musicbrainz_class_init (GstMusicBrainzClass * 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);
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_SIGNATURE,
- g_param_spec_string ("signature","signature","signature",
- NULL, G_PARAM_READABLE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_ASCII_SIGNATURE,
- g_param_spec_string ("ascii_signature","ascii_signature","ascii_signature",
- NULL, G_PARAM_READABLE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIGNATURE,
+ g_param_spec_string ("signature", "signature", "signature",
+ NULL, G_PARAM_READABLE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ASCII_SIGNATURE,
+ g_param_spec_string ("ascii_signature", "ascii_signature",
+ "ascii_signature", NULL, G_PARAM_READABLE));
gobject_class->set_property = gst_musicbrainz_set_property;
gobject_class->get_property = gst_musicbrainz_get_property;
gst_musicbrainz_signals[SIGNAL_SIGNATURE_AVAILABLE] =
- g_signal_new ("signature-available", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstMusicBrainzClass, signature_available), NULL, NULL,
- g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("signature-available", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstMusicBrainzClass,
+ signature_available), NULL, NULL, g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
gstelement_class->change_state = gst_musicbrainz_change_state;
}
static GstPadLinkReturn
-gst_musicbrainz_sinkconnect (GstPad *pad, const GstCaps *caps)
+gst_musicbrainz_sinkconnect (GstPad * pad, const GstCaps * caps)
{
GstMusicBrainz *musicbrainz;
GstStructure *structure;
const gchar *mimetype;
gint width;
- musicbrainz = GST_MUSICBRAINZ (gst_pad_get_parent (pad));
-
+ musicbrainz = GST_MUSICBRAINZ (gst_pad_get_parent (pad));
+
musicbrainz->caps = caps;
structure = gst_caps_get_structure (caps, 0);
if (!gst_structure_get_int (structure, "depth", &musicbrainz->depth) ||
!gst_structure_get_int (structure, "width", &width))
- return GST_PAD_LINK_REFUSED;
+ return GST_PAD_LINK_REFUSED;
if (musicbrainz->depth != width)
- return GST_PAD_LINK_REFUSED;
+ return GST_PAD_LINK_REFUSED;
if (!gst_structure_get_int (structure, "channels", &musicbrainz->channels))
- return GST_PAD_LINK_REFUSED;
+ return GST_PAD_LINK_REFUSED;
if (!gst_structure_get_int (structure, "rate", &musicbrainz->rate))
- return GST_PAD_LINK_REFUSED;
+ return GST_PAD_LINK_REFUSED;
- trm_SetPCMDataInfo (musicbrainz->trm, musicbrainz->rate, musicbrainz->channels, musicbrainz->depth);
- musicbrainz->linked= TRUE;
+ trm_SetPCMDataInfo (musicbrainz->trm, musicbrainz->rate,
+ musicbrainz->channels, musicbrainz->depth);
+ musicbrainz->linked = TRUE;
- return GST_PAD_LINK_OK;
+ return GST_PAD_LINK_OK;
}
static void
-gst_musicbrainz_init (GstMusicBrainz *musicbrainz)
+gst_musicbrainz_init (GstMusicBrainz * musicbrainz)
{
- musicbrainz->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&sink_template), "sink");
+ musicbrainz->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get (&sink_template),
+ "sink");
gst_element_add_pad (GST_ELEMENT (musicbrainz), musicbrainz->sinkpad);
gst_pad_set_chain_function (musicbrainz->sinkpad, gst_musicbrainz_chain);
gst_pad_set_link_function (musicbrainz->sinkpad, gst_musicbrainz_sinkconnect);
- musicbrainz->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&src_template), "src");
+ musicbrainz->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get (&src_template),
+ "src");
gst_element_add_pad (GST_ELEMENT (musicbrainz), musicbrainz->srcpad);
musicbrainz->trm = NULL;
musicbrainz->signature_available = FALSE;
GST_FLAG_SET (musicbrainz, GST_ELEMENT_EVENT_AWARE);
- /*GST_FLAG_SET(musicbrainz, GST_ELEMENT_THREAD_SUGGESTED);*/
+ /*GST_FLAG_SET(musicbrainz, GST_ELEMENT_THREAD_SUGGESTED); */
}
static void
-gst_trm_handle_event (GstPad *pad, GstData *data)
+gst_trm_handle_event (GstPad * pad, GstData * data)
{
GstEvent *event = GST_EVENT (data);
}
static void
-gst_musicbrainz_chain (GstPad *pad, GstData *data)
+gst_musicbrainz_chain (GstPad * pad, GstData * data)
{
GstMusicBrainz *musicbrainz;
GstBuffer *buf;
musicbrainz = GST_MUSICBRAINZ (gst_pad_get_parent (pad));
- if (GST_IS_EVENT (data))
- {
+ if (GST_IS_EVENT (data)) {
gst_trm_handle_event (pad, data);
return;
}
buf = GST_BUFFER (data);
-
+
if (musicbrainz->linked && !musicbrainz->data_available)
- if (gst_pad_query (gst_pad_get_peer (pad), GST_QUERY_TOTAL, &format, &nanos))
- {
+ if (gst_pad_query (gst_pad_get_peer (pad), GST_QUERY_TOTAL, &format,
+ &nanos)) {
musicbrainz->total_time = nanos / GST_SECOND;
- trm_SetSongLength(musicbrainz->trm, musicbrainz->total_time);
+ trm_SetSongLength (musicbrainz->trm, musicbrainz->total_time);
musicbrainz->data_available = TRUE;
gst_pad_try_set_caps (musicbrainz->srcpad, musicbrainz->caps);
}
- if (!musicbrainz->signature_available && trm_GenerateSignature (musicbrainz->trm, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf)))
- {
+ if (!musicbrainz->signature_available
+ && trm_GenerateSignature (musicbrainz->trm, GST_BUFFER_DATA (buf),
+ GST_BUFFER_SIZE (buf))) {
GST_DEBUG ("Signature");
- trm_FinalizeSignature(musicbrainz->trm, musicbrainz->signature, NULL);
- trm_ConvertSigToASCII (musicbrainz->trm, musicbrainz->signature, musicbrainz->ascii_signature);
-g_print ("Signature : %s\n", musicbrainz->ascii_signature);
+ trm_FinalizeSignature (musicbrainz->trm, musicbrainz->signature, NULL);
+ trm_ConvertSigToASCII (musicbrainz->trm, musicbrainz->signature,
+ musicbrainz->ascii_signature);
+ g_print ("Signature : %s\n", musicbrainz->ascii_signature);
musicbrainz->signature_available = TRUE;
- g_signal_emit (G_OBJECT(musicbrainz),gst_musicbrainz_signals[SIGNAL_SIGNATURE_AVAILABLE], 0);
+ g_signal_emit (G_OBJECT (musicbrainz),
+ gst_musicbrainz_signals[SIGNAL_SIGNATURE_AVAILABLE], 0);
GST_DEBUG ("Signature : %s", musicbrainz->ascii_signature);
static void
-gst_musicbrainz_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_musicbrainz_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstMusicBrainz *musicbrainz;
}
static void
-gst_musicbrainz_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_musicbrainz_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstMusicBrainz *musicbrainz;
/* it's not null if we got it, but it might not be ours */
- musicbrainz = GST_MUSICBRAINZ(object);
+ musicbrainz = GST_MUSICBRAINZ (object);
switch (prop_id) {
- case ARG_SIGNATURE: {
+ case ARG_SIGNATURE:{
g_value_set_string (value, musicbrainz->signature);
break;
}
- case ARG_ASCII_SIGNATURE: {
+ case ARG_ASCII_SIGNATURE:{
g_value_set_string (value, musicbrainz->ascii_signature);
break;
}
- default: {
+ default:{
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
static GstElementStateReturn
-gst_musicbrainz_change_state (GstElement *element)
+gst_musicbrainz_change_state (GstElement * element)
{
GstMusicBrainz *musicbrainz;
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
return gst_element_register (plugin, "trm",
- GST_RANK_NONE,
- GST_TYPE_MUSICBRAINZ);
+ GST_RANK_NONE, GST_TYPE_MUSICBRAINZ);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "trm",
- "A trm signature producer",
- plugin_init,
- VERSION,
- "GPL",
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "trm",
+ "A trm signature producer",
+ plugin_init, VERSION, "GPL", GST_PACKAGE, GST_ORIGIN)
#include <musicbrainz/mb_c.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_MUSICBRAINZ \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MUSICBRAINZ))
-typedef struct _GstMusicBrainz GstMusicBrainz;
-typedef struct _GstMusicBrainzClass GstMusicBrainzClass;
+ typedef struct _GstMusicBrainz GstMusicBrainz;
+ typedef struct _GstMusicBrainzClass GstMusicBrainzClass;
-struct _GstMusicBrainz {
- GstElement element;
+ struct _GstMusicBrainz
+ {
+ GstElement element;
- GstPad *sinkpad;
- GstPad *srcpad;
- const GstCaps *caps;
+ GstPad *sinkpad;
+ GstPad *srcpad;
+ const GstCaps *caps;
- trm_t trm;
- gchar signature[17];
- gchar ascii_signature[37];
+ trm_t trm;
+ gchar signature[17];
+ gchar ascii_signature[37];
- guint depth;
- guint rate;
- guint channels;
- gboolean linked;
- gboolean data_available;
- gboolean signature_available;
- guint64 total_time;
-};
+ guint depth;
+ guint rate;
+ guint channels;
+ gboolean linked;
+ gboolean data_available;
+ gboolean signature_available;
+ guint64 total_time;
+ };
-struct _GstMusicBrainzClass {
- GstElementClass parent_class;
+ struct _GstMusicBrainzClass
+ {
+ GstElementClass parent_class;
- /* signals */
- void (*signature_available) (GstElement *element);
-};
+ /* signals */
+ void (*signature_available) (GstElement * element);
+ };
-GType gst_musicbrainz_get_type(void);
+ GType gst_musicbrainz_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_MUSICBRAINZE_H__ */
+#endif /* __GST_MUSICBRAINZE_H__ */
#define NAS_SOUND_PORT_DURATION (2)
-GST_DEBUG_CATEGORY(NAS);
+GST_DEBUG_CATEGORY (NAS);
/* Signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_MUTE,
ARG_HOST
};
-static GstStaticPadTemplate sink_factory =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS(
- "audio/x-raw-int, "
- "endianess = (int) BYTE_ORDER, "
- "signed = (boolean) TRUE, "
- "width = (int) 16, "
- "depth = (int) 16, "
- "rate = (int) [ 1000, 96000 ], "
- "channels = (int) [ 1, 2 ]; "
- "audio/x-raw-int, "
- "signed = (boolean) FALSE, "
- "width = (int) 8, "
- "depth = (int) 8, "
- "rate = (int) [ 1000, 96000 ], "
- "channels = (int) [ 1, 2 ]"
- )
-);
-
-static void gst_nassink_base_init (gpointer g_class);
-static void gst_nassink_class_init (GstNassinkClass *klass);
-static void gst_nassink_init (GstNassink *nassink);
-
-static gboolean gst_nassink_open_audio (GstNassink *sink);
-static void gst_nassink_close_audio (GstNassink *sink);
-static GstElementStateReturn gst_nassink_change_state (GstElement *element);
-static GstCaps* gst_nassink_getcaps (GstPad *pad);
-static gboolean gst_nassink_sync_parms (GstNassink *nassink);
-static GstPadLinkReturn gst_nassink_sinkconnect (GstPad *pad, const GstCaps *caps);
-
-static void gst_nassink_chain (GstPad *pad, GstData *_data);
-
-static void gst_nassink_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_nassink_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
-
-static void NAS_flush (GstNassink *sink);
-static void NAS_sendData (GstNassink *sink, AuUint32 numBytes);
-static AuBool NAS_EventHandler (AuServer *aud, AuEvent *ev, AuEventHandlerRec *handler);
-static AuDeviceID NAS_getDevice (AuServer* aud, int numTracks);
-static int NAS_allocBuffer (GstNassink *sink);
-static int NAS_createFlow (GstNassink *sink, unsigned char format, unsigned short rate, int numTracks);
+static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "endianess = (int) BYTE_ORDER, "
+ "signed = (boolean) TRUE, "
+ "width = (int) 16, "
+ "depth = (int) 16, "
+ "rate = (int) [ 1000, 96000 ], "
+ "channels = (int) [ 1, 2 ]; "
+ "audio/x-raw-int, "
+ "signed = (boolean) FALSE, "
+ "width = (int) 8, "
+ "depth = (int) 8, "
+ "rate = (int) [ 1000, 96000 ], " "channels = (int) [ 1, 2 ]")
+ );
+
+static void gst_nassink_base_init (gpointer g_class);
+static void gst_nassink_class_init (GstNassinkClass * klass);
+static void gst_nassink_init (GstNassink * nassink);
+
+static gboolean gst_nassink_open_audio (GstNassink * sink);
+static void gst_nassink_close_audio (GstNassink * sink);
+static GstElementStateReturn gst_nassink_change_state (GstElement * element);
+static GstCaps *gst_nassink_getcaps (GstPad * pad);
+static gboolean gst_nassink_sync_parms (GstNassink * nassink);
+static GstPadLinkReturn gst_nassink_sinkconnect (GstPad * pad,
+ const GstCaps * caps);
+
+static void gst_nassink_chain (GstPad * pad, GstData * _data);
+
+static void gst_nassink_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_nassink_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+
+static void NAS_flush (GstNassink * sink);
+static void NAS_sendData (GstNassink * sink, AuUint32 numBytes);
+static AuBool NAS_EventHandler (AuServer * aud, AuEvent * ev,
+ AuEventHandlerRec * handler);
+static AuDeviceID NAS_getDevice (AuServer * aud, int numTracks);
+static int NAS_allocBuffer (GstNassink * sink);
+static int NAS_createFlow (GstNassink * sink, unsigned char format,
+ unsigned short rate, int numTracks);
static GstElementClass *parent_class = NULL;
if (!nassink_type) {
static const GTypeInfo nassink_info = {
- sizeof(GstNassinkClass),
+ sizeof (GstNassinkClass),
gst_nassink_base_init,
NULL,
- (GClassInitFunc)gst_nassink_class_init,
+ (GClassInitFunc) gst_nassink_class_init,
NULL,
NULL,
- sizeof(GstNassink),
+ sizeof (GstNassink),
0,
- (GInstanceInitFunc)gst_nassink_init,
+ (GInstanceInitFunc) gst_nassink_init,
};
- nassink_type = g_type_register_static(GST_TYPE_ELEMENT, "GstNassink", &nassink_info, 0);
+ nassink_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstNassink", &nassink_info,
+ 0);
}
return nassink_type;
"Sink/Audio",
"Plays audio to a Network Audio Server",
"Laurent Vivier <Laurent.Vivier@bull.net>, "
- "Arwed v. Merkatz <v.merkatz@gmx.net>"
+ "Arwed v. Merkatz <v.merkatz@gmx.net>"
};
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&sink_factory));
gst_element_class_set_details (element_class, &nassink_details);
- GST_DEBUG_CATEGORY_INIT(NAS, "NAS", 0, NULL);
+ GST_DEBUG_CATEGORY_INIT (NAS, "NAS", 0, NULL);
}
static void
-gst_nassink_class_init (GstNassinkClass *klass)
+gst_nassink_class_init (GstNassinkClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- gobject_class = (GObjectClass*)klass;
- gstelement_class = (GstElementClass*)klass;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
if (parent_class == NULL)
- parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
+ parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
gobject_class->set_property = gst_nassink_set_property;
gobject_class->get_property = gst_nassink_get_property;
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_MUTE,
- g_param_spec_boolean("mute","mute","mute",
- TRUE,G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_HOST,
- g_param_spec_string("host","host","host",
- NULL, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MUTE, g_param_spec_boolean ("mute", "mute", "mute", TRUE, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_HOST, g_param_spec_string ("host", "host", "host", NULL, G_PARAM_READWRITE)); /* CHECKME */
gstelement_class->change_state = gst_nassink_change_state;
}
static void
-gst_nassink_init(GstNassink *nassink)
+gst_nassink_init (GstNassink * nassink)
{
- GST_CAT_DEBUG(NAS,"nassink: init");
- nassink->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&sink_factory), "sink");
- gst_element_add_pad(GST_ELEMENT(nassink), nassink->sinkpad);
- gst_pad_set_chain_function(nassink->sinkpad, GST_DEBUG_FUNCPTR(gst_nassink_chain));
- gst_pad_set_link_function(nassink->sinkpad, gst_nassink_sinkconnect);
- gst_pad_set_getcaps_function(nassink->sinkpad, gst_nassink_getcaps);
+ GST_CAT_DEBUG (NAS, "nassink: init");
+ nassink->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get (&sink_factory),
+ "sink");
+ gst_element_add_pad (GST_ELEMENT (nassink), nassink->sinkpad);
+ gst_pad_set_chain_function (nassink->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_nassink_chain));
+ gst_pad_set_link_function (nassink->sinkpad, gst_nassink_sinkconnect);
+ gst_pad_set_getcaps_function (nassink->sinkpad, gst_nassink_getcaps);
nassink->mute = FALSE;
nassink->depth = 16;
nassink->tracks = 2;
nassink->rate = 44100;
- nassink->host = g_strdup (getenv("AUDIOSERVER"));
+ nassink->host = g_strdup (getenv ("AUDIOSERVER"));
if (nassink->host == NULL)
- nassink->host = g_strdup (getenv("DISPLAY"));
+ nassink->host = g_strdup (getenv ("DISPLAY"));
nassink->audio = NULL;
nassink->flow = AuNone;
nassink->buf = NULL;
}
-static GstCaps*
-gst_nassink_getcaps (GstPad *pad)
+static GstCaps *
+gst_nassink_getcaps (GstPad * pad)
{
- GstNassink *nassink = GST_NASSINK(gst_pad_get_parent(pad));
- GstCaps *templatecaps = gst_caps_copy(gst_pad_get_pad_template_caps(pad));
+ GstNassink *nassink = GST_NASSINK (gst_pad_get_parent (pad));
+ GstCaps *templatecaps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
GstCaps *caps;
int i;
AuServer *server;
- server = AuOpenServer(nassink->host, 0, NULL, 0, NULL, NULL);
+ server = AuOpenServer (nassink->host, 0, NULL, 0, NULL, NULL);
if (!server)
return templatecaps;
-
+
for (i = 0; i < gst_caps_get_size (templatecaps); i++) {
GstStructure *structure = gst_caps_get_structure (templatecaps, i);
- gst_structure_set (structure, "rate", GST_TYPE_INT_RANGE, AuServerMinSampleRate(server), AuServerMaxSampleRate(server), NULL);
+ gst_structure_set (structure, "rate", GST_TYPE_INT_RANGE,
+ AuServerMinSampleRate (server), AuServerMaxSampleRate (server), NULL);
}
- caps = gst_caps_intersect(templatecaps, gst_pad_get_pad_template_caps(pad));
- gst_caps_free(templatecaps);
+ caps = gst_caps_intersect (templatecaps, gst_pad_get_pad_template_caps (pad));
+ gst_caps_free (templatecaps);
return caps;
-
+
}
static gboolean
-gst_nassink_sync_parms (GstNassink *nassink)
+gst_nassink_sync_parms (GstNassink * nassink)
{
gint ret;
unsigned char format;
+
g_return_val_if_fail (nassink != NULL, FALSE);
g_return_val_if_fail (GST_IS_NASSINK (nassink), FALSE);
- if (nassink->audio == NULL) return TRUE;
+ if (nassink->audio == NULL)
+ return TRUE;
- GST_CAT_DEBUG(NAS,"depth=%i rate=%i", nassink->depth, nassink->rate);
- if (nassink->flow != AuNone)
- {
- GST_CAT_DEBUG(NAS,"flushing buffer");
+ GST_CAT_DEBUG (NAS, "depth=%i rate=%i", nassink->depth, nassink->rate);
+ if (nassink->flow != AuNone) {
+ GST_CAT_DEBUG (NAS, "flushing buffer");
while (nassink->pos && nassink->buf)
- NAS_flush(nassink);
- AuStopFlow( nassink->audio, nassink->flow, NULL);
- AuReleaseScratchFlow(nassink->audio, nassink->flow, NULL);
+ NAS_flush (nassink);
+ AuStopFlow (nassink->audio, nassink->flow, NULL);
+ AuReleaseScratchFlow (nassink->audio, nassink->flow, NULL);
nassink->flow = AuNone;
}
else
format = AuFormatLinearUnsigned8;
- ret = NAS_createFlow(nassink, format, nassink->rate, nassink->tracks);
+ ret = NAS_createFlow (nassink, format, nassink->rate, nassink->tracks);
return ret >= 0;
}
static GstPadLinkReturn
-gst_nassink_sinkconnect (GstPad *pad, const GstCaps *caps)
+gst_nassink_sinkconnect (GstPad * pad, const GstCaps * caps)
{
GstNassink *nassink;
GstStructure *structure;
gst_structure_get_int (structure, "channels", &nassink->tracks);
gst_structure_get_int (structure, "rate", &nassink->rate);
- if (!gst_nassink_sync_parms(nassink))
+ if (!gst_nassink_sync_parms (nassink))
return GST_PAD_LINK_REFUSED;
return GST_PAD_LINK_OK;
}
static void
-gst_nassink_chain (GstPad *pad, GstData *_data)
+gst_nassink_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
int pos = 0;
int available;
GstNassink *nassink;
- g_return_if_fail(pad != NULL);
- g_return_if_fail(GST_IS_PAD(pad));
- g_return_if_fail(buf != NULL);
+ g_return_if_fail (pad != NULL);
+ g_return_if_fail (GST_IS_PAD (pad));
+ g_return_if_fail (buf != NULL);
nassink = GST_NASSINK (gst_pad_get_parent (pad));
- g_return_if_fail(nassink->buf != NULL);
+ g_return_if_fail (nassink->buf != NULL);
if (GST_BUFFER_DATA (buf) != NULL) {
if (!nassink->mute && nassink->audio != NULL) {
remaining = GST_BUFFER_SIZE (buf);
- while ((nassink->flow != AuNone) && ( remaining > 0)) {
+ while ((nassink->flow != AuNone) && (remaining > 0)) {
+
+ /* number of bytes we can copy to buffer */
- /* number of bytes we can copy to buffer */
-
- available = remaining > nassink->size - nassink->pos ?
- nassink->size - nassink->pos : remaining;
+ available = remaining > nassink->size - nassink->pos ?
+ nassink->size - nassink->pos : remaining;
/* fill the buffer */
- memcpy (nassink->buf + nassink->pos, GST_BUFFER_DATA (buf) + pos, available);
+ memcpy (nassink->buf + nassink->pos, GST_BUFFER_DATA (buf) + pos,
+ available);
nassink->pos += available;
pos += available;
if (remaining > 0) {
while ((nassink->flow != AuNone) && (nassink->pos == nassink->size)) {
- NAS_flush(nassink);
+ NAS_flush (nassink);
}
}
}
/* give some time to event handler */
- AuSync(nassink->audio, AuFalse);
+ AuSync (nassink->audio, AuFalse);
}
}
}
static void
-gst_nassink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_nassink_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstNassink *nassink;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_NASSINK(object));
- nassink = GST_NASSINK(object);
+ g_return_if_fail (GST_IS_NASSINK (object));
+ nassink = GST_NASSINK (object);
switch (prop_id) {
- case ARG_MUTE:
- nassink->mute = g_value_get_boolean (value);
- break;
- case ARG_HOST:
- if (nassink->host != NULL) g_free(nassink->host);
- if (g_value_get_string (value) == NULL)
- nassink->host = NULL;
- else
- nassink->host = g_strdup (g_value_get_string (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ case ARG_MUTE:
+ nassink->mute = g_value_get_boolean (value);
+ break;
+ case ARG_HOST:
+ if (nassink->host != NULL)
+ g_free (nassink->host);
+ if (g_value_get_string (value) == NULL)
+ nassink->host = NULL;
+ else
+ nassink->host = g_strdup (g_value_get_string (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
static void
-gst_nassink_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_nassink_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstNassink *nassink;
- g_return_if_fail(GST_IS_NASSINK(object));
+ g_return_if_fail (GST_IS_NASSINK (object));
- nassink = GST_NASSINK(object);
+ nassink = GST_NASSINK (object);
switch (prop_id) {
- case ARG_MUTE:
- g_value_set_boolean (value, nassink->mute);
- break;
- case ARG_HOST:
- g_value_set_string (value, nassink->host);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ case ARG_MUTE:
+ g_value_set_boolean (value, nassink->mute);
+ break;
+ case ARG_HOST:
+ g_value_set_string (value, nassink->host);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
if (!gst_element_register (plugin, "nassink", GST_RANK_NONE,
- GST_TYPE_NASSINK)){
+ GST_TYPE_NASSINK)) {
return FALSE;
}
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "nassink",
- "uses NAS for audio output",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN
-);
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "nassink",
+ "uses NAS for audio output",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN);
static gboolean
-gst_nassink_open_audio (GstNassink *sink)
+gst_nassink_open_audio (GstNassink * sink)
{
/* Open Server */
- sink->audio = AuOpenServer(sink->host, 0, NULL, 0, NULL, NULL);
+ sink->audio = AuOpenServer (sink->host, 0, NULL, 0, NULL, NULL);
if (sink->audio == NULL)
return FALSE;
- sink->device = NAS_getDevice(sink->audio, sink->tracks);
+ sink->device = NAS_getDevice (sink->audio, sink->tracks);
if (sink->device == AuNone) {
- GST_CAT_DEBUG(NAS,"no device with %i tracks found", sink->tracks);
+ GST_CAT_DEBUG (NAS, "no device with %i tracks found", sink->tracks);
return FALSE;
}
GST_FLAG_SET (sink, GST_NASSINK_OPEN);
- GST_CAT_DEBUG(NAS,"opened audio device");
+ GST_CAT_DEBUG (NAS, "opened audio device");
return TRUE;
}
static void
-gst_nassink_close_audio (GstNassink *sink)
+gst_nassink_close_audio (GstNassink * sink)
{
- if (sink->audio == NULL) return;
+ if (sink->audio == NULL)
+ return;
if (sink->flow != AuNone) {
while (sink->pos && sink->buf) {
- NAS_flush(sink);
+ NAS_flush (sink);
}
- AuStopFlow( sink->audio, sink->flow, NULL);
- AuReleaseScratchFlow(sink->audio, sink->flow, NULL);
+ AuStopFlow (sink->audio, sink->flow, NULL);
+ AuReleaseScratchFlow (sink->audio, sink->flow, NULL);
sink->flow = AuNone;
}
- if (sink->buf != NULL)
- {
- free(sink->buf);
+ if (sink->buf != NULL) {
+ free (sink->buf);
sink->buf = NULL;
}
- AuCloseServer(sink->audio);
+ AuCloseServer (sink->audio);
sink->audio = NULL;
GST_FLAG_UNSET (sink, GST_NASSINK_OPEN);
- GST_CAT_DEBUG (NAS,"closed audio device");
+ GST_CAT_DEBUG (NAS, "closed audio device");
}
static GstElementStateReturn
-gst_nassink_change_state (GstElement *element)
+gst_nassink_change_state (GstElement * element)
{
GstNassink *nassink;
+
g_return_val_if_fail (GST_IS_NASSINK (element), FALSE);
nassink = GST_NASSINK (element);
switch (GST_STATE_PENDING (element)) {
- case GST_STATE_NULL:
- if (GST_FLAG_IS_SET (element, GST_NASSINK_OPEN))
- gst_nassink_close_audio (nassink);
- break;
+ case GST_STATE_NULL:
+ if (GST_FLAG_IS_SET (element, GST_NASSINK_OPEN))
+ gst_nassink_close_audio (nassink);
+ break;
- case GST_STATE_READY:
- if (!GST_FLAG_IS_SET (element, GST_NASSINK_OPEN))
- gst_nassink_open_audio (nassink);
- break;
+ case GST_STATE_READY:
+ if (!GST_FLAG_IS_SET (element, GST_NASSINK_OPEN))
+ gst_nassink_open_audio (nassink);
+ break;
- case GST_STATE_PAUSED:
- while (nassink->pos && nassink->buf)
- NAS_flush(nassink);
- break;
+ case GST_STATE_PAUSED:
+ while (nassink->pos && nassink->buf)
+ NAS_flush (nassink);
+ break;
- case GST_STATE_PLAYING:
- break;
+ case GST_STATE_PLAYING:
+ break;
}
if (GST_ELEMENT_CLASS (parent_class)->change_state)
}
static void
-NAS_flush(GstNassink *sink)
+NAS_flush (GstNassink * sink)
{
AuEvent ev;
- AuNextEvent(sink->audio, AuTrue, &ev);
- AuDispatchEvent(sink->audio, &ev);
+ AuNextEvent (sink->audio, AuTrue, &ev);
+ AuDispatchEvent (sink->audio, &ev);
}
static void
-NAS_sendData(GstNassink *sink, AuUint32 numBytes)
+NAS_sendData (GstNassink * sink, AuUint32 numBytes)
{
if (numBytes < (sink->pos)) {
- AuWriteElement(sink->audio, sink->flow, 0,
- numBytes, sink->buf, AuFalse, NULL);
+ AuWriteElement (sink->audio, sink->flow, 0,
+ numBytes, sink->buf, AuFalse, NULL);
- memmove(sink->buf, sink->buf + numBytes,
- sink->pos - numBytes);
+ memmove (sink->buf, sink->buf + numBytes, sink->pos - numBytes);
sink->pos = sink->pos - numBytes;
- } else
- {
- AuWriteElement(sink->audio, sink->flow, 0,
- sink->pos, sink->buf,
- (numBytes > sink->pos), NULL);
+ } else {
+ AuWriteElement (sink->audio, sink->flow, 0,
+ sink->pos, sink->buf, (numBytes > sink->pos), NULL);
sink->pos = 0;
}
}
static AuBool
-NAS_EventHandler(AuServer *aud, AuEvent *ev, AuEventHandlerRec *handler)
+NAS_EventHandler (AuServer * aud, AuEvent * ev, AuEventHandlerRec * handler)
{
- GstNassink *sink = (GstNassink *)handler->data;
+ GstNassink *sink = (GstNassink *) handler->data;
AuElementNotifyEvent *notify;
switch (ev->type) {
- case AuEventTypeElementNotify:
+ case AuEventTypeElementNotify:
- notify = (AuElementNotifyEvent *) ev;
+ notify = (AuElementNotifyEvent *) ev;
- switch(notify->kind) {
+ switch (notify->kind) {
- case AuElementNotifyKindLowWater:
- NAS_sendData(sink, notify->num_bytes);
- break;
+ case AuElementNotifyKindLowWater:
+ NAS_sendData (sink, notify->num_bytes);
+ break;
- case AuElementNotifyKindState:
+ case AuElementNotifyKindState:
- switch(notify->cur_state) {
+ switch (notify->cur_state) {
- case AuStateStop:
-
- if (sink->flow != AuNone) {
- if (notify->reason == AuReasonEOF)
- AuStopFlow(handler->aud, sink->flow, NULL);
- AuReleaseScratchFlow(handler->aud, sink->flow, NULL);
- sink->flow = AuNone;
- }
- AuUnregisterEventHandler(handler->aud, handler);
- break;
+ case AuStateStop:
- case AuStatePause:
+ if (sink->flow != AuNone) {
+ if (notify->reason == AuReasonEOF)
+ AuStopFlow (handler->aud, sink->flow, NULL);
+ AuReleaseScratchFlow (handler->aud, sink->flow, NULL);
+ sink->flow = AuNone;
+ }
+ AuUnregisterEventHandler (handler->aud, handler);
+ break;
- switch(notify->reason) {
- case AuReasonUnderrun:
- case AuReasonOverrun:
- case AuReasonEOF:
- case AuReasonWatermark:
+ case AuStatePause:
- NAS_sendData(sink, notify->num_bytes);
+ switch (notify->reason) {
+ case AuReasonUnderrun:
+ case AuReasonOverrun:
+ case AuReasonEOF:
+ case AuReasonWatermark:
- break;
+ NAS_sendData (sink, notify->num_bytes);
- case AuReasonHardware:
+ break;
- if (AuSoundRestartHardwarePauses)
- AuStartFlow(handler->aud, sink->flow, NULL);
- else
- AuStopFlow(handler->aud, sink->flow, NULL);
+ case AuReasonHardware:
+ if (AuSoundRestartHardwarePauses)
+ AuStartFlow (handler->aud, sink->flow, NULL);
+ else
+ AuStopFlow (handler->aud, sink->flow, NULL);
+
+ break;
+ }
+ break;
+ }
break;
- }
- break;
}
break;
- }
- break;
}
return AuTrue;
}
static AuDeviceID
-NAS_getDevice(AuServer* aud, int numTracks)
+NAS_getDevice (AuServer * aud, int numTracks)
{
int i;
- for (i = 0; i < AuServerNumDevices(aud); i++) {
- if ( (AuDeviceKind(AuServerDevice(aud, i))
- == AuComponentKindPhysicalOutput) &&
- (AuDeviceNumTracks(AuServerDevice(aud, i)) == numTracks )) {
+ for (i = 0; i < AuServerNumDevices (aud); i++) {
+ if ((AuDeviceKind (AuServerDevice (aud, i))
+ == AuComponentKindPhysicalOutput) &&
+ (AuDeviceNumTracks (AuServerDevice (aud, i)) == numTracks)) {
- return AuDeviceIdentifier(AuServerDevice(aud, i));
+ return AuDeviceIdentifier (AuServerDevice (aud, i));
}
}
}
static int
-NAS_allocBuffer(GstNassink *sink)
+NAS_allocBuffer (GstNassink * sink)
{
if (sink->buf != NULL) {
- free(sink->buf);
+ free (sink->buf);
}
- sink->buf = (char *) malloc(sink->size);
+ sink->buf = (char *) malloc (sink->size);
if (sink->buf == NULL) {
return -1;
}
}
static int
-NAS_createFlow(GstNassink *sink, unsigned char format, unsigned short rate, int numTracks)
+NAS_createFlow (GstNassink * sink, unsigned char format, unsigned short rate,
+ int numTracks)
{
AuElement elements[2];
AuUint32 buf_samples;
- sink->flow = AuGetScratchFlow(sink->audio, NULL);
+ sink->flow = AuGetScratchFlow (sink->audio, NULL);
if (sink->flow == 0) {
- GST_CAT_DEBUG(NAS,"couldn't get flow");
+ GST_CAT_DEBUG (NAS, "couldn't get flow");
return -1;
}
int num_elements;
AuStatus status;
AuElement *oldelems;
- oldelems = AuGetElements(sink->audio, sink->flow, &clocked, &num_elements, &status);
+
+ oldelems =
+ AuGetElements (sink->audio, sink->flow, &clocked, &num_elements,
+ &status);
if (num_elements > 0) {
- GST_CAT_DEBUG(NAS,"GetElements status: %i", status);
+ GST_CAT_DEBUG (NAS, "GetElements status: %i", status);
if (oldelems)
- AuFreeElements(sink->audio, num_elements, oldelems);
- gst_nassink_close_audio(sink);
- gst_nassink_open_audio(sink);
- sink->flow = AuGetScratchFlow(sink->audio, NULL);
+ AuFreeElements (sink->audio, num_elements, oldelems);
+ gst_nassink_close_audio (sink);
+ gst_nassink_open_audio (sink);
+ sink->flow = AuGetScratchFlow (sink->audio, NULL);
if (sink->flow == 0) {
- GST_CAT_DEBUG(NAS,"couldn't get flow");
- return -1;
+ GST_CAT_DEBUG (NAS, "couldn't get flow");
+ return -1;
}
}
}
int num_elements;
AuStatus status;
AuElement *oldelems;
- oldelems = AuGetElements(sink->audio, sink->flow, &clocked, &num_elements, &status);
+
+ oldelems =
+ AuGetElements (sink->audio, sink->flow, &clocked, &num_elements,
+ &status);
if (num_elements > 0) {
- GST_CAT_DEBUG(NAS,"GetElements status: %i", status);
+ GST_CAT_DEBUG (NAS, "GetElements status: %i", status);
if (oldelems)
- AuFreeElements(sink->audio, num_elements, oldelems);
- gst_nassink_close_audio(sink);
- gst_nassink_open_audio(sink);
- sink->flow = AuGetScratchFlow(sink->audio, NULL);
+ AuFreeElements (sink->audio, num_elements, oldelems);
+ gst_nassink_close_audio (sink);
+ gst_nassink_open_audio (sink);
+ sink->flow = AuGetScratchFlow (sink->audio, NULL);
if (sink->flow == 0) {
- GST_CAT_DEBUG(NAS,"couldn't get flow");
- return -1;
+ GST_CAT_DEBUG (NAS, "couldn't get flow");
+ return -1;
}
}
}
buf_samples = rate * NAS_SOUND_PORT_DURATION;
- AuMakeElementImportClient( &elements[0], /* element */
- rate, /* rate */
- format, /* format */
- numTracks, /* number of tracks */
- AuTrue, /* discart */
- buf_samples, /* max samples */
- (AuUint32) (buf_samples / 100
- * AuSoundPortLowWaterMark),
- /* low water mark */
- 0, /* num actions */
- NULL);
-
- AuMakeElementExportDevice( &elements[1], /* element */
- 0, /* input */
- sink->device, /* device */
- rate, /* rate */
- AuUnlimitedSamples, /* num samples */
- 0, /* num actions */
- NULL); /* actions */
-
- AuSetElements( sink->audio, /* server */
- sink->flow, /* flow ID */
- AuTrue, /* clocked */
- 2, /* num elements */
- elements, /* elements */
- NULL);
-
- AuRegisterEventHandler( sink->audio, /* server */
- AuEventHandlerIDMask, /* value mask */
- 0, /* type */
- sink->flow, /* flow ID */
- NAS_EventHandler, /* callback */
- (AuPointer)sink); /* data */
-
- sink->size = buf_samples * numTracks * AuSizeofFormat(format);
-
- if (NAS_allocBuffer(sink) < 0) {
-
- AuReleaseScratchFlow(sink->audio, sink->flow, NULL);
+ AuMakeElementImportClient (&elements[0], /* element */
+ rate, /* rate */
+ format, /* format */
+ numTracks, /* number of tracks */
+ AuTrue, /* discart */
+ buf_samples, /* max samples */
+ (AuUint32) (buf_samples / 100 * AuSoundPortLowWaterMark),
+ /* low water mark */
+ 0, /* num actions */
+ NULL);
+
+ AuMakeElementExportDevice (&elements[1], /* element */
+ 0, /* input */
+ sink->device, /* device */
+ rate, /* rate */
+ AuUnlimitedSamples, /* num samples */
+ 0, /* num actions */
+ NULL); /* actions */
+
+ AuSetElements (sink->audio, /* server */
+ sink->flow, /* flow ID */
+ AuTrue, /* clocked */
+ 2, /* num elements */
+ elements, /* elements */
+ NULL);
+
+ AuRegisterEventHandler (sink->audio, /* server */
+ AuEventHandlerIDMask, /* value mask */
+ 0, /* type */
+ sink->flow, /* flow ID */
+ NAS_EventHandler, /* callback */
+ (AuPointer) sink); /* data */
+
+ sink->size = buf_samples * numTracks * AuSizeofFormat (format);
+
+ if (NAS_allocBuffer (sink) < 0) {
+
+ AuReleaseScratchFlow (sink->audio, sink->flow, NULL);
return -1;
}
- AuStartFlow(sink->audio, sink->flow, NULL);
+ AuStartFlow (sink->audio, sink->flow, NULL);
return 0;
}
#include <gst/gst.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_NASSINK \
#define GST_IS_NASSINK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_NASSINK))
-typedef enum {
- GST_NASSINK_OPEN = GST_ELEMENT_FLAG_LAST,
- GST_NASSINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST+2
-} GstNasSinkFlags;
+ typedef enum
+ {
+ GST_NASSINK_OPEN = GST_ELEMENT_FLAG_LAST,
+ GST_NASSINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2
+ } GstNasSinkFlags;
-typedef struct _GstNassink GstNassink;
-typedef struct _GstNassinkClass GstNassinkClass;
+ typedef struct _GstNassink GstNassink;
+ typedef struct _GstNassinkClass GstNassinkClass;
-struct _GstNassink {
- GstElement element;
+ struct _GstNassink
+ {
+ GstElement element;
- GstPad *sinkpad;
+ GstPad *sinkpad;
- /* instance properties */
+ /* instance properties */
- gboolean mute;
- gint depth;
- gint tracks;
- gint rate;
- gchar* host;
+ gboolean mute;
+ gint depth;
+ gint tracks;
+ gint rate;
+ gchar *host;
- /* Server info */
+ /* Server info */
- AuServer *audio;
- AuFlowID flow;
- AuDeviceID device;
+ AuServer *audio;
+ AuFlowID flow;
+ AuDeviceID device;
- /* buffer */
+ /* buffer */
- AuUint32 size;
- AuUint32 pos;
+ AuUint32 size;
+ AuUint32 pos;
- char *buf;
-};
+ char *buf;
+ };
-struct _GstNassinkClass {
- GstElementClass parent_class;
-};
+ struct _GstNassinkClass
+ {
+ GstElementClass parent_class;
+ };
-GType gst_nassink_get_type(void);
+ GType gst_nassink_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_NASSINK_H__ */
+#endif /* __GST_NASSINK_H__ */
"Ronald Bultje <rbultje@ronald.bitfreak.net>",
};
-static void gst_sdlvideosink_base_init (gpointer g_class);
-static void gst_sdlvideosink_class_init (GstSDLVideoSinkClass *klass);
-static void gst_sdlvideosink_init (GstSDLVideoSink *sdl);
+static void gst_sdlvideosink_base_init (gpointer g_class);
+static void gst_sdlvideosink_class_init (GstSDLVideoSinkClass * klass);
+static void gst_sdlvideosink_init (GstSDLVideoSink * sdl);
-static void gst_sdlvideosink_interface_init (GstImplementsInterfaceClass *klass);
-static gboolean gst_sdlvideosink_supported (GstImplementsInterface *iface,
- GType type);
+static void gst_sdlvideosink_interface_init (GstImplementsInterfaceClass *
+ klass);
+static gboolean gst_sdlvideosink_supported (GstImplementsInterface * iface,
+ GType type);
-static void gst_sdlvideosink_xoverlay_init (GstXOverlayClass *klass);
-static void gst_sdlvideosink_xoverlay_set_xwindow_id
- (GstXOverlay *overlay,
- unsigned long parent);
+static void gst_sdlvideosink_xoverlay_init (GstXOverlayClass * klass);
+static void gst_sdlvideosink_xoverlay_set_xwindow_id
+ (GstXOverlay * overlay, unsigned long parent);
-static gboolean gst_sdlvideosink_lock (GstSDLVideoSink *sdl);
-static void gst_sdlvideosink_unlock (GstSDLVideoSink *sdl);
+static gboolean gst_sdlvideosink_lock (GstSDLVideoSink * sdl);
+static void gst_sdlvideosink_unlock (GstSDLVideoSink * sdl);
-static gboolean gst_sdlvideosink_initsdl (GstSDLVideoSink *sdl);
-static void gst_sdlvideosink_deinitsdl (GstSDLVideoSink *sdl);
+static gboolean gst_sdlvideosink_initsdl (GstSDLVideoSink * sdl);
+static void gst_sdlvideosink_deinitsdl (GstSDLVideoSink * sdl);
-static gboolean gst_sdlvideosink_create (GstSDLVideoSink *sdl);
-static void gst_sdlvideosink_destroy (GstSDLVideoSink *sdl);
+static gboolean gst_sdlvideosink_create (GstSDLVideoSink * sdl);
+static void gst_sdlvideosink_destroy (GstSDLVideoSink * sdl);
static GstPadLinkReturn
- gst_sdlvideosink_sinkconnect (GstPad *pad,
- const GstCaps *caps);
-static GstCaps * gst_sdlvideosink_fixate (GstPad *pad, const GstCaps *caps);
-static void gst_sdlvideosink_chain (GstPad *pad,
- GstData *data);
-
-static void gst_sdlvideosink_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gst_sdlvideosink_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
+gst_sdlvideosink_sinkconnect (GstPad * pad, const GstCaps * caps);
+static GstCaps *gst_sdlvideosink_fixate (GstPad * pad, const GstCaps * caps);
+static void gst_sdlvideosink_chain (GstPad * pad, GstData * data);
+
+static void gst_sdlvideosink_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+static void gst_sdlvideosink_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
static GstElementStateReturn
- gst_sdlvideosink_change_state (GstElement *element);
+gst_sdlvideosink_change_state (GstElement * element);
static GstPadTemplate *sink_template;
NULL,
};
- sdlvideosink_type = g_type_register_static(GST_TYPE_VIDEOSINK,
- "GstSDLVideoSink",
- &sdlvideosink_info, 0);
- g_type_add_interface_static(sdlvideosink_type, GST_TYPE_IMPLEMENTS_INTERFACE,
- &iface_info);
- g_type_add_interface_static(sdlvideosink_type, GST_TYPE_X_OVERLAY,
- &xoverlay_info);
+ sdlvideosink_type = g_type_register_static (GST_TYPE_VIDEOSINK,
+ "GstSDLVideoSink", &sdlvideosink_info, 0);
+ g_type_add_interface_static (sdlvideosink_type,
+ GST_TYPE_IMPLEMENTS_INTERFACE, &iface_info);
+ g_type_add_interface_static (sdlvideosink_type, GST_TYPE_X_OVERLAY,
+ &xoverlay_info);
}
return sdlvideosink_type;
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
GstCaps *capslist;
gint i;
- gulong format[6] = { GST_MAKE_FOURCC('I','4','2','0'),
- GST_MAKE_FOURCC('Y','V','1','2'),
- GST_MAKE_FOURCC('Y','U','Y','2'),
- GST_MAKE_FOURCC('Y','V','Y','U'),
- GST_MAKE_FOURCC('U','Y','V','Y')
- };
+ gulong format[6] = { GST_MAKE_FOURCC ('I', '4', '2', '0'),
+ GST_MAKE_FOURCC ('Y', 'V', '1', '2'),
+ GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'),
+ GST_MAKE_FOURCC ('Y', 'V', 'Y', 'U'),
+ GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y')
+ };
/* make a list of all available caps */
- capslist = gst_caps_new_empty();
+ capslist = gst_caps_new_empty ();
for (i = 0; i < 5; i++) {
- gst_caps_append_structure (capslist,
- gst_structure_new ("video/x-raw-yuv",
- "format", GST_TYPE_FOURCC, format[i],
- "width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
- "height", GST_TYPE_INT_RANGE, 1, G_MAXINT,
- "framerate", GST_TYPE_DOUBLE_RANGE, 0.0, G_MAXDOUBLE,
- NULL));
+ gst_caps_append_structure (capslist,
+ gst_structure_new ("video/x-raw-yuv",
+ "format", GST_TYPE_FOURCC, format[i],
+ "width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
+ "height", GST_TYPE_INT_RANGE, 1, G_MAXINT,
+ "framerate", GST_TYPE_DOUBLE_RANGE, 0.0, G_MAXDOUBLE, NULL));
}
sink_template = gst_pad_template_new ("sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- capslist);
-
+ GST_PAD_SINK, GST_PAD_ALWAYS, capslist);
+
gst_element_class_add_pad_template (element_class, sink_template);
gst_element_class_set_details (element_class, &gst_sdlvideosink_details);
}
static void
-gst_sdlvideosink_dispose (GObject *obj)
+gst_sdlvideosink_dispose (GObject * obj)
{
g_mutex_free (GST_SDLVIDEOSINK (obj)->lock);
}
static void
-gst_sdlvideosink_class_init (GstSDLVideoSinkClass *klass)
+gst_sdlvideosink_class_init (GstSDLVideoSinkClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GstVideoSinkClass *gstvs_class;
- gobject_class = (GObjectClass*) klass;
- gstelement_class = (GstElementClass*) klass;
- gstvs_class = (GstVideoSinkClass*) klass;
-
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
+ gstvs_class = (GstVideoSinkClass *) klass;
+
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
gobject_class->set_property = gst_sdlvideosink_set_property;
gobject_class->dispose = gst_sdlvideosink_dispose;
gstelement_class->change_state = gst_sdlvideosink_change_state;
-
+
/*gstvs_class->set_video_out = gst_sdlvideosink_set_video_out;
- gstvs_class->push_ui_event = gst_sdlvideosink_push_ui_event;
- gstvs_class->set_geometry = gst_sdlvideosink_set_geometry;*/
+ gstvs_class->push_ui_event = gst_sdlvideosink_push_ui_event;
+ gstvs_class->set_geometry = gst_sdlvideosink_set_geometry; */
}
#if 0
/* FIXME */
static GstBuffer *
-gst_sdlvideosink_buffer_new (GstBufferPool *pool,
- gint64 location,
- guint size,
- gpointer user_data)
+gst_sdlvideosink_buffer_new (GstBufferPool * pool,
+ gint64 location, guint size, gpointer user_data)
{
GstSDLVideoSink *sdlvideosink = GST_SDLVIDEOSINK (user_data);
GstBuffer *buffer;
if (!sdlvideosink->overlay)
return NULL;
- if (!gst_sdlvideosink_lock(sdlvideosink)) {
+ if (!gst_sdlvideosink_lock (sdlvideosink)) {
return NULL;
}
if (sdlvideosink->format == SDL_YV12_OVERLAY ||
sdlvideosink->format == SDL_IYUV_OVERLAY) {
GST_BUFFER_SIZE (buffer) =
- sdlvideosink->width * sdlvideosink->height * 3/2;
+ sdlvideosink->width * sdlvideosink->height * 3 / 2;
} else {
- GST_BUFFER_SIZE (buffer) =
- sdlvideosink->width * sdlvideosink->height * 2;
+ GST_BUFFER_SIZE (buffer) = sdlvideosink->width * sdlvideosink->height * 2;
}
GST_BUFFER_MAXSIZE (buffer) = GST_BUFFER_SIZE (buffer);
}
static void
-gst_sdlvideosink_buffer_free (GstBufferPool *pool,
- GstBuffer *buffer,
- gpointer user_data)
+gst_sdlvideosink_buffer_free (GstBufferPool * pool,
+ GstBuffer * buffer, gpointer user_data)
{
GstSDLVideoSink *sdlvideosink = GST_SDLVIDEOSINK (user_data);
g_mutex_unlock (sdlvideosink->lock);
- gst_sdlvideosink_unlock(sdlvideosink);
+ gst_sdlvideosink_unlock (sdlvideosink);
gst_buffer_default_free (buffer);
}
static GstBufferPool *
-gst_sdlvideosink_get_bufferpool (GstPad *pad)
+gst_sdlvideosink_get_bufferpool (GstPad * pad)
{
GstSDLVideoSink *sdlvideosink = GST_SDLVIDEOSINK (gst_pad_get_parent (pad));
#endif
static void
-gst_sdlvideosink_init (GstSDLVideoSink *sdlvideosink)
+gst_sdlvideosink_init (GstSDLVideoSink * sdlvideosink)
{
GST_VIDEOSINK_PAD (sdlvideosink) = gst_pad_new_from_template (sink_template,
- "sink");
+ "sink");
gst_element_add_pad (GST_ELEMENT (sdlvideosink),
- GST_VIDEOSINK_PAD (sdlvideosink));
+ GST_VIDEOSINK_PAD (sdlvideosink));
gst_pad_set_chain_function (GST_VIDEOSINK_PAD (sdlvideosink),
- gst_sdlvideosink_chain);
+ gst_sdlvideosink_chain);
gst_pad_set_link_function (GST_VIDEOSINK_PAD (sdlvideosink),
- gst_sdlvideosink_sinkconnect);
+ gst_sdlvideosink_sinkconnect);
gst_pad_set_fixate_function (GST_VIDEOSINK_PAD (sdlvideosink),
- gst_sdlvideosink_fixate);
+ gst_sdlvideosink_fixate);
sdlvideosink->width = -1;
sdlvideosink->height = -1;
sdlvideosink->lock = g_mutex_new ();
#if 0
- sdlvideosink->bufferpool = gst_buffer_pool_new (
- NULL, /* free */
- NULL, /* copy */
- (GstBufferPoolBufferNewFunction) gst_sdlvideosink_buffer_new,
- NULL, /* buffer copy, the default is fine */
- (GstBufferPoolBufferFreeFunction) gst_sdlvideosink_buffer_free,
- sdlvideosink);
+ sdlvideosink->bufferpool = gst_buffer_pool_new (NULL, /* free */
+ NULL, /* copy */
+ (GstBufferPoolBufferNewFunction) gst_sdlvideosink_buffer_new, NULL, /* buffer copy, the default is fine */
+ (GstBufferPoolBufferFreeFunction) gst_sdlvideosink_buffer_free,
+ sdlvideosink);
#endif
- GST_FLAG_SET(sdlvideosink, GST_ELEMENT_THREAD_SUGGESTED);
- GST_FLAG_SET(sdlvideosink, GST_ELEMENT_EVENT_AWARE);
+ GST_FLAG_SET (sdlvideosink, GST_ELEMENT_THREAD_SUGGESTED);
+ GST_FLAG_SET (sdlvideosink, GST_ELEMENT_EVENT_AWARE);
}
static void
-gst_sdlvideosink_interface_init (GstImplementsInterfaceClass *klass)
+gst_sdlvideosink_interface_init (GstImplementsInterfaceClass * klass)
{
klass->supported = gst_sdlvideosink_supported;
}
static gboolean
-gst_sdlvideosink_supported (GstImplementsInterface *interface,
- GType iface_type)
+gst_sdlvideosink_supported (GstImplementsInterface * interface,
+ GType iface_type)
{
g_assert (iface_type == GST_TYPE_X_OVERLAY);
}
static void
-gst_sdlvideosink_xoverlay_init (GstXOverlayClass *klass)
+gst_sdlvideosink_xoverlay_init (GstXOverlayClass * klass)
{
klass->set_xwindow_id = gst_sdlvideosink_xoverlay_set_xwindow_id;
}
static void
-gst_sdlvideosink_xoverlay_set_xwindow_id (GstXOverlay *overlay,
+gst_sdlvideosink_xoverlay_set_xwindow_id (GstXOverlay * overlay,
unsigned long parent)
{
GstSDLVideoSink *sdlvideosink = GST_SDLVIDEOSINK (overlay);
static guint32
-gst_sdlvideosink_get_sdl_from_fourcc (GstSDLVideoSink *sdlvideosink,
- guint32 code)
+gst_sdlvideosink_get_sdl_from_fourcc (GstSDLVideoSink * sdlvideosink,
+ guint32 code)
{
- switch (code)
- {
- case GST_MAKE_FOURCC('I','4','2','0'):
+ switch (code) {
+ case GST_MAKE_FOURCC ('I', '4', '2', '0'):
return SDL_IYUV_OVERLAY;
- case GST_MAKE_FOURCC('Y','V','1','2'):
+ case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
return SDL_YV12_OVERLAY;
- case GST_MAKE_FOURCC('Y','U','Y','2'):
+ case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
return SDL_YUY2_OVERLAY;
- case GST_MAKE_FOURCC('U','Y','V','Y'):
+ case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
return SDL_UYVY_OVERLAY;
- case GST_MAKE_FOURCC('Y','V','Y','U'):
+ case GST_MAKE_FOURCC ('Y', 'V', 'Y', 'U'):
return SDL_YVYU_OVERLAY;
default:
return 0;
static gboolean
-gst_sdlvideosink_lock (GstSDLVideoSink *sdlvideosink)
+gst_sdlvideosink_lock (GstSDLVideoSink * sdlvideosink)
{
/* assure that we've got a screen */
if (!sdlvideosink->screen || !sdlvideosink->overlay) {
GST_ELEMENT_ERROR (sdlvideosink, LIBRARY, TOO_LAZY, (NULL),
- ("Tried to lock screen without being set-up"));
+ ("Tried to lock screen without being set-up"));
return FALSE;
}
/* Lock SDL/yuv-overlay */
- if (SDL_MUSTLOCK(sdlvideosink->screen))
- {
- if (SDL_LockSurface(sdlvideosink->screen) < 0)
- {
+ if (SDL_MUSTLOCK (sdlvideosink->screen)) {
+ if (SDL_LockSurface (sdlvideosink->screen) < 0) {
GST_ELEMENT_ERROR (sdlvideosink, LIBRARY, TOO_LAZY, (NULL),
- ("SDL: couldn't lock the SDL video window: %s", SDL_GetError()));
+ ("SDL: couldn't lock the SDL video window: %s", SDL_GetError ()));
return FALSE;
}
}
- if (SDL_LockYUVOverlay(sdlvideosink->overlay) < 0)
- {
+ if (SDL_LockYUVOverlay (sdlvideosink->overlay) < 0) {
GST_ELEMENT_ERROR (sdlvideosink, LIBRARY, TOO_LAZY, (NULL),
- ("SDL: couldn\'t lock the SDL YUV overlay: %s", SDL_GetError()));
+ ("SDL: couldn\'t lock the SDL YUV overlay: %s", SDL_GetError ()));
return FALSE;
}
static void
-gst_sdlvideosink_unlock (GstSDLVideoSink *sdlvideosink)
+gst_sdlvideosink_unlock (GstSDLVideoSink * sdlvideosink)
{
/* Unlock SDL_overlay */
- SDL_UnlockYUVOverlay(sdlvideosink->overlay);
- if (SDL_MUSTLOCK(sdlvideosink->screen))
- SDL_UnlockSurface(sdlvideosink->screen);
+ SDL_UnlockYUVOverlay (sdlvideosink->overlay);
+ if (SDL_MUSTLOCK (sdlvideosink->screen))
+ SDL_UnlockSurface (sdlvideosink->screen);
}
static void
-gst_sdlvideosink_deinitsdl (GstSDLVideoSink *sdlvideosink)
+gst_sdlvideosink_deinitsdl (GstSDLVideoSink * sdlvideosink)
{
if (sdlvideosink->init) {
SDL_Quit ();
}
static gboolean
-gst_sdlvideosink_initsdl (GstSDLVideoSink *sdlvideosink)
+gst_sdlvideosink_initsdl (GstSDLVideoSink * sdlvideosink)
{
gst_sdlvideosink_deinitsdl (sdlvideosink);
if (!sdlvideosink->xwindow_id) {
- unsetenv("SDL_WINDOWID");
+ unsetenv ("SDL_WINDOWID");
} else {
char SDL_hack[32];
- sprintf(SDL_hack, "%lu", sdlvideosink->xwindow_id);
- setenv("SDL_WINDOWID", SDL_hack, 1);
+
+ sprintf (SDL_hack, "%lu", sdlvideosink->xwindow_id);
+ setenv ("SDL_WINDOWID", SDL_hack, 1);
}
/* Initialize the SDL library */
- if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0 ) {
+ if (SDL_Init (SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0) {
GST_ELEMENT_ERROR (sdlvideosink, LIBRARY, INIT, (NULL),
- ("Couldn't initialize SDL: %s", SDL_GetError()));
+ ("Couldn't initialize SDL: %s", SDL_GetError ()));
return FALSE;
}
}
static void
-gst_sdlvideosink_destroy (GstSDLVideoSink *sdlvideosink)
+gst_sdlvideosink_destroy (GstSDLVideoSink * sdlvideosink)
{
if (sdlvideosink->overlay) {
- SDL_FreeYUVOverlay(sdlvideosink->overlay);
+ SDL_FreeYUVOverlay (sdlvideosink->overlay);
sdlvideosink->overlay = NULL;
}
}
static gboolean
-gst_sdlvideosink_create (GstSDLVideoSink *sdlvideosink)
+gst_sdlvideosink_create (GstSDLVideoSink * sdlvideosink)
{
if (GST_VIDEOSINK_HEIGHT (sdlvideosink) <= 0)
GST_VIDEOSINK_HEIGHT (sdlvideosink) = sdlvideosink->height;
gst_sdlvideosink_destroy (sdlvideosink);
/* create a SDL window of the size requested by the user */
- sdlvideosink->screen = SDL_SetVideoMode(GST_VIDEOSINK_WIDTH (sdlvideosink),
- GST_VIDEOSINK_HEIGHT (sdlvideosink), 0, SDL_HWSURFACE | SDL_RESIZABLE);
- if (sdlvideosink->screen == NULL)
- {
+ sdlvideosink->screen = SDL_SetVideoMode (GST_VIDEOSINK_WIDTH (sdlvideosink),
+ GST_VIDEOSINK_HEIGHT (sdlvideosink), 0, SDL_HWSURFACE | SDL_RESIZABLE);
+ if (sdlvideosink->screen == NULL) {
GST_ELEMENT_ERROR (sdlvideosink, LIBRARY, TOO_LAZY, (NULL),
- ("SDL: Couldn't set %dx%d: %s", GST_VIDEOSINK_WIDTH (sdlvideosink),
- GST_VIDEOSINK_HEIGHT (sdlvideosink), SDL_GetError()));
+ ("SDL: Couldn't set %dx%d: %s", GST_VIDEOSINK_WIDTH (sdlvideosink),
+ GST_VIDEOSINK_HEIGHT (sdlvideosink), SDL_GetError ()));
return FALSE;
}
/* create a new YUV overlay */
- sdlvideosink->overlay = SDL_CreateYUVOverlay(sdlvideosink->width,
- sdlvideosink->height, sdlvideosink->format, sdlvideosink->screen);
- if ( sdlvideosink->overlay == NULL )
- {
+ sdlvideosink->overlay = SDL_CreateYUVOverlay (sdlvideosink->width,
+ sdlvideosink->height, sdlvideosink->format, sdlvideosink->screen);
+ if (sdlvideosink->overlay == NULL) {
GST_ELEMENT_ERROR (sdlvideosink, LIBRARY, TOO_LAZY, (NULL),
- ("SDL: Couldn't create SDL YUV overlay (%dx%d \'" GST_FOURCC_FORMAT "\'): %s",
- sdlvideosink->width, sdlvideosink->height,
- GST_FOURCC_ARGS(sdlvideosink->format), SDL_GetError()));
+ ("SDL: Couldn't create SDL YUV overlay (%dx%d \'" GST_FOURCC_FORMAT
+ "\'): %s", sdlvideosink->width, sdlvideosink->height,
+ GST_FOURCC_ARGS (sdlvideosink->format), SDL_GetError ()));
return FALSE;
- }
- else
- {
- GST_DEBUG("Using a %dx%d %dbpp SDL screen with a %dx%d \'" GST_FOURCC_FORMAT "\' YUV overlay",
- GST_VIDEOSINK_WIDTH (sdlvideosink), GST_VIDEOSINK_HEIGHT (sdlvideosink),
- sdlvideosink->screen->format->BitsPerPixel,
- sdlvideosink->width, sdlvideosink->height,
- GST_FOURCC_ARGS(sdlvideosink->format));
+ } else {
+ GST_DEBUG ("Using a %dx%d %dbpp SDL screen with a %dx%d \'"
+ GST_FOURCC_FORMAT "\' YUV overlay", GST_VIDEOSINK_WIDTH (sdlvideosink),
+ GST_VIDEOSINK_HEIGHT (sdlvideosink),
+ sdlvideosink->screen->format->BitsPerPixel, sdlvideosink->width,
+ sdlvideosink->height, GST_FOURCC_ARGS (sdlvideosink->format));
}
sdlvideosink->rect.x = 0;
sdlvideosink->rect.w = GST_VIDEOSINK_WIDTH (sdlvideosink);
sdlvideosink->rect.h = GST_VIDEOSINK_HEIGHT (sdlvideosink);
- SDL_DisplayYUVOverlay(sdlvideosink->overlay, &(sdlvideosink->rect));
+ SDL_DisplayYUVOverlay (sdlvideosink->overlay, &(sdlvideosink->rect));
GST_DEBUG ("sdlvideosink: setting %08x (" GST_FOURCC_FORMAT ")",
- sdlvideosink->format, GST_FOURCC_ARGS(sdlvideosink->format));
+ sdlvideosink->format, GST_FOURCC_ARGS (sdlvideosink->format));
gst_x_overlay_got_desired_size (GST_X_OVERLAY (sdlvideosink),
- GST_VIDEOSINK_WIDTH (sdlvideosink),
- GST_VIDEOSINK_HEIGHT (sdlvideosink));
+ GST_VIDEOSINK_WIDTH (sdlvideosink), GST_VIDEOSINK_HEIGHT (sdlvideosink));
return TRUE;
}
static GstCaps *
-gst_sdlvideosink_fixate (GstPad *pad, const GstCaps *caps)
+gst_sdlvideosink_fixate (GstPad * pad, const GstCaps * caps)
{
GstStructure *structure;
GstCaps *newcaps;
- if (gst_caps_get_size (caps) > 1) return NULL;
+ if (gst_caps_get_size (caps) > 1)
+ return NULL;
newcaps = gst_caps_copy (caps);
structure = gst_caps_get_structure (newcaps, 0);
return newcaps;
}
if (gst_caps_structure_fixate_field_nearest_double (structure, "framerate",
- 30.0)) {
+ 30.0)) {
return newcaps;
}
}
static GstPadLinkReturn
-gst_sdlvideosink_sinkconnect (GstPad *pad,
- const GstCaps *vscapslist)
+gst_sdlvideosink_sinkconnect (GstPad * pad, const GstCaps * vscapslist)
{
GstSDLVideoSink *sdlvideosink;
guint32 format;
structure = gst_caps_get_structure (vscapslist, 0);
gst_structure_get_fourcc (structure, "format", &format);
sdlvideosink->format =
- gst_sdlvideosink_get_sdl_from_fourcc (sdlvideosink, format);
+ gst_sdlvideosink_get_sdl_from_fourcc (sdlvideosink, format);
gst_structure_get_int (structure, "width", &sdlvideosink->width);
gst_structure_get_int (structure, "height", &sdlvideosink->height);
- if (!sdlvideosink->format || !gst_sdlvideosink_create(sdlvideosink))
+ if (!sdlvideosink->format || !gst_sdlvideosink_create (sdlvideosink))
return GST_PAD_LINK_REFUSED;
return GST_PAD_LINK_OK;
static void
-gst_sdlvideosink_chain (GstPad *pad, GstData *_data)
+gst_sdlvideosink_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstSDLVideoSink *sdlvideosink;
case GST_EVENT_DISCONTINUOUS:
offset = GST_EVENT_DISCONT_OFFSET (event, 0).value;
/*gst_clock_handle_discont (sdlvideosink->clock,
- (guint64) GST_EVENT_DISCONT_OFFSET (event, 0).value);*/
+ (guint64) GST_EVENT_DISCONT_OFFSET (event, 0).value); */
break;
default:
gst_pad_event_default (pad, event);
}
if (GST_BUFFER_DATA (buf) != sdlvideosink->overlay->pixels[0]) {
- if (!gst_sdlvideosink_lock(sdlvideosink)) {
+ if (!gst_sdlvideosink_lock (sdlvideosink)) {
return;
}
/* buf->yuv - FIXME: bufferpool! */
if (sdlvideosink->format == SDL_IYUV_OVERLAY ||
- sdlvideosink->format == SDL_YV12_OVERLAY)
- {
+ sdlvideosink->format == SDL_YV12_OVERLAY) {
memcpy (sdlvideosink->overlay->pixels[0], GST_BUFFER_DATA (buf),
- sdlvideosink->width * sdlvideosink->height);
+ sdlvideosink->width * sdlvideosink->height);
memcpy (sdlvideosink->overlay->pixels[1],
- GST_BUFFER_DATA (buf) + sdlvideosink->width*sdlvideosink->height,
- sdlvideosink->width * sdlvideosink->height / 4);
+ GST_BUFFER_DATA (buf) + sdlvideosink->width * sdlvideosink->height,
+ sdlvideosink->width * sdlvideosink->height / 4);
memcpy (sdlvideosink->overlay->pixels[2],
- GST_BUFFER_DATA (buf) + sdlvideosink->width*sdlvideosink->height*5/4,
- sdlvideosink->width * sdlvideosink->height / 4);
+ GST_BUFFER_DATA (buf) +
+ sdlvideosink->width * sdlvideosink->height * 5 / 4,
+ sdlvideosink->width * sdlvideosink->height / 4);
} else {
memcpy (sdlvideosink->overlay->pixels[0], GST_BUFFER_DATA (buf),
- sdlvideosink->width * sdlvideosink->height * 2);
+ sdlvideosink->width * sdlvideosink->height * 2);
}
- gst_sdlvideosink_unlock(sdlvideosink);
+ gst_sdlvideosink_unlock (sdlvideosink);
}
- gst_buffer_unref(buf);
+ gst_buffer_unref (buf);
/* Show, baby, show! */
- SDL_DisplayYUVOverlay(sdlvideosink->overlay, &(sdlvideosink->rect));
+ SDL_DisplayYUVOverlay (sdlvideosink->overlay, &(sdlvideosink->rect));
- while (SDL_PollEvent(&sdl_event))
- {
- switch(sdl_event.type)
- {
+ while (SDL_PollEvent (&sdl_event)) {
+ switch (sdl_event.type) {
case SDL_VIDEORESIZE:
- /* create a SDL window of the size requested by the user */
- GST_VIDEOSINK_WIDTH (sdlvideosink) = sdl_event.resize.w;
- GST_VIDEOSINK_HEIGHT (sdlvideosink) = sdl_event.resize.h;
- gst_sdlvideosink_create(sdlvideosink);
- break;
+ /* create a SDL window of the size requested by the user */
+ GST_VIDEOSINK_WIDTH (sdlvideosink) = sdl_event.resize.w;
+ GST_VIDEOSINK_HEIGHT (sdlvideosink) = sdl_event.resize.h;
+ gst_sdlvideosink_create (sdlvideosink);
+ break;
}
}
}
static void
-gst_sdlvideosink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_sdlvideosink_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstSDLVideoSink *sdlvideosink;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_SDLVIDEOSINK (object));
- sdlvideosink = GST_SDLVIDEOSINK(object);
+ sdlvideosink = GST_SDLVIDEOSINK (object);
- switch (prop_id)
- {
+ switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
static void
-gst_sdlvideosink_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_sdlvideosink_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstSDLVideoSink *sdlvideosink;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_SDLVIDEOSINK (object));
- sdlvideosink = GST_SDLVIDEOSINK(object);
+ sdlvideosink = GST_SDLVIDEOSINK (object);
switch (prop_id) {
default:
static GstElementStateReturn
-gst_sdlvideosink_change_state (GstElement *element)
+gst_sdlvideosink_change_state (GstElement * element)
{
GstSDLVideoSink *sdlvideosink;
+
g_return_val_if_fail (GST_IS_SDLVIDEOSINK (element), GST_STATE_FAILURE);
- sdlvideosink = GST_SDLVIDEOSINK(element);
+ sdlvideosink = GST_SDLVIDEOSINK (element);
- switch (GST_STATE_TRANSITION (element))
- {
+ switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY:
if (!gst_sdlvideosink_initsdl (sdlvideosink))
- return GST_STATE_FAILURE;
+ return GST_STATE_FAILURE;
GST_FLAG_SET (sdlvideosink, GST_SDLVIDEOSINK_OPEN);
break;
case GST_STATE_PAUSED_TO_READY:
gst_sdlvideosink_deinitsdl (sdlvideosink);
GST_FLAG_UNSET (sdlvideosink, GST_SDLVIDEOSINK_OPEN);
break;
- default: /* do nothing */
+ default: /* do nothing */
break;
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
/* Loading the library containing GstVideoSink, our parent object */
if (!gst_library_load ("gstvideo"))
return FALSE;
- if (!gst_element_register (plugin, "sdlvideosink", GST_RANK_NONE, GST_TYPE_SDLVIDEOSINK))
+ if (!gst_element_register (plugin, "sdlvideosink", GST_RANK_NONE,
+ GST_TYPE_SDLVIDEOSINK))
return FALSE;
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "sdlvideosink",
- "SDL Video Sink",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "sdlvideosink",
+ "SDL Video Sink", plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
#include <SDL.h>
G_BEGIN_DECLS
-
#define GST_TYPE_SDLVIDEOSINK \
(gst_sdlvideosink_get_type())
#define GST_SDLVIDEOSINK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SDLVIDEOSINK))
#define GST_IS_SDLVIDEOSINK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SDLVIDEOSINK))
-
-typedef enum {
- GST_SDLVIDEOSINK_OPEN = GST_ELEMENT_FLAG_LAST,
+ typedef enum
+{
+ GST_SDLVIDEOSINK_OPEN = GST_ELEMENT_FLAG_LAST,
GST_SDLVIDEOSINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
} GstSDLVideoSinkFlags;
typedef struct _GstSDLVideoSink GstSDLVideoSink;
typedef struct _GstSDLVideoSinkClass GstSDLVideoSinkClass;
-struct _GstSDLVideoSink {
+struct _GstSDLVideoSink
+{
GstVideoSink videosink;
guint32 format;
- gint width, height; /* the size of the incoming YUV stream */
+ gint width, height; /* the size of the incoming YUV stream */
unsigned long xwindow_id;
gboolean init;
GMutex *lock;
};
-struct _GstSDLVideoSinkClass {
+struct _GstSDLVideoSinkClass
+{
GstVideoSinkClass parent_class;
};
-GType gst_sdlsink_get_type(void);
+GType gst_sdlsink_get_type (void);
G_END_DECLS
-
#endif /* __GST_SDLVIDEOSINK_H__ */
};
/* IcecastSend signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
- ARG_IP, /* the ip of the server */
- ARG_PORT, /* the encoder port number on the server */
- ARG_PASSWORD, /* the encoder password on the server */
- ARG_PUBLIC, /* is this stream public? */
- ARG_NAME, /* Name of the stream */
- ARG_DESCRIPTION, /* Description of the stream */
- ARG_GENRE, /* Genre of the stream */
- ARG_MOUNT, /* mountpoint of stream (icecast only) */
- ARG_DUMPFILE, /* Dumpfile on the server for this stream (icecast only) */
- ARG_ICY, /* use icy headers for login? (for use with shoutcast) */
- ARG_AIM, /* AIM number (shoutcast only) */
- ARG_ICQ, /* ICQ number (shoutcast only) */
- ARG_IRC, /* IRC server (shoutcast only) */
+ ARG_IP, /* the ip of the server */
+ ARG_PORT, /* the encoder port number on the server */
+ ARG_PASSWORD, /* the encoder password on the server */
+ ARG_PUBLIC, /* is this stream public? */
+ ARG_NAME, /* Name of the stream */
+ ARG_DESCRIPTION, /* Description of the stream */
+ ARG_GENRE, /* Genre of the stream */
+ ARG_MOUNT, /* mountpoint of stream (icecast only) */
+ ARG_DUMPFILE, /* Dumpfile on the server for this stream (icecast only) */
+ ARG_ICY, /* use icy headers for login? (for use with shoutcast) */
+ ARG_AIM, /* AIM number (shoutcast only) */
+ ARG_ICQ, /* ICQ number (shoutcast only) */
+ ARG_IRC, /* IRC server (shoutcast only) */
};
static GstStaticPadTemplate sink_template_factory =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/mpeg, "
- "mpegversion = (int) 1, "
- "layer = (int) [ 1, 3 ]"
- )
-);
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/mpeg, "
+ "mpegversion = (int) 1, " "layer = (int) [ 1, 3 ]")
+ );
-static void gst_icecastsend_class_init (GstIcecastSendClass *klass);
-static void gst_icecastsend_base_init (GstIcecastSendClass *klass);
-static void gst_icecastsend_init (GstIcecastSend *icecastsend);
+static void gst_icecastsend_class_init (GstIcecastSendClass * klass);
+static void gst_icecastsend_base_init (GstIcecastSendClass * klass);
+static void gst_icecastsend_init (GstIcecastSend * icecastsend);
-static void gst_icecastsend_chain (GstPad *pad, GstData *_data);
+static void gst_icecastsend_chain (GstPad * pad, GstData * _data);
-static void gst_icecastsend_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void gst_icecastsend_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+static void gst_icecastsend_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_icecastsend_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static
- GstElementStateReturn gst_icecastsend_change_state (GstElement *element);
+static
+ GstElementStateReturn gst_icecastsend_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_icecastsend_signals[LAST_SIGNAL] = { 0 }; */
GType
sizeof (GstIcecastSend), 0,
(GInstanceInitFunc) gst_icecastsend_init,
};
- icecastsend_type = g_type_register_static(GST_TYPE_ELEMENT, "GstIcecastSend", &icecastsend_info, 0);
+ icecastsend_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstIcecastSend",
+ &icecastsend_info, 0);
}
return icecastsend_type;
}
static void
-gst_icecastsend_base_init (GstIcecastSendClass *klass)
+gst_icecastsend_base_init (GstIcecastSendClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&sink_template_factory));
+ gst_static_pad_template_get (&sink_template_factory));
gst_element_class_set_details (element_class, &icecastsend_details);
}
static void
-gst_icecastsend_class_init (GstIcecastSendClass *klass)
+gst_icecastsend_class_init (GstIcecastSendClass * 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);
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_IP,
- g_param_spec_string("ip","ip","ip",
- NULL, G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_PORT,
- g_param_spec_int("port","port","port",
- G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_IP, g_param_spec_string ("ip", "ip", "ip", NULL, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PORT, g_param_spec_int ("port", "port", "port", G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_PASSWORD,
- g_param_spec_string("password","password","password",
- NULL, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PASSWORD, g_param_spec_string ("password", "password", "password", NULL, G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_PUBLIC,
- g_param_spec_boolean("public","public","public",
- TRUE, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PUBLIC, g_param_spec_boolean ("public", "public", "public", TRUE, G_PARAM_READWRITE)); /* CHECKME */
/* metadata */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_NAME,
- g_param_spec_string("name","name","name",
- NULL, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NAME, g_param_spec_string ("name", "name", "name", NULL, G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_DESCRIPTION,
- g_param_spec_string("description","description","description",
- NULL, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DESCRIPTION, g_param_spec_string ("description", "description", "description", NULL, G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_GENRE,
- g_param_spec_string("genre","genre","genre",
- NULL, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_GENRE, g_param_spec_string ("genre", "genre", "genre", NULL, G_PARAM_READWRITE)); /* CHECKME */
/* icecast only */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_MOUNT,
- g_param_spec_string("mount","mount","mount",
- NULL, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MOUNT, g_param_spec_string ("mount", "mount", "mount", NULL, G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_DUMPFILE,
- g_param_spec_string("dumpfile","dumpfile","dumpfile",
- NULL, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUMPFILE, g_param_spec_string ("dumpfile", "dumpfile", "dumpfile", NULL, G_PARAM_READWRITE)); /* CHECKME */
/* shoutcast only */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_ICY,
- g_param_spec_boolean("icy","icy","icy",
- FALSE, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ICY, g_param_spec_boolean ("icy", "icy", "icy", FALSE, G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_AIM,
- g_param_spec_string("aim","aim","aim",
- NULL, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_AIM, g_param_spec_string ("aim", "aim", "aim", NULL, G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_ICQ,
- g_param_spec_string("icq","icq","icq",
- NULL, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ICQ, g_param_spec_string ("icq", "icq", "icq", NULL, G_PARAM_READWRITE)); /* CHECKME */
+
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_IRC, g_param_spec_string ("irc", "irc", "irc", NULL, G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_IRC,
- g_param_spec_string("irc","irc","irc",
- NULL, G_PARAM_READWRITE)); /* CHECKME */
-
gobject_class->set_property = gst_icecastsend_set_property;
gobject_class->get_property = gst_icecastsend_get_property;
}
static void
-gst_icecastsend_init (GstIcecastSend *icecastsend)
+gst_icecastsend_init (GstIcecastSend * icecastsend)
{
GstElementClass *klass = GST_ELEMENT_GET_CLASS (icecastsend);
-
- icecastsend->sinkpad = gst_pad_new_from_template (
- gst_element_class_get_pad_template (klass, "sink"), "sink");
- gst_element_add_pad(GST_ELEMENT(icecastsend),icecastsend->sinkpad);
- gst_pad_set_chain_function(icecastsend->sinkpad,gst_icecastsend_chain);
+
+ icecastsend->sinkpad =
+ gst_pad_new_from_template (gst_element_class_get_pad_template (klass,
+ "sink"), "sink");
+ gst_element_add_pad (GST_ELEMENT (icecastsend), icecastsend->sinkpad);
+ gst_pad_set_chain_function (icecastsend->sinkpad, gst_icecastsend_chain);
icecastsend->ip = g_strdup ("127.0.0.1");
icecastsend->port = 8000;
}
static void
-gst_icecastsend_chain (GstPad *pad, GstData *_data)
+gst_icecastsend_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstIcecastSend *icecastsend;
glong ret;
- g_return_if_fail(pad != NULL);
- g_return_if_fail(GST_IS_PAD(pad));
- g_return_if_fail(buf != NULL);
+ g_return_if_fail (pad != NULL);
+ g_return_if_fail (GST_IS_PAD (pad));
+ g_return_if_fail (buf != NULL);
icecastsend = GST_ICECASTSEND (GST_OBJECT_PARENT (pad));
g_return_if_fail (GST_IS_ICECASTSEND (icecastsend));
ret = shout_send_data (&icecastsend->conn, GST_BUFFER_DATA (buf),
- GST_BUFFER_SIZE (buf));
+ GST_BUFFER_SIZE (buf));
if (!ret) {
g_warning ("send error: %i...\n", icecastsend->conn.error);
}
}
static void
-gst_icecastsend_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_icecastsend_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstIcecastSend *icecastsend;
- g_return_if_fail(GST_IS_ICECASTSEND(object));
- icecastsend = GST_ICECASTSEND(object);
+ g_return_if_fail (GST_IS_ICECASTSEND (object));
+ icecastsend = GST_ICECASTSEND (object);
switch (prop_id) {
case ARG_IP:
if (icecastsend->ip)
g_free (icecastsend->ip);
icecastsend->ip = g_strdup (g_value_get_string (value));
- break;
+ break;
case ARG_PORT:
icecastsend->port = g_value_get_int (value);
break;
icecastsend->password = g_strdup (g_value_get_string (value));
break;
- case ARG_PUBLIC: /* is this stream public? */
- icecastsend->public=g_value_get_boolean (value);
+ case ARG_PUBLIC: /* is this stream public? */
+ icecastsend->public = g_value_get_boolean (value);
break;
- case ARG_NAME: /* Name of the stream */
+ case ARG_NAME: /* Name of the stream */
if (icecastsend->name)
g_free (icecastsend->name);
icecastsend->name = g_strdup (g_value_get_string (value));
break;
- case ARG_DESCRIPTION: /* Description of the stream */
+ case ARG_DESCRIPTION: /* Description of the stream */
if (icecastsend->description)
g_free (icecastsend->description);
icecastsend->description = g_strdup (g_value_get_string (value));
break;
- case ARG_GENRE: /* Genre of the stream */
+ case ARG_GENRE: /* Genre of the stream */
if (icecastsend->genre)
g_free (icecastsend->genre);
icecastsend->genre = g_strdup (g_value_get_string (value));
break;
- case ARG_MOUNT: /* mountpoint of stream (icecast only) */
+ case ARG_MOUNT: /* mountpoint of stream (icecast only) */
if (icecastsend->mount)
g_free (icecastsend->mount);
icecastsend->mount = g_strdup (g_value_get_string (value));
break;
- case ARG_DUMPFILE: /* Dumpfile on the server for this stream (icecast only) */
+ case ARG_DUMPFILE: /* Dumpfile on the server for this stream (icecast only) */
if (icecastsend->dumpfile)
g_free (icecastsend->dumpfile);
icecastsend->dumpfile = g_strdup (g_value_get_string (value));
break;
- case ARG_ICY: /* use icy headers for login? (for use with shoutcast) */
+ case ARG_ICY: /* use icy headers for login? (for use with shoutcast) */
icecastsend->icy = g_value_get_boolean (value);
break;
- case ARG_AIM: /* AIM number (shoutcast only) */
+ case ARG_AIM: /* AIM number (shoutcast only) */
if (icecastsend->aim)
g_free (icecastsend->aim);
icecastsend->aim = g_strdup (g_value_get_string (value));
break;
- case ARG_ICQ: /* ICQ number (shoutcast only) */
+ case ARG_ICQ: /* ICQ number (shoutcast only) */
if (icecastsend->icq)
g_free (icecastsend->icq);
icecastsend->icq = g_strdup (g_value_get_string (value));
break;
- case ARG_IRC: /* IRC server (shoutcast only) */
+ case ARG_IRC: /* IRC server (shoutcast only) */
if (icecastsend->irc)
g_free (icecastsend->irc);
icecastsend->irc = g_strdup (g_value_get_string (value));
}
static void
-gst_icecastsend_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_icecastsend_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstIcecastSend *icecastsend;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_ICECASTSEND(object));
- icecastsend = GST_ICECASTSEND(object);
+ g_return_if_fail (GST_IS_ICECASTSEND (object));
+ icecastsend = GST_ICECASTSEND (object);
switch (prop_id) {
case ARG_IP:
case ARG_PASSWORD:
g_value_set_string (value, icecastsend->password);
break;
- case ARG_PUBLIC: /* is this stream public? */
+ case ARG_PUBLIC: /* is this stream public? */
g_value_set_boolean (value, icecastsend->public);
break;
- case ARG_NAME: /* Name of the stream */
+ case ARG_NAME: /* Name of the stream */
g_value_set_string (value, icecastsend->name);
break;
- case ARG_DESCRIPTION: /* Description of the stream */
+ case ARG_DESCRIPTION: /* Description of the stream */
g_value_set_string (value, icecastsend->description);
break;
- case ARG_GENRE: /* Genre of the stream */
+ case ARG_GENRE: /* Genre of the stream */
g_value_set_string (value, icecastsend->genre);
break;
- case ARG_MOUNT: /* mountpoint of stream (icecast only) */
+ case ARG_MOUNT: /* mountpoint of stream (icecast only) */
g_value_set_string (value, icecastsend->mount);
break;
- case ARG_DUMPFILE: /* Dumpfile on the server for this stream (icecast only) */
+ case ARG_DUMPFILE: /* Dumpfile on the server for this stream (icecast only) */
g_value_set_string (value, icecastsend->dumpfile);
break;
- case ARG_ICY: /* use icy headers for login? (for use with shoutcast) */
+ case ARG_ICY: /* use icy headers for login? (for use with shoutcast) */
g_value_set_boolean (value, icecastsend->icy);
break;
- case ARG_AIM: /* AIM number (shoutcast only) */
+ case ARG_AIM: /* AIM number (shoutcast only) */
g_value_set_string (value, icecastsend->aim);
break;
- case ARG_ICQ: /* ICQ number (shoutcast only) */
+ case ARG_ICQ: /* ICQ number (shoutcast only) */
g_value_set_string (value, icecastsend->icq);
break;
- case ARG_IRC: /* IRC server (shoutcast only) */
+ case ARG_IRC: /* IRC server (shoutcast only) */
g_value_set_string (value, icecastsend->irc);
break;
}
static GstElementStateReturn
-gst_icecastsend_change_state (GstElement *element)
+gst_icecastsend_change_state (GstElement * element)
{
GstIcecastSend *icecastsend;
g_return_val_if_fail (GST_IS_ICECASTSEND (element), GST_STATE_FAILURE);
- icecastsend = GST_ICECASTSEND(element);
+ icecastsend = GST_ICECASTSEND (element);
GST_DEBUG ("state pending %d", GST_STATE_PENDING (element));
/* if going down into NULL state, close the file if it's open */
switch (GST_STATE_TRANSITION (element)) {
- case GST_STATE_READY_TO_NULL:
- shout_init_connection (&icecastsend->conn);
-
- /* --- FIXME: shout requires an ip, and fails if it is given a host. */
- /* may want to put convert_to_ip(icecastsend->ip) here */
- icecastsend->conn.ip = icecastsend->ip;
- /* --- */
-
- icecastsend->conn.port = icecastsend->port;
- icecastsend->conn.password = icecastsend->password;
- icecastsend->conn.ispublic = icecastsend->public;
- icecastsend->conn.name = icecastsend->name;
- icecastsend->conn.description = icecastsend->description;
- icecastsend->conn.genre = icecastsend->genre;
- icecastsend->conn.mount = icecastsend->mount;
- icecastsend->conn.dumpfile = icecastsend->dumpfile;
- icecastsend->conn.icy_compat = icecastsend->icy;
- /* --- FIXME: libshout 1.0.5 doesn't have the two next fields */
- /* icecastsend->conn.aim = icecastsend->aim;
- icecastsend->conn.irc = icecastsend->irc;*/
-
- if (shout_connect (&icecastsend->conn)) {
- g_print ("connected to server...\n");
- }
- else {
- g_warning ("couldn't connect to server... (%i: %s)\n",
- icecastsend->conn.error,
- SHOUT_ERRORS[icecastsend->conn.error]);
- shout_disconnect (&icecastsend->conn);
- return GST_STATE_FAILURE;
- }
- break;
- case GST_STATE_PAUSED_TO_READY:
- shout_disconnect (&icecastsend->conn);
- break;
- default:
- break;
+ case GST_STATE_READY_TO_NULL:
+ shout_init_connection (&icecastsend->conn);
+
+ /* --- FIXME: shout requires an ip, and fails if it is given a host. */
+ /* may want to put convert_to_ip(icecastsend->ip) here */
+ icecastsend->conn.ip = icecastsend->ip;
+ /* --- */
+
+ icecastsend->conn.port = icecastsend->port;
+ icecastsend->conn.password = icecastsend->password;
+ icecastsend->conn.ispublic = icecastsend->public;
+ icecastsend->conn.name = icecastsend->name;
+ icecastsend->conn.description = icecastsend->description;
+ icecastsend->conn.genre = icecastsend->genre;
+ icecastsend->conn.mount = icecastsend->mount;
+ icecastsend->conn.dumpfile = icecastsend->dumpfile;
+ icecastsend->conn.icy_compat = icecastsend->icy;
+ /* --- FIXME: libshout 1.0.5 doesn't have the two next fields */
+ /* icecastsend->conn.aim = icecastsend->aim;
+ icecastsend->conn.irc = icecastsend->irc; */
+
+ if (shout_connect (&icecastsend->conn)) {
+ g_print ("connected to server...\n");
+ } else {
+ g_warning ("couldn't connect to server... (%i: %s)\n",
+ icecastsend->conn.error, SHOUT_ERRORS[icecastsend->conn.error]);
+ shout_disconnect (&icecastsend->conn);
+ return GST_STATE_FAILURE;
+ }
+ break;
+ case GST_STATE_PAUSED_TO_READY:
+ shout_disconnect (&icecastsend->conn);
+ break;
+ default:
+ break;
}
/* if we haven't failed already, give the parent class a chance to ;-) */
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
return gst_element_register (plugin, "icecastsend",
- GST_RANK_NONE, GST_TYPE_ICECASTSEND);
+ GST_RANK_NONE, GST_TYPE_ICECASTSEND);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "icecastsend",
- "Sends data to an icecast server using libshout",
- plugin_init,
- VERSION,
- "GPL",
- "libshout",
- "http://developer.icecast.org/libshout/"
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "icecastsend",
+ "Sends data to an icecast server using libshout",
+ plugin_init,
+ VERSION, "GPL", "libshout", "http://developer.icecast.org/libshout/")
#include <shout/shout.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
/* Definition of structure storing data for this element. */
-typedef struct _GstIcecastSend GstIcecastSend;
-struct _GstIcecastSend {
- GstElement element;
-
- GstPad *sinkpad,*srcpad;
-
- shout_conn_t conn;
-
- gchar *ip;
- guint port;
- gchar *password;
- gboolean public;
- gchar *name;
- gchar *description;
- gchar *genre;
- gchar *mount;
- gchar *dumpfile;
- gboolean icy;
- gchar *aim;
- gchar *icq;
- gchar *irc;
-
-};
+ typedef struct _GstIcecastSend GstIcecastSend;
+ struct _GstIcecastSend
+ {
+ GstElement element;
+
+ GstPad *sinkpad, *srcpad;
+
+ shout_conn_t conn;
+
+ gchar *ip;
+ guint port;
+ gchar *password;
+ gboolean public;
+ gchar *name;
+ gchar *description;
+ gchar *genre;
+ gchar *mount;
+ gchar *dumpfile;
+ gboolean icy;
+ gchar *aim;
+ gchar *icq;
+ gchar *irc;
+
+ };
/* Standard definition defining a class for this element. */
-typedef struct _GstIcecastSendClass GstIcecastSendClass;
-struct _GstIcecastSendClass {
- GstElementClass parent_class;
-};
+ typedef struct _GstIcecastSendClass GstIcecastSendClass;
+ struct _GstIcecastSendClass
+ {
+ GstElementClass parent_class;
+ };
/* Standard macros for defining types for this element. */
#define GST_TYPE_ICECASTSEND \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ICECASTSEND))
/* Standard function returning type information. */
-GType gst_icecastsend_get_type(void);
+ GType gst_icecastsend_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_ICECASTSEND_H__ */
+#endif /* __GST_ICECASTSEND_H__ */
extern gboolean _gst_plugin_spew;
-gboolean idle_func(gpointer data);
+gboolean idle_func (gpointer data);
GtkWidget *drawingarea;
-int main(int argc,char *argv[]) {
+int
+main (int argc, char *argv[])
+{
GstElement *bin;
GstElementFactory *srcfactory;
GstElement *src;
GtkWidget *wave_widget;
GtkWidget *appwindow;
- gst_init(&argc,&argv);
- gst_plugin_load("libsmoothwave.so");
- gtk_init(&argc,&argv);
+ gst_init (&argc, &argv);
+ gst_plugin_load ("libsmoothwave.so");
+ gtk_init (&argc, &argv);
- bin = gst_pipeline_new("bin");
+ bin = gst_pipeline_new ("bin");
- srcfactory = gst_element_factory_find("sinesrc");
- g_return_val_if_fail(srcfactory != NULL, -1);
- wavefactory = gst_element_factory_find("smoothwave");
- g_return_val_if_fail(wavefactory != NULL, -1);
+ srcfactory = gst_element_factory_find ("sinesrc");
+ g_return_val_if_fail (srcfactory != NULL, -1);
+ wavefactory = gst_element_factory_find ("smoothwave");
+ g_return_val_if_fail (wavefactory != NULL, -1);
- src = gst_element_factory_create(srcfactory,"src");
+ src = gst_element_factory_create (srcfactory, "src");
//g_object_set(G_OBJECT(src),"bytes_per_read",(gulong)2048,NULL);
- wave = gst_element_factory_create(wavefactory,"wave");
- g_object_set(G_OBJECT(wave),"width",256,"height",100,NULL);
+ wave = gst_element_factory_create (wavefactory, "wave");
+ g_object_set (G_OBJECT (wave), "width", 256, "height", 100, NULL);
- gst_bin_add(GST_BIN(bin),GST_ELEMENT(src));
- gst_bin_add(GST_BIN(bin),GST_ELEMENT(wave));
+ gst_bin_add (GST_BIN (bin), GST_ELEMENT (src));
+ gst_bin_add (GST_BIN (bin), GST_ELEMENT (wave));
- gst_pad_link(gst_element_get_pad(src,"src"),
- gst_element_get_pad(wave,"sink"));
+ gst_pad_link (gst_element_get_pad (src, "src"),
+ gst_element_get_pad (wave, "sink"));
- appwindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- g_object_get(G_OBJECT(wave),"widget",&wave_widget,NULL);
- gtk_container_add(GTK_CONTAINER(appwindow), wave_widget);
- gtk_widget_show_all(appwindow);
+ appwindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ g_object_get (G_OBJECT (wave), "widget", &wave_widget, NULL);
+ gtk_container_add (GTK_CONTAINER (appwindow), wave_widget);
+ gtk_widget_show_all (appwindow);
- gst_element_set_state(GST_ELEMENT(bin),GST_STATE_READY);
- gst_element_set_state(GST_ELEMENT(bin),GST_STATE_PLAYING);
+ gst_element_set_state (GST_ELEMENT (bin), GST_STATE_READY);
+ gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING);
- g_idle_add(idle_func,bin);
+ g_idle_add (idle_func, bin);
- gtk_main();
+ gtk_main ();
return 0;
}
-gboolean idle_func(gpointer data)
+gboolean
+idle_func (gpointer data)
{
- gst_bin_iterate(GST_BIN(data));
+ gst_bin_iterate (GST_BIN (data));
return TRUE;
}
#include "gstsmoothwave.h"
-static GstElementDetails gst_smoothwave_details = GST_ELEMENT_DETAILS (
- "Smooth waveform",
- "Visualization",
- "Fading grayscale waveform display",
- "Erik Walthinsen <omega@cse.ogi.edu>"
-);
+static GstElementDetails gst_smoothwave_details =
+GST_ELEMENT_DETAILS ("Smooth waveform",
+ "Visualization",
+ "Fading grayscale waveform display",
+ "Erik Walthinsen <omega@cse.ogi.edu>");
/* SmoothWave signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_WIDTH,
ARG_HEIGHT,
ARG_WIDGET,
};
-static void gst_smoothwave_base_init (gpointer g_class);
-static void gst_smoothwave_class_init (GstSmoothWaveClass *klass);
-static void gst_smoothwave_init (GstSmoothWave *smoothwave);
+static void gst_smoothwave_base_init (gpointer g_class);
+static void gst_smoothwave_class_init (GstSmoothWaveClass * klass);
+static void gst_smoothwave_init (GstSmoothWave * smoothwave);
-static void gst_smoothwave_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void gst_smoothwave_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+static void gst_smoothwave_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_smoothwave_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static void gst_smoothwave_chain (GstPad *pad, GstData *_data);
+static void gst_smoothwave_chain (GstPad * pad, GstData * _data);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_smoothwave_signals[LAST_SIGNAL] = { 0 }; */
if (!smoothwave_type) {
static const GTypeInfo smoothwave_info = {
- sizeof(GstSmoothWaveClass),
+ sizeof (GstSmoothWaveClass),
gst_smoothwave_base_init,
NULL,
- (GClassInitFunc)gst_smoothwave_class_init,
+ (GClassInitFunc) gst_smoothwave_class_init,
NULL,
NULL,
- sizeof(GstSmoothWave),
+ sizeof (GstSmoothWave),
0,
- (GInstanceInitFunc)gst_smoothwave_init,
+ (GInstanceInitFunc) gst_smoothwave_init,
};
- smoothwave_type = g_type_register_static(GST_TYPE_ELEMENT, "GstSmoothWave", &smoothwave_info, 0);
+ smoothwave_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstSmoothWave",
+ &smoothwave_info, 0);
}
return smoothwave_type;
}
}
static void
-gst_smoothwave_class_init (GstSmoothWaveClass *klass)
+gst_smoothwave_class_init (GstSmoothWaveClass * 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);
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_WIDTH,
- g_param_spec_int("width","width","width",
- G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_HEIGHT,
- g_param_spec_int("height","height","height",
- G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_WIDGET,
- g_param_spec_object("widget","widget","widget",
- GTK_TYPE_WIDGET,G_PARAM_READABLE)); /* CHECKME! */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_WIDTH, g_param_spec_int ("width", "width", "width", G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_HEIGHT, g_param_spec_int ("height", "height", "height", G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_WIDGET, g_param_spec_object ("widget", "widget", "widget", GTK_TYPE_WIDGET, G_PARAM_READABLE)); /* CHECKME! */
gobject_class->set_property = gst_smoothwave_set_property;
gobject_class->get_property = gst_smoothwave_get_property;
}
static void
-gst_smoothwave_init (GstSmoothWave *smoothwave)
+gst_smoothwave_init (GstSmoothWave * smoothwave)
{
int i;
guint32 palette[256];
- smoothwave->sinkpad = gst_pad_new("sink",GST_PAD_SINK);
- gst_element_add_pad(GST_ELEMENT(smoothwave),smoothwave->sinkpad);
- gst_pad_set_chain_function(smoothwave->sinkpad,gst_smoothwave_chain);
- smoothwave->srcpad = gst_pad_new("src",GST_PAD_SRC);
- gst_element_add_pad(GST_ELEMENT(smoothwave),smoothwave->srcpad);
+ smoothwave->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
+ gst_element_add_pad (GST_ELEMENT (smoothwave), smoothwave->sinkpad);
+ gst_pad_set_chain_function (smoothwave->sinkpad, gst_smoothwave_chain);
+ smoothwave->srcpad = gst_pad_new ("src", GST_PAD_SRC);
+ gst_element_add_pad (GST_ELEMENT (smoothwave), smoothwave->srcpad);
/* smoothwave->meta = NULL; */
smoothwave->width = 512;
smoothwave->height = 256;
- gdk_rgb_init();
+ gdk_rgb_init ();
/* gtk_widget_set_default_colormap (gdk_rgb_get_cmap()); */
/* gtk_widget_set_default_visual (gdk_rgb_get_visual()); */
/* GST_DEBUG ("creating palette"); */
- for (i=0;i<256;i++)
+ for (i = 0; i < 256; i++)
palette[i] = (i << 16) || (i << 8);
/* GST_DEBUG ("creating cmap"); */
- smoothwave->cmap = gdk_rgb_cmap_new(palette,256);
+ smoothwave->cmap = gdk_rgb_cmap_new (palette, 256);
/* GST_DEBUG ("created cmap"); */
/* gtk_widget_set_default_colormap (smoothwave->cmap); */
- smoothwave->image = gtk_drawing_area_new();
- gtk_drawing_area_size(GTK_DRAWING_AREA(smoothwave->image),
- smoothwave->width,smoothwave->height);
- gtk_widget_show(smoothwave->image);
+ smoothwave->image = gtk_drawing_area_new ();
+ gtk_drawing_area_size (GTK_DRAWING_AREA (smoothwave->image),
+ smoothwave->width, smoothwave->height);
+ gtk_widget_show (smoothwave->image);
- smoothwave->imagebuffer = g_malloc(smoothwave->width*smoothwave->height);
- memset(smoothwave->imagebuffer,0,smoothwave->width*smoothwave->height);
+ smoothwave->imagebuffer = g_malloc (smoothwave->width * smoothwave->height);
+ memset (smoothwave->imagebuffer, 0, smoothwave->width * smoothwave->height);
}
static void
-gst_smoothwave_chain (GstPad *pad, GstData *_data)
+gst_smoothwave_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstSmoothWave *smoothwave;
gint16 *samples;
- gint samplecount,i;
+ gint samplecount, i;
register guint32 *ptr;
gint qheight;
- g_return_if_fail(pad != NULL);
- g_return_if_fail(GST_IS_PAD(pad));
- g_return_if_fail(buf != NULL);
+ g_return_if_fail (pad != NULL);
+ g_return_if_fail (GST_IS_PAD (pad));
+ g_return_if_fail (buf != NULL);
/* g_return_if_fail(GST_IS_BUFFER(buf)); */
- smoothwave = GST_SMOOTHWAVE(GST_OBJECT_PARENT (pad));
+ smoothwave = GST_SMOOTHWAVE (GST_OBJECT_PARENT (pad));
/* first deal with audio metadata */
#if 0
/* FIXME: need to unref the old metadata so it goes away */
}
/* we just make a copy of the pointer */
- smoothwave->meta = (MetaAudioRaw *)(buf->meta);
+ smoothwave->meta = (MetaAudioRaw *) (buf->meta);
/* FIXME: now we have to ref the metadata so it doesn't go away */
}
#endif
/* g_return_if_fail(smoothwave->meta != NULL); */
- samples = (gint16 *)GST_BUFFER_DATA(buf);
+ samples = (gint16 *) GST_BUFFER_DATA (buf);
/* samplecount = buf->datasize / (smoothwave->meta->channels * sizeof(gint16)); */
- samplecount = GST_BUFFER_SIZE(buf) / (2 * sizeof(gint16));
+ samplecount = GST_BUFFER_SIZE (buf) / (2 * sizeof (gint16));
- qheight = smoothwave->height/4;
+ qheight = smoothwave->height / 4;
/* GST_DEBUG ("traversing %d",smoothwave->width); */
- for (i=0;i<MAX(smoothwave->width,samplecount);i++) {
- gint16 y1 = (gint32)(samples[i*2] * qheight) / 32768 +
- qheight;
- gint16 y2 = (gint32)(samples[(i*2)+1] * qheight) / 32768 +
- (qheight*3);
- smoothwave->imagebuffer[y1*smoothwave->width + i] = 0xff;
- smoothwave->imagebuffer[y2*smoothwave->width + i] = 0xff;
+ for (i = 0; i < MAX (smoothwave->width, samplecount); i++) {
+ gint16 y1 = (gint32) (samples[i * 2] * qheight) / 32768 + qheight;
+ gint16 y2 = (gint32) (samples[(i * 2) + 1] * qheight) / 32768 +
+ (qheight * 3);
+ smoothwave->imagebuffer[y1 * smoothwave->width + i] = 0xff;
+ smoothwave->imagebuffer[y2 * smoothwave->width + i] = 0xff;
/* smoothwave->imagebuffer[i+(smoothwave->width*5)] = i; */
}
- ptr = (guint32 *)smoothwave->imagebuffer;
- for (i=0;i<(smoothwave->width*smoothwave->height)/4;i++) {
- if (*ptr){
+ ptr = (guint32 *) smoothwave->imagebuffer;
+ for (i = 0; i < (smoothwave->width * smoothwave->height) / 4; i++) {
+ if (*ptr) {
*ptr -= ((*ptr & 0xf0f0f0f0ul) >> 4) + ((*ptr & 0xe0e0e0e0ul) >> 5);
ptr++;
- }else{
+ } else {
ptr++;
}
}
GDK_RGB_DITHER_NONE,
smoothwave->imagebuffer,smoothwave->width,
smoothwave->cmap);*/
- gdk_draw_gray_image(smoothwave->image->window,
- smoothwave->image->style->fg_gc[GTK_STATE_NORMAL],
- 0,0,smoothwave->width,smoothwave->height,
- GDK_RGB_DITHER_NORMAL,
- smoothwave->imagebuffer,smoothwave->width);
+ gdk_draw_gray_image (smoothwave->image->window,
+ smoothwave->image->style->fg_gc[GTK_STATE_NORMAL],
+ 0, 0, smoothwave->width, smoothwave->height,
+ GDK_RGB_DITHER_NORMAL, smoothwave->imagebuffer, smoothwave->width);
/* gst_trace_add_entry(NULL,0,buf,"smoothwave: calculated smoothwave"); */
- gst_buffer_unref(buf);
+ gst_buffer_unref (buf);
}
static void
-gst_smoothwave_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_smoothwave_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstSmoothWave *smoothwave;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_SMOOTHWAVE(object));
- smoothwave = GST_SMOOTHWAVE(object);
+ g_return_if_fail (GST_IS_SMOOTHWAVE (object));
+ smoothwave = GST_SMOOTHWAVE (object);
switch (prop_id) {
case ARG_WIDTH:
smoothwave->width = g_value_get_int (value);
- gtk_drawing_area_size(GTK_DRAWING_AREA(smoothwave->image),
- smoothwave->width,smoothwave->height);
- gtk_widget_set_usize(GTK_WIDGET(smoothwave->image),
- smoothwave->width,smoothwave->height);
+ gtk_drawing_area_size (GTK_DRAWING_AREA (smoothwave->image),
+ smoothwave->width, smoothwave->height);
+ gtk_widget_set_usize (GTK_WIDGET (smoothwave->image),
+ smoothwave->width, smoothwave->height);
break;
case ARG_HEIGHT:
smoothwave->height = g_value_get_int (value);
- gtk_drawing_area_size(GTK_DRAWING_AREA(smoothwave->image),
- smoothwave->width,smoothwave->height);
- gtk_widget_set_usize(GTK_WIDGET(smoothwave->image),
- smoothwave->width,smoothwave->height);
+ gtk_drawing_area_size (GTK_DRAWING_AREA (smoothwave->image),
+ smoothwave->width, smoothwave->height);
+ gtk_widget_set_usize (GTK_WIDGET (smoothwave->image),
+ smoothwave->width, smoothwave->height);
break;
default:
break;
}
static void
-gst_smoothwave_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_smoothwave_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstSmoothWave *smoothwave;
/* it's not null if we got it, but it might not be ours */
- smoothwave = GST_SMOOTHWAVE(object);
+ smoothwave = GST_SMOOTHWAVE (object);
switch (prop_id) {
- case ARG_WIDTH: {
+ case ARG_WIDTH:{
g_value_set_int (value, smoothwave->width);
break;
}
- case ARG_HEIGHT: {
+ case ARG_HEIGHT:{
g_value_set_int (value, smoothwave->height);
break;
}
- case ARG_WIDGET: {
+ case ARG_WIDGET:{
g_value_set_object (value, smoothwave->image);
break;
}
- default: {
+ default:{
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- if (!gst_element_register (plugin, "smoothwave", GST_RANK_NONE, GST_TYPE_SMOOTHWAVE))
+ if (!gst_element_register (plugin, "smoothwave", GST_RANK_NONE,
+ GST_TYPE_SMOOTHWAVE))
return FALSE;
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "smoothwave",
- "Fading greyscale waveform display",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "smoothwave",
+ "Fading greyscale waveform display",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
#include <gtk/gtk.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_SMOOTHWAVE \
#define GST_IS_SMOOTHWAVE_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SMOOTHWAVE))
-typedef struct _GstSmoothWave GstSmoothWave;
-typedef struct _GstSmoothWaveClass GstSmoothWaveClass;
+ typedef struct _GstSmoothWave GstSmoothWave;
+ typedef struct _GstSmoothWaveClass GstSmoothWaveClass;
-struct _GstSmoothWave {
- GstElement element;
+ struct _GstSmoothWave
+ {
+ GstElement element;
- GstPad *sinkpad,*srcpad;
+ GstPad *sinkpad, *srcpad;
- gint width,height;
+ gint width, height;
- GdkRgbCmap *cmap;
- GtkWidget *image;
- guchar *imagebuffer;
-};
+ GdkRgbCmap *cmap;
+ GtkWidget *image;
+ guchar *imagebuffer;
+ };
-struct _GstSmoothWaveClass {
- GstElementClass parent_class;
-};
+ struct _GstSmoothWaveClass
+ {
+ GstElementClass parent_class;
+ };
-GType gst_smoothwave_get_type(void);
+ GType gst_smoothwave_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_SMOOTHWAVE_H__ */
+#endif /* __GST_SMOOTHWAVE_H__ */
};
static GstStaticPadTemplate snapshot_src_factory =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (GST_VIDEO_CAPS_BGR)
-);
+GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_BGR)
+ );
static GstStaticPadTemplate snapshot_sink_factory =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (GST_VIDEO_CAPS_BGR)
-);
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_BGR)
+ );
/* Snapshot signals and args */
-enum {
+enum
+{
/* FILL ME */
SNAPSHOT_SIGNAL,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_FRAME,
ARG_LOCATION
};
-static GType gst_snapshot_get_type (void);
-static void gst_snapshot_base_init (gpointer g_class);
-static void gst_snapshot_class_init (GstSnapshotClass *klass);
-static void gst_snapshot_init (GstSnapshot *snapshot);
+static GType gst_snapshot_get_type (void);
+static void gst_snapshot_base_init (gpointer g_class);
+static void gst_snapshot_class_init (GstSnapshotClass * klass);
+static void gst_snapshot_init (GstSnapshot * snapshot);
-static void gst_snapshot_chain (GstPad *pad, GstData *_data);
+static void gst_snapshot_chain (GstPad * pad, GstData * _data);
-static void gst_snapshot_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void gst_snapshot_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
-static void snapshot_handler(GstElement *element);
+static void gst_snapshot_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_snapshot_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+static void snapshot_handler (GstElement * element);
static GstElementClass *parent_class = NULL;
-static guint gst_snapshot_signals[LAST_SIGNAL] = { 0 };
+static guint gst_snapshot_signals[LAST_SIGNAL] = { 0 };
-static void user_error_fn(png_structp png_ptr, png_const_charp error_msg)
+static void
+user_error_fn (png_structp png_ptr, png_const_charp error_msg)
{
- g_warning("%s", error_msg);
+ g_warning ("%s", error_msg);
}
-static void user_warning_fn(png_structp png_ptr, png_const_charp warning_msg)
+static void
+user_warning_fn (png_structp png_ptr, png_const_charp warning_msg)
{
- g_warning("%s", warning_msg);
+ g_warning ("%s", warning_msg);
}
GType
if (!snapshot_type) {
static const GTypeInfo snapshot_info = {
- sizeof(GstSnapshotClass),
+ sizeof (GstSnapshotClass),
gst_snapshot_base_init,
NULL,
- (GClassInitFunc)gst_snapshot_class_init,
+ (GClassInitFunc) gst_snapshot_class_init,
NULL,
NULL,
- sizeof(GstSnapshot),
+ sizeof (GstSnapshot),
0,
- (GInstanceInitFunc)gst_snapshot_init,
+ (GInstanceInitFunc) gst_snapshot_init,
};
- snapshot_type = g_type_register_static(GST_TYPE_ELEMENT, "GstSnapshot", &snapshot_info, 0);
+ snapshot_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstSnapshot", &snapshot_info,
+ 0);
}
return snapshot_type;
}
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&snapshot_sink_factory));
- gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&snapshot_src_factory));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&snapshot_sink_factory));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&snapshot_src_factory));
gst_element_class_set_details (element_class, &snapshot_details);
}
static void
-gst_snapshot_class_init (GstSnapshotClass *klass)
+gst_snapshot_class_init (GstSnapshotClass * 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);
+
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FRAME,
+ g_param_spec_long ("frame", "frame", "frame",
+ 0, G_MAXLONG, 0, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATION,
+ g_param_spec_string ("location", "location", "location",
+ 0, G_PARAM_READWRITE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_FRAME,
- g_param_spec_long("frame","frame","frame",
- 0, G_MAXLONG, 0, G_PARAM_READWRITE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_LOCATION,
- g_param_spec_string("location","location","location",
- 0,G_PARAM_READWRITE));
-
gst_snapshot_signals[SNAPSHOT_SIGNAL] =
- g_signal_new("snapshot", G_TYPE_FROM_CLASS(klass),
- G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET(GstSnapshotClass, snapshot),
- NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("snapshot", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstSnapshotClass, snapshot),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
klass->snapshot = snapshot_handler;
}
static void
-snapshot_handler(GstElement *element)
+snapshot_handler (GstElement * element)
{
GstSnapshot *snapshot;
- snapshot = GST_SNAPSHOT( element );
- snapshot->snapshot_asked=TRUE;
+ snapshot = GST_SNAPSHOT (element);
+ snapshot->snapshot_asked = TRUE;
}
static gboolean
-gst_snapshot_sinkconnect (GstPad *pad, const GstCaps *caps)
+gst_snapshot_sinkconnect (GstPad * pad, const GstCaps * caps)
{
GstSnapshot *filter;
gdouble fps;
filter = GST_SNAPSHOT (gst_pad_get_parent (pad));
structure = gst_caps_get_structure (caps, 0);
- gst_structure_get_int (structure, "width", &filter->width);
- gst_structure_get_int (structure, "height", &filter->height);
- gst_structure_get_double (structure, "framerate", &fps);
- gst_structure_get_fourcc (structure, "format", &filter->format);
+ gst_structure_get_int (structure, "width", &filter->width);
+ gst_structure_get_int (structure, "height", &filter->height);
+ gst_structure_get_double (structure, "framerate", &fps);
+ gst_structure_get_fourcc (structure, "format", &filter->format);
filter->to_bpp = 24;
- filter->png_struct_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, (png_voidp)NULL, user_error_fn, user_warning_fn);
- if ( filter->png_struct_ptr == NULL )
- g_warning( "Failed to initialize png structure");
+ filter->png_struct_ptr =
+ png_create_write_struct (PNG_LIBPNG_VER_STRING, (png_voidp) NULL,
+ user_error_fn, user_warning_fn);
+ if (filter->png_struct_ptr == NULL)
+ g_warning ("Failed to initialize png structure");
+
+ filter->png_info_ptr = png_create_info_struct (filter->png_struct_ptr);
- filter->png_info_ptr = png_create_info_struct( filter->png_struct_ptr );
+ if (setjmp (filter->png_struct_ptr->jmpbuf))
+ png_destroy_write_struct (&filter->png_struct_ptr, &filter->png_info_ptr);
- if (setjmp( filter->png_struct_ptr->jmpbuf))
- png_destroy_write_struct(&filter->png_struct_ptr, &filter->png_info_ptr);
-
gst_pad_try_set_caps (filter->srcpad, caps);
return GST_PAD_LINK_OK;
}
static void
-gst_snapshot_init (GstSnapshot *snapshot)
+gst_snapshot_init (GstSnapshot * snapshot)
{
- snapshot->sinkpad = gst_pad_new_from_template (gst_static_pad_template_get (&snapshot_sink_factory), "sink");
+ snapshot->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&snapshot_sink_factory), "sink");
gst_pad_set_link_function (snapshot->sinkpad, gst_snapshot_sinkconnect);
gst_pad_set_chain_function (snapshot->sinkpad, gst_snapshot_chain);
gst_element_add_pad (GST_ELEMENT (snapshot), snapshot->sinkpad);
- snapshot->srcpad = gst_pad_new_from_template (gst_static_pad_template_get (&snapshot_src_factory), "src");
+ snapshot->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&snapshot_src_factory), "src");
gst_element_add_pad (GST_ELEMENT (snapshot), snapshot->srcpad);
snapshot->cur_frame = 0;
- snapshot->frame=-1;
- snapshot->snapshot_asked=FALSE;
+ snapshot->frame = -1;
+ snapshot->snapshot_asked = FALSE;
}
static void
-gst_snapshot_chain (GstPad *pad, GstData *_data)
+gst_snapshot_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstSnapshot *snapshot;
guchar *data;
gulong size;
gint i;
- png_byte *row_pointers[ MAX_HEIGHT ];
+ png_byte *row_pointers[MAX_HEIGHT];
FILE *fp;
- g_return_if_fail(pad != NULL);
- g_return_if_fail(GST_IS_PAD(pad));
- g_return_if_fail(buf != NULL);
+ g_return_if_fail (pad != NULL);
+ g_return_if_fail (GST_IS_PAD (pad));
+ g_return_if_fail (buf != NULL);
snapshot = GST_SNAPSHOT (GST_OBJECT_PARENT (pad));
- data = GST_BUFFER_DATA(buf);
- size = GST_BUFFER_SIZE(buf);
+ data = GST_BUFFER_DATA (buf);
+ size = GST_BUFFER_SIZE (buf);
- GST_DEBUG ("snapshot: have buffer of %d\n", GST_BUFFER_SIZE(buf));
+ GST_DEBUG ("snapshot: have buffer of %d\n", GST_BUFFER_SIZE (buf));
snapshot->cur_frame++;
if (snapshot->cur_frame == snapshot->frame ||
- snapshot->snapshot_asked == TRUE )
- {
+ snapshot->snapshot_asked == TRUE) {
snapshot->snapshot_asked = FALSE;
- GST_INFO ("dumpfile : %s\n", snapshot->location );
- fp = fopen( snapshot->location, "wb" );
- if ( fp == NULL )
- g_warning(" Can not open %s\n", snapshot->location );
- else
- {
- png_set_filter( snapshot->png_struct_ptr, 0, PNG_FILTER_NONE | PNG_FILTER_VALUE_NONE );
- png_init_io(snapshot->png_struct_ptr, fp);
- png_set_compression_level( snapshot->png_struct_ptr, 9);
- png_set_IHDR(
- snapshot->png_struct_ptr,
- snapshot->png_info_ptr,
- snapshot->width,
- snapshot->height,
- snapshot->to_bpp/3,
- PNG_COLOR_TYPE_RGB,
- PNG_INTERLACE_NONE,
- PNG_COMPRESSION_TYPE_DEFAULT,
- PNG_FILTER_TYPE_DEFAULT
- );
-
- for ( i = 0; i < snapshot->height; i++ )
- row_pointers[i] = data + (snapshot->width * i * snapshot->to_bpp/8 );
-
- png_write_info( snapshot->png_struct_ptr, snapshot->png_info_ptr );
- png_write_image( snapshot->png_struct_ptr, row_pointers );
- png_write_end( snapshot->png_struct_ptr, NULL );
- png_destroy_info_struct ( snapshot->png_struct_ptr, &snapshot->png_info_ptr );
- png_destroy_write_struct( &snapshot->png_struct_ptr, (png_infopp)NULL );
- fclose( fp );
- g_signal_emit (G_OBJECT (snapshot),
- gst_snapshot_signals[SNAPSHOT_SIGNAL], 0);
+ GST_INFO ("dumpfile : %s\n", snapshot->location);
+ fp = fopen (snapshot->location, "wb");
+ if (fp == NULL)
+ g_warning (" Can not open %s\n", snapshot->location);
+ else {
+ png_set_filter (snapshot->png_struct_ptr, 0,
+ PNG_FILTER_NONE | PNG_FILTER_VALUE_NONE);
+ png_init_io (snapshot->png_struct_ptr, fp);
+ png_set_compression_level (snapshot->png_struct_ptr, 9);
+ png_set_IHDR (snapshot->png_struct_ptr,
+ snapshot->png_info_ptr,
+ snapshot->width,
+ snapshot->height,
+ snapshot->to_bpp / 3,
+ PNG_COLOR_TYPE_RGB,
+ PNG_INTERLACE_NONE,
+ PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
+
+ for (i = 0; i < snapshot->height; i++)
+ row_pointers[i] = data + (snapshot->width * i * snapshot->to_bpp / 8);
+
+ png_write_info (snapshot->png_struct_ptr, snapshot->png_info_ptr);
+ png_write_image (snapshot->png_struct_ptr, row_pointers);
+ png_write_end (snapshot->png_struct_ptr, NULL);
+ png_destroy_info_struct (snapshot->png_struct_ptr,
+ &snapshot->png_info_ptr);
+ png_destroy_write_struct (&snapshot->png_struct_ptr, (png_infopp) NULL);
+ fclose (fp);
+ g_signal_emit (G_OBJECT (snapshot),
+ gst_snapshot_signals[SNAPSHOT_SIGNAL], 0);
}
}
- gst_pad_push(snapshot->srcpad,GST_DATA (buf ));
+ gst_pad_push (snapshot->srcpad, GST_DATA (buf));
}
static void
-gst_snapshot_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_snapshot_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstSnapshot *snapshot;
- g_return_if_fail(GST_IS_SNAPSHOT(object));
- snapshot = GST_SNAPSHOT(object);
+ g_return_if_fail (GST_IS_SNAPSHOT (object));
+ snapshot = GST_SNAPSHOT (object);
switch (prop_id) {
case ARG_LOCATION:
- snapshot->location = g_strdup(g_value_get_string (value));
+ snapshot->location = g_strdup (g_value_get_string (value));
break;
case ARG_FRAME:
- snapshot->frame = g_value_get_long(value);
+ snapshot->frame = g_value_get_long (value);
break;
default:
break;
}
static void
-gst_snapshot_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_snapshot_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstSnapshot *snapshot;
- g_return_if_fail(GST_IS_SNAPSHOT(object));
- snapshot = GST_SNAPSHOT(object);
+ g_return_if_fail (GST_IS_SNAPSHOT (object));
+ snapshot = GST_SNAPSHOT (object);
switch (prop_id) {
case ARG_LOCATION:
- g_value_set_string(value, snapshot->location);
+ g_value_set_string (value, snapshot->location);
break;
case ARG_FRAME:
- g_value_set_long(value, snapshot->frame);
+ g_value_set_long (value, snapshot->frame);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- if (!gst_element_register (plugin, "snapshot", GST_RANK_NONE, GST_TYPE_SNAPSHOT))
+ if (!gst_element_register (plugin, "snapshot", GST_RANK_NONE,
+ GST_TYPE_SNAPSHOT))
return FALSE;
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "snapshot",
- "Dump a frame to a png file",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "snapshot",
+ "Dump a frame to a png file",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
#include <png.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_SNAPSHOT \
#define GST_IS_SNAPSHOT_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SNAPSHOT))
-typedef struct _GstSnapshot GstSnapshot;
-typedef struct _GstSnapshotClass GstSnapshotClass;
+ typedef struct _GstSnapshot GstSnapshot;
+ typedef struct _GstSnapshotClass GstSnapshotClass;
-struct _GstSnapshot {
- GstElement element;
+ struct _GstSnapshot
+ {
+ GstElement element;
- guint32 format;
- gint width;
- gint height;
- gint to_bpp;
- glong frame;
- glong cur_frame;
- const gchar *location;
- gboolean snapshot_asked;
+ guint32 format;
+ gint width;
+ gint height;
+ gint to_bpp;
+ glong frame;
+ glong cur_frame;
+ const gchar *location;
+ gboolean snapshot_asked;
- png_structp png_struct_ptr;
- png_infop png_info_ptr;
+ png_structp png_struct_ptr;
+ png_infop png_info_ptr;
- GstPad *sinkpad,*srcpad;
-};
+ GstPad *sinkpad, *srcpad;
+ };
-struct _GstSnapshotClass {
- GstElementClass parent_class;
+ struct _GstSnapshotClass
+ {
+ GstElementClass parent_class;
- void (*snapshot) (GstElement *elem);
-};
+ void (*snapshot) (GstElement * elem);
+ };
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_SNAPSHOT_H__ */
+#endif /* __GST_SNAPSHOT_H__ */
"Andy Wingo <wingo at pobox dot com>",
};
-enum {
+enum
+{
ARG_0,
ARG_LOCATION,
ARG_MAJOR_TYPE,
ARG_CREATE_PADS
};
-static GstStaticPadTemplate sf_src_factory =
-GST_STATIC_PAD_TEMPLATE (
- "src%d",
- GST_PAD_SRC,
- GST_PAD_REQUEST,
- GST_STATIC_CAPS (GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS)
-);
-
-static GstStaticPadTemplate sf_sink_factory =
-GST_STATIC_PAD_TEMPLATE (
- "sink%d",
- GST_PAD_SINK,
- GST_PAD_REQUEST,
- GST_STATIC_CAPS (GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS)
-);
+static GstStaticPadTemplate sf_src_factory = GST_STATIC_PAD_TEMPLATE ("src%d",
+ GST_PAD_SRC,
+ GST_PAD_REQUEST,
+ GST_STATIC_CAPS (GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS)
+ );
+
+static GstStaticPadTemplate sf_sink_factory = GST_STATIC_PAD_TEMPLATE ("sink%d",
+ GST_PAD_SINK,
+ GST_PAD_REQUEST,
+ GST_STATIC_CAPS (GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS)
+ );
#define GST_TYPE_SF_MAJOR_TYPES (gst_sf_major_types_get_type())
static GType
-gst_sf_major_types_get_type (void)
+gst_sf_major_types_get_type (void)
{
static GType sf_major_types_type = 0;
static GEnumValue *sf_major_types = NULL;
-
- if (!sf_major_types_type)
- {
+
+ if (!sf_major_types_type) {
SF_FORMAT_INFO format_info;
- int k, count ;
+ int k, count;
- sf_command (NULL, SFC_GET_FORMAT_MAJOR_COUNT, &count, sizeof (int)) ;
+ sf_command (NULL, SFC_GET_FORMAT_MAJOR_COUNT, &count, sizeof (int));
sf_major_types = g_new0 (GEnumValue, count + 1);
-
- for (k = 0 ; k < count ; k++) {
- format_info.format = k ;
- sf_command (NULL, SFC_GET_FORMAT_MAJOR, &format_info, sizeof (format_info));
+
+ for (k = 0; k < count; k++) {
+ format_info.format = k;
+ sf_command (NULL, SFC_GET_FORMAT_MAJOR, &format_info,
+ sizeof (format_info));
sf_major_types[k].value = format_info.format;
sf_major_types[k].value_name = g_strdup (format_info.name);
sf_major_types[k].value_nick = g_strdup (format_info.extension);
/* Irritatingly enough, there exist major_types with the same extension. Let's
just hope that sndfile gives us the list in alphabetical order, as it
currently does. */
- if (k > 0 && strcmp (sf_major_types[k].value_nick, sf_major_types[k-1].value_nick) == 0) {
- g_free (sf_major_types[k].value_nick);
- sf_major_types[k].value_nick = g_strconcat (sf_major_types[k-1].value_nick, "-",
- sf_major_types[k].value_name, NULL);
- g_strcanon (sf_major_types[k].value_nick,
- G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "-", '-');
+ if (k > 0
+ && strcmp (sf_major_types[k].value_nick,
+ sf_major_types[k - 1].value_nick) == 0) {
+ g_free (sf_major_types[k].value_nick);
+ sf_major_types[k].value_nick =
+ g_strconcat (sf_major_types[k - 1].value_nick, "-",
+ sf_major_types[k].value_name, NULL);
+ g_strcanon (sf_major_types[k].value_nick,
+ G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "-", '-');
}
}
- sf_major_types_type = g_enum_register_static ("GstSndfileMajorTypes", sf_major_types);
+ sf_major_types_type =
+ g_enum_register_static ("GstSndfileMajorTypes", sf_major_types);
}
return sf_major_types_type;
}
#define GST_TYPE_SF_MINOR_TYPES (gst_sf_minor_types_get_type())
static GType
-gst_sf_minor_types_get_type (void)
+gst_sf_minor_types_get_type (void)
{
static GType sf_minor_types_type = 0;
static GEnumValue *sf_minor_types = NULL;
-
- if (!sf_minor_types_type)
- {
+
+ if (!sf_minor_types_type) {
SF_FORMAT_INFO format_info;
- int k, count ;
+ int k, count;
- sf_command (NULL, SFC_GET_FORMAT_SUBTYPE_COUNT, &count, sizeof (int)) ;
+ sf_command (NULL, SFC_GET_FORMAT_SUBTYPE_COUNT, &count, sizeof (int));
sf_minor_types = g_new0 (GEnumValue, count + 1);
-
- for (k = 0 ; k < count ; k++) {
- format_info.format = k ;
- sf_command (NULL, SFC_GET_FORMAT_SUBTYPE, &format_info, sizeof (format_info));
+
+ for (k = 0; k < count; k++) {
+ format_info.format = k;
+ sf_command (NULL, SFC_GET_FORMAT_SUBTYPE, &format_info,
+ sizeof (format_info));
sf_minor_types[k].value = format_info.format;
sf_minor_types[k].value_name = g_strdup (format_info.name);
sf_minor_types[k].value_nick = g_ascii_strdown (format_info.name, -1);
- g_strcanon (sf_minor_types[k].value_nick, G_CSET_a_2_z G_CSET_DIGITS "-", '-');
+ g_strcanon (sf_minor_types[k].value_nick, G_CSET_a_2_z G_CSET_DIGITS "-",
+ '-');
}
- sf_minor_types_type = g_enum_register_static ("GstSndfileMinorTypes", sf_minor_types);
+ sf_minor_types_type =
+ g_enum_register_static ("GstSndfileMinorTypes", sf_minor_types);
}
return sf_minor_types_type;
}
-static void gst_sfsrc_base_init (gpointer g_class);
-static void gst_sfsink_base_init (gpointer g_class);
-static void gst_sf_class_init (GstSFClass *klass);
-static void gst_sf_init (GstSF *this);
-static void gst_sf_dispose (GObject *object);
-static void gst_sf_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_sf_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static void gst_sfsrc_base_init (gpointer g_class);
+static void gst_sfsink_base_init (gpointer g_class);
+static void gst_sf_class_init (GstSFClass * klass);
+static void gst_sf_init (GstSF * this);
+static void gst_sf_dispose (GObject * object);
+static void gst_sf_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_sf_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static GstClock* gst_sf_get_clock (GstElement *element);
-static void gst_sf_set_clock (GstElement *element, GstClock *clock);
-static GstPad* gst_sf_request_new_pad (GstElement *element, GstPadTemplate *templ,
- const gchar *unused);
-static void gst_sf_release_request_pad (GstElement *element, GstPad *pad);
-static GstElementStateReturn gst_sf_change_state (GstElement *element);
+static GstClock *gst_sf_get_clock (GstElement * element);
+static void gst_sf_set_clock (GstElement * element, GstClock * clock);
+static GstPad *gst_sf_request_new_pad (GstElement * element,
+ GstPadTemplate * templ, const gchar * unused);
+static void gst_sf_release_request_pad (GstElement * element, GstPad * pad);
+static GstElementStateReturn gst_sf_change_state (GstElement * element);
-static GstPadLinkReturn gst_sf_link (GstPad *pad, const GstCaps *caps);
+static GstPadLinkReturn gst_sf_link (GstPad * pad, const GstCaps * caps);
-static void gst_sf_loop (GstElement *element);
+static void gst_sf_loop (GstElement * element);
-static GstClockTime gst_sf_get_time (GstClock *clock, gpointer data);
+static GstClockTime gst_sf_get_time (GstClock * clock, gpointer data);
-static gboolean gst_sf_open_file (GstSF *this);
-static void gst_sf_close_file (GstSF *this);
+static gboolean gst_sf_open_file (GstSF * this);
+static void gst_sf_close_file (GstSF * this);
static GstElementClass *parent_class = NULL;
GST_CAT_LEVEL_LOG (gstsf_debug, GST_LEVEL_INFO, obj, __VA_ARGS__)
GType
-gst_sf_get_type (void)
+gst_sf_get_type (void)
{
static GType sf_type = 0;
if (!sf_type) {
static const GTypeInfo sf_info = {
- sizeof (GstSFClass), NULL,
+ sizeof (GstSFClass), NULL,
NULL,
- (GClassInitFunc)NULL, /* don't even initialize the class */
+ (GClassInitFunc) NULL, /* don't even initialize the class */
NULL,
NULL,
sizeof (GstSF),
0,
- (GInstanceInitFunc)NULL /* abstract base class */
+ (GInstanceInitFunc) NULL /* abstract base class */
};
sf_type = g_type_register_static (GST_TYPE_ELEMENT, "GstSF", &sf_info, 0);
}
}
GType
-gst_sfsrc_get_type (void)
+gst_sfsrc_get_type (void)
{
static GType sfsrc_type = 0;
0,
(GInstanceInitFunc) gst_sf_init,
};
- sfsrc_type = g_type_register_static (GST_TYPE_SF, "GstSFSrc", &sfsrc_info, 0);
+ sfsrc_type =
+ g_type_register_static (GST_TYPE_SF, "GstSFSrc", &sfsrc_info, 0);
}
return sfsrc_type;
}
GType
-gst_sfsink_get_type (void)
+gst_sfsink_get_type (void)
{
static GType sfsink_type = 0;
0,
(GInstanceInitFunc) gst_sf_init,
};
- sfsink_type = g_type_register_static (GST_TYPE_SF, "GstSFSink", &sfsink_info, 0);
+ sfsink_type =
+ g_type_register_static (GST_TYPE_SF, "GstSFSink", &sfsink_info, 0);
}
return sfsink_type;
}
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&sf_src_factory));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&sf_src_factory));
gst_element_class_set_details (element_class, &sfsrc_details);
}
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&sf_sink_factory));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&sf_sink_factory));
gst_element_class_set_details (element_class, &sfsink_details);
}
static void
-gst_sf_class_init (GstSFClass *klass)
+gst_sf_class_init (GstSFClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GParamSpec *pspec;
- gobject_class = (GObjectClass*)klass;
- gstelement_class = (GstElementClass*)klass;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
/* although this isn't really the parent class, that's ok; GstSF doesn't
override any methods */
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
gst_element_class_install_std_props (gstelement_class, "location",
- ARG_LOCATION, G_PARAM_READWRITE, NULL);
+ ARG_LOCATION, G_PARAM_READWRITE, NULL);
pspec = g_param_spec_enum
- ("major-type", "Major type", "Major output type", GST_TYPE_SF_MAJOR_TYPES,
- SF_FORMAT_WAV, G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
+ ("major-type", "Major type", "Major output type", GST_TYPE_SF_MAJOR_TYPES,
+ SF_FORMAT_WAV, G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
g_object_class_install_property (gobject_class, ARG_MAJOR_TYPE, pspec);
pspec = g_param_spec_enum
- ("minor-type", "Minor type", "Minor output type", GST_TYPE_SF_MINOR_TYPES,
- SF_FORMAT_FLOAT, G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
+ ("minor-type", "Minor type", "Minor output type", GST_TYPE_SF_MINOR_TYPES,
+ SF_FORMAT_FLOAT, G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
g_object_class_install_property (gobject_class, ARG_MINOR_TYPE, pspec);
if (G_TYPE_FROM_CLASS (klass) == GST_TYPE_SFSRC) {
pspec = g_param_spec_boolean ("loop", "Loop?", "Loop the output?",
- FALSE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
+ FALSE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
g_object_class_install_property (gobject_class, ARG_LOOP, pspec);
- pspec = g_param_spec_boolean ("create-pads", "Create pads?", "Create one pad for each channel in the sound file?",
- TRUE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
+ pspec =
+ g_param_spec_boolean ("create-pads", "Create pads?",
+ "Create one pad for each channel in the sound file?", TRUE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
g_object_class_install_property (gobject_class, ARG_CREATE_PADS, pspec);
}
-
+
gobject_class->dispose = gst_sf_dispose;
gobject_class->set_property = gst_sf_set_property;
gobject_class->get_property = gst_sf_get_property;
gstelement_class->release_pad = gst_sf_release_request_pad;
}
-static void
-gst_sf_init (GstSF *this)
+static void
+gst_sf_init (GstSF * this)
{
gst_element_set_loop_function (GST_ELEMENT (this), gst_sf_loop);
this->provided_clock = gst_audio_clock_new ("sfclock", gst_sf_get_time, this);
}
static void
-gst_sf_dispose (GObject *object)
+gst_sf_dispose (GObject * object)
{
- GstSF *this = (GstSF*)object;
+ GstSF *this = (GstSF *) object;
gst_object_unparent (GST_OBJECT (this->provided_clock));
}
static void
-gst_sf_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_sf_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstSF *this = GST_SF (object);
switch (prop_id) {
case ARG_LOCATION:
if (GST_FLAG_IS_SET (object, GST_SF_OPEN))
- gst_sf_close_file (this);
+ gst_sf_close_file (this);
if (this->filename)
g_free (this->filename);
if (g_value_get_string (value))
- this->filename = g_strdup (g_value_get_string (value));
+ this->filename = g_strdup (g_value_get_string (value));
else
- this->filename = NULL;
+ this->filename = NULL;
if (this->filename)
- gst_sf_open_file (this);
+ gst_sf_open_file (this);
break;
case ARG_MAJOR_TYPE:
case ARG_CREATE_PADS:
this->create_pads = g_value_get_boolean (value);
if (this->file && this->create_pads) {
- int i;
- for (i=g_list_length (this->channels); i<this->numchannels; i++)
- gst_element_get_request_pad ((GstElement*)this, "src%d");
+ int i;
+
+ for (i = g_list_length (this->channels); i < this->numchannels; i++)
+ gst_element_get_request_pad ((GstElement *) this, "src%d");
}
break;
}
}
-static void
-gst_sf_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+static void
+gst_sf_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstSF *this = GST_SF (object);
-
+
switch (prop_id) {
case ARG_LOCATION:
g_value_set_string (value, this->filename);
}
}
-static GstClock*
-gst_sf_get_clock (GstElement *element)
+static GstClock *
+gst_sf_get_clock (GstElement * element)
{
GstSF *this = GST_SF (element);
}
static void
-gst_sf_set_clock (GstElement *element, GstClock *clock)
+gst_sf_set_clock (GstElement * element, GstClock * clock)
{
GstSF *this = GST_SF (element);
-
+
this->clock = clock;
}
-static GstClockTime
-gst_sf_get_time (GstClock *clock, gpointer data)
+static GstClockTime
+gst_sf_get_time (GstClock * clock, gpointer data)
{
GstSF *this = GST_SF (data);
}
static GstElementStateReturn
-gst_sf_change_state (GstElement *element)
+gst_sf_change_state (GstElement * element)
{
GstSF *this = GST_SF (element);
gst_audio_clock_set_active (GST_AUDIO_CLOCK (this->provided_clock), TRUE);
break;
case GST_STATE_PLAYING_TO_PAUSED:
- gst_audio_clock_set_active (GST_AUDIO_CLOCK (this->provided_clock), FALSE);
+ gst_audio_clock_set_active (GST_AUDIO_CLOCK (this->provided_clock),
+ FALSE);
break;
case GST_STATE_PAUSED_TO_READY:
break;
case GST_STATE_READY_TO_NULL:
if (GST_FLAG_IS_SET (this, GST_SF_OPEN))
- gst_sf_close_file (this);
+ gst_sf_close_file (this);
break;
}
return GST_STATE_SUCCESS;
}
-static GstPad*
-gst_sf_request_new_pad (GstElement *element, GstPadTemplate *templ,
- const gchar *unused)
+static GstPad *
+gst_sf_request_new_pad (GstElement * element, GstPadTemplate * templ,
+ const gchar * unused)
{
gchar *name;
GstSF *this;
this = GST_SF (element);
channel = g_new0 (GstSFChannel, 1);
-
+
if (templ->direction == GST_PAD_SINK) {
/* we have an SFSink */
name = g_strdup_printf ("sink%d", this->channelcount);
/* we have an SFSrc */
name = g_strdup_printf ("src%d", this->channelcount);
}
-
+
channel->pad = gst_pad_new_from_template (templ, name);
gst_element_add_pad (GST_ELEMENT (this), channel->pad);
gst_pad_set_link_function (channel->pad, gst_sf_link);
-
+
this->channels = g_list_append (this->channels, channel);
this->channelcount++;
-
+
INFO_OBJ (element, "added pad %s\n", name);
g_free (name);
}
static void
-gst_sf_release_request_pad (GstElement *element, GstPad *pad)
+gst_sf_release_request_pad (GstElement * element, GstPad * pad)
{
GstSF *this;
GstSFChannel *channel = NULL;
GList *l;
this = GST_SF (element);
-
+
if (GST_STATE (element) == GST_STATE_PLAYING) {
- g_warning ("You can't release a request pad if the element is PLAYING, sorry.");
+ g_warning
+ ("You can't release a request pad if the element is PLAYING, sorry.");
return;
}
- for (l=this->channels; l; l=l->next) {
+ for (l = this->channels; l; l = l->next) {
if (GST_SF_CHANNEL (l)->pad == pad) {
channel = GST_SF_CHANNEL (l);
break;
}
static GstPadLinkReturn
-gst_sf_link (GstPad *pad, const GstCaps *caps)
+gst_sf_link (GstPad * pad, const GstCaps * caps)
{
- GstSF *this = (GstSF*)GST_OBJECT_PARENT (pad);
+ GstSF *this = (GstSF *) GST_OBJECT_PARENT (pad);
GstStructure *structure;
structure = gst_caps_get_structure (caps, 0);
-
- gst_structure_get_int (structure, "rate", &this->rate);
- gst_structure_get_int (structure, "buffer-frames", &this->buffer_frames);
+
+ gst_structure_get_int (structure, "rate", &this->rate);
+ gst_structure_get_int (structure, "buffer-frames", &this->buffer_frames);
INFO_OBJ (this, "linked pad %s:%s with fixed caps, rate=%d, frames=%d",
- GST_DEBUG_PAD_NAME (pad), this->rate, this->buffer_frames);
+ GST_DEBUG_PAD_NAME (pad), this->rate, this->buffer_frames);
if (this->numchannels) {
/* we can go ahead and allocate our buffer */
if (this->buffer)
g_free (this->buffer);
- this->buffer = g_malloc (this->numchannels * this->buffer_frames * sizeof (float));
- memset (this->buffer, 0, this->numchannels * this->buffer_frames * sizeof (float));
+ this->buffer =
+ g_malloc (this->numchannels * this->buffer_frames * sizeof (float));
+ memset (this->buffer, 0,
+ this->numchannels * this->buffer_frames * sizeof (float));
}
return GST_PAD_LINK_OK;
}
static gboolean
-gst_sf_open_file (GstSF *this)
+gst_sf_open_file (GstSF * this)
{
int mode;
SF_INFO info;
-
+
g_return_val_if_fail (!GST_FLAG_IS_SET (this, GST_SF_OPEN), FALSE);
this->time = 0;
if (!this->filename) {
GST_ELEMENT_ERROR (this, RESOURCE, NOT_FOUND,
- (_("No filename specified.")),
- (NULL));
+ (_("No filename specified.")), (NULL));
return FALSE;
}
-
+
if (GST_IS_SFSRC (this)) {
mode = SFM_READ;
info.format = 0;
} else {
if (!this->rate) {
- INFO_OBJ (this, "Not opening %s yet because caps are not set", this->filename);
+ INFO_OBJ (this, "Not opening %s yet because caps are not set",
+ this->filename);
return FALSE;
} else if (!this->numchannels) {
- INFO_OBJ (this, "Not opening %s yet because we have no input channels", this->filename);
+ INFO_OBJ (this, "Not opening %s yet because we have no input channels",
+ this->filename);
return FALSE;
}
info.format = this->format;
INFO_OBJ (this, "Opening %s with rate %d, %d channels, format 0x%x",
- this->filename, info.samplerate, info.channels, info.format);
+ this->filename, info.samplerate, info.channels, info.format);
if (!sf_format_check (&info)) {
GST_ELEMENT_ERROR (this, STREAM, ENCODE, (NULL),
- ("Input parameters (rate:%d, channels:%d, format:0x%x) invalid",
- info.samplerate, info.channels, info.format));
+ ("Input parameters (rate:%d, channels:%d, format:0x%x) invalid",
+ info.samplerate, info.channels, info.format));
return FALSE;
}
}
if (!this->file) {
GST_ELEMENT_ERROR (this, RESOURCE, OPEN_WRITE,
- (_("Could not open file \"%s\" for writing."), this->filename),
- ("soundfile error: %s", sf_strerror (NULL)));
+ (_("Could not open file \"%s\" for writing."), this->filename),
+ ("soundfile error: %s", sf_strerror (NULL)));
return FALSE;
}
if (GST_IS_SFSRC (this)) {
GList *l = NULL;
+
/* the number of channels in the file can be different than the number of
* pads */
this->numchannels = info.channels;
if (this->create_pads) {
int i;
- for (i=g_list_length (this->channels); i<this->numchannels; i++)
- gst_element_get_request_pad ((GstElement*)this, "src%d");
+
+ for (i = g_list_length (this->channels); i < this->numchannels; i++)
+ gst_element_get_request_pad ((GstElement *) this, "src%d");
}
-
- for (l=this->channels; l; l=l->next)
+
+ for (l = this->channels; l; l = l->next)
/* queue the need to set caps */
GST_SF_CHANNEL (l)->caps_set = FALSE;
}
}
static void
-gst_sf_close_file (GstSF *this)
+gst_sf_close_file (GstSF * this)
{
int err = 0;
if ((err = sf_close (this->file)))
GST_ELEMENT_ERROR (this, RESOURCE, CLOSE,
- ("Could not close file file \"%s\".", this->filename),
- ("soundfile error: %s", strerror (err)));
+ ("Could not close file file \"%s\".", this->filename),
+ ("soundfile error: %s", strerror (err)));
else
GST_FLAG_UNSET (this, GST_SF_OPEN);
this->buffer = NULL;
}
-static void
-gst_sf_loop (GstElement *element)
+static void
+gst_sf_loop (GstElement * element)
{
GstSF *this;
GList *l = NULL;
- this = (GstSF*)element;
-
+ this = (GstSF *) element;
+
if (this->channels == NULL) {
- GST_ELEMENT_ERROR (element, CORE, PAD, (NULL), ("You must connect at least one pad to sndfile elements."));
+ GST_ELEMENT_ERROR (element, CORE, PAD, (NULL),
+ ("You must connect at least one pad to sndfile elements."));
return;
}
if (!GST_FLAG_IS_SET (this, GST_SF_OPEN))
if (!gst_sf_open_file (this))
- return; /* we've already set gst_element_error */
+ return; /* we've already set gst_element_error */
if (buffer_frames == 0) {
/* we have to set the caps later */
buffer_frames = this->buffer_frames = 1024;
}
if (buf == NULL) {
- buf = this->buffer = g_malloc (this->numchannels * this->buffer_frames * sizeof (float));
- memset (this->buffer, 0, this->numchannels * this->buffer_frames * sizeof (float));
+ buf = this->buffer =
+ g_malloc (this->numchannels * this->buffer_frames * sizeof (float));
+ memset (this->buffer, 0,
+ this->numchannels * this->buffer_frames * sizeof (float));
}
read = sf_readf_float (this->file, buf, buffer_frames);
eos = 1;
if (read)
- for (i=0,l=this->channels; l; l=l->next,i++) {
- channel = GST_SF_CHANNEL (l);
-
- /* don't push on disconnected pads -- useful for ::create-pads=TRUE*/
- if (!GST_PAD_PEER (channel->pad))
- continue;
-
- if (!channel->caps_set) {
- GstCaps *caps = gst_caps_copy (GST_PAD_CAPS (GST_SF_CHANNEL (l)->pad));
- if (!caps)
- caps = gst_caps_copy
- (GST_PAD_TEMPLATE_CAPS (GST_PAD_PAD_TEMPLATE (GST_SF_CHANNEL (l)->pad)));
- gst_caps_set_simple (caps,
- "rate", G_TYPE_INT, this->rate,
- "buffer-frames", G_TYPE_INT, this->buffer_frames,
- NULL);
- if (!gst_pad_try_set_caps (GST_SF_CHANNEL (l)->pad, caps)) {
- GST_ELEMENT_ERROR (this, CORE, NEGOTIATION, (NULL),
- ("Opened file with sample rate %d, but could not set caps", this->rate));
- gst_sf_close_file (this);
- return;
- }
- channel->caps_set = TRUE;
- }
-
- out = gst_buffer_new_and_alloc (read * sizeof(float));
- data = (gfloat*)GST_BUFFER_DATA (out);
- for (j=0; j<read; j++)
- data[j] = buf[j * nchannels + i % nchannels];
- gst_pad_push (channel->pad, GST_DATA (out));
+ for (i = 0, l = this->channels; l; l = l->next, i++) {
+ channel = GST_SF_CHANNEL (l);
+
+ /* don't push on disconnected pads -- useful for ::create-pads=TRUE */
+ if (!GST_PAD_PEER (channel->pad))
+ continue;
+
+ if (!channel->caps_set) {
+ GstCaps *caps =
+ gst_caps_copy (GST_PAD_CAPS (GST_SF_CHANNEL (l)->pad));
+ if (!caps)
+ caps = gst_caps_copy
+ (GST_PAD_TEMPLATE_CAPS (GST_PAD_PAD_TEMPLATE (GST_SF_CHANNEL
+ (l)->pad)));
+ gst_caps_set_simple (caps, "rate", G_TYPE_INT, this->rate,
+ "buffer-frames", G_TYPE_INT, this->buffer_frames, NULL);
+ if (!gst_pad_try_set_caps (GST_SF_CHANNEL (l)->pad, caps)) {
+ GST_ELEMENT_ERROR (this, CORE, NEGOTIATION, (NULL),
+ ("Opened file with sample rate %d, but could not set caps",
+ this->rate));
+ gst_sf_close_file (this);
+ return;
+ }
+ channel->caps_set = TRUE;
+ }
+
+ out = gst_buffer_new_and_alloc (read * sizeof (float));
+ data = (gfloat *) GST_BUFFER_DATA (out);
+ for (j = 0; j < read; j++)
+ data[j] = buf[j * nchannels + i % nchannels];
+ gst_pad_push (channel->pad, GST_DATA (out));
}
this->time += read * (GST_SECOND / this->rate);
- gst_audio_clock_update_time ((GstAudioClock*)this->provided_clock, this->time);
+ gst_audio_clock_update_time ((GstAudioClock *) this->provided_clock,
+ this->time);
if (eos) {
if (this->loop) {
- sf_seek (this->file, (sf_count_t)0, SEEK_SET);
- eos = 0;
+ sf_seek (this->file, (sf_count_t) 0, SEEK_SET);
+ eos = 0;
} else {
- for (l=this->channels; l; l=l->next)
- gst_pad_push (GST_SF_CHANNEL (l)->pad, GST_DATA (gst_event_new (GST_EVENT_EOS)));
- gst_element_set_eos (element);
+ for (l = this->channels; l; l = l->next)
+ gst_pad_push (GST_SF_CHANNEL (l)->pad,
+ GST_DATA (gst_event_new (GST_EVENT_EOS)));
+ gst_element_set_eos (element);
}
}
} else {
num_to_write = buffer_frames;
- INFO_OBJ (this, "looping, buffer_frames=%d, nchannels=%d", buffer_frames, nchannels);
+ INFO_OBJ (this, "looping, buffer_frames=%d, nchannels=%d", buffer_frames,
+ nchannels);
- for (i=0,l=this->channels; l; l=l->next,i++) {
+ for (i = 0, l = this->channels; l; l = l->next, i++) {
channel = GST_SF_CHANNEL (l);
-
+
pull_again:
in = GST_BUFFER (gst_pad_pull (channel->pad));
if (buffer_frames == 0) {
- /* pulling a buffer from the pad should have caused capsnego to occur,
- which then would set this->buffer_frames to a new value */
- buffer_frames = this->buffer_frames;
- if (buffer_frames == 0) {
- GST_ELEMENT_ERROR (element, CORE, NEGOTIATION, (NULL),
- ("format wasn't negotiated before chain function"));
- return;
- }
- buf = this->buffer;
- num_to_write = buffer_frames;
+ /* pulling a buffer from the pad should have caused capsnego to occur,
+ which then would set this->buffer_frames to a new value */
+ buffer_frames = this->buffer_frames;
+ if (buffer_frames == 0) {
+ GST_ELEMENT_ERROR (element, CORE, NEGOTIATION, (NULL),
+ ("format wasn't negotiated before chain function"));
+ return;
+ }
+ buf = this->buffer;
+ num_to_write = buffer_frames;
}
if (!GST_FLAG_IS_SET (this, GST_SF_OPEN))
- if (!gst_sf_open_file (this))
- return; /* we've already set gst_element_error */
+ if (!gst_sf_open_file (this))
+ return; /* we've already set gst_element_error */
if (GST_IS_EVENT (in)) {
- switch (GST_EVENT_TYPE (in)) {
- case GST_EVENT_EOS:
- case GST_EVENT_INTERRUPT:
- num_to_write = 0;
- break;
- default:
- goto pull_again;
- break;
- }
+ switch (GST_EVENT_TYPE (in)) {
+ case GST_EVENT_EOS:
+ case GST_EVENT_INTERRUPT:
+ num_to_write = 0;
+ break;
+ default:
+ goto pull_again;
+ break;
+ }
}
-
+
if (num_to_write) {
- data = (gfloat*)GST_BUFFER_DATA (in);
- num_to_write = MIN (num_to_write, GST_BUFFER_SIZE (in) / sizeof (gfloat));
- for (j=0; j<num_to_write; j++)
- buf[j * nchannels + i % nchannels] = data[j];
+ data = (gfloat *) GST_BUFFER_DATA (in);
+ num_to_write =
+ MIN (num_to_write, GST_BUFFER_SIZE (in) / sizeof (gfloat));
+ for (j = 0; j < num_to_write; j++)
+ buf[j * nchannels + i % nchannels] = data[j];
}
- gst_data_unref ((GstData*)in);
+ gst_data_unref ((GstData *) in);
}
if (num_to_write) {
written = sf_writef_float (this->file, buf, num_to_write);
if (written != num_to_write)
- GST_ELEMENT_ERROR (element, RESOURCE, WRITE,
- (_("Could not write to file \"%s\"."), this->filename),
- ("soundfile error: %s", sf_strerror (this->file)));
+ GST_ELEMENT_ERROR (element, RESOURCE, WRITE,
+ (_("Could not write to file \"%s\"."), this->filename),
+ ("soundfile error: %s", sf_strerror (this->file)));
}
this->time += num_to_write * (GST_SECOND / this->rate);
- gst_audio_clock_update_time ((GstAudioClock*)this->provided_clock, this->time);
+ gst_audio_clock_update_time ((GstAudioClock *) this->provided_clock,
+ this->time);
if (num_to_write != buffer_frames)
gst_element_set_eos (element);
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
if (!gst_library_load ("gstaudio"))
return FALSE;
GST_DEBUG_CATEGORY_INIT (gstsf_debug, "sf",
- GST_DEBUG_FG_WHITE | GST_DEBUG_BG_GREEN | GST_DEBUG_BOLD,
- "libsndfile plugin");
+ GST_DEBUG_FG_WHITE | GST_DEBUG_BG_GREEN | GST_DEBUG_BOLD,
+ "libsndfile plugin");
if (!gst_element_register (plugin, "sfsrc", GST_RANK_NONE, GST_TYPE_SFSRC))
return FALSE;
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "gstsf",
- "Sndfile plugin library",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "gstsf",
+ "Sndfile plugin library",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
G_BEGIN_DECLS
-
-
#define GST_TYPE_SF \
(gst_sf_get_type())
#define GST_SF(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SF))
#define GST_IS_SF_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SF))
-
#define GST_TYPE_SFSRC \
(gst_sfsrc_get_type())
#define GST_SFSRC(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SFSRC))
#define GST_IS_SFSRC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SFSRC))
-
#define GST_TYPE_SFSINK \
(gst_sfsink_get_type())
#define GST_SFSINK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SFSINK))
#define GST_IS_SFSINK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SFSINK))
-
typedef struct _GstSF GstSF;
typedef struct _GstSFClass GstSFClass;
-typedef enum {
- GST_SF_OPEN = GST_ELEMENT_FLAG_LAST,
- GST_SF_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
+typedef enum
+{
+ GST_SF_OPEN = GST_ELEMENT_FLAG_LAST,
+ GST_SF_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
} GstSFlags;
-typedef struct {
+typedef struct
+{
GstPad *pad;
gint num;
gboolean caps_set;
#define GST_SF_CHANNEL(l) ((GstSFChannel*)l->data)
-struct _GstSF {
+struct _GstSF
+{
GstElement element;
GList *channels;
guint64 time;
};
-struct _GstSFClass {
+struct _GstSFClass
+{
GstElementClass parent_class;
};
-GType gst_sf_get_type (void);
-GType gst_sfsrc_get_type (void);
-GType gst_sfsink_get_type (void);
+GType gst_sf_get_type (void);
+GType gst_sfsrc_get_type (void);
+GType gst_sfsink_get_type (void);
G_END_DECLS
-
-
#endif /* __GST_SFSINK_H__ */
#include <gst/video/video.h>
/* elementfactory information */
-static GstElementDetails gst_swfdec_details = GST_ELEMENT_DETAILS (
- "SWF video decoder",
- "Codec/Decoder/Video",
- "Uses libswfdec to decode Flash video streams",
- "David Schleef <ds@schleef.org>"
-);
+static GstElementDetails gst_swfdec_details =
+GST_ELEMENT_DETAILS ("SWF video decoder",
+ "Codec/Decoder/Video",
+ "Uses libswfdec to decode Flash video streams",
+ "David Schleef <ds@schleef.org>");
/* Swfdec signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
/* FILL ME */
};
static GstStaticPadTemplate video_template_factory =
-GST_STATIC_PAD_TEMPLATE (
- "video_00",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (GST_VIDEO_CAPS_BGRx)
-);
+GST_STATIC_PAD_TEMPLATE ("video_00",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_BGRx)
+ );
static GstStaticPadTemplate audio_template_factory =
-GST_STATIC_PAD_TEMPLATE (
- "audio_00",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-raw-int, "
- "rate = (int) 44100, "
- "channels = (int) 2, "
- "endianness = (int) BYTE_ORDER, "
- "width = (int) 16, "
- "depth = (int) 16, "
- "signed = (boolean) true, "
- "buffer-frames = (int) [ 1, MAX ]")
-);
+GST_STATIC_PAD_TEMPLATE ("audio_00",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "rate = (int) 44100, "
+ "channels = (int) 2, "
+ "endianness = (int) BYTE_ORDER, "
+ "width = (int) 16, "
+ "depth = (int) 16, "
+ "signed = (boolean) true, " "buffer-frames = (int) [ 1, MAX ]")
+ );
static GstStaticPadTemplate sink_template_factory =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ( "application/x-shockwave-flash")
-);
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("application/x-shockwave-flash")
+ );
-static void gst_swfdec_base_init (gpointer g_class);
-static void gst_swfdec_class_init (GstSwfdecClass *klass);
-static void gst_swfdec_init (GstSwfdec *swfdec);
+static void gst_swfdec_base_init (gpointer g_class);
+static void gst_swfdec_class_init (GstSwfdecClass * klass);
+static void gst_swfdec_init (GstSwfdec * swfdec);
-static void gst_swfdec_dispose (GObject *object);
+static void gst_swfdec_dispose (GObject * object);
-static void gst_swfdec_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_swfdec_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static void gst_swfdec_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_swfdec_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
#if 0
-static gboolean gst_swfdec_src_event (GstPad *pad, GstEvent *event);
+static gboolean gst_swfdec_src_event (GstPad * pad, GstEvent * event);
#endif
-static gboolean gst_swfdec_src_query (GstPad *pad, GstQueryType type,
- GstFormat *format, gint64 *value);
+static gboolean gst_swfdec_src_query (GstPad * pad, GstQueryType type,
+ GstFormat * format, gint64 * value);
#if 0
-static gboolean gst_swfdec_convert_sink (GstPad *pad, GstFormat src_format, gint64 src_value,
- GstFormat *dest_format, gint64 *dest_value);
-static gboolean gst_swfdec_convert_src (GstPad *pad, GstFormat src_format, gint64 src_value,
- GstFormat *dest_format, gint64 *dest_value);
+static gboolean gst_swfdec_convert_sink (GstPad * pad, GstFormat src_format,
+ gint64 src_value, GstFormat * dest_format, gint64 * dest_value);
+static gboolean gst_swfdec_convert_src (GstPad * pad, GstFormat src_format,
+ gint64 src_value, GstFormat * dest_format, gint64 * dest_value);
#endif
-static GstElementStateReturn gst_swfdec_change_state (GstElement *element);
+static GstElementStateReturn gst_swfdec_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
if (!swfdec_type) {
static const GTypeInfo swfdec_info = {
- sizeof(GstSwfdecClass),
+ sizeof (GstSwfdecClass),
gst_swfdec_base_init,
NULL,
- (GClassInitFunc)gst_swfdec_class_init,
+ (GClassInitFunc) gst_swfdec_class_init,
NULL,
NULL,
- sizeof(GstSwfdec),
+ sizeof (GstSwfdec),
0,
- (GInstanceInitFunc)gst_swfdec_init,
+ (GInstanceInitFunc) gst_swfdec_init,
};
- swfdec_type = g_type_register_static(GST_TYPE_ELEMENT, "GstSwfdec", &swfdec_info, 0);
+ swfdec_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstSwfdec", &swfdec_info, 0);
}
return swfdec_type;
}
static void
-gst_swfdec_base_init(gpointer g_class)
+gst_swfdec_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_set_details (element_class, &gst_swfdec_details);
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&video_template_factory));
+ gst_static_pad_template_get (&video_template_factory));
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&audio_template_factory));
+ gst_static_pad_template_get (&audio_template_factory));
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&sink_template_factory));
+ gst_static_pad_template_get (&sink_template_factory));
}
static void
-gst_swfdec_class_init(GstSwfdecClass *klass)
+gst_swfdec_class_init (GstSwfdecClass * 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);
- gobject_class->set_property = gst_swfdec_set_property;
- gobject_class->get_property = gst_swfdec_get_property;
- gobject_class->dispose = gst_swfdec_dispose;
+ gobject_class->set_property = gst_swfdec_set_property;
+ gobject_class->get_property = gst_swfdec_get_property;
+ gobject_class->dispose = gst_swfdec_dispose;
gstelement_class->change_state = gst_swfdec_change_state;
}
static GstCaps *
-gst_swfdec_video_getcaps (GstPad *pad)
+gst_swfdec_video_getcaps (GstPad * pad)
{
GstSwfdec *swfdec;
GstCaps *caps;
caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
if (swfdec->have_format) {
gst_caps_set_simple (caps,
- "framerate", G_TYPE_DOUBLE, swfdec->frame_rate,
- NULL);
+ "framerate", G_TYPE_DOUBLE, swfdec->frame_rate, NULL);
}
return caps;
}
static GstPadLinkReturn
-gst_swfdec_video_link (GstPad *pad, const GstCaps *caps)
+gst_swfdec_video_link (GstPad * pad, const GstCaps * caps)
{
GstSwfdec *swfdec;
GstStructure *structure;
{
guint8 *d = dest;
guint8 *s = src;
- int x,y;
+ int x, y;
- for(y=0;y<height;y++){
- for(x=0;x<width;x++){
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++) {
d[0] = s[2];
d[1] = s[1];
d[2] = s[0];
d[3] = 0;
- d+=4;
- s+=3;
+ d += 4;
+ s += 3;
}
}
-
+
}
static void
-gst_swfdec_loop(GstElement *element)
+gst_swfdec_loop (GstElement * element)
{
- GstSwfdec *swfdec;
- GstBuffer *buf = NULL;
- int ret;
+ GstSwfdec *swfdec;
+ GstBuffer *buf = NULL;
+ int ret;
- g_return_if_fail(element != NULL);
- g_return_if_fail(GST_IS_SWFDEC(element));
+ g_return_if_fail (element != NULL);
+ g_return_if_fail (GST_IS_SWFDEC (element));
- swfdec = GST_SWFDEC(element);
+ swfdec = GST_SWFDEC (element);
- if(!swfdec->videopad){
- }
+ if (!swfdec->videopad) {
+ }
- ret = swfdec_decoder_parse(swfdec->state);
- if(ret==SWF_NEEDBITS){
- buf = GST_BUFFER (gst_pad_pull(swfdec->sinkpad));
- if(GST_IS_EVENT(buf)){
- switch (GST_EVENT_TYPE (buf)) {
- case GST_EVENT_EOS:
- GST_DEBUG("got eos");
- break;
- default:
- GST_DEBUG("got event");
- break;
- }
-
- }else{
- if(!GST_BUFFER_DATA(buf)){
- GST_DEBUG("expected non-null buffer");
- }
- ret = swfdec_decoder_addbits(swfdec->state,
- GST_BUFFER_DATA(buf), GST_BUFFER_SIZE(buf));
- }
- }
+ ret = swfdec_decoder_parse (swfdec->state);
+ if (ret == SWF_NEEDBITS) {
+ buf = GST_BUFFER (gst_pad_pull (swfdec->sinkpad));
+ if (GST_IS_EVENT (buf)) {
+ switch (GST_EVENT_TYPE (buf)) {
+ case GST_EVENT_EOS:
+ GST_DEBUG ("got eos");
+ break;
+ default:
+ GST_DEBUG ("got event");
+ break;
+ }
- if(ret==SWF_CHANGE){
- GstCaps *caps;
- GstPadLinkReturn link_ret;
-
- swfdec_decoder_get_image_size(swfdec->state,
- &swfdec->width, &swfdec->height);
- swfdec_decoder_get_rate(swfdec->state, &swfdec->rate);
- swfdec->interval = GST_SECOND / swfdec->rate;
-
- caps = gst_caps_copy (gst_pad_get_pad_template_caps (
- swfdec->videopad));
- swfdec_decoder_get_rate (swfdec->state, &swfdec->frame_rate);
- gst_caps_set_simple (caps,
- "framerate", G_TYPE_DOUBLE, swfdec->frame_rate,
- "height",G_TYPE_INT,swfdec->height,
- "width",G_TYPE_INT,swfdec->width,
- NULL);
- link_ret = gst_pad_try_set_caps (swfdec->videopad, caps);
- if (GST_PAD_LINK_SUCCESSFUL (link_ret)){
- /* good */
- } else {
- GST_ELEMENT_ERROR (swfdec, CORE, NEGOTIATION, (NULL), (NULL));
- return;
- }
- swfdec->have_format = TRUE;
-
- return;
- }
+ } else {
+ if (!GST_BUFFER_DATA (buf)) {
+ GST_DEBUG ("expected non-null buffer");
+ }
+ ret = swfdec_decoder_addbits (swfdec->state,
+ GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
+ }
+ }
- if(ret==SWF_IMAGE){
- GstBuffer *newbuf = NULL;
- unsigned char *data;
- int len;
+ if (ret == SWF_CHANGE) {
+ GstCaps *caps;
+ GstPadLinkReturn link_ret;
- /* video stuff */
- //newbuf = gst_buffer_new();
- //GST_BUFFER_SIZE(newbuf) = swfdec->width * swfdec->height * 3;
+ swfdec_decoder_get_image_size (swfdec->state,
+ &swfdec->width, &swfdec->height);
+ swfdec_decoder_get_rate (swfdec->state, &swfdec->rate);
+ swfdec->interval = GST_SECOND / swfdec->rate;
- newbuf = gst_pad_alloc_buffer (swfdec->videopad, GST_BUFFER_OFFSET_NONE,
- swfdec->width * 4 * swfdec->height);
+ caps = gst_caps_copy (gst_pad_get_pad_template_caps (swfdec->videopad));
+ swfdec_decoder_get_rate (swfdec->state, &swfdec->frame_rate);
+ gst_caps_set_simple (caps,
+ "framerate", G_TYPE_DOUBLE, swfdec->frame_rate,
+ "height", G_TYPE_INT, swfdec->height,
+ "width", G_TYPE_INT, swfdec->width, NULL);
+ link_ret = gst_pad_try_set_caps (swfdec->videopad, caps);
+ if (GST_PAD_LINK_SUCCESSFUL (link_ret)) {
+ /* good */
+ } else {
+ GST_ELEMENT_ERROR (swfdec, CORE, NEGOTIATION, (NULL), (NULL));
+ return;
+ }
+ swfdec->have_format = TRUE;
- swfdec_decoder_get_image(swfdec->state, &data);
- copy_image (GST_BUFFER_DATA (newbuf), data, swfdec->width,
- swfdec->height);
- free (data);
- //GST_BUFFER_DATA(newbuf) = data;
+ return;
+ }
- swfdec->timestamp += swfdec->interval;
- GST_BUFFER_TIMESTAMP(newbuf) = swfdec->timestamp;
+ if (ret == SWF_IMAGE) {
+ GstBuffer *newbuf = NULL;
+ unsigned char *data;
+ int len;
- gst_pad_push(swfdec->videopad, GST_DATA (newbuf));
+ /* video stuff */
+ //newbuf = gst_buffer_new();
+ //GST_BUFFER_SIZE(newbuf) = swfdec->width * swfdec->height * 3;
- /* audio stuff */
+ newbuf = gst_pad_alloc_buffer (swfdec->videopad, GST_BUFFER_OFFSET_NONE,
+ swfdec->width * 4 * swfdec->height);
- data = swfdec_decoder_get_sound_chunk(swfdec->state, &len);
- while(data){
- newbuf = gst_buffer_new();
+ swfdec_decoder_get_image (swfdec->state, &data);
+ copy_image (GST_BUFFER_DATA (newbuf), data, swfdec->width, swfdec->height);
+ free (data);
+ //GST_BUFFER_DATA(newbuf) = data;
- GST_BUFFER_SIZE(newbuf) = len;
- GST_BUFFER_DATA(newbuf) = data;
- GST_BUFFER_TIMESTAMP(newbuf) = swfdec->timestamp;
+ swfdec->timestamp += swfdec->interval;
+ GST_BUFFER_TIMESTAMP (newbuf) = swfdec->timestamp;
- gst_pad_push(swfdec->audiopad, GST_DATA (newbuf));
+ gst_pad_push (swfdec->videopad, GST_DATA (newbuf));
- data = swfdec_decoder_get_sound_chunk(swfdec->state, &len);
- }
- }
+ /* audio stuff */
- if(ret==SWF_EOF){
- gst_pad_push(swfdec->videopad, GST_DATA (gst_event_new (GST_EVENT_EOS)));
- gst_pad_push(swfdec->audiopad, GST_DATA (gst_event_new (GST_EVENT_EOS)));
- }
+ data = swfdec_decoder_get_sound_chunk (swfdec->state, &len);
+ while (data) {
+ newbuf = gst_buffer_new ();
+
+ GST_BUFFER_SIZE (newbuf) = len;
+ GST_BUFFER_DATA (newbuf) = data;
+ GST_BUFFER_TIMESTAMP (newbuf) = swfdec->timestamp;
+
+ gst_pad_push (swfdec->audiopad, GST_DATA (newbuf));
+
+ data = swfdec_decoder_get_sound_chunk (swfdec->state, &len);
+ }
+ }
+
+ if (ret == SWF_EOF) {
+ gst_pad_push (swfdec->videopad, GST_DATA (gst_event_new (GST_EVENT_EOS)));
+ gst_pad_push (swfdec->audiopad, GST_DATA (gst_event_new (GST_EVENT_EOS)));
+ }
}
static void
-gst_swfdec_init (GstSwfdec *swfdec)
+gst_swfdec_init (GstSwfdec * swfdec)
{
/* create the sink and src pads */
- swfdec->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&sink_template_factory), "sink");
+ swfdec->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&sink_template_factory), "sink");
gst_element_add_pad (GST_ELEMENT (swfdec), swfdec->sinkpad);
- swfdec->videopad = gst_pad_new_from_template(
- gst_static_pad_template_get (&video_template_factory),
- "video_00");
+ swfdec->videopad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&video_template_factory), "video_00");
gst_pad_set_query_function (swfdec->videopad,
- GST_DEBUG_FUNCPTR (gst_swfdec_src_query));
+ GST_DEBUG_FUNCPTR (gst_swfdec_src_query));
gst_pad_set_getcaps_function (swfdec->videopad, gst_swfdec_video_getcaps);
gst_pad_set_link_function (swfdec->videopad, gst_swfdec_video_link);
- gst_element_add_pad(GST_ELEMENT(swfdec), swfdec->videopad);
+ gst_element_add_pad (GST_ELEMENT (swfdec), swfdec->videopad);
- swfdec->audiopad = gst_pad_new_from_template(
- gst_static_pad_template_get (&audio_template_factory),
- "audio_00");
+ swfdec->audiopad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&audio_template_factory), "audio_00");
gst_pad_set_query_function (swfdec->audiopad,
- GST_DEBUG_FUNCPTR (gst_swfdec_src_query));
+ GST_DEBUG_FUNCPTR (gst_swfdec_src_query));
+
+ gst_element_add_pad (GST_ELEMENT (swfdec), swfdec->audiopad);
- gst_element_add_pad(GST_ELEMENT(swfdec), swfdec->audiopad);
-
- gst_element_set_loop_function(GST_ELEMENT(swfdec), gst_swfdec_loop);
+ gst_element_set_loop_function (GST_ELEMENT (swfdec), gst_swfdec_loop);
/* initialize the swfdec decoder state */
- swfdec->state = swfdec_decoder_new();
- g_return_if_fail(swfdec->state != NULL);
+ swfdec->state = swfdec_decoder_new ();
+ g_return_if_fail (swfdec->state != NULL);
- swfdec_decoder_set_colorspace(swfdec->state, SWF_COLORSPACE_RGB888);
+ swfdec_decoder_set_colorspace (swfdec->state, SWF_COLORSPACE_RGB888);
GST_FLAG_SET (GST_ELEMENT (swfdec), GST_ELEMENT_EVENT_AWARE);
}
static void
-gst_swfdec_dispose (GObject *object)
+gst_swfdec_dispose (GObject * object)
{
//GstSwfdec *swfdec = GST_SWFDEC (object);
#if 0
static gboolean
-gst_swfdec_convert_sink (GstPad *pad, GstFormat src_format, gint64 src_value,
- GstFormat *dest_format, gint64 *dest_value)
+gst_swfdec_convert_sink (GstPad * pad, GstFormat src_format, gint64 src_value,
+ GstFormat * dest_format, gint64 * dest_value)
{
gboolean res = TRUE;
GstSwfdec *swfdec;
-
+
swfdec = GST_SWFDEC (gst_pad_get_parent (pad));
switch (src_format) {
case GST_FORMAT_BYTES:
switch (*dest_format) {
- case GST_FORMAT_TIME:
- default:
- res = FALSE;
+ case GST_FORMAT_TIME:
+ default:
+ res = FALSE;
}
break;
case GST_FORMAT_TIME:
switch (*dest_format) {
- case GST_FORMAT_BYTES:
- default:
- res = FALSE;
+ case GST_FORMAT_BYTES:
+ default:
+ res = FALSE;
}
break;
default:
#if 0
static gboolean
-gst_swfdec_convert_src (GstPad *pad, GstFormat src_format, gint64 src_value,
- GstFormat *dest_format, gint64 *dest_value)
+gst_swfdec_convert_src (GstPad * pad, GstFormat src_format, gint64 src_value,
+ GstFormat * dest_format, gint64 * dest_value)
{
gboolean res = TRUE;
GstSwfdec *swfdec;
-
+
swfdec = GST_SWFDEC (gst_pad_get_parent (pad));
switch (src_format) {
case GST_FORMAT_BYTES:
switch (*dest_format) {
- case GST_FORMAT_TIME:
- default:
- res = FALSE;
+ case GST_FORMAT_TIME:
+ default:
+ res = FALSE;
}
break;
case GST_FORMAT_TIME:
switch (*dest_format) {
- case GST_FORMAT_BYTES:
- *dest_value = src_value * 6 * (swfdec->width * swfdec->height >> 2) *
- video_rates[swfdec->decoder->frame_rate_code] / GST_SECOND;
+ case GST_FORMAT_BYTES:
+ *dest_value = src_value * 6 * (swfdec->width * swfdec->height >> 2) *
+ video_rates[swfdec->decoder->frame_rate_code] / GST_SECOND;
break;
- case GST_FORMAT_DEFAULT:
- *dest_value = src_value * video_rates[swfdec->decoder->frame_rate_code] / GST_SECOND;
+ case GST_FORMAT_DEFAULT:
+ *dest_value =
+ src_value * video_rates[swfdec->decoder->frame_rate_code] /
+ GST_SECOND;
break;
- default:
- res = FALSE;
+ default:
+ res = FALSE;
}
break;
case GST_FORMAT_DEFAULT:
switch (*dest_format) {
- case GST_FORMAT_TIME:
+ case GST_FORMAT_TIME:
if (video_rates[swfdec->decoder->frame_rate_code] != 0.0) {
*dest_value = src_value * GST_SECOND /
- video_rates[swfdec->decoder->frame_rate_code];
- }
- else
+ video_rates[swfdec->decoder->frame_rate_code];
+ } else
res = FALSE;
break;
- case GST_FORMAT_BYTES:
+ case GST_FORMAT_BYTES:
*dest_value = src_value * 6 * (swfdec->width * swfdec->height >> 2);
break;
- case GST_FORMAT_DEFAULT:
+ case GST_FORMAT_DEFAULT:
*dest_value = src_value;
break;
- default:
- res = FALSE;
+ default:
+ res = FALSE;
}
break;
default:
}
#endif
-static gboolean
-gst_swfdec_src_query (GstPad *pad, GstQueryType type,
- GstFormat *format, gint64 *value)
+static gboolean
+gst_swfdec_src_query (GstPad * pad, GstQueryType type,
+ GstFormat * format, gint64 * value)
{
gboolean res = TRUE;
GstSwfdec *swfdec;
case GST_QUERY_TOTAL:
{
switch (*format) {
- case GST_FORMAT_TIME:
+ case GST_FORMAT_TIME:
{
int n_frames;
int ret;
- res = FALSE;
- ret = swfdec_decoder_get_n_frames(swfdec->state, &n_frames);
- if(ret == SWF_OK){
+ res = FALSE;
+ ret = swfdec_decoder_get_n_frames (swfdec->state, &n_frames);
+ if (ret == SWF_OK) {
*value = n_frames * swfdec->interval;
- res = TRUE;
+ res = TRUE;
}
- break;
+ break;
}
- default:
+ default:
res = FALSE;
- break;
+ break;
}
break;
}
case GST_QUERY_POSITION:
{
switch (*format) {
- default:
- res = FALSE;
- break;
+ default:
+ res = FALSE;
+ break;
}
break;
}
}
#if 0
-static gboolean
-gst_swfdec_src_event (GstPad *pad, GstEvent *event)
+static gboolean
+gst_swfdec_src_event (GstPad * pad, GstEvent * event)
{
gboolean res = TRUE;
GstSwfdec *swfdec;
static const GstFormat formats[] = { GST_FORMAT_TIME, GST_FORMAT_BYTES };
-#define MAX_SEEK_FORMATS 1 /* we can only do time seeking for now */
+#define MAX_SEEK_FORMATS 1 /* we can only do time seeking for now */
gint i;
swfdec = GST_SWFDEC (gst_pad_get_parent (pad));
switch (GST_EVENT_TYPE (event)) {
- /* the all-formats seek logic */
+ /* the all-formats seek logic */
case GST_EVENT_SEEK:
{
gint64 src_offset;
gboolean flush;
GstFormat format;
-
+
format = GST_FORMAT_TIME;
/* first bring the src_format to TIME */
if (!gst_pad_convert (pad,
- GST_EVENT_SEEK_FORMAT (event), GST_EVENT_SEEK_OFFSET (event),
- &format, &src_offset))
- {
- /* didn't work, probably unsupported seek format then */
- res = FALSE;
- break;
+ GST_EVENT_SEEK_FORMAT (event), GST_EVENT_SEEK_OFFSET (event),
+ &format, &src_offset)) {
+ /* didn't work, probably unsupported seek format then */
+ res = FALSE;
+ break;
}
/* shave off the flush flag, we'll need it later */
/* while we did not exhaust our seek formats without result */
for (i = 0; i < MAX_SEEK_FORMATS && !res; i++) {
- gint64 desired_offset;
-
- format = formats[i];
-
- /* try to convert requested format to one we can seek with on the sinkpad */
- if (gst_pad_convert (swfdec->sinkpad, GST_FORMAT_TIME, src_offset, &format, &desired_offset))
- {
- GstEvent *seek_event;
-
- /* conversion succeeded, create the seek */
- seek_event = gst_event_new_seek (formats[i] | GST_SEEK_METHOD_SET | flush, desired_offset);
- /* do the seekk */
- if (gst_pad_send_event (GST_PAD_PEER (swfdec->sinkpad), seek_event)) {
- /* seek worked, we're done, loop will exit */
- res = TRUE;
- }
- }
- /* at this point, either the seek worked or res == FALSE */
+ gint64 desired_offset;
+
+ format = formats[i];
+
+ /* try to convert requested format to one we can seek with on the sinkpad */
+ if (gst_pad_convert (swfdec->sinkpad, GST_FORMAT_TIME, src_offset,
+ &format, &desired_offset)) {
+ GstEvent *seek_event;
+
+ /* conversion succeeded, create the seek */
+ seek_event =
+ gst_event_new_seek (formats[i] | GST_SEEK_METHOD_SET | flush,
+ desired_offset);
+ /* do the seekk */
+ if (gst_pad_send_event (GST_PAD_PEER (swfdec->sinkpad), seek_event)) {
+ /* seek worked, we're done, loop will exit */
+ res = TRUE;
+ }
+ }
+ /* at this point, either the seek worked or res == FALSE */
}
break;
}
#endif
static GstElementStateReturn
-gst_swfdec_change_state (GstElement *element)
+gst_swfdec_change_state (GstElement * element)
{
GstSwfdec *swfdec = GST_SWFDEC (element);
- switch (GST_STATE_TRANSITION (element)) {
+ switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY:
break;
case GST_STATE_READY_TO_PAUSED:
/* if we are not closed by an EOS event do so now, this cen send a few frames but
* we are prepared to not really send them (see above) */
if (!swfdec->closed) {
- /*swf_close (swfdec->decoder); */
+ /*swf_close (swfdec->decoder); */
swfdec->closed = TRUE;
}
//gst_swfdec_vo_destroy (swfdec);
}
static void
-gst_swfdec_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_swfdec_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstSwfdec *src;
}
static void
-gst_swfdec_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_swfdec_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstSwfdec *swfdec;
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- return gst_element_register (plugin, "swfdec", GST_RANK_PRIMARY, GST_TYPE_SWFDEC);
+ return gst_element_register (plugin, "swfdec", GST_RANK_PRIMARY,
+ GST_TYPE_SWFDEC);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "swfdec",
- "Uses libswfdec to decode Flash video streams",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "swfdec",
+ "Uses libswfdec to decode Flash video streams",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
#include <swfdec.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_SWFDEC \
#define GST_IS_SWFDEC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SWFDEC))
-typedef struct _GstSwfdec GstSwfdec;
-typedef struct _GstSwfdecClass GstSwfdecClass;
+ typedef struct _GstSwfdec GstSwfdec;
+ typedef struct _GstSwfdecClass GstSwfdecClass;
-struct _GstSwfdec {
- GstElement element;
+ struct _GstSwfdec
+ {
+ GstElement element;
- /* pads */
- GstPad *sinkpad;
- GstPad *videopad;
- GstPad *audiopad;
+ /* pads */
+ GstPad *sinkpad;
+ GstPad *videopad;
+ GstPad *audiopad;
- SwfdecDecoder *state;
- gboolean closed;
+ SwfdecDecoder *state;
+ gboolean closed;
- /* the timestamp of the next frame */
- gboolean first;
- gboolean have_format;
+ /* the timestamp of the next frame */
+ gboolean first;
+ gboolean have_format;
- double rate;
- gint64 timestamp;
- gint64 interval;
- double frame_rate;
+ double rate;
+ gint64 timestamp;
+ gint64 interval;
+ double frame_rate;
- /* video state */
- gint format;
- gint width;
- gint height;
- gint64 total_frames;
+ /* video state */
+ gint format;
+ gint width;
+ gint height;
+ gint64 total_frames;
-};
+ };
-struct _GstSwfdecClass {
- GstElementClass parent_class;
-};
+ struct _GstSwfdecClass
+ {
+ GstElementClass parent_class;
+ };
-GType gst_swfdec_get_type(void);
+ GType gst_swfdec_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_SWFDEC_H__ */
+#endif /* __GST_SWFDEC_H__ */
#define ENTROPY_ENCODER_FLUSH(coder) bitcoder_flush(coder)
#define ENTROPY_DECODER_INIT(coder,bitstream,limit) \
bitcoder_decoder_init(coder,bitstream,limit)
-#define ENTROPY_DECODER_DONE(coder) /* nothing to do ... */
+#define ENTROPY_DECODER_DONE(coder) /* nothing to do ... */
#define ENTROPY_CODER_BITSTREAM(coder) (coder)->bitstream
#define ENTROPY_CODER_SYMBOL(coder) 1
#endif
-typedef struct {
- int32_t bit_count; /* number of valid bits in byte */
- uint8_t byte; /* buffer to save bits */
- uint32_t byte_count; /* number of bytes written */
- uint8_t *bitstream;
- uint32_t limit; /* don't write more bytes to bitstream ... */
- int eos; /* end of stream reached */
+typedef struct
+{
+ int32_t bit_count; /* number of valid bits in byte */
+ uint8_t byte; /* buffer to save bits */
+ uint32_t byte_count; /* number of bytes written */
+ uint8_t *bitstream;
+ uint32_t limit; /* don't write more bytes to bitstream ... */
+ int eos; /* end of stream reached */
} BitCoderState;
-static inline
-void bitcoder_encoder_init (BitCoderState *s, uint32_t limit)
+static inline void
+bitcoder_encoder_init (BitCoderState * s, uint32_t limit)
{
- s->bit_count = 0;
- s->byte = 0;
- s->byte_count = 0;
- s->bitstream = (uint8_t*) MALLOC (limit);
- s->limit = limit;
- s->eos = 0;
+ s->bit_count = 0;
+ s->byte = 0;
+ s->byte_count = 0;
+ s->bitstream = (uint8_t *) MALLOC (limit);
+ s->limit = limit;
+ s->eos = 0;
}
-static inline
-void bitcoder_encoder_done (BitCoderState *s)
+static inline void
+bitcoder_encoder_done (BitCoderState * s)
{
- FREE (s->bitstream);
+ FREE (s->bitstream);
}
-static inline
-void bitcoder_decoder_init (BitCoderState *s, uint8_t *bitstream, uint32_t limit)
+static inline void
+bitcoder_decoder_init (BitCoderState * s, uint8_t * bitstream, uint32_t limit)
{
- s->bit_count = -1;
- s->byte = 0;
- s->byte_count = 0;
- s->bitstream = bitstream;
- s->limit = limit;
- s->eos = 0;
+ s->bit_count = -1;
+ s->byte = 0;
+ s->byte_count = 0;
+ s->bitstream = bitstream;
+ s->limit = limit;
+ s->eos = 0;
}
-static inline
-uint32_t bitcoder_flush (BitCoderState *s)
+static inline uint32_t
+bitcoder_flush (BitCoderState * s)
{
- if (s->bit_count > 0 && s->byte_count < s->limit)
- s->bitstream [s->byte_count++] = s->byte << (8 - s->bit_count);
+ if (s->bit_count > 0 && s->byte_count < s->limit)
+ s->bitstream[s->byte_count++] = s->byte << (8 - s->bit_count);
/*printf ("%s: %i bytes written.\n", __FUNCTION__, s->byte_count); */
/*printf ("%s: last bit %i\n", __FUNCTION__, s->bit_count); */
- return s->byte_count;
+ return s->byte_count;
}
-static inline
-void bitcoder_write_bit (BitCoderState *s, int bit)
+static inline void
+bitcoder_write_bit (BitCoderState * s, int bit)
{
- s->byte <<= 1;
- s->byte |= bit & 1;
-
- s->bit_count++;
-
- if (s->bit_count == 8) {
- if (s->byte_count < s->limit) {
- s->bitstream [s->byte_count++] = s->byte;
- s->bit_count = 0;
- } else {
- s->eos = 1;
- }
- }
+ s->byte <<= 1;
+ s->byte |= bit & 1;
+
+ s->bit_count++;
+
+ if (s->bit_count == 8) {
+ if (s->byte_count < s->limit) {
+ s->bitstream[s->byte_count++] = s->byte;
+ s->bit_count = 0;
+ } else {
+ s->eos = 1;
+ }
+ }
}
-static inline
-int bitcoder_read_bit (BitCoderState *s)
+static inline int
+bitcoder_read_bit (BitCoderState * s)
{
- int ret;
+ int ret;
- if (s->bit_count <= 0) {
- if (!s->bitstream) {
- s->eos = 1;
- return 0;
- }
+ if (s->bit_count <= 0) {
+ if (!s->bitstream) {
+ s->eos = 1;
+ return 0;
+ }
- if (s->byte_count < s->limit) {
- s->byte = s->bitstream [s->byte_count++];
- } else {
- s->eos = 1;
- s->byte = 0;
- }
+ if (s->byte_count < s->limit) {
+ s->byte = s->bitstream[s->byte_count++];
+ } else {
+ s->eos = 1;
+ s->byte = 0;
+ }
- s->bit_count = 8;
- }
+ s->bit_count = 8;
+ }
- ret = s->byte >> 7;
- s->byte <<= 1;
- s->bit_count--;
+ ret = s->byte >> 7;
+ s->byte <<= 1;
+ s->bit_count--;
- return ret & 1;
+ return ret & 1;
}
-static inline
-void bit_print (TYPE byte)
+static inline void
+bit_print (TYPE byte)
{
- int bit = 8*sizeof(TYPE);
+ int bit = 8 * sizeof (TYPE);
- do {
- bit--;
- printf ((byte & (1 << bit)) ? "1" : "0");
- } while (bit);
- printf ("\n");
+ do {
+ bit--;
+ printf ((byte & (1 << bit)) ? "1" : "0");
+ } while (bit);
+ printf ("\n");
}
#endif
-
#include "bitcoder.h"
-static inline
-unsigned int required_bits (unsigned int x)
+static inline unsigned int
+required_bits (unsigned int x)
{
- int bits = 31;
+ int bits = 31;
- while ((x & (1 << bits)) == 0 && bits)
- bits--;
+ while ((x & (1 << bits)) == 0 && bits)
+ bits--;
- return bits;
+ return bits;
}
-static inline
-void write_number_binary (BitCoderState *b, unsigned int x, int bits, int u)
+static inline void
+write_number_binary (BitCoderState * b, unsigned int x, int bits, int u)
{
/*printf ("wrote %i with %i bits (%i+%i)\n", x, u+bits, u, bits); */
- while (bits) {
- bits--;
- bitcoder_write_bit (b, (x >> bits) & 1);
- }
+ while (bits) {
+ bits--;
+ bitcoder_write_bit (b, (x >> bits) & 1);
+ }
}
-static inline
-unsigned int read_number_binary (BitCoderState *b, int bits)
+static inline unsigned int
+read_number_binary (BitCoderState * b, int bits)
{
- unsigned int x = 0;
+ unsigned int x = 0;
- while (bits) {
- bits--;
- x |= bitcoder_read_bit (b) << bits;
- }
+ while (bits) {
+ bits--;
+ x |= bitcoder_read_bit (b) << bits;
+ }
- return x;
+ return x;
}
-static inline
-void golomb_write_number (BitCoderState *b, unsigned int x, int bits)
+static inline void
+golomb_write_number (BitCoderState * b, unsigned int x, int bits)
{
- unsigned int q, r;
-int i = 0;
+ unsigned int q, r;
+ int i = 0;
- assert (x > 0);
+ assert (x > 0);
- while ((q = (x - 1) >> bits) > 0) {
- bitcoder_write_bit (b, 1); /* fast temporary adaption, write */
- bits++; /* unary representation of q */
-i++;
- };
+ while ((q = (x - 1) >> bits) > 0) {
+ bitcoder_write_bit (b, 1); /* fast temporary adaption, write */
+ bits++; /* unary representation of q */
+ i++;
+ };
- bitcoder_write_bit (b, 0);
+ bitcoder_write_bit (b, 0);
- r = x - 1 - (q << bits);
+ r = x - 1 - (q << bits);
- write_number_binary (b, r, bits, i+1);
+ write_number_binary (b, r, bits, i + 1);
}
-static inline
-unsigned int golomb_read_number (BitCoderState *b, int bits)
+static inline unsigned int
+golomb_read_number (BitCoderState * b, int bits)
{
- unsigned int q = 0, r, x;
+ unsigned int q = 0, r, x;
- while (bitcoder_read_bit (b) != 0) {
- bits++;
- }
+ while (bitcoder_read_bit (b) != 0) {
+ bits++;
+ }
- r = read_number_binary (b, bits);
- x = (q << bits) + r + 1;
+ r = read_number_binary (b, bits);
+ x = (q << bits) + r + 1;
- return x;
+ return x;
}
-typedef struct {
- uint8_t count;
- uint8_t bits; /* a 5.3 fixed point integer */
+typedef struct
+{
+ uint8_t count;
+ uint8_t bits; /* a 5.3 fixed point integer */
} GolombAdaptiveCoderState;
#define GOLOMB_ADAPTIVE_CODER_STATE_INITIALIZER { 8<<3, 0 }
-static const int golomb_w_tab [] = { 256, 128, 64 };
+static const int golomb_w_tab[] = { 256, 128, 64 };
-static inline
-void golombcoder_encode_number (GolombAdaptiveCoderState *g,
- BitCoderState *b,
- unsigned int x)
+static inline void
+golombcoder_encode_number (GolombAdaptiveCoderState * g,
+ BitCoderState * b, unsigned int x)
{
- golomb_write_number (b, x, g->bits >> 3);
+ golomb_write_number (b, x, g->bits >> 3);
- g->bits = ((256 - golomb_w_tab[g->count]) * (int) g->bits +
- golomb_w_tab[g->count] * (required_bits(x)<<3)) / 256;
- g->count++;
+ g->bits = ((256 - golomb_w_tab[g->count]) * (int) g->bits +
+ golomb_w_tab[g->count] * (required_bits (x) << 3)) / 256;
+ g->count++;
- if (g->count > 2)
- g->count = 2;
+ if (g->count > 2)
+ g->count = 2;
}
-static inline
-unsigned int golombcoder_decode_number (GolombAdaptiveCoderState *g,
- BitCoderState *b)
+static inline unsigned int
+golombcoder_decode_number (GolombAdaptiveCoderState * g, BitCoderState * b)
{
- unsigned int x;
+ unsigned int x;
- x = golomb_read_number (b, g->bits >> 3);
+ x = golomb_read_number (b, g->bits >> 3);
- g->bits = ((256 - golomb_w_tab[g->count]) * g->bits +
- golomb_w_tab[g->count] * (required_bits(x)<<3)) / 256;
- g->count++;
+ g->bits = ((256 - golomb_w_tab[g->count]) * g->bits +
+ golomb_w_tab[g->count] * (required_bits (x) << 3)) / 256;
+ g->count++;
- if (g->count > 2)
- g->count = 2;
+ if (g->count > 2)
+ g->count = 2;
- return x;
+ return x;
}
#endif
-
#include "gsttarkindec.h"
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- if (!gst_element_register (plugin, "tarkinenc", GST_RANK_NONE, GST_TYPE_TARKINENC))
+ if (!gst_element_register (plugin, "tarkinenc", GST_RANK_NONE,
+ GST_TYPE_TARKINENC))
return FALSE;
- if (!gst_element_register (plugin, "tarkindec", GST_RANK_NONE, GST_TYPE_TARKINDEC))
+ if (!gst_element_register (plugin, "tarkindec", GST_RANK_NONE,
+ GST_TYPE_TARKINDEC))
return FALSE;
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "tarkin",
- "Tarkin plugin library",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "tarkin",
+ "Tarkin plugin library",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
"Ogg Tarkin decoder",
"Filter/Video/Decoder",
"Decodes video in OGG Tarkin format",
- "Monty <monty@xiph.org>, "
- "Wim Taymans <wim.taymans@chello.be>",
+ "Monty <monty@xiph.org>, " "Wim Taymans <wim.taymans@chello.be>",
};
/* TarkinDec signals and args */
ARG_BITRATE,
};
-static void gst_tarkindec_base_init (gpointer g_class);
-static void gst_tarkindec_class_init (TarkinDecClass *klass);
-static void gst_tarkindec_init (TarkinDec *arkindec);
+static void gst_tarkindec_base_init (gpointer g_class);
+static void gst_tarkindec_class_init (TarkinDecClass * klass);
+static void gst_tarkindec_init (TarkinDec * arkindec);
-static void gst_tarkindec_chain (GstPad *pad, GstData *_data);
-static void gst_tarkindec_setup (TarkinDec *tarkindec);
-static GstElementStateReturn
- gst_tarkindec_change_state (GstElement *element);
+static void gst_tarkindec_chain (GstPad * pad, GstData * _data);
+static void gst_tarkindec_setup (TarkinDec * tarkindec);
+static GstElementStateReturn gst_tarkindec_change_state (GstElement * element);
-static void gst_tarkindec_get_property (GObject *object, guint prop_id, GValue *value,
- GParamSpec *pspec);
-static void gst_tarkindec_set_property (GObject *object, guint prop_id, const GValue *value,
- GParamSpec *pspec);
+static void gst_tarkindec_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+static void gst_tarkindec_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_tarkindec_signals[LAST_SIGNAL] = { 0 }; */
GType
if (!tarkindec_type) {
static const GTypeInfo tarkindec_info = {
- sizeof (TarkinDecClass),
+ sizeof (TarkinDecClass),
gst_tarkindec_base_init,
NULL,
(GClassInitFunc) gst_tarkindec_class_init,
(GInstanceInitFunc) gst_tarkindec_init,
};
- tarkindec_type = g_type_register_static (GST_TYPE_ELEMENT, "TarkinDec", &tarkindec_info, 0);
+ tarkindec_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "TarkinDec", &tarkindec_info,
+ 0);
}
return tarkindec_type;
}
-static GstCaps*
+static GstCaps *
tarkin_caps_factory (void)
{
- return
- gst_caps_new (
- "tarkin_tarkin",
- "application/ogg",
- NULL);
+ return gst_caps_new ("tarkin_tarkin", "application/ogg", NULL);
}
-static GstCaps*
+static GstCaps *
raw_caps_factory (void)
{
return
- GST_CAPS_NEW (
- "tarkin_raw",
- "video/x-raw-rgb",
- "bpp", GST_PROPS_INT (24),
- "depth", GST_PROPS_INT (24),
+ GST_CAPS_NEW ("tarkin_raw",
+ "video/x-raw-rgb",
+ "bpp", GST_PROPS_INT (24),
+ "depth", GST_PROPS_INT (24),
"endianness", GST_PROPS_INT (G_BYTE_ORDER),
- "red_mask", GST_PROPS_INT (0xff0000),
+ "red_mask", GST_PROPS_INT (0xff0000),
"green_mask", GST_PROPS_INT (0xff00),
- "blue_mask", GST_PROPS_INT (0xff),
- "width", GST_PROPS_INT_RANGE (0, G_MAXINT),
- "height", GST_PROPS_INT_RANGE (0, G_MAXINT),
- "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT)
- );
+ "blue_mask", GST_PROPS_INT (0xff),
+ "width", GST_PROPS_INT_RANGE (0, G_MAXINT),
+ "height", GST_PROPS_INT_RANGE (0, G_MAXINT),
+ "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT)
+ );
}
static void
raw_caps = raw_caps_factory ();
tarkin_caps = tarkin_caps_factory ();
- dec_sink_template = gst_pad_template_new ("sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- tarkin_caps,
- NULL);
- dec_src_template = gst_pad_template_new ("src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- raw_caps,
- NULL);
+ dec_sink_template = gst_pad_template_new ("sink",
+ GST_PAD_SINK, GST_PAD_ALWAYS, tarkin_caps, NULL);
+ dec_src_template = gst_pad_template_new ("src",
+ GST_PAD_SRC, GST_PAD_ALWAYS, raw_caps, NULL);
gst_element_class_add_pad_template (element_class, dec_sink_template);
gst_element_class_add_pad_template (element_class, dec_src_template);
}
static void
-gst_tarkindec_class_init (TarkinDecClass *klass)
+gst_tarkindec_class_init (TarkinDecClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BITRATE,
- g_param_spec_int ("bitrate", "bitrate", "bitrate",
- G_MININT, G_MAXINT, 3000, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BITRATE,
+ g_param_spec_int ("bitrate", "bitrate", "bitrate",
+ G_MININT, G_MAXINT, 3000, G_PARAM_READWRITE));
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
}
static void
-gst_tarkindec_setup (TarkinDec *tarkindec)
+gst_tarkindec_setup (TarkinDec * tarkindec)
{
tarkindec->tarkin_stream = tarkin_stream_new ();
-
+
ogg_sync_init (&tarkindec->oy);
ogg_stream_init (&tarkindec->os, 1);
tarkin_info_init (&tarkindec->ti);
}
static void
-gst_tarkindec_chain (GstPad *pad, GstData *_data)
+gst_tarkindec_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
TarkinDec *tarkindec;
tarkindec = GST_TARKINDEC (gst_pad_get_parent (pad));
if (!tarkindec->setup) {
- GST_ELEMENT_ERROR (tarkindec, CORE, NEGOTATION, (NULL), ("decoder not initialized (input is not tarkin?)"));
+ GST_ELEMENT_ERROR (tarkindec, CORE, NEGOTATION, (NULL),
+ ("decoder not initialized (input is not tarkin?)"));
if (GST_IS_BUFFER (buf))
gst_buffer_unref (buf);
else
gst_pad_event_default (pad, GST_EVENT (buf));
break;
}
- }
- else {
+ } else {
gchar *data;
gulong size;
gchar *buffer;
guchar *rgb;
TarkinTime date;
TarkinVideoLayerDesc *layer;
-
+
/* data to decode */
data = GST_BUFFER_DATA (buf);
size = GST_BUFFER_SIZE (buf);
- buffer = ogg_sync_buffer(&tarkindec->oy, size);
+ buffer = ogg_sync_buffer (&tarkindec->oy, size);
memcpy (buffer, data, size);
- ogg_sync_wrote(&tarkindec->oy, size);
+ ogg_sync_wrote (&tarkindec->oy, size);
if (ogg_sync_pageout (&tarkindec->oy, &tarkindec->og)) {
ogg_stream_pagein (&tarkindec->os, &tarkindec->og);
while (ogg_stream_packetout (&tarkindec->os, &tarkindec->op)) {
- if (tarkindec->op.e_o_s)
- break;
- if (tarkindec->nheader < 3) { /* 3 first packets to headerin */
- tarkin_synthesis_headerin (&tarkindec->ti, &tarkindec->tc, &tarkindec->op);
+ if (tarkindec->op.e_o_s)
+ break;
+ if (tarkindec->nheader < 3) { /* 3 first packets to headerin */
+ tarkin_synthesis_headerin (&tarkindec->ti, &tarkindec->tc,
+ &tarkindec->op);
if (tarkindec->nheader == 2) {
tarkin_synthesis_init (tarkindec->tarkin_stream, &tarkindec->ti);
- }
- tarkindec->nheader++;
- } else {
+ }
+ tarkindec->nheader++;
+ } else {
tarkin_synthesis_packetin (tarkindec->tarkin_stream, &tarkindec->op);
-
- while (tarkin_synthesis_frameout (tarkindec->tarkin_stream, &rgb, 0, &date) == 0) {
- GstBuffer *outbuf;
+
+ while (tarkin_synthesis_frameout (tarkindec->tarkin_stream, &rgb, 0,
+ &date) == 0) {
+ GstBuffer *outbuf;
layer = &tarkindec->tarkin_stream->layer->desc;
if (!GST_PAD_CAPS (tarkindec->srcpad)) {
- if (gst_pad_try_set_caps (tarkindec->srcpad,
- GST_CAPS_NEW (
- "tarkin_raw",
- "video/x-raw-rgb",
- "bpp", GST_PROPS_INT (24),
- "depth", GST_PROPS_INT (24),
- "endianness", GST_PROPS_INT (G_BYTE_ORDER),
- "red_mask", GST_PROPS_INT (0xff0000),
- "green_mask", GST_PROPS_INT (0xff00),
- "blue_mask", GST_PROPS_INT (0xff),
- "width", GST_PROPS_INT (layer->width),
- "height", GST_PROPS_INT (layer->height),
- "framerate", GST_PROPS_FLOAT (0.) /* FIXME!!! */
- )) <= 0)
- {
- GST_ELEMENT_ERROR (tarkindec, CORE, NEGOTATION, (NULL), ("could not output format"));
+ if (gst_pad_try_set_caps (tarkindec->srcpad, GST_CAPS_NEW ("tarkin_raw", "video/x-raw-rgb", "bpp", GST_PROPS_INT (24), "depth", GST_PROPS_INT (24), "endianness", GST_PROPS_INT (G_BYTE_ORDER), "red_mask", GST_PROPS_INT (0xff0000), "green_mask", GST_PROPS_INT (0xff00), "blue_mask", GST_PROPS_INT (0xff), "width", GST_PROPS_INT (layer->width), "height", GST_PROPS_INT (layer->height), "framerate", GST_PROPS_FLOAT (0.) /* FIXME!!! */
+ )) <= 0) {
+ GST_ELEMENT_ERROR (tarkindec, CORE, NEGOTATION, (NULL),
+ ("could not output format"));
gst_buffer_unref (buf);
return;
}
GST_BUFFER_SIZE (outbuf) = layer->width * layer->height * 3;
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_DONTFREE);
gst_pad_push (tarkindec->srcpad, GST_DATA (outbuf));
-
+
tarkin_synthesis_freeframe (tarkindec->tarkin_stream, rgb);
- }
- }
+ }
+ }
}
}
gst_buffer_unref (buf);
}
static GstElementStateReturn
-gst_tarkindec_change_state (GstElement *element)
+gst_tarkindec_change_state (GstElement * element)
{
TarkinDec *tarkindec;
default:
break;
}
-
+
return parent_class->change_state (element);
}
static void
-gst_tarkindec_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_tarkindec_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
TarkinDec *tarkindec;
}
static void
-gst_tarkindec_set_property (GObject *object, guint prop_id, const GValue *value,
- GParamSpec *pspec)
+gst_tarkindec_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
TarkinDec *tarkindec;
#include "tarkin.h"
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_TARKINDEC \
(tarkindec_get_type())
#define GST_IS_TARKINDEC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TARKINDEC))
-typedef struct _TarkinDec TarkinDec;
-typedef struct _TarkinDecClass TarkinDecClass;
+ typedef struct _TarkinDec TarkinDec;
+ typedef struct _TarkinDecClass TarkinDecClass;
-struct _TarkinDec {
- GstElement element;
+ struct _TarkinDec
+ {
+ GstElement element;
- GstPad *sinkpad,*srcpad;
+ GstPad *sinkpad, *srcpad;
- ogg_sync_state oy;
- ogg_stream_state os;
- ogg_page og;
- ogg_packet op;
+ ogg_sync_state oy;
+ ogg_stream_state os;
+ ogg_page og;
+ ogg_packet op;
- TarkinStream *tarkin_stream;
- TarkinComment tc;
- TarkinInfo ti;
- TarkinVideoLayerDesc layer[1];
+ TarkinStream *tarkin_stream;
+ TarkinComment tc;
+ TarkinInfo ti;
+ TarkinVideoLayerDesc layer[1];
- gint frame_num;
- gint nheader;
-
- gboolean eos;
- gint bitrate;
- gboolean setup;
-};
+ gint frame_num;
+ gint nheader;
-struct _TarkinDecClass {
- GstElementClass parent_class;
-};
+ gboolean eos;
+ gint bitrate;
+ gboolean setup;
+ };
-GType tarkindec_get_type(void);
+ struct _TarkinDecClass
+ {
+ GstElementClass parent_class;
+ };
+
+ GType tarkindec_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __TARKINDEC_H__ */
+#endif /* __TARKINDEC_H__ */
"Ogg Tarkin encoder",
"Filter/Video/Encoder",
"Encodes video in OGG Tarkin format",
- "Monty <monty@xiph.org>, "
- "Wim Taymans <wim.taymans@chello.be>",
+ "Monty <monty@xiph.org>, " "Wim Taymans <wim.taymans@chello.be>",
};
/* TarkinEnc signals and args */
ARG_A_MOMENTS,
};
-static void gst_tarkinenc_base_init (gpointer g_class);
-static void gst_tarkinenc_class_init (TarkinEncClass *klass);
-static void gst_tarkinenc_init (TarkinEnc *arkinenc);
+static void gst_tarkinenc_base_init (gpointer g_class);
+static void gst_tarkinenc_class_init (TarkinEncClass * klass);
+static void gst_tarkinenc_init (TarkinEnc * arkinenc);
-static void gst_tarkinenc_chain (GstPad *pad, GstData *_data);
-static void gst_tarkinenc_setup (TarkinEnc *tarkinenc);
+static void gst_tarkinenc_chain (GstPad * pad, GstData * _data);
+static void gst_tarkinenc_setup (TarkinEnc * tarkinenc);
-static void gst_tarkinenc_get_property (GObject *object, guint prop_id, GValue *value,
- GParamSpec *pspec);
-static void gst_tarkinenc_set_property (GObject *object, guint prop_id, const GValue *value,
- GParamSpec *pspec);
+static void gst_tarkinenc_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+static void gst_tarkinenc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_tarkinenc_signals[LAST_SIGNAL] = { 0 }; */
GType
if (!tarkinenc_type) {
static const GTypeInfo tarkinenc_info = {
- sizeof (TarkinEncClass),
+ sizeof (TarkinEncClass),
gst_tarkinenc_base_init,
NULL,
(GClassInitFunc) gst_tarkinenc_class_init,
(GInstanceInitFunc) gst_tarkinenc_init,
};
- tarkinenc_type = g_type_register_static (GST_TYPE_ELEMENT, "TarkinEnc", &tarkinenc_info, 0);
+ tarkinenc_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "TarkinEnc", &tarkinenc_info,
+ 0);
}
return tarkinenc_type;
}
-static GstCaps*
+static GstCaps *
tarkin_caps_factory (void)
{
- return
- gst_caps_new (
- "tarkin_tarkin",
- "application/ogg",
- NULL);
+ return gst_caps_new ("tarkin_tarkin", "application/ogg", NULL);
}
-static GstCaps*
+static GstCaps *
raw_caps_factory (void)
{
return
- GST_CAPS_NEW (
- "tarkin_raw",
- "video/x-raw-rgb",
- "bpp", GST_PROPS_INT (24),
- "depth", GST_PROPS_INT (24),
+ GST_CAPS_NEW ("tarkin_raw",
+ "video/x-raw-rgb",
+ "bpp", GST_PROPS_INT (24),
+ "depth", GST_PROPS_INT (24),
"endianness", GST_PROPS_INT (G_BYTE_ORDER),
- "red_mask", GST_PROPS_INT (0xff0000),
+ "red_mask", GST_PROPS_INT (0xff0000),
"green_mask", GST_PROPS_INT (0xff00),
- "blue_mask", GST_PROPS_INT (0xff),
- "width", GST_PROPS_INT_RANGE (0, G_MAXINT),
- "height", GST_PROPS_INT_RANGE (0, G_MAXINT),
- "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT)
- );
+ "blue_mask", GST_PROPS_INT (0xff),
+ "width", GST_PROPS_INT_RANGE (0, G_MAXINT),
+ "height", GST_PROPS_INT_RANGE (0, G_MAXINT),
+ "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT)
+ );
}
static void
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
GstCaps *raw_caps, *tarkin_caps;
-
+
raw_caps = raw_caps_factory ();
tarkin_caps = tarkin_caps_factory ();
- enc_sink_template = gst_pad_template_new ("sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- raw_caps,
- NULL);
- enc_src_template = gst_pad_template_new ("src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- tarkin_caps,
- NULL);
+ enc_sink_template = gst_pad_template_new ("sink",
+ GST_PAD_SINK, GST_PAD_ALWAYS, raw_caps, NULL);
+ enc_src_template = gst_pad_template_new ("src",
+ GST_PAD_SRC, GST_PAD_ALWAYS, tarkin_caps, NULL);
gst_element_class_add_pad_template (element_class, enc_sink_template);
gst_element_class_add_pad_template (element_class, enc_src_template);
}
static void
-gst_tarkinenc_class_init (TarkinEncClass *klass)
+gst_tarkinenc_class_init (TarkinEncClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BITRATE,
- g_param_spec_int ("bitrate", "bitrate", "bitrate",
- G_MININT, G_MAXINT, 3000, G_PARAM_READWRITE));
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_S_MOMENTS,
- g_param_spec_int ("s_moments", "Synthesis Moments",
- "Number of vanishing moments for the synthesis filter",
- 1, 4, 2, G_PARAM_READWRITE));
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_A_MOMENTS,
- g_param_spec_int ("a_moments", "Analysis Moments",
- "Number of vanishing moments for the analysis filter",
- 1, 4, 2, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BITRATE,
+ g_param_spec_int ("bitrate", "bitrate", "bitrate",
+ G_MININT, G_MAXINT, 3000, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_S_MOMENTS,
+ g_param_spec_int ("s_moments", "Synthesis Moments",
+ "Number of vanishing moments for the synthesis filter",
+ 1, 4, 2, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_A_MOMENTS,
+ g_param_spec_int ("a_moments", "Analysis Moments",
+ "Number of vanishing moments for the analysis filter",
+ 1, 4, 2, G_PARAM_READWRITE));
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
}
static GstPadLinkReturn
-gst_tarkinenc_sinkconnect (GstPad *pad, GstCaps *caps)
+gst_tarkinenc_sinkconnect (GstPad * pad, GstCaps * caps)
{
TarkinEnc *tarkinenc;
tarkinenc->setup = FALSE;
}
-TarkinError free_frame (void *s, void *ptr)
+TarkinError
+free_frame (void *s, void *ptr)
{
- return(TARKIN_OK);
+ return (TARKIN_OK);
}
-TarkinError packet_out (void *stream, ogg_packet *op)
+TarkinError
+packet_out (void *stream, ogg_packet * op)
{
ogg_page og;
TarkinStream *s = stream;
ogg_stream_packetin (&te->os, op);
- if(op->e_o_s){
+ if (op->e_o_s) {
ogg_stream_flush (&te->os, &og);
outbuf = gst_buffer_new ();
GST_BUFFER_DATA (outbuf) = og.header;
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_DONTFREE);
gst_pad_push (te->srcpad, GST_DATA (outbuf));
} else {
- while (ogg_stream_pageout (&te->os, &og)){
+ while (ogg_stream_pageout (&te->os, &og)) {
outbuf = gst_buffer_new ();
GST_BUFFER_DATA (outbuf) = og.header;
GST_BUFFER_SIZE (outbuf) = og.header_len;
static void
-gst_tarkinenc_setup (TarkinEnc *tarkinenc)
+gst_tarkinenc_setup (TarkinEnc * tarkinenc)
{
gint i;
GstBuffer *outbuf;
tarkinenc->ti.inter.numerator = 1;
tarkinenc->ti.inter.denominator = 1;
-
+
tarkin_comment_init (&tarkinenc->tc);
tarkin_comment_add_tag (&tarkinenc->tc, "TITLE", "GStreamer produced file");
tarkin_comment_add_tag (&tarkinenc->tc, "ARTIST", "C coders ;)");
tarkinenc->tarkin_stream = tarkin_stream_new ();
- tarkin_analysis_init (tarkinenc->tarkin_stream,
- &tarkinenc->ti, free_frame, packet_out, (void*)tarkinenc);
- tarkin_analysis_add_layer(tarkinenc->tarkin_stream, &tarkinenc->layer[0]);
-
- tarkin_analysis_headerout (tarkinenc->tarkin_stream, &tarkinenc->tc,
- tarkinenc->op, &tarkinenc->op[1], &tarkinenc->op[2]);
- for(i = 0; i < 3; i++){
- ogg_stream_packetin(&tarkinenc->os, &tarkinenc->op[i]);
+ tarkin_analysis_init (tarkinenc->tarkin_stream,
+ &tarkinenc->ti, free_frame, packet_out, (void *) tarkinenc);
+ tarkin_analysis_add_layer (tarkinenc->tarkin_stream, &tarkinenc->layer[0]);
+
+ tarkin_analysis_headerout (tarkinenc->tarkin_stream, &tarkinenc->tc,
+ tarkinenc->op, &tarkinenc->op[1], &tarkinenc->op[2]);
+ for (i = 0; i < 3; i++) {
+ ogg_stream_packetin (&tarkinenc->os, &tarkinenc->op[i]);
}
ogg_stream_flush (&tarkinenc->os, &tarkinenc->og);
}
static void
-gst_tarkinenc_chain (GstPad *pad, GstData *_data)
+gst_tarkinenc_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
TarkinEnc *tarkinenc;
tarkinenc = GST_TARKINENC (gst_pad_get_parent (pad));
if (!tarkinenc->setup) {
- GST_ELEMENT_ERROR (tarkinenc, CORE, NEGOTIATION, (NULL), ("encoder not initialized (input is not tarkin?)"));
+ GST_ELEMENT_ERROR (tarkinenc, CORE, NEGOTIATION, (NULL),
+ ("encoder not initialized (input is not tarkin?)"));
if (GST_IS_BUFFER (buf))
gst_buffer_unref (buf);
else
if (GST_IS_EVENT (buf)) {
switch (GST_EVENT_TYPE (buf)) {
case GST_EVENT_EOS:
- tarkin_analysis_framein (tarkinenc->tarkin_stream, NULL, 0, NULL); /* EOS */
- tarkin_comment_clear (&tarkinenc->tc);
- tarkin_stream_destroy (tarkinenc->tarkin_stream);
+ tarkin_analysis_framein (tarkinenc->tarkin_stream, NULL, 0, NULL); /* EOS */
+ tarkin_comment_clear (&tarkinenc->tc);
+ tarkin_stream_destroy (tarkinenc->tarkin_stream);
default:
gst_pad_event_default (pad, GST_EVENT (buf));
break;
}
- }
- else {
+ } else {
gchar *data;
gulong size;
TarkinTime date;
-
+
/* data to encode */
data = GST_BUFFER_DATA (buf);
size = GST_BUFFER_SIZE (buf);
}
static void
-gst_tarkinenc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_tarkinenc_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
TarkinEnc *tarkinenc;
}
static void
-gst_tarkinenc_set_property (GObject *object, guint prop_id, const GValue *value,
- GParamSpec *pspec)
+gst_tarkinenc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
TarkinEnc *tarkinenc;
s_moments = g_value_get_int (value);
if (s_moments != 1 || s_moments != 2 || s_moments != 4) {
g_warning ("tarkinenc: s_moments must be 1, 2 or 4");
- }
- else {
- tarkinenc->s_moments = s_moments;
+ } else {
+ tarkinenc->s_moments = s_moments;
}
break;
}
a_moments = g_value_get_int (value);
if (a_moments != 1 || a_moments != 2 || a_moments != 4) {
g_warning ("tarkinenc: a_moments must be 1, 2 or 4");
- }
- else {
- tarkinenc->a_moments = a_moments;
+ } else {
+ tarkinenc->a_moments = a_moments;
}
break;
}
#include "tarkin.h"
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_TARKINENC \
(tarkinenc_get_type())
#define GST_IS_TARKINENC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TARKINENC))
-typedef struct _TarkinEnc TarkinEnc;
-typedef struct _TarkinEncClass TarkinEncClass;
+ typedef struct _TarkinEnc TarkinEnc;
+ typedef struct _TarkinEncClass TarkinEncClass;
-struct _TarkinEnc {
- GstElement element;
+ struct _TarkinEnc
+ {
+ GstElement element;
- GstPad *sinkpad,*srcpad;
+ GstPad *sinkpad, *srcpad;
- ogg_stream_state os; /* take physical pages, weld into a logical
- stream of packets */
- ogg_page og; /* one Ogg bitstream page. Tarkin packets are inside */
- ogg_packet op[3]; /* one raw packet of data for decode */
+ ogg_stream_state os; /* take physical pages, weld into a logical
+ stream of packets */
+ ogg_page og; /* one Ogg bitstream page. Tarkin packets are inside */
+ ogg_packet op[3]; /* one raw packet of data for decode */
- TarkinStream *tarkin_stream;
- TarkinComment tc;
- TarkinInfo ti;
- TarkinVideoLayerDesc layer[1];
+ TarkinStream *tarkin_stream;
+ TarkinComment tc;
+ TarkinInfo ti;
+ TarkinVideoLayerDesc layer[1];
- gint frame_num;
-
- gboolean eos;
- gint bitrate;
- gint s_moments;
- gint a_moments;
- gboolean setup;
-};
+ gint frame_num;
-struct _TarkinEncClass {
- GstElementClass parent_class;
-};
+ gboolean eos;
+ gint bitrate;
+ gint s_moments;
+ gint a_moments;
+ gboolean setup;
+ };
-GType tarkinenc_get_type(void);
+ struct _TarkinEncClass
+ {
+ GstElementClass parent_class;
+ };
+
+ GType tarkinenc_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __TARKINENC_H__ */
+#endif /* __TARKINENC_H__ */
#include "mem.h"
/* helpers */
-static void _v_writestring(oggpack_buffer *o,char *s, int bytes){
- while(bytes--){
- oggpack_write(o,*s++,8);
+static void
+_v_writestring (oggpack_buffer * o, char *s, int bytes)
+{
+ while (bytes--) {
+ oggpack_write (o, *s++, 8);
}
}
-static void _v_readstring(oggpack_buffer *o,char *buf,int bytes){
- while(bytes--){
- *buf++=oggpack_read(o,8);
+static void
+_v_readstring (oggpack_buffer * o, char *buf, int bytes)
+{
+ while (bytes--) {
+ *buf++ = oggpack_read (o, 8);
}
}
-void tarkin_comment_init(TarkinComment *vc){
- memset(vc,0,sizeof(*vc));
+void
+tarkin_comment_init (TarkinComment * vc)
+{
+ memset (vc, 0, sizeof (*vc));
}
-void tarkin_comment_add(TarkinComment *vc,char *comment){
- vc->user_comments=REALLOC(vc->user_comments,
- (vc->comments+2)*sizeof(*vc->user_comments));
- vc->comment_lengths=REALLOC(vc->comment_lengths,
- (vc->comments+2)*sizeof(*vc->comment_lengths));
- vc->comment_lengths[vc->comments]=strlen(comment);
- vc->user_comments[vc->comments]=MALLOC(vc->comment_lengths[vc->comments]+1);
- strcpy(vc->user_comments[vc->comments], comment);
+void
+tarkin_comment_add (TarkinComment * vc, char *comment)
+{
+ vc->user_comments = REALLOC (vc->user_comments,
+ (vc->comments + 2) * sizeof (*vc->user_comments));
+ vc->comment_lengths = REALLOC (vc->comment_lengths,
+ (vc->comments + 2) * sizeof (*vc->comment_lengths));
+ vc->comment_lengths[vc->comments] = strlen (comment);
+ vc->user_comments[vc->comments] =
+ MALLOC (vc->comment_lengths[vc->comments] + 1);
+ strcpy (vc->user_comments[vc->comments], comment);
vc->comments++;
- vc->user_comments[vc->comments]=NULL;
+ vc->user_comments[vc->comments] = NULL;
}
-void tarkin_comment_add_tag(TarkinComment *vc, char *tag, char *contents){
- char *comment=alloca(strlen(tag)+strlen(contents)+2); /* +2 for = and \0 */
- strcpy(comment, tag);
- strcat(comment, "=");
- strcat(comment, contents);
- tarkin_comment_add(vc, comment);
+void
+tarkin_comment_add_tag (TarkinComment * vc, char *tag, char *contents)
+{
+ char *comment = alloca (strlen (tag) + strlen (contents) + 2); /* +2 for = and \0 */
+
+ strcpy (comment, tag);
+ strcat (comment, "=");
+ strcat (comment, contents);
+ tarkin_comment_add (vc, comment);
}
/* This is more or less the same as strncasecmp - but that doesn't exist
* everywhere, and this is a fairly trivial function, so we include it */
-static int tagcompare(const char *s1, const char *s2, int n){
- int c=0;
- while(c < n){
- if(toupper(s1[c]) != toupper(s2[c]))
+static int
+tagcompare (const char *s1, const char *s2, int n)
+{
+ int c = 0;
+
+ while (c < n) {
+ if (toupper (s1[c]) != toupper (s2[c]))
return !0;
c++;
}
return 0;
}
-char *tarkin_comment_query(TarkinComment *vc, char *tag, int count){
+char *
+tarkin_comment_query (TarkinComment * vc, char *tag, int count)
+{
long i;
int found = 0;
- int taglen = strlen(tag)+1; /* +1 for the = we append */
- char *fulltag = alloca(taglen+ 1);
-
- strcpy(fulltag, tag);
- strcat(fulltag, "=");
-
- for(i=0;i<vc->comments;i++){
- if(!tagcompare(vc->user_comments[i], fulltag, taglen)){
- if(count == found)
- /* We return a pointer to the data, not a copy */
- return vc->user_comments[i] + taglen;
+ int taglen = strlen (tag) + 1; /* +1 for the = we append */
+ char *fulltag = alloca (taglen + 1);
+
+ strcpy (fulltag, tag);
+ strcat (fulltag, "=");
+
+ for (i = 0; i < vc->comments; i++) {
+ if (!tagcompare (vc->user_comments[i], fulltag, taglen)) {
+ if (count == found)
+ /* We return a pointer to the data, not a copy */
+ return vc->user_comments[i] + taglen;
else
- found++;
+ found++;
}
}
- return NULL; /* didn't find anything */
+ return NULL; /* didn't find anything */
}
-int tarkin_comment_query_count(TarkinComment *vc, char *tag){
- int i,count=0;
- int taglen = strlen(tag)+1; /* +1 for the = we append */
- char *fulltag = alloca(taglen+1);
- strcpy(fulltag,tag);
- strcat(fulltag, "=");
+int
+tarkin_comment_query_count (TarkinComment * vc, char *tag)
+{
+ int i, count = 0;
+ int taglen = strlen (tag) + 1; /* +1 for the = we append */
+ char *fulltag = alloca (taglen + 1);
- for(i=0;i<vc->comments;i++){
- if(!tagcompare(vc->user_comments[i], fulltag, taglen))
+ strcpy (fulltag, tag);
+ strcat (fulltag, "=");
+
+ for (i = 0; i < vc->comments; i++) {
+ if (!tagcompare (vc->user_comments[i], fulltag, taglen))
count++;
}
return count;
}
-void tarkin_comment_clear(TarkinComment *vc){
- if(vc){
+void
+tarkin_comment_clear (TarkinComment * vc)
+{
+ if (vc) {
long i;
- for(i=0;i<vc->comments;i++)
- if(vc->user_comments[i])FREE(vc->user_comments[i]);
- if(vc->user_comments)FREE(vc->user_comments);
- if(vc->comment_lengths)FREE(vc->comment_lengths);
- if(vc->vendor)FREE(vc->vendor);
+
+ for (i = 0; i < vc->comments; i++)
+ if (vc->user_comments[i])
+ FREE (vc->user_comments[i]);
+ if (vc->user_comments)
+ FREE (vc->user_comments);
+ if (vc->comment_lengths)
+ FREE (vc->comment_lengths);
+ if (vc->vendor)
+ FREE (vc->vendor);
}
- memset(vc,0,sizeof(*vc));
+ memset (vc, 0, sizeof (*vc));
}
/* used by synthesis, which has a full, alloced vi */
-void tarkin_info_init(TarkinInfo *vi){
- memset(vi,0,sizeof(*vi));
+void
+tarkin_info_init (TarkinInfo * vi)
+{
+ memset (vi, 0, sizeof (*vi));
}
-void tarkin_info_clear(TarkinInfo *vi){
- memset(vi,0,sizeof(*vi));
+void
+tarkin_info_clear (TarkinInfo * vi)
+{
+ memset (vi, 0, sizeof (*vi));
}
/* Header packing/unpacking ********************************************/
-static int _tarkin_unpack_info(TarkinInfo *vi,oggpack_buffer *opb)
+static int
+_tarkin_unpack_info (TarkinInfo * vi, oggpack_buffer * opb)
{
#ifdef DBG_OGG
- printf("dbg_ogg: Decoding Info: ");
+ printf ("dbg_ogg: Decoding Info: ");
#endif
- vi->version=oggpack_read(opb,32);
- if(vi->version!=0)return(-TARKIN_VERSION);
+ vi->version = oggpack_read (opb, 32);
+ if (vi->version != 0)
+ return (-TARKIN_VERSION);
+
+ vi->n_layers = oggpack_read (opb, 8);
+ vi->inter.numerator = oggpack_read (opb, 32);
+ vi->inter.denominator = oggpack_read (opb, 32);
- vi->n_layers=oggpack_read(opb,8);
- vi->inter.numerator=oggpack_read(opb,32);
- vi->inter.denominator=oggpack_read(opb,32);
-
- vi->bitrate_upper=oggpack_read(opb,32);
- vi->bitrate_nominal=oggpack_read(opb,32);
- vi->bitrate_lower=oggpack_read(opb,32);
+ vi->bitrate_upper = oggpack_read (opb, 32);
+ vi->bitrate_nominal = oggpack_read (opb, 32);
+ vi->bitrate_lower = oggpack_read (opb, 32);
#ifdef DBG_OGG
- printf(" n_layers %d, interleave: %d/%d, ",
- vi->n_layers, vi->inter.numerator, vi->inter.denominator);
+ printf (" n_layers %d, interleave: %d/%d, ",
+ vi->n_layers, vi->inter.numerator, vi->inter.denominator);
#endif
-
- if(vi->inter.numerator<1)goto err_out;
- if(vi->inter.denominator<1)goto err_out;
- if(vi->n_layers<1)goto err_out;
-
- if(oggpack_read(opb,1)!=1)goto err_out; /* EOP check */
+
+ if (vi->inter.numerator < 1)
+ goto err_out;
+ if (vi->inter.denominator < 1)
+ goto err_out;
+ if (vi->n_layers < 1)
+ goto err_out;
+
+ if (oggpack_read (opb, 1) != 1)
+ goto err_out; /* EOP check */
#ifdef DBG_OGG
- printf("Success\n");
+ printf ("Success\n");
#endif
- return(0);
- err_out:
+ return (0);
+err_out:
#ifdef DBG_OGG
- printf("Failed\n");
+ printf ("Failed\n");
#endif
- tarkin_info_clear(vi);
- return(-TARKIN_BAD_HEADER);
+ tarkin_info_clear (vi);
+ return (-TARKIN_BAD_HEADER);
}
-static int _tarkin_unpack_comment(TarkinComment *vc,oggpack_buffer *opb)
+static int
+_tarkin_unpack_comment (TarkinComment * vc, oggpack_buffer * opb)
{
- int i;
- int vendorlen=oggpack_read(opb,32);
+ int i;
+ int vendorlen = oggpack_read (opb, 32);
#ifdef DBG_OGG
- printf("dbg_ogg: Decoding comment: ");
+ printf ("dbg_ogg: Decoding comment: ");
#endif
- if(vendorlen<0)goto err_out;
- vc->vendor=_ogg_calloc(vendorlen+1,1);
- _v_readstring(opb,vc->vendor,vendorlen);
- vc->comments=oggpack_read(opb,32);
- if(vc->comments<0)goto err_out;
- vc->user_comments=_ogg_calloc(vc->comments+1,sizeof(*vc->user_comments));
- vc->comment_lengths=_ogg_calloc(vc->comments+1,
- sizeof(*vc->comment_lengths));
-
- for(i=0;i<vc->comments;i++){
- int len=oggpack_read(opb,32);
- if(len<0)goto err_out;
- vc->comment_lengths[i]=len;
- vc->user_comments[i]=_ogg_calloc(len+1,1);
- _v_readstring(opb,vc->user_comments[i],len);
- }
- if(oggpack_read(opb,1)!=1)goto err_out; /* EOP check */
+ if (vendorlen < 0)
+ goto err_out;
+ vc->vendor = _ogg_calloc (vendorlen + 1, 1);
+ _v_readstring (opb, vc->vendor, vendorlen);
+ vc->comments = oggpack_read (opb, 32);
+ if (vc->comments < 0)
+ goto err_out;
+ vc->user_comments =
+ _ogg_calloc (vc->comments + 1, sizeof (*vc->user_comments));
+ vc->comment_lengths =
+ _ogg_calloc (vc->comments + 1, sizeof (*vc->comment_lengths));
+
+ for (i = 0; i < vc->comments; i++) {
+ int len = oggpack_read (opb, 32);
+
+ if (len < 0)
+ goto err_out;
+ vc->comment_lengths[i] = len;
+ vc->user_comments[i] = _ogg_calloc (len + 1, 1);
+ _v_readstring (opb, vc->user_comments[i], len);
+ }
+ if (oggpack_read (opb, 1) != 1)
+ goto err_out; /* EOP check */
#ifdef DBG_OGG
- printf("Success, read %d comments\n", vc->comments);
+ printf ("Success, read %d comments\n", vc->comments);
#endif
- return(0);
- err_out:
+ return (0);
+err_out:
#ifdef DBG_OGG
- printf("Failed\n");
+ printf ("Failed\n");
#endif
- tarkin_comment_clear(vc);
- return(-TARKIN_BAD_HEADER);
+ tarkin_comment_clear (vc);
+ return (-TARKIN_BAD_HEADER);
}
/* the real encoding details are here, currently TarkinVideoLayerDesc. */
-static int _tarkin_unpack_layer_desc(TarkinInfo *vi,oggpack_buffer *opb){
- int i,j;
- vi->layer = CALLOC (vi->n_layers, (sizeof(*vi->layer)));
- memset(vi->layer,0, vi->n_layers * sizeof(*vi->layer));
+static int
+_tarkin_unpack_layer_desc (TarkinInfo * vi, oggpack_buffer * opb)
+{
+ int i, j;
+
+ vi->layer = CALLOC (vi->n_layers, (sizeof (*vi->layer)));
+ memset (vi->layer, 0, vi->n_layers * sizeof (*vi->layer));
#ifdef DBG_OGG
- printf("ogg: Decoding layers description: ");
+ printf ("ogg: Decoding layers description: ");
#endif
- for(i=0;i<vi->n_layers;i++){
+ for (i = 0; i < vi->n_layers; i++) {
TarkinVideoLayer *layer = vi->layer + i;
- layer->desc.width = oggpack_read(opb,32);
- layer->desc.height = oggpack_read(opb,32);
- layer->desc.a_moments = oggpack_read(opb,32);
- layer->desc.s_moments = oggpack_read(opb,32);
- layer->desc.frames_per_buf = oggpack_read(opb,32);
- layer->desc.bitstream_len = oggpack_read(opb,32);
- layer->desc.format = oggpack_read(opb,32);
+
+ layer->desc.width = oggpack_read (opb, 32);
+ layer->desc.height = oggpack_read (opb, 32);
+ layer->desc.a_moments = oggpack_read (opb, 32);
+ layer->desc.s_moments = oggpack_read (opb, 32);
+ layer->desc.frames_per_buf = oggpack_read (opb, 32);
+ layer->desc.bitstream_len = oggpack_read (opb, 32);
+ layer->desc.format = oggpack_read (opb, 32);
switch (layer->desc.format) {
- case TARKIN_GRAYSCALE:
- layer->n_comp = 1;
- layer->color_fwd_xform = grayscale_to_y;
- layer->color_inv_xform = y_to_grayscale;
- break;
- case TARKIN_RGB24:
- layer->n_comp = 3;
- layer->color_fwd_xform = rgb24_to_yuv;
- layer->color_inv_xform = yuv_to_rgb24;
- break;
- case TARKIN_RGB32:
- layer->n_comp = 3;
- layer->color_fwd_xform = rgb32_to_yuv;
- layer->color_inv_xform = yuv_to_rgb32;
- break;
- case TARKIN_RGBA:
- layer->n_comp = 4;
- layer->color_fwd_xform = rgba_to_yuv;
- layer->color_inv_xform = yuv_to_rgba;
- break;
- default:
- return -TARKIN_INVALID_COLOR_FORMAT;
+ case TARKIN_GRAYSCALE:
+ layer->n_comp = 1;
+ layer->color_fwd_xform = grayscale_to_y;
+ layer->color_inv_xform = y_to_grayscale;
+ break;
+ case TARKIN_RGB24:
+ layer->n_comp = 3;
+ layer->color_fwd_xform = rgb24_to_yuv;
+ layer->color_inv_xform = yuv_to_rgb24;
+ break;
+ case TARKIN_RGB32:
+ layer->n_comp = 3;
+ layer->color_fwd_xform = rgb32_to_yuv;
+ layer->color_inv_xform = yuv_to_rgb32;
+ break;
+ case TARKIN_RGBA:
+ layer->n_comp = 4;
+ layer->color_fwd_xform = rgba_to_yuv;
+ layer->color_inv_xform = yuv_to_rgba;
+ break;
+ default:
+ return -TARKIN_INVALID_COLOR_FORMAT;
};
- layer->waveletbuf = (Wavelet3DBuf**) CALLOC (layer->n_comp,
- sizeof(Wavelet3DBuf*));
-
- layer->packet = MALLOC (layer->n_comp * sizeof(*layer->packet));
- memset(layer->packet, 0, layer->n_comp * sizeof(*layer->packet));
-
- for (j=0; j<layer->n_comp; j++){
- layer->waveletbuf[j] = wavelet_3d_buf_new (layer->desc.width,
- layer->desc.height,
- layer->desc.frames_per_buf);
- layer->packet[j].data = MALLOC(layer->desc.bitstream_len);
- layer->packet[j].storage = layer->desc.bitstream_len;
+ layer->waveletbuf = (Wavelet3DBuf **) CALLOC (layer->n_comp,
+ sizeof (Wavelet3DBuf *));
+
+ layer->packet = MALLOC (layer->n_comp * sizeof (*layer->packet));
+ memset (layer->packet, 0, layer->n_comp * sizeof (*layer->packet));
+
+ for (j = 0; j < layer->n_comp; j++) {
+ layer->waveletbuf[j] = wavelet_3d_buf_new (layer->desc.width,
+ layer->desc.height, layer->desc.frames_per_buf);
+ layer->packet[j].data = MALLOC (layer->desc.bitstream_len);
+ layer->packet[j].storage = layer->desc.bitstream_len;
}
- vi->max_bitstream_len += layer->desc.bitstream_len
- + 2 * 10 * sizeof(uint32_t) * layer->n_comp; /* truncation tables */
+ vi->max_bitstream_len += layer->desc.bitstream_len + 2 * 10 * sizeof (uint32_t) * layer->n_comp; /* truncation tables */
#ifdef DBG_OGG
- printf("\n layer%d: size %dx%dx%d, format %d, a_m %d, s_m %d, %d fpb\n",
- i, layer->desc.width, layer->desc.height, layer->n_comp,
- layer->desc.format, layer->desc.a_moments, layer->desc.s_moments,
- layer->desc.frames_per_buf);
+ printf
+ ("\n layer%d: size %dx%dx%d, format %d, a_m %d, s_m %d, %d fpb\n",
+ i, layer->desc.width, layer->desc.height, layer->n_comp,
+ layer->desc.format, layer->desc.a_moments, layer->desc.s_moments,
+ layer->desc.frames_per_buf);
#endif
- } /* for each layer */
-
- if(oggpack_read(opb,1)!=1)goto err_out; /* EOP check */
+ } /* for each layer */
+
+ if (oggpack_read (opb, 1) != 1)
+ goto err_out; /* EOP check */
#ifdef DBG_OGG
- printf("Success\n");
+ printf ("Success\n");
#endif
-
- return(0);
- err_out:
+
+ return (0);
+err_out:
#ifdef DBG_OGG
- printf("Failed\n");
+ printf ("Failed\n");
#endif
- tarkin_info_clear(vi);
- return(-TARKIN_BAD_HEADER);
+ tarkin_info_clear (vi);
+ return (-TARKIN_BAD_HEADER);
}
/* The Tarkin header is in three packets; the initial small packet in
with bitstream comments and a third packet that holds the
layer description structures. */
-TarkinError tarkin_synthesis_headerin(TarkinInfo *vi,TarkinComment *vc,ogg_packet *op){
+TarkinError
+tarkin_synthesis_headerin (TarkinInfo * vi, TarkinComment * vc, ogg_packet * op)
+{
oggpack_buffer opb;
-
- if(op){
- oggpack_readinit(&opb,op->packet,op->bytes);
+
+ if (op) {
+ oggpack_readinit (&opb, op->packet, op->bytes);
/* Which of the three types of header is this? */
/* Also verify header-ness, tarkin */
{
char buffer[6];
- int packtype=oggpack_read(&opb,8);
- memset(buffer,0,6);
- _v_readstring(&opb,buffer,6);
- if(memcmp(buffer,"tarkin",6)){
- /* not a tarkin header */
- return(-TARKIN_NOT_TARKIN);
- }
- switch(packtype){
- case 0x01: /* least significant *bit* is read first */
- if(!op->b_o_s){
- /* Not the initial packet */
- return(-TARKIN_BAD_HEADER);
- }
- if(vi->inter.numerator!=0){
- /* previously initialized info header */
- return(-TARKIN_BAD_HEADER);
- }
-
- return(_tarkin_unpack_info(vi,&opb));
-
- case 0x03: /* least significant *bit* is read first */
- if(vi->inter.denominator==0){
- /* um... we didn't get the initial header */
- return(-TARKIN_BAD_HEADER);
- }
-
- return(_tarkin_unpack_comment(vc,&opb));
-
- case 0x05: /* least significant *bit* is read first */
- if(vi->inter.numerator == 0 || vc->vendor==NULL){
- /* um... we didn;t get the initial header or comments yet */
- return(-TARKIN_BAD_HEADER);
- }
-
- return(_tarkin_unpack_layer_desc(vi,&opb));
+ int packtype = oggpack_read (&opb, 8);
- default:
- /* Not a valid tarkin header type */
- return(-TARKIN_BAD_HEADER);
- break;
+ memset (buffer, 0, 6);
+ _v_readstring (&opb, buffer, 6);
+ if (memcmp (buffer, "tarkin", 6)) {
+ /* not a tarkin header */
+ return (-TARKIN_NOT_TARKIN);
+ }
+ switch (packtype) {
+ case 0x01: /* least significant *bit* is read first */
+ if (!op->b_o_s) {
+ /* Not the initial packet */
+ return (-TARKIN_BAD_HEADER);
+ }
+ if (vi->inter.numerator != 0) {
+ /* previously initialized info header */
+ return (-TARKIN_BAD_HEADER);
+ }
+
+ return (_tarkin_unpack_info (vi, &opb));
+
+ case 0x03: /* least significant *bit* is read first */
+ if (vi->inter.denominator == 0) {
+ /* um... we didn't get the initial header */
+ return (-TARKIN_BAD_HEADER);
+ }
+
+ return (_tarkin_unpack_comment (vc, &opb));
+
+ case 0x05: /* least significant *bit* is read first */
+ if (vi->inter.numerator == 0 || vc->vendor == NULL) {
+ /* um... we didn;t get the initial header or comments yet */
+ return (-TARKIN_BAD_HEADER);
+ }
+
+ return (_tarkin_unpack_layer_desc (vi, &opb));
+
+ default:
+ /* Not a valid tarkin header type */
+ return (-TARKIN_BAD_HEADER);
+ break;
}
}
}
- return(-TARKIN_BAD_HEADER);
+ return (-TARKIN_BAD_HEADER);
}
/* pack side **********************************************************/
-static int _tarkin_pack_info(oggpack_buffer *opb,TarkinInfo *vi){
+static int
+_tarkin_pack_info (oggpack_buffer * opb, TarkinInfo * vi)
+{
- /* preamble */
- oggpack_write(opb,0x01,8);
- _v_writestring(opb,"tarkin", 6);
+ /* preamble */
+ oggpack_write (opb, 0x01, 8);
+ _v_writestring (opb, "tarkin", 6);
/* basic information about the stream */
- oggpack_write(opb,0x00,32);
- oggpack_write(opb,vi->n_layers,8);
- oggpack_write(opb,vi->inter.numerator,32);
- oggpack_write(opb,vi->inter.denominator,32);
+ oggpack_write (opb, 0x00, 32);
+ oggpack_write (opb, vi->n_layers, 8);
+ oggpack_write (opb, vi->inter.numerator, 32);
+ oggpack_write (opb, vi->inter.denominator, 32);
- oggpack_write(opb,vi->bitrate_upper,32);
- oggpack_write(opb,vi->bitrate_nominal,32);
- oggpack_write(opb,vi->bitrate_lower,32);
+ oggpack_write (opb, vi->bitrate_upper, 32);
+ oggpack_write (opb, vi->bitrate_nominal, 32);
+ oggpack_write (opb, vi->bitrate_lower, 32);
- oggpack_write(opb,1,1);
+ oggpack_write (opb, 1, 1);
#ifdef DBG_OGG
- printf("dbg_ogg: Putting out info, inter %d/%d, n_layers %d\n",
- vi->inter.numerator,vi->inter.denominator,vi->n_layers);
+ printf ("dbg_ogg: Putting out info, inter %d/%d, n_layers %d\n",
+ vi->inter.numerator, vi->inter.denominator, vi->n_layers);
#endif
- return(0);
+ return (0);
}
-static int _tarkin_pack_comment(oggpack_buffer *opb,TarkinComment *vc){
- char temp[]="libTarkin debugging edition 20011104";
- int bytes = strlen(temp);
+static int
+_tarkin_pack_comment (oggpack_buffer * opb, TarkinComment * vc)
+{
+ char temp[] = "libTarkin debugging edition 20011104";
+ int bytes = strlen (temp);
- /* preamble */
- oggpack_write(opb,0x03,8);
- _v_writestring(opb,"tarkin", 6);
+ /* preamble */
+ oggpack_write (opb, 0x03, 8);
+ _v_writestring (opb, "tarkin", 6);
/* vendor */
- oggpack_write(opb,bytes,32);
- _v_writestring(opb,temp, bytes);
-
+ oggpack_write (opb, bytes, 32);
+ _v_writestring (opb, temp, bytes);
+
/* comments */
- oggpack_write(opb,vc->comments,32);
- if(vc->comments){
+ oggpack_write (opb, vc->comments, 32);
+ if (vc->comments) {
int i;
- for(i=0;i<vc->comments;i++){
- if(vc->user_comments[i]){
- oggpack_write(opb,vc->comment_lengths[i],32);
- _v_writestring(opb,vc->user_comments[i], vc->comment_lengths[i]);
- }else{
- oggpack_write(opb,0,32);
+
+ for (i = 0; i < vc->comments; i++) {
+ if (vc->user_comments[i]) {
+ oggpack_write (opb, vc->comment_lengths[i], 32);
+ _v_writestring (opb, vc->user_comments[i], vc->comment_lengths[i]);
+ } else {
+ oggpack_write (opb, 0, 32);
}
}
}
- oggpack_write(opb,1,1);
+ oggpack_write (opb, 1, 1);
#ifdef DBG_OGG
- printf("dbg_ogg: Putting out %d comments\n", vc->comments);
+ printf ("dbg_ogg: Putting out %d comments\n", vc->comments);
#endif
-
- return(0);
+
+ return (0);
}
-
-static int _tarkin_pack_layer_desc(oggpack_buffer *opb,TarkinInfo *vi)
+
+static int
+_tarkin_pack_layer_desc (oggpack_buffer * opb, TarkinInfo * vi)
{
int i;
TarkinVideoLayer *layer;
#ifdef DBG_OGG
- printf("dbg_ogg: Putting out layers description:\n");
+ printf ("dbg_ogg: Putting out layers description:\n");
#endif
- oggpack_write(opb,0x05,8);
- _v_writestring(opb,"tarkin", 6);
+ oggpack_write (opb, 0x05, 8);
+ _v_writestring (opb, "tarkin", 6);
- for(i=0;i<vi->n_layers;i++){
+ for (i = 0; i < vi->n_layers; i++) {
layer = vi->layer + i;
- oggpack_write(opb,layer->desc.width,32);
- oggpack_write(opb,layer->desc.height,32);
- oggpack_write(opb,layer->desc.a_moments,32);
- oggpack_write(opb,layer->desc.s_moments,32);
- oggpack_write(opb,layer->desc.frames_per_buf,32);
- oggpack_write(opb,layer->desc.bitstream_len,32);
- oggpack_write(opb,layer->desc.format,32);
+ oggpack_write (opb, layer->desc.width, 32);
+ oggpack_write (opb, layer->desc.height, 32);
+ oggpack_write (opb, layer->desc.a_moments, 32);
+ oggpack_write (opb, layer->desc.s_moments, 32);
+ oggpack_write (opb, layer->desc.frames_per_buf, 32);
+ oggpack_write (opb, layer->desc.bitstream_len, 32);
+ oggpack_write (opb, layer->desc.format, 32);
#ifdef DBG_OGG
- printf(" res. %dx%d, format %d, a_m %d, s_m %d, fpb %d\n",
- layer->desc.width, layer->desc.height, layer->desc.format,
- layer->desc.a_moments, layer->desc.s_moments,
- layer->desc.frames_per_buf);
+ printf (" res. %dx%d, format %d, a_m %d, s_m %d, fpb %d\n",
+ layer->desc.width, layer->desc.height, layer->desc.format,
+ layer->desc.a_moments, layer->desc.s_moments,
+ layer->desc.frames_per_buf);
#endif
-
+
}
- oggpack_write(opb,1,1);
+ oggpack_write (opb, 1, 1);
#ifdef DBG_OGG
- printf(" wrote %ld bytes.\n", oggpack_bytes(opb));
+ printf (" wrote %ld bytes.\n", oggpack_bytes (opb));
#endif
-
- return(0);
-}
-int tarkin_comment_header_out(TarkinComment *vc, ogg_packet *op)
+ return (0);
+}
+
+int
+tarkin_comment_header_out (TarkinComment * vc, ogg_packet * op)
{
oggpack_buffer opb;
- oggpack_writeinit(&opb);
- if(_tarkin_pack_comment(&opb,vc)) return -TARKIN_NOT_IMPLEMENTED;
+ oggpack_writeinit (&opb);
+ if (_tarkin_pack_comment (&opb, vc))
+ return -TARKIN_NOT_IMPLEMENTED;
- op->packet = MALLOC(oggpack_bytes(&opb));
- memcpy(op->packet, opb.buffer, oggpack_bytes(&opb));
+ op->packet = MALLOC (oggpack_bytes (&opb));
+ memcpy (op->packet, opb.buffer, oggpack_bytes (&opb));
- op->bytes=oggpack_bytes(&opb);
- op->b_o_s=0;
- op->e_o_s=0;
- op->granulepos=0;
+ op->bytes = oggpack_bytes (&opb);
+ op->b_o_s = 0;
+ op->e_o_s = 0;
+ op->granulepos = 0;
return 0;
}
-TarkinError tarkin_analysis_headerout(TarkinStream *v,
- TarkinComment *vc,
- ogg_packet *op,
- ogg_packet *op_comm,
- ogg_packet *op_code)
+TarkinError
+tarkin_analysis_headerout (TarkinStream * v,
+ TarkinComment * vc,
+ ogg_packet * op, ogg_packet * op_comm, ogg_packet * op_code)
{
- int ret=-TARKIN_NOT_IMPLEMENTED;
- TarkinInfo * vi;
- oggpack_buffer opb;
- tarkin_header_store *b=&v->headers;
-
- vi = v->ti;
-
- /* first header packet **********************************************/
-
- oggpack_writeinit(&opb);
- if(_tarkin_pack_info(&opb,vi))goto err_out;
-
- /* build the packet */
- if(b->header)FREE(b->header);
- b->header=MALLOC(oggpack_bytes(&opb));
- memcpy(b->header,opb.buffer,oggpack_bytes(&opb));
- op->packet=b->header;
- op->bytes=oggpack_bytes(&opb);
- op->b_o_s=1;
- op->e_o_s=0;
- op->granulepos=0;
-
- /* second header packet (comments) **********************************/
-
- oggpack_reset(&opb);
- if(_tarkin_pack_comment(&opb,vc))goto err_out;
-
- if(b->header1)FREE(b->header1);
- b->header1=MALLOC(oggpack_bytes(&opb));
- memcpy(b->header1,opb.buffer,oggpack_bytes(&opb));
- op_comm->packet=b->header1;
- op_comm->bytes=oggpack_bytes(&opb);
- op_comm->b_o_s=0;
- op_comm->e_o_s=0;
- op_comm->granulepos=0;
-
- /* third header packet (modes/codebooks) ****************************/
-
- oggpack_reset(&opb);
- if(_tarkin_pack_layer_desc(&opb,vi))goto err_out;
-
- if(b->header2)FREE(b->header2);
- b->header2=MALLOC(oggpack_bytes(&opb));
- memcpy(b->header2,opb.buffer,oggpack_bytes(&opb));
- op_code->packet=b->header2;
- op_code->bytes=oggpack_bytes(&opb);
- op_code->b_o_s=0;
- op_code->e_o_s=0;
- op_code->granulepos=0;
-
- oggpack_writeclear(&opb);
- return(0);
- err_out:
- oggpack_writeclear(&opb);
- memset(op,0,sizeof(*op));
- memset(op_comm,0,sizeof(*op_comm));
- memset(op_code,0,sizeof(*op_code));
-
- if(b->header)FREE(b->header);
- if(b->header1)FREE(b->header1);
- if(b->header2)FREE(b->header2);
- b->header=NULL;
- b->header1=NULL;
- b->header2=NULL;
- return(ret);
+ int ret = -TARKIN_NOT_IMPLEMENTED;
+ TarkinInfo *vi;
+ oggpack_buffer opb;
+ tarkin_header_store *b = &v->headers;
+
+ vi = v->ti;
+
+ /* first header packet ********************************************* */
+
+ oggpack_writeinit (&opb);
+ if (_tarkin_pack_info (&opb, vi))
+ goto err_out;
+
+ /* build the packet */
+ if (b->header)
+ FREE (b->header);
+ b->header = MALLOC (oggpack_bytes (&opb));
+ memcpy (b->header, opb.buffer, oggpack_bytes (&opb));
+ op->packet = b->header;
+ op->bytes = oggpack_bytes (&opb);
+ op->b_o_s = 1;
+ op->e_o_s = 0;
+ op->granulepos = 0;
+
+ /* second header packet (comments) ********************************* */
+
+ oggpack_reset (&opb);
+ if (_tarkin_pack_comment (&opb, vc))
+ goto err_out;
+
+ if (b->header1)
+ FREE (b->header1);
+ b->header1 = MALLOC (oggpack_bytes (&opb));
+ memcpy (b->header1, opb.buffer, oggpack_bytes (&opb));
+ op_comm->packet = b->header1;
+ op_comm->bytes = oggpack_bytes (&opb);
+ op_comm->b_o_s = 0;
+ op_comm->e_o_s = 0;
+ op_comm->granulepos = 0;
+
+ /* third header packet (modes/codebooks) *************************** */
+
+ oggpack_reset (&opb);
+ if (_tarkin_pack_layer_desc (&opb, vi))
+ goto err_out;
+
+ if (b->header2)
+ FREE (b->header2);
+ b->header2 = MALLOC (oggpack_bytes (&opb));
+ memcpy (b->header2, opb.buffer, oggpack_bytes (&opb));
+ op_code->packet = b->header2;
+ op_code->bytes = oggpack_bytes (&opb);
+ op_code->b_o_s = 0;
+ op_code->e_o_s = 0;
+ op_code->granulepos = 0;
+
+ oggpack_writeclear (&opb);
+ return (0);
+err_out:
+ oggpack_writeclear (&opb);
+ memset (op, 0, sizeof (*op));
+ memset (op_comm, 0, sizeof (*op_comm));
+ memset (op_code, 0, sizeof (*op_code));
+
+ if (b->header)
+ FREE (b->header);
+ if (b->header1)
+ FREE (b->header1);
+ if (b->header2)
+ FREE (b->header2);
+ b->header = NULL;
+ b->header1 = NULL;
+ b->header2 = NULL;
+ return (ret);
}
-
#if defined(DBG_MEMLEAKS)
-typedef struct {
- void *mem;
- char *allocated_in_func;
- char *allocated_in_file;
- unsigned int allocated_in_line;
+typedef struct
+{
+ void *mem;
+ char *allocated_in_func;
+ char *allocated_in_file;
+ unsigned int allocated_in_line;
} MemDesc;
static MemDesc *alloc_list = NULL;
-static
-void dbg_memleaks_done (int exitcode, void *dummy)
+static void
+dbg_memleaks_done (int exitcode, void *dummy)
{
- unsigned int i;
- (void) dummy;
-
- if (exitcode == 0 && alloc_count != 0) {
- fprintf (stderr, "\nmemory leak detected !!!\n");
- fprintf (stderr, "\nalloc_count == %i\n\n", alloc_count);
- for (i=0; i<alloc_count; i++) {
- MemDesc *d = &alloc_list[i];
- fprintf (stderr, "chunk %p allocated in %s (%s: %u) not free'd !!\n",
- d->mem, d->allocated_in_func, d->allocated_in_file,
- d->allocated_in_line);
- }
- free(alloc_list);
- }
- fprintf (stderr, "\n");
+ unsigned int i;
+
+ (void) dummy;
+
+ if (exitcode == 0 && alloc_count != 0) {
+ fprintf (stderr, "\nmemory leak detected !!!\n");
+ fprintf (stderr, "\nalloc_count == %i\n\n", alloc_count);
+ for (i = 0; i < alloc_count; i++) {
+ MemDesc *d = &alloc_list[i];
+
+ fprintf (stderr, "chunk %p allocated in %s (%s: %u) not free'd !!\n",
+ d->mem, d->allocated_in_func, d->allocated_in_file,
+ d->allocated_in_line);
+ }
+ free (alloc_list);
+ }
+ fprintf (stderr, "\n");
}
-static
-void dbg_memleaks_init (void)
+static void
+dbg_memleaks_init (void)
{
- on_exit (dbg_memleaks_done, NULL);
- initialized = 1;
+ on_exit (dbg_memleaks_done, NULL);
+ initialized = 1;
}
-void* dbg_malloc (char* file, int line, char *func, size_t bytes)
+void *
+dbg_malloc (char *file, int line, char *func, size_t bytes)
{
- void *mem = (void*) malloc (bytes);
- MemDesc *d;
+ void *mem = (void *) malloc (bytes);
+ MemDesc *d;
- if (!initialized)
- dbg_memleaks_init();
+ if (!initialized)
+ dbg_memleaks_init ();
- alloc_count++;
- alloc_list = realloc (alloc_list, alloc_count * sizeof(MemDesc));
+ alloc_count++;
+ alloc_list = realloc (alloc_list, alloc_count * sizeof (MemDesc));
- d = &alloc_list[alloc_count-1];
- d->mem = mem;
- d->allocated_in_func = func;
- d->allocated_in_file = file;
- d->allocated_in_line = line;
+ d = &alloc_list[alloc_count - 1];
+ d->mem = mem;
+ d->allocated_in_func = func;
+ d->allocated_in_file = file;
+ d->allocated_in_line = line;
- return mem;
+ return mem;
}
-void* dbg_calloc (char* file, int line, char *func, size_t count, size_t bytes)
+void *
+dbg_calloc (char *file, int line, char *func, size_t count, size_t bytes)
{
- void *mem = (void*) calloc (count, bytes);
- MemDesc *d;
+ void *mem = (void *) calloc (count, bytes);
+ MemDesc *d;
- if (!initialized)
- dbg_memleaks_init();
+ if (!initialized)
+ dbg_memleaks_init ();
- alloc_count++;
- alloc_list = realloc (alloc_list, alloc_count * sizeof(MemDesc));
+ alloc_count++;
+ alloc_list = realloc (alloc_list, alloc_count * sizeof (MemDesc));
- d = &alloc_list[alloc_count-1];
- d->mem = mem;
- d->allocated_in_func = func;
- d->allocated_in_file = file;
- d->allocated_in_line = line;
+ d = &alloc_list[alloc_count - 1];
+ d->mem = mem;
+ d->allocated_in_func = func;
+ d->allocated_in_file = file;
+ d->allocated_in_line = line;
- return mem;
+ return mem;
}
-void* dbg_realloc (char *file, int line, char *func, char *what,
- void *mem, size_t bytes)
+void *
+dbg_realloc (char *file, int line, char *func, char *what,
+ void *mem, size_t bytes)
{
- unsigned int i;
-
- for (i=0; i<alloc_count; i++) {
- if (alloc_list[i].mem == mem) {
- alloc_list[i].mem = (void*) realloc (mem, bytes);
- return alloc_list[i].mem;
- }
- }
-
- if (mem != NULL) {
- fprintf (stderr,
- "%s: trying to reallocate unknown chunk %p (%s)\n"
- " in %s (%s: %u) !!!\n",
- __FUNCTION__, mem, what, func, file, line);
- exit (-1);
- }
-
- return dbg_malloc(file, line, func, bytes);
+ unsigned int i;
+
+ for (i = 0; i < alloc_count; i++) {
+ if (alloc_list[i].mem == mem) {
+ alloc_list[i].mem = (void *) realloc (mem, bytes);
+ return alloc_list[i].mem;
+ }
+ }
+
+ if (mem != NULL) {
+ fprintf (stderr,
+ "%s: trying to reallocate unknown chunk %p (%s)\n"
+ " in %s (%s: %u) !!!\n",
+ __FUNCTION__, mem, what, func, file, line);
+ exit (-1);
+ }
+
+ return dbg_malloc (file, line, func, bytes);
}
-void dbg_free (char *file, int line, char *func, char *what, void *mem)
+void
+dbg_free (char *file, int line, char *func, char *what, void *mem)
{
- unsigned int i;
-
- if (!initialized)
- dbg_memleaks_init();
-
- for (i=0; i<alloc_count; i++) {
- if (alloc_list[i].mem == mem) {
- free (mem);
- alloc_count--;
- memmove (&alloc_list[i], &alloc_list[i+1],
- (alloc_count - i) * sizeof(MemDesc));
- return;
- }
- }
-
- fprintf (stderr, "%s: trying to free unknown chunk %p (%s)\n"
- " in %s (%s: %u) !!!\n",
- __FUNCTION__, mem, what, func, file, line);
- exit (-1);
+ unsigned int i;
+
+ if (!initialized)
+ dbg_memleaks_init ();
+
+ for (i = 0; i < alloc_count; i++) {
+ if (alloc_list[i].mem == mem) {
+ free (mem);
+ alloc_count--;
+ memmove (&alloc_list[i], &alloc_list[i + 1],
+ (alloc_count - i) * sizeof (MemDesc));
+ return;
+ }
+ }
+
+ fprintf (stderr, "%s: trying to free unknown chunk %p (%s)\n"
+ " in %s (%s: %u) !!!\n",
+ __FUNCTION__, mem, what, func, file, line);
+ exit (-1);
}
#endif
-
#if defined(DBG_MEMLEAKS)
-extern void* dbg_malloc (char *file, int line, char *func, size_t bytes);
-extern void* dbg_calloc (char *file, int line, char *func, size_t count, size_t bytes);
-extern void* dbg_realloc (char *file, int line, char *func, char *what, void *mem, size_t bytes);
+extern void *dbg_malloc (char *file, int line, char *func, size_t bytes);
+extern void *dbg_calloc (char *file, int line, char *func, size_t count,
+ size_t bytes);
+extern void *dbg_realloc (char *file, int line, char *func, char *what,
+ void *mem, size_t bytes);
extern void dbg_free (char *file, int line, char *func, char *what, void *mem);
#define MALLOC(bytes) dbg_malloc(__FILE__,__LINE__,__FUNCTION__,bytes)
#endif
#endif
-
#define ENTROPY_ENCODER_FLUSH(coder) rlecoder_encoder_flush(coder)
#define ENTROPY_DECODER_INIT(coder,bitstream,limit) \
rlecoder_decoder_init(coder,bitstream,limit)
-#define ENTROPY_DECODER_DONE(coder) /* nothing to do ... */
+#define ENTROPY_DECODER_DONE(coder) /* nothing to do ... */
#define ENTROPY_CODER_BITSTREAM(coder) ((coder)->bitcoder.bitstream)
#define ENTROPY_CODER_EOS(coder) ((coder)->bitcoder.eos)
-typedef struct {
- int symbol;
- uint32_t count; /* have seen count symbol's */
- BitCoderState bitcoder;
- GolombAdaptiveCoderState golomb_state [2]; /* 2 states for 2 symbols... */
- int have_seen_1;
+typedef struct
+{
+ int symbol;
+ uint32_t count; /* have seen count symbol's */
+ BitCoderState bitcoder;
+ GolombAdaptiveCoderState golomb_state[2]; /* 2 states for 2 symbols... */
+ int have_seen_1;
} RLECoderState;
/*
* bit should be 0 or 1 !!!
*/
-static inline
-void rlecoder_write_bit (RLECoderState *s, int bit)
+static inline void
+rlecoder_write_bit (RLECoderState * s, int bit)
{
- assert (bit == 0 || bit == 1);
-
- if (s->symbol == -1) {
- s->symbol = bit & 1;
- s->count = 1;
- s->have_seen_1 = bit;
- bitcoder_write_bit (&s->bitcoder, bit);
- }
-
- if (s->symbol != bit) {
- golombcoder_encode_number (&s->golomb_state[s->symbol],
- &s->bitcoder, s->count);
- s->symbol = ~s->symbol & 1;
- s->have_seen_1 = 1;
- s->count = 1;
- } else
- s->count++;
+ assert (bit == 0 || bit == 1);
+
+ if (s->symbol == -1) {
+ s->symbol = bit & 1;
+ s->count = 1;
+ s->have_seen_1 = bit;
+ bitcoder_write_bit (&s->bitcoder, bit);
+ }
+
+ if (s->symbol != bit) {
+ golombcoder_encode_number (&s->golomb_state[s->symbol],
+ &s->bitcoder, s->count);
+ s->symbol = ~s->symbol & 1;
+ s->have_seen_1 = 1;
+ s->count = 1;
+ } else
+ s->count++;
}
-static inline
-int rlecoder_read_bit (RLECoderState *s)
+static inline int
+rlecoder_read_bit (RLECoderState * s)
{
- if (s->count == 0) {
- s->symbol = ~s->symbol & 1;
- s->count = golombcoder_decode_number (&s->golomb_state[s->symbol],
- &s->bitcoder);
- if (s->bitcoder.eos) {
- s->symbol = 0;
- s->count = ~0;
- }
- }
- s->count--;
- return (s->symbol);
+ if (s->count == 0) {
+ s->symbol = ~s->symbol & 1;
+ s->count = golombcoder_decode_number (&s->golomb_state[s->symbol],
+ &s->bitcoder);
+ if (s->bitcoder.eos) {
+ s->symbol = 0;
+ s->count = ~0;
+ }
+ }
+ s->count--;
+ return (s->symbol);
}
int coder_id = 0;
FILE *file = NULL;
-static inline
-void rlecoder_encoder_init (RLECoderState *s, uint32_t limit)
+static inline void
+rlecoder_encoder_init (RLECoderState * s, uint32_t limit)
{
- bitcoder_encoder_init (&s->bitcoder, limit);
- s->symbol = -1;
- s->have_seen_1 = 0;
- s->golomb_state[0].count = 0;
- s->golomb_state[1].count = 0;
- s->golomb_state[0].bits = 5 << 3;
- s->golomb_state[1].bits = 5 << 3;
+ bitcoder_encoder_init (&s->bitcoder, limit);
+ s->symbol = -1;
+ s->have_seen_1 = 0;
+ s->golomb_state[0].count = 0;
+ s->golomb_state[1].count = 0;
+ s->golomb_state[0].bits = 5 << 3;
+ s->golomb_state[1].bits = 5 << 3;
}
/**
* once you called this, you better should not encode any more symbols ...
*/
-static inline
-uint32_t rlecoder_encoder_flush (RLECoderState *s)
+static inline uint32_t
+rlecoder_encoder_flush (RLECoderState * s)
{
- if (s->symbol == -1 || !s->have_seen_1)
- return 0;
+ if (s->symbol == -1 || !s->have_seen_1)
+ return 0;
- golombcoder_encode_number (&s->golomb_state[s->symbol],
- &s->bitcoder, s->count);
- return bitcoder_flush (&s->bitcoder);
+ golombcoder_encode_number (&s->golomb_state[s->symbol],
+ &s->bitcoder, s->count);
+ return bitcoder_flush (&s->bitcoder);
}
-static inline
-void rlecoder_decoder_init (RLECoderState *s, uint8_t *bitstream, uint32_t limit)
+static inline void
+rlecoder_decoder_init (RLECoderState * s, uint8_t * bitstream, uint32_t limit)
{
- bitcoder_decoder_init (&s->bitcoder, bitstream, limit);
- s->golomb_state[0].count = 0;
- s->golomb_state[1].count = 0;
- s->golomb_state[0].bits = 5 << 3;
- s->golomb_state[1].bits = 5 << 3;
- s->symbol = bitcoder_read_bit (&s->bitcoder);
- s->count = golombcoder_decode_number (&s->golomb_state[s->symbol],
- &s->bitcoder) - 1;
- if (s->bitcoder.eos) {
- s->symbol = 0;
- s->count = ~0;
- }
+ bitcoder_decoder_init (&s->bitcoder, bitstream, limit);
+ s->golomb_state[0].count = 0;
+ s->golomb_state[1].count = 0;
+ s->golomb_state[0].bits = 5 << 3;
+ s->golomb_state[1].bits = 5 << 3;
+ s->symbol = bitcoder_read_bit (&s->bitcoder);
+ s->count = golombcoder_decode_number (&s->golomb_state[s->symbol],
+ &s->bitcoder) - 1;
+ if (s->bitcoder.eos) {
+ s->symbol = 0;
+ s->count = ~0;
+ }
}
-static inline
-void rlecoder_encoder_done (RLECoderState *s)
+static inline void
+rlecoder_encoder_done (RLECoderState * s)
{
- bitcoder_encoder_done (&s->bitcoder);
+ bitcoder_encoder_done (&s->bitcoder);
}
#endif
-
-TarkinStream* tarkin_stream_new ()
+TarkinStream *
+tarkin_stream_new ()
{
- TarkinStream *s = (TarkinStream*) CALLOC (1, sizeof(TarkinStream));
+ TarkinStream *s = (TarkinStream *) CALLOC (1, sizeof (TarkinStream));
- if (!s)
- return NULL;
- memset(s,0,sizeof(*s));
+ if (!s)
+ return NULL;
+ memset (s, 0, sizeof (*s));
- s->frames_per_buf = N_FRAMES;
+ s->frames_per_buf = N_FRAMES;
- return s;
+ return s;
}
-void tarkin_stream_destroy (TarkinStream *s)
+void
+tarkin_stream_destroy (TarkinStream * s)
{
- uint32_t i, j;
-
- if (!s)
- return;
-
- for (i=0; i<s->n_layers; i++) {
- if (s->layer[i].waveletbuf) {
- for (j=0; j<s->layer[i].n_comp; j++) {
- wavelet_3d_buf_destroy (s->layer[i].waveletbuf[j]);
- FREE (s->layer[i].packet[j].data);
- }
- FREE(s->layer[i].waveletbuf);
- FREE(s->layer[i].packet);
+ uint32_t i, j;
+
+ if (!s)
+ return;
+
+ for (i = 0; i < s->n_layers; i++) {
+ if (s->layer[i].waveletbuf) {
+ for (j = 0; j < s->layer[i].n_comp; j++) {
+ wavelet_3d_buf_destroy (s->layer[i].waveletbuf[j]);
+ FREE (s->layer[i].packet[j].data);
}
- }
-
- if (s->layer)
- FREE(s->layer);
+ FREE (s->layer[i].waveletbuf);
+ FREE (s->layer[i].packet);
+ }
+ }
+
+ if (s->layer)
+ FREE (s->layer);
- if (s->headers.header)
- FREE(s->headers.header);
+ if (s->headers.header)
+ FREE (s->headers.header);
- if (s->headers.header1)
- FREE(s->headers.header1);
+ if (s->headers.header1)
+ FREE (s->headers.header1);
- if (s->headers.header2)
- FREE(s->headers.header2);
+ if (s->headers.header2)
+ FREE (s->headers.header2);
- FREE(s);
+ FREE (s);
}
-int tarkin_analysis_init(TarkinStream *s, TarkinInfo *ti,
- TarkinError (*free_frame)(void *s, void *ptr),
- TarkinError (*packet_out)(void *s, ogg_packet *ptr),
- void *user_ptr)
+int
+tarkin_analysis_init (TarkinStream * s, TarkinInfo * ti,
+ TarkinError (*free_frame) (void *s, void *ptr),
+ TarkinError (*packet_out) (void *s, ogg_packet * ptr), void *user_ptr)
{
- if((!ti->inter.numerator)||(!ti->inter.denominator))return (-TARKIN_FAULT);
- if((!free_frame) || (!packet_out)) return (-TARKIN_FAULT);
- s->ti = ti;
- s->free_frame = free_frame;
- s->packet_out = packet_out;
- s->user_ptr = user_ptr;
- return(0);
+ if ((!ti->inter.numerator) || (!ti->inter.denominator))
+ return (-TARKIN_FAULT);
+ if ((!free_frame) || (!packet_out))
+ return (-TARKIN_FAULT);
+ s->ti = ti;
+ s->free_frame = free_frame;
+ s->packet_out = packet_out;
+ s->user_ptr = user_ptr;
+ return (0);
}
-extern int tarkin_analysis_add_layer(TarkinStream *s,
- TarkinVideoLayerDesc *tvld)
+extern int
+tarkin_analysis_add_layer (TarkinStream * s, TarkinVideoLayerDesc * tvld)
{
- int i;
- TarkinVideoLayer *layer;
- if(s->n_layers) {
- s->layer = REALLOC(s->layer,(s->n_layers+1) * sizeof(*s->layer));
- } else {
- s->layer = MALLOC(sizeof(*s->layer));
- }
- layer = s->layer + s->n_layers;
- memset(layer,0,sizeof(*s->layer));
- memcpy (&layer->desc , tvld, sizeof(TarkinVideoLayerDesc));
-
- s->n_layers++;
- s->ti->n_layers = s->n_layers;
- s->ti->layer = s->layer;
-
- switch (layer->desc.format) {
- case TARKIN_GRAYSCALE:
- layer->n_comp = 1;
- layer->color_fwd_xform = grayscale_to_y;
- layer->color_inv_xform = y_to_grayscale;
- break;
- case TARKIN_RGB24:
- layer->n_comp = 3;
- layer->color_fwd_xform = rgb24_to_yuv;
- layer->color_inv_xform = yuv_to_rgb24;
- break;
- case TARKIN_RGB32:
- layer->n_comp = 3;
- layer->color_fwd_xform = rgb32_to_yuv;
- layer->color_inv_xform = yuv_to_rgb32;
- break;
- case TARKIN_RGBA:
- layer->n_comp = 4;
- layer->color_fwd_xform = rgba_to_yuv;
- layer->color_inv_xform = yuv_to_rgba;
- break;
- default:
- return -TARKIN_INVALID_COLOR_FORMAT;
- };
-
-#ifdef DBG_OGG
- printf("dbg_ogg:add_layer %d with %d components\n",
- s->n_layers, layer->n_comp);
-#endif
-
- layer->waveletbuf = (Wavelet3DBuf**) CALLOC (layer->n_comp,
- sizeof(Wavelet3DBuf*));
-
- layer->packet = MALLOC (layer->n_comp * sizeof(*layer->packet));
- memset(layer->packet, 0, layer->n_comp * sizeof(*layer->packet));
-
- for (i=0; i<layer->n_comp; i++){
- layer->waveletbuf[i] = wavelet_3d_buf_new (layer->desc.width,
- layer->desc.height,
- layer->desc.frames_per_buf);
- layer->packet[i].data = MALLOC(layer->desc.bitstream_len);
- layer->packet[i].storage = layer->desc.bitstream_len;
- }
- /*
- max_bitstream_len += layer->desc.bitstream_len
- + 2 * 10 * sizeof(uint32_t) * layer->n_comp;
+ int i;
+ TarkinVideoLayer *layer;
+
+ if (s->n_layers) {
+ s->layer = REALLOC (s->layer, (s->n_layers + 1) * sizeof (*s->layer));
+ } else {
+ s->layer = MALLOC (sizeof (*s->layer));
+ }
+ layer = s->layer + s->n_layers;
+ memset (layer, 0, sizeof (*s->layer));
+ memcpy (&layer->desc, tvld, sizeof (TarkinVideoLayerDesc));
+
+ s->n_layers++;
+ s->ti->n_layers = s->n_layers;
+ s->ti->layer = s->layer;
+
+ switch (layer->desc.format) {
+ case TARKIN_GRAYSCALE:
+ layer->n_comp = 1;
+ layer->color_fwd_xform = grayscale_to_y;
+ layer->color_inv_xform = y_to_grayscale;
+ break;
+ case TARKIN_RGB24:
+ layer->n_comp = 3;
+ layer->color_fwd_xform = rgb24_to_yuv;
+ layer->color_inv_xform = yuv_to_rgb24;
+ break;
+ case TARKIN_RGB32:
+ layer->n_comp = 3;
+ layer->color_fwd_xform = rgb32_to_yuv;
+ layer->color_inv_xform = yuv_to_rgb32;
+ break;
+ case TARKIN_RGBA:
+ layer->n_comp = 4;
+ layer->color_fwd_xform = rgba_to_yuv;
+ layer->color_inv_xform = yuv_to_rgba;
+ break;
+ default:
+ return -TARKIN_INVALID_COLOR_FORMAT;
+ };
+
+#ifdef DBG_OGG
+ printf ("dbg_ogg:add_layer %d with %d components\n",
+ s->n_layers, layer->n_comp);
+#endif
+
+ layer->waveletbuf = (Wavelet3DBuf **) CALLOC (layer->n_comp,
+ sizeof (Wavelet3DBuf *));
+
+ layer->packet = MALLOC (layer->n_comp * sizeof (*layer->packet));
+ memset (layer->packet, 0, layer->n_comp * sizeof (*layer->packet));
+
+ for (i = 0; i < layer->n_comp; i++) {
+ layer->waveletbuf[i] = wavelet_3d_buf_new (layer->desc.width,
+ layer->desc.height, layer->desc.frames_per_buf);
+ layer->packet[i].data = MALLOC (layer->desc.bitstream_len);
+ layer->packet[i].storage = layer->desc.bitstream_len;
+ }
+ /*
+ max_bitstream_len += layer->desc.bitstream_len
+ + 2 * 10 * sizeof(uint32_t) * layer->n_comp;
*/
- return (TARKIN_OK);
+ return (TARKIN_OK);
}
-TarkinError _analysis_packetout(TarkinStream *s, uint32_t layer_id,
- uint32_t comp)
+TarkinError
+_analysis_packetout (TarkinStream * s, uint32_t layer_id, uint32_t comp)
{
- ogg_packet op;
- oggpack_buffer opb;
- uint8_t *data;
- uint32_t data_len;
- int i;
- data = s->layer[layer_id].packet[comp].data;
- data_len = s->layer[layer_id].packet[comp].data_len;
-
- oggpack_writeinit(&opb);
- oggpack_write(&opb,0,8); /* No feature flags for now */
- oggpack_write(&opb,layer_id,12);
- oggpack_write(&opb,comp,12);
- for(i=0;i<data_len;i++)
- oggpack_write(&opb,*(data + i), 8);
-
- op.b_o_s = 0;
- op.e_o_s = data_len?0:1;
- op.granulepos = 0;
- op.bytes = oggpack_bytes(&opb)+4;
- op.packet = opb.buffer;
+ ogg_packet op;
+ oggpack_buffer opb;
+ uint8_t *data;
+ uint32_t data_len;
+ int i;
+
+ data = s->layer[layer_id].packet[comp].data;
+ data_len = s->layer[layer_id].packet[comp].data_len;
+
+ oggpack_writeinit (&opb);
+ oggpack_write (&opb, 0, 8); /* No feature flags for now */
+ oggpack_write (&opb, layer_id, 12);
+ oggpack_write (&opb, comp, 12);
+ for (i = 0; i < data_len; i++)
+ oggpack_write (&opb, *(data + i), 8);
+
+ op.b_o_s = 0;
+ op.e_o_s = data_len ? 0 : 1;
+ op.granulepos = 0;
+ op.bytes = oggpack_bytes (&opb) + 4;
+ op.packet = opb.buffer;
#ifdef DBG_OGG
- printf("dbg_ogg: writing packet layer %d, comp %d, data_len %d %s\n",
- layer_id, comp, data_len, op.e_o_s?"eos":"");
+ printf ("dbg_ogg: writing packet layer %d, comp %d, data_len %d %s\n",
+ layer_id, comp, data_len, op.e_o_s ? "eos" : "");
#endif
- s->layer[layer_id].packet[comp].data_len = 0; /* so direct call => eos */
- return(s->packet_out(s,&op));
+ s->layer[layer_id].packet[comp].data_len = 0; /* so direct call => eos */
+ return (s->packet_out (s, &op));
}
-void _stream_flush (TarkinStream *s)
+void
+_stream_flush (TarkinStream * s)
{
- uint32_t i, j;
+ uint32_t i, j;
- s->current_frame_in_buf=0;
+ s->current_frame_in_buf = 0;
- for (i=0; i<s->n_layers; i++) {
- TarkinVideoLayer *layer = &s->layer[i];
+ for (i = 0; i < s->n_layers; i++) {
+ TarkinVideoLayer *layer = &s->layer[i];
- for (j=0; j<layer->n_comp; j++) {
- uint32_t comp_bitstream_len;
- TarkinPacket *packet = layer->packet + j;
+ for (j = 0; j < layer->n_comp; j++) {
+ uint32_t comp_bitstream_len;
+ TarkinPacket *packet = layer->packet + j;
- /**
+ /**
* implicit 6:1:1 subsampling
*/
- if (j == 0)
- comp_bitstream_len = 6*layer->desc.bitstream_len/(layer->n_comp+5);
- else
- comp_bitstream_len = layer->desc.bitstream_len/(layer->n_comp+5);
-
- if(packet->storage < comp_bitstream_len) {
- packet->storage = comp_bitstream_len;
- packet->data = REALLOC (packet->data, comp_bitstream_len);
- }
-
- wavelet_3d_buf_dump ("color-%d-%03d.pgm",
- s->current_frame, j,
- layer->waveletbuf[j], j == 0 ? 0 : 128);
-
- wavelet_3d_buf_fwd_xform (layer->waveletbuf[j],
- layer->desc.a_moments,
- layer->desc.s_moments);
-
- wavelet_3d_buf_dump ("coeff-%d-%03d.pgm",
- s->current_frame, j,
- layer->waveletbuf[j], 128);
-
- packet->data_len = wavelet_3d_buf_encode_coeff (layer->waveletbuf[j],
- packet->data,
- comp_bitstream_len);
-
- _analysis_packetout (s, i, j);
+ if (j == 0)
+ comp_bitstream_len =
+ 6 * layer->desc.bitstream_len / (layer->n_comp + 5);
+ else
+ comp_bitstream_len = layer->desc.bitstream_len / (layer->n_comp + 5);
+
+ if (packet->storage < comp_bitstream_len) {
+ packet->storage = comp_bitstream_len;
+ packet->data = REALLOC (packet->data, comp_bitstream_len);
}
- }
+
+ wavelet_3d_buf_dump ("color-%d-%03d.pgm",
+ s->current_frame, j, layer->waveletbuf[j], j == 0 ? 0 : 128);
+
+ wavelet_3d_buf_fwd_xform (layer->waveletbuf[j],
+ layer->desc.a_moments, layer->desc.s_moments);
+
+ wavelet_3d_buf_dump ("coeff-%d-%03d.pgm",
+ s->current_frame, j, layer->waveletbuf[j], 128);
+
+ packet->data_len = wavelet_3d_buf_encode_coeff (layer->waveletbuf[j],
+ packet->data, comp_bitstream_len);
+
+ _analysis_packetout (s, i, j);
+ }
+ }
}
-uint32_t tarkin_analysis_framein (TarkinStream *s, uint8_t *frame,
- uint32_t layer_id, TarkinTime *date)
+uint32_t
+tarkin_analysis_framein (TarkinStream * s, uint8_t * frame,
+ uint32_t layer_id, TarkinTime * date)
{
- TarkinVideoLayer *layer;
-
- if(!frame) return (_analysis_packetout(s, 0, 0)); /* eos */
- if((layer_id>=s->n_layers) || (date->denominator==0)) return (TARKIN_FAULT);
-
- layer = s->layer + layer_id;
- layer->color_fwd_xform (frame, layer->waveletbuf,
- s->current_frame_in_buf);
- /* We don't use this feature for now, neither date... */
- s->free_frame(s,frame);
-
- s->current_frame_in_buf++;
-
- if (s->current_frame_in_buf == s->frames_per_buf)
- _stream_flush (s);
-
+ TarkinVideoLayer *layer;
+
+ if (!frame)
+ return (_analysis_packetout (s, 0, 0)); /* eos */
+ if ((layer_id >= s->n_layers) || (date->denominator == 0))
+ return (TARKIN_FAULT);
+
+ layer = s->layer + layer_id;
+ layer->color_fwd_xform (frame, layer->waveletbuf, s->current_frame_in_buf);
+ /* We don't use this feature for now, neither date... */
+ s->free_frame (s, frame);
+
+ s->current_frame_in_buf++;
+
+ if (s->current_frame_in_buf == s->frames_per_buf)
+ _stream_flush (s);
+
#ifdef DBG_OGG
- printf("dbg_ogg: framein at pos %d/%d, n° %d,%d on layer %d\n",
- date->numerator, date->denominator,
- layer->frameno, s->current_frame, layer_id);
+ printf ("dbg_ogg: framein at pos %d/%d, n° %d,%d on layer %d\n",
+ date->numerator, date->denominator,
+ layer->frameno, s->current_frame, layer_id);
#endif
-
- layer->frameno++;
- return (++s->current_frame);
+
+ layer->frameno++;
+ return (++s->current_frame);
}
-TarkinError tarkin_stream_get_layer_desc (TarkinStream *s,
- uint32_t layer_id,
- TarkinVideoLayerDesc *desc)
+TarkinError
+tarkin_stream_get_layer_desc (TarkinStream * s,
+ uint32_t layer_id, TarkinVideoLayerDesc * desc)
{
- if (layer_id > s->n_layers-1)
- return -TARKIN_INVALID_LAYER;
+ if (layer_id > s->n_layers - 1)
+ return -TARKIN_INVALID_LAYER;
- memcpy (desc, &(s->layer[layer_id].desc), sizeof(TarkinVideoLayerDesc));
+ memcpy (desc, &(s->layer[layer_id].desc), sizeof (TarkinVideoLayerDesc));
- return TARKIN_OK;
+ return TARKIN_OK;
}
-TarkinError tarkin_synthesis_init (TarkinStream *s, TarkinInfo *ti)
+TarkinError
+tarkin_synthesis_init (TarkinStream * s, TarkinInfo * ti)
{
- s->ti = ti;
- s->layer = ti->layer; /* It was malloc()ed by headerin() */
- s->n_layers = ti->n_layers;
- return (TARKIN_OK);
+ s->ti = ti;
+ s->layer = ti->layer; /* It was malloc()ed by headerin() */
+ s->n_layers = ti->n_layers;
+ return (TARKIN_OK);
}
-TarkinError tarkin_synthesis_packetin (TarkinStream *s, ogg_packet *op)
+TarkinError
+tarkin_synthesis_packetin (TarkinStream * s, ogg_packet * op)
{
- uint32_t i, layer_id, comp, data_len;
- uint32_t flags, junk;
- int nread;
- oggpack_buffer opb;
- TarkinPacket *packet;
+ uint32_t i, layer_id, comp, data_len;
+ uint32_t flags, junk;
+ int nread;
+ oggpack_buffer opb;
+ TarkinPacket *packet;
+
#ifdef DBG_OGG
- printf("dbg_ogg: Reading packet n° %lld, granulepos %lld, len %ld, %s%s\n",
- op->packetno, op->granulepos, op->bytes,
- op->b_o_s?"b_o_s":"", op->e_o_s?"e_o_s":"");
+ printf ("dbg_ogg: Reading packet n° %lld, granulepos %lld, len %ld, %s%s\n",
+ op->packetno, op->granulepos, op->bytes,
+ op->b_o_s ? "b_o_s" : "", op->e_o_s ? "e_o_s" : "");
#endif
- oggpack_readinit(&opb,op->packet,op->bytes);
- flags = oggpack_read(&opb,8);
- layer_id = oggpack_read(&opb,12); /* Theses are required for */
- comp = oggpack_read(&opb,12); /* data hole handling (or maybe
- * packetno would be enough ?) */
- nread = 4;
-
- if(flags){ /* This is void "infinite future features" feature ;) */
- if(flags & 1<<7){
- junk = flags;
- while (junk & 1<<7)
- junk = oggpack_read(&opb,8); /* allow for many future flags
- that must be correctly ordonned. */
- }
- /* This shows how to get a feature's data:
- if (flags & TARKIN_FLAGS_EXAMPLE){
- tp->example = oggpack_read(&opb,32);
- junk = tp->example & 3<<30;
- tp->example &= 0x4fffffff;
- }
+ oggpack_readinit (&opb, op->packet, op->bytes);
+ flags = oggpack_read (&opb, 8);
+ layer_id = oggpack_read (&opb, 12); /* Theses are required for */
+ comp = oggpack_read (&opb, 12); /* data hole handling (or maybe
+ * packetno would be enough ?) */
+ nread = 4;
+
+ if (flags) { /* This is void "infinite future features" feature ;) */
+ if (flags & 1 << 7) {
+ junk = flags;
+ while (junk & 1 << 7)
+ junk = oggpack_read (&opb, 8); /* allow for many future flags
+ that must be correctly ordonned. */
+ }
+ /* This shows how to get a feature's data:
+ if (flags & TARKIN_FLAGS_EXAMPLE){
+ tp->example = oggpack_read(&opb,32);
+ junk = tp->example & 3<<30;
+ tp->example &= 0x4fffffff;
+ }
*/
- for(junk=1<<31;junk & 1<<31;) /* and many future data */
- while((junk=oggpack_read(&opb,32)) & 1<<30);
- /* That is, feature data comes in 30 bit chunks. We also have
- * 31 potentially usefull bits in last chunk. */
- }
-
- nread = (opb.ptr - opb.buffer);
- data_len = op->bytes - nread;
-
-#ifdef DBG_OGG
- printf(" layer_id %d, comp %d, meta-data %dB, w3d data %dB.\n",
- layer_id, comp,nread, data_len);
-#endif
+ for (junk = 1 << 31; junk & 1 << 31;) /* and many future data */
+ while ((junk = oggpack_read (&opb, 32)) & 1 << 30);
+ /* That is, feature data comes in 30 bit chunks. We also have
+ * 31 potentially usefull bits in last chunk. */
+ }
- /* We now have for shure our data. */
- packet = &s->layer[layer_id].packet[comp];
- if(packet->data_len)return(-TARKIN_UNUSED); /* Previous data wasn't used */
-
- if(packet->storage < data_len){
- packet->storage = data_len + 255;
- packet->data = REALLOC (packet->data, packet->storage);
- }
-
- for(i=0;i < data_len ; i++)
- packet->data[i] = oggpack_read(&opb,8);
-
- packet->data_len = data_len;
-
- return(TARKIN_OK);
-}
-
-TarkinError tarkin_synthesis_frameout(TarkinStream *s,
- uint8_t **frame,
- uint32_t layer_id, TarkinTime *date)
-{
- int j;
- TarkinVideoLayer *layer = &s->layer[layer_id];
- if (s->current_frame_in_buf == 0) {
- *frame = MALLOC (layer->desc.width * layer->desc.height * layer->n_comp);
- for (j=0; j<layer->n_comp; j++) {
- TarkinPacket *packet = layer->packet + j;
-
- if(packet->data_len == 0)goto err_out ;
-
- wavelet_3d_buf_decode_coeff (layer->waveletbuf[j], packet->data,
- packet->data_len);
-
- wavelet_3d_buf_dump ("rcoeff-%d-%03d.pgm",
- s->current_frame, j, layer->waveletbuf[j],
- 128);
-
- wavelet_3d_buf_inv_xform (layer->waveletbuf[j],
- layer->desc.a_moments,
- layer->desc.s_moments);
-
- wavelet_3d_buf_dump ("rcolor-%d-%03d.pgm",
- s->current_frame, j,
- layer->waveletbuf[j], j == 0 ? 0 : 128);
- }
+ nread = (opb.ptr - opb.buffer);
+ data_len = op->bytes - nread;
- /* We did successfylly read a block from this layer, acknowledge it. */
- for (j=0; j < layer->n_comp; j++)
- layer->packet[j].data_len = 0;
- }
-
- layer->color_inv_xform (layer->waveletbuf, *frame,
- s->current_frame_in_buf);
- s->current_frame_in_buf++;
- s->current_frame++;
-
- if (s->current_frame_in_buf == s->frames_per_buf)
- s->current_frame_in_buf=0;
-
- date->numerator = layer->frameno * s->ti->inter.numerator;
- date->denominator = s->ti->inter.denominator;
#ifdef DBG_OGG
- printf("dbg_ogg: outputting frame pos %d/%d from layer %d.\n",
- date->numerator, date->denominator, layer_id);
+ printf (" layer_id %d, comp %d, meta-data %dB, w3d data %dB.\n",
+ layer_id, comp, nread, data_len);
#endif
- layer->frameno++;
- return (TARKIN_OK);
-err_out:
- FREE(*frame);
- return (TARKIN_NEED_MORE);
+
+ /* We now have for shure our data. */
+ packet = &s->layer[layer_id].packet[comp];
+ if (packet->data_len)
+ return (-TARKIN_UNUSED); /* Previous data wasn't used */
+
+ if (packet->storage < data_len) {
+ packet->storage = data_len + 255;
+ packet->data = REALLOC (packet->data, packet->storage);
+ }
+
+ for (i = 0; i < data_len; i++)
+ packet->data[i] = oggpack_read (&opb, 8);
+
+ packet->data_len = data_len;
+
+ return (TARKIN_OK);
}
-int tarkin_synthesis_freeframe(TarkinStream *s, uint8_t *frame)
+TarkinError
+tarkin_synthesis_frameout (TarkinStream * s,
+ uint8_t ** frame, uint32_t layer_id, TarkinTime * date)
{
- FREE(frame);
-
- return(TARKIN_OK);
-}
+ int j;
+ TarkinVideoLayer *layer = &s->layer[layer_id];
+ if (s->current_frame_in_buf == 0) {
+ *frame = MALLOC (layer->desc.width * layer->desc.height * layer->n_comp);
+ for (j = 0; j < layer->n_comp; j++) {
+ TarkinPacket *packet = layer->packet + j;
+ if (packet->data_len == 0)
+ goto err_out;
+ wavelet_3d_buf_decode_coeff (layer->waveletbuf[j], packet->data,
+ packet->data_len);
+ wavelet_3d_buf_dump ("rcoeff-%d-%03d.pgm",
+ s->current_frame, j, layer->waveletbuf[j], 128);
+ wavelet_3d_buf_inv_xform (layer->waveletbuf[j],
+ layer->desc.a_moments, layer->desc.s_moments);
+ wavelet_3d_buf_dump ("rcolor-%d-%03d.pgm",
+ s->current_frame, j, layer->waveletbuf[j], j == 0 ? 0 : 128);
+ }
+ /* We did successfylly read a block from this layer, acknowledge it. */
+ for (j = 0; j < layer->n_comp; j++)
+ layer->packet[j].data_len = 0;
+ }
+ layer->color_inv_xform (layer->waveletbuf, *frame, s->current_frame_in_buf);
+ s->current_frame_in_buf++;
+ s->current_frame++;
+ if (s->current_frame_in_buf == s->frames_per_buf)
+ s->current_frame_in_buf = 0;
+ date->numerator = layer->frameno * s->ti->inter.numerator;
+ date->denominator = s->ti->inter.denominator;
+#ifdef DBG_OGG
+ printf ("dbg_ogg: outputting frame pos %d/%d from layer %d.\n",
+ date->numerator, date->denominator, layer_id);
+#endif
+ layer->frameno++;
+ return (TARKIN_OK);
+err_out:
+ FREE (*frame);
+ return (TARKIN_NEED_MORE);
+}
+
+int
+tarkin_synthesis_freeframe (TarkinStream * s, uint8_t * frame)
+{
+ FREE (frame);
+
+ return (TARKIN_OK);
+}
/* Theses determine what infos the packet comes with */
#define TARKIN_PACK_EXAMPLE 1
-typedef struct {
- uint8_t *data;
- uint32_t data_len;
- uint32_t storage;
-} TarkinPacket;
-
-
-typedef enum {
- TARKIN_GRAYSCALE,
- TARKIN_RGB24, /* tight packed RGB */
- TARKIN_RGB32, /* 32bit, no alphachannel */
- TARKIN_RGBA, /* dito w/ alphachannel */
- TARKIN_YUV2, /* 16 bits YUV */
- TARKIN_YUV12, /* 12 bits YUV */
- TARKIN_FYUV, /* Tarkin's Fast YUV-like? */
+typedef struct
+{
+ uint8_t *data;
+ uint32_t data_len;
+ uint32_t storage;
+} TarkinPacket;
+
+
+typedef enum
+{
+ TARKIN_GRAYSCALE,
+ TARKIN_RGB24, /* tight packed RGB */
+ TARKIN_RGB32, /* 32bit, no alphachannel */
+ TARKIN_RGBA, /* dito w/ alphachannel */
+ TARKIN_YUV2, /* 16 bits YUV */
+ TARKIN_YUV12, /* 12 bits YUV */
+ TARKIN_FYUV, /* Tarkin's Fast YUV-like? */
} TarkinColorFormat;
#define TARKIN_INTERNAL_FORMAT TARKIN_FYUV
-typedef enum {
- TARKIN_OK = 0,
- TARKIN_IO_ERROR,
- TARKIN_SIGNATURE_NOT_FOUND,
- TARKIN_INVALID_LAYER,
- TARKIN_INVALID_COLOR_FORMAT,
- TARKIN_VERSION,
- TARKIN_BAD_HEADER,
- TARKIN_NOT_TARKIN,
- TARKIN_FAULT,
- TARKIN_UNUSED,
- TARKIN_NEED_MORE,
- TARKIN_NOT_IMPLEMENTED
+typedef enum
+{
+ TARKIN_OK = 0,
+ TARKIN_IO_ERROR,
+ TARKIN_SIGNATURE_NOT_FOUND,
+ TARKIN_INVALID_LAYER,
+ TARKIN_INVALID_COLOR_FORMAT,
+ TARKIN_VERSION,
+ TARKIN_BAD_HEADER,
+ TARKIN_NOT_TARKIN,
+ TARKIN_FAULT,
+ TARKIN_UNUSED,
+ TARKIN_NEED_MORE,
+ TARKIN_NOT_IMPLEMENTED
} TarkinError;
-typedef struct {
- uint32_t width;
- uint32_t height;
- uint32_t a_moments;
- uint32_t s_moments;
- uint32_t frames_per_buf;
- uint32_t bitstream_len; /* for all color components, bytes */
- TarkinColorFormat format;
+typedef struct
+{
+ uint32_t width;
+ uint32_t height;
+ uint32_t a_moments;
+ uint32_t s_moments;
+ uint32_t frames_per_buf;
+ uint32_t bitstream_len; /* for all color components, bytes */
+ TarkinColorFormat format;
} TarkinVideoLayerDesc;
-typedef struct {
- TarkinVideoLayerDesc desc;
- uint32_t n_comp; /* number of color components */
- Wavelet3DBuf **waveletbuf;
- TarkinPacket *packet;
- uint32_t current_frame_in_buf;
- uint32_t frameno;
+typedef struct
+{
+ TarkinVideoLayerDesc desc;
+ uint32_t n_comp; /* number of color components */
+ Wavelet3DBuf **waveletbuf;
+ TarkinPacket *packet;
+ uint32_t current_frame_in_buf;
+ uint32_t frameno;
- void (*color_fwd_xform) (uint8_t *rgba, Wavelet3DBuf *yuva [], uint32_t count);
- void (*color_inv_xform) (Wavelet3DBuf *yuva [], uint8_t *rgba, uint32_t count);
+ void (*color_fwd_xform) (uint8_t * rgba, Wavelet3DBuf * yuva[],
+ uint32_t count);
+ void (*color_inv_xform) (Wavelet3DBuf * yuva[], uint8_t * rgba,
+ uint32_t count);
} TarkinVideoLayer;
-typedef struct {
- uint32_t numerator;
- uint32_t denominator;
-} TarkinTime; /* Let's say the unit is 1 second */
-
-typedef struct TarkinInfo {
- int version;
- int n_layers;
- TarkinVideoLayer *layer;
- TarkinTime inter; /* numerator == O if per-frame time info. */
- int frames_per_block;
- int comp_per_block; /* AKA "packets per block" for now */
- uint32_t max_bitstream_len;
+typedef struct
+{
+ uint32_t numerator;
+ uint32_t denominator;
+} TarkinTime; /* Let's say the unit is 1 second */
+
+typedef struct TarkinInfo
+{
+ int version;
+ int n_layers;
+ TarkinVideoLayer *layer;
+ TarkinTime inter; /* numerator == O if per-frame time info. */
+ int frames_per_block;
+ int comp_per_block; /* AKA "packets per block" for now */
+ uint32_t max_bitstream_len;
/* The below bitrate declarations are *hints*.
Combinations of the three values carry the following implications:
-
+
all three set to the same value:
- implies a fixed rate bitstream
+ implies a fixed rate bitstream
only nominal set:
- implies a VBR stream that averages the nominal bitrate. No hard
- upper/lower limit
+ implies a VBR stream that averages the nominal bitrate. No hard
+ upper/lower limit
upper and or lower set:
- implies a VBR bitstream that obeys the bitrate limits. nominal
- may also be set to give a nominal rate.
+ implies a VBR bitstream that obeys the bitrate limits. nominal
+ may also be set to give a nominal rate.
none set:
- the coder does not care to speculate.
- */
+ the coder does not care to speculate.
+ */
- long bitrate_upper;
- long bitrate_nominal;
- long bitrate_lower;
- long bitrate_window;
+ long bitrate_upper;
+ long bitrate_nominal;
+ long bitrate_lower;
+ long bitrate_window;
} TarkinInfo;
/* This is used for encoding */
-typedef struct {
- unsigned char *header;
- unsigned char *header1;
- unsigned char *header2;
+typedef struct
+{
+ unsigned char *header;
+ unsigned char *header1;
+ unsigned char *header2;
} tarkin_header_store;
/* Some of the fields in TarkinStream are redundent with TarkinInfo ones
* and will probably get deleted, namely n_layers and frames_per_buf */
-typedef struct TarkinStream {
- uint32_t n_layers;
- TarkinVideoLayer *layer;
- uint32_t current_frame;
- uint32_t current_frame_in_buf;
- ogg_int64_t packetno;
- uint32_t frames_per_buf;
- uint32_t max_bitstream_len;
- TarkinInfo *ti;
- tarkin_header_store headers;
- /* These callbacks are only used for encoding */
- TarkinError (*free_frame)(void *tarkinstream, void *ptr);
- /* These thing allows not to buffer but it needs global var in caller. */
- TarkinError (*packet_out)(void *tarkinstream, ogg_packet *ptr);
- void * user_ptr;
+typedef struct TarkinStream
+{
+ uint32_t n_layers;
+ TarkinVideoLayer *layer;
+ uint32_t current_frame;
+ uint32_t current_frame_in_buf;
+ ogg_int64_t packetno;
+ uint32_t frames_per_buf;
+ uint32_t max_bitstream_len;
+ TarkinInfo *ti;
+ tarkin_header_store headers;
+ /* These callbacks are only used for encoding */
+ TarkinError (*free_frame) (void *tarkinstream, void *ptr);
+ /* These thing allows not to buffer but it needs global var in caller. */
+ TarkinError (*packet_out) (void *tarkinstream, ogg_packet * ptr);
+ void *user_ptr;
} TarkinStream;
-typedef struct TarkinComment{
+typedef struct TarkinComment
+{
/* unlimited user comment fields. libtarkin writes 'libtarkin'
whatever vendor is set to in encode */
char **user_comments;
- int *comment_lengths;
- int comments;
- char *vendor;
+ int *comment_lengths;
+ int comments;
+ char *vendor;
} TarkinComment;
/* Theses are the very same than Vorbis versions, they could be shared. */
-extern TarkinStream* tarkin_stream_new ();
-extern void tarkin_stream_destroy (TarkinStream *s);
-extern void tarkin_info_init(TarkinInfo *vi);
-extern void tarkin_info_clear(TarkinInfo *vi);
-extern void tarkin_comment_init(TarkinComment *vc);
-extern void tarkin_comment_add(TarkinComment *vc, char *comment);
-extern void tarkin_comment_add_tag(TarkinComment *vc,
- char *tag, char *contents);
-extern char *tarkin_comment_query(TarkinComment *vc, char *tag, int count);
-extern int tarkin_comment_query_count(TarkinComment *vc, char *tag);
-extern void tarkin_comment_clear(TarkinComment *vc);
+extern TarkinStream *tarkin_stream_new ();
+extern void tarkin_stream_destroy (TarkinStream * s);
+extern void tarkin_info_init (TarkinInfo * vi);
+extern void tarkin_info_clear (TarkinInfo * vi);
+extern void tarkin_comment_init (TarkinComment * vc);
+extern void tarkin_comment_add (TarkinComment * vc, char *comment);
+extern void tarkin_comment_add_tag (TarkinComment * vc,
+ char *tag, char *contents);
+extern char *tarkin_comment_query (TarkinComment * vc, char *tag, int count);
+extern int tarkin_comment_query_count (TarkinComment * vc, char *tag);
+extern void tarkin_comment_clear (TarkinComment * vc);
/* Tarkin PRIMITIVES: analysis layer ****************************/
/* Tarkin encoding is done this way : you init it passing a fresh
* is called when a packet is ready. The pointers given as arguments to
* these callback functions are of course only valid at the function call
* time. The user_ptr is stored in s and can be used by packet_out(). */
-extern int tarkin_analysis_init(TarkinStream *s,
- TarkinInfo *ti,
- TarkinError (*free_frame)(void *tarkinstream, void *ptr),
- TarkinError (*packet_out)(void *tarkinstream, ogg_packet *ptr),
- void *user_ptr
- );
+extern int tarkin_analysis_init (TarkinStream * s,
+ TarkinInfo * ti,
+ TarkinError (*free_frame) (void *tarkinstream, void *ptr),
+ TarkinError (*packet_out) (void *tarkinstream, ogg_packet * ptr),
+ void *user_ptr);
/* Then you need to add at least a layer in your stream, passing a
* TarkinVideoLayerDesc renseigned at least on the width, height and
* format parameters. */
-extern int tarkin_analysis_add_layer(TarkinStream *s,
- TarkinVideoLayerDesc *tvld);
+extern int tarkin_analysis_add_layer (TarkinStream * s,
+ TarkinVideoLayerDesc * tvld);
/* At that point you are ready to get headers out the lib by calling
* tarkin_analysis_headerout() passing it a renseigned TarkinComment
* structure. It does fill your 3 ogg_packet headers, which are valid
* till next call */
-extern int TarkinCommentheader_out(TarkinComment *vc, ogg_packet *op);
-extern TarkinError tarkin_analysis_headerout(TarkinStream *s,
- TarkinComment *vc,
- ogg_packet *op,
- ogg_packet *op_comm,
- ogg_packet *op_code);
+extern int TarkinCommentheader_out (TarkinComment * vc, ogg_packet * op);
+extern TarkinError tarkin_analysis_headerout (TarkinStream * s,
+ TarkinComment * vc,
+ ogg_packet * op, ogg_packet * op_comm, ogg_packet * op_code);
/* You are now ready to pass in frames to the codec, however don't free
* them before the codec told you so. It'll tell you when packets are
* ready to be taken out. When you have no more frame, simply pass NULL.
* If you encode multiple layers you have to do it synchronously, putting
* one frame from each layer at a time. */
-extern uint32_t tarkin_analysis_framein(TarkinStream *s,
- uint8_t *frame, /* NULL for EOS */
- uint32_t layer,
- TarkinTime *date);
+extern uint32_t tarkin_analysis_framein (TarkinStream * s, uint8_t * frame, /* NULL for EOS */
+ uint32_t layer, TarkinTime * date);
/* Tarkin PRIMITIVES: synthesis layer *******************************/
/* For decoding, you needs first to give the three first packet of the
* stream to tarkin_synthesis_headerin() which will fill for you blank
* TarkinInfo and TarkinComment. */
-extern TarkinError tarkin_synthesis_headerin(TarkinInfo *vi,TarkinComment *vc,
- ogg_packet *op);
+extern TarkinError tarkin_synthesis_headerin (TarkinInfo * vi,
+ TarkinComment * vc, ogg_packet * op);
/* Then you can init your stream with your TarkinInfo struct. */
-extern TarkinError tarkin_synthesis_init(TarkinStream *s,TarkinInfo *ti);
+extern TarkinError tarkin_synthesis_init (TarkinStream * s, TarkinInfo * ti);
+
/* All subsequent packets are to this be passed to tarkin_synthesis_packetin*/
-extern TarkinError tarkin_synthesis_packetin(TarkinStream *s, ogg_packet *op);
+extern TarkinError tarkin_synthesis_packetin (TarkinStream * s,
+ ogg_packet * op);
/* and then tarkin_synthesis_frameout gives you ptr on next frame, or NULL. It
* also fills for you date. */
-extern TarkinError tarkin_synthesis_frameout(TarkinStream *s,
- uint8_t **frame, uint32_t layer_id, TarkinTime *date);
+extern TarkinError tarkin_synthesis_frameout (TarkinStream * s,
+ uint8_t ** frame, uint32_t layer_id, TarkinTime * date);
/* When you're done with a frame, tell it to the codec with this. */
-extern int tarkin_synthesis_freeframe(TarkinStream *s, uint8_t *frame);
+extern int tarkin_synthesis_freeframe (TarkinStream * s, uint8_t * frame);
#endif
-
-
-
-
-
-
-Wavelet3DBuf* wavelet_3d_buf_new (uint32_t width, uint32_t height,
- uint32_t frames)
+Wavelet3DBuf *
+wavelet_3d_buf_new (uint32_t width, uint32_t height, uint32_t frames)
{
- Wavelet3DBuf* buf = (Wavelet3DBuf*) MALLOC (sizeof (Wavelet3DBuf));
- uint32_t _w = width;
- uint32_t _h = height;
- uint32_t _f = frames;
- int level;
-
- if (!buf)
- return NULL;
-
- buf->data = (TYPE*) MALLOC (width * height * frames * sizeof (TYPE));
-
- if (!buf->data) {
- wavelet_3d_buf_destroy (buf);
- return NULL;
- }
-
- buf->width = width;
- buf->height = height;
- buf->frames = frames;
- buf->scales = 1;
-
- while (_w > 1 || _h > 1 || _f > 1) {
- buf->scales++;
- _w = (_w+1)/2;
- _h = (_h+1)/2;
- _f = (_f+1)/2;
- }
-
- buf->w = (uint32_t*) MALLOC (buf->scales * sizeof (uint32_t));
- buf->h = (uint32_t*) MALLOC (buf->scales * sizeof (uint32_t));
- buf->f = (uint32_t*) MALLOC (buf->scales * sizeof (uint32_t));
- buf->offset = (uint32_t (*) [8]) MALLOC (8 * buf->scales * sizeof (uint32_t));
-
- buf->scratchbuf = (TYPE*) MALLOC (MAX3(width, height, frames) * sizeof (TYPE));
-
- if (!buf->w || !buf->h || !buf->f || !buf->offset || !buf->scratchbuf) {
- wavelet_3d_buf_destroy (buf);
- return NULL;
- }
-
- buf->w [buf->scales-1] = width;
- buf->h [buf->scales-1] = height;
- buf->f [buf->scales-1] = frames;
-
- for (level=buf->scales-2; level>=0; level--) {
- buf->w [level] = (buf->w [level+1] + 1) / 2;
- buf->h [level] = (buf->h [level+1] + 1) / 2;
- buf->f [level] = (buf->f [level+1] + 1) / 2;
- buf->offset[level][0] = 0;
- buf->offset[level][1] = buf->w [level];
- buf->offset[level][2] = buf->h [level] * width;
- buf->offset[level][3] = buf->f [level] * width * height;
- buf->offset[level][4] = buf->offset [level][2] + buf->w [level];
- buf->offset[level][5] = buf->offset [level][3] + buf->w [level];
- buf->offset[level][6] = buf->offset [level][3] + buf->offset [level][2];
- buf->offset[level][7] = buf->offset [level][6] + buf->w [level];
- }
-
- return buf;
+ Wavelet3DBuf *buf = (Wavelet3DBuf *) MALLOC (sizeof (Wavelet3DBuf));
+ uint32_t _w = width;
+ uint32_t _h = height;
+ uint32_t _f = frames;
+ int level;
+
+ if (!buf)
+ return NULL;
+
+ buf->data = (TYPE *) MALLOC (width * height * frames * sizeof (TYPE));
+
+ if (!buf->data) {
+ wavelet_3d_buf_destroy (buf);
+ return NULL;
+ }
+
+ buf->width = width;
+ buf->height = height;
+ buf->frames = frames;
+ buf->scales = 1;
+
+ while (_w > 1 || _h > 1 || _f > 1) {
+ buf->scales++;
+ _w = (_w + 1) / 2;
+ _h = (_h + 1) / 2;
+ _f = (_f + 1) / 2;
+ }
+
+ buf->w = (uint32_t *) MALLOC (buf->scales * sizeof (uint32_t));
+ buf->h = (uint32_t *) MALLOC (buf->scales * sizeof (uint32_t));
+ buf->f = (uint32_t *) MALLOC (buf->scales * sizeof (uint32_t));
+ buf->offset = (uint32_t (*)[8]) MALLOC (8 * buf->scales * sizeof (uint32_t));
+
+ buf->scratchbuf =
+ (TYPE *) MALLOC (MAX3 (width, height, frames) * sizeof (TYPE));
+
+ if (!buf->w || !buf->h || !buf->f || !buf->offset || !buf->scratchbuf) {
+ wavelet_3d_buf_destroy (buf);
+ return NULL;
+ }
+
+ buf->w[buf->scales - 1] = width;
+ buf->h[buf->scales - 1] = height;
+ buf->f[buf->scales - 1] = frames;
+
+ for (level = buf->scales - 2; level >= 0; level--) {
+ buf->w[level] = (buf->w[level + 1] + 1) / 2;
+ buf->h[level] = (buf->h[level + 1] + 1) / 2;
+ buf->f[level] = (buf->f[level + 1] + 1) / 2;
+ buf->offset[level][0] = 0;
+ buf->offset[level][1] = buf->w[level];
+ buf->offset[level][2] = buf->h[level] * width;
+ buf->offset[level][3] = buf->f[level] * width * height;
+ buf->offset[level][4] = buf->offset[level][2] + buf->w[level];
+ buf->offset[level][5] = buf->offset[level][3] + buf->w[level];
+ buf->offset[level][6] = buf->offset[level][3] + buf->offset[level][2];
+ buf->offset[level][7] = buf->offset[level][6] + buf->w[level];
+ }
+
+ return buf;
}
-void wavelet_3d_buf_destroy (Wavelet3DBuf* buf)
+void
+wavelet_3d_buf_destroy (Wavelet3DBuf * buf)
{
- if (buf) {
- if (buf->data)
- FREE (buf->data);
- if (buf->w)
- FREE (buf->w);
- if (buf->h)
- FREE (buf->h);
- if (buf->f)
- FREE (buf->f);
- if (buf->offset)
- FREE (buf->offset);
- if (buf->scratchbuf)
- FREE (buf->scratchbuf);
- FREE (buf);
- }
+ if (buf) {
+ if (buf->data)
+ FREE (buf->data);
+ if (buf->w)
+ FREE (buf->w);
+ if (buf->h)
+ FREE (buf->h);
+ if (buf->f)
+ FREE (buf->f);
+ if (buf->offset)
+ FREE (buf->offset);
+ if (buf->scratchbuf)
+ FREE (buf->scratchbuf);
+ FREE (buf);
+ }
}
#include "pnm.h"
-void wavelet_3d_buf_dump (char *fmt,
- uint32_t first_frame_in_buf,
- uint32_t id,
- Wavelet3DBuf* buf,
- int16_t offset)
+void
+wavelet_3d_buf_dump (char *fmt,
+ uint32_t first_frame_in_buf,
+ uint32_t id, Wavelet3DBuf * buf, int16_t offset)
{
- char fname [256];
- uint32_t f;
+ char fname[256];
+ uint32_t f;
- for (f=0; f<buf->frames; f++) {
- snprintf (fname, 256, fmt, id, first_frame_in_buf + f);
+ for (f = 0; f < buf->frames; f++) {
+ snprintf (fname, 256, fmt, id, first_frame_in_buf + f);
- write_pgm16 (fname, buf->data + f * buf->width * buf->height,
- buf->width, buf->height, offset);
- }
+ write_pgm16 (fname, buf->data + f * buf->width * buf->height,
+ buf->width, buf->height, offset);
+ }
}
#endif
-
-
#include <stdint.h>
-typedef struct {
- TYPE *data;
- uint32_t width;
- uint32_t height;
- uint32_t frames;
- uint32_t scales;
- uint32_t *w;
- uint32_t *h;
- uint32_t *f;
- uint32_t (*offset)[8];
- TYPE *scratchbuf;
+typedef struct
+{
+ TYPE *data;
+ uint32_t width;
+ uint32_t height;
+ uint32_t frames;
+ uint32_t scales;
+ uint32_t *w;
+ uint32_t *h;
+ uint32_t *f;
+ uint32_t (*offset)[8];
+ TYPE *scratchbuf;
} Wavelet3DBuf;
-extern Wavelet3DBuf* wavelet_3d_buf_new (uint32_t width, uint32_t height,
- uint32_t frames);
+extern Wavelet3DBuf *wavelet_3d_buf_new (uint32_t width, uint32_t height,
+ uint32_t frames);
-extern void wavelet_3d_buf_destroy (Wavelet3DBuf* buf);
+extern void wavelet_3d_buf_destroy (Wavelet3DBuf * buf);
/**
* transform buf->data
* highpass filter,
* s_moments the one of the synthesizing lowpass filter.
*/
-extern void wavelet_3d_buf_fwd_xform (Wavelet3DBuf* buf,
- int a_moments, int s_moments);
-extern void wavelet_3d_buf_inv_xform (Wavelet3DBuf* buf,
- int a_moments, int s_moments);
+extern void wavelet_3d_buf_fwd_xform (Wavelet3DBuf * buf,
+ int a_moments, int s_moments);
+extern void wavelet_3d_buf_inv_xform (Wavelet3DBuf * buf,
+ int a_moments, int s_moments);
-extern int wavelet_3d_buf_encode_coeff (const Wavelet3DBuf* buf,
- uint8_t *bitstream,
- uint32_t limit);
+extern int wavelet_3d_buf_encode_coeff (const Wavelet3DBuf * buf,
+ uint8_t * bitstream, uint32_t limit);
-extern void wavelet_3d_buf_decode_coeff (Wavelet3DBuf* buf,
- uint8_t *bitstream,
- uint32_t limit);
+extern void wavelet_3d_buf_decode_coeff (Wavelet3DBuf * buf,
+ uint8_t * bitstream, uint32_t limit);
#if defined(DBG_XFORM)
extern void wavelet_3d_buf_dump (char *fmt,
- uint32_t first_frame_in_buf,
- uint32_t id,
- Wavelet3DBuf* buf,
- int16_t offset);
+ uint32_t first_frame_in_buf,
+ uint32_t id, Wavelet3DBuf * buf, int16_t offset);
#else
#define wavelet_3d_buf_dump(x...)
#endif
#define GRAY_CODES 1
#if defined(GRAY_CODES)
-static inline
-uint16_t binary_to_gray (uint16_t x) { return x ^ (x >> 1); }
+static inline uint16_t
+binary_to_gray (uint16_t x)
+{
+ return x ^ (x >> 1);
+}
+
+static inline uint16_t
+gray_to_binary (uint16_t x)
+{
+ int i;
-static inline
-uint16_t gray_to_binary (uint16_t x)
-{ int i; for (i=1; i<16; i+=i) x ^= x >> i; return x; }
+ for (i = 1; i < 16; i += i)
+ x ^= x >> i;
+ return x;
+}
#endif
-static inline
-void encode_coeff (ENTROPY_CODER significand_bitstream [],
- ENTROPY_CODER insignificand_bitstream [],
- TYPE coeff)
+static inline void
+encode_coeff (ENTROPY_CODER significand_bitstream[],
+ ENTROPY_CODER insignificand_bitstream[], TYPE coeff)
{
- int sign = (coeff >> (8*sizeof(TYPE)-1)) & 1;
+ int sign = (coeff >> (8 * sizeof (TYPE) - 1)) & 1;
+
#if defined(GRAY_CODES)
- TYPE significance = binary_to_gray(coeff);
+ TYPE significance = binary_to_gray (coeff);
#else
- static TYPE mask [2] = { 0, ~0 };
- TYPE significance = coeff ^ mask[sign];
+ static TYPE mask[2] = { 0, ~0 };
+ TYPE significance = coeff ^ mask[sign];
#endif
- int i = TYPE_BITS;
+ int i = TYPE_BITS;
- do {
- i--;
- OUTPUT_BIT(&significand_bitstream[i], (significance >> i) & 1);
- } while (!((significance >> i) & 1) && i > 0);
+ do {
+ i--;
+ OUTPUT_BIT (&significand_bitstream[i], (significance >> i) & 1);
+ } while (!((significance >> i) & 1) && i > 0);
- OUTPUT_BIT(&significand_bitstream[i], sign);
+ OUTPUT_BIT (&significand_bitstream[i], sign);
- while (--i >= 0)
- OUTPUT_BIT(&insignificand_bitstream[i], (significance >> i) & 1);
+ while (--i >= 0)
+ OUTPUT_BIT (&insignificand_bitstream[i], (significance >> i) & 1);
}
-static inline
-TYPE decode_coeff (ENTROPY_CODER significand_bitstream [],
- ENTROPY_CODER insignificand_bitstream [])
+static inline TYPE
+decode_coeff (ENTROPY_CODER significand_bitstream[],
+ ENTROPY_CODER insignificand_bitstream[])
{
#if !defined(GRAY_CODES)
- static TYPE mask [2] = { 0, ~0 };
+ static TYPE mask[2] = { 0, ~0 };
#endif
- TYPE significance = 0;
- int sign;
- int i = TYPE_BITS;
+ TYPE significance = 0;
+ int sign;
+ int i = TYPE_BITS;
- do {
- i--;
- significance |= INPUT_BIT(&significand_bitstream[i]) << i;
+ do {
+ i--;
+ significance |= INPUT_BIT (&significand_bitstream[i]) << i;
/* if (ENTROPY_CODER_EOS(&significand_bitstream[i])) */
/* return 0; */
- } while (!significance && i > 0);
+ } while (!significance && i > 0);
- sign = INPUT_BIT(&significand_bitstream[i]);
+ sign = INPUT_BIT (&significand_bitstream[i]);
/* if (ENTROPY_CODER_EOS(&significand_bitstream[i])) */
/* return 0; */
- while (--i >= 0)
- significance |= INPUT_BIT(&insignificand_bitstream[i]) << i;
+ while (--i >= 0)
+ significance |= INPUT_BIT (&insignificand_bitstream[i]) << i;
#if defined(GRAY_CODES)
- significance |= sign << (8*sizeof(TYPE)-1);
- return gray_to_binary(significance);
+ significance |= sign << (8 * sizeof (TYPE) - 1);
+ return gray_to_binary (significance);
#else
- return (significance ^ mask[sign]);
+ return (significance ^ mask[sign]);
#endif
}
-static inline
-uint32_t skip_0coeffs (Wavelet3DBuf* buf,
- ENTROPY_CODER s_stream [],
- ENTROPY_CODER i_stream [],
- uint32_t limit)
+static inline uint32_t
+skip_0coeffs (Wavelet3DBuf * buf,
+ ENTROPY_CODER s_stream[], ENTROPY_CODER i_stream[], uint32_t limit)
{
- int i;
- uint32_t skip = limit;
-
- for (i=0; i<TYPE_BITS; i++) {
- if (ENTROPY_CODER_SYMBOL(&s_stream[i]) != 0) {
- return 0;
- } else {
- uint32_t runlength = ENTROPY_CODER_RUNLENGTH(&s_stream[i]);
- if (i==0)
- runlength /= 2; /* sign bits are in this bitplane ... */
- if (skip > runlength)
- skip = runlength;
- if (skip <= 2)
- return 0;
- }
- }
-
- ENTROPY_CODER_SKIP(&s_stream[0], 2*skip); /* kill sign+significance bits */
-
- for (i=1; i<TYPE_BITS; i++)
- ENTROPY_CODER_SKIP(&s_stream[i], skip);
-
- return skip;
+ int i;
+ uint32_t skip = limit;
+
+ for (i = 0; i < TYPE_BITS; i++) {
+ if (ENTROPY_CODER_SYMBOL (&s_stream[i]) != 0) {
+ return 0;
+ } else {
+ uint32_t runlength = ENTROPY_CODER_RUNLENGTH (&s_stream[i]);
+
+ if (i == 0)
+ runlength /= 2; /* sign bits are in this bitplane ... */
+ if (skip > runlength)
+ skip = runlength;
+ if (skip <= 2)
+ return 0;
+ }
+ }
+
+ ENTROPY_CODER_SKIP (&s_stream[0], 2 * skip); /* kill sign+significance bits */
+
+ for (i = 1; i < TYPE_BITS; i++)
+ ENTROPY_CODER_SKIP (&s_stream[i], skip);
+
+ return skip;
}
#if 1
-static inline
-void encode_quadrant (const Wavelet3DBuf* buf,
- int level, int quadrant, uint32_t w, uint32_t h, uint32_t f,
- ENTROPY_CODER significand_bitstream [],
- ENTROPY_CODER insignificand_bitstream [])
+static inline void
+encode_quadrant (const Wavelet3DBuf * buf,
+ int level, int quadrant, uint32_t w, uint32_t h, uint32_t f,
+ ENTROPY_CODER significand_bitstream[],
+ ENTROPY_CODER insignificand_bitstream[])
{
- uint32_t x, y, z;
-
- for (z=0; z<f; z++) {
- for (y=0; y<h; y++) {
- for (x=0; x<w; x++) {
- unsigned int index = buf->offset [level] [quadrant]
- + z * buf->width * buf->height
- + y * buf->width + x;
-
- encode_coeff (significand_bitstream, insignificand_bitstream,
- buf->data [index]);
- }
+ uint32_t x, y, z;
+
+ for (z = 0; z < f; z++) {
+ for (y = 0; y < h; y++) {
+ for (x = 0; x < w; x++) {
+ unsigned int index = buf->offset[level][quadrant]
+ + z * buf->width * buf->height + y * buf->width + x;
+
+ encode_coeff (significand_bitstream, insignificand_bitstream,
+ buf->data[index]);
}
- }
+ }
+ }
}
-static
-void encode_coefficients (const Wavelet3DBuf* buf,
- ENTROPY_CODER s_stream [],
- ENTROPY_CODER i_stream [])
+static void
+encode_coefficients (const Wavelet3DBuf * buf,
+ ENTROPY_CODER s_stream[], ENTROPY_CODER i_stream[])
{
- int level;
-
- encode_coeff (s_stream, i_stream, buf->data[0]);
-
- for (level=0; level<buf->scales-1; level++) {
- uint32_t w, h, f, w1, h1, f1;
-
- w = buf->w [level];
- h = buf->h [level];
- f = buf->f [level];
- w1 = buf->w [level+1] - w;
- h1 = buf->h [level+1] - h;
- f1 = buf->f [level+1] - f;
-
- if (w1 > 0) encode_quadrant(buf,level,1,w1,h,f,s_stream,i_stream);
- if (h1 > 0) encode_quadrant(buf,level,2,w,h1,f,s_stream,i_stream);
- if (f1 > 0) encode_quadrant(buf,level,3,w,h,f1,s_stream,i_stream);
- if (w1 > 0 && h1 > 0) encode_quadrant(buf,level,4,w1,h1,f,s_stream,i_stream);
- if (w1 > 0 && f1 > 0) encode_quadrant(buf,level,5,w1,h,f1,s_stream,i_stream);
- if (h1 > 0 && f1 > 0) encode_quadrant(buf,level,6,w,h1,f1,s_stream,i_stream);
- if (h1 > 0 && f1 > 0 && f1 > 0)
- encode_quadrant (buf,level,7,w1,h1,f1,s_stream,i_stream);
- }
+ int level;
+
+ encode_coeff (s_stream, i_stream, buf->data[0]);
+
+ for (level = 0; level < buf->scales - 1; level++) {
+ uint32_t w, h, f, w1, h1, f1;
+
+ w = buf->w[level];
+ h = buf->h[level];
+ f = buf->f[level];
+ w1 = buf->w[level + 1] - w;
+ h1 = buf->h[level + 1] - h;
+ f1 = buf->f[level + 1] - f;
+
+ if (w1 > 0)
+ encode_quadrant (buf, level, 1, w1, h, f, s_stream, i_stream);
+ if (h1 > 0)
+ encode_quadrant (buf, level, 2, w, h1, f, s_stream, i_stream);
+ if (f1 > 0)
+ encode_quadrant (buf, level, 3, w, h, f1, s_stream, i_stream);
+ if (w1 > 0 && h1 > 0)
+ encode_quadrant (buf, level, 4, w1, h1, f, s_stream, i_stream);
+ if (w1 > 0 && f1 > 0)
+ encode_quadrant (buf, level, 5, w1, h, f1, s_stream, i_stream);
+ if (h1 > 0 && f1 > 0)
+ encode_quadrant (buf, level, 6, w, h1, f1, s_stream, i_stream);
+ if (h1 > 0 && f1 > 0 && f1 > 0)
+ encode_quadrant (buf, level, 7, w1, h1, f1, s_stream, i_stream);
+ }
}
-static inline
-void decode_quadrant (Wavelet3DBuf* buf,
- int level, int quadrant, uint32_t w, uint32_t h, uint32_t f,
- ENTROPY_CODER s_stream [],
- ENTROPY_CODER i_stream [])
+static inline void
+decode_quadrant (Wavelet3DBuf * buf,
+ int level, int quadrant, uint32_t w, uint32_t h, uint32_t f,
+ ENTROPY_CODER s_stream[], ENTROPY_CODER i_stream[])
{
- uint32_t x, y, z;
+ uint32_t x, y, z;
- z = 0;
- do {
- y = 0;
+ z = 0;
+ do {
+ y = 0;
+ do {
+ x = 0;
do {
- x = 0;
- do {
- uint32_t skip;
- uint32_t index = buf->offset [level] [quadrant]
- + z * buf->width * buf->height
- + y * buf->width + x;
-
- buf->data [index] = decode_coeff (s_stream, i_stream);
-
- skip = skip_0coeffs (buf, s_stream, i_stream,
- (w-x-1)+(h-y-1)*w+(f-z-1)*w*h);
- if (skip > 0) {
- x += skip;
- while (x >= w) {
- y++; x -= w;
- while (y >= h) {
- z++; y -= h;
- if (z >= f)
- return;
- }
- }
- }
- x++;
- } while (x < w);
- y++;
- } while (y < h);
- z++;
- } while (z < f);
+ uint32_t skip;
+ uint32_t index = buf->offset[level][quadrant]
+ + z * buf->width * buf->height + y * buf->width + x;
+
+ buf->data[index] = decode_coeff (s_stream, i_stream);
+
+ skip = skip_0coeffs (buf, s_stream, i_stream,
+ (w - x - 1) + (h - y - 1) * w + (f - z - 1) * w * h);
+ if (skip > 0) {
+ x += skip;
+ while (x >= w) {
+ y++;
+ x -= w;
+ while (y >= h) {
+ z++;
+ y -= h;
+ if (z >= f)
+ return;
+ }
+ }
+ }
+ x++;
+ } while (x < w);
+ y++;
+ } while (y < h);
+ z++;
+ } while (z < f);
}
-static
-void decode_coefficients (Wavelet3DBuf* buf,
- ENTROPY_CODER s_stream [],
- ENTROPY_CODER i_stream [])
+static void
+decode_coefficients (Wavelet3DBuf * buf,
+ ENTROPY_CODER s_stream[], ENTROPY_CODER i_stream[])
{
- int level;
-
- buf->data[0] = decode_coeff (s_stream, i_stream);
-
- for (level=0; level<buf->scales-1; level++) {
- uint32_t w, h, f, w1, h1, f1;
-
- w = buf->w [level];
- h = buf->h [level];
- f = buf->f [level];
- w1 = buf->w [level+1] - w;
- h1 = buf->h [level+1] - h;
- f1 = buf->f [level+1] - f;
-
- if (w1 > 0) decode_quadrant(buf,level,1,w1,h,f,s_stream,i_stream);
- if (h1 > 0) decode_quadrant(buf,level,2,w,h1,f,s_stream,i_stream);
- if (f1 > 0) decode_quadrant(buf,level,3,w,h,f1,s_stream,i_stream);
- if (w1 > 0 && h1 > 0) decode_quadrant(buf,level,4,w1,h1,f,s_stream,i_stream);
- if (w1 > 0 && f1 > 0) decode_quadrant(buf,level,5,w1,h,f1,s_stream,i_stream);
- if (h1 > 0 && f1 > 0) decode_quadrant(buf,level,6,w,h1,f1,s_stream,i_stream);
- if (h1 > 0 && f1 > 0 && f1 > 0)
- decode_quadrant (buf,level,7,w1,h1,f1,s_stream,i_stream);
- }
+ int level;
+
+ buf->data[0] = decode_coeff (s_stream, i_stream);
+
+ for (level = 0; level < buf->scales - 1; level++) {
+ uint32_t w, h, f, w1, h1, f1;
+
+ w = buf->w[level];
+ h = buf->h[level];
+ f = buf->f[level];
+ w1 = buf->w[level + 1] - w;
+ h1 = buf->h[level + 1] - h;
+ f1 = buf->f[level + 1] - f;
+
+ if (w1 > 0)
+ decode_quadrant (buf, level, 1, w1, h, f, s_stream, i_stream);
+ if (h1 > 0)
+ decode_quadrant (buf, level, 2, w, h1, f, s_stream, i_stream);
+ if (f1 > 0)
+ decode_quadrant (buf, level, 3, w, h, f1, s_stream, i_stream);
+ if (w1 > 0 && h1 > 0)
+ decode_quadrant (buf, level, 4, w1, h1, f, s_stream, i_stream);
+ if (w1 > 0 && f1 > 0)
+ decode_quadrant (buf, level, 5, w1, h, f1, s_stream, i_stream);
+ if (h1 > 0 && f1 > 0)
+ decode_quadrant (buf, level, 6, w, h1, f1, s_stream, i_stream);
+ if (h1 > 0 && f1 > 0 && f1 > 0)
+ decode_quadrant (buf, level, 7, w1, h1, f1, s_stream, i_stream);
+ }
}
#else
-static
-void encode_coefficients (const Wavelet3DBuf* buf,
- ENTROPY_CODER s_stream [],
- ENTROPY_CODER i_stream [])
+static void
+encode_coefficients (const Wavelet3DBuf * buf,
+ ENTROPY_CODER s_stream[], ENTROPY_CODER i_stream[])
{
- uint32_t i;
+ uint32_t i;
- for (i=0; i<buf->width*buf->height*buf->frames; i++)
- encode_coeff(s_stream, i_stream, buf->data[i]);
+ for (i = 0; i < buf->width * buf->height * buf->frames; i++)
+ encode_coeff (s_stream, i_stream, buf->data[i]);
}
-static
-void decode_coefficients (Wavelet3DBuf* buf,
- ENTROPY_CODER s_stream [],
- ENTROPY_CODER i_stream [])
+static void
+decode_coefficients (Wavelet3DBuf * buf,
+ ENTROPY_CODER s_stream[], ENTROPY_CODER i_stream[])
{
- uint32_t i;
+ uint32_t i;
- for (i=0; i<buf->width*buf->height*buf->frames; i++) {
- uint32_t skip;
+ for (i = 0; i < buf->width * buf->height * buf->frames; i++) {
+ uint32_t skip;
- buf->data[i] = decode_coeff(s_stream, i_stream);
+ buf->data[i] = decode_coeff (s_stream, i_stream);
- skip = skip_0coeffs (buf, s_stream, i_stream,
- buf->width*buf->height*buf->frames - i);
- i += skip;
- }
+ skip = skip_0coeffs (buf, s_stream, i_stream,
+ buf->width * buf->height * buf->frames - i);
+ i += skip;
+ }
}
#endif
-static
-uint32_t setup_limittabs (ENTROPY_CODER significand_bitstream [],
- ENTROPY_CODER insignificand_bitstream [],
- uint32_t significand_limittab [],
- uint32_t insignificand_limittab [],
- uint32_t limit)
+static uint32_t
+setup_limittabs (ENTROPY_CODER significand_bitstream[],
+ ENTROPY_CODER insignificand_bitstream[],
+ uint32_t significand_limittab[],
+ uint32_t insignificand_limittab[], uint32_t limit)
{
- uint32_t significand_limit;
- uint32_t insignificand_limit;
- uint32_t byte_count;
- int i;
-
- assert (limit > 2 * TYPE_BITS * sizeof(uint32_t)); /* limit too small */
-
- printf ("%s: limit == %u\n", __FUNCTION__, limit);
- byte_count = 2 * TYPE_BITS * sizeof(uint32_t); /* 2 binary coded limittabs */
- limit -= byte_count;
- printf ("%s: rem. limit == %u\n", __FUNCTION__, limit);
-
- significand_limit = limit * 7 / 8;
- insignificand_limit = limit - significand_limit;
-
- printf ("%s: limit == %u\n", __FUNCTION__, limit);
- printf ("significand limit == %u\n", significand_limit);
- printf ("insignificand limit == %u\n", insignificand_limit);
-
- for (i=TYPE_BITS-1; i>=0; i--) {
- uint32_t s_bytes, i_bytes;
-
- if (i > 0) {
- significand_limittab[i] = (significand_limit + 1) / 2;
- insignificand_limittab[i] = (insignificand_limit + 1) / 2;
- } else {
- significand_limittab[0] = significand_limit;
- insignificand_limittab[0] = insignificand_limit;
- }
+ uint32_t significand_limit;
+ uint32_t insignificand_limit;
+ uint32_t byte_count;
+ int i;
+
+ assert (limit > 2 * TYPE_BITS * sizeof (uint32_t)); /* limit too small */
+
+ printf ("%s: limit == %u\n", __FUNCTION__, limit);
+ byte_count = 2 * TYPE_BITS * sizeof (uint32_t); /* 2 binary coded limittabs */
+ limit -= byte_count;
+ printf ("%s: rem. limit == %u\n", __FUNCTION__, limit);
+
+ significand_limit = limit * 7 / 8;
+ insignificand_limit = limit - significand_limit;
- s_bytes = ENTROPY_ENCODER_FLUSH(&significand_bitstream[i]);
- i_bytes = ENTROPY_ENCODER_FLUSH(&insignificand_bitstream[i]);
+ printf ("%s: limit == %u\n", __FUNCTION__, limit);
+ printf ("significand limit == %u\n", significand_limit);
+ printf ("insignificand limit == %u\n", insignificand_limit);
- if (s_bytes < significand_limittab[i])
- significand_limittab[i] = s_bytes;
+ for (i = TYPE_BITS - 1; i >= 0; i--) {
+ uint32_t s_bytes, i_bytes;
- if (i_bytes < insignificand_limittab[i])
- insignificand_limittab[i] = i_bytes;
+ if (i > 0) {
+ significand_limittab[i] = (significand_limit + 1) / 2;
+ insignificand_limittab[i] = (insignificand_limit + 1) / 2;
+ } else {
+ significand_limittab[0] = significand_limit;
+ insignificand_limittab[0] = insignificand_limit;
+ }
- byte_count += significand_limittab[i];
- byte_count += insignificand_limittab[i];
+ s_bytes = ENTROPY_ENCODER_FLUSH (&significand_bitstream[i]);
+ i_bytes = ENTROPY_ENCODER_FLUSH (&insignificand_bitstream[i]);
- printf ("insignificand_limittab[%i] == %u / %u\n",
- i, insignificand_limittab[i], i_bytes);
- printf (" significand_limittab[%i] == %u / %u\n",
- i, significand_limittab[i], s_bytes);
+ if (s_bytes < significand_limittab[i])
+ significand_limittab[i] = s_bytes;
- significand_limit -= significand_limittab[i];
- insignificand_limit -= insignificand_limittab[i];
- }
+ if (i_bytes < insignificand_limittab[i])
+ insignificand_limittab[i] = i_bytes;
- printf ("byte_count == %u\n", byte_count);
+ byte_count += significand_limittab[i];
+ byte_count += insignificand_limittab[i];
- return byte_count;
+ printf ("insignificand_limittab[%i] == %u / %u\n",
+ i, insignificand_limittab[i], i_bytes);
+ printf (" significand_limittab[%i] == %u / %u\n",
+ i, significand_limittab[i], s_bytes);
+
+ significand_limit -= significand_limittab[i];
+ insignificand_limit -= insignificand_limittab[i];
+ }
+
+ printf ("byte_count == %u\n", byte_count);
+
+ return byte_count;
}
/**
* write 'em binary for now, should be easy to compress ...
*/
-static
-uint8_t* write_limittabs (uint8_t *bitstream,
- uint32_t significand_limittab [],
- uint32_t insignificand_limittab [])
+static uint8_t *
+write_limittabs (uint8_t * bitstream,
+ uint32_t significand_limittab[], uint32_t insignificand_limittab[])
{
- int i;
+ int i;
- for (i=0; i<TYPE_BITS; i++) {
- *(uint32_t*) bitstream = significand_limittab[i];
- bitstream += 4;
- }
+ for (i = 0; i < TYPE_BITS; i++) {
+ *(uint32_t *) bitstream = significand_limittab[i];
+ bitstream += 4;
+ }
- for (i=0; i<TYPE_BITS; i++) {
- *(uint32_t*) bitstream = insignificand_limittab[i];
- bitstream += 4;
- }
+ for (i = 0; i < TYPE_BITS; i++) {
+ *(uint32_t *) bitstream = insignificand_limittab[i];
+ bitstream += 4;
+ }
- return bitstream;
+ return bitstream;
}
-static
-uint8_t* read_limittabs (uint8_t *bitstream,
- uint32_t significand_limittab [],
- uint32_t insignificand_limittab [])
+static uint8_t *
+read_limittabs (uint8_t * bitstream,
+ uint32_t significand_limittab[], uint32_t insignificand_limittab[])
{
- int i;
-
- for (i=0; i<TYPE_BITS; i++) {
- significand_limittab[i] = *(uint32_t*) bitstream;
- printf ("significand_limittab[%i] == %u\n", i, significand_limittab[i]);
- bitstream += 4;
- }
-
- for (i=0; i<TYPE_BITS; i++) {
- insignificand_limittab[i] = *(uint32_t*) bitstream;
- printf ("insignificand_limittab[%i] == %u\n", i, insignificand_limittab[i]);
- bitstream += 4;
- }
-
- return bitstream;
+ int i;
+
+ for (i = 0; i < TYPE_BITS; i++) {
+ significand_limittab[i] = *(uint32_t *) bitstream;
+ printf ("significand_limittab[%i] == %u\n", i, significand_limittab[i]);
+ bitstream += 4;
+ }
+
+ for (i = 0; i < TYPE_BITS; i++) {
+ insignificand_limittab[i] = *(uint32_t *) bitstream;
+ printf ("insignificand_limittab[%i] == %u\n", i,
+ insignificand_limittab[i]);
+ bitstream += 4;
+ }
+
+ return bitstream;
}
/**
* concatenate entropy coder bitstreams
*/
-static
-void merge_bitstreams (uint8_t *bitstream,
- ENTROPY_CODER significand_bitstream [],
- ENTROPY_CODER insignificand_bitstream [],
- uint32_t significand_limittab [],
- uint32_t insignificand_limittab [])
+static void
+merge_bitstreams (uint8_t * bitstream,
+ ENTROPY_CODER significand_bitstream[],
+ ENTROPY_CODER insignificand_bitstream[],
+ uint32_t significand_limittab[], uint32_t insignificand_limittab[])
{
- int i;
+ int i;
- for (i=TYPE_BITS-1; i>=0; i--) {
- memcpy (bitstream,
- ENTROPY_CODER_BITSTREAM(&significand_bitstream[i]),
- significand_limittab[i]);
+ for (i = TYPE_BITS - 1; i >= 0; i--) {
+ memcpy (bitstream,
+ ENTROPY_CODER_BITSTREAM (&significand_bitstream[i]),
+ significand_limittab[i]);
- bitstream += significand_limittab[i];
- }
+ bitstream += significand_limittab[i];
+ }
- for (i=TYPE_BITS-1; i>=0; i--) {
- memcpy (bitstream,
- ENTROPY_CODER_BITSTREAM(&insignificand_bitstream[i]),
- insignificand_limittab[i]);
+ for (i = TYPE_BITS - 1; i >= 0; i--) {
+ memcpy (bitstream,
+ ENTROPY_CODER_BITSTREAM (&insignificand_bitstream[i]),
+ insignificand_limittab[i]);
- bitstream += insignificand_limittab[i];
- }
+ bitstream += insignificand_limittab[i];
+ }
}
-static
-void split_bitstreams (uint8_t *bitstream,
- ENTROPY_CODER significand_bitstream [],
- ENTROPY_CODER insignificand_bitstream [],
- uint32_t significand_limittab [],
- uint32_t insignificand_limittab [])
+static void
+split_bitstreams (uint8_t * bitstream,
+ ENTROPY_CODER significand_bitstream[],
+ ENTROPY_CODER insignificand_bitstream[],
+ uint32_t significand_limittab[], uint32_t insignificand_limittab[])
{
- uint32_t byte_count;
- int i;
-
- for (i=TYPE_BITS-1; i>=0; i--) {
- byte_count = significand_limittab[i];
- ENTROPY_DECODER_INIT(&significand_bitstream[i], bitstream, byte_count);
- bitstream += byte_count;
- }
-
- for (i=TYPE_BITS-1; i>=0; i--) {
- byte_count = insignificand_limittab[i];
- ENTROPY_DECODER_INIT(&insignificand_bitstream[i], bitstream, byte_count);
- bitstream += byte_count;
- }
+ uint32_t byte_count;
+ int i;
+
+ for (i = TYPE_BITS - 1; i >= 0; i--) {
+ byte_count = significand_limittab[i];
+ ENTROPY_DECODER_INIT (&significand_bitstream[i], bitstream, byte_count);
+ bitstream += byte_count;
+ }
+
+ for (i = TYPE_BITS - 1; i >= 0; i--) {
+ byte_count = insignificand_limittab[i];
+ ENTROPY_DECODER_INIT (&insignificand_bitstream[i], bitstream, byte_count);
+ bitstream += byte_count;
+ }
}
-int wavelet_3d_buf_encode_coeff (const Wavelet3DBuf* buf,
- uint8_t *bitstream,
- uint32_t limit)
+int
+wavelet_3d_buf_encode_coeff (const Wavelet3DBuf * buf,
+ uint8_t * bitstream, uint32_t limit)
{
- ENTROPY_CODER significand_bitstream [TYPE_BITS];
- ENTROPY_CODER insignificand_bitstream [TYPE_BITS];
- uint32_t significand_limittab [TYPE_BITS];
- uint32_t insignificand_limittab [TYPE_BITS];
- uint32_t byte_count;
- int i;
+ ENTROPY_CODER significand_bitstream[TYPE_BITS];
+ ENTROPY_CODER insignificand_bitstream[TYPE_BITS];
+ uint32_t significand_limittab[TYPE_BITS];
+ uint32_t insignificand_limittab[TYPE_BITS];
+ uint32_t byte_count;
+ int i;
- for (i=0; i<TYPE_BITS; i++)
- ENTROPY_ENCODER_INIT(&significand_bitstream[i], limit);
- for (i=0; i<TYPE_BITS; i++)
- ENTROPY_ENCODER_INIT(&insignificand_bitstream[i], limit);
+ for (i = 0; i < TYPE_BITS; i++)
+ ENTROPY_ENCODER_INIT (&significand_bitstream[i], limit);
+ for (i = 0; i < TYPE_BITS; i++)
+ ENTROPY_ENCODER_INIT (&insignificand_bitstream[i], limit);
- encode_coefficients (buf, significand_bitstream, insignificand_bitstream);
+ encode_coefficients (buf, significand_bitstream, insignificand_bitstream);
- byte_count = setup_limittabs (significand_bitstream, insignificand_bitstream,
- significand_limittab, insignificand_limittab,
- limit);
+ byte_count = setup_limittabs (significand_bitstream, insignificand_bitstream,
+ significand_limittab, insignificand_limittab, limit);
- bitstream = write_limittabs (bitstream,
- significand_limittab, insignificand_limittab);
+ bitstream = write_limittabs (bitstream,
+ significand_limittab, insignificand_limittab);
- merge_bitstreams (bitstream, significand_bitstream, insignificand_bitstream,
- significand_limittab, insignificand_limittab);
+ merge_bitstreams (bitstream, significand_bitstream, insignificand_bitstream,
+ significand_limittab, insignificand_limittab);
- for (i=0; i<TYPE_BITS; i++) {
- ENTROPY_ENCODER_DONE(&significand_bitstream[i]);
- ENTROPY_ENCODER_DONE(&insignificand_bitstream[i]);
- }
+ for (i = 0; i < TYPE_BITS; i++) {
+ ENTROPY_ENCODER_DONE (&significand_bitstream[i]);
+ ENTROPY_ENCODER_DONE (&insignificand_bitstream[i]);
+ }
- return byte_count;
+ return byte_count;
}
-void wavelet_3d_buf_decode_coeff (Wavelet3DBuf* buf,
- uint8_t *bitstream,
- uint32_t byte_count)
+void
+wavelet_3d_buf_decode_coeff (Wavelet3DBuf * buf,
+ uint8_t * bitstream, uint32_t byte_count)
{
- ENTROPY_CODER significand_bitstream [TYPE_BITS];
- ENTROPY_CODER insignificand_bitstream [TYPE_BITS];
- uint32_t significand_limittab [TYPE_BITS];
- uint32_t insignificand_limittab [TYPE_BITS];
- int i;
+ ENTROPY_CODER significand_bitstream[TYPE_BITS];
+ ENTROPY_CODER insignificand_bitstream[TYPE_BITS];
+ uint32_t significand_limittab[TYPE_BITS];
+ uint32_t insignificand_limittab[TYPE_BITS];
+ int i;
- memset (buf->data, 0,
- buf->width * buf->height * buf->frames * sizeof(TYPE));
+ memset (buf->data, 0, buf->width * buf->height * buf->frames * sizeof (TYPE));
- bitstream = read_limittabs (bitstream,
- significand_limittab, insignificand_limittab);
+ bitstream = read_limittabs (bitstream,
+ significand_limittab, insignificand_limittab);
- split_bitstreams (bitstream, significand_bitstream, insignificand_bitstream,
- significand_limittab, insignificand_limittab);
+ split_bitstreams (bitstream, significand_bitstream, insignificand_bitstream,
+ significand_limittab, insignificand_limittab);
- decode_coefficients (buf, significand_bitstream, insignificand_bitstream);
+ decode_coefficients (buf, significand_bitstream, insignificand_bitstream);
- for (i=0; i<TYPE_BITS; i++) {
- ENTROPY_DECODER_DONE(&significand_bitstream[i]);
- ENTROPY_DECODER_DONE(&insignificand_bitstream[i]);
- }
+ for (i = 0; i < TYPE_BITS; i++) {
+ ENTROPY_DECODER_DONE (&significand_bitstream[i]);
+ ENTROPY_DECODER_DONE (&insignificand_bitstream[i]);
+ }
}
-
-
-static
-void fwd_analyze_1 (const TYPE *x, TYPE *d, int stride, int n)
+static void
+fwd_analyze_1 (const TYPE * x, TYPE * d, int stride, int n)
{
- int i, k=n/2;
+ int i, k = n / 2;
- for (i=0; i<k; i++)
- d[i] = x[(2*i+1)*stride] - x[2*i*stride];
+ for (i = 0; i < k; i++)
+ d[i] = x[(2 * i + 1) * stride] - x[2 * i * stride];
}
-static
-void fwd_synthesize_1 (const TYPE *x, TYPE *s, const TYPE *d, int stride, int n)
+static void
+fwd_synthesize_1 (const TYPE * x, TYPE * s, const TYPE * d, int stride, int n)
{
- int i, k=n/2;
+ int i, k = n / 2;
- for (i=0; i<k; i++)
- s[i*stride] = x[2*i*stride] + d[i] / 2;
- if (n & 1)
- s[k*stride] = x[2*k*stride] + d[k-1] / 2;
+ for (i = 0; i < k; i++)
+ s[i * stride] = x[2 * i * stride] + d[i] / 2;
+ if (n & 1)
+ s[k * stride] = x[2 * k * stride] + d[k - 1] / 2;
}
-static
-void inv_analyze_1 (TYPE *x, const TYPE *d, int stride, int n)
+static void
+inv_analyze_1 (TYPE * x, const TYPE * d, int stride, int n)
{
- int i, k=n/2;
+ int i, k = n / 2;
- for (i=0; i<k; i++)
- x[(2*i+1)*stride] = d[i] + x[2*i*stride];
+ for (i = 0; i < k; i++)
+ x[(2 * i + 1) * stride] = d[i] + x[2 * i * stride];
}
-static
-void inv_synthesize_1 (TYPE *x, const TYPE *s, const TYPE *d, int stride, int n)
+static void
+inv_synthesize_1 (TYPE * x, const TYPE * s, const TYPE * d, int stride, int n)
{
- int i, k=n/2;
+ int i, k = n / 2;
- for (i=0; i<k; i++)
- x[2*i*stride] = s[i] - d[i] / 2;
- if (n & 1)
- x[2*k*stride] = s[k] - d[k-1] / 2;
+ for (i = 0; i < k; i++)
+ x[2 * i * stride] = s[i] - d[i] / 2;
+ if (n & 1)
+ x[2 * k * stride] = s[k] - d[k - 1] / 2;
}
-static
-void fwd_analyze_2 (const TYPE *x, TYPE *d, int stride, int n)
+static void
+fwd_analyze_2 (const TYPE * x, TYPE * d, int stride, int n)
{
- int i, k=n/2;
-
- if (n & 1) {
- for (i=0; i<k; i++)
- d[i] = x[(2*i+1)*stride] - (x[2*i*stride] + x[(2*i+2)*stride]) / 2;
- } else {
- for (i=0; i<k-1; i++)
- d[i] = x[(2*i+1)*stride] - (x[2*i*stride] + x[(2*i+2)*stride]) / 2;
- d[k-1] = x[(n-1)*stride] - x[(n-2)*stride];
- }
+ int i, k = n / 2;
+
+ if (n & 1) {
+ for (i = 0; i < k; i++)
+ d[i] =
+ x[(2 * i + 1) * stride] - (x[2 * i * stride] + x[(2 * i +
+ 2) * stride]) / 2;
+ } else {
+ for (i = 0; i < k - 1; i++)
+ d[i] =
+ x[(2 * i + 1) * stride] - (x[2 * i * stride] + x[(2 * i +
+ 2) * stride]) / 2;
+ d[k - 1] = x[(n - 1) * stride] - x[(n - 2) * stride];
+ }
}
-static
-void fwd_synthesize_2 (const TYPE *x, TYPE *s, const TYPE *d, int stride, int n)
+static void
+fwd_synthesize_2 (const TYPE * x, TYPE * s, const TYPE * d, int stride, int n)
{
- int i, k=n/2;
+ int i, k = n / 2;
- s[0] = x[0] + d[1] / 2;
- for (i=1; i<k; i++)
- s[i*stride] = x[2*i*stride] + (d[i-1] + d[i]) / 4;
- if (n & 1)
- s[k*stride] = x[2*k*stride] + d[k-1] / 2;
+ s[0] = x[0] + d[1] / 2;
+ for (i = 1; i < k; i++)
+ s[i * stride] = x[2 * i * stride] + (d[i - 1] + d[i]) / 4;
+ if (n & 1)
+ s[k * stride] = x[2 * k * stride] + d[k - 1] / 2;
}
-static inline
-void inv_analyze_2 (TYPE *x, const TYPE *d, int stride, int n)
+static inline void
+inv_analyze_2 (TYPE * x, const TYPE * d, int stride, int n)
{
- int i, k=n/2;
-
- if (n & 1) {
- for (i=0; i<k; i++)
- x[(2*i+1)*stride] = d[i] + (x[2*i*stride] + x[(2*i+2)*stride]) / 2;
- } else {
- for (i=0; i<k-1; i++)
- x[(2*i+1)*stride] = d[i] + (x[2*i*stride] + x[(2*i+2)*stride]) / 2;
- x[(n-1)*stride] = d[k-1] + x[(n-2)*stride];
- }
+ int i, k = n / 2;
+
+ if (n & 1) {
+ for (i = 0; i < k; i++)
+ x[(2 * i + 1) * stride] =
+ d[i] + (x[2 * i * stride] + x[(2 * i + 2) * stride]) / 2;
+ } else {
+ for (i = 0; i < k - 1; i++)
+ x[(2 * i + 1) * stride] =
+ d[i] + (x[2 * i * stride] + x[(2 * i + 2) * stride]) / 2;
+ x[(n - 1) * stride] = d[k - 1] + x[(n - 2) * stride];
+ }
}
-static inline
-void inv_synthesize_2 (TYPE *x, const TYPE *s, const TYPE *d, int stride, int n)
+static inline void
+inv_synthesize_2 (TYPE * x, const TYPE * s, const TYPE * d, int stride, int n)
{
- int i, k=n/2;
+ int i, k = n / 2;
- x[0] = s[0] - d[1] / 2;
- for (i=1; i<k; i++)
- x[2*i*stride] = s[i] - (d[i-1] + d[i]) / 4;
- if (n & 1)
- x[2*k*stride] = s[k] - d[k-1] / 2;
+ x[0] = s[0] - d[1] / 2;
+ for (i = 1; i < k; i++)
+ x[2 * i * stride] = s[i] - (d[i - 1] + d[i]) / 4;
+ if (n & 1)
+ x[2 * k * stride] = s[k] - d[k - 1] / 2;
}
-static
-void fwd_analyze_4 (const TYPE *x, TYPE *d, int stride, int n)
+static void
+fwd_analyze_4 (const TYPE * x, TYPE * d, int stride, int n)
{
- int i, k=n/2;
-
- d[0] = x[stride] - (x[0] + x[2*stride]) / 2;
-
- if (n & 1) {
- for (i=1; i<k-1; i++)
- d[i] = x[(2*i+1)*stride]
- - ((uint32_t) 9 * (x[2*i*stride] + x[(2*i+2)*stride])
- - (x[(2*i-2)*stride] + x[(2*i+4)*stride])) / 16;
- if (k > 1)
- d[k-1] = x[(2*k-1)*stride] - (x[(2*k-2)*stride] + x[2*k*stride]) / 2;
- } else {
- for (i=1; i<k-2; i++)
- d[i] = x[(2*i+1)*stride]
- - ((uint32_t) 9 * (x[2*i*stride] + x[(2*i+2)*stride])
- - (x[(2*i-2)*stride] + x[(2*i+4)*stride])) / 16;
- if (k > 2)
- d[k-2] = x[(2*k-3)*stride] - (x[(2*k-4)*stride]
- + x[(2*k-2)*stride]) / 2;
- if (k > 1)
- d[k-1] = x[(n-1)*stride] - x[(n-2)*stride];
- }
+ int i, k = n / 2;
+
+ d[0] = x[stride] - (x[0] + x[2 * stride]) / 2;
+
+ if (n & 1) {
+ for (i = 1; i < k - 1; i++)
+ d[i] = x[(2 * i + 1) * stride]
+ - ((uint32_t) 9 * (x[2 * i * stride] + x[(2 * i + 2) * stride])
+ - (x[(2 * i - 2) * stride] + x[(2 * i + 4) * stride])) / 16;
+ if (k > 1)
+ d[k - 1] =
+ x[(2 * k - 1) * stride] - (x[(2 * k - 2) * stride] +
+ x[2 * k * stride]) / 2;
+ } else {
+ for (i = 1; i < k - 2; i++)
+ d[i] = x[(2 * i + 1) * stride]
+ - ((uint32_t) 9 * (x[2 * i * stride] + x[(2 * i + 2) * stride])
+ - (x[(2 * i - 2) * stride] + x[(2 * i + 4) * stride])) / 16;
+ if (k > 2)
+ d[k - 2] = x[(2 * k - 3) * stride] - (x[(2 * k - 4) * stride]
+ + x[(2 * k - 2) * stride]) / 2;
+ if (k > 1)
+ d[k - 1] = x[(n - 1) * stride] - x[(n - 2) * stride];
+ }
}
-static
-void fwd_synthesize_4 (const TYPE *x, TYPE *s, const TYPE *d, int stride, int n)
+static void
+fwd_synthesize_4 (const TYPE * x, TYPE * s, const TYPE * d, int stride, int n)
{
- int i, k=n/2;
-
- s[0] = x[0] + d[1] / 2;
- if (k > 1)
- s[stride] = x[2*stride] + (d[0] + d[1]) / 4;
- for (i=2; i<k-1; i++)
- s[i*stride] = x[2*i*stride]
- + ((uint32_t) 9 * (d[i-1] + d[i]) - (d[i-2] + d[i+1])) / 32;
- if (k > 2)
- s[(k-1)*stride] = x[(2*k-2)*stride] + (d[k-2] + d[k-1]) / 4;
- if (n & 1)
- s[k*stride] = x[2*k*stride] + d[k-1] / 2;
+ int i, k = n / 2;
+
+ s[0] = x[0] + d[1] / 2;
+ if (k > 1)
+ s[stride] = x[2 * stride] + (d[0] + d[1]) / 4;
+ for (i = 2; i < k - 1; i++)
+ s[i * stride] = x[2 * i * stride]
+ + ((uint32_t) 9 * (d[i - 1] + d[i]) - (d[i - 2] + d[i + 1])) / 32;
+ if (k > 2)
+ s[(k - 1) * stride] = x[(2 * k - 2) * stride] + (d[k - 2] + d[k - 1]) / 4;
+ if (n & 1)
+ s[k * stride] = x[2 * k * stride] + d[k - 1] / 2;
}
-static
-void inv_analyze_4 (TYPE *x, const TYPE *d, int stride, int n)
+static void
+inv_analyze_4 (TYPE * x, const TYPE * d, int stride, int n)
{
- int i, k=n/2;
-
- x[stride] = d[0] + (x[0] + x[2*stride]) / 2;
-
- if (n & 1) {
- for (i=1; i<k-1; i++)
- x[(2*i+1)*stride] = d[i]
- + ((uint32_t) 9 * (x[2*i*stride] + x[(2*i+2)*stride])
- - (x[(2*i-2)*stride] + x[(2*i+4)*stride])) / 16;
- if (k > 1)
- x[(2*k-1)*stride] = d[k-1] + (x[(2*k-2)*stride] + x[2*k*stride]) / 2;
- } else {
- for (i=1; i<k-2; i++)
- x[(2*i+1)*stride] = d[i]
- + (9 * (x[2*i*stride] + x[(2*i+2)*stride])
- - (x[(2*i-2)*stride] + x[(2*i+4)*stride])) / 16;
- if (k > 2)
- x[(2*k-3)*stride] = d[k-2] + (x[(2*k-4)*stride]
- + x[(2*k-2)*stride]) / 2;
- if (k > 1)
- x[(n-1)*stride] = d[k-1] + x[(n-2)*stride];
- }
+ int i, k = n / 2;
+
+ x[stride] = d[0] + (x[0] + x[2 * stride]) / 2;
+
+ if (n & 1) {
+ for (i = 1; i < k - 1; i++)
+ x[(2 * i + 1) * stride] = d[i]
+ + ((uint32_t) 9 * (x[2 * i * stride] + x[(2 * i + 2) * stride])
+ - (x[(2 * i - 2) * stride] + x[(2 * i + 4) * stride])) / 16;
+ if (k > 1)
+ x[(2 * k - 1) * stride] =
+ d[k - 1] + (x[(2 * k - 2) * stride] + x[2 * k * stride]) / 2;
+ } else {
+ for (i = 1; i < k - 2; i++)
+ x[(2 * i + 1) * stride] = d[i]
+ + (9 * (x[2 * i * stride] + x[(2 * i + 2) * stride])
+ - (x[(2 * i - 2) * stride] + x[(2 * i + 4) * stride])) / 16;
+ if (k > 2)
+ x[(2 * k - 3) * stride] = d[k - 2] + (x[(2 * k - 4) * stride]
+ + x[(2 * k - 2) * stride]) / 2;
+ if (k > 1)
+ x[(n - 1) * stride] = d[k - 1] + x[(n - 2) * stride];
+ }
}
-static
-void inv_synthesize_4 (TYPE *x, const TYPE *s, const TYPE *d, int stride, int n)
+static void
+inv_synthesize_4 (TYPE * x, const TYPE * s, const TYPE * d, int stride, int n)
{
- int i, k=n/2;
-
- x[0] = s[0] - d[1] / 2;
- if (k > 1)
- x[2*stride] = s[1] - (d[0] + d[1]) / 4;
- for (i=2; i<k-1; i++)
- x[2*i*stride] = s[i] - ((uint32_t) 9 * (d[i-1] + d[i])
- - (d[i-2] + d[i+1])) / 32;
- if (k > 2)
- x[(2*k-2)*stride] = s[k-1] - (d[k-2] + d[k-1]) / 4;
- if (n & 1)
- x[2*k*stride] = s[k] - d[k-1] / 2;
+ int i, k = n / 2;
+
+ x[0] = s[0] - d[1] / 2;
+ if (k > 1)
+ x[2 * stride] = s[1] - (d[0] + d[1]) / 4;
+ for (i = 2; i < k - 1; i++)
+ x[2 * i * stride] = s[i] - ((uint32_t) 9 * (d[i - 1] + d[i])
+ - (d[i - 2] + d[i + 1])) / 32;
+ if (k > 2)
+ x[(2 * k - 2) * stride] = s[k - 1] - (d[k - 2] + d[k - 1]) / 4;
+ if (n & 1)
+ x[2 * k * stride] = s[k] - d[k - 1] / 2;
}
-static inline
-void copyback_d (TYPE *x, const TYPE *d, int stride, int n)
+static inline void
+copyback_d (TYPE * x, const TYPE * d, int stride, int n)
{
- int i, j, k=n/2;
+ int i, j, k = n / 2;
- for (i=n-k, j=0; i<n; i++, j++)
- x [i*stride] = d[j];
+ for (i = n - k, j = 0; i < n; i++, j++)
+ x[i * stride] = d[j];
}
-static inline
-void copy_s_d (const TYPE *x, TYPE *s_d, int stride, int n)
+static inline void
+copy_s_d (const TYPE * x, TYPE * s_d, int stride, int n)
{
- int i;
+ int i;
- for (i=0; i<n; i++)
- s_d[i] = x [i*stride];
+ for (i = 0; i < n; i++)
+ s_d[i] = x[i * stride];
}
typedef
-void (*FwdSFnc) (const TYPE *x, TYPE *s, const TYPE *d, int stride, int n);
+ void (*FwdSFnc) (const TYPE * x, TYPE * s, const TYPE * d, int stride,
+ int n);
-typedef
-void (*FwdAFnc) (const TYPE *x, TYPE *d, int stride, int n);
+typedef void (*FwdAFnc) (const TYPE * x, TYPE * d, int stride, int n);
typedef
-void (*InvSFnc) (TYPE *x, const TYPE *s, const TYPE *d, int stride, int n);
+ void (*InvSFnc) (TYPE * x, const TYPE * s, const TYPE * d, int stride,
+ int n);
-typedef
-void (*InvAFnc) (TYPE *x, const TYPE *d, int stride, int n);
+typedef void (*InvAFnc) (TYPE * x, const TYPE * d, int stride, int n);
-static FwdSFnc fwd_synthesize [] = { NULL, fwd_synthesize_1, fwd_synthesize_2,
- NULL, fwd_synthesize_4 };
+static FwdSFnc fwd_synthesize[] = { NULL, fwd_synthesize_1, fwd_synthesize_2,
+ NULL, fwd_synthesize_4
+};
-static FwdAFnc fwd_analyze [] = { NULL, fwd_analyze_1, fwd_analyze_2,
- NULL, fwd_analyze_4 };
+static FwdAFnc fwd_analyze[] = { NULL, fwd_analyze_1, fwd_analyze_2,
+ NULL, fwd_analyze_4
+};
-static InvSFnc inv_synthesize [] = { NULL, inv_synthesize_1, inv_synthesize_2,
- NULL, inv_synthesize_4 };
+static InvSFnc inv_synthesize[] = { NULL, inv_synthesize_1, inv_synthesize_2,
+ NULL, inv_synthesize_4
+};
-static InvAFnc inv_analyze [] = { NULL, inv_analyze_1, inv_analyze_2,
- NULL, inv_analyze_4 };
+static InvAFnc inv_analyze[] = { NULL, inv_analyze_1, inv_analyze_2,
+ NULL, inv_analyze_4
+};
-static inline
-void fwd_xform (TYPE *scratchbuf, TYPE *data, int stride, int n,
- int a_moments, int s_moments)
+static inline void
+fwd_xform (TYPE * scratchbuf, TYPE * data, int stride, int n,
+ int a_moments, int s_moments)
{
- TYPE *x = data;
- TYPE *d = scratchbuf;
- TYPE *s = data;
-
- assert (a_moments == 1 || a_moments == 2 || a_moments == 4);
- assert (s_moments == 1 || s_moments == 2 || s_moments == 4);
-
- /* XXX FIXME: Ugly hack to work around */
- /* the short-row bug in high */
- /* order xform functions */
- if (n < 9)
- a_moments = s_moments = 2;
- if (n < 5)
- a_moments = s_moments = 1;
-
- fwd_analyze [a_moments] (x, d, stride, n);
- fwd_synthesize [s_moments] (x, s, d, stride, n);
- copyback_d (x, d, stride, n);
+ TYPE *x = data;
+ TYPE *d = scratchbuf;
+ TYPE *s = data;
+
+ assert (a_moments == 1 || a_moments == 2 || a_moments == 4);
+ assert (s_moments == 1 || s_moments == 2 || s_moments == 4);
+
+ /* XXX FIXME: Ugly hack to work around */
+ /* the short-row bug in high */
+ /* order xform functions */
+ if (n < 9)
+ a_moments = s_moments = 2;
+ if (n < 5)
+ a_moments = s_moments = 1;
+
+ fwd_analyze[a_moments] (x, d, stride, n);
+ fwd_synthesize[s_moments] (x, s, d, stride, n);
+ copyback_d (x, d, stride, n);
}
-static inline
-void inv_xform (TYPE *scratchbuf, TYPE *data, int stride, int n,
- int a_moments, int s_moments)
+static inline void
+inv_xform (TYPE * scratchbuf, TYPE * data, int stride, int n,
+ int a_moments, int s_moments)
{
- int k=n/2;
- TYPE *x = data;
- TYPE *s = scratchbuf;
- TYPE *d = scratchbuf + n - k;
-
- assert (a_moments == 1 || a_moments == 2 || a_moments == 4);
- assert (s_moments == 1 || s_moments == 2 || s_moments == 4);
-
- /* XXX FIXME: Ugly hack to work around */
- /* the short-row bug in high */
- /* order xform functions */
- if (n < 9)
- a_moments = s_moments = 2;
- if (n < 5)
- a_moments = s_moments = 1;
-
- copy_s_d (data, scratchbuf, stride, n);
- inv_synthesize [s_moments] (x, s, d, stride, n);
- inv_analyze [a_moments] (x, d, stride, n);
+ int k = n / 2;
+ TYPE *x = data;
+ TYPE *s = scratchbuf;
+ TYPE *d = scratchbuf + n - k;
+
+ assert (a_moments == 1 || a_moments == 2 || a_moments == 4);
+ assert (s_moments == 1 || s_moments == 2 || s_moments == 4);
+
+ /* XXX FIXME: Ugly hack to work around */
+ /* the short-row bug in high */
+ /* order xform functions */
+ if (n < 9)
+ a_moments = s_moments = 2;
+ if (n < 5)
+ a_moments = s_moments = 1;
+
+ copy_s_d (data, scratchbuf, stride, n);
+ inv_synthesize[s_moments] (x, s, d, stride, n);
+ inv_analyze[a_moments] (x, d, stride, n);
}
-void wavelet_3d_buf_fwd_xform (Wavelet3DBuf* buf, int a_moments, int s_moments)
+void
+wavelet_3d_buf_fwd_xform (Wavelet3DBuf * buf, int a_moments, int s_moments)
{
- int level;
-
- for (level=buf->scales-1; level>0; level--) {
- uint32_t w = buf->w[level];
- uint32_t h = buf->h[level];
- uint32_t f = buf->f[level];
-
- if (w > 1) {
- int row, frame;
- for (frame=0; frame<f; frame++) {
- for (row=0; row<h; row++) {
- TYPE *data = buf->data + (frame * buf->height + row) * buf->width;
- fwd_xform (buf->scratchbuf, data, 1, w, a_moments, s_moments);
- }
- }
+ int level;
+
+ for (level = buf->scales - 1; level > 0; level--) {
+ uint32_t w = buf->w[level];
+ uint32_t h = buf->h[level];
+ uint32_t f = buf->f[level];
+
+ if (w > 1) {
+ int row, frame;
+
+ for (frame = 0; frame < f; frame++) {
+ for (row = 0; row < h; row++) {
+ TYPE *data = buf->data + (frame * buf->height + row) * buf->width;
+
+ fwd_xform (buf->scratchbuf, data, 1, w, a_moments, s_moments);
+ }
}
+ }
+
+ if (h > 1) {
+ int col, frame;
+
+ for (frame = 0; frame < f; frame++) {
+ for (col = 0; col < w; col++) {
+ TYPE *data = buf->data + frame * buf->width * buf->height + col;
- if (h > 1) {
- int col, frame;
- for (frame=0; frame<f; frame++) {
- for (col=0; col<w; col++) {
- TYPE *data = buf->data + frame * buf->width * buf->height + col;
- fwd_xform (buf->scratchbuf, data, buf->width, h,
- a_moments, s_moments);
- }
- }
+ fwd_xform (buf->scratchbuf, data, buf->width, h,
+ a_moments, s_moments);
+ }
}
+ }
+
+ if (f > 1) {
+ int i, j;
+
+ for (j = 0; j < h; j++) {
+ for (i = 0; i < w; i++) {
+ TYPE *data = buf->data + j * buf->width + i;
- if (f > 1) {
- int i, j;
- for (j=0; j<h; j++) {
- for (i=0; i<w; i++) {
- TYPE *data = buf->data + j*buf->width + i;
- fwd_xform (buf->scratchbuf, data, buf->width * buf->height, f,
- a_moments, s_moments);
- }
- }
+ fwd_xform (buf->scratchbuf, data, buf->width * buf->height, f,
+ a_moments, s_moments);
+ }
}
- }
+ }
+ }
}
-void wavelet_3d_buf_inv_xform (Wavelet3DBuf* buf, int a_moments, int s_moments)
+void
+wavelet_3d_buf_inv_xform (Wavelet3DBuf * buf, int a_moments, int s_moments)
{
- int level;
-
- for (level=1; level<buf->scales; level++) {
- uint32_t w = buf->w[level];
- uint32_t h = buf->h[level];
- uint32_t f = buf->f[level];
-
- if (f > 1) {
- int i, j;
- for (j=0; j<h; j++) {
- for (i=0; i<w; i++) {
- TYPE *data = buf->data + j*buf->width + i;
- inv_xform (buf->scratchbuf, data, buf->width * buf->height, f,
- a_moments, s_moments);
- }
- }
+ int level;
+
+ for (level = 1; level < buf->scales; level++) {
+ uint32_t w = buf->w[level];
+ uint32_t h = buf->h[level];
+ uint32_t f = buf->f[level];
+
+ if (f > 1) {
+ int i, j;
+
+ for (j = 0; j < h; j++) {
+ for (i = 0; i < w; i++) {
+ TYPE *data = buf->data + j * buf->width + i;
+
+ inv_xform (buf->scratchbuf, data, buf->width * buf->height, f,
+ a_moments, s_moments);
+ }
}
+ }
+
+ if (h > 1) {
+ int col, frame;
- if (h > 1) {
- int col, frame;
- for (frame=0; frame<f; frame++) {
- for (col=0; col<w; col++) {
- TYPE *data = buf->data + frame * buf->width * buf->height + col;
- inv_xform (buf->scratchbuf, data, buf->width, h,
- a_moments, s_moments);
- }
- }
+ for (frame = 0; frame < f; frame++) {
+ for (col = 0; col < w; col++) {
+ TYPE *data = buf->data + frame * buf->width * buf->height + col;
+
+ inv_xform (buf->scratchbuf, data, buf->width, h,
+ a_moments, s_moments);
+ }
}
+ }
+
+ if (w > 1) {
+ int row, frame;
- if (w > 1) {
- int row, frame;
- for (frame=0; frame<f; frame++) {
- for (row=0; row<h; row++) {
- TYPE *data = buf->data + (frame * buf->height + row) * buf->width;
- inv_xform (buf->scratchbuf, data, 1, w, a_moments, s_moments);
- }
- }
+ for (frame = 0; frame < f; frame++) {
+ for (row = 0; row < h; row++) {
+ TYPE *data = buf->data + (frame * buf->height + row) * buf->width;
+
+ inv_xform (buf->scratchbuf, data, 1, w, a_moments, s_moments);
+ }
}
- }
+ }
+ }
}
-
/*#define TARKIN_YUV_LXY*/
-static inline
-uint8_t CLAMP(int16_t x)
+static inline uint8_t
+CLAMP (int16_t x)
{
- return ((x > 255) ? 255 : (x < 0) ? 0 : x);
+ return ((x > 255) ? 255 : (x < 0) ? 0 : x);
}
-void rgb24_to_yuv (uint8_t *rgb, Wavelet3DBuf *yuv [], uint32_t frame)
+void
+rgb24_to_yuv (uint8_t * rgb, Wavelet3DBuf * yuv[], uint32_t frame)
{
- int count = yuv[0]->width * yuv[0]->height;
- int16_t *y = yuv[0]->data + frame * count;
- int16_t *u = yuv[1]->data + frame * count;
- int16_t *v = yuv[2]->data + frame * count;
- int i;
+ int count = yuv[0]->width * yuv[0]->height;
+ int16_t *y = yuv[0]->data + frame * count;
+ int16_t *u = yuv[1]->data + frame * count;
+ int16_t *v = yuv[2]->data + frame * count;
+ int i;
#if defined(TARKIN_YUV_EXACT)
- for (i=0; i<count; i++, rgb+=3) {
- y [i] = ((int16_t) 77 * rgb [0] + 150 * rgb [1] + 29 * rgb [2]) / 256;
- u [i] = ((int16_t) -44 * rgb [0] - 87 * rgb [1] + 131 * rgb [2]) / 256;
- v [i] = ((int16_t) 131 * rgb [0] - 110 * rgb [1] - 21 * rgb [2]) / 256;
- }
+ for (i = 0; i < count; i++, rgb += 3) {
+ y[i] = ((int16_t) 77 * rgb[0] + 150 * rgb[1] + 29 * rgb[2]) / 256;
+ u[i] = ((int16_t) - 44 * rgb[0] - 87 * rgb[1] + 131 * rgb[2]) / 256;
+ v[i] = ((int16_t) 131 * rgb[0] - 110 * rgb[1] - 21 * rgb[2]) / 256;
+ }
#elif defined(TARKIN_YUV_LXY)
- for (i=0; i<count; i++, rgb+=3) {
- y [i] = ((int16_t) 54 * rgb [0] + 182 * rgb [1] + 18 * rgb [2]) / 256;
- u [i] = rgb [0] - y [i];
- v [i] = rgb [2] - y [i];
- }
+ for (i = 0; i < count; i++, rgb += 3) {
+ y[i] = ((int16_t) 54 * rgb[0] + 182 * rgb[1] + 18 * rgb[2]) / 256;
+ u[i] = rgb[0] - y[i];
+ v[i] = rgb[2] - y[i];
+ }
#else
- for (i=0; i<count; i++, rgb+=3) {
- v [i] = rgb [0] - rgb [1];
- u [i] = rgb [2] - rgb [1];
- y [i] = rgb [1] + (u [i] + v [i]) / 4;
- }
+ for (i = 0; i < count; i++, rgb += 3) {
+ v[i] = rgb[0] - rgb[1];
+ u[i] = rgb[2] - rgb[1];
+ y[i] = rgb[1] + (u[i] + v[i]) / 4;
+ }
#endif
}
-void yuv_to_rgb24 (Wavelet3DBuf *yuv [], uint8_t *rgb, uint32_t frame)
+void
+yuv_to_rgb24 (Wavelet3DBuf * yuv[], uint8_t * rgb, uint32_t frame)
{
- int count = yuv[0]->width * yuv[0]->height;
- int16_t *y = yuv[0]->data + frame * count;
- int16_t *u = yuv[1]->data + frame * count;
- int16_t *v = yuv[2]->data + frame * count;
- int i;
+ int count = yuv[0]->width * yuv[0]->height;
+ int16_t *y = yuv[0]->data + frame * count;
+ int16_t *u = yuv[1]->data + frame * count;
+ int16_t *v = yuv[2]->data + frame * count;
+ int i;
#if defined(TARKIN_YUV_EXACT)
- for (i=0; i<count; i++, rgb+=3) {
- rgb [0] = CLAMP(y [i] + 1.371 * v [i]);
- rgb [1] = CLAMP(y [i] - 0.698 * v [i] - 0.336 * u [i]);
- rgb [2] = CLAMP(y [i] + 1.732 * u [i]);
- }
+ for (i = 0; i < count; i++, rgb += 3) {
+ rgb[0] = CLAMP (y[i] + 1.371 * v[i]);
+ rgb[1] = CLAMP (y[i] - 0.698 * v[i] - 0.336 * u[i]);
+ rgb[2] = CLAMP (y[i] + 1.732 * u[i]);
+ }
#elif defined(TARKIN_YUV_LXY)
- for (i=0; i<count; i++, rgb+=3) {
- rgb [1] = CLAMP(y [i] - (76 * u [i] - 26 * v [i]) / 256);
- rgb [0] = CLAMP(y [i] + u [i]);
- rgb [2] = CLAMP(y [i] + v [i]);
- }
+ for (i = 0; i < count; i++, rgb += 3) {
+ rgb[1] = CLAMP (y[i] - (76 * u[i] - 26 * v[i]) / 256);
+ rgb[0] = CLAMP (y[i] + u[i]);
+ rgb[2] = CLAMP (y[i] + v[i]);
+ }
#else
- for (i=0; i<count; i++, rgb+=3) {
- rgb [1] = CLAMP(y [i] - (u [i] + v [i]) / 4);
- rgb [2] = CLAMP(u [i] + rgb [1]);
- rgb [0] = CLAMP(v [i] + rgb [1]);
- }
+ for (i = 0; i < count; i++, rgb += 3) {
+ rgb[1] = CLAMP (y[i] - (u[i] + v[i]) / 4);
+ rgb[2] = CLAMP (u[i] + rgb[1]);
+ rgb[0] = CLAMP (v[i] + rgb[1]);
+ }
#endif
}
-void rgb32_to_yuv (uint8_t *rgb, Wavelet3DBuf *yuv [], uint32_t frame)
+void
+rgb32_to_yuv (uint8_t * rgb, Wavelet3DBuf * yuv[], uint32_t frame)
{
- int count = yuv[0]->width * yuv[0]->height;
- int16_t *y = yuv[0]->data + frame * count;
- int16_t *u = yuv[1]->data + frame * count;
- int16_t *v = yuv[2]->data + frame * count;
- int i;
+ int count = yuv[0]->width * yuv[0]->height;
+ int16_t *y = yuv[0]->data + frame * count;
+ int16_t *u = yuv[1]->data + frame * count;
+ int16_t *v = yuv[2]->data + frame * count;
+ int i;
#if defined(TARKIN_YUV_EXACT)
- for (i=0; i<count; i++, rgb+=4) {
- y [i] = ((int16_t) 77 * rgb [0] + 150 * rgb [1] + 29 * rgb [2]) / 256;
- u [i] = ((int16_t) -44 * rgb [0] - 87 * rgb [1] + 131 * rgb [2]) / 256;
- v [i] = ((int16_t) 131 * rgb [0] - 110 * rgb [1] - 21 * rgb [2]) / 256;
- }
+ for (i = 0; i < count; i++, rgb += 4) {
+ y[i] = ((int16_t) 77 * rgb[0] + 150 * rgb[1] + 29 * rgb[2]) / 256;
+ u[i] = ((int16_t) - 44 * rgb[0] - 87 * rgb[1] + 131 * rgb[2]) / 256;
+ v[i] = ((int16_t) 131 * rgb[0] - 110 * rgb[1] - 21 * rgb[2]) / 256;
+ }
#elif defined(TARKIN_YUV_LXY)
- for (i=0; i<count; i++, rgb+=4) {
- y [i] = ((int16_t) 54 * rgb [0] + 182 * rgb [1] + 18 * rgb [2]) / 256;
- u [i] = rgb [0] - y [i];
- v [i] = rgb [2] - y [i];
- }
+ for (i = 0; i < count; i++, rgb += 4) {
+ y[i] = ((int16_t) 54 * rgb[0] + 182 * rgb[1] + 18 * rgb[2]) / 256;
+ u[i] = rgb[0] - y[i];
+ v[i] = rgb[2] - y[i];
+ }
#else
- for (i=0; i<count; i++, rgb+=4) {
- v [i] = rgb [0] - rgb [1];
- u [i] = rgb [2] - rgb [1];
- y [i] = rgb [1] + (u [i] + v [i]) / 4;
- }
+ for (i = 0; i < count; i++, rgb += 4) {
+ v[i] = rgb[0] - rgb[1];
+ u[i] = rgb[2] - rgb[1];
+ y[i] = rgb[1] + (u[i] + v[i]) / 4;
+ }
#endif
}
-void yuv_to_rgb32 (Wavelet3DBuf *yuv [], uint8_t *rgb, uint32_t frame)
+void
+yuv_to_rgb32 (Wavelet3DBuf * yuv[], uint8_t * rgb, uint32_t frame)
{
- int count = yuv[0]->width * yuv[0]->height;
- int16_t *y = yuv[0]->data + frame * count;
- int16_t *u = yuv[1]->data + frame * count;
- int16_t *v = yuv[2]->data + frame * count;
- int i;
+ int count = yuv[0]->width * yuv[0]->height;
+ int16_t *y = yuv[0]->data + frame * count;
+ int16_t *u = yuv[1]->data + frame * count;
+ int16_t *v = yuv[2]->data + frame * count;
+ int i;
#if defined(TARKIN_YUV_EXACT)
- for (i=0; i<count; i++, rgb+=4) {
- rgb [0] = CLAMP(y [i] + 1.371 * v [i]);
- rgb [1] = CLAMP(y [i] - 0.698 * v [i] - 0.336 * u [i]);
- rgb [2] = CLAMP(y [i] + 1.732 * u [i]);
- }
+ for (i = 0; i < count; i++, rgb += 4) {
+ rgb[0] = CLAMP (y[i] + 1.371 * v[i]);
+ rgb[1] = CLAMP (y[i] - 0.698 * v[i] - 0.336 * u[i]);
+ rgb[2] = CLAMP (y[i] + 1.732 * u[i]);
+ }
#elif defined(TARKIN_YUV_LXY)
- for (i=0; i<count; i++, rgb+=4) {
- rgb [1] = CLAMP(y [i] - (76 * u [i] - 26 * v [i]) / 256);
- rgb [0] = CLAMP(y [i] + u [i]);
- rgb [2] = CLAMP(y [i] + v [i]);
- }
+ for (i = 0; i < count; i++, rgb += 4) {
+ rgb[1] = CLAMP (y[i] - (76 * u[i] - 26 * v[i]) / 256);
+ rgb[0] = CLAMP (y[i] + u[i]);
+ rgb[2] = CLAMP (y[i] + v[i]);
+ }
#else
- for (i=0; i<count; i++, rgb+=4) {
- rgb [1] = CLAMP(y [i] - (u [i] + v [i]) / 4);
- rgb [2] = CLAMP(u [i] + rgb [1]);
- rgb [0] = CLAMP(v [i] + rgb [1]);
- }
+ for (i = 0; i < count; i++, rgb += 4) {
+ rgb[1] = CLAMP (y[i] - (u[i] + v[i]) / 4);
+ rgb[2] = CLAMP (u[i] + rgb[1]);
+ rgb[0] = CLAMP (v[i] + rgb[1]);
+ }
#endif
}
-void rgba_to_yuv (uint8_t *rgba, Wavelet3DBuf *yuva [], uint32_t frame)
+void
+rgba_to_yuv (uint8_t * rgba, Wavelet3DBuf * yuva[], uint32_t frame)
{
- int count = yuva[0]->width * yuva[0]->height;
- int16_t *y = yuva[0]->data + frame * count;
- int16_t *u = yuva[1]->data + frame * count;
- int16_t *v = yuva[2]->data + frame * count;
- int16_t *a = yuva[3]->data + frame * count;
- int i;
+ int count = yuva[0]->width * yuva[0]->height;
+ int16_t *y = yuva[0]->data + frame * count;
+ int16_t *u = yuva[1]->data + frame * count;
+ int16_t *v = yuva[2]->data + frame * count;
+ int16_t *a = yuva[3]->data + frame * count;
+ int i;
#if defined(TARKIN_YUV_EXACT)
- for (i=0; i<count; i++, rgba+=4) {
- y [i] = ((int16_t) 77 * rgba [0] + 150 * rgba [1] + 29 * rgba [2]) / 256;
- u [i] = ((int16_t) -44 * rgba [0] - 87 * rgba [1] + 131 * rgba [2]) / 256;
- v [i] = ((int16_t) 131 * rgba [0] - 110 * rgba [1] - 21 * rgba [2]) / 256;
- a [i] = rgba [3];
- }
+ for (i = 0; i < count; i++, rgba += 4) {
+ y[i] = ((int16_t) 77 * rgba[0] + 150 * rgba[1] + 29 * rgba[2]) / 256;
+ u[i] = ((int16_t) - 44 * rgba[0] - 87 * rgba[1] + 131 * rgba[2]) / 256;
+ v[i] = ((int16_t) 131 * rgba[0] - 110 * rgba[1] - 21 * rgba[2]) / 256;
+ a[i] = rgba[3];
+ }
#elif defined(TARKIN_YUV_LXY)
- for (i=0; i<count; i++, rgba+=4) {
- y [i] = ((int16_t) 54 * rgba [0] + 182 * rgba [1] + 18 * rgba [2]) / 256;
- u [i] = rgba [0] - y [i];
- v [i] = rgba [2] - y [i];
- a [i] = rgba [3];
- }
+ for (i = 0; i < count; i++, rgba += 4) {
+ y[i] = ((int16_t) 54 * rgba[0] + 182 * rgba[1] + 18 * rgba[2]) / 256;
+ u[i] = rgba[0] - y[i];
+ v[i] = rgba[2] - y[i];
+ a[i] = rgba[3];
+ }
#else
- for (i=0; i<count; i++, rgba+=4) {
- v [i] = rgba [0] - rgba [1];
- u [i] = rgba [2] - rgba [1];
- y [i] = rgba [1] + (u [i] + v [i]) / 4;
- a [i] = rgba [3];
- }
+ for (i = 0; i < count; i++, rgba += 4) {
+ v[i] = rgba[0] - rgba[1];
+ u[i] = rgba[2] - rgba[1];
+ y[i] = rgba[1] + (u[i] + v[i]) / 4;
+ a[i] = rgba[3];
+ }
#endif
}
-void yuv_to_rgba (Wavelet3DBuf *yuva [], uint8_t *rgba, uint32_t frame)
+void
+yuv_to_rgba (Wavelet3DBuf * yuva[], uint8_t * rgba, uint32_t frame)
{
- int count = yuva[0]->width * yuva[0]->height;
- int16_t *y = yuva[0]->data + frame * count;
- int16_t *u = yuva[1]->data + frame * count;
- int16_t *v = yuva[2]->data + frame * count;
- int16_t *a = yuva[3]->data + frame * count;
- int i;
+ int count = yuva[0]->width * yuva[0]->height;
+ int16_t *y = yuva[0]->data + frame * count;
+ int16_t *u = yuva[1]->data + frame * count;
+ int16_t *v = yuva[2]->data + frame * count;
+ int16_t *a = yuva[3]->data + frame * count;
+ int i;
#if defined(TARKIN_YUV_EXACT)
- for (i=0; i<count; i++, rgba+=4) {
- rgba [0] = CLAMP(y [i] + 1.371 * v [i]);
- rgba [1] = CLAMP(y [i] - 0.698 * v [i] - 0.336 * u [i]);
- rgba [2] = CLAMP(y [i] + 1.732 * u [i]);
- rgba [3] = a [i];
- }
+ for (i = 0; i < count; i++, rgba += 4) {
+ rgba[0] = CLAMP (y[i] + 1.371 * v[i]);
+ rgba[1] = CLAMP (y[i] - 0.698 * v[i] - 0.336 * u[i]);
+ rgba[2] = CLAMP (y[i] + 1.732 * u[i]);
+ rgba[3] = a[i];
+ }
#elif defined(TARKIN_YUV_LXY)
- for (i=0; i<count; i++, rgba+=4) {
- rgba [1] = CLAMP(y [i] - (76 * u [i] - 26 * v [i]) / 256);
- rgba [0] = CLAMP(y [i] + u [i]);
- rgba [2] = CLAMP(y [i] + v [i]);
- rgba [3] = a [i];
- }
+ for (i = 0; i < count; i++, rgba += 4) {
+ rgba[1] = CLAMP (y[i] - (76 * u[i] - 26 * v[i]) / 256);
+ rgba[0] = CLAMP (y[i] + u[i]);
+ rgba[2] = CLAMP (y[i] + v[i]);
+ rgba[3] = a[i];
+ }
#else
- for (i=0; i<count; i++, rgba+=4) {
- rgba [1] = CLAMP(y [i] - (u [i] + v [i]) / 4);
- rgba [2] = CLAMP(u [i] + rgba [1]);
- rgba [0] = CLAMP(v [i] + rgba [1]);
- rgba [3] = a [i];
- }
+ for (i = 0; i < count; i++, rgba += 4) {
+ rgba[1] = CLAMP (y[i] - (u[i] + v[i]) / 4);
+ rgba[2] = CLAMP (u[i] + rgba[1]);
+ rgba[0] = CLAMP (v[i] + rgba[1]);
+ rgba[3] = a[i];
+ }
#endif
}
-void grayscale_to_y (uint8_t *rgba, Wavelet3DBuf *y [], uint32_t frame)
+void
+grayscale_to_y (uint8_t * rgba, Wavelet3DBuf * y[], uint32_t frame)
{
- int count = y[0]->width * y[0]->height;
- int16_t *_y = y[0]->data + frame * count;
- int i;
+ int count = y[0]->width * y[0]->height;
+ int16_t *_y = y[0]->data + frame * count;
+ int i;
- for (i=0; i<count; i++)
- _y [i] = rgba [i];
+ for (i = 0; i < count; i++)
+ _y[i] = rgba[i];
}
-void y_to_grayscale (Wavelet3DBuf *y [], uint8_t *rgba, uint32_t frame)
+void
+y_to_grayscale (Wavelet3DBuf * y[], uint8_t * rgba, uint32_t frame)
{
- int count = y[0]->width * y[0]->height;
- int16_t *_y = y[0]->data + frame * count;
- int i;
+ int count = y[0]->width * y[0]->height;
+ int16_t *_y = y[0]->data + frame * count;
+ int i;
- for (i=0; i<count; i++)
- rgba [i] = CLAMP(_y[i]);
+ for (i = 0; i < count; i++)
+ rgba[i] = CLAMP (_y[i]);
}
-
-
#include <stdint.h>
#include "wavelet.h"
-extern void rgb24_to_yuv (uint8_t *rgb, Wavelet3DBuf *yuv [], uint32_t frame);
-extern void yuv_to_rgb24 (Wavelet3DBuf *yuv [], uint8_t *rgb, uint32_t frame);
+extern void rgb24_to_yuv (uint8_t * rgb, Wavelet3DBuf * yuv[], uint32_t frame);
+extern void yuv_to_rgb24 (Wavelet3DBuf * yuv[], uint8_t * rgb, uint32_t frame);
-extern void rgb32_to_yuv (uint8_t *rgb, Wavelet3DBuf *yuv [], uint32_t frame);
-extern void yuv_to_rgb32 (Wavelet3DBuf *yuv [], uint8_t *rgb, uint32_t frame);
+extern void rgb32_to_yuv (uint8_t * rgb, Wavelet3DBuf * yuv[], uint32_t frame);
+extern void yuv_to_rgb32 (Wavelet3DBuf * yuv[], uint8_t * rgb, uint32_t frame);
-extern void rgba_to_yuv (uint8_t *rgba, Wavelet3DBuf *yuva [], uint32_t frame);
-extern void yuv_to_rgba (Wavelet3DBuf *yuva [], uint8_t *rgba, uint32_t frame);
+extern void rgba_to_yuv (uint8_t * rgba, Wavelet3DBuf * yuva[], uint32_t frame);
+extern void yuv_to_rgba (Wavelet3DBuf * yuva[], uint8_t * rgba, uint32_t frame);
-extern void grayscale_to_y (uint8_t *rgba, Wavelet3DBuf *y [], uint32_t frame);
-extern void y_to_grayscale (Wavelet3DBuf *y [], uint8_t *rgba, uint32_t frame);
+extern void grayscale_to_y (uint8_t * rgba, Wavelet3DBuf * y[], uint32_t frame);
+extern void y_to_grayscale (Wavelet3DBuf * y[], uint8_t * rgba, uint32_t frame);
#endif
-
#include <xine/buffer.h>
G_BEGIN_DECLS
-
#define GST_TYPE_XINE \
(gst_xine_get_type())
#define GST_XINE(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_XINE))
#define GST_IS_XINE_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_XINE))
-
-typedef struct _GstXine GstXine;
+typedef struct _GstXine GstXine;
typedef struct _GstXineClass GstXineClass;
struct _GstXine
{
- GstElement element;
+ GstElement element;
- xine_stream_t * stream;
- xine_ao_driver_t * audio_driver;
- xine_vo_driver_t * video_driver;
+ xine_stream_t *stream;
+ xine_ao_driver_t *audio_driver;
+ xine_vo_driver_t *video_driver;
};
-struct _GstXineClass
+struct _GstXineClass
{
- GstElementClass parent_class;
+ GstElementClass parent_class;
- xine_t * xine;
+ xine_t *xine;
- xine_ao_driver_t * (* create_audio_driver) (GstXine * xine);
- xine_vo_driver_t * (* create_video_driver) (GstXine * xine);
+ xine_ao_driver_t *(*create_audio_driver) (GstXine * xine);
+ xine_vo_driver_t *(*create_video_driver) (GstXine * xine);
};
-GType gst_xine_get_type (void);
+GType gst_xine_get_type (void);
-xine_stream_t * gst_xine_get_stream (GstXine *xine);
-void gst_xine_free_stream (GstXine *xine);
+xine_stream_t *gst_xine_get_stream (GstXine * xine);
+void gst_xine_free_stream (GstXine * xine);
-void gst_buffer_to_xine_buffer (buf_element_t *element, GstBuffer *buffer);
+void gst_buffer_to_xine_buffer (buf_element_t * element, GstBuffer * buffer);
/* conversion functions from xinecaps.c */
-const gchar * gst_xine_get_caps_for_format (guint32 format);
-guint32 gst_xine_get_format_for_caps (const GstCaps *caps);
+const gchar *gst_xine_get_caps_for_format (guint32 format);
+guint32 gst_xine_get_format_for_caps (const GstCaps * caps);
/* init functions for the plugins */
-gboolean gst_xine_audio_sink_init_plugin (GstPlugin *plugin);
-gboolean gst_xine_audio_dec_init_plugin (GstPlugin *plugin);
-gboolean gst_xine_input_init_plugin (GstPlugin *plugin);
-
-G_END_DECLS
+gboolean gst_xine_audio_sink_init_plugin (GstPlugin * plugin);
+gboolean gst_xine_audio_dec_init_plugin (GstPlugin * plugin);
+gboolean gst_xine_input_init_plugin (GstPlugin * plugin);
+G_END_DECLS
#endif /* __GST_XINE_H__ */
GST_BOILERPLATE (GstXine, gst_xine, GstElement, GST_TYPE_ELEMENT)
-static GstElementStateReturn gst_xine_change_state (GstElement * element);
-
-static xine_ao_driver_t * _xine_create_audio_driver (GstXine * xine);
-static xine_vo_driver_t * _xine_create_video_driver (GstXine * xine);
+ static GstElementStateReturn gst_xine_change_state (GstElement * element);
+ static xine_ao_driver_t *_xine_create_audio_driver (GstXine * xine);
+ static xine_vo_driver_t *_xine_create_video_driver (GstXine * xine);
-static void
-gst_xine_base_init (gpointer klass)
+
+ static void gst_xine_base_init (gpointer klass)
{
}
static void
-gst_xine_class_init (GstXineClass *klass)
+gst_xine_class_init (GstXineClass * klass)
{
GstElementClass *element = GST_ELEMENT_CLASS (klass);
-
+
klass->xine = xine_new ();
xine_init (klass->xine);
}
static void
-gst_xine_init (GstXine *filter)
+gst_xine_init (GstXine * filter)
{
}
static GstElementStateReturn
-gst_xine_change_state (GstElement *element)
+gst_xine_change_state (GstElement * element)
{
GstXine *xine = GST_XINE (element);
-
+
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY:
break;
GST_ERROR_OBJECT (element, "invalid state change");
break;
}
-
- return GST_CALL_PARENT_WITH_DEFAULT (GST_ELEMENT_CLASS, change_state, (element), GST_STATE_SUCCESS);
+
+ return GST_CALL_PARENT_WITH_DEFAULT (GST_ELEMENT_CLASS, change_state,
+ (element), GST_STATE_SUCCESS);
}
static xine_ao_driver_t *
-_xine_create_audio_driver (GstXine *xine)
+_xine_create_audio_driver (GstXine * xine)
{
return xine_open_audio_driver (GST_XINE_GET_CLASS (xine)->xine, "none", NULL);
}
static xine_vo_driver_t *
-_xine_create_video_driver (GstXine *xine)
+_xine_create_video_driver (GstXine * xine)
{
- return xine_open_video_driver (GST_XINE_GET_CLASS (xine)->xine, "none", XINE_VISUAL_TYPE_NONE, NULL);
+ return xine_open_video_driver (GST_XINE_GET_CLASS (xine)->xine, "none",
+ XINE_VISUAL_TYPE_NONE, NULL);
}
xine_stream_t *
-gst_xine_get_stream (GstXine *xine)
+gst_xine_get_stream (GstXine * xine)
{
if (!xine->stream) {
GstXineClass *klass = GST_XINE_GET_CLASS (xine);
+
g_assert (xine->video_driver == NULL);
g_assert (xine->audio_driver == NULL);
xine->audio_driver = klass->create_audio_driver (xine);
xine->video_driver = klass->create_video_driver (xine);
- xine->stream = xine_stream_new (klass->xine, xine->audio_driver, xine->video_driver);
+ xine->stream =
+ xine_stream_new (klass->xine, xine->audio_driver, xine->video_driver);
/* FIXME: fail gracefully */
g_assert (xine->stream);
}
void
-gst_xine_free_stream (GstXine *xine)
+gst_xine_free_stream (GstXine * xine)
{
g_return_if_fail (xine->stream != NULL);
g_assert (xine->video_driver != NULL);
}
static void
-_free_xine_buf_element (buf_element_t *buffer)
+_free_xine_buf_element (buf_element_t * buffer)
{
gst_buffer_unref (GST_BUFFER (buffer->source));
}
void
-gst_buffer_to_xine_buffer (buf_element_t *ret, GstBuffer *buffer)
+gst_buffer_to_xine_buffer (buf_element_t * ret, GstBuffer * buffer)
{
g_return_if_fail (ret != NULL);
g_return_if_fail (buffer != NULL);
-
+
/* FIXME: what's the difference? */
ret->mem = GST_BUFFER_DATA (buffer);
ret->content = GST_BUFFER_DATA (buffer);
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
if (!gst_xine_input_init_plugin (plugin) ||
!gst_xine_audio_dec_init_plugin (plugin) ||
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "xine",
- "wrapper for libxine (version "XINE_VERSION") plugins",
- plugin_init,
- VERSION,
- "GPL",
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "xine",
+ "wrapper for libxine (version " XINE_VERSION ") plugins",
+ plugin_init, VERSION, "GPL", GST_PACKAGE, GST_ORIGIN)
GType gst_xine_audio_dec_get_type (void);
-typedef struct _GstXineAudioDec GstXineAudioDec;
+typedef struct _GstXineAudioDec GstXineAudioDec;
typedef struct _GstXineAudioDecClass GstXineAudioDecClass;
struct _GstXineAudioDec
{
- GstXine parent;
+ GstXine parent;
- GstPad * sinkpad;
- GstPad * srcpad;
+ GstPad *sinkpad;
+ GstPad *srcpad;
- audio_decoder_t * decoder;
- guint32 format;
- xine_waveformatex wave;
- gboolean setup;
+ audio_decoder_t *decoder;
+ guint32 format;
+ xine_waveformatex wave;
+ gboolean setup;
};
-struct _GstXineAudioDecClass
+struct _GstXineAudioDecClass
{
- GstXineClass parent_class;
+ GstXineClass parent_class;
- plugin_node_t * plugin_node;
+ plugin_node_t *plugin_node;
};
/*** xine audio driver wrapper ************************************************/
-
-typedef struct {
- xine_ao_driver_t driver;
- GstXineAudioDec * xine;
- gboolean open;
+
+typedef struct
+{
+ xine_ao_driver_t driver;
+ GstXineAudioDec *xine;
+ gboolean open;
} GstXineAudioDriver;
static guint32
-_driver_get_capabilities (xine_ao_driver_t *driver)
+_driver_get_capabilities (xine_ao_driver_t * driver)
{
/* FIXME: add more when gst handles more than 2 channels */
return AO_CAP_MODE_MONO | AO_CAP_MODE_STEREO | AO_CAP_8BITS;
}
static gint
-_driver_get_property (xine_ao_driver_t *driver, int property)
+_driver_get_property (xine_ao_driver_t * driver, int property)
{
return 0;
}
}
static gint
-_driver_open (xine_ao_driver_t *driver, xine_stream_t *stream, guint32 bits, guint32 rate, int mode)
+_driver_open (xine_ao_driver_t * driver, xine_stream_t * stream, guint32 bits,
+ guint32 rate, int mode)
{
GstCaps *caps;
GstXineAudioDriver *xine = ((GstXineAudioDriver *) driver);
-
+
caps = gst_caps_new_simple ("audio/x-raw-int",
- "endianness", G_TYPE_INT, G_BYTE_ORDER,
- "width", G_TYPE_INT, (gint) bits,
- "depth", G_TYPE_INT, (gint) bits,
- "signed", G_TYPE_BOOLEAN, (bits == 8) ? FALSE : TRUE,
- "channels", G_TYPE_INT, (mode | AO_CAP_MODE_STEREO) ? 2 : 1,
- "rate", G_TYPE_INT, rate,
- NULL);
-
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "width", G_TYPE_INT, (gint) bits,
+ "depth", G_TYPE_INT, (gint) bits,
+ "signed", G_TYPE_BOOLEAN, (bits == 8) ? FALSE : TRUE,
+ "channels", G_TYPE_INT, (mode | AO_CAP_MODE_STEREO) ? 2 : 1,
+ "rate", G_TYPE_INT, rate, NULL);
+
if (!gst_pad_set_explicit_caps (xine->xine->srcpad, caps)) {
gst_caps_free (caps);
driver->open = FALSE;
return -1;
}
-
+
xine->open = TRUE;
gst_caps_free (caps);
return rate;
}
static void
-_driver_close (xine_ao_driver_t *driver, xine_stream_t *stream)
+_driver_close (xine_ao_driver_t * driver, xine_stream_t * stream)
{
/* FIXME: unset explicit caps here? And how? */
driver->open = FALSE;
}
static void
-_driver_exit (xine_ao_driver_t *driver)
+_driver_exit (xine_ao_driver_t * driver)
{
g_free (driver);
}
static int
-_driver_control (xine_ao_driver_t *driver, int cmd, ...)
+_driver_control (xine_ao_driver_t * driver, int cmd, ...)
{
return 0;
}
static void
-_driver_flush (xine_ao_driver_t *driver)
+_driver_flush (xine_ao_driver_t * driver)
{
}
static int
-_driver_status (xine_ao_driver_t *driver, xine_stream_t *stream, uint32_t *bits, uint32_t *rate, int *mode)
+_driver_status (xine_ao_driver_t * driver, xine_stream_t * stream,
+ uint32_t * bits, uint32_t * rate, int *mode)
{
const GstCaps *caps;
GstStructure *structure;
gint temp;
GstXineAudioDriver *xine = (GstXineAudioDriver *) driver;
-
- if (xine->open == FALSE || !(caps = gst_pad_get_negotiated_caps (xine->xine->srcpad)))
+
+ if (xine->open == FALSE
+ || !(caps = gst_pad_get_negotiated_caps (xine->xine->srcpad)))
return 0;
structure = gst_caps_get_structure (caps, 0);
- *bits = 0; /* FIXME */
+ *bits = 0; /* FIXME */
if (!gst_structure_get_int (structure, "rate", &temp)) {
- g_assert_not_reached (); /* may never happen with negotiated caps */
+ g_assert_not_reached (); /* may never happen with negotiated caps */
return 0;
}
*rate = temp;
if (!gst_structure_get_int (structure, "channels", &temp)) {
- g_assert_not_reached (); /* may never happen with negotiated caps */
+ g_assert_not_reached (); /* may never happen with negotiated caps */
return 0;
}
*mode = (temp == 2) ? AO_CAP_MODE_STEREO : AO_CAP_MODE_MONO;
if (!gst_structure_get_int (structure, "width", &temp)) {
- g_assert_not_reached (); /* may never happen with negotiated caps */
+ g_assert_not_reached (); /* may never happen with negotiated caps */
return 0;
}
if (temp == 8)
#define _DRIVER_BUFFER_SIZE 4096
static audio_buffer_t *
-_driver_get_buffer (xine_ao_driver_t *driver)
+_driver_get_buffer (xine_ao_driver_t * driver)
{
GstXineAudioDriver *xine = (GstXineAudioDriver *) driver;
- audio_buffer_t *audio = g_new0 (audio_buffer_t, 1);
+ audio_buffer_t *audio = g_new0 (audio_buffer_t, 1);
audio->mem = g_malloc (_DRIVER_BUFFER_SIZE);
audio->mem_size = _DRIVER_BUFFER_SIZE;
audio->stream = gst_xine_get_stream (GST_XINE (xine->xine));
/* FIXME: fill more fields */
-
+
return audio;
}
-static void
-_driver_put_buffer (xine_ao_driver_t *driver, audio_buffer_t *audio, xine_stream_t *stream)
+static void
+_driver_put_buffer (xine_ao_driver_t * driver, audio_buffer_t * audio,
+ xine_stream_t * stream)
{
GstXineAudioDriver *xine = (GstXineAudioDriver *) driver;
GstBuffer *buffer;
-
+
buffer = gst_buffer_new ();
GST_BUFFER_DATA (buffer) = (guint8 *) audio->mem;
GST_BUFFER_SIZE (buffer) = audio->mem_size;
g_free (audio);
gst_pad_push (xine->xine->srcpad, GST_DATA (buffer));
}
-
+
static xine_ao_driver_t *
-_gst_xine_audio_dec_create_audio_driver (GstXine *xine)
+_gst_xine_audio_dec_create_audio_driver (GstXine * xine)
{
GstXineAudioDriver *driver = g_new (GstXineAudioDriver, 1);
driver->xine = GST_XINE_AUDIO_DEC (xine);
driver->open = FALSE;
-
- driver->driver.get_buffer = _driver_get_buffer;
- driver->driver.put_buffer = _driver_put_buffer;
- driver->driver.get_capabilities = _driver_get_capabilities;
- driver->driver.get_property = _driver_get_property;
- driver->driver.set_property = _driver_set_property;
- driver->driver.open = _driver_open;
- driver->driver.close = _driver_close;
- driver->driver.exit = _driver_exit;
- driver->driver.control = _driver_control;
- driver->driver.flush = _driver_flush;
- driver->driver.status = _driver_status;
-
+
+ driver->driver.get_buffer = _driver_get_buffer;
+ driver->driver.put_buffer = _driver_put_buffer;
+ driver->driver.get_capabilities = _driver_get_capabilities;
+ driver->driver.get_property = _driver_get_property;
+ driver->driver.set_property = _driver_set_property;
+ driver->driver.open = _driver_open;
+ driver->driver.close = _driver_close;
+ driver->driver.exit = _driver_exit;
+ driver->driver.control = _driver_control;
+ driver->driver.flush = _driver_flush;
+ driver->driver.status = _driver_status;
+
return (xine_ao_driver_t *) driver;
}
GST_BOILERPLATE (GstXineAudioDec, gst_xine_audio_dec, GstXine, GST_TYPE_XINE)
-static void gst_xine_audio_dec_chain (GstPad *pad, GstData *in);
-static GstElementStateReturn
- gst_xine_audio_dec_change_state (GstElement *element);
+ static void gst_xine_audio_dec_chain (GstPad * pad, GstData * in);
+ static GstElementStateReturn
+ gst_xine_audio_dec_change_state (GstElement * element);
/* this function handles the link with other plug-ins */
-static GstPadLinkReturn
-gst_xine_audio_dec_sink_link (GstPad *pad, const GstCaps *caps)
+ static GstPadLinkReturn
+ gst_xine_audio_dec_sink_link (GstPad * pad, const GstCaps * caps)
{
guint temp;
GstStructure *structure;
- GstXineAudioDec *xine = GST_XINE_AUDIO_DEC (gst_object_get_parent (GST_OBJECT (pad)));
+ GstXineAudioDec *xine =
+ GST_XINE_AUDIO_DEC (gst_object_get_parent (GST_OBJECT (pad)));
xine->format = gst_xine_get_format_for_caps (caps);
- if (xine->format == 0) return GST_PAD_LINK_REFUSED;
+ if (xine->format == 0)
+ return GST_PAD_LINK_REFUSED;
/* get setup data */
xine->setup = FALSE;
xine->wave.nChannels = temp;
if (gst_structure_get_int (structure, "rate", &temp))
xine->wave.nSamplesPerSec = temp;
- xine->wave.wBitsPerSample = 16; /* FIXME: how do we figure this thing out? */
+ xine->wave.wBitsPerSample = 16; /* FIXME: how do we figure this thing out? */
/* FIXME: fill wave header better */
return GST_PAD_LINK_OK;
}
static void
-gst_xine_audio_dec_class_init (GstXineAudioDecClass *klass)
+gst_xine_audio_dec_class_init (GstXineAudioDecClass * klass)
{
GstXineClass *xine = GST_XINE_CLASS (klass);
GstElementClass *element = GST_ELEMENT_CLASS (klass);
}
static void
-gst_xine_audio_dec_init (GstXineAudioDec *xine)
+gst_xine_audio_dec_init (GstXineAudioDec * xine)
{
xine->setup = FALSE;
}
static void
-gst_xine_audio_dec_event (GstXineAudioDec *xine, GstEvent *event)
+gst_xine_audio_dec_event (GstXineAudioDec * xine, GstEvent * event)
{
gst_pad_event_default (xine->sinkpad, event);
}
static void
-gst_xine_audio_dec_chain (GstPad *pad, GstData *in)
+gst_xine_audio_dec_chain (GstPad * pad, GstData * in)
{
buf_element_t buffer = { 0, };
- GstXineAudioDec *xine = GST_XINE_AUDIO_DEC (gst_object_get_parent (GST_OBJECT (pad)));
+ GstXineAudioDec *xine =
+ GST_XINE_AUDIO_DEC (gst_object_get_parent (GST_OBJECT (pad)));
if (GST_IS_EVENT (in)) {
gst_xine_audio_dec_event (xine, GST_EVENT (in));
if (xine->format == 0) {
/* no caps yet */
- GST_ELEMENT_ERROR (xine, CORE, NEGOTIATION, (NULL), ("buffer sent before doing caps nego"));
+ GST_ELEMENT_ERROR (xine, CORE, NEGOTIATION, (NULL),
+ ("buffer sent before doing caps nego"));
gst_data_unref (in);
return;
}
guint8 stsd[150] = { 0, };
guint temp;
GstStructure *structure;
+
/* sent setup header */
element.type = xine->format;
element.decoder_flags = BUF_FLAG_HEADER;
element.decoder_info[1] = xine->wave.nSamplesPerSec;
element.decoder_info[2] = xine->wave.wBitsPerSample;
element.decoder_info[3] = xine->wave.nChannels;
- element.content = (guchar *) &xine->wave;
+ element.content = (guchar *) & xine->wave;
element.size = sizeof (xine_waveformatex);
xine->decoder->decode_data (xine->decoder, &element);
/* send stsd emulation to the decoder */
/* FIXME: qdm2 only right now */
g_assert (gst_pad_get_negotiated_caps (xine->sinkpad));
- structure = gst_caps_get_structure (gst_pad_get_negotiated_caps (xine->sinkpad), 0);
- *((guint32 *) &stsd[56]) = GUINT32_TO_BE (12);
+ structure =
+ gst_caps_get_structure (gst_pad_get_negotiated_caps (xine->sinkpad), 0);
+ *((guint32 *) & stsd[56]) = GUINT32_TO_BE (12);
memcpy (&stsd[60], "frmaQDM2", 8);
- *((guint32 *) &stsd[68]) = GUINT32_TO_BE (36);
+ *((guint32 *) & stsd[68]) = GUINT32_TO_BE (36);
memcpy (&stsd[72], "QDCA", 4);
- *((guint32 *) &stsd[76]) = GUINT32_TO_BE (1);
+ *((guint32 *) & stsd[76]) = GUINT32_TO_BE (1);
if (!gst_structure_get_int (structure, "channels", &temp))
temp = 0;
- *((guint32 *) &stsd[80]) = GUINT32_TO_BE (temp);
+ *((guint32 *) & stsd[80]) = GUINT32_TO_BE (temp);
if (!gst_structure_get_int (structure, "rate", &temp))
temp = 0;
- *((guint32 *) &stsd[84]) = GUINT32_TO_BE (temp);
+ *((guint32 *) & stsd[84]) = GUINT32_TO_BE (temp);
if (!gst_structure_get_int (structure, "bitrate", &temp))
temp = 0;
- *((guint32 *) &stsd[88]) = GUINT32_TO_BE (temp);
+ *((guint32 *) & stsd[88]) = GUINT32_TO_BE (temp);
if (!gst_structure_get_int (structure, "blocksize", &temp))
temp = 0;
- *((guint32 *) &stsd[92]) = GUINT32_TO_BE (temp);
- *((guint32 *) &stsd[96]) = GUINT32_TO_BE (256);
+ *((guint32 *) & stsd[92]) = GUINT32_TO_BE (temp);
+ *((guint32 *) & stsd[96]) = GUINT32_TO_BE (256);
if (!gst_structure_get_int (structure, "framesize", &temp))
temp = 0;
- *((guint32 *) &stsd[100]) = GUINT32_TO_BE (temp);
- *((guint32 *) &stsd[104]) = GUINT32_TO_BE (28);
+ *((guint32 *) & stsd[100]) = GUINT32_TO_BE (temp);
+ *((guint32 *) & stsd[104]) = GUINT32_TO_BE (28);
memcpy (&stsd[108], "QDCP", 4);
- *((guint32 *) &stsd[112]) = GUINT32_TO_BE (1065353216);
- *((guint32 *) &stsd[116]) = GUINT32_TO_BE (0);
- *((guint32 *) &stsd[120]) = GUINT32_TO_BE (1065353216);
- *((guint32 *) &stsd[124]) = GUINT32_TO_BE (1065353216);
- *((guint32 *) &stsd[128]) = GUINT32_TO_BE (27);
- *((guint32 *) &stsd[132]) = GUINT32_TO_BE (8);
- *((guint32 *) &stsd[136]) = GUINT32_TO_BE (0);
- *((guint32 *) &stsd[140]) = GUINT32_TO_BE (24);
- gst_util_dump_mem (stsd, 144);
+ *((guint32 *) & stsd[112]) = GUINT32_TO_BE (1065353216);
+ *((guint32 *) & stsd[116]) = GUINT32_TO_BE (0);
+ *((guint32 *) & stsd[120]) = GUINT32_TO_BE (1065353216);
+ *((guint32 *) & stsd[124]) = GUINT32_TO_BE (1065353216);
+ *((guint32 *) & stsd[128]) = GUINT32_TO_BE (27);
+ *((guint32 *) & stsd[132]) = GUINT32_TO_BE (8);
+ *((guint32 *) & stsd[136]) = GUINT32_TO_BE (0);
+ *((guint32 *) & stsd[140]) = GUINT32_TO_BE (24);
+ gst_util_dump_mem (stsd, 144);
element.decoder_flags = BUF_FLAG_SPECIAL;
element.decoder_info[1] = BUF_SPECIAL_STSD_ATOM;
element.decoder_info[2] = 144;
element.size = 0;
element.content = 0;
xine->decoder->decode_data (xine->decoder, &element);
-
+
xine->setup = TRUE;
}
-
+
gst_buffer_to_xine_buffer (&buffer, GST_BUFFER (in));
buffer.type = xine->format;
xine->decoder->decode_data (xine->decoder, &buffer);
}
static audio_decoder_t *
-_load_decoder (GstXineAudioDec* dec)
+_load_decoder (GstXineAudioDec * dec)
{
xine_stream_t *stream = gst_xine_get_stream (GST_XINE (dec));
plugin_catalog_t *catalog = stream->xine->plugin_catalog;
plugin_node_t *node = GST_XINE_AUDIO_DEC_GET_CLASS (dec)->plugin_node;
audio_decoder_t *ret;
-
+
/* FIXME: this is really hacky, but how to force xine to load a plugin? */
/* how it works: xine can load a plugin for a particular stream type.
* We just take one type, which should not have plugins attached to it,
}
static GstElementStateReturn
-gst_xine_audio_dec_change_state (GstElement *element)
+gst_xine_audio_dec_change_state (GstElement * element)
{
GstXineAudioDec *xine = GST_XINE_AUDIO_DEC (element);
-
+
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY:
xine->decoder = _load_decoder (xine);
break;
case GST_STATE_READY_TO_NULL:
xine->setup = FALSE;
- _x_free_audio_decoder (gst_xine_get_stream (GST_XINE (xine)), xine->decoder);
+ _x_free_audio_decoder (gst_xine_get_stream (GST_XINE (xine)),
+ xine->decoder);
break;
default:
GST_ERROR_OBJECT (element, "invalid state change");
break;
}
-
- return GST_CALL_PARENT_WITH_DEFAULT (GST_ELEMENT_CLASS, change_state, (element), GST_STATE_SUCCESS);
+
+ return GST_CALL_PARENT_WITH_DEFAULT (GST_ELEMENT_CLASS, change_state,
+ (element), GST_STATE_SUCCESS);
}
/** GstXineAudioDec subclasses ************************************************/
-static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "audio/x-raw-int, "
- "endianness = (int) BYTE_ORDER, "
- "signed = (boolean) TRUE, "
- "width = (int) 16, "
- "depth = (int) 16, "
- "rate = (int) [ 1, MAX ], "
- "channels = (int) [ 1, 2 ]; "
- "audio/x-raw-int, "
- "signed = (boolean) FALSE, "
- "width = (int) 8, "
- "depth = (int) 8, "
- "rate = (int) [ 1, MAX ], "
- "channels = (int) [ 1, 2 ]"
- )
-);
+static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "endianness = (int) BYTE_ORDER, "
+ "signed = (boolean) TRUE, "
+ "width = (int) 16, "
+ "depth = (int) 16, "
+ "rate = (int) [ 1, MAX ], "
+ "channels = (int) [ 1, 2 ]; "
+ "audio/x-raw-int, "
+ "signed = (boolean) FALSE, "
+ "width = (int) 8, "
+ "depth = (int) 8, "
+ "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, 2 ]")
+ );
static void
gst_xine_audio_dec_subclass_init (gpointer g_class, gpointer class_data)
{
GstXineAudioDecClass *xine_class = GST_XINE_AUDIO_DEC_CLASS (g_class);
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- GstElementDetails details = GST_ELEMENT_DETAILS (
- NULL,
- "Filter/Decoder/Audio",
- NULL,
- "Benjamin Otte <otte@gnome.org>"
- );
+ GstElementDetails details = GST_ELEMENT_DETAILS (NULL,
+ "Filter/Decoder/Audio",
+ NULL,
+ "Benjamin Otte <otte@gnome.org>");
GstPadTemplate *template;
guint i = 0;
GstCaps *caps = gst_caps_new_empty ();
decoder_info_t *dec;
-
+
xine_class->plugin_node = class_data;
dec = xine_class->plugin_node->info->special_info;
- details.longname = g_strdup_printf ("%s xine audio decoder", xine_class->plugin_node->info->id);
- details.description = g_strdup_printf ("decodes audio using the xine '%s' plugin", xine_class->plugin_node->info->id);
+ details.longname =
+ g_strdup_printf ("%s xine audio decoder",
+ xine_class->plugin_node->info->id);
+ details.description =
+ g_strdup_printf ("decodes audio using the xine '%s' plugin",
+ xine_class->plugin_node->info->id);
gst_element_class_set_details (element_class, &details);
g_free (details.longname);
g_free (details.description);
-
- gst_element_class_add_pad_template (element_class,
+
+ gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&src_template));
-
+
while (dec->supported_types[i] != 0) {
- const gchar *type_str = gst_xine_get_caps_for_format (dec->supported_types[i]);
+ const gchar *type_str =
+ gst_xine_get_caps_for_format (dec->supported_types[i]);
if (type_str) {
gst_caps_append (caps, gst_caps_from_string (type_str));
}
}
static void
-gst_xine_audio_dec_sub_init (GTypeInstance *instance, gpointer g_class)
+gst_xine_audio_dec_sub_init (GTypeInstance * instance, gpointer g_class)
{
GstElementClass *klass = GST_ELEMENT_GET_CLASS (instance);
GstXineAudioDec *xine = GST_XINE_AUDIO_DEC (instance);
- xine->sinkpad = gst_pad_new_from_template (
- gst_element_class_get_pad_template (klass, "sink"), "sink");
+ xine->sinkpad =
+ gst_pad_new_from_template (gst_element_class_get_pad_template (klass,
+ "sink"), "sink");
gst_pad_set_link_function (xine->sinkpad, gst_xine_audio_dec_sink_link);
gst_pad_set_chain_function (xine->sinkpad, gst_xine_audio_dec_chain);
gst_element_add_pad (GST_ELEMENT (xine), xine->sinkpad);
- xine->srcpad = gst_pad_new_from_template (
- gst_element_class_get_pad_template (klass, "src"), "src");
+ xine->srcpad =
+ gst_pad_new_from_template (gst_element_class_get_pad_template (klass,
+ "src"), "src");
gst_pad_use_explicit_caps (xine->srcpad);
gst_element_add_pad (GST_ELEMENT (xine), xine->srcpad);
}
gboolean
-gst_xine_audio_dec_init_plugin (GstPlugin *plugin)
+gst_xine_audio_dec_init_plugin (GstPlugin * plugin)
{
- GTypeInfo plugin_info =
- {
+ GTypeInfo plugin_info = {
sizeof (GstXineAudioDecClass),
NULL,
NULL,
};
xine_node_t *list;
GstXineClass *klass;
-
+
klass = g_type_class_ref (GST_TYPE_XINE);
-
+
list = klass->xine->plugin_catalog->audio->first;
while (list) {
plugin_node_t *node = list->content;
guint format = 0;
list = list->next;
- if (!node) continue;
-
+ if (!node)
+ continue;
+
dec = node->info->special_info;
while (dec->supported_types[format] != 0) {
- const gchar *caps = gst_xine_get_caps_for_format (dec->supported_types[format]);
+ const gchar *caps =
+ gst_xine_get_caps_for_format (dec->supported_types[format]);
if (caps) {
- gchar *plugin_name = g_strdup_printf ("xineaudiodec_%s", node->info->id);
- gchar *type_name = g_strdup_printf ("GstXineAudioDec%s", node->info->id);
+ gchar *plugin_name =
+ g_strdup_printf ("xineaudiodec_%s", node->info->id);
+ gchar *type_name =
+ g_strdup_printf ("GstXineAudioDec%s", node->info->id);
GType type;
+
plugin_info.class_data = node;
- type = g_type_register_static (GST_TYPE_XINE_AUDIO_DEC, type_name, &plugin_info, 0);
+ type =
+ g_type_register_static (GST_TYPE_XINE_AUDIO_DEC, type_name,
+ &plugin_info, 0);
g_free (type_name);
- if (!gst_element_register (plugin, plugin_name,
- MAX (GST_RANK_MARGINAL, GST_RANK_MARGINAL * dec->priority / 10 + 1), type)) {
+ if (!gst_element_register (plugin, plugin_name,
+ MAX (GST_RANK_MARGINAL,
+ GST_RANK_MARGINAL * dec->priority / 10 + 1), type)) {
g_free (plugin_name);
return FALSE;
}
}
}
- g_type_class_unref (klass);
+ g_type_class_unref (klass);
return TRUE;
}
-
GType gst_xine_audio_sink_get_type (void);
-typedef struct _GstXineAudioSink GstXineAudioSink;
+typedef struct _GstXineAudioSink GstXineAudioSink;
typedef struct _GstXineAudioSinkClass GstXineAudioSinkClass;
struct _GstXineAudioSink
{
- GstXine parent;
+ GstXine parent;
- GstPad * sinkpad;
+ GstPad *sinkpad;
- ao_driver_t * driver;
- guint open; /* number of bytes per sample or 0 if driver not open */
+ ao_driver_t *driver;
+ guint open; /* number of bytes per sample or 0 if driver not open */
};
-struct _GstXineAudioSinkClass
+struct _GstXineAudioSinkClass
{
- GstXineClass parent_class;
+ GstXineClass parent_class;
- plugin_node_t * plugin_node;
+ plugin_node_t *plugin_node;
};
/** GstXineAudioSink ***********************************************************/
GST_BOILERPLATE (GstXineAudioSink, gst_xine_audio_sink, GstXine, GST_TYPE_XINE)
-static GstElementStateReturn
- gst_xine_audio_sink_change_state (GstElement *element);
+ static GstElementStateReturn
+ gst_xine_audio_sink_change_state (GstElement * element);
-static void
-gst_xine_audio_sink_base_init (gpointer g_class)
+ static void gst_xine_audio_sink_base_init (gpointer g_class)
{
}
static void
-gst_xine_audio_sink_class_init (GstXineAudioSinkClass *klass)
+gst_xine_audio_sink_class_init (GstXineAudioSinkClass * klass)
{
GstElementClass *element = GST_ELEMENT_CLASS (klass);
}
static void
-gst_xine_audio_sink_init (GstXineAudioSink *xine)
+gst_xine_audio_sink_init (GstXineAudioSink * xine)
{
}
static void
-gst_xine_audio_sink_chain (GstPad *pad, GstData *data)
+gst_xine_audio_sink_chain (GstPad * pad, GstData * data)
{
- GstXineAudioSink *xine = GST_XINE_AUDIO_SINK (gst_object_get_parent (GST_OBJECT (pad)));
+ GstXineAudioSink *xine =
+ GST_XINE_AUDIO_SINK (gst_object_get_parent (GST_OBJECT (pad)));
- while (xine->driver->write (xine->driver, (guint16 *) GST_BUFFER_DATA (data), GST_BUFFER_SIZE (data) / xine->open) == 0);
+ while (xine->driver->write (xine->driver, (guint16 *) GST_BUFFER_DATA (data),
+ GST_BUFFER_SIZE (data) / xine->open) == 0);
gst_data_unref (GST_DATA (data));
}
static GstElementStateReturn
-gst_xine_audio_sink_change_state (GstElement *element)
+gst_xine_audio_sink_change_state (GstElement * element)
{
GstXineAudioSink *xine = GST_XINE_AUDIO_SINK (element);
- audio_driver_class_t *driver = (audio_driver_class_t *) GST_XINE_AUDIO_SINK_GET_CLASS (xine)->plugin_node->plugin_class;
+ audio_driver_class_t *driver =
+ (audio_driver_class_t *) GST_XINE_AUDIO_SINK_GET_CLASS (xine)->
+ plugin_node->plugin_class;
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY:
if (driver == NULL) {
- xine_audio_port_t *port = xine_open_audio_driver (GST_XINE_GET_CLASS (xine)->xine,
+ xine_audio_port_t *port =
+ xine_open_audio_driver (GST_XINE_GET_CLASS (xine)->xine,
GST_XINE_AUDIO_SINK_GET_CLASS (xine)->plugin_node->info->id, NULL);
+
if (!port)
return GST_STATE_FAILURE;
port->exit (port);
- driver = (audio_driver_class_t *) GST_XINE_AUDIO_SINK_GET_CLASS (xine)->plugin_node->plugin_class;
- if (driver == NULL)
+ driver =
+ (audio_driver_class_t *) GST_XINE_AUDIO_SINK_GET_CLASS (xine)->
+ plugin_node->plugin_class;
+ if (driver == NULL)
return GST_STATE_FAILURE;
}
xine->driver = driver->open_plugin (driver, NULL);
GST_ERROR_OBJECT (element, "invalid state change");
break;
}
-
- return GST_CALL_PARENT_WITH_DEFAULT (GST_ELEMENT_CLASS, change_state, (element), GST_STATE_SUCCESS);
+
+ return GST_CALL_PARENT_WITH_DEFAULT (GST_ELEMENT_CLASS, change_state,
+ (element), GST_STATE_SUCCESS);
}
static GstCaps *
-_xine_audio_sink_get_caps (GstPad *pad)
+_xine_audio_sink_get_caps (GstPad * pad)
{
- GstXineAudioSink *xine = GST_XINE_AUDIO_SINK (gst_object_get_parent (GST_OBJECT (pad)));
+ GstXineAudioSink *xine =
+ GST_XINE_AUDIO_SINK (gst_object_get_parent (GST_OBJECT (pad)));
GstCaps *caps, *ret = gst_caps_new_empty ();
guint32 capa, channels;
-
+
if (!xine->driver)
return gst_caps_copy (gst_pad_get_pad_template_caps (pad));
capa = xine->driver->get_capabilities (xine->driver);
channels = capa & (AO_CAP_MODE_MONO | AO_CAP_MODE_STEREO);
-
+
if (channels == 0) {
/* neither mono nor stereo supported, die */
return ret;
caps = gst_caps_from_string ("audio/x-raw-int, "
"signed = (boolean) FALSE, "
"width = (int) 8, "
- "depth = (int) 8, "
- "rate = (int) [ 8000, 192000 ]");
+ "depth = (int) 8, " "rate = (int) [ 8000, 192000 ]");
capa &= ~AO_CAP_8BITS;
} else {
caps = gst_caps_from_string ("audio/x-raw-int, "
"endianness = (int) BYTE_ORDER, "
"signed = (boolean) TRUE, "
"width = (int) 16, "
- "depth = (int) 16, "
- "rate = (int) [ 8000, 192000 ]");
+ "depth = (int) 16, " "rate = (int) [ 8000, 192000 ]");
capa = -1;
}
switch (channels) {
}
gst_caps_append (ret, caps);
} while (capa != -1);
-
+
return ret;
}
static GstPadLinkReturn
-_xine_audio_sink_link (GstPad *pad, const GstCaps *caps)
+_xine_audio_sink_link (GstPad * pad, const GstCaps * caps)
{
GstStructure *structure = gst_caps_get_structure (caps, 0);
- GstXineAudioSink *xine = GST_XINE_AUDIO_SINK (gst_object_get_parent (GST_OBJECT (pad)));
+ GstXineAudioSink *xine =
+ GST_XINE_AUDIO_SINK (gst_object_get_parent (GST_OBJECT (pad)));
guint channels, temp, rate, width;
int mode;
-
+
if (!gst_structure_get_int (structure, "channels", &channels))
return GST_PAD_LINK_REFUSED;
mode = (channels == 1) ? AO_CAP_MODE_MONO : AO_CAP_MODE_STEREO;
return GST_PAD_LINK_REFUSED;
if (!gst_structure_get_int (structure, "width", &width))
return GST_PAD_LINK_REFUSED;
-
+
if (xine->open != 0)
xine->driver->close (xine->driver);
xine->open = 0;
temp = xine->driver->open (xine->driver, width, rate, mode);
if (temp == 0)
return GST_PAD_LINK_REFUSED;
-
+
xine->open = channels * width / 8;
if (temp != rate) {
/* FIXME? */
- GST_WARNING_OBJECT (xine, "rates don't match (requested: %u, got %u)", rate, temp);
+ GST_WARNING_OBJECT (xine, "rates don't match (requested: %u, got %u)", rate,
+ temp);
}
-
+
return GST_PAD_LINK_OK;
}
/** GstXineAudioSink subclasses ************************************************/
-static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "audio/x-raw-int, "
- "signed = (boolean) FALSE, "
- "width = (int) 8, "
- "depth = (int) 8, "
- "rate = (int) [ 8000, 192000 ], "
- "channels = (int) [1, 2]; "
- "audio/x-raw-int, "
- "endianness = (int) BYTE_ORDER, "
- "signed = (boolean) TRUE, "
- "width = (int) 16, "
- "depth = (int) 16, "
- "rate = (int) [ 8000, 192000 ], "
- "channels = (int) [1, 2]"
- )
-);
+static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "signed = (boolean) FALSE, "
+ "width = (int) 8, "
+ "depth = (int) 8, "
+ "rate = (int) [ 8000, 192000 ], "
+ "channels = (int) [1, 2]; "
+ "audio/x-raw-int, "
+ "endianness = (int) BYTE_ORDER, "
+ "signed = (boolean) TRUE, "
+ "width = (int) 16, "
+ "depth = (int) 16, "
+ "rate = (int) [ 8000, 192000 ], " "channels = (int) [1, 2]")
+ );
static void
gst_xine_audio_sink_subclass_init (gpointer g_class, gpointer class_data)
{
GstXineAudioSinkClass *xine_class = GST_XINE_AUDIO_SINK_CLASS (g_class);
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- GstElementDetails details = GST_ELEMENT_DETAILS (
- NULL,
- "Source",
- NULL,
- "Benjamin Otte <otte@gnome.org>"
- );
-
+ GstElementDetails details = GST_ELEMENT_DETAILS (NULL,
+ "Source",
+ NULL,
+ "Benjamin Otte <otte@gnome.org>");
+
xine_class->plugin_node = class_data;
- details.longname = g_strdup_printf ("%s xine audio sink", xine_class->plugin_node->info->id);
- details.description = g_strdup_printf ("%s audio output using Xine", xine_class->plugin_node->info->id);
+ details.longname =
+ g_strdup_printf ("%s xine audio sink", xine_class->plugin_node->info->id);
+ details.description =
+ g_strdup_printf ("%s audio output using Xine",
+ xine_class->plugin_node->info->id);
gst_element_class_set_details (element_class, &details);
g_free (details.longname);
g_free (details.description);
-
- gst_element_class_add_pad_template (element_class,
+
+ gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&sink_template));
}
static void
-gst_xine_audio_sink_sub_init (GTypeInstance *instance, gpointer g_class)
+gst_xine_audio_sink_sub_init (GTypeInstance * instance, gpointer g_class)
{
GstElementClass *klass = GST_ELEMENT_GET_CLASS (instance);
GstXineAudioSink *xine = GST_XINE_AUDIO_SINK (instance);
- xine->sinkpad = gst_pad_new_from_template (
- gst_element_class_get_pad_template (klass, "sink"), "sink");
+ xine->sinkpad =
+ gst_pad_new_from_template (gst_element_class_get_pad_template (klass,
+ "sink"), "sink");
gst_pad_set_chain_function (xine->sinkpad, gst_xine_audio_sink_chain);
gst_pad_set_getcaps_function (xine->sinkpad, _xine_audio_sink_get_caps);
gst_pad_set_link_function (xine->sinkpad, _xine_audio_sink_link);
}
gboolean
-gst_xine_audio_sink_init_plugin (GstPlugin *plugin)
+gst_xine_audio_sink_init_plugin (GstPlugin * plugin)
{
- GTypeInfo plugin_info =
- {
+ GTypeInfo plugin_info = {
sizeof (GstXineAudioSinkClass),
NULL,
NULL,
};
plugin_node_t *node;
GstXineClass *klass;
-
+
klass = g_type_class_ref (GST_TYPE_XINE);
-
+
node = xine_list_first_content (klass->xine->plugin_catalog->aout);
while (node) {
gchar *plugin_name = g_strdup_printf ("xineaudiosink_%s", node->info->id);
gchar *type_name = g_strdup_printf ("GstXineAudioSink%s", node->info->id);
GType type;
+
plugin_info.class_data = node;
- type = g_type_register_static (GST_TYPE_XINE_AUDIO_SINK, type_name, &plugin_info, 0);
+ type =
+ g_type_register_static (GST_TYPE_XINE_AUDIO_SINK, type_name,
+ &plugin_info, 0);
g_free (type_name);
- if (!gst_element_register (plugin, plugin_name,
- GST_RANK_MARGINAL, type)) {
+ if (!gst_element_register (plugin, plugin_name, GST_RANK_MARGINAL, type)) {
g_free (plugin_name);
return FALSE;
}
node = xine_list_next_content (klass->xine->plugin_catalog->aout);
}
- g_type_class_unref (klass);
+ g_type_class_unref (klass);
return TRUE;
}
-
#include "gstxine.h"
#include <xine/buffer.h>
-typedef struct {
- guint32 xine;
- gchar * caps;
+typedef struct
+{
+ guint32 xine;
+ gchar *caps;
} GstXineCapsMap;
static GstXineCapsMap _gst_xine_caps_map[] = {
- { BUF_AUDIO_QDESIGN2, "audio/x-qdm2" },
+ {BUF_AUDIO_QDESIGN2, "audio/x-qdm2"},
/* FIXME:
#define BUF_AUDIO_A52 0x03000000
#define BUF_AUDIO_MPEG 0x03010000
#define BUF_AUDIO_RAWPCM 0x03300000
#define BUF_AUDIO_4X_ADPCM 0x03310000
*/
- { 0, NULL }
+ {0, NULL}
};
const gchar *
gst_xine_get_caps_for_format (guint32 format)
{
guint i = 0;
-
+
while (_gst_xine_caps_map[i].xine != 0) {
if (_gst_xine_caps_map[i].xine == format)
return _gst_xine_caps_map[i].caps;
i++;
}
-
+
return NULL;
}
guint32
-gst_xine_get_format_for_caps (const GstCaps *caps)
+gst_xine_get_format_for_caps (const GstCaps * caps)
{
guint i = 0;
GstCaps *compare, *intersect;
-
+
while (_gst_xine_caps_map[i].xine != 0) {
compare = gst_caps_from_string (_gst_xine_caps_map[i].caps);
intersect = gst_caps_intersect (caps, compare);
gst_caps_free (intersect);
i++;
}
-
- return 0;
-}
+ return 0;
+}
GType gst_xine_input_get_type (void);
-typedef struct _GstXineInput GstXineInput;
+typedef struct _GstXineInput GstXineInput;
typedef struct _GstXineInputClass GstXineInputClass;
struct _GstXineInput
{
- GstXine parent;
+ GstXine parent;
- GstPad * srcpad;
+ GstPad *srcpad;
- input_plugin_t * input;
- gchar * location;
- guint blocksize;
+ input_plugin_t *input;
+ gchar *location;
+ guint blocksize;
};
-struct _GstXineInputClass
+struct _GstXineInputClass
{
- GstXineClass parent_class;
+ GstXineClass parent_class;
- plugin_node_t * plugin_node;
+ plugin_node_t *plugin_node;
};
/** GstXineInput ***********************************************************/
-enum {
+enum
+{
ARG_0,
ARG_LOCATION
};
GST_BOILERPLATE (GstXineInput, gst_xine_input, GstXine, GST_TYPE_XINE)
-static void gst_xine_input_dispose (GObject *object);
-static void gst_xine_input_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_xine_input_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
-static GstElementStateReturn
- gst_xine_input_change_state (GstElement *element);
+ static void gst_xine_input_dispose (GObject * object);
+ static void gst_xine_input_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+ static void gst_xine_input_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+ static GstElementStateReturn
+ gst_xine_input_change_state (GstElement * element);
-static void
-gst_xine_input_base_init (gpointer g_class)
+ static void gst_xine_input_base_init (gpointer g_class)
{
}
static void
-gst_xine_input_class_init (GstXineInputClass *klass)
+gst_xine_input_class_init (GstXineInputClass * klass)
{
GstElementClass *element = GST_ELEMENT_CLASS (klass);
GObjectClass *object = G_OBJECT_CLASS (klass);
object->set_property = gst_xine_input_set_property;
object->get_property = gst_xine_input_get_property;
object->dispose = gst_xine_input_dispose;
-
- g_object_class_install_property (object, ARG_LOCATION,
- g_param_spec_string ("location", "location", "location",
- NULL, G_PARAM_READWRITE));
+
+ g_object_class_install_property (object, ARG_LOCATION,
+ g_param_spec_string ("location", "location", "location",
+ NULL, G_PARAM_READWRITE));
}
static void
-gst_xine_input_init (GstXineInput *xine)
+gst_xine_input_init (GstXineInput * xine)
{
}
static void
-gst_xine_input_dispose (GObject *object)
+gst_xine_input_dispose (GObject * object)
{
GstXineInput *xine = GST_XINE_INPUT (object);
}
static void
-gst_xine_input_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_xine_input_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstXineInput *xine = GST_XINE_INPUT (object);
g_free (xine->location);
xine->location = g_strdup (g_value_get_string (value));
break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- return;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ return;
}
}
static void
-gst_xine_input_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_xine_input_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstXineInput *xine = GST_XINE_INPUT (object);
case ARG_LOCATION:
g_value_set_string (value, xine->location);
break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- return;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ return;
}
}
-#define BUFFER_SIZE 4096 /* FIXME: what size? */
+#define BUFFER_SIZE 4096 /* FIXME: what size? */
static GstData *
-gst_xine_input_get (GstPad *pad)
+gst_xine_input_get (GstPad * pad)
{
- GstXineInput *xine = GST_XINE_INPUT (gst_object_get_parent (GST_OBJECT (pad)));
+ GstXineInput *xine =
+ GST_XINE_INPUT (gst_object_get_parent (GST_OBJECT (pad)));
GstBuffer *buf;
gint real_size, position;
-
+
/* FIXME: how does xine figure out EOS? */
position = xine->input->get_current_pos (xine->input);
if (position > 0 && position == xine->input->get_length (xine->input)) {
gst_element_set_eos (GST_ELEMENT (xine));
return GST_DATA (gst_event_new (GST_EVENT_EOS));
}
-
- buf = gst_pad_alloc_buffer (xine->srcpad, GST_BUFFER_OFFSET_NONE, xine->blocksize);
+
+ buf =
+ gst_pad_alloc_buffer (xine->srcpad, GST_BUFFER_OFFSET_NONE,
+ xine->blocksize);
GST_BUFFER_OFFSET (buf) = position;
- real_size = xine->input->read (xine->input, GST_BUFFER_DATA (buf), GST_BUFFER_MAXSIZE (buf));
+ real_size =
+ xine->input->read (xine->input, GST_BUFFER_DATA (buf),
+ GST_BUFFER_MAXSIZE (buf));
GST_BUFFER_SIZE (buf) = real_size;
if (real_size < 0) {
- GST_ELEMENT_ERROR (xine, RESOURCE, READ, (NULL), ("error %d reading data", real_size));
+ GST_ELEMENT_ERROR (xine, RESOURCE, READ, (NULL), ("error %d reading data",
+ real_size));
gst_data_unref (GST_DATA (buf));
return NULL;
} else if (real_size == 0) {
buf_element_t *element;
+
if (xine->input->get_capabilities (xine->input) & INPUT_CAP_BLOCK)
- element = xine->input->read_block (xine->input, gst_xine_get_stream (GST_XINE (xine))->audio_fifo, xine->blocksize);
+ element =
+ xine->input->read_block (xine->input,
+ gst_xine_get_stream (GST_XINE (xine))->audio_fifo, xine->blocksize);
if (element == NULL) {
/* FIXME: is this EOS? */
gst_element_set_eos (GST_ELEMENT (xine));
- return GST_DATA (gst_event_new (GST_EVENT_EOS));
+ return GST_DATA (gst_event_new (GST_EVENT_EOS));
} else {
GST_BUFFER_SIZE (buf) = element->size;
/* FIXME: put buf_element_t data in buffer */
}
}
GST_BUFFER_OFFSET_END (buf) = xine->input->get_current_pos (xine->input);
-
+
return GST_DATA (buf);
}
static GstElementStateReturn
-gst_xine_input_change_state (GstElement *element)
+gst_xine_input_change_state (GstElement * element)
{
GstXineInput *xine = GST_XINE_INPUT (element);
- input_class_t *input = (input_class_t *) GST_XINE_INPUT_GET_CLASS (xine)->plugin_node->plugin_class;
-
+ input_class_t *input =
+ (input_class_t *) GST_XINE_INPUT_GET_CLASS (xine)->plugin_node->
+ plugin_class;
+
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY:
- xine->input = input->get_instance (input, gst_xine_get_stream (GST_XINE (xine)), xine->location);
+ xine->input =
+ input->get_instance (input, gst_xine_get_stream (GST_XINE (xine)),
+ xine->location);
if (!xine->input)
return GST_STATE_FAILURE;
if (xine->input->open (xine->input) == 0)
GST_ERROR_OBJECT (element, "invalid state change");
break;
}
-
- return GST_CALL_PARENT_WITH_DEFAULT (GST_ELEMENT_CLASS, change_state, (element), GST_STATE_SUCCESS);
+
+ return GST_CALL_PARENT_WITH_DEFAULT (GST_ELEMENT_CLASS, change_state,
+ (element), GST_STATE_SUCCESS);
}
/** GstXineInput subclasses ************************************************/
-static GstStaticPadTemplate any_template = GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS_ANY
-);
-
-static GstStaticPadTemplate cdda_template = GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "audio/x-raw-int, "
- "endianness = (int) LITTLE_ENDIAN, "
- "signed = (boolean) true, "
- "width = (int) 16, "
- "depth = (int) 16, "
- "rate = (int) 44100, "
- "channels = (int) 2"
- )
-);
+static GstStaticPadTemplate any_template = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS_ANY);
+
+static GstStaticPadTemplate cdda_template = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "endianness = (int) LITTLE_ENDIAN, "
+ "signed = (boolean) true, "
+ "width = (int) 16, "
+ "depth = (int) 16, " "rate = (int) 44100, " "channels = (int) 2")
+ );
static void
gst_xine_input_subclass_init (gpointer g_class, gpointer class_data)
{
GstXineInputClass *xine_class = GST_XINE_INPUT_CLASS (g_class);
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- GstElementDetails details = GST_ELEMENT_DETAILS (
- NULL,
- "Source",
- NULL,
- "Benjamin Otte <otte@gnome.org>"
- );
+ GstElementDetails details = GST_ELEMENT_DETAILS (NULL,
+ "Source",
+ NULL,
+ "Benjamin Otte <otte@gnome.org>");
input_class_t *input;
-
+
xine_class->plugin_node = class_data;
input = (input_class_t *) xine_class->plugin_node->plugin_class;
- details.longname = g_strdup_printf ("%s xine input", input->get_identifier (input));
+ details.longname =
+ g_strdup_printf ("%s xine input", input->get_identifier (input));
details.description = g_strdup_printf ("%s", input->get_description (input));
gst_element_class_set_details (element_class, &details);
g_free (details.longname);
g_free (details.description);
-
+
/* FIXME: this is pretty hackish, anyone knows a better idea (xine doesn't) */
if (strcmp (input->get_identifier (input), "cdda") == 0) {
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&cdda_template));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&cdda_template));
} else {
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&any_template));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&any_template));
}
}
static void
-gst_xine_input_sub_init (GTypeInstance *instance, gpointer g_class)
+gst_xine_input_sub_init (GTypeInstance * instance, gpointer g_class)
{
GstElementClass *klass = GST_ELEMENT_GET_CLASS (instance);
GstXineInput *xine = GST_XINE_INPUT (instance);
- xine->srcpad = gst_pad_new_from_template (
- gst_element_class_get_pad_template (klass, "src"), "src");
+ xine->srcpad =
+ gst_pad_new_from_template (gst_element_class_get_pad_template (klass,
+ "src"), "src");
gst_pad_set_get_function (xine->srcpad, gst_xine_input_get);
gst_element_add_pad (GST_ELEMENT (xine), xine->srcpad);
}
gboolean
-gst_xine_input_init_plugin (GstPlugin *plugin)
+gst_xine_input_init_plugin (GstPlugin * plugin)
{
- GTypeInfo plugin_info =
- {
+ GTypeInfo plugin_info = {
sizeof (GstXineInputClass),
NULL,
NULL,
};
plugin_node_t *node;
GstXineClass *klass;
-
+
klass = g_type_class_ref (GST_TYPE_XINE);
-
+
node = xine_list_first_content (klass->xine->plugin_catalog->input);
while (node) {
gchar *plugin_name = g_strdup_printf ("xinesrc_%s", node->info->id);
gchar *type_name = g_strdup_printf ("GstXineInput%s", node->info->id);
GType type;
+
plugin_info.class_data = node;
- type = g_type_register_static (GST_TYPE_XINE_INPUT, type_name, &plugin_info, 0);
+ type =
+ g_type_register_static (GST_TYPE_XINE_INPUT, type_name, &plugin_info,
+ 0);
g_free (type_name);
- if (!gst_element_register (plugin, plugin_name,
- GST_RANK_MARGINAL, type)) {
+ if (!gst_element_register (plugin, plugin_name, GST_RANK_MARGINAL, type)) {
g_free (plugin_name);
return FALSE;
}
node = xine_list_next_content (klass->xine->plugin_catalog->input);
}
- g_type_class_unref (klass);
+ g_type_class_unref (klass);
return TRUE;
}
-
/* set up xvid initially (function pointers, CPU flags) */
gst_xvid_init_struct (xinit);
- if ((ret = xvid_global(NULL, XVID_GBL_INIT, &xinit, NULL)) < 0) {
- g_warning("Failed to initialize XviD: %s (%d)",
- gst_xvid_error(ret), ret);
+ if ((ret = xvid_global (NULL, XVID_GBL_INIT, &xinit, NULL)) < 0) {
+ g_warning ("Failed to initialize XviD: %s (%d)", gst_xvid_error (ret), ret);
return FALSE;
}
GST_LOG ("Initted XviD version %d.%d.%d (API %d.%d)",
- XVID_VERSION_MAJOR (XVID_VERSION),
- XVID_VERSION_MINOR (XVID_VERSION),
- XVID_VERSION_PATCH (XVID_VERSION),
- XVID_API_MAJOR (XVID_API), XVID_API_MINOR (XVID_API));
+ XVID_VERSION_MAJOR (XVID_VERSION),
+ XVID_VERSION_MINOR (XVID_VERSION),
+ XVID_VERSION_PATCH (XVID_VERSION),
+ XVID_API_MAJOR (XVID_API), XVID_API_MINOR (XVID_API));
is_init = TRUE;
return TRUE;
}
gint
-gst_xvid_structure_to_csp (GstStructure *structure,
- gint w, gint *_stride, gint *_bpp)
+gst_xvid_structure_to_csp (GstStructure * structure,
+ gint w, gint * _stride, gint * _bpp)
{
const gchar *mime = gst_structure_get_name (structure);
gint xvid_cs = -1, stride = -1, bpp = -1;
gst_structure_get_fourcc (structure, "format", &fourcc);
switch (fourcc) {
- case GST_MAKE_FOURCC('I','4','2','0'):
- xvid_cs = XVID_CSP_I420;
- stride = w;
- bpp = 12;
- break;
- case GST_MAKE_FOURCC('Y','U','Y','2'):
- xvid_cs = XVID_CSP_YUY2;
- stride = w * 2;
- bpp = 16;
- break;
- case GST_MAKE_FOURCC('Y','V','1','2'):
- xvid_cs = XVID_CSP_YV12;
- stride = w;
- bpp = 12;
- break;
- case GST_MAKE_FOURCC('U','Y','V','Y'):
- xvid_cs = XVID_CSP_UYVY;
- stride = w * 2;
- bpp = 16;
- break;
- case GST_MAKE_FOURCC('Y','V','Y','U'):
- xvid_cs = XVID_CSP_YVYU;
- stride = w * 2;
- bpp = 16;
- break;
+ case GST_MAKE_FOURCC ('I', '4', '2', '0'):
+ xvid_cs = XVID_CSP_I420;
+ stride = w;
+ bpp = 12;
+ break;
+ case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
+ xvid_cs = XVID_CSP_YUY2;
+ stride = w * 2;
+ bpp = 16;
+ break;
+ case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
+ xvid_cs = XVID_CSP_YV12;
+ stride = w;
+ bpp = 12;
+ break;
+ case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
+ xvid_cs = XVID_CSP_UYVY;
+ stride = w * 2;
+ bpp = 16;
+ break;
+ case GST_MAKE_FOURCC ('Y', 'V', 'Y', 'U'):
+ xvid_cs = XVID_CSP_YVYU;
+ stride = w * 2;
+ bpp = 16;
+ break;
}
} else {
gint depth, r_mask;
- gst_structure_get_int(structure, "depth", &depth);
- gst_structure_get_int(structure, "bpp", &bpp);
- gst_structure_get_int(structure, "red_mask", &r_mask);
+ gst_structure_get_int (structure, "depth", &depth);
+ gst_structure_get_int (structure, "bpp", &bpp);
+ gst_structure_get_int (structure, "red_mask", &r_mask);
switch (depth) {
case 15:
- xvid_cs = XVID_CSP_RGB555;
- break;
+ xvid_cs = XVID_CSP_RGB555;
+ break;
case 16:
- xvid_cs = XVID_CSP_RGB565;
- break;
+ xvid_cs = XVID_CSP_RGB565;
+ break;
case 24:
- if (bpp == 24) {
- xvid_cs = XVID_CSP_BGR;
- } else {
- switch (r_mask) {
- case 0xff000000:
- xvid_cs = XVID_CSP_RGBA;
- break;
+ if (bpp == 24) {
+ xvid_cs = XVID_CSP_BGR;
+ } else {
+ switch (r_mask) {
+ case 0xff000000:
+ xvid_cs = XVID_CSP_RGBA;
+ break;
#ifdef XVID_CSP_ARGB
- case 0x00ff0000:
- xvid_cs = XVID_CSP_ARGB;
- break;
+ case 0x00ff0000:
+ xvid_cs = XVID_CSP_ARGB;
+ break;
#endif
- case 0x0000ff00:
- xvid_cs = XVID_CSP_BGRA;
- break;
- case 0x000000ff:
- xvid_cs = XVID_CSP_ABGR;
- break;
- }
- }
- break;
+ case 0x0000ff00:
+ xvid_cs = XVID_CSP_BGRA;
+ break;
+ case 0x000000ff:
+ xvid_cs = XVID_CSP_ABGR;
+ break;
+ }
+ }
+ break;
default:
- break;
+ break;
}
stride = w * bpp / 8;
#ifdef XVID_CSP_ARGB
case XVID_CSP_ARGB:
#endif
- case XVID_CSP_RGBA: {
+ case XVID_CSP_RGBA:{
gint r_mask = 0, b_mask = 0, g_mask = 0,
- endianness = 0, bpp = 0, depth = 0;
+ endianness = 0, bpp = 0, depth = 0;
switch (csp) {
- case XVID_CSP_RGB555:
- r_mask = GST_VIDEO_RED_MASK_15_INT;
- g_mask = GST_VIDEO_GREEN_MASK_15_INT;
- b_mask = GST_VIDEO_BLUE_MASK_15_INT;
- endianness = G_BYTE_ORDER; depth = 15; bpp = 16;
- break;
- case XVID_CSP_RGB565:
- r_mask = GST_VIDEO_RED_MASK_16_INT;
- g_mask = GST_VIDEO_GREEN_MASK_16_INT;
- b_mask = GST_VIDEO_BLUE_MASK_16_INT;
- endianness = G_BYTE_ORDER; depth = 16; bpp = 16;
- break;
- case XVID_CSP_BGR:
- r_mask = 0x0000ff; g_mask = 0x00ff00; b_mask = 0xff0000;
- endianness = G_BIG_ENDIAN; depth = 24; bpp = 24;
- break;
- case XVID_CSP_ABGR:
- r_mask = 0x000000ff; g_mask = 0x0000ff00; b_mask = 0x00ff0000;
- endianness = G_BIG_ENDIAN; depth = 24; bpp = 32;
- break;
- case XVID_CSP_BGRA:
- r_mask = 0x0000ff00; g_mask = 0x00ff0000; b_mask = 0xff000000;
- endianness = G_BIG_ENDIAN; depth = 24; bpp = 32;
- break;
+ case XVID_CSP_RGB555:
+ r_mask = GST_VIDEO_RED_MASK_15_INT;
+ g_mask = GST_VIDEO_GREEN_MASK_15_INT;
+ b_mask = GST_VIDEO_BLUE_MASK_15_INT;
+ endianness = G_BYTE_ORDER;
+ depth = 15;
+ bpp = 16;
+ break;
+ case XVID_CSP_RGB565:
+ r_mask = GST_VIDEO_RED_MASK_16_INT;
+ g_mask = GST_VIDEO_GREEN_MASK_16_INT;
+ b_mask = GST_VIDEO_BLUE_MASK_16_INT;
+ endianness = G_BYTE_ORDER;
+ depth = 16;
+ bpp = 16;
+ break;
+ case XVID_CSP_BGR:
+ r_mask = 0x0000ff;
+ g_mask = 0x00ff00;
+ b_mask = 0xff0000;
+ endianness = G_BIG_ENDIAN;
+ depth = 24;
+ bpp = 24;
+ break;
+ case XVID_CSP_ABGR:
+ r_mask = 0x000000ff;
+ g_mask = 0x0000ff00;
+ b_mask = 0x00ff0000;
+ endianness = G_BIG_ENDIAN;
+ depth = 24;
+ bpp = 32;
+ break;
+ case XVID_CSP_BGRA:
+ r_mask = 0x0000ff00;
+ g_mask = 0x00ff0000;
+ b_mask = 0xff000000;
+ endianness = G_BIG_ENDIAN;
+ depth = 24;
+ bpp = 32;
+ break;
#ifdef XVID_CSP_ARGB
- case XVID_CSP_ARGB:
- r_mask = 0x00ff0000; g_mask = 0x0000ff00; b_mask = 0x000000ff;
- endianness = G_BIG_ENDIAN; depth = 24; bpp = 32;
- break;
+ case XVID_CSP_ARGB:
+ r_mask = 0x00ff0000;
+ g_mask = 0x0000ff00;
+ b_mask = 0x000000ff;
+ endianness = G_BIG_ENDIAN;
+ depth = 24;
+ bpp = 32;
+ break;
#endif
- case XVID_CSP_RGBA:
- r_mask = 0xff000000; g_mask = 0x00ff0000; b_mask = 0x0000ff00;
- endianness = G_BIG_ENDIAN; depth = 24; bpp = 32;
- break;
+ case XVID_CSP_RGBA:
+ r_mask = 0xff000000;
+ g_mask = 0x00ff0000;
+ b_mask = 0x0000ff00;
+ endianness = G_BIG_ENDIAN;
+ depth = 24;
+ bpp = 32;
+ break;
}
caps = gst_caps_new_simple ("video/x-raw-rgb",
- "width", G_TYPE_INT, w,
- "height", G_TYPE_INT, h,
- "depth", G_TYPE_INT, depth,
- "bpp", G_TYPE_INT, bpp,
- "endianness", G_TYPE_INT, endianness,
- "red_mask", G_TYPE_INT, r_mask,
- "green_mask", G_TYPE_INT, g_mask,
- "blue_mask", G_TYPE_INT, b_mask,
- "framerate", G_TYPE_DOUBLE, fps,
- NULL);
+ "width", G_TYPE_INT, w,
+ "height", G_TYPE_INT, h,
+ "depth", G_TYPE_INT, depth,
+ "bpp", G_TYPE_INT, bpp,
+ "endianness", G_TYPE_INT, endianness,
+ "red_mask", G_TYPE_INT, r_mask,
+ "green_mask", G_TYPE_INT, g_mask,
+ "blue_mask", G_TYPE_INT, b_mask,
+ "framerate", G_TYPE_DOUBLE, fps, NULL);
break;
}
case XVID_CSP_YVYU:
case XVID_CSP_UYVY:
case XVID_CSP_I420:
- case XVID_CSP_YV12: {
+ case XVID_CSP_YV12:{
guint32 fourcc = 0;
switch (csp) {
- case XVID_CSP_YUY2:
- fourcc = GST_MAKE_FOURCC ('Y','U','Y','2');
- break;
- case XVID_CSP_YVYU:
- fourcc = GST_MAKE_FOURCC ('Y','V','Y','U');
- break;
- case XVID_CSP_UYVY:
- fourcc = GST_MAKE_FOURCC ('U','Y','V','Y');
- break;
- case XVID_CSP_I420:
- fourcc = GST_MAKE_FOURCC ('I','4','2','0');
- break;
- case XVID_CSP_YV12:
- fourcc = GST_MAKE_FOURCC ('Y','V','1','2');
- break;
+ case XVID_CSP_YUY2:
+ fourcc = GST_MAKE_FOURCC ('Y', 'U', 'Y', '2');
+ break;
+ case XVID_CSP_YVYU:
+ fourcc = GST_MAKE_FOURCC ('Y', 'V', 'Y', 'U');
+ break;
+ case XVID_CSP_UYVY:
+ fourcc = GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y');
+ break;
+ case XVID_CSP_I420:
+ fourcc = GST_MAKE_FOURCC ('I', '4', '2', '0');
+ break;
+ case XVID_CSP_YV12:
+ fourcc = GST_MAKE_FOURCC ('Y', 'V', '1', '2');
+ break;
}
caps = gst_caps_new_simple ("video/x-raw-yuv",
- "width", G_TYPE_INT, w,
- "height", G_TYPE_INT, h,
- "format", GST_TYPE_FOURCC, fourcc,
- "framerate", G_TYPE_DOUBLE, fps,
- NULL);
+ "width", G_TYPE_INT, w,
+ "height", G_TYPE_INT, h,
+ "format", GST_TYPE_FOURCC, fourcc,
+ "framerate", G_TYPE_DOUBLE, fps, NULL);
break;
}
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
return (gst_element_register (plugin, "xvidenc",
- GST_RANK_NONE, GST_TYPE_XVIDENC) &&
- gst_element_register (plugin, "xviddec",
- GST_RANK_SECONDARY, GST_TYPE_XVIDDEC));
+ GST_RANK_NONE, GST_TYPE_XVIDENC) &&
+ gst_element_register (plugin, "xviddec",
+ GST_RANK_SECONDARY, GST_TYPE_XVIDDEC));
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "xvid",
- "XviD plugin library",
- plugin_init,
- VERSION,
- "GPL",
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "xvid",
+ "XviD plugin library", plugin_init, VERSION, "GPL", GST_PACKAGE, GST_ORIGIN)
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define gst_xvid_init_struct(s) \
do { \
memset (&s, 0, sizeof(s)); \
s.version = XVID_VERSION; \
} while (0);
-
#define RGB_24_32_STATIC_CAPS(bpp, r_mask,g_mask,b_mask) \
"video/x-raw-rgb, " \
"width = (int) [ 0, MAX ], " \
"red_mask = (int) " G_STRINGIFY (r_mask) ", " \
"green_mask = (int) " G_STRINGIFY (g_mask) ", " \
"blue_mask = (int) " G_STRINGIFY (b_mask)
+extern gchar *gst_xvid_error (int errorcode);
+extern gboolean gst_xvid_init (void);
-extern gchar * gst_xvid_error (int errorcode);
-extern gboolean gst_xvid_init (void);
-
-extern gint gst_xvid_structure_to_csp (GstStructure *structure,
- gint w, gint *stride, gint *bpp);
-extern GstCaps *gst_xvid_csp_to_caps (gint csp, gint w, gint h, gdouble fps);
+extern gint gst_xvid_structure_to_csp (GstStructure * structure,
+ gint w, gint * stride, gint * bpp);
+extern GstCaps *gst_xvid_csp_to_caps (gint csp, gint w, gint h, gdouble fps);
G_END_DECLS
-
#endif /* __GST_XVID_H__ */
"Ronald Bultje <rbultje@ronald.bitfreak.net>",
};
-static GstStaticPadTemplate sink_template =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "video/x-xvid, "
- "width = (int) [ 0, MAX ], "
- "height = (int) [ 0, MAX ], "
- "framerate = (double) [ 0, MAX ]"
- )
-);
-
-static GstStaticPadTemplate src_template =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- GST_VIDEO_CAPS_YUV ("{ I420, YUY2, YV12, YVYU, UYVY }") "; "
- RGB_24_32_STATIC_CAPS (32, 0x00ff0000, 0x0000ff00, 0x000000ff) "; "
- RGB_24_32_STATIC_CAPS (32, 0xff000000, 0x00ff0000, 0x0000ff00) "; "
- RGB_24_32_STATIC_CAPS (32, 0x0000ff00, 0x00ff0000, 0xff000000) "; "
- RGB_24_32_STATIC_CAPS (32, 0x000000ff, 0x0000ff00, 0x00ff0000) "; "
- RGB_24_32_STATIC_CAPS (24, 0x0000ff, 0x00ff00, 0xff0000) "; "
- GST_VIDEO_CAPS_RGB_15 "; "
- GST_VIDEO_CAPS_RGB_16
- )
-);
+static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/x-xvid, "
+ "width = (int) [ 0, MAX ], "
+ "height = (int) [ 0, MAX ], " "framerate = (double) [ 0, MAX ]")
+ );
+
+static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("{ I420, YUY2, YV12, YVYU, UYVY }")
+ "; " RGB_24_32_STATIC_CAPS (32, 0x00ff0000, 0x0000ff00,
+ 0x000000ff) "; " RGB_24_32_STATIC_CAPS (32, 0xff000000, 0x00ff0000,
+ 0x0000ff00) "; " RGB_24_32_STATIC_CAPS (32, 0x0000ff00, 0x00ff0000,
+ 0xff000000) "; " RGB_24_32_STATIC_CAPS (32, 0x000000ff, 0x0000ff00,
+ 0x00ff0000) "; " RGB_24_32_STATIC_CAPS (24, 0x0000ff, 0x00ff00,
+ 0xff0000) "; " GST_VIDEO_CAPS_RGB_15 "; " GST_VIDEO_CAPS_RGB_16)
+ );
/* XvidDec signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0
- /* FILL ME */
+ /* FILL ME */
};
-static void gst_xviddec_base_init (gpointer g_class);
-static void gst_xviddec_class_init (GstXvidDecClass *klass);
-static void gst_xviddec_init (GstXvidDec *xviddec);
-static void gst_xviddec_chain (GstPad *pad,
- GstData *data);
+static void gst_xviddec_base_init (gpointer g_class);
+static void gst_xviddec_class_init (GstXvidDecClass * klass);
+static void gst_xviddec_init (GstXvidDec * xviddec);
+static void gst_xviddec_chain (GstPad * pad, GstData * data);
static GstPadLinkReturn
- gst_xviddec_sink_link (GstPad *pad,
- const GstCaps *vscapslist);
+gst_xviddec_sink_link (GstPad * pad, const GstCaps * vscapslist);
static GstPadLinkReturn
- gst_xviddec_src_link (GstPad *pad,
- const GstCaps *vscapslist);
-static GstCaps *
- gst_xviddec_src_getcaps (GstPad *pad);
-static GstElementStateReturn
- gst_xviddec_change_state (GstElement *element);
+gst_xviddec_src_link (GstPad * pad, const GstCaps * vscapslist);
+static GstCaps *gst_xviddec_src_getcaps (GstPad * pad);
+static GstElementStateReturn gst_xviddec_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
+
/* static guint gst_xviddec_signals[LAST_SIGNAL] = { 0 }; */
GType
-gst_xviddec_get_type(void)
+gst_xviddec_get_type (void)
{
static GType xviddec_type = 0;
- if (!xviddec_type)
- {
+ if (!xviddec_type) {
static const GTypeInfo xviddec_info = {
- sizeof(GstXvidDecClass),
+ sizeof (GstXvidDecClass),
gst_xviddec_base_init,
NULL,
(GClassInitFunc) gst_xviddec_class_init,
NULL,
NULL,
- sizeof(GstXvidDec),
+ sizeof (GstXvidDec),
0,
(GInstanceInitFunc) gst_xviddec_init,
};
- xviddec_type = g_type_register_static(GST_TYPE_ELEMENT,
- "GstXvidDec",
- &xviddec_info, 0);
+ xviddec_type = g_type_register_static (GST_TYPE_ELEMENT,
+ "GstXvidDec", &xviddec_info, 0);
}
return xviddec_type;
}
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&sink_template));
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&src_template));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&sink_template));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&src_template));
gst_element_class_set_details (element_class, &gst_xviddec_details);
}
static void
-gst_xviddec_class_init (GstXvidDecClass *klass)
+gst_xviddec_class_init (GstXvidDecClass * klass)
{
GstElementClass *gstelement_class = (GstElementClass *) klass;
- parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
+ parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
gstelement_class->change_state = gst_xviddec_change_state;
}
static void
-gst_xviddec_init (GstXvidDec *xviddec)
+gst_xviddec_init (GstXvidDec * xviddec)
{
- gst_xvid_init();
+ gst_xvid_init ();
/* create the sink pad */
- xviddec->sinkpad = gst_pad_new_from_template(
- gst_static_pad_template_get (&sink_template),
- "sink");
- gst_element_add_pad(GST_ELEMENT(xviddec), xviddec->sinkpad);
+ xviddec->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get (&sink_template),
+ "sink");
+ gst_element_add_pad (GST_ELEMENT (xviddec), xviddec->sinkpad);
- gst_pad_set_chain_function(xviddec->sinkpad, gst_xviddec_chain);
- gst_pad_set_link_function(xviddec->sinkpad, gst_xviddec_sink_link);
+ gst_pad_set_chain_function (xviddec->sinkpad, gst_xviddec_chain);
+ gst_pad_set_link_function (xviddec->sinkpad, gst_xviddec_sink_link);
/* create the src pad */
- xviddec->srcpad = gst_pad_new_from_template(
- gst_static_pad_template_get (&src_template),
- "src");
- gst_element_add_pad(GST_ELEMENT(xviddec), xviddec->srcpad);
+ xviddec->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get (&src_template),
+ "src");
+ gst_element_add_pad (GST_ELEMENT (xviddec), xviddec->srcpad);
gst_pad_set_getcaps_function (xviddec->srcpad, gst_xviddec_src_getcaps);
- gst_pad_set_link_function(xviddec->srcpad, gst_xviddec_src_link);
+ gst_pad_set_link_function (xviddec->srcpad, gst_xviddec_src_link);
/* size, etc. */
xviddec->width = xviddec->height = xviddec->csp = -1;
static void
-gst_xviddec_unset (GstXvidDec *xviddec)
+gst_xviddec_unset (GstXvidDec * xviddec)
{
/* unref this instance */
- xvid_decore(xviddec->handle, XVID_DEC_DESTROY, NULL, NULL);
+ xvid_decore (xviddec->handle, XVID_DEC_DESTROY, NULL, NULL);
xviddec->handle = NULL;
}
static gboolean
-gst_xviddec_setup (GstXvidDec *xviddec)
+gst_xviddec_setup (GstXvidDec * xviddec)
{
xvid_dec_create_t xdec;
int ret;
xdec.height = xviddec->height;
xdec.handle = NULL;
- if ((ret = xvid_decore(NULL, XVID_DEC_CREATE,
- &xdec, NULL)) < 0) {
+ if ((ret = xvid_decore (NULL, XVID_DEC_CREATE, &xdec, NULL)) < 0) {
GST_ELEMENT_ERROR (xviddec, LIBRARY, SETTINGS, (NULL),
- ("Setting parameters %dx%d@%d failed: %s (%d)",
- xviddec->width, xviddec->height, xviddec->csp,
- gst_xvid_error(ret), ret));
+ ("Setting parameters %dx%d@%d failed: %s (%d)",
+ xviddec->width, xviddec->height, xviddec->csp,
+ gst_xvid_error (ret), ret));
return FALSE;
}
static void
-gst_xviddec_chain (GstPad *pad,
- GstData *_data)
+gst_xviddec_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
- GstXvidDec *xviddec = GST_XVIDDEC(GST_OBJECT_PARENT(pad));
+ GstXvidDec *xviddec = GST_XVIDDEC (GST_OBJECT_PARENT (pad));
GstBuffer *outbuf;
xvid_dec_frame_t xframe;
int ret;
- g_return_if_fail(pad != NULL);
- g_return_if_fail(GST_IS_PAD(pad));
+ g_return_if_fail (pad != NULL);
+ g_return_if_fail (GST_IS_PAD (pad));
if (!xviddec->handle) {
GST_ELEMENT_ERROR (xviddec, CORE, NEGOTIATION, (NULL),
- ("format wasn't negotiated before chain function"));
- gst_buffer_unref(buf);
+ ("format wasn't negotiated before chain function"));
+ gst_buffer_unref (buf);
return;
}
- outbuf = gst_buffer_new_and_alloc(xviddec->width *
- xviddec->height *
- xviddec->bpp / 8);
- GST_BUFFER_TIMESTAMP(outbuf) = GST_BUFFER_TIMESTAMP(buf);
- GST_BUFFER_DURATION(outbuf) = GST_BUFFER_DURATION(buf);
- GST_BUFFER_SIZE(outbuf) = xviddec->width *
- xviddec->height *
- xviddec->bpp / 8;
+ outbuf = gst_buffer_new_and_alloc (xviddec->width *
+ xviddec->height * xviddec->bpp / 8);
+ GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
+ GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buf);
+ GST_BUFFER_SIZE (outbuf) = xviddec->width *
+ xviddec->height * xviddec->bpp / 8;
/* decode and so ... */
gst_xvid_init_struct (xframe);
xframe.general = 0;
- xframe.bitstream = (void *) GST_BUFFER_DATA(buf);
- xframe.length = GST_BUFFER_SIZE(buf);
+ xframe.bitstream = (void *) GST_BUFFER_DATA (buf);
+ xframe.length = GST_BUFFER_SIZE (buf);
xframe.output.csp = xviddec->csp;
if (xviddec->width == xviddec->stride) {
- xframe.output.plane[0] = GST_BUFFER_DATA(outbuf);
- xframe.output.plane[1] = xframe.output.plane[0] + (xviddec->width * xviddec->height);
- xframe.output.plane[2] = xframe.output.plane[1] + (xviddec->width * xviddec->height / 4);
+ xframe.output.plane[0] = GST_BUFFER_DATA (outbuf);
+ xframe.output.plane[1] =
+ xframe.output.plane[0] + (xviddec->width * xviddec->height);
+ xframe.output.plane[2] =
+ xframe.output.plane[1] + (xviddec->width * xviddec->height / 4);
xframe.output.stride[0] = xviddec->width;
xframe.output.stride[1] = xviddec->width / 2;
xframe.output.stride[2] = xviddec->width / 2;
} else {
- xframe.output.plane[0] = GST_BUFFER_DATA(outbuf);
+ xframe.output.plane[0] = GST_BUFFER_DATA (outbuf);
xframe.output.stride[0] = xviddec->stride;
}
- if ((ret = xvid_decore(xviddec->handle, XVID_DEC_DECODE,
- &xframe, NULL)) < 0) {
+ if ((ret = xvid_decore (xviddec->handle, XVID_DEC_DECODE, &xframe, NULL)) < 0) {
GST_ELEMENT_ERROR (xviddec, STREAM, DECODE, (NULL),
- ("Error decoding xvid frame: %s (%d)\n",
- gst_xvid_error(ret), ret));
- gst_buffer_unref(buf);
- gst_buffer_unref(outbuf);
+ ("Error decoding xvid frame: %s (%d)\n", gst_xvid_error (ret), ret));
+ gst_buffer_unref (buf);
+ gst_buffer_unref (outbuf);
return;
}
- gst_pad_push(xviddec->srcpad, GST_DATA (outbuf));
- gst_buffer_unref(buf);
+ gst_pad_push (xviddec->srcpad, GST_DATA (outbuf));
+ gst_buffer_unref (buf);
}
static GstCaps *
-gst_xviddec_src_getcaps (GstPad *pad)
+gst_xviddec_src_getcaps (GstPad * pad)
{
GstXvidDec *xviddec = GST_XVIDDEC (gst_pad_get_parent (pad));
GstCaps *caps;
if (!GST_PAD_CAPS (xviddec->sinkpad)) {
GstPadTemplate *templ = gst_static_pad_template_get (&src_template);
+
return gst_caps_copy (gst_pad_template_get_caps (templ));
}
caps = gst_caps_new_empty ();
for (i = 0; csp[i] != 0; i++) {
GstCaps *one = gst_xvid_csp_to_caps (csp[i], xviddec->width,
- xviddec->height, xviddec->fps);
+ xviddec->height, xviddec->fps);
+
gst_caps_append (caps, one);
}
}
static GstPadLinkReturn
-gst_xviddec_src_link (GstPad *pad,
- const GstCaps *vscaps)
+gst_xviddec_src_link (GstPad * pad, const GstCaps * vscaps)
{
- GstXvidDec *xviddec = GST_XVIDDEC(gst_pad_get_parent (pad));
+ GstXvidDec *xviddec = GST_XVIDDEC (gst_pad_get_parent (pad));
GstStructure *structure = gst_caps_get_structure (vscaps, 0);
if (!GST_PAD_CAPS (xviddec->sinkpad))
/* if there's something old around, remove it */
if (xviddec->handle) {
- gst_xviddec_unset(xviddec);
+ gst_xviddec_unset (xviddec);
}
-g_print ("out: %s\n", gst_caps_to_string (vscaps));
+ g_print ("out: %s\n", gst_caps_to_string (vscaps));
xviddec->csp = gst_xvid_structure_to_csp (structure, xviddec->width,
- &xviddec->stride,
- &xviddec->bpp);
+ &xviddec->stride, &xviddec->bpp);
if (xviddec->csp < 0)
return GST_PAD_LINK_REFUSED;
- if (!gst_xviddec_setup(xviddec))
+ if (!gst_xviddec_setup (xviddec))
return GST_PAD_LINK_REFUSED;
return GST_PAD_LINK_OK;
}
static GstPadLinkReturn
-gst_xviddec_sink_link (GstPad *pad,
- const GstCaps *vscaps)
+gst_xviddec_sink_link (GstPad * pad, const GstCaps * vscaps)
{
- GstXvidDec *xviddec = GST_XVIDDEC(gst_pad_get_parent (pad));
+ GstXvidDec *xviddec = GST_XVIDDEC (gst_pad_get_parent (pad));
GstStructure *structure;
/* if there's something old around, remove it */
if (xviddec->handle) {
- gst_xviddec_unset(xviddec);
+ gst_xviddec_unset (xviddec);
}
/* if we get here, we know the input is xvid. we
* only need to bother with the output colorspace,
* which the src_link function takes care of. */
structure = gst_caps_get_structure (vscaps, 0);
- gst_structure_get_int(structure, "width", &xviddec->width);
- gst_structure_get_int(structure, "height", &xviddec->height);
- gst_structure_get_double(structure, "framerate", &xviddec->fps);
-g_print ("in: %dx%d\n", xviddec->width, xviddec->height);
+ gst_structure_get_int (structure, "width", &xviddec->width);
+ gst_structure_get_int (structure, "height", &xviddec->height);
+ gst_structure_get_double (structure, "framerate", &xviddec->fps);
+ g_print ("in: %dx%d\n", xviddec->width, xviddec->height);
/* re-nego? or just await src nego? */
- if (GST_PAD_CAPS(xviddec->srcpad)) {
+ if (GST_PAD_CAPS (xviddec->srcpad)) {
GstPadLinkReturn ret;
GstCaps *vscaps = gst_pad_get_allowed_caps (xviddec->srcpad), *new;
gint i, csp;
for (i = 0; i < gst_caps_get_size (vscaps); i++) {
csp = gst_xvid_structure_to_csp (gst_caps_get_structure (vscaps, i),
- 0, NULL, NULL);
- new = gst_xvid_csp_to_caps (csp, xviddec->width, xviddec->height, xviddec->fps);
- ret = gst_pad_try_set_caps(xviddec->srcpad, new);
+ 0, NULL, NULL);
+ new =
+ gst_xvid_csp_to_caps (csp, xviddec->width, xviddec->height,
+ xviddec->fps);
+ ret = gst_pad_try_set_caps (xviddec->srcpad, new);
if (ret != GST_PAD_LINK_REFUSED)
- return ret;
+ return ret;
}
return GST_PAD_LINK_REFUSED;
}
static GstElementStateReturn
-gst_xviddec_change_state (GstElement *element)
+gst_xviddec_change_state (GstElement * element)
{
GstXvidDec *xviddec = GST_XVIDDEC (element);
switch (GST_STATE_PENDING (element)) {
case GST_STATE_PAUSED_TO_READY:
if (xviddec->handle) {
- gst_xviddec_unset (xviddec);
+ gst_xviddec_unset (xviddec);
}
break;
default:
#include "gstxvid.h"
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_XVIDDEC \
#define GST_IS_XVIDDEC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_XVIDDEC))
-typedef struct _GstXvidDec GstXvidDec;
-typedef struct _GstXvidDecClass GstXvidDecClass;
+ typedef struct _GstXvidDec GstXvidDec;
+ typedef struct _GstXvidDecClass GstXvidDecClass;
-struct _GstXvidDec {
- GstElement element;
+ struct _GstXvidDec
+ {
+ GstElement element;
- /* pads */
- GstPad *sinkpad, *srcpad;
+ /* pads */
+ GstPad *sinkpad, *srcpad;
- /* xvid handle */
- void *handle;
+ /* xvid handle */
+ void *handle;
- /* video (output) settings */
- gint csp, bpp, stride;
- gint width, height;
- double fps;
-};
+ /* video (output) settings */
+ gint csp, bpp, stride;
+ gint width, height;
+ double fps;
+ };
-struct _GstXvidDecClass {
- GstElementClass parent_class;
-};
+ struct _GstXvidDecClass
+ {
+ GstElementClass parent_class;
+ };
-GType gst_xviddec_get_type(void);
+ GType gst_xviddec_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_XVIDDEC_H__ */
+#endif /* __GST_XVIDDEC_H__ */
"Ronald Bultje <rbultje@ronald.bitfreak.net>",
};
-static GstStaticPadTemplate sink_template =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- GST_VIDEO_CAPS_YUV ("{ I420, YUY2, YV12, YVYU, UYVY }") "; "
- RGB_24_32_STATIC_CAPS (32, 0x00ff0000, 0x0000ff00, 0x000000ff) "; "
- RGB_24_32_STATIC_CAPS (32, 0xff000000, 0x00ff0000, 0x0000ff00) "; "
- RGB_24_32_STATIC_CAPS (32, 0x0000ff00, 0x00ff0000, 0xff000000) "; "
- RGB_24_32_STATIC_CAPS (32, 0x000000ff, 0x0000ff00, 0x00ff0000) "; "
- RGB_24_32_STATIC_CAPS (24, 0x0000ff, 0x00ff00, 0xff0000) "; "
- GST_VIDEO_CAPS_RGB_15 "; "
- GST_VIDEO_CAPS_RGB_16
- )
-);
-
-static GstStaticPadTemplate src_template =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "video/x-xvid, "
- "width = (int) [ 0, MAX ], "
- "height = (int) [ 0, MAX ], "
- "framerate = (double) [ 0.0, MAX ]"
- )
-);
+static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("{ I420, YUY2, YV12, YVYU, UYVY }")
+ "; " RGB_24_32_STATIC_CAPS (32, 0x00ff0000, 0x0000ff00,
+ 0x000000ff) "; " RGB_24_32_STATIC_CAPS (32, 0xff000000, 0x00ff0000,
+ 0x0000ff00) "; " RGB_24_32_STATIC_CAPS (32, 0x0000ff00, 0x00ff0000,
+ 0xff000000) "; " RGB_24_32_STATIC_CAPS (32, 0x000000ff, 0x0000ff00,
+ 0x00ff0000) "; " RGB_24_32_STATIC_CAPS (24, 0x0000ff, 0x00ff00,
+ 0xff0000) "; " GST_VIDEO_CAPS_RGB_15 "; " GST_VIDEO_CAPS_RGB_16)
+ );
+
+static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/x-xvid, "
+ "width = (int) [ 0, MAX ], "
+ "height = (int) [ 0, MAX ], " "framerate = (double) [ 0.0, MAX ]")
+ );
/* XvidEnc signals and args */
-enum {
+enum
+{
FRAME_ENCODED,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_PROFILE,
ARG_BITRATE,
ARG_MAXKEYINTERVAL,
ARG_BUFSIZE
- /* FILL ME:
- * - ME
- * - VOP
- * - VOL
- * - PAR
- * - max b frames
- */
+ /* FILL ME:
+ * - ME
+ * - VOP
+ * - VOL
+ * - PAR
+ * - max b frames
+ */
};
-static void gst_xvidenc_base_init (gpointer g_class);
-static void gst_xvidenc_class_init (GstXvidEncClass *klass);
-static void gst_xvidenc_init (GstXvidEnc *xvidenc);
-static void gst_xvidenc_chain (GstPad *pad,
- GstData *data);
+static void gst_xvidenc_base_init (gpointer g_class);
+static void gst_xvidenc_class_init (GstXvidEncClass * klass);
+static void gst_xvidenc_init (GstXvidEnc * xvidenc);
+static void gst_xvidenc_chain (GstPad * pad, GstData * data);
static GstPadLinkReturn
- gst_xvidenc_link (GstPad *pad,
- const GstCaps *vscapslist);
+gst_xvidenc_link (GstPad * pad, const GstCaps * vscapslist);
/* properties */
-static void gst_xvidenc_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gst_xvidenc_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static GstElementStateReturn
- gst_xvidenc_change_state (GstElement *element);
+static void gst_xvidenc_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+static void gst_xvidenc_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
+static GstElementStateReturn gst_xvidenc_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
static guint gst_xvidenc_signals[LAST_SIGNAL] = { 0 };
if (!xvidenc_profile_type) {
static const GEnumValue xvidenc_profiles[] = {
- { XVID_PROFILE_S_L0, "S_L0", "Simple profile, L0" },
- { XVID_PROFILE_S_L1, "S_L1", "Simple profile, L1" },
- { XVID_PROFILE_S_L2, "S_L2", "Simple profile, L2" },
- { XVID_PROFILE_S_L3, "S_L3", "Simple profile, L3" },
- { XVID_PROFILE_ARTS_L1, "ARTS_L1", "Advanced real-time simple profile, L1" },
- { XVID_PROFILE_ARTS_L2, "ARTS_L2", "Advanced real-time simple profile, L2" },
- { XVID_PROFILE_ARTS_L3, "ARTS_L3", "Advanced real-time simple profile, L3" },
- { XVID_PROFILE_ARTS_L4, "ARTS_L4", "Advanced real-time simple profile, L4" },
- { XVID_PROFILE_AS_L0, "AS_L0", "Advanced simple profile, L0" },
- { XVID_PROFILE_AS_L1, "AS_L1", "Advanced simple profile, L1" },
- { XVID_PROFILE_AS_L2, "AS_L2", "Advanced simple profile, L2" },
- { XVID_PROFILE_AS_L3, "AS_L3", "Advanced simple profile, L3" },
- { XVID_PROFILE_AS_L4, "AS_L4", "Advanced simple profile, L4" },
- { 0, NULL, NULL },
+ {XVID_PROFILE_S_L0, "S_L0", "Simple profile, L0"},
+ {XVID_PROFILE_S_L1, "S_L1", "Simple profile, L1"},
+ {XVID_PROFILE_S_L2, "S_L2", "Simple profile, L2"},
+ {XVID_PROFILE_S_L3, "S_L3", "Simple profile, L3"},
+ {XVID_PROFILE_ARTS_L1, "ARTS_L1",
+ "Advanced real-time simple profile, L1"},
+ {XVID_PROFILE_ARTS_L2, "ARTS_L2",
+ "Advanced real-time simple profile, L2"},
+ {XVID_PROFILE_ARTS_L3, "ARTS_L3",
+ "Advanced real-time simple profile, L3"},
+ {XVID_PROFILE_ARTS_L4, "ARTS_L4",
+ "Advanced real-time simple profile, L4"},
+ {XVID_PROFILE_AS_L0, "AS_L0", "Advanced simple profile, L0"},
+ {XVID_PROFILE_AS_L1, "AS_L1", "Advanced simple profile, L1"},
+ {XVID_PROFILE_AS_L2, "AS_L2", "Advanced simple profile, L2"},
+ {XVID_PROFILE_AS_L3, "AS_L3", "Advanced simple profile, L3"},
+ {XVID_PROFILE_AS_L4, "AS_L4", "Advanced simple profile, L4"},
+ {0, NULL, NULL},
};
xvidenc_profile_type =
- g_enum_register_static ("GstXvidEncProfiles",
- xvidenc_profiles);
+ g_enum_register_static ("GstXvidEncProfiles", xvidenc_profiles);
}
return xvidenc_profile_type;
}
GType
-gst_xvidenc_get_type(void)
+gst_xvidenc_get_type (void)
{
static GType xvidenc_type = 0;
- if (!xvidenc_type)
- {
+ if (!xvidenc_type) {
static const GTypeInfo xvidenc_info = {
- sizeof(GstXvidEncClass),
+ sizeof (GstXvidEncClass),
gst_xvidenc_base_init,
NULL,
(GClassInitFunc) gst_xvidenc_class_init,
NULL,
NULL,
- sizeof(GstXvidEnc),
+ sizeof (GstXvidEnc),
0,
(GInstanceInitFunc) gst_xvidenc_init,
};
- xvidenc_type = g_type_register_static(GST_TYPE_ELEMENT,
- "GstXvidEnc",
- &xvidenc_info, 0);
+ xvidenc_type = g_type_register_static (GST_TYPE_ELEMENT,
+ "GstXvidEnc", &xvidenc_info, 0);
}
return xvidenc_type;
}
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&sink_template));
+ gst_static_pad_template_get (&sink_template));
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&src_template));
+ gst_static_pad_template_get (&src_template));
gst_element_class_set_details (element_class, &gst_xvidenc_details);
}
static void
-gst_xvidenc_class_init (GstXvidEncClass *klass)
+gst_xvidenc_class_init (GstXvidEncClass * klass)
{
GstElementClass *gstelement_class;
GObjectClass *gobject_class;
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);
/* encoding profile */
- g_object_class_install_property(gobject_class, ARG_PROFILE,
- g_param_spec_enum("profile", "Profile", "XviD/MPEG-4 encoding profile",
- GST_TYPE_XVIDENC_PROFILE, XVID_PROFILE_S_L0,
- G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, ARG_PROFILE,
+ g_param_spec_enum ("profile", "Profile", "XviD/MPEG-4 encoding profile",
+ GST_TYPE_XVIDENC_PROFILE, XVID_PROFILE_S_L0, G_PARAM_READWRITE));
/* bitrate */
- g_object_class_install_property(gobject_class, ARG_BITRATE,
- g_param_spec_int("bitrate","Bitrate",
- "Target video bitrate (kbps)",
- 0,G_MAXINT,512,G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, ARG_BITRATE,
+ g_param_spec_int ("bitrate", "Bitrate",
+ "Target video bitrate (kbps)", 0, G_MAXINT, 512, G_PARAM_READWRITE));
/* keyframe interval */
- g_object_class_install_property(gobject_class, ARG_MAXKEYINTERVAL,
- g_param_spec_int("max_key_interval","Max. Key Interval",
- "Maximum number of frames between two keyframes",
- 0,G_MAXINT,0,G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, ARG_MAXKEYINTERVAL,
+ g_param_spec_int ("max_key_interval", "Max. Key Interval",
+ "Maximum number of frames between two keyframes",
+ 0, G_MAXINT, 0, G_PARAM_READWRITE));
- g_object_class_install_property(gobject_class, ARG_BUFSIZE,
- g_param_spec_ulong("buffer_size", "Buffer Size",
- "Size of the video buffers",
- 0,G_MAXULONG,0,G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, ARG_BUFSIZE,
+ g_param_spec_ulong ("buffer_size", "Buffer Size",
+ "Size of the video buffers", 0, G_MAXULONG, 0, G_PARAM_READWRITE));
gobject_class->set_property = gst_xvidenc_set_property;
gobject_class->get_property = gst_xvidenc_get_property;
gstelement_class->change_state = gst_xvidenc_change_state;
gst_xvidenc_signals[FRAME_ENCODED] =
- g_signal_new ("frame-encoded", G_TYPE_FROM_CLASS(klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstXvidEncClass, frame_encoded),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("frame-encoded", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstXvidEncClass, frame_encoded),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}
static void
-gst_xvidenc_init (GstXvidEnc *xvidenc)
+gst_xvidenc_init (GstXvidEnc * xvidenc)
{
- gst_xvid_init();
+ gst_xvid_init ();
/* create the sink pad */
- xvidenc->sinkpad = gst_pad_new_from_template(
- gst_static_pad_template_get (&sink_template),
- "sink");
- gst_element_add_pad(GST_ELEMENT(xvidenc), xvidenc->sinkpad);
+ xvidenc->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get (&sink_template),
+ "sink");
+ gst_element_add_pad (GST_ELEMENT (xvidenc), xvidenc->sinkpad);
- gst_pad_set_chain_function(xvidenc->sinkpad, gst_xvidenc_chain);
- gst_pad_set_link_function(xvidenc->sinkpad, gst_xvidenc_link);
+ gst_pad_set_chain_function (xvidenc->sinkpad, gst_xvidenc_chain);
+ gst_pad_set_link_function (xvidenc->sinkpad, gst_xvidenc_link);
/* create the src pad */
- xvidenc->srcpad = gst_pad_new_from_template(
- gst_static_pad_template_get (&src_template),
- "src");
- gst_element_add_pad(GST_ELEMENT(xvidenc), xvidenc->srcpad);
+ xvidenc->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get (&src_template),
+ "src");
+ gst_element_add_pad (GST_ELEMENT (xvidenc), xvidenc->srcpad);
/* bitrate, etc. */
xvidenc->width = xvidenc->height = xvidenc->csp = xvidenc->stride = -1;
xvidenc->profile = XVID_PROFILE_S_L0;
xvidenc->bitrate = 512;
xvidenc->max_b_frames = 2;
- xvidenc->max_key_interval = -1; /* default - 2*fps */
+ xvidenc->max_key_interval = -1; /* default - 2*fps */
xvidenc->buffer_size = 512;
/* set xvid handle to NULL */
static gboolean
-gst_xvidenc_setup (GstXvidEnc *xvidenc)
+gst_xvidenc_setup (GstXvidEnc * xvidenc)
{
xvid_enc_create_t xenc;
xvid_enc_plugin_t xplugin;
xenc.height = xvidenc->height;
xenc.max_bframes = xvidenc->max_b_frames;
xenc.global = XVID_GLOBAL_PACKED;
+
xenc.fbase = 1000000;
- xenc.fincr = (int)(xenc.fbase / xvidenc->fps);
+ xenc.fincr = (int) (xenc.fbase / xvidenc->fps);
xenc.max_key_interval = (xvidenc->max_key_interval == -1) ?
- (2 * xenc.fbase / xenc.fincr) :
- xvidenc->max_key_interval;
+ (2 * xenc.fbase / xenc.fincr) : xvidenc->max_key_interval;
xenc.handle = NULL;
/* CBR bitrate/quant for now */
xenc.plugins[0].func = xvid_plugin_single;
xenc.plugins[0].param = &xsingle;
- if ((ret = xvid_encore(NULL, XVID_ENC_CREATE,
- &xenc, NULL)) < 0) {
+ if ((ret = xvid_encore (NULL, XVID_ENC_CREATE, &xenc, NULL)) < 0) {
GST_ELEMENT_ERROR (xvidenc, LIBRARY, INIT, (NULL),
- ("Error setting up xvid encoder: %s (%d)",
- gst_xvid_error(ret), ret));
+ ("Error setting up xvid encoder: %s (%d)", gst_xvid_error (ret), ret));
return FALSE;
}
static void
-gst_xvidenc_chain (GstPad *pad,
- GstData *_data)
+gst_xvidenc_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
- GstXvidEnc *xvidenc = GST_XVIDENC(GST_OBJECT_PARENT(pad));
+ GstXvidEnc *xvidenc = GST_XVIDENC (GST_OBJECT_PARENT (pad));
GstBuffer *outbuf;
xvid_enc_frame_t xframe;
xvid_enc_stats_t xstats;
gint ret;
- g_return_if_fail(pad != NULL);
- g_return_if_fail(GST_IS_PAD(pad));
+ g_return_if_fail (pad != NULL);
+ g_return_if_fail (GST_IS_PAD (pad));
- outbuf = gst_buffer_new_and_alloc(xvidenc->buffer_size << 10);
- GST_BUFFER_TIMESTAMP(outbuf) = GST_BUFFER_TIMESTAMP(buf);
- GST_BUFFER_DURATION(outbuf) = GST_BUFFER_DURATION(buf);
+ outbuf = gst_buffer_new_and_alloc (xvidenc->buffer_size << 10);
+ GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
+ GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buf);
/* encode and so ... */
gst_xvid_init_struct (xframe);
- xframe.vol_flags = XVID_VOL_MPEGQUANT |
- XVID_VOL_GMC;
+ xframe.vol_flags = XVID_VOL_MPEGQUANT | XVID_VOL_GMC;
xframe.par = XVID_PAR_11_VGA;
xframe.vop_flags = XVID_VOP_TRELLISQUANT;
xframe.motion = 0;
xframe.input.csp = xvidenc->csp;
if (xvidenc->width == xvidenc->stride) {
- xframe.input.plane[0] = GST_BUFFER_DATA(buf);
- xframe.input.plane[1] = xframe.input.plane[0] + (xvidenc->width * xvidenc->height);
- xframe.input.plane[2] = xframe.input.plane[1] + (xvidenc->width * xvidenc->height / 4);
+ xframe.input.plane[0] = GST_BUFFER_DATA (buf);
+ xframe.input.plane[1] =
+ xframe.input.plane[0] + (xvidenc->width * xvidenc->height);
+ xframe.input.plane[2] =
+ xframe.input.plane[1] + (xvidenc->width * xvidenc->height / 4);
xframe.input.stride[0] = xvidenc->width;
xframe.input.stride[1] = xvidenc->width / 2;
xframe.input.stride[2] = xvidenc->width / 2;
} else {
- xframe.input.plane[0] = GST_BUFFER_DATA(buf);
+ xframe.input.plane[0] = GST_BUFFER_DATA (buf);
xframe.input.stride[0] = xvidenc->stride;
}
xframe.type = XVID_TYPE_AUTO;
- xframe.bitstream = (void *) GST_BUFFER_DATA(outbuf);
- xframe.length = GST_BUFFER_MAXSIZE(outbuf);
+ xframe.bitstream = (void *) GST_BUFFER_DATA (outbuf);
+ xframe.length = GST_BUFFER_MAXSIZE (outbuf);
gst_xvid_init_struct (xstats);
- if ((ret = xvid_encore(xvidenc->handle, XVID_ENC_ENCODE,
- &xframe, &xstats)) < 0) {
+ if ((ret = xvid_encore (xvidenc->handle, XVID_ENC_ENCODE,
+ &xframe, &xstats)) < 0) {
GST_ELEMENT_ERROR (xvidenc, LIBRARY, ENCODE, (NULL),
- ("Error encoding xvid frame: %s (%d)",
- gst_xvid_error(ret), ret));
- gst_buffer_unref(buf);
- gst_buffer_unref(outbuf);
+ ("Error encoding xvid frame: %s (%d)", gst_xvid_error (ret), ret));
+ gst_buffer_unref (buf);
+ gst_buffer_unref (outbuf);
return;
}
- GST_BUFFER_SIZE(outbuf) = xstats.length;
+ GST_BUFFER_SIZE (outbuf) = xstats.length;
if (xframe.out_flags & XVID_KEYFRAME)
- GST_BUFFER_FLAG_SET(outbuf, GST_BUFFER_KEY_UNIT);
+ GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_KEY_UNIT);
/* go out, multiply! */
- gst_pad_push(xvidenc->srcpad, GST_DATA (outbuf));
+ gst_pad_push (xvidenc->srcpad, GST_DATA (outbuf));
/* proclaim destiny */
- g_signal_emit(G_OBJECT(xvidenc),gst_xvidenc_signals[FRAME_ENCODED], 0);
+ g_signal_emit (G_OBJECT (xvidenc), gst_xvidenc_signals[FRAME_ENCODED], 0);
/* until the final judgement */
- gst_buffer_unref(buf);
+ gst_buffer_unref (buf);
}
static GstPadLinkReturn
-gst_xvidenc_link (GstPad *pad,
- const GstCaps *vscaps)
+gst_xvidenc_link (GstPad * pad, const GstCaps * vscaps)
{
GstXvidEnc *xvidenc;
GstStructure *structure;
double fps;
gint xvid_cs = -1, stride = -1;
- xvidenc = GST_XVIDENC(gst_pad_get_parent (pad));
+ xvidenc = GST_XVIDENC (gst_pad_get_parent (pad));
/* if there's something old around, remove it */
if (xvidenc->handle) {
- xvid_encore(xvidenc->handle, XVID_ENC_DESTROY, NULL, NULL);
+ xvid_encore (xvidenc->handle, XVID_ENC_DESTROY, NULL, NULL);
xvidenc->handle = NULL;
}
xvidenc->stride = stride;
xvidenc->fps = fps;
- if (gst_xvidenc_setup(xvidenc)) {
+ if (gst_xvidenc_setup (xvidenc)) {
GstPadLinkReturn ret;
GstCaps *new_caps;
- new_caps = gst_caps_new_simple("video/x-xvid",
- "width", G_TYPE_INT, w,
- "height", G_TYPE_INT, h,
- "framerate", G_TYPE_DOUBLE, fps, NULL);
- ret = gst_pad_try_set_caps(xvidenc->srcpad, new_caps);
+ new_caps = gst_caps_new_simple ("video/x-xvid",
+ "width", G_TYPE_INT, w,
+ "height", G_TYPE_INT, h, "framerate", G_TYPE_DOUBLE, fps, NULL);
+ ret = gst_pad_try_set_caps (xvidenc->srcpad, new_caps);
if (GST_PAD_LINK_FAILED (ret)) {
if (xvidenc->handle) {
- xvid_encore(xvidenc->handle, XVID_ENC_DESTROY, NULL, NULL);
- xvidenc->handle = NULL;
+ xvid_encore (xvidenc->handle, XVID_ENC_DESTROY, NULL, NULL);
+ xvidenc->handle = NULL;
}
}
static void
-gst_xvidenc_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+gst_xvidenc_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec)
{
GstXvidEnc *xvidenc;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_XVIDENC (object));
- xvidenc = GST_XVIDENC(object);
+ xvidenc = GST_XVIDENC (object);
- switch (prop_id)
- {
+ switch (prop_id) {
case ARG_PROFILE:
- xvidenc->profile = g_value_get_enum(value);
+ xvidenc->profile = g_value_get_enum (value);
break;
case ARG_BITRATE:
- xvidenc->bitrate = g_value_get_int(value);
+ xvidenc->bitrate = g_value_get_int (value);
break;
case ARG_BUFSIZE:
- xvidenc->buffer_size = g_value_get_int(value);
+ xvidenc->buffer_size = g_value_get_int (value);
break;
case ARG_MAXKEYINTERVAL:
- xvidenc->max_key_interval = g_value_get_int(value);
+ xvidenc->max_key_interval = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
static void
-gst_xvidenc_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+gst_xvidenc_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec)
{
GstXvidEnc *xvidenc;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_XVIDENC (object));
- xvidenc = GST_XVIDENC(object);
+ xvidenc = GST_XVIDENC (object);
switch (prop_id) {
case ARG_PROFILE:
- g_value_set_enum(value, xvidenc->profile);
+ g_value_set_enum (value, xvidenc->profile);
break;
case ARG_BITRATE:
- g_value_set_int(value, xvidenc->bitrate);
+ g_value_set_int (value, xvidenc->bitrate);
break;
case ARG_BUFSIZE:
- g_value_set_int(value, xvidenc->buffer_size);
+ g_value_set_int (value, xvidenc->buffer_size);
break;
case ARG_MAXKEYINTERVAL:
- g_value_set_int(value, xvidenc->max_key_interval);
+ g_value_set_int (value, xvidenc->max_key_interval);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
static GstElementStateReturn
-gst_xvidenc_change_state (GstElement *element)
+gst_xvidenc_change_state (GstElement * element)
{
GstXvidEnc *xvidenc = GST_XVIDENC (element);
switch (GST_STATE_PENDING (element)) {
case GST_STATE_PAUSED_TO_READY:
if (xvidenc->handle) {
- xvid_encore(xvidenc->handle, XVID_ENC_DESTROY, NULL, NULL);
- xvidenc->handle = NULL;
+ xvid_encore (xvidenc->handle, XVID_ENC_DESTROY, NULL, NULL);
+ xvidenc->handle = NULL;
}
break;
default:
#include "gstxvid.h"
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_XVIDENC \
#define GST_IS_XVIDENC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_XVIDENC))
-typedef struct _GstXvidEnc GstXvidEnc;
-typedef struct _GstXvidEncClass GstXvidEncClass;
+ typedef struct _GstXvidEnc GstXvidEnc;
+ typedef struct _GstXvidEncClass GstXvidEncClass;
-struct _GstXvidEnc {
- GstElement element;
+ struct _GstXvidEnc
+ {
+ GstElement element;
- /* pads */
- GstPad *sinkpad, *srcpad;
+ /* pads */
+ GstPad *sinkpad, *srcpad;
- /* encoding profile */
- gint profile;
+ /* encoding profile */
+ gint profile;
- /* quality of encoded image */
- gint bitrate;
- gint buffer_size;
+ /* quality of encoded image */
+ gint bitrate;
+ gint buffer_size;
- /* max number of B frames between I/P */
- gint max_b_frames;
+ /* max number of B frames between I/P */
+ gint max_b_frames;
- /* max key interval */
- gint max_key_interval;
+ /* max key interval */
+ gint max_key_interval;
- /* xvid handle */
- void *handle;
- gint csp;
- gint width, height, stride;
- gdouble fps;
-};
+ /* xvid handle */
+ void *handle;
+ gint csp;
+ gint width, height, stride;
+ gdouble fps;
+ };
-struct _GstXvidEncClass {
- GstElementClass parent_class;
+ struct _GstXvidEncClass
+ {
+ GstElementClass parent_class;
- /* signals */
- void (*frame_encoded) (GstElement *element);
-};
+ /* signals */
+ void (*frame_encoded) (GstElement * element);
+ };
-GType gst_xvidenc_get_type(void);
+ GType gst_xvidenc_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_XVIDENC_H__ */
+#endif /* __GST_XVIDENC_H__ */
#include <gst/gststructure.h>
int
-gst_audio_frame_byte_size (GstPad* pad)
+gst_audio_frame_byte_size (GstPad * pad)
{
/* calculate byte size of an audio frame
* this should be moved closer to the gstreamer core
if (caps == NULL) {
/* ERROR: could not get caps of pad */
- g_warning ("gstaudio: could not get caps of pad %s:%s\n",
- GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad));
+ g_warning ("gstaudio: could not get caps of pad %s:%s\n",
+ GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad));
return 0;
}
structure = gst_caps_get_structure (caps, 0);
- gst_structure_get_int (structure, "width", &width);
+ gst_structure_get_int (structure, "width", &width);
gst_structure_get_int (structure, "channels", &channels);
- return (width / 8) * channels;
+ return (width / 8) * channels;
}
long
-gst_audio_frame_length (GstPad* pad, GstBuffer* buf)
+gst_audio_frame_length (GstPad * pad, GstBuffer * buf)
/* calculate length of buffer in frames
* this should be moved closer to the gstreamer core
* and be implemented for every mime type IMO
/* error */
return 0;
/* FIXME: this function assumes the buffer size to be a whole multiple
- * of the frame byte size
+ * of the frame byte size
*/
return GST_BUFFER_SIZE (buf) / frame_byte_size;
}
long
-gst_audio_frame_rate (GstPad *pad)
+gst_audio_frame_rate (GstPad * pad)
/*
* calculate frame rate (based on caps of pad)
* returns 0 if failed, rate if success
if (caps == NULL) {
/* ERROR: could not get caps of pad */
- g_warning ("gstaudio: could not get caps of pad %s:%s\n",
- GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad));
+ g_warning ("gstaudio: could not get caps of pad %s:%s\n",
+ GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad));
return 0;
- }
- else {
+ } else {
structure = gst_caps_get_structure (caps, 0);
- gst_structure_get_int (structure, "rate", &rate);
+ gst_structure_get_int (structure, "rate", &rate);
return rate;
}
}
-double
-gst_audio_length (GstPad* pad, GstBuffer* buf)
+double
+gst_audio_length (GstPad * pad, GstBuffer * buf)
{
/* calculate length in seconds
* of audio buffer buf
g_assert (GST_IS_BUFFER (buf));
/* get caps of pad */
caps = GST_PAD_CAPS (pad);
- if (caps == NULL)
- {
+ if (caps == NULL) {
/* ERROR: could not get caps of pad */
- g_warning ("gstaudio: could not get caps of pad %s:%s\n",
- GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad));
+ g_warning ("gstaudio: could not get caps of pad %s:%s\n",
+ GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad));
length = 0.0;
- }
- else
- {
+ } else {
structure = gst_caps_get_structure (caps, 0);
bytes = GST_BUFFER_SIZE (buf);
- gst_structure_get_int (structure, "width", &width);
- gst_structure_get_int (structure, "channels", &channels);
- gst_structure_get_int (structure, "rate", &rate);
+ gst_structure_get_int (structure, "width", &width);
+ gst_structure_get_int (structure, "channels", &channels);
+ gst_structure_get_int (structure, "rate", &rate);
g_assert (bytes != 0);
g_assert (width != 0);
return length;
}
-long
-gst_audio_highest_sample_value (GstPad* pad)
+long
+gst_audio_highest_sample_value (GstPad * pad)
/* calculate highest possible sample value
* based on capabilities of pad
*/
gint width = 0;
const GstCaps *caps = NULL;
GstStructure *structure;
-
+
caps = GST_PAD_CAPS (pad);
- if (caps == NULL)
- {
- g_warning ("gstaudio: could not get caps of pad %s:%s\n",
- GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad));
+ if (caps == NULL) {
+ g_warning ("gstaudio: could not get caps of pad %s:%s\n",
+ GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad));
}
-
+
structure = gst_caps_get_structure (caps, 0);
- gst_structure_get_int (structure, "width", &width);
- gst_structure_get_boolean (structure, "signed", &is_signed);
-
- if (is_signed) --width;
+ gst_structure_get_int (structure, "width", &width);
+ gst_structure_get_boolean (structure, "signed", &is_signed);
+
+ if (is_signed)
+ --width;
/* example : 16 bit, signed : samples between -32768 and 32767 */
return ((long) (1 << width));
}
-gboolean
-gst_audio_is_buffer_framed (GstPad* pad, GstBuffer* buf)
+gboolean
+gst_audio_is_buffer_framed (GstPad * pad, GstBuffer * buf)
/* check if the buffer size is a whole multiple of the frame size */
{
if (GST_BUFFER_SIZE (buf) % gst_audio_frame_byte_size (pad) == 0)
* number of list values, and each of the values, terminating with NULL
*/
static void
-_gst_audio_structure_set_list (GstStructure *structure, const gchar *fieldname,
- GType type, int number, ...)
+_gst_audio_structure_set_list (GstStructure * structure,
+ const gchar * fieldname, GType type, int number, ...)
{
va_list varargs;
GValue value = { 0 };
va_start (varargs, number);
- for (j = 0; j < number; ++j)
- {
+ for (j = 0; j < number; ++j) {
int i;
gboolean b;
GValue list_value = { 0 };
- switch (type)
- {
+ switch (type) {
case G_TYPE_INT:
- i = va_arg (varargs, int);
- g_value_init (&list_value, G_TYPE_INT);
- g_value_set_int (&list_value, i);
- break;
+ i = va_arg (varargs, int);
+
+ g_value_init (&list_value, G_TYPE_INT);
+ g_value_set_int (&list_value, i);
+ break;
case G_TYPE_BOOLEAN:
- b = va_arg (varargs, gboolean);
- g_value_init (&list_value, G_TYPE_BOOLEAN);
- g_value_set_boolean (&list_value, b);
- break;
- default:
- g_warning ("_gst_audio_structure_set_list: LIST of given type not implemented.");
+ b = va_arg (varargs, gboolean);
+ g_value_init (&list_value, G_TYPE_BOOLEAN);
+ g_value_set_boolean (&list_value, b);
+ break;
+ default:
+ g_warning
+ ("_gst_audio_structure_set_list: LIST of given type not implemented.");
}
g_array_append_val (array, list_value);
}
void
-gst_audio_structure_set_int (GstStructure *structure, GstAudioFieldFlag flag)
+gst_audio_structure_set_int (GstStructure * structure, GstAudioFieldFlag flag)
{
if (flag & GST_AUDIO_FIELD_RATE)
- gst_structure_set (structure, "rate", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
+ gst_structure_set (structure, "rate", GST_TYPE_INT_RANGE, 1, G_MAXINT,
+ NULL);
if (flag & GST_AUDIO_FIELD_CHANNELS)
- gst_structure_set (structure, "channels", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
+ gst_structure_set (structure, "channels", GST_TYPE_INT_RANGE, 1, G_MAXINT,
+ NULL);
if (flag & GST_AUDIO_FIELD_ENDIANNESS)
- _gst_audio_structure_set_list (structure, "endianness", G_TYPE_INT, 2, G_LITTLE_ENDIAN, G_BIG_ENDIAN, NULL);
+ _gst_audio_structure_set_list (structure, "endianness", G_TYPE_INT, 2,
+ G_LITTLE_ENDIAN, G_BIG_ENDIAN, NULL);
if (flag & GST_AUDIO_FIELD_WIDTH)
- _gst_audio_structure_set_list (structure, "width", G_TYPE_INT, 3, 8, 16, 32, NULL);
+ _gst_audio_structure_set_list (structure, "width", G_TYPE_INT, 3, 8, 16, 32,
+ NULL);
if (flag & GST_AUDIO_FIELD_DEPTH)
gst_structure_set (structure, "depth", GST_TYPE_INT_RANGE, 1, 32, NULL);
if (flag & GST_AUDIO_FIELD_SIGNED)
- _gst_audio_structure_set_list (structure, "signed", G_TYPE_BOOLEAN, 2, TRUE, FALSE, NULL);
+ _gst_audio_structure_set_list (structure, "signed", G_TYPE_BOOLEAN, 2, TRUE,
+ FALSE, NULL);
if (flag & GST_AUDIO_FIELD_BUFFER_FRAMES)
- gst_structure_set (structure, "buffer-frames", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
+ gst_structure_set (structure, "buffer-frames", GST_TYPE_INT_RANGE, 1,
+ G_MAXINT, NULL);
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "gstaudio",
- "Support services for audio plugins",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-);
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "gstaudio",
+ "Support services for audio plugins",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN);
#define __GST_AUDIO_AUDIO_H__
G_BEGIN_DECLS
-
/* For people that are looking at this source: the purpose of these defines is
* to make GstCaps a bit easier, in that you don't have to know all of the
* properties that need to be defined. you can just use these macros. currently
*
* Andy Wingo, 18 August 2001
* Thomas, 6 September 2002 */
-
#define GST_AUDIO_DEF_RATE 44100
-
#define GST_AUDIO_INT_PAD_TEMPLATE_CAPS \
"audio/x-raw-int, " \
"rate = (int) [ 1, MAX ], " \
"endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, " \
"width = (int) { 8, 16, 32 }, " \
"depth = (int) [ 1, 32 ], " \
- "signed = (boolean) { true, false }"
-
-
+ "signed = (boolean) { true, false }"
/* "standard" int audio is native order, 16 bit stereo. */
#define GST_AUDIO_INT_STANDARD_PAD_TEMPLATE_CAPS \
"audio/x-raw-int, " \
"endianness = (int) BYTE_ORDER, " \
"width = (int) 16, " \
"depth = (int) 16, " \
- "signed = (boolean) true"
-
+ "signed = (boolean) true"
#define GST_AUDIO_FLOAT_PAD_TEMPLATE_CAPS \
"audio/x-raw-float, " \
"rate = (int) [ 1, MAX ], " \
"endianness = (int) { LITTLE_ENDIAN , BIG_ENDIAN }, " \
"width = (int) { 32, 64 }, " \
"buffer-frames = (int) [ 1, MAX]"
-
/* "standard" float audio is native order, 32 bit mono. */
#define GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS \
"audio/x-raw-float, " \
"channels = (int) 1, " \
"endianness = (int) BYTE_ORDER, " \
"buffer-frames = (int) [ 1, MAX]"
-
/*
* this library defines and implements some helper functions for audio
* handling
*/
-
/* get byte size of audio frame (based on caps of pad */
-int gst_audio_frame_byte_size (GstPad* pad);
+int gst_audio_frame_byte_size (GstPad * pad);
/* get length in frames of buffer */
-long gst_audio_frame_length (GstPad* pad, GstBuffer* buf);
+long gst_audio_frame_length (GstPad * pad, GstBuffer * buf);
/* get frame rate based on caps */
-long gst_audio_frame_rate (GstPad *pad);
+long gst_audio_frame_rate (GstPad * pad);
/* calculate length in seconds of audio buffer buf based on caps of pad */
-double gst_audio_length (GstPad* pad, GstBuffer* buf);
+double gst_audio_length (GstPad * pad, GstBuffer * buf);
/* calculate highest possible sample value based on capabilities of pad */
-long gst_audio_highest_sample_value (GstPad* pad);
+long gst_audio_highest_sample_value (GstPad * pad);
/* check if the buffer size is a whole multiple of the frame size */
-gboolean gst_audio_is_buffer_framed (GstPad* pad, GstBuffer* buf);
+gboolean gst_audio_is_buffer_framed (GstPad * pad, GstBuffer * buf);
/* functions useful for _getcaps functions */
-typedef enum {
- GST_AUDIO_FIELD_RATE = (1 << 0),
- GST_AUDIO_FIELD_CHANNELS = (1 << 1),
- GST_AUDIO_FIELD_ENDIANNESS = (1 << 2),
- GST_AUDIO_FIELD_WIDTH = (1 << 3),
- GST_AUDIO_FIELD_DEPTH = (1 << 4),
- GST_AUDIO_FIELD_SIGNED = (1 << 5),
+typedef enum
+{
+ GST_AUDIO_FIELD_RATE = (1 << 0),
+ GST_AUDIO_FIELD_CHANNELS = (1 << 1),
+ GST_AUDIO_FIELD_ENDIANNESS = (1 << 2),
+ GST_AUDIO_FIELD_WIDTH = (1 << 3),
+ GST_AUDIO_FIELD_DEPTH = (1 << 4),
+ GST_AUDIO_FIELD_SIGNED = (1 << 5),
GST_AUDIO_FIELD_BUFFER_FRAMES = (1 << 6)
} GstAudioFieldFlag;
-void gst_audio_structure_set_int (GstStructure *structure, GstAudioFieldFlag flag);
+void gst_audio_structure_set_int (GstStructure * structure,
+ GstAudioFieldFlag flag);
G_END_DECLS
-
#endif /* __GST_AUDIO_AUDIO_H__ */
#include "audioclock.h"
-static void gst_audio_clock_class_init (GstAudioClockClass *klass);
-static void gst_audio_clock_init (GstAudioClock *clock);
+static void gst_audio_clock_class_init (GstAudioClockClass * klass);
+static void gst_audio_clock_init (GstAudioClock * clock);
-static GstClockTime gst_audio_clock_get_internal_time (GstClock *clock);
-static GstClockReturn gst_audio_clock_id_wait_async (GstClock *clock,
- GstClockEntry *entry);
-static void gst_audio_clock_id_unschedule (GstClock *clock,
- GstClockEntry *entry);
+static GstClockTime gst_audio_clock_get_internal_time (GstClock * clock);
+static GstClockReturn gst_audio_clock_id_wait_async (GstClock * clock,
+ GstClockEntry * entry);
+static void gst_audio_clock_id_unschedule (GstClock * clock,
+ GstClockEntry * entry);
static GstSystemClockClass *parent_class = NULL;
+
/* static guint gst_audio_clock_signals[LAST_SIGNAL] = { 0 }; */
-
+
GType
gst_audio_clock_get_type (void)
-{
+{
static GType clock_type = 0;
-
+
if (!clock_type) {
static const GTypeInfo clock_info = {
sizeof (GstAudioClockClass),
NULL
};
clock_type = g_type_register_static (GST_TYPE_SYSTEM_CLOCK, "GstAudioClock",
- &clock_info, 0);
+ &clock_info, 0);
}
return clock_type;
}
static void
-gst_audio_clock_class_init (GstAudioClockClass *klass)
+gst_audio_clock_class_init (GstAudioClockClass * klass)
{
GObjectClass *gobject_class;
GstObjectClass *gstobject_class;
GstClockClass *gstclock_class;
- gobject_class = (GObjectClass*) klass;
- gstobject_class = (GstObjectClass*) klass;
- gstclock_class = (GstClockClass*) klass;
+ gobject_class = (GObjectClass *) klass;
+ gstobject_class = (GstObjectClass *) klass;
+ gstclock_class = (GstClockClass *) klass;
parent_class = g_type_class_ref (GST_TYPE_SYSTEM_CLOCK);
- gstclock_class->get_internal_time = gst_audio_clock_get_internal_time;
- gstclock_class->wait_async = gst_audio_clock_id_wait_async;
- gstclock_class->unschedule = gst_audio_clock_id_unschedule;
+ gstclock_class->get_internal_time = gst_audio_clock_get_internal_time;
+ gstclock_class->wait_async = gst_audio_clock_id_wait_async;
+ gstclock_class->unschedule = gst_audio_clock_id_unschedule;
}
static void
-gst_audio_clock_init (GstAudioClock *clock)
+gst_audio_clock_init (GstAudioClock * clock)
{
gst_object_set_name (GST_OBJECT (clock), "GstAudioClock");
clock->prev2 = 0;
}
-GstClock*
-gst_audio_clock_new (gchar *name, GstAudioClockGetTimeFunc func, gpointer user_data)
+GstClock *
+gst_audio_clock_new (gchar * name, GstAudioClockGetTimeFunc func,
+ gpointer user_data)
{
- GstAudioClock *aclock = GST_AUDIO_CLOCK (g_object_new (GST_TYPE_AUDIO_CLOCK, NULL));
+ GstAudioClock *aclock =
+ GST_AUDIO_CLOCK (g_object_new (GST_TYPE_AUDIO_CLOCK, NULL));
aclock->func = func;
aclock->user_data = user_data;
aclock->adjust = 0;
- return (GstClock*)aclock;
+ return (GstClock *) aclock;
}
void
-gst_audio_clock_set_active (GstAudioClock *aclock, gboolean active)
+gst_audio_clock_set_active (GstAudioClock * aclock, gboolean active)
{
GstClockTime time;
GstClock *clock;
aclock->adjust = time - aclock->func (clock, aclock->user_data);
} else {
GTimeVal timeval;
+
g_get_current_time (&timeval);
-
+
aclock->adjust = GST_TIMEVAL_TO_TIME (timeval) - time;
}
}
static GstClockTime
-gst_audio_clock_get_internal_time (GstClock *clock)
+gst_audio_clock_get_internal_time (GstClock * clock)
{
GstAudioClock *aclock = GST_AUDIO_CLOCK (clock);
-
+
if (aclock->active) {
return aclock->func (clock, aclock->user_data) + aclock->adjust;
} else {
GTimeVal timeval;
-
+
g_get_current_time (&timeval);
return GST_TIMEVAL_TO_TIME (timeval);
}
}
void
-gst_audio_clock_update_time (GstAudioClock *aclock, GstClockTime time)
+gst_audio_clock_update_time (GstAudioClock * aclock, GstClockTime time)
{
/* I don't know of a purpose in updating these; perhaps they can be removed */
aclock->prev2 = aclock->prev1;
/* FIXME: the wait_async subsystem should be made threadsafe, but I don't want
* to lock and unlock a mutex on every iteration... */
while (aclock->async_entries) {
- GstClockEntry *entry = (GstClockEntry*)aclock->async_entries->data;
-
+ GstClockEntry *entry = (GstClockEntry *) aclock->async_entries->data;
+
if (entry->time > time)
break;
- entry->func ((GstClock*)aclock, time, entry, entry->user_data);
+ entry->func ((GstClock *) aclock, time, entry, entry->user_data);
aclock->async_entries = g_slist_delete_link (aclock->async_entries,
- aclock->async_entries);
+ aclock->async_entries);
/* do I need to free the entry? */
}
}
static gint
-compare_clock_entries (GstClockEntry *entry1, GstClockEntry *entry2)
+compare_clock_entries (GstClockEntry * entry1, GstClockEntry * entry2)
{
return entry1->time - entry2->time;
}
static GstClockReturn
-gst_audio_clock_id_wait_async (GstClock *clock, GstClockEntry *entry)
+gst_audio_clock_id_wait_async (GstClock * clock, GstClockEntry * entry)
{
- GstAudioClock *aclock = (GstAudioClock*)clock;
-
+ GstAudioClock *aclock = (GstAudioClock *) clock;
+
aclock->async_entries = g_slist_insert_sorted (aclock->async_entries,
- entry,
- (GCompareFunc)compare_clock_entries);
+ entry, (GCompareFunc) compare_clock_entries);
/* is this the proper return val? */
return GST_CLOCK_EARLY;
}
static void
-gst_audio_clock_id_unschedule (GstClock *clock, GstClockEntry *entry)
+gst_audio_clock_id_unschedule (GstClock * clock, GstClockEntry * entry)
{
- GstAudioClock *aclock = (GstAudioClock*)clock;
-
- aclock->async_entries = g_slist_remove (aclock->async_entries,
- entry);
+ GstAudioClock *aclock = (GstAudioClock *) clock;
+
+ aclock->async_entries = g_slist_remove (aclock->async_entries, entry);
}
#include <gst/gstsystemclock.h>
G_BEGIN_DECLS
-
#define GST_TYPE_AUDIO_CLOCK \
(gst_audio_clock_get_type())
#define GST_AUDIO_CLOCK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIO_CLOCK))
#define GST_IS_AUDIO_CLOCK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIO_CLOCK))
-
typedef struct _GstAudioClock GstAudioClock;
typedef struct _GstAudioClockClass GstAudioClockClass;
-typedef GstClockTime (*GstAudioClockGetTimeFunc) (GstClock *clock, gpointer user_data);
+typedef GstClockTime (*GstAudioClockGetTimeFunc) (GstClock * clock,
+ gpointer user_data);
-struct _GstAudioClock {
+struct _GstAudioClock
+{
GstSystemClock clock;
GstClockTime prev1, prev2;
gpointer _gst_reserved[GST_PADDING];
};
-struct _GstAudioClockClass {
+struct _GstAudioClockClass
+{
GstSystemClockClass parent_class;
gpointer _gst_reserved[GST_PADDING];
};
-GType gst_audio_clock_get_type (void);
-GstClock* gst_audio_clock_new (gchar *name, GstAudioClockGetTimeFunc func,
- gpointer user_data);
-void gst_audio_clock_set_active (GstAudioClock *aclock, gboolean active);
+GType gst_audio_clock_get_type (void);
+GstClock *gst_audio_clock_new (gchar * name, GstAudioClockGetTimeFunc func,
+ gpointer user_data);
+void gst_audio_clock_set_active (GstAudioClock * aclock, gboolean active);
-void gst_audio_clock_update_time (GstAudioClock *aclock, GstClockTime time);
+void gst_audio_clock_update_time (GstAudioClock * aclock, GstClockTime time);
G_END_DECLS
-
#endif /* __GST_AUDIO_CLOCK_H__ */
/* GstAudiofilter signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_METHOD,
/* FILL ME */
};
-static void gst_audiofilter_base_init (gpointer g_class);
-static void gst_audiofilter_class_init (gpointer g_class, gpointer class_data);
-static void gst_audiofilter_init (GTypeInstance *instance, gpointer g_class);
+static void gst_audiofilter_base_init (gpointer g_class);
+static void gst_audiofilter_class_init (gpointer g_class, gpointer class_data);
+static void gst_audiofilter_init (GTypeInstance * instance, gpointer g_class);
-static void gst_audiofilter_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void gst_audiofilter_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+static void gst_audiofilter_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_audiofilter_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static void gst_audiofilter_chain (GstPad *pad, GstData *_data);
-GstCaps * gst_audiofilter_class_get_capslist(GstAudiofilterClass *klass);
+static void gst_audiofilter_chain (GstPad * pad, GstData * _data);
+GstCaps *gst_audiofilter_class_get_capslist (GstAudiofilterClass * klass);
static GstElementClass *parent_class = NULL;
if (!audiofilter_type) {
static const GTypeInfo audiofilter_info = {
- sizeof(GstAudiofilterClass),
+ sizeof (GstAudiofilterClass),
gst_audiofilter_base_init,
NULL,
gst_audiofilter_class_init,
NULL,
NULL,
- sizeof(GstAudiofilter),
+ sizeof (GstAudiofilter),
0,
gst_audiofilter_init,
};
- audiofilter_type = g_type_register_static(GST_TYPE_ELEMENT,
+ audiofilter_type = g_type_register_static (GST_TYPE_ELEMENT,
"GstAudiofilter", &audiofilter_info, G_TYPE_FLAG_ABSTRACT);
}
return audiofilter_type;
}
-static void gst_audiofilter_base_init (gpointer g_class)
+static void
+gst_audiofilter_base_init (gpointer g_class)
{
static GstElementDetails audiofilter_details = {
"Audio filter base class",
gst_element_class_set_details (element_class, &audiofilter_details);
}
-static void gst_audiofilter_class_init (gpointer g_class, gpointer class_data)
+static void
+gst_audiofilter_class_init (gpointer g_class, gpointer class_data)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GstAudiofilterClass *klass;
- klass = (GstAudiofilterClass *)g_class;
- gobject_class = (GObjectClass*)klass;
- gstelement_class = (GstElementClass*)klass;
+ klass = (GstAudiofilterClass *) g_class;
+ 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);
gobject_class->set_property = gst_audiofilter_set_property;
gobject_class->get_property = gst_audiofilter_get_property;
}
static GstPadLinkReturn
-gst_audiofilter_link (GstPad *pad, const GstCaps *caps)
+gst_audiofilter_link (GstPad * pad, const GstCaps * caps)
{
GstAudiofilter *audiofilter;
GstPadLinkReturn ret;
GstStructure *structure;
GstAudiofilterClass *audiofilter_class;
- GST_DEBUG("gst_audiofilter_link");
+ GST_DEBUG ("gst_audiofilter_link");
audiofilter = GST_AUDIOFILTER (gst_pad_get_parent (pad));
- audiofilter_class = GST_AUDIOFILTER_CLASS (
- G_OBJECT_GET_CLASS (audiofilter));
-
+ audiofilter_class = GST_AUDIOFILTER_CLASS (G_OBJECT_GET_CLASS (audiofilter));
+
if (pad == audiofilter->srcpad) {
link_ret = gst_pad_try_set_caps (audiofilter->sinkpad, caps);
if (strcmp (gst_structure_get_name (structure), "audio/x-raw-int") == 0) {
ret = gst_structure_get_int (structure, "depth", &audiofilter->depth);
ret &= gst_structure_get_int (structure, "width", &audiofilter->width);
- ret &= gst_structure_get_int (structure, "channels", &audiofilter->channels);
+ ret &=
+ gst_structure_get_int (structure, "channels", &audiofilter->channels);
} else if (strcmp (gst_structure_get_name (structure), "audio/x-raw-float")
== 0) {
} else {
- g_assert_not_reached();
+ g_assert_not_reached ();
}
ret &= gst_structure_get_int (structure, "rate", &audiofilter->rate);
- audiofilter->bytes_per_sample = (audiofilter->width/8) *
- audiofilter->channels;
+ audiofilter->bytes_per_sample = (audiofilter->width / 8) *
+ audiofilter->channels;
- if (audiofilter_class->setup) (audiofilter_class->setup) (audiofilter);
+ if (audiofilter_class->setup)
+ (audiofilter_class->setup) (audiofilter);
return GST_PAD_LINK_OK;
}
static void
-gst_audiofilter_init (GTypeInstance *instance, gpointer g_class)
+gst_audiofilter_init (GTypeInstance * instance, gpointer g_class)
{
GstAudiofilter *audiofilter = GST_AUDIOFILTER (instance);
GstPadTemplate *pad_template;
- GST_DEBUG("gst_audiofilter_init");
-
- pad_template = gst_element_class_get_pad_template(GST_ELEMENT_CLASS(g_class),
- "sink");
- g_return_if_fail(pad_template != NULL);
- audiofilter->sinkpad = gst_pad_new_from_template(pad_template, "sink");
- gst_element_add_pad(GST_ELEMENT(audiofilter),audiofilter->sinkpad);
- gst_pad_set_chain_function(audiofilter->sinkpad,gst_audiofilter_chain);
- gst_pad_set_link_function(audiofilter->sinkpad,gst_audiofilter_link);
- gst_pad_set_getcaps_function(audiofilter->sinkpad,gst_pad_proxy_getcaps);
-
- pad_template = gst_element_class_get_pad_template(GST_ELEMENT_CLASS(g_class),
- "src");
- g_return_if_fail(pad_template != NULL);
- audiofilter->srcpad = gst_pad_new_from_template(pad_template, "src");
- gst_element_add_pad(GST_ELEMENT(audiofilter),audiofilter->srcpad);
- gst_pad_set_link_function(audiofilter->srcpad,gst_audiofilter_link);
- gst_pad_set_getcaps_function(audiofilter->srcpad,gst_pad_proxy_getcaps);
+ GST_DEBUG ("gst_audiofilter_init");
+
+ pad_template =
+ gst_element_class_get_pad_template (GST_ELEMENT_CLASS (g_class), "sink");
+ g_return_if_fail (pad_template != NULL);
+ audiofilter->sinkpad = gst_pad_new_from_template (pad_template, "sink");
+ gst_element_add_pad (GST_ELEMENT (audiofilter), audiofilter->sinkpad);
+ gst_pad_set_chain_function (audiofilter->sinkpad, gst_audiofilter_chain);
+ gst_pad_set_link_function (audiofilter->sinkpad, gst_audiofilter_link);
+ gst_pad_set_getcaps_function (audiofilter->sinkpad, gst_pad_proxy_getcaps);
+
+ pad_template =
+ gst_element_class_get_pad_template (GST_ELEMENT_CLASS (g_class), "src");
+ g_return_if_fail (pad_template != NULL);
+ audiofilter->srcpad = gst_pad_new_from_template (pad_template, "src");
+ gst_element_add_pad (GST_ELEMENT (audiofilter), audiofilter->srcpad);
+ gst_pad_set_link_function (audiofilter->srcpad, gst_audiofilter_link);
+ gst_pad_set_getcaps_function (audiofilter->srcpad, gst_pad_proxy_getcaps);
audiofilter->inited = FALSE;
}
static void
-gst_audiofilter_chain (GstPad *pad, GstData *data)
+gst_audiofilter_chain (GstPad * pad, GstData * data)
{
GstBuffer *inbuf = GST_BUFFER (data);
GstAudiofilter *audiofilter;
audiofilter = GST_AUDIOFILTER (gst_pad_get_parent (pad));
//g_return_if_fail (audiofilter->inited);
- audiofilter_class = GST_AUDIOFILTER_CLASS (
- G_OBJECT_GET_CLASS (audiofilter));
+ audiofilter_class = GST_AUDIOFILTER_CLASS (G_OBJECT_GET_CLASS (audiofilter));
GST_DEBUG ("gst_audiofilter_chain: got buffer of %d bytes in '%s'",
- GST_BUFFER_SIZE(inbuf), GST_OBJECT_NAME (audiofilter));
-
- if(audiofilter->passthru){
- gst_pad_push(audiofilter->srcpad, data);
+ GST_BUFFER_SIZE (inbuf), GST_OBJECT_NAME (audiofilter));
+
+ if (audiofilter->passthru) {
+ gst_pad_push (audiofilter->srcpad, data);
return;
}
audiofilter->size = GST_BUFFER_SIZE (inbuf);
audiofilter->n_samples = audiofilter->size / audiofilter->bytes_per_sample;
- if (gst_data_is_writable(data)) {
+ if (gst_data_is_writable (data)) {
if (audiofilter_class->filter_inplace) {
(audiofilter_class->filter_inplace) (audiofilter, inbuf);
outbuf = inbuf;
} else {
- outbuf = gst_buffer_new_and_alloc (GST_BUFFER_SIZE(inbuf));
- GST_BUFFER_DURATION(outbuf) = GST_BUFFER_DURATION(inbuf);
- GST_BUFFER_TIMESTAMP(outbuf) = GST_BUFFER_TIMESTAMP(inbuf);
+ outbuf = gst_buffer_new_and_alloc (GST_BUFFER_SIZE (inbuf));
+ GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (inbuf);
+ GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (inbuf);
(audiofilter_class->filter) (audiofilter, outbuf, inbuf);
- gst_buffer_unref(inbuf);
+ gst_buffer_unref (inbuf);
}
} else {
- outbuf = gst_buffer_new_and_alloc (GST_BUFFER_SIZE(inbuf));
- GST_BUFFER_DURATION(outbuf) = GST_BUFFER_DURATION(inbuf);
- GST_BUFFER_TIMESTAMP(outbuf) = GST_BUFFER_TIMESTAMP(inbuf);
+ outbuf = gst_buffer_new_and_alloc (GST_BUFFER_SIZE (inbuf));
+ GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (inbuf);
+ GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (inbuf);
if (audiofilter_class->filter) {
(audiofilter_class->filter) (audiofilter, outbuf, inbuf);
} else {
- memcpy(GST_BUFFER_DATA(outbuf), GST_BUFFER_DATA(inbuf),
- GST_BUFFER_SIZE(inbuf));
+ memcpy (GST_BUFFER_DATA (outbuf), GST_BUFFER_DATA (inbuf),
+ GST_BUFFER_SIZE (inbuf));
(audiofilter_class->filter_inplace) (audiofilter, outbuf);
}
- gst_buffer_unref(inbuf);
+ gst_buffer_unref (inbuf);
}
- gst_pad_push(audiofilter->srcpad, GST_DATA (outbuf));
+ gst_pad_push (audiofilter->srcpad, GST_DATA (outbuf));
}
static void
-gst_audiofilter_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_audiofilter_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstAudiofilter *src;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_AUDIOFILTER(object));
- src = GST_AUDIOFILTER(object);
+ g_return_if_fail (GST_IS_AUDIOFILTER (object));
+ src = GST_AUDIOFILTER (object);
- GST_DEBUG("gst_audiofilter_set_property");
+ GST_DEBUG ("gst_audiofilter_set_property");
switch (prop_id) {
default:
break;
}
static void
-gst_audiofilter_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_audiofilter_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstAudiofilter *src;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_AUDIOFILTER(object));
- src = GST_AUDIOFILTER(object);
+ g_return_if_fail (GST_IS_AUDIOFILTER (object));
+ src = GST_AUDIOFILTER (object);
switch (prop_id) {
default:
}
}
-void gst_audiofilter_class_add_pad_templates (
- GstAudiofilterClass *audiofilter_class, const GstCaps *caps)
+void
+gst_audiofilter_class_add_pad_templates (GstAudiofilterClass *
+ audiofilter_class, const GstCaps * caps)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (audiofilter_class);
- audiofilter_class->caps = gst_caps_copy(caps);
+ audiofilter_class->caps = gst_caps_copy (caps);
gst_element_class_add_pad_template (element_class,
- gst_pad_template_new("src", GST_PAD_SRC, GST_PAD_ALWAYS,
- gst_caps_copy(caps)));
+ gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
+ gst_caps_copy (caps)));
gst_element_class_add_pad_template (element_class,
- gst_pad_template_new("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
- gst_caps_copy(caps)));
+ gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
+ gst_caps_copy (caps)));
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "gstaudiofilter",
- "Audio filter parent class",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN
-)
-
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "gstaudiofilter",
+ "Audio filter parent class",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
#include <gst/gst.h>
-G_BEGIN_DECLS
-
-typedef struct _GstAudiofilter GstAudiofilter;
+G_BEGIN_DECLS typedef struct _GstAudiofilter GstAudiofilter;
typedef struct _GstAudiofilterClass GstAudiofilterClass;
-typedef void (*GstAudiofilterFilterFunc)(GstAudiofilter *filter,
- GstBuffer *outbuf, GstBuffer *inbuf);
-typedef void (*GstAudiofilterInplaceFilterFunc)(GstAudiofilter *filter,
- GstBuffer *buffer);
+typedef void (*GstAudiofilterFilterFunc) (GstAudiofilter * filter,
+ GstBuffer * outbuf, GstBuffer * inbuf);
+typedef void (*GstAudiofilterInplaceFilterFunc) (GstAudiofilter * filter,
+ GstBuffer * buffer);
-typedef void (*GstAudiofilterSetupFunc) (GstAudiofilter *filter);
+typedef void (*GstAudiofilterSetupFunc) (GstAudiofilter * filter);
#define GST_TYPE_AUDIOFILTER \
#define GST_IS_AUDIOFILTER_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIOFILTER))
-struct _GstAudiofilter {
+struct _GstAudiofilter
+{
GstElement element;
- GstPad *sinkpad,*srcpad;
+ GstPad *sinkpad, *srcpad;
/* audio state */
gboolean inited;
int bytes_per_sample;
};
-struct _GstAudiofilterClass {
+struct _GstAudiofilterClass
+{
GstElementClass parent_class;
GstCaps *caps;
GstAudiofilterFilterFunc filter;
};
-GType gst_audiofilter_get_type(void);
+GType gst_audiofilter_get_type (void);
-void gst_audiofilter_class_add_pad_templates (GstAudiofilterClass *audiofilterclass, const GstCaps *caps);
+void gst_audiofilter_class_add_pad_templates (GstAudiofilterClass *
+ audiofilterclass, const GstCaps * caps);
G_END_DECLS
-
#endif /* __GST_AUDIOFILTER_H__ */
-
#define GST_IS_AUDIOFILTER_TEMPLATE_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIOFILTER_TEMPLATE))
-struct _GstAudiofilterTemplate {
+struct _GstAudiofilterTemplate
+{
GstAudiofilter audiofilter;
};
-struct _GstAudiofilterTemplateClass {
+struct _GstAudiofilterTemplateClass
+{
GstAudiofilterClass parent_class;
};
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
/* FILL ME */
};
-static void gst_audiofilter_template_base_init (gpointer g_class);
-static void gst_audiofilter_template_class_init (gpointer g_class, gpointer class_data);
-static void gst_audiofilter_template_init (GTypeInstance *instance, gpointer g_class);
+static void gst_audiofilter_template_base_init (gpointer g_class);
+static void gst_audiofilter_template_class_init (gpointer g_class,
+ gpointer class_data);
+static void gst_audiofilter_template_init (GTypeInstance * instance,
+ gpointer g_class);
-static void gst_audiofilter_template_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void gst_audiofilter_template_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+static void gst_audiofilter_template_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+static void gst_audiofilter_template_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
-static void gst_audiofilter_template_setup (GstAudiofilter *audiofilter);
-static void gst_audiofilter_template_filter (GstAudiofilter *audiofilter, GstBuffer *outbuf, GstBuffer *inbuf);
-static void gst_audiofilter_template_filter_inplace (GstAudiofilter *audiofilter, GstBuffer *buf);
+static void gst_audiofilter_template_setup (GstAudiofilter * audiofilter);
+static void gst_audiofilter_template_filter (GstAudiofilter * audiofilter,
+ GstBuffer * outbuf, GstBuffer * inbuf);
+static void gst_audiofilter_template_filter_inplace (GstAudiofilter *
+ audiofilter, GstBuffer * buf);
GType
gst_audiofilter_template_get_type (void)
if (!audiofilter_template_type) {
static const GTypeInfo audiofilter_template_info = {
- sizeof(GstAudiofilterTemplateClass),
+ sizeof (GstAudiofilterTemplateClass),
gst_audiofilter_template_base_init,
NULL,
gst_audiofilter_template_class_init,
NULL,
gst_audiofilter_template_init,
- sizeof(GstAudiofilterTemplate),
+ sizeof (GstAudiofilterTemplate),
0,
NULL,
};
- audiofilter_template_type = g_type_register_static(GST_TYPE_AUDIOFILTER,
+ audiofilter_template_type = g_type_register_static (GST_TYPE_AUDIOFILTER,
"GstAudiofilterTemplate", &audiofilter_template_info, 0);
}
return audiofilter_template_type;
}
-static void gst_audiofilter_template_base_init (gpointer g_class)
+static void
+gst_audiofilter_template_base_init (gpointer g_class)
{
static GstElementDetails audiofilter_template_details = {
"Audio filter template",
GstAudiofilterTemplateClass *klass;
GstAudiofilterClass *audiofilter_class;
- klass = (GstAudiofilterTemplateClass *)g_class;
- gobject_class = (GObjectClass*)klass;
- gstelement_class = (GstElementClass*)klass;
- audiofilter_class = (GstAudiofilterClass *)g_class;
+ klass = (GstAudiofilterTemplateClass *) g_class;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
+ audiofilter_class = (GstAudiofilterClass *) g_class;
#if 0
- g_object_class_install_property(gobject_class, ARG_METHOD,
- g_param_spec_enum("method","method","method",
- GST_TYPE_AUDIOTEMPLATE_METHOD, GST_AUDIOTEMPLATE_METHOD_1,
- G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, ARG_METHOD,
+ g_param_spec_enum ("method", "method", "method",
+ GST_TYPE_AUDIOTEMPLATE_METHOD, GST_AUDIOTEMPLATE_METHOD_1,
+ G_PARAM_READWRITE));
#endif
gobject_class->set_property = gst_audiofilter_template_set_property;
audiofilter_class->setup = gst_audiofilter_template_setup;
audiofilter_class->filter = gst_audiofilter_template_filter;
audiofilter_class->filter_inplace = gst_audiofilter_template_filter_inplace;
-audiofilter_class->filter = NULL;
+ audiofilter_class->filter = NULL;
}
static void
-gst_audiofilter_template_init (GTypeInstance *instance, gpointer g_class)
+gst_audiofilter_template_init (GTypeInstance * instance, gpointer g_class)
{
//GstAudiofilterTemplate *audiofilter_template = GST_AUDIOFILTER_TEMPLATE (instance);
//GstAudiofilter *audiofilter = GST_AUDIOFILTER (instance);
}
static void
-gst_audiofilter_template_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_audiofilter_template_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstAudiofilterTemplate *src;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_AUDIOFILTER_TEMPLATE(object));
- src = GST_AUDIOFILTER_TEMPLATE(object);
+ g_return_if_fail (GST_IS_AUDIOFILTER_TEMPLATE (object));
+ src = GST_AUDIOFILTER_TEMPLATE (object);
- GST_DEBUG("gst_audiofilter_template_set_property");
+ GST_DEBUG ("gst_audiofilter_template_set_property");
switch (prop_id) {
default:
break;
}
static void
-gst_audiofilter_template_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_audiofilter_template_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
GstAudiofilterTemplate *src;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_AUDIOFILTER_TEMPLATE(object));
- src = GST_AUDIOFILTER_TEMPLATE(object);
+ g_return_if_fail (GST_IS_AUDIOFILTER_TEMPLATE (object));
+ src = GST_AUDIOFILTER_TEMPLATE (object);
switch (prop_id) {
default:
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
if (!gst_library_load ("gstaudiofilter"))
return FALSE;
GST_TYPE_AUDIOFILTER_TEMPLATE);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "gstaudiofilter_template",
- "Audio filter template",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "gstaudiofilter_template",
+ "Audio filter template",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
-static void
-gst_audiofilter_template_setup (GstAudiofilter *audiofilter)
+ static void gst_audiofilter_template_setup (GstAudiofilter * audiofilter)
{
GstAudiofilterTemplate *audiofilter_template;
* with a minimum of memory copies. */
static void
-gst_audiofilter_template_filter (GstAudiofilter *audiofilter,
- GstBuffer *outbuf, GstBuffer *inbuf)
+gst_audiofilter_template_filter (GstAudiofilter * audiofilter,
+ GstBuffer * outbuf, GstBuffer * inbuf)
{
GstAudiofilterTemplate *audiofilter_template;
/* do something interesting here. This simply copies the source
* to the destination. */
- memcpy (GST_BUFFER_DATA (outbuf), GST_BUFFER_DATA (inbuf),
- audiofilter->size);
+ memcpy (GST_BUFFER_DATA (outbuf), GST_BUFFER_DATA (inbuf), audiofilter->size);
}
static void
-gst_audiofilter_template_filter_inplace (GstAudiofilter *audiofilter,
- GstBuffer *buf)
+gst_audiofilter_template_filter_inplace (GstAudiofilter * audiofilter,
+ GstBuffer * buf)
{
GstAudiofilterTemplate *audiofilter_template;
* to the destination. */
}
-
#include "colorbalance.h"
#include "colorbalance-marshal.h"
-enum {
+enum
+{
VALUE_CHANGED,
LAST_SIGNAL
};
-static void gst_color_balance_class_init (GstColorBalanceClass *klass);
+static void gst_color_balance_class_init (GstColorBalanceClass * klass);
static guint gst_color_balance_signals[LAST_SIGNAL] = { 0 };
};
gst_color_balance_type = g_type_register_static (G_TYPE_INTERFACE,
- "GstColorBalance",
- &gst_color_balance_info, 0);
+ "GstColorBalance", &gst_color_balance_info, 0);
g_type_interface_add_prerequisite (gst_color_balance_type,
- GST_TYPE_IMPLEMENTS_INTERFACE);
+ GST_TYPE_IMPLEMENTS_INTERFACE);
}
return gst_color_balance_type;
}
static void
-gst_color_balance_class_init (GstColorBalanceClass *klass)
+gst_color_balance_class_init (GstColorBalanceClass * klass)
{
static gboolean initialized = FALSE;
-
+
if (!initialized) {
gst_color_balance_signals[VALUE_CHANGED] =
- g_signal_new ("value-changed",
- GST_TYPE_COLOR_BALANCE, G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstColorBalanceClass, value_changed),
- NULL, NULL,
- gst_color_balance_marshal_VOID__OBJECT_INT,
- G_TYPE_NONE, 2,
- GST_TYPE_COLOR_BALANCE_CHANNEL, G_TYPE_INT);
-
+ g_signal_new ("value-changed",
+ GST_TYPE_COLOR_BALANCE, G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstColorBalanceClass, value_changed),
+ NULL, NULL,
+ gst_color_balance_marshal_VOID__OBJECT_INT,
+ G_TYPE_NONE, 2, GST_TYPE_COLOR_BALANCE_CHANNEL, G_TYPE_INT);
+
initialized = TRUE;
}
klass->balance_type = GST_COLOR_BALANCE_SOFTWARE;
-
+
/* default virtual functions */
klass->list_channels = NULL;
klass->set_value = NULL;
}
const GList *
-gst_color_balance_list_channels (GstColorBalance *balance)
+gst_color_balance_list_channels (GstColorBalance * balance)
{
GstColorBalanceClass *klass = GST_COLOR_BALANCE_GET_CLASS (balance);
}
void
-gst_color_balance_set_value (GstColorBalance *balance,
- GstColorBalanceChannel *channel,
- gint value)
+gst_color_balance_set_value (GstColorBalance * balance,
+ GstColorBalanceChannel * channel, gint value)
{
GstColorBalanceClass *klass = GST_COLOR_BALANCE_GET_CLASS (balance);
}
gint
-gst_color_balance_get_value (GstColorBalance *balance,
- GstColorBalanceChannel *channel)
+gst_color_balance_get_value (GstColorBalance * balance,
+ GstColorBalanceChannel * channel)
{
GstColorBalanceClass *klass = GST_COLOR_BALANCE_GET_CLASS (balance);
}
void
-gst_color_balance_value_changed (GstColorBalance *balance,
- GstColorBalanceChannel *channel,
- gint value)
+gst_color_balance_value_changed (GstColorBalance * balance,
+ GstColorBalanceChannel * channel, gint value)
{
g_signal_emit (G_OBJECT (balance),
- gst_color_balance_signals[VALUE_CHANGED],
- 0, channel, value);
+ gst_color_balance_signals[VALUE_CHANGED], 0, channel, value);
g_signal_emit_by_name (G_OBJECT (channel), "value_changed", value);
}
#include <gst/colorbalance/colorbalance-enumtypes.h>
G_BEGIN_DECLS
-
#define GST_TYPE_COLOR_BALANCE \
(gst_color_balance_get_type ())
#define GST_COLOR_BALANCE(obj) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_COLOR_BALANCE))
#define GST_COLOR_BALANCE_GET_CLASS(inst) \
(G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_COLOR_BALANCE, GstColorBalanceClass))
-
#define GST_COLOR_BALANCE_TYPE(klass) (klass->balance_type)
-
typedef struct _GstColorBalance GstColorBalance;
-
+
typedef enum
{
GST_COLOR_BALANCE_HARDWARE,
GST_COLOR_BALANCE_SOFTWARE
} GstColorBalanceType;
-typedef struct _GstColorBalanceClass {
+typedef struct _GstColorBalanceClass
+{
GTypeInterface klass;
GstColorBalanceType balance_type;
-
+
/* virtual functions */
- const GList * (* list_channels) (GstColorBalance *balance);
+ const GList *(*list_channels) (GstColorBalance * balance);
- void (* set_value) (GstColorBalance *balance,
- GstColorBalanceChannel *channel,
- gint value);
- gint (* get_value) (GstColorBalance *balance,
- GstColorBalanceChannel *channel);
+ void (*set_value) (GstColorBalance * balance,
+ GstColorBalanceChannel * channel, gint value);
+ gint (*get_value) (GstColorBalance * balance,
+ GstColorBalanceChannel * channel);
/* signals */
- void (* value_changed) (GstColorBalance *balance,
- GstColorBalanceChannel *channel,
- gint value);
+ void (*value_changed) (GstColorBalance * balance,
+ GstColorBalanceChannel * channel, gint value);
gpointer _gst_reserved[GST_PADDING];
} GstColorBalanceClass;
-GType gst_color_balance_get_type (void);
+GType gst_color_balance_get_type (void);
/* virtual class function wrappers */
-const GList *
- gst_color_balance_list_channels (GstColorBalance *balance);
-void gst_color_balance_set_value (GstColorBalance *balance,
- GstColorBalanceChannel *channel,
- gint value);
-gint gst_color_balance_get_value (GstColorBalance *balance,
- GstColorBalanceChannel *channel);
+const GList *gst_color_balance_list_channels (GstColorBalance * balance);
+void gst_color_balance_set_value (GstColorBalance * balance,
+ GstColorBalanceChannel * channel, gint value);
+gint gst_color_balance_get_value (GstColorBalance * balance,
+ GstColorBalanceChannel * channel);
/* trigger signal */
-void gst_color_balance_value_changed (GstColorBalance *balance,
- GstColorBalanceChannel *channel,
- gint value);
+void gst_color_balance_value_changed (GstColorBalance * balance,
+ GstColorBalanceChannel * channel, gint value);
G_END_DECLS
-
#endif /* __GST_COLOR_BALANCE_H__ */
#include "colorbalancechannel.h"
-enum {
+enum
+{
/* FILL ME */
SIGNAL_VALUE_CHANGED,
LAST_SIGNAL
};
-static void gst_color_balance_channel_class_init (GstColorBalanceChannelClass *klass);
-static void gst_color_balance_channel_init (GstColorBalanceChannel *balance);
-static void gst_color_balance_channel_dispose (GObject *object);
+static void gst_color_balance_channel_class_init (GstColorBalanceChannelClass *
+ klass);
+static void gst_color_balance_channel_init (GstColorBalanceChannel * balance);
+static void gst_color_balance_channel_dispose (GObject * object);
static GObjectClass *parent_class = NULL;
static guint signals[LAST_SIGNAL] = { 0 };
gst_color_balance_channel_type =
g_type_register_static (G_TYPE_OBJECT,
- "GstColorBalanceChannel",
- &color_balance_channel_info, 0);
+ "GstColorBalanceChannel", &color_balance_channel_info, 0);
}
return gst_color_balance_channel_type;
}
static void
-gst_color_balance_channel_class_init (GstColorBalanceChannelClass *klass)
+gst_color_balance_channel_class_init (GstColorBalanceChannelClass * klass)
{
GObjectClass *object_klass = (GObjectClass *) klass;
parent_class = g_type_class_ref (G_TYPE_OBJECT);
signals[SIGNAL_VALUE_CHANGED] =
- g_signal_new ("value-changed", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstColorBalanceChannelClass,
- value_changed),
- NULL, NULL, g_cclosure_marshal_VOID__INT,
- G_TYPE_NONE, 1, G_TYPE_INT);
+ g_signal_new ("value-changed", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstColorBalanceChannelClass,
+ value_changed),
+ NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
object_klass->dispose = gst_color_balance_channel_dispose;
}
static void
-gst_color_balance_channel_init (GstColorBalanceChannel *channel)
+gst_color_balance_channel_init (GstColorBalanceChannel * channel)
{
channel->label = NULL;
channel->min_value = channel->max_value = 0;
}
static void
-gst_color_balance_channel_dispose (GObject *object)
+gst_color_balance_channel_dispose (GObject * object)
{
GstColorBalanceChannel *channel = GST_COLOR_BALANCE_CHANNEL (object);
if (channel->label)
g_free (channel->label);
-
+
channel->label = NULL;
if (parent_class->dispose)
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_TYPE_COLOR_BALANCE_CHANNEL \
(gst_color_balance_channel_get_type ())
#define GST_COLOR_BALANCE_CHANNEL(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_COLOR_BALANCE_CHANNEL))
#define GST_IS_COLOR_BALANCE_CHANNEL_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_COLOR_BALANCE_CHANNEL))
-
-typedef struct _GstColorBalanceChannel {
+ typedef struct _GstColorBalanceChannel
+{
GObject parent;
- gchar *label;
- gint min_value,
- max_value;
+ gchar *label;
+ gint min_value, max_value;
} GstColorBalanceChannel;
-typedef struct _GstColorBalanceChannelClass {
+typedef struct _GstColorBalanceChannelClass
+{
GObjectClass parent;
/* signals */
- void (* value_changed) (GstColorBalanceChannel *channel,
- gint value);
+ void (*value_changed) (GstColorBalanceChannel * channel, gint value);
gpointer _gst_reserved[GST_PADDING];
} GstColorBalanceChannelClass;
-GType gst_color_balance_channel_get_type (void);
+GType gst_color_balance_channel_get_type (void);
G_END_DECLS
-
#endif /* __GST_COLOR_BALANCE_CHANNEL_H__ */
#include <glib/gtypes.h>
G_BEGIN_DECLS
-
#if (HAVE_LRINT && HAVE_LRINTF)
-
- /* These defines enable functionality introduced with the 1999 ISO C
- ** standard. They must be defined before the inclusion of math.h to
- ** engage them. If optimisation is enabled, these functions will be
- ** inlined. With optimisation switched off, you have to link in the
- ** maths library using -lm.
- */
-
- #define _ISOC9X_SOURCE 1
- #define _ISOC99_SOURCE 1
-
- #define __USE_ISOC9X 1
- #define __USE_ISOC99 1
-
- #include <math.h>
-
- #define gst_cast_float(x) ((gint)lrintf(x))
- #define gst_cast_double(x) ((gint)lrint(x))
-
+ /* These defines enable functionality introduced with the 1999 ISO C
+ ** standard. They must be defined before the inclusion of math.h to
+ ** engage them. If optimisation is enabled, these functions will be
+ ** inlined. With optimisation switched off, you have to link in the
+ ** maths library using -lm.
+ */
+#define _ISOC9X_SOURCE 1
+#define _ISOC99_SOURCE 1
+#define __USE_ISOC9X 1
+#define __USE_ISOC99 1
+#include <math.h>
+#define gst_cast_float(x) ((gint)lrintf(x))
+#define gst_cast_double(x) ((gint)lrint(x))
#else
- /* use a standard c cast, but do rounding correctly */
- #define gst_cast_float(x) ((gint)floor((x)+0.5))
- #define gst_cast_double(x) ((gint)floor((x)+0.5))
-
+ /* use a standard c cast, but do rounding correctly */
+#define gst_cast_float(x) ((gint)floor((x)+0.5))
+#define gst_cast_double(x) ((gint)floor((x)+0.5))
#endif
-
inline static gfloat
-GFLOAT_SWAP_LE_BE(gfloat in)
+GFLOAT_SWAP_LE_BE (gfloat in)
{
gint32 swap;
gfloat out;
- memcpy(&swap, &in, 4);
+
+ memcpy (&swap, &in, 4);
swap = GUINT32_SWAP_LE_BE_CONSTANT (swap);
- memcpy(&out, &swap, 4);
+ memcpy (&out, &swap, 4);
return out;
}
inline static gdouble
-GDOUBLE_SWAP_LE_BE(gdouble in)
+GDOUBLE_SWAP_LE_BE (gdouble in)
{
gint64 swap;
gdouble out;
- memcpy(&swap, &in, 8);
+
+ memcpy (&swap, &in, 8);
swap = GUINT64_SWAP_LE_BE_CONSTANT (swap);
- memcpy(&out, &swap, 8);
+ memcpy (&out, &swap, 8);
return out;
}
#define GDOUBLE_FROM_BE(val) (GDOUBLE_TO_BE (val))
G_END_DECLS
-
#endif /* __FLOATCAST_H__ */
-
#error "GST_GCONF_DIR is not defined !"
#endif
-static GConfClient *_gst_gconf_client = NULL; /* GConf connection */
+static GConfClient *_gst_gconf_client = NULL; /* GConf connection */
/* internal functions */
/* go through a bin, finding the one pad that is unconnected in the given
* * direction, and return that pad */
static GstPad *
-gst_bin_find_unconnected_pad (GstBin *bin, GstPadDirection direction)
+gst_bin_find_unconnected_pad (GstBin * bin, GstPadDirection direction)
{
GstPad *pad = NULL;
GList *elements = NULL;
elements = (GList *) gst_bin_get_list (bin);
/* traverse all elements looking for unconnected pads */
- while (elements && pad == NULL)
- {
+ while (elements && pad == NULL) {
element = GST_ELEMENT (elements->data);
pads = gst_element_get_pad_list (element);
- while (pads)
- {
+ while (pads) {
/* check if the direction matches */
- if (GST_PAD_DIRECTION (GST_PAD (pads->data)) == direction)
- {
- if (GST_PAD_PEER (GST_PAD (pads->data)) == NULL)
- {
- /* found it ! */
+ if (GST_PAD_DIRECTION (GST_PAD (pads->data)) == direction) {
+ if (GST_PAD_PEER (GST_PAD (pads->data)) == NULL) {
+ /* found it ! */
pad = GST_PAD (pads->data);
}
}
- if (pad) break; /* found one already */
+ if (pad)
+ break; /* found one already */
pads = g_list_next (pads);
}
elements = g_list_next (elements);
* Returns: a #gchar string containing @key's value.
*/
gchar *
-gst_gconf_get_string (const gchar *key)
+gst_gconf_get_string (const gchar * key)
{
GError *error = NULL;
gchar *value = NULL;
value = gconf_client_get_string (gst_gconf_get_client (), full_key, &error);
g_free (full_key);
- if (error)
- {
+ if (error) {
g_print ("gst_gconf_get_string: error: %s\n", error->message);
g_error_free (error);
}
* Set GConf key @key to string value @value.
*/
void
-gst_gconf_set_string (const gchar *key, const gchar *value)
+gst_gconf_set_string (const gchar * key, const gchar * value)
{
GError *error = NULL;
gchar *full_key = g_strdup_printf ("%s/%s", GST_GCONF_DIR, key);
gconf_client_set_string (gst_gconf_get_client (), full_key, value, &error);
- if (error)
- {
+ if (error) {
g_print ("gst_gconf_set_string: error: %s\n", error->message);
g_error_free (error);
}
* Returns: a #GstElement containing the rendered bin.
*/
GstElement *
-gst_gconf_render_bin_from_description (const gchar *description)
+gst_gconf_render_bin_from_description (const gchar * description)
{
GstElement *bin = NULL;
GstPad *pad = NULL;
desc = g_strdup_printf ("bin.( %s )", description);
bin = GST_ELEMENT (gst_parse_launch (desc, &error));
g_free (desc);
- if (error)
- {
+ if (error) {
g_print ("DEBUG: gstgconf: error parsing pipeline %s\n%s\n",
- description, error->message);
+ description, error->message);
g_error_free (error);
return NULL;
}
/* find pads and ghost them if necessary */
- if ((pad = gst_bin_find_unconnected_pad (GST_BIN (bin), GST_PAD_SRC))){
+ if ((pad = gst_bin_find_unconnected_pad (GST_BIN (bin), GST_PAD_SRC))) {
gst_element_add_ghost_pad (bin, pad, "src");
}
- if ((pad = gst_bin_find_unconnected_pad (GST_BIN (bin), GST_PAD_SINK))){
+ if ((pad = gst_bin_find_unconnected_pad (GST_BIN (bin), GST_PAD_SINK))) {
gst_element_add_ghost_pad (bin, pad, "sink");
}
return bin;
* Returns: a #GstElement containing the rendered bin.
*/
GstElement *
-gst_gconf_render_bin_from_key (const gchar *key)
+gst_gconf_render_bin_from_key (const gchar * key)
{
GstElement *bin = NULL;
gchar *value;
-
+
value = gst_gconf_get_string (key);
if (value)
bin = gst_gconf_render_bin_from_description (value);
gst_gconf_get_default_audio_sink (void)
{
GstElement *ret = gst_gconf_render_bin_from_key ("default/audiosink");
-
+
if (!ret) {
ret = gst_element_factory_make ("osssink", NULL);
-
+
if (!ret)
g_warning ("No GConf default audio sink key and osssink doesn't work");
else
gst_gconf_get_default_video_sink (void)
{
GstElement *ret = gst_gconf_render_bin_from_key ("default/videosink");
-
+
if (!ret) {
ret = gst_element_factory_make ("ximagesink", NULL);
-
+
if (!ret)
g_warning ("No GConf default video sink key and ximagesink doesn't work");
else
gst_gconf_get_default_audio_src (void)
{
GstElement *ret = gst_gconf_render_bin_from_key ("default/audiosrc");
-
+
if (!ret) {
ret = gst_element_factory_make ("osssrc", NULL);
-
+
if (!ret)
g_warning ("No GConf default audio src key and osssrc doesn't work");
else
gst_gconf_get_default_video_src (void)
{
GstElement *ret = gst_gconf_render_bin_from_key ("default/videosrc");
-
+
if (!ret) {
ret = gst_element_factory_make ("videotestsrc", NULL);
-
+
if (!ret)
g_warning ("No GConf default video src key and videotestrc doesn't work");
else
gst_gconf_get_default_visualization_element (void)
{
GstElement *ret = gst_gconf_render_bin_from_key ("default/visualization");
-
+
if (!ret) {
ret = gst_element_factory_make ("goom", NULL);
-
+
if (!ret)
- g_warning ("No GConf default visualization plugin key and goom doesn't work");
+ g_warning
+ ("No GConf default visualization plugin key and goom doesn't work");
else
g_print ("GConf visualization plugin not found, using goom\n");
}
return ret;
}
-
#include <gst/gst.h>
#include <gconf/gconf-client.h>
-gchar * gst_gconf_get_string (const gchar *key);
-void gst_gconf_set_string (const gchar *key,
- const gchar *value);
+gchar *gst_gconf_get_string (const gchar * key);
+void gst_gconf_set_string (const gchar * key, const gchar * value);
-GstElement * gst_gconf_render_bin_from_key (const gchar *key);
-GstElement * gst_gconf_render_bin_from_description (const gchar *description);
+GstElement *gst_gconf_render_bin_from_key (const gchar * key);
+GstElement *gst_gconf_render_bin_from_description (const gchar * description);
-GstElement * gst_gconf_get_default_video_sink (void);
-GstElement * gst_gconf_get_default_audio_sink (void);
-GstElement * gst_gconf_get_default_video_src (void);
-GstElement * gst_gconf_get_default_audio_src (void);
-GstElement * gst_gconf_get_default_visualization_element (void);
+GstElement *gst_gconf_get_default_video_sink (void);
+GstElement *gst_gconf_get_default_audio_sink (void);
+GstElement *gst_gconf_get_default_video_src (void);
+GstElement *gst_gconf_get_default_audio_src (void);
+GstElement *gst_gconf_get_default_visualization_element (void);
#endif /* GST_GCONF_H */
int
main (int argc, char *argv[])
{
- printf ("Default video sink : %s\n",
- gst_gconf_get_string ("default/videosink"));
- printf ("Default audio sink : %s\n",
- gst_gconf_get_string ("default/audiosink"));
- printf ("Default video src : %s\n",
- gst_gconf_get_string ("default/videosrc"));
- printf ("Default audio src : %s\n",
- gst_gconf_get_string ("default/audiosrc"));
+ printf ("Default video sink : %s\n",
+ gst_gconf_get_string ("default/videosink"));
+ printf ("Default audio sink : %s\n",
+ gst_gconf_get_string ("default/audiosink"));
+ printf ("Default video src : %s\n",
+ gst_gconf_get_string ("default/videosrc"));
+ printf ("Default audio src : %s\n",
+ gst_gconf_get_string ("default/audiosrc"));
return 0;
}
#ifndef __GST_I18N_PLUGIN_H__
#define __GST_I18N_PLUGIN_H__
-#include <locale.h> /* some people need it and some people don't */
-#include "gettext.h" /* included with gettext distribution and copied */
+#include <locale.h> /* some people need it and some people don't */
+#include "gettext.h" /* included with gettext distribution and copied */
#ifndef GETTEXT_PACKAGE
#error You must define GETTEXT_PACKAGE before including this header.
typedef long INT32; /* must be at least 32 bits */
-extern void gst_idct_int_idct();
+extern void gst_idct_int_idct ();
extern void gst_idct_init_fast_int_idct (void);
extern void gst_idct_fast_int_idct (short *block);
extern void gst_idct_sse_idct (short *block);
#endif /* HAVE_LIBMMX */
-extern void gst_idct_init_float_idct(void);
+extern void gst_idct_init_float_idct (void);
extern void gst_idct_float_idct (short *block);
-
/* this code assumes >> to be a two's-complement arithmetic */
/* right shift: (-2)>>1 == -1 , (-3)>>1 == -2 */
-#define W1 2841 /* 2048*sqrt(2)*cos(1*pi/16) */
-#define W2 2676 /* 2048*sqrt(2)*cos(2*pi/16) */
-#define W3 2408 /* 2048*sqrt(2)*cos(3*pi/16) */
-#define W5 1609 /* 2048*sqrt(2)*cos(5*pi/16) */
-#define W6 1108 /* 2048*sqrt(2)*cos(6*pi/16) */
-#define W7 565 /* 2048*sqrt(2)*cos(7*pi/16) */
+#define W1 2841 /* 2048*sqrt(2)*cos(1*pi/16) */
+#define W2 2676 /* 2048*sqrt(2)*cos(2*pi/16) */
+#define W3 2408 /* 2048*sqrt(2)*cos(3*pi/16) */
+#define W5 1609 /* 2048*sqrt(2)*cos(5*pi/16) */
+#define W6 1108 /* 2048*sqrt(2)*cos(6*pi/16) */
+#define W7 565 /* 2048*sqrt(2)*cos(7*pi/16) */
#include "dct.h"
/* private data */
-static short iclip[1024]; /* clipping table */
+static short iclip[1024]; /* clipping table */
static short *iclp;
/* private prototypes */
* c[1..7] = 128*sqrt(2)
*/
-static void idctrow(blk)
-short *blk;
+static void
+idctrow (blk)
+ short *blk;
{
int x0, x1, x2, x3, x4, x5, x6, x7, x8;
/* shortcut */
- if (!((x1 = blk[4]<<11) | (x2 = blk[6]) | (x3 = blk[2]) |
- (x4 = blk[1]) | (x5 = blk[7]) | (x6 = blk[5]) | (x7 = blk[3])))
- {
- blk[0]=blk[1]=blk[2]=blk[3]=blk[4]=blk[5]=blk[6]=blk[7]=blk[0]<<3;
+ if (!((x1 = blk[4] << 11) | (x2 = blk[6]) | (x3 = blk[2]) |
+ (x4 = blk[1]) | (x5 = blk[7]) | (x6 = blk[5]) | (x7 = blk[3]))) {
+ blk[0] = blk[1] = blk[2] = blk[3] = blk[4] = blk[5] = blk[6] = blk[7] =
+ blk[0] << 3;
return;
}
- x0 = (blk[0]<<11) + 128; /* for proper rounding in the fourth stage */
+ x0 = (blk[0] << 11) + 128; /* for proper rounding in the fourth stage */
/* first stage */
- x8 = W7*(x4+x5);
- x4 = x8 + (W1-W7)*x4;
- x5 = x8 - (W1+W7)*x5;
- x8 = W3*(x6+x7);
- x6 = x8 - (W3-W5)*x6;
- x7 = x8 - (W3+W5)*x7;
-
+ x8 = W7 * (x4 + x5);
+ x4 = x8 + (W1 - W7) * x4;
+ x5 = x8 - (W1 + W7) * x5;
+ x8 = W3 * (x6 + x7);
+ x6 = x8 - (W3 - W5) * x6;
+ x7 = x8 - (W3 + W5) * x7;
+
/* second stage */
x8 = x0 + x1;
x0 -= x1;
- x1 = W6*(x3+x2);
- x2 = x1 - (W2+W6)*x2;
- x3 = x1 + (W2-W6)*x3;
+ x1 = W6 * (x3 + x2);
+ x2 = x1 - (W2 + W6) * x2;
+ x3 = x1 + (W2 - W6) * x3;
x1 = x4 + x6;
x4 -= x6;
x6 = x5 + x7;
x5 -= x7;
-
+
/* third stage */
x7 = x8 + x3;
x8 -= x3;
x3 = x0 + x2;
x0 -= x2;
- x2 = (181*(x4+x5)+128)>>8;
- x4 = (181*(x4-x5)+128)>>8;
-
+ x2 = (181 * (x4 + x5) + 128) >> 8;
+ x4 = (181 * (x4 - x5) + 128) >> 8;
+
/* fourth stage */
- blk[0] = (x7+x1)>>8;
- blk[1] = (x3+x2)>>8;
- blk[2] = (x0+x4)>>8;
- blk[3] = (x8+x6)>>8;
- blk[4] = (x8-x6)>>8;
- blk[5] = (x0-x4)>>8;
- blk[6] = (x3-x2)>>8;
- blk[7] = (x7-x1)>>8;
+ blk[0] = (x7 + x1) >> 8;
+ blk[1] = (x3 + x2) >> 8;
+ blk[2] = (x0 + x4) >> 8;
+ blk[3] = (x8 + x6) >> 8;
+ blk[4] = (x8 - x6) >> 8;
+ blk[5] = (x0 - x4) >> 8;
+ blk[6] = (x3 - x2) >> 8;
+ blk[7] = (x7 - x1) >> 8;
}
/* column (vertical) IDCT
* where: c[0] = 1/1024
* c[1..7] = (1/1024)*sqrt(2)
*/
-static void idctcol(blk)
-short *blk;
+static void
+idctcol (blk)
+ short *blk;
{
int x0, x1, x2, x3, x4, x5, x6, x7, x8;
/* shortcut */
- if (!((x1 = (blk[8*4]<<8)) | (x2 = blk[8*6]) | (x3 = blk[8*2]) |
- (x4 = blk[8*1]) | (x5 = blk[8*7]) | (x6 = blk[8*5]) | (x7 = blk[8*3])))
- {
- blk[8*0]=blk[8*1]=blk[8*2]=blk[8*3]=blk[8*4]=blk[8*5]=blk[8*6]=blk[8*7]=
- iclp[(blk[8*0]+32)>>6];
+ if (!((x1 = (blk[8 * 4] << 8)) | (x2 = blk[8 * 6]) | (x3 = blk[8 * 2]) |
+ (x4 = blk[8 * 1]) | (x5 = blk[8 * 7]) | (x6 = blk[8 * 5]) | (x7 =
+ blk[8 * 3]))) {
+ blk[8 * 0] = blk[8 * 1] = blk[8 * 2] = blk[8 * 3] = blk[8 * 4] =
+ blk[8 * 5] = blk[8 * 6] = blk[8 * 7] = iclp[(blk[8 * 0] + 32) >> 6];
return;
}
- x0 = (blk[8*0]<<8) + 8192;
+ x0 = (blk[8 * 0] << 8) + 8192;
/* first stage */
- x8 = W7*(x4+x5) + 4;
- x4 = (x8+(W1-W7)*x4)>>3;
- x5 = (x8-(W1+W7)*x5)>>3;
- x8 = W3*(x6+x7) + 4;
- x6 = (x8-(W3-W5)*x6)>>3;
- x7 = (x8-(W3+W5)*x7)>>3;
-
+ x8 = W7 * (x4 + x5) + 4;
+ x4 = (x8 + (W1 - W7) * x4) >> 3;
+ x5 = (x8 - (W1 + W7) * x5) >> 3;
+ x8 = W3 * (x6 + x7) + 4;
+ x6 = (x8 - (W3 - W5) * x6) >> 3;
+ x7 = (x8 - (W3 + W5) * x7) >> 3;
+
/* second stage */
x8 = x0 + x1;
x0 -= x1;
- x1 = W6*(x3+x2) + 4;
- x2 = (x1-(W2+W6)*x2)>>3;
- x3 = (x1+(W2-W6)*x3)>>3;
+ x1 = W6 * (x3 + x2) + 4;
+ x2 = (x1 - (W2 + W6) * x2) >> 3;
+ x3 = (x1 + (W2 - W6) * x3) >> 3;
x1 = x4 + x6;
x4 -= x6;
x6 = x5 + x7;
x5 -= x7;
-
+
/* third stage */
x7 = x8 + x3;
x8 -= x3;
x3 = x0 + x2;
x0 -= x2;
- x2 = (181*(x4+x5)+128)>>8;
- x4 = (181*(x4-x5)+128)>>8;
-
+ x2 = (181 * (x4 + x5) + 128) >> 8;
+ x4 = (181 * (x4 - x5) + 128) >> 8;
+
/* fourth stage */
- blk[8*0] = iclp[(x7+x1)>>14];
- blk[8*1] = iclp[(x3+x2)>>14];
- blk[8*2] = iclp[(x0+x4)>>14];
- blk[8*3] = iclp[(x8+x6)>>14];
- blk[8*4] = iclp[(x8-x6)>>14];
- blk[8*5] = iclp[(x0-x4)>>14];
- blk[8*6] = iclp[(x3-x2)>>14];
- blk[8*7] = iclp[(x7-x1)>>14];
+ blk[8 * 0] = iclp[(x7 + x1) >> 14];
+ blk[8 * 1] = iclp[(x3 + x2) >> 14];
+ blk[8 * 2] = iclp[(x0 + x4) >> 14];
+ blk[8 * 3] = iclp[(x8 + x6) >> 14];
+ blk[8 * 4] = iclp[(x8 - x6) >> 14];
+ blk[8 * 5] = iclp[(x0 - x4) >> 14];
+ blk[8 * 6] = iclp[(x3 - x2) >> 14];
+ blk[8 * 7] = iclp[(x7 - x1) >> 14];
}
/* two dimensional inverse discrete cosine transform */
-void gst_idct_fast_int_idct(block)
-short *block;
+void
+gst_idct_fast_int_idct (block)
+ short *block;
{
int i;
- for (i=0; i<8; i++)
- idctrow(block+8*i);
+ for (i = 0; i < 8; i++)
+ idctrow (block + 8 * i);
- for (i=0; i<8; i++)
- idctcol(block+i);
+ for (i = 0; i < 8; i++)
+ idctcol (block + i);
}
-void gst_idct_init_fast_int_idct()
+void
+gst_idct_init_fast_int_idct ()
{
int i;
- iclp = iclip+512;
- for (i= -512; i<512; i++)
- iclp[i] = (i<-256) ? -256 : ((i>255) ? 255 : i);
+ iclp = iclip + 512;
+ for (i = -512; i < 512; i++)
+ iclp[i] = (i < -256) ? -256 : ((i > 255) ? 255 : i);
}
/* initialize DCT coefficient matrix */
-void gst_idct_init_float_idct()
+void
+gst_idct_init_float_idct ()
{
int freq, time;
double scale;
- for (freq=0; freq < 8; freq++)
- {
- scale = (freq == 0) ? sqrt(0.125) : 0.5;
- for (time=0; time<8; time++)
- gst_idct_float_c[freq][time] = scale*cos((PI/8.0)*freq*(time + 0.5));
+ for (freq = 0; freq < 8; freq++) {
+ scale = (freq == 0) ? sqrt (0.125) : 0.5;
+ for (time = 0; time < 8; time++)
+ gst_idct_float_c[freq][time] =
+ scale * cos ((PI / 8.0) * freq * (time + 0.5));
}
}
/* perform IDCT matrix multiply for 8x8 coefficient block */
-void gst_idct_float_idct(block)
-short *block;
+void
+gst_idct_float_idct (block)
+ short *block;
{
int i, j, k, v;
double partial_product;
double tmp[64];
- for (i=0; i<8; i++)
- for (j=0; j<8; j++)
- {
+ for (i = 0; i < 8; i++)
+ for (j = 0; j < 8; j++) {
partial_product = 0.0;
- for (k=0; k<8; k++)
- partial_product+= gst_idct_float_c[k][j]*block[8*i+k];
+ for (k = 0; k < 8; k++)
+ partial_product += gst_idct_float_c[k][j] * block[8 * i + k];
- tmp[8*i+j] = partial_product;
+ tmp[8 * i + j] = partial_product;
}
/* Transpose operation is integrated into address mapping by switching
loop order of i and j */
- for (j=0; j<8; j++)
- for (i=0; i<8; i++)
- {
+ for (j = 0; j < 8; j++)
+ for (i = 0; i < 8; i++) {
partial_product = 0.0;
- for (k=0; k<8; k++)
- partial_product+= gst_idct_float_c[k][i]*tmp[8*k+j];
+ for (k = 0; k < 8; k++)
+ partial_product += gst_idct_float_c[k][i] * tmp[8 * k + j];
- v = (int) floor(partial_product+0.5);
- block[8*i+j] = (v<-256) ? -256 : ((v>255) ? 255 : v);
+ v = (int) floor (partial_product + 0.5);
+ block[8 * i + j] = (v < -256) ? -256 : ((v > 255) ? 255 : v);
}
}
#include <gst/idct/idct.h>
#include "dct.h"
-static void gst_idct_int_sparse_idct(short *data);
+static void gst_idct_int_sparse_idct (short *data);
-GstIDCT *gst_idct_new(GstIDCTMethod method)
+GstIDCT *
+gst_idct_new (GstIDCTMethod method)
{
- GstIDCT *new = g_malloc(sizeof(GstIDCT));
+ GstIDCT *new = g_malloc (sizeof (GstIDCT));
new->need_transpose = FALSE;
if (method == GST_IDCT_DEFAULT) {
#ifdef HAVE_LIBMMX
- if (gst_cpu_get_flags() & GST_CPU_FLAG_MMX) {
+ if (gst_cpu_get_flags () & GST_CPU_FLAG_MMX) {
method = GST_IDCT_MMX;
}
/* disabled for now
- if (gst_cpu_get_flags() & GST_CPU_FLAG_SSE) {
- method = GST_IDCT_SSE;
- }
- */
+ if (gst_cpu_get_flags() & GST_CPU_FLAG_SSE) {
+ method = GST_IDCT_SSE;
+ }
+ */
else
#endif /* HAVE_LIBMMX */
{
new->convert_sparse = gst_idct_int_sparse_idct;
switch (method) {
- case GST_IDCT_FAST_INT:
- GST_INFO ( "using fast_int_idct");
- gst_idct_init_fast_int_idct();
- new->convert = gst_idct_fast_int_idct;
- break;
- case GST_IDCT_INT:
- GST_INFO ( "using int_idct");
- new->convert = gst_idct_int_idct;
- break;
- case GST_IDCT_FLOAT:
- GST_INFO ( "using float_idct");
- gst_idct_init_float_idct();
- new->convert = gst_idct_float_idct;
- break;
+ case GST_IDCT_FAST_INT:
+ GST_INFO ("using fast_int_idct");
+ gst_idct_init_fast_int_idct ();
+ new->convert = gst_idct_fast_int_idct;
+ break;
+ case GST_IDCT_INT:
+ GST_INFO ("using int_idct");
+ new->convert = gst_idct_int_idct;
+ break;
+ case GST_IDCT_FLOAT:
+ GST_INFO ("using float_idct");
+ gst_idct_init_float_idct ();
+ new->convert = gst_idct_float_idct;
+ break;
#ifdef HAVE_LIBMMX
- case GST_IDCT_MMX:
- GST_INFO ( "using MMX_idct");
- new->convert = gst_idct_mmx_idct;
- new->need_transpose = TRUE;
- break;
- case GST_IDCT_MMX32:
- GST_INFO ( "using MMX32_idct");
- new->convert = gst_idct_mmx32_idct;
- new->need_transpose = TRUE;
- break;
- case GST_IDCT_SSE:
- GST_INFO ( "using SSE_idct");
- new->convert = gst_idct_sse_idct;
- new->need_transpose = TRUE;
- break;
+ case GST_IDCT_MMX:
+ GST_INFO ("using MMX_idct");
+ new->convert = gst_idct_mmx_idct;
+ new->need_transpose = TRUE;
+ break;
+ case GST_IDCT_MMX32:
+ GST_INFO ("using MMX32_idct");
+ new->convert = gst_idct_mmx32_idct;
+ new->need_transpose = TRUE;
+ break;
+ case GST_IDCT_SSE:
+ GST_INFO ("using SSE_idct");
+ new->convert = gst_idct_sse_idct;
+ new->need_transpose = TRUE;
+ break;
#endif /* HAVE_LIBMMX */
- default:
- GST_INFO ( "method not supported");
- g_free(new);
- return NULL;
+ default:
+ GST_INFO ("method not supported");
+ g_free (new);
+ return NULL;
}
return new;
}
-static void gst_idct_int_sparse_idct(short *data)
+static void
+gst_idct_int_sparse_idct (short *data)
{
short val;
- gint32 v, *dp = (guint32 *)data;
+ gint32 v, *dp = (guint32 *) data;
v = *data;
val += (8 >> 1);
val /= 8;
val = -val;
- }
- else {
+ } else {
val = (v + (8 >> 1)) / 8;
}
- v = (( val & 0xffff) | (val << 16));
-
- dp[0] = v; dp[1] = v; dp[2] = v; dp[3] = v;
- dp[4] = v; dp[5] = v; dp[6] = v; dp[7] = v;
- dp[8] = v; dp[9] = v; dp[10] = v; dp[11] = v;
- dp[12] = v; dp[13] = v; dp[14] = v; dp[15] = v;
- dp[16] = v; dp[17] = v; dp[18] = v; dp[19] = v;
- dp[20] = v; dp[21] = v; dp[22] = v; dp[23] = v;
- dp[24] = v; dp[25] = v; dp[26] = v; dp[27] = v;
- dp[28] = v; dp[29] = v; dp[30] = v; dp[31] = v;
+ v = ((val & 0xffff) | (val << 16));
+
+ dp[0] = v;
+ dp[1] = v;
+ dp[2] = v;
+ dp[3] = v;
+ dp[4] = v;
+ dp[5] = v;
+ dp[6] = v;
+ dp[7] = v;
+ dp[8] = v;
+ dp[9] = v;
+ dp[10] = v;
+ dp[11] = v;
+ dp[12] = v;
+ dp[13] = v;
+ dp[14] = v;
+ dp[15] = v;
+ dp[16] = v;
+ dp[17] = v;
+ dp[18] = v;
+ dp[19] = v;
+ dp[20] = v;
+ dp[21] = v;
+ dp[22] = v;
+ dp[23] = v;
+ dp[24] = v;
+ dp[25] = v;
+ dp[26] = v;
+ dp[27] = v;
+ dp[28] = v;
+ dp[29] = v;
+ dp[30] = v;
+ dp[31] = v;
}
-void gst_idct_destroy(GstIDCT *idct)
+void
+gst_idct_destroy (GstIDCT * idct)
{
- g_return_if_fail(idct != NULL);
+ g_return_if_fail (idct != NULL);
- g_free(idct);
+ g_free (idct);
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "gstidct",
- "Accelerated IDCT routines",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "gstidct",
+ "Accelerated IDCT routines",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
#include <glib.h>
-typedef enum {
- GST_IDCT_DEFAULT,
- GST_IDCT_INT,
- GST_IDCT_FAST_INT,
- GST_IDCT_FLOAT,
- GST_IDCT_MMX,
+typedef enum
+{
+ GST_IDCT_DEFAULT,
+ GST_IDCT_INT,
+ GST_IDCT_FAST_INT,
+ GST_IDCT_FLOAT,
+ GST_IDCT_MMX,
GST_IDCT_MMX32,
GST_IDCT_SSE,
} GstIDCTMethod;
typedef struct _GstIDCT GstIDCT;
-typedef void (*GstIDCTFunction) (gshort *block);
+typedef void (*GstIDCTFunction) (gshort * block);
#define GST_IDCT_TRANSPOSE(idct) ((idct)->need_transpose)
-struct _GstIDCT {
+struct _GstIDCT
+{
/* private */
GstIDCTFunction convert;
GstIDCTFunction convert_sparse;
};
-GstIDCT *gst_idct_new(GstIDCTMethod method);
+GstIDCT *gst_idct_new (GstIDCTMethod method);
+
#define gst_idct_convert(idct, blocks) (idct)->convert((blocks))
#define gst_idct_convert_sparse(idct, blocks) (idct)->convert_sparse((blocks))
-void gst_idct_destroy(GstIDCT *idct);
+void gst_idct_destroy (GstIDCT * idct);
#endif /* __GST_IDCT_H__ */
void usage (char *msg);
long ieeerand (long L, long H);
-void dct_init(void);
-void ref_fdct(DCTELEM block[8][8]);
-void ref_idct(DCTELEM block[8][8]);
+void dct_init (void);
+void ref_fdct (DCTELEM block[8][8]);
+void ref_idct (DCTELEM block[8][8]);
/* error stat accumulators -- assume initialized to 0 */
int maxerr[DCTSIZE2];
-char * meets (double val, double limit)
+char *
+meets (double val, double limit)
{
- return ((fabs(val) <= limit) ? "meets" : "FAILS");
+ return ((fabs (val) <= limit) ? "meets" : "FAILS");
}
int
-main(int argc, char **argv)
+main (int argc, char **argv)
{
long minpix, maxpix, sign;
long curiter, niters;
int i, j;
double max, total;
int method;
- DCTELEM block[DCTSIZE2]; /* random source data */
- DCTELEM refcoefs[DCTSIZE2]; /* coefs from reference FDCT */
- DCTELEM refout[DCTSIZE2]; /* output from reference IDCT */
- DCTELEM testout[DCTSIZE2]; /* output from test IDCT */
- GstIDCT *idct;
- guint64 tscstart, tscmin = ~0, tscmax = 0;
- guint64 tscstop;
+ DCTELEM block[DCTSIZE2]; /* random source data */
+ DCTELEM refcoefs[DCTSIZE2]; /* coefs from reference FDCT */
+ DCTELEM refout[DCTSIZE2]; /* output from reference IDCT */
+ DCTELEM testout[DCTSIZE2]; /* output from test IDCT */
+ GstIDCT *idct;
+ guint64 tscstart, tscmin = ~0, tscmax = 0;
+ guint64 tscstop;
/* Argument parsing --- not very bulletproof at all */
- if (argc != 6) usage(NULL);
+ if (argc != 6)
+ usage (NULL);
- method = atoi(argv[1]);
- minpix = atoi(argv[2]);
- maxpix = atoi(argv[3]);
- sign = atoi(argv[4]);
- niters = atol(argv[5]);
+ method = atoi (argv[1]);
+ minpix = atoi (argv[2]);
+ maxpix = atoi (argv[3]);
+ sign = atoi (argv[4]);
+ niters = atol (argv[5]);
- gst_library_load("gstidct");
+ gst_library_load ("gstidct");
- idct = gst_idct_new(method);
+ idct = gst_idct_new (method);
if (idct == 0) {
- printf("method not available\n\n\n");
+ printf ("method not available\n\n\n");
return 0;
}
- dct_init();
+ dct_init ();
/* Loop once per generated random-data block */
/* generate a pseudo-random block of data */
for (i = 0; i < DCTSIZE2; i++)
- block[i] = (DCTELEM) (ieeerand(-minpix,maxpix) * sign);
+ block[i] = (DCTELEM) (ieeerand (-minpix, maxpix) * sign);
/* perform reference FDCT */
- memcpy(refcoefs, block, sizeof(DCTELEM)*DCTSIZE2);
- ref_fdct((DCTELEM **) &refcoefs);
+ memcpy (refcoefs, block, sizeof (DCTELEM) * DCTSIZE2);
+ ref_fdct ((DCTELEM **) & refcoefs);
/* clip */
for (i = 0; i < DCTSIZE2; i++) {
- if (refcoefs[i] < -2048) refcoefs[i] = -2048;
- else if (refcoefs[i] > 2047) refcoefs[i] = 2047;
+ if (refcoefs[i] < -2048)
+ refcoefs[i] = -2048;
+ else if (refcoefs[i] > 2047)
+ refcoefs[i] = 2047;
}
/* perform reference IDCT */
- memcpy(refout, refcoefs, sizeof(DCTELEM)*DCTSIZE2);
- ref_idct(refout);
+ memcpy (refout, refcoefs, sizeof (DCTELEM) * DCTSIZE2);
+ ref_idct (refout);
/* clip */
for (i = 0; i < DCTSIZE2; i++) {
- if (refout[i] < -256) refout[i] = -256;
- else if (refout[i] > 255) refout[i] = 255;
+ if (refout[i] < -256)
+ refout[i] = -256;
+ else if (refout[i] > 255)
+ refout[i] = 255;
}
/* perform test IDCT */
- if (GST_IDCT_TRANSPOSE(idct)) {
+ if (GST_IDCT_TRANSPOSE (idct)) {
for (j = 0; j < DCTSIZE; j++) {
- for (i = 0; i < DCTSIZE; i++) {
- testout[i*DCTSIZE+j] = refcoefs[j*DCTSIZE+i];
- }
- }
- }
- else {
- memcpy(testout, refcoefs, sizeof(DCTELEM)*DCTSIZE2);
- }
-
- gst_trace_read_tsc(&tscstart);
- gst_idct_convert(idct, testout);
- gst_trace_read_tsc(&tscstop);
- /*printf("time %llu, %llu %lld\n", tscstart, tscstop, tscstop-tscstart); */
- if (tscstop - tscstart < tscmin) tscmin = tscstop-tscstart;
- if (tscstop - tscstart > tscmax) tscmax = tscstop-tscstart;
+ for (i = 0; i < DCTSIZE; i++) {
+ testout[i * DCTSIZE + j] = refcoefs[j * DCTSIZE + i];
+ }
+ }
+ } else {
+ memcpy (testout, refcoefs, sizeof (DCTELEM) * DCTSIZE2);
+ }
+
+ gst_trace_read_tsc (&tscstart);
+ gst_idct_convert (idct, testout);
+ gst_trace_read_tsc (&tscstop);
+ /*printf("time %llu, %llu %lld\n", tscstart, tscstop, tscstop-tscstart); */
+ if (tscstop - tscstart < tscmin)
+ tscmin = tscstop - tscstart;
+ if (tscstop - tscstart > tscmax)
+ tscmax = tscstop - tscstart;
/* clip */
for (i = 0; i < DCTSIZE2; i++) {
- if (testout[i] < -256) testout[i] = -256;
- else if (testout[i] > 255) testout[i] = 255;
+ if (testout[i] < -256)
+ testout[i] = -256;
+ else if (testout[i] > 255)
+ testout[i] = 255;
}
/* accumulate error stats */
for (i = 0; i < DCTSIZE2; i++) {
register int err = testout[i] - refout[i];
+
sumerrs[i] += err;
sumsqerrs[i] += err * err;
- if (err < 0) err = -err;
- if (maxerr[i] < err) maxerr[i] = err;
+ if (err < 0)
+ err = -err;
+ if (maxerr[i] < err)
+ maxerr[i] = err;
}
if (curiter % 100 == 99) {
- fprintf(stderr, ".");
- fflush(stderr);
+ fprintf (stderr, ".");
+ fflush (stderr);
}
}
- fprintf(stderr, "\n");
+ fprintf (stderr, "\n");
/* print results */
- printf("IEEE test conditions: -L = %ld, +H = %ld, sign = %ld, #iters = %ld\n",
- minpix, maxpix, sign, niters);
+ printf
+ ("IEEE test conditions: -L = %ld, +H = %ld, sign = %ld, #iters = %ld\n",
+ minpix, maxpix, sign, niters);
- printf("Speed, min time %lld, max %lld\n", tscmin, tscmax);
+ printf ("Speed, min time %lld, max %lld\n", tscmin, tscmax);
- printf("Peak absolute values of errors:\n");
+ printf ("Peak absolute values of errors:\n");
for (i = 0, j = 0; i < DCTSIZE2; i++) {
- if (j < maxerr[i]) j = maxerr[i];
- printf("%4d", maxerr[i]);
- if ((i%DCTSIZE) == DCTSIZE-1) printf("\n");
+ if (j < maxerr[i])
+ j = maxerr[i];
+ printf ("%4d", maxerr[i]);
+ if ((i % DCTSIZE) == DCTSIZE - 1)
+ printf ("\n");
}
- printf("Worst peak error = %d (%s spec limit 1)\n\n", j,
- meets((double) j, 1.0));
+ printf ("Worst peak error = %d (%s spec limit 1)\n\n", j,
+ meets ((double) j, 1.0));
- printf("Mean square errors:\n");
+ printf ("Mean square errors:\n");
max = total = 0.0;
for (i = 0; i < DCTSIZE2; i++) {
- double err = (double) sumsqerrs[i] / ((double) niters);
+ double err = (double) sumsqerrs[i] / ((double) niters);
+
total += (double) sumsqerrs[i];
- if (max < err) max = err;
- printf(" %8.4f", err);
- if ((i%DCTSIZE) == DCTSIZE-1) printf("\n");
+ if (max < err)
+ max = err;
+ printf (" %8.4f", err);
+ if ((i % DCTSIZE) == DCTSIZE - 1)
+ printf ("\n");
}
- printf("Worst pmse = %.6f (%s spec limit 0.06)\n", max, meets(max, 0.06));
- total /= (double) (64*niters);
- printf("Overall mse = %.6f (%s spec limit 0.02)\n\n", total,
- meets(total, 0.02));
+ printf ("Worst pmse = %.6f (%s spec limit 0.06)\n", max, meets (max, 0.06));
+ total /= (double) (64 * niters);
+ printf ("Overall mse = %.6f (%s spec limit 0.02)\n\n", total,
+ meets (total, 0.02));
- printf("Mean errors:\n");
+ printf ("Mean errors:\n");
max = total = 0.0;
for (i = 0; i < DCTSIZE2; i++) {
- double err = (double) sumerrs[i] / ((double) niters);
+ double err = (double) sumerrs[i] / ((double) niters);
+
total += (double) sumerrs[i];
- printf(" %8.4f", err);
- if (err < 0.0) err = -err;
- if (max < err) max = err;
- if ((i%DCTSIZE) == DCTSIZE-1) printf("\n");
+ printf (" %8.4f", err);
+ if (err < 0.0)
+ err = -err;
+ if (max < err)
+ max = err;
+ if ((i % DCTSIZE) == DCTSIZE - 1)
+ printf ("\n");
}
- printf("Worst mean error = %.6f (%s spec limit 0.015)\n", max,
- meets(max, 0.015));
- total /= (double) (64*niters);
- printf("Overall mean error = %.6f (%s spec limit 0.0015)\n\n", total,
- meets(total, 0.0015));
+ printf ("Worst mean error = %.6f (%s spec limit 0.015)\n", max,
+ meets (max, 0.015));
+ total /= (double) (64 * niters);
+ printf ("Overall mean error = %.6f (%s spec limit 0.0015)\n\n", total,
+ meets (total, 0.0015));
/* test for 0 input giving 0 output */
- memset(testout, 0, sizeof(DCTELEM)*DCTSIZE2);
- gst_idct_convert(idct, testout);
- for (i = 0, j=0; i < DCTSIZE2; i++) {
+ memset (testout, 0, sizeof (DCTELEM) * DCTSIZE2);
+ gst_idct_convert (idct, testout);
+ for (i = 0, j = 0; i < DCTSIZE2; i++) {
if (testout[i]) {
- printf("Position %d of IDCT(0) = %d (FAILS)\n", i, testout[i]);
+ printf ("Position %d of IDCT(0) = %d (FAILS)\n", i, testout[i]);
j++;
}
}
- printf("%d elements of IDCT(0) were not zero\n\n\n", j);
+ printf ("%d elements of IDCT(0) were not zero\n\n\n", j);
- exit(0);
+ exit (0);
return 0;
}
-void usage (char *msg)
+void
+usage (char *msg)
{
if (msg != NULL)
- fprintf(stderr, "\nerror: %s\n", msg);
-
- fprintf(stderr, "\n");
- fprintf(stderr, "usage: ieeetest minpix maxpix sign niters\n");
- fprintf(stderr, "\n");
- fprintf(stderr, " test = 1 - 5\n");
- fprintf(stderr, " minpix = -L value per IEEE spec\n");
- fprintf(stderr, " maxpix = H value per IEEE spec\n");
- fprintf(stderr, " sign = +1 for normal, -1 to run negated test\n");
- fprintf(stderr, " niters = # iterations (10000 for full test)\n");
- fprintf(stderr, "\n");
-
- exit(1);
+ fprintf (stderr, "\nerror: %s\n", msg);
+
+ fprintf (stderr, "\n");
+ fprintf (stderr, "usage: ieeetest minpix maxpix sign niters\n");
+ fprintf (stderr, "\n");
+ fprintf (stderr, " test = 1 - 5\n");
+ fprintf (stderr, " minpix = -L value per IEEE spec\n");
+ fprintf (stderr, " maxpix = H value per IEEE spec\n");
+ fprintf (stderr, " sign = +1 for normal, -1 to run negated test\n");
+ fprintf (stderr, " niters = # iterations (10000 for full test)\n");
+ fprintf (stderr, "\n");
+
+ exit (1);
}
/* Pseudo-random generator specified by IEEE 1180 */
-long ieeerand (long L, long H)
+long
+ieeerand (long L, long H)
{
static long randx = 1;
static double z = (double) 0x7fffffff;
- long i,j;
+ long i, j;
double x;
randx = (randx * 1103515245) + 12345;
i = randx & 0x7ffffffe;
x = ((double) i) / z;
- x *= (L+H+1);
+ x *= (L + H + 1);
j = x;
- return j-L;
+ return j - L;
}
/* Routine to initialise the cosine lookup table */
-void dct_init(void)
+void
+dct_init (void)
{
- int a,b;
+ int a, b;
double tmp;
- for(a=0;a<8;a++)
- for(b=0;b<8;b++) {
- tmp = cos((double)((a+a+1)*b) * (3.14159265358979323846 / 16.0));
- if(b==0)
- tmp /= sqrt(2.0);
+ for (a = 0; a < 8; a++)
+ for (b = 0; b < 8; b++) {
+ tmp = cos ((double) ((a + a + 1) * b) * (3.14159265358979323846 / 16.0));
+ if (b == 0)
+ tmp /= sqrt (2.0);
coslu[a][b] = tmp * 0.5;
}
}
-void ref_fdct (DCTELEM block[8][8])
+void
+ref_fdct (DCTELEM block[8][8])
{
- int x,y,u,v;
+ int x, y, u, v;
double tmp, tmp2;
double res[8][8];
- for (v=0; v<8; v++) {
- for (u=0; u<8; u++) {
+ for (v = 0; v < 8; v++) {
+ for (u = 0; u < 8; u++) {
tmp = 0.0;
- for (y=0; y<8; y++) {
+ for (y = 0; y < 8; y++) {
tmp2 = 0.0;
- for (x=0; x<8; x++) {
+ for (x = 0; x < 8; x++) {
tmp2 += (double) block[y][x] * coslu[x][u];
}
tmp += coslu[y][v] * tmp2;
}
}
- for (v=0; v<8; v++) {
- for (u=0; u<8; u++) {
+ for (v = 0; v < 8; v++) {
+ for (u = 0; u < 8; u++) {
tmp = res[v][u];
if (tmp < 0.0) {
- x = - ((int) (0.5 - tmp));
+ x = -((int) (0.5 - tmp));
} else {
x = (int) (tmp + 0.5);
}
}
-void ref_idct (DCTELEM block[8][8])
+void
+ref_idct (DCTELEM block[8][8])
{
- int x,y,u,v;
+ int x, y, u, v;
double tmp, tmp2;
double res[8][8];
- for (y=0; y<8; y++) {
- for (x=0; x<8; x++) {
+ for (y = 0; y < 8; y++) {
+ for (x = 0; x < 8; x++) {
tmp = 0.0;
- for (v=0; v<8; v++) {
+ for (v = 0; v < 8; v++) {
tmp2 = 0.0;
- for (u=0; u<8; u++) {
+ for (u = 0; u < 8; u++) {
tmp2 += (double) block[v][u] * coslu[x][u];
}
tmp += coslu[y][v] * tmp2;
}
}
- for (v=0; v<8; v++) {
- for (u=0; u<8; u++) {
+ for (v = 0; v < 8; v++) {
+ for (u = 0; u < 8; u++) {
tmp = res[v][u];
if (tmp < 0.0) {
- x = - ((int) (0.5 - tmp));
+ x = -((int) (0.5 - tmp));
} else {
x = (int) (tmp + 0.5);
}
*/
#if DCTSIZE != 8
- Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */
+Sorry, this code only copes with 8 x8 DCTs. /* deliberate syntax err */
#endif
-
-
/*
* A 2-D IDCT can be done by 1-D IDCT on each row followed by 1-D IDCT
* on each column. Direct algorithms are also available, but they are
* have BITS_IN_JSAMPLE + CONST_BITS + PASS1_BITS <= 26. Error analysis
* shows that the values given below are the most effective.
*/
-
#ifdef EIGHT_BIT_SAMPLES
#define CONST_BITS 13
#define PASS1_BITS 2
#define CONST_BITS 13
#define PASS1_BITS 1 /* lose a little precision to avoid overflow */
#endif
-
#define ONE ((INT32) 1)
-
#define CONST_SCALE (ONE << CONST_BITS)
-
/* Convert a positive real constant to an integer scaled by CONST_SCALE. */
-
#define FIX(x) ((INT32) ((x) * CONST_SCALE + 0.5))
-
/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus
* causing a lot of useless floating-point operations at run time.
* To get around this we use the following pre-calculated constants.
* If you change CONST_BITS you may want to add appropriate values.
* (With a reasonable C compiler, you can just rely on the FIX() macro...)
*/
-
#if CONST_BITS == 13
#define FIX_0_298631336 ((INT32) 2446) /* FIX(0.298631336) */
#define FIX_0_390180644 ((INT32) 3196) /* FIX(0.390180644) */
#define FIX_2_562915447 FIX(2.562915447)
#define FIX_3_072711026 FIX(3.072711026)
#endif
-
-
/* Descale and correctly round an INT32 value that's scaled by N bits.
* We assume RIGHT_SHIFT rounds towards minus infinity, so adding
* the fudge factor is correct for either sign of X.
*/
-
#define DESCALE(x,n) RIGHT_SHIFT((x) + (ONE << ((n)-1)), n)
-
/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result.
* For 8-bit samples with the recommended scaling, all the variable
* and constant values involved are no more than 16 bits wide, so a
* combination of casts.
* NB: for 12-bit samples, a full 32-bit multiplication will be needed.
*/
-
#ifdef EIGHT_BIT_SAMPLES
#ifdef SHORTxSHORT_32 /* may work if 'int' is 32 bits */
#define MULTIPLY(var,const) (((INT16) (var)) * ((INT16) (const)))
#define MULTIPLY(var,const) (((INT16) (var)) * ((INT32) (const)))
#endif
#endif
-
#ifndef MULTIPLY /* default definition */
#define MULTIPLY(var,const) ((var) * (const))
#endif
-
-
/*
* Perform the inverse DCT on one block of coefficients.
*/
-
-void
+ void
gst_idct_int_idct (DCTBLOCK data)
{
INT32 tmp0, tmp1, tmp2, tmp3;
INT32 z1, z2, z3, z4, z5;
register DCTELEM *dataptr;
int rowctr;
- SHIFT_TEMPS
-
- /* Pass 1: process rows. */
- /* Note results are scaled up by sqrt(8) compared to a true IDCT; */
- /* furthermore, we scale the results by 2**PASS1_BITS. */
- dataptr = data;
- for (rowctr = DCTSIZE-1; rowctr >= 0; rowctr--) {
+ SHIFT_TEMPS
+ /* Pass 1: process rows. */
+ /* Note results are scaled up by sqrt(8) compared to a true IDCT; */
+ /* furthermore, we scale the results by 2**PASS1_BITS. */
+ dataptr = data;
+ for (rowctr = DCTSIZE - 1; rowctr >= 0; rowctr--) {
/* Due to quantization, we will usually find that many of the input
* coefficients are zero, especially the AC terms. We can exploit this
* by short-circuiting the IDCT calculation for any row in which all
*/
if ((dataptr[1] | dataptr[2] | dataptr[3] | dataptr[4] |
- dataptr[5] | dataptr[6] | dataptr[7]) == 0) {
+ dataptr[5] | dataptr[6] | dataptr[7]) == 0) {
/* AC terms all zero */
DCTELEM dcval = (DCTELEM) (dataptr[0] << PASS1_BITS);
-
+
dataptr[0] = dcval;
dataptr[1] = dcval;
dataptr[2] = dcval;
dataptr[5] = dcval;
dataptr[6] = dcval;
dataptr[7] = dcval;
-
+
dataptr += DCTSIZE; /* advance pointer to next row */
continue;
}
z2 = (INT32) dataptr[2];
z3 = (INT32) dataptr[6];
- z1 = MULTIPLY(z2 + z3, FIX_0_541196100);
- tmp2 = z1 + MULTIPLY(z3, - FIX_1_847759065);
- tmp3 = z1 + MULTIPLY(z2, FIX_0_765366865);
+ z1 = MULTIPLY (z2 + z3, FIX_0_541196100);
+ tmp2 = z1 + MULTIPLY (z3, -FIX_1_847759065);
+ tmp3 = z1 + MULTIPLY (z2, FIX_0_765366865);
tmp0 = ((INT32) dataptr[0] + (INT32) dataptr[4]) << CONST_BITS;
tmp1 = ((INT32) dataptr[0] - (INT32) dataptr[4]) << CONST_BITS;
tmp13 = tmp0 - tmp3;
tmp11 = tmp1 + tmp2;
tmp12 = tmp1 - tmp2;
-
+
/* Odd part per figure 8; the matrix is unitary and hence its
* transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively.
*/
z2 = tmp1 + tmp2;
z3 = tmp0 + tmp2;
z4 = tmp1 + tmp3;
- z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */
-
- tmp0 = MULTIPLY(tmp0, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */
- tmp1 = MULTIPLY(tmp1, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */
- tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */
- tmp3 = MULTIPLY(tmp3, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */
- z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */
- z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */
- z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */
- z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */
-
+ z5 = MULTIPLY (z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */
+
+ tmp0 = MULTIPLY (tmp0, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */
+ tmp1 = MULTIPLY (tmp1, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */
+ tmp2 = MULTIPLY (tmp2, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */
+ tmp3 = MULTIPLY (tmp3, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */
+ z1 = MULTIPLY (z1, -FIX_0_899976223); /* sqrt(2) * (c7-c3) */
+ z2 = MULTIPLY (z2, -FIX_2_562915447); /* sqrt(2) * (-c1-c3) */
+ z3 = MULTIPLY (z3, -FIX_1_961570560); /* sqrt(2) * (-c3-c5) */
+ z4 = MULTIPLY (z4, -FIX_0_390180644); /* sqrt(2) * (c5-c3) */
+
z3 += z5;
z4 += z5;
-
+
tmp0 += z1 + z3;
tmp1 += z2 + z4;
tmp2 += z2 + z3;
/* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
- dataptr[0] = (DCTELEM) DESCALE(tmp10 + tmp3, CONST_BITS-PASS1_BITS);
- dataptr[7] = (DCTELEM) DESCALE(tmp10 - tmp3, CONST_BITS-PASS1_BITS);
- dataptr[1] = (DCTELEM) DESCALE(tmp11 + tmp2, CONST_BITS-PASS1_BITS);
- dataptr[6] = (DCTELEM) DESCALE(tmp11 - tmp2, CONST_BITS-PASS1_BITS);
- dataptr[2] = (DCTELEM) DESCALE(tmp12 + tmp1, CONST_BITS-PASS1_BITS);
- dataptr[5] = (DCTELEM) DESCALE(tmp12 - tmp1, CONST_BITS-PASS1_BITS);
- dataptr[3] = (DCTELEM) DESCALE(tmp13 + tmp0, CONST_BITS-PASS1_BITS);
- dataptr[4] = (DCTELEM) DESCALE(tmp13 - tmp0, CONST_BITS-PASS1_BITS);
+ dataptr[0] = (DCTELEM) DESCALE (tmp10 + tmp3, CONST_BITS - PASS1_BITS);
+ dataptr[7] = (DCTELEM) DESCALE (tmp10 - tmp3, CONST_BITS - PASS1_BITS);
+ dataptr[1] = (DCTELEM) DESCALE (tmp11 + tmp2, CONST_BITS - PASS1_BITS);
+ dataptr[6] = (DCTELEM) DESCALE (tmp11 - tmp2, CONST_BITS - PASS1_BITS);
+ dataptr[2] = (DCTELEM) DESCALE (tmp12 + tmp1, CONST_BITS - PASS1_BITS);
+ dataptr[5] = (DCTELEM) DESCALE (tmp12 - tmp1, CONST_BITS - PASS1_BITS);
+ dataptr[3] = (DCTELEM) DESCALE (tmp13 + tmp0, CONST_BITS - PASS1_BITS);
+ dataptr[4] = (DCTELEM) DESCALE (tmp13 - tmp0, CONST_BITS - PASS1_BITS);
dataptr += DCTSIZE; /* advance pointer to next row */
}
/* and also undo the PASS1_BITS scaling. */
dataptr = data;
- for (rowctr = DCTSIZE-1; rowctr >= 0; rowctr--) {
+ for (rowctr = DCTSIZE - 1; rowctr >= 0; rowctr--) {
/* Columns of zeroes can be exploited in the same way as we did with rows.
* However, the row calculation has created many nonzero AC terms, so the
* simplification applies less often (typically 5% to 10% of the time).
*/
#ifndef NO_ZERO_COLUMN_TEST
- if ((dataptr[DCTSIZE*1] | dataptr[DCTSIZE*2] | dataptr[DCTSIZE*3] |
- dataptr[DCTSIZE*4] | dataptr[DCTSIZE*5] | dataptr[DCTSIZE*6] |
- dataptr[DCTSIZE*7]) == 0) {
+ if ((dataptr[DCTSIZE * 1] | dataptr[DCTSIZE * 2] | dataptr[DCTSIZE * 3] |
+ dataptr[DCTSIZE * 4] | dataptr[DCTSIZE * 5] | dataptr[DCTSIZE * 6] |
+ dataptr[DCTSIZE * 7]) == 0) {
/* AC terms all zero */
- DCTELEM dcval = (DCTELEM) DESCALE((INT32) dataptr[0], PASS1_BITS+3);
-
- dataptr[DCTSIZE*0] = dcval;
- dataptr[DCTSIZE*1] = dcval;
- dataptr[DCTSIZE*2] = dcval;
- dataptr[DCTSIZE*3] = dcval;
- dataptr[DCTSIZE*4] = dcval;
- dataptr[DCTSIZE*5] = dcval;
- dataptr[DCTSIZE*6] = dcval;
- dataptr[DCTSIZE*7] = dcval;
-
+ DCTELEM dcval = (DCTELEM) DESCALE ((INT32) dataptr[0], PASS1_BITS + 3);
+
+ dataptr[DCTSIZE * 0] = dcval;
+ dataptr[DCTSIZE * 1] = dcval;
+ dataptr[DCTSIZE * 2] = dcval;
+ dataptr[DCTSIZE * 3] = dcval;
+ dataptr[DCTSIZE * 4] = dcval;
+ dataptr[DCTSIZE * 5] = dcval;
+ dataptr[DCTSIZE * 6] = dcval;
+ dataptr[DCTSIZE * 7] = dcval;
+
dataptr++; /* advance pointer to next column */
continue;
}
/* Even part: reverse the even part of the forward DCT. */
/* The rotator is sqrt(2)*c(-6). */
- z2 = (INT32) dataptr[DCTSIZE*2];
- z3 = (INT32) dataptr[DCTSIZE*6];
+ z2 = (INT32) dataptr[DCTSIZE * 2];
+ z3 = (INT32) dataptr[DCTSIZE * 6];
- z1 = MULTIPLY(z2 + z3, FIX_0_541196100);
- tmp2 = z1 + MULTIPLY(z3, - FIX_1_847759065);
- tmp3 = z1 + MULTIPLY(z2, FIX_0_765366865);
+ z1 = MULTIPLY (z2 + z3, FIX_0_541196100);
+ tmp2 = z1 + MULTIPLY (z3, -FIX_1_847759065);
+ tmp3 = z1 + MULTIPLY (z2, FIX_0_765366865);
- tmp0 = ((INT32) dataptr[DCTSIZE*0] + (INT32) dataptr[DCTSIZE*4]) << CONST_BITS;
- tmp1 = ((INT32) dataptr[DCTSIZE*0] - (INT32) dataptr[DCTSIZE*4]) << CONST_BITS;
+ tmp0 =
+ ((INT32) dataptr[DCTSIZE * 0] +
+ (INT32) dataptr[DCTSIZE * 4]) << CONST_BITS;
+ tmp1 =
+ ((INT32) dataptr[DCTSIZE * 0] -
+ (INT32) dataptr[DCTSIZE * 4]) << CONST_BITS;
tmp10 = tmp0 + tmp3;
tmp13 = tmp0 - tmp3;
tmp11 = tmp1 + tmp2;
tmp12 = tmp1 - tmp2;
-
+
/* Odd part per figure 8; the matrix is unitary and hence its
* transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively.
*/
- tmp0 = (INT32) dataptr[DCTSIZE*7];
- tmp1 = (INT32) dataptr[DCTSIZE*5];
- tmp2 = (INT32) dataptr[DCTSIZE*3];
- tmp3 = (INT32) dataptr[DCTSIZE*1];
+ tmp0 = (INT32) dataptr[DCTSIZE * 7];
+ tmp1 = (INT32) dataptr[DCTSIZE * 5];
+ tmp2 = (INT32) dataptr[DCTSIZE * 3];
+ tmp3 = (INT32) dataptr[DCTSIZE * 1];
z1 = tmp0 + tmp3;
z2 = tmp1 + tmp2;
z3 = tmp0 + tmp2;
z4 = tmp1 + tmp3;
- z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */
-
- tmp0 = MULTIPLY(tmp0, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */
- tmp1 = MULTIPLY(tmp1, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */
- tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */
- tmp3 = MULTIPLY(tmp3, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */
- z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */
- z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */
- z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */
- z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */
-
+ z5 = MULTIPLY (z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */
+
+ tmp0 = MULTIPLY (tmp0, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */
+ tmp1 = MULTIPLY (tmp1, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */
+ tmp2 = MULTIPLY (tmp2, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */
+ tmp3 = MULTIPLY (tmp3, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */
+ z1 = MULTIPLY (z1, -FIX_0_899976223); /* sqrt(2) * (c7-c3) */
+ z2 = MULTIPLY (z2, -FIX_2_562915447); /* sqrt(2) * (-c1-c3) */
+ z3 = MULTIPLY (z3, -FIX_1_961570560); /* sqrt(2) * (-c3-c5) */
+ z4 = MULTIPLY (z4, -FIX_0_390180644); /* sqrt(2) * (c5-c3) */
+
z3 += z5;
z4 += z5;
-
+
tmp0 += z1 + z3;
tmp1 += z2 + z4;
tmp2 += z2 + z3;
/* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
- dataptr[DCTSIZE*0] = (DCTELEM) DESCALE(tmp10 + tmp3,
- CONST_BITS+PASS1_BITS+3);
- dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp10 - tmp3,
- CONST_BITS+PASS1_BITS+3);
- dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp11 + tmp2,
- CONST_BITS+PASS1_BITS+3);
- dataptr[DCTSIZE*6] = (DCTELEM) DESCALE(tmp11 - tmp2,
- CONST_BITS+PASS1_BITS+3);
- dataptr[DCTSIZE*2] = (DCTELEM) DESCALE(tmp12 + tmp1,
- CONST_BITS+PASS1_BITS+3);
- dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp12 - tmp1,
- CONST_BITS+PASS1_BITS+3);
- dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp13 + tmp0,
- CONST_BITS+PASS1_BITS+3);
- dataptr[DCTSIZE*4] = (DCTELEM) DESCALE(tmp13 - tmp0,
- CONST_BITS+PASS1_BITS+3);
-
+ dataptr[DCTSIZE * 0] = (DCTELEM) DESCALE (tmp10 + tmp3,
+ CONST_BITS + PASS1_BITS + 3);
+ dataptr[DCTSIZE * 7] = (DCTELEM) DESCALE (tmp10 - tmp3,
+ CONST_BITS + PASS1_BITS + 3);
+ dataptr[DCTSIZE * 1] = (DCTELEM) DESCALE (tmp11 + tmp2,
+ CONST_BITS + PASS1_BITS + 3);
+ dataptr[DCTSIZE * 6] = (DCTELEM) DESCALE (tmp11 - tmp2,
+ CONST_BITS + PASS1_BITS + 3);
+ dataptr[DCTSIZE * 2] = (DCTELEM) DESCALE (tmp12 + tmp1,
+ CONST_BITS + PASS1_BITS + 3);
+ dataptr[DCTSIZE * 5] = (DCTELEM) DESCALE (tmp12 - tmp1,
+ CONST_BITS + PASS1_BITS + 3);
+ dataptr[DCTSIZE * 3] = (DCTELEM) DESCALE (tmp13 + tmp0,
+ CONST_BITS + PASS1_BITS + 3);
+ dataptr[DCTSIZE * 4] = (DCTELEM) DESCALE (tmp13 - tmp0,
+ CONST_BITS + PASS1_BITS + 3);
+
dataptr++; /* advance pointer to next column */
}
}
* along with GNU Make; see the file COPYING. If not, write to\r
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. \r
*\r
- */\r
-\r
-\r
+ */ \r
+ \r\r
/* MMX32 iDCT algorithm (IEEE-1180 compliant) :: idct_mmx32()\r */
/*\r */
/* MPEG2AVI\r */
/*\r */
/* liaor@umcc.ais.org http://members.tripod.com/~liaor\r */
/* \r */
-\r
-\r
+ \r\r
/*;=============================================================================\r */
/*;\r */
/*; AP-922 http://developer.intel.com/vtune/cbts/strmsimd\r */
/*;=============================================================================\r */
/*\r
mword typedef qword\r
-qword ptr equ mword ptr */\r
-
+qword ptr equ mword ptr */ \r
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-
#include <mmx.h>\r
-\r
+ \r
#define BITS_INV_ACC 4 /*; 4 or 5 for IEEE\r */
- /* 5 yields higher accuracy, but lessens dynamic range on the input matrix\r */
+ /* 5 yields higher accuracy, but lessens dynamic range on the input matrix\r */
#define SHIFT_INV_ROW (16 - BITS_INV_ACC)\r
-#define SHIFT_INV_COL (1 + BITS_INV_ACC +14 ) /* changed from Intel's val)\r */
+#define SHIFT_INV_COL (1 + BITS_INV_ACC +14 ) /* changed from Intel's val)\r */
/*#define SHIFT_INV_COL (1 + BITS_INV_ACC )\r */
-\r
+ \r
#define RND_INV_ROW (1 << (SHIFT_INV_ROW-1))\r
#define RND_INV_COL (1 << (SHIFT_INV_COL-1)) \r
-#define RND_INV_CORR (RND_INV_COL - 1) /*; correction -1.0 and round\r */
+#define RND_INV_CORR (RND_INV_COL - 1) /*; correction -1.0 and round\r */
/*#define RND_INV_ROW (1024 * (6 - BITS_INV_ACC)) //; 1 << (SHIFT_INV_ROW-1)\r */
/*#define RND_INV_COL (16 * (BITS_INV_ACC - 3)) //; 1 << (SHIFT_INV_COL-1)\r */
-\r
-\r
+ \r\r
/*.data\r */
/*Align 16\r */
-const static long r_inv_row[2] = { RND_INV_ROW, RND_INV_ROW};\r
-const static long r_inv_col[2] = {RND_INV_COL, RND_INV_COL};\r
-const static long r_inv_corr[2] = {RND_INV_CORR, RND_INV_CORR };\r
-\r
+const static long r_inv_row[2] = { RND_INV_ROW, RND_INV_ROW };
+\rconst static long r_inv_col[2] = { RND_INV_COL, RND_INV_COL };
+\rconst static long r_inv_corr[2] = { RND_INV_CORR, RND_INV_CORR };
+
+\r\r
/*const static short r_inv_col[4] = \r */
/* {RND_INV_COL, RND_INV_COL, RND_INV_COL, RND_INV_COL};\r */
/*const static short r_inv_corr[4] =\r */
/* {RND_INV_CORR, RND_INV_CORR, RND_INV_CORR, RND_INV_CORR};\r */
-\r
+ \r
/* constants for the forward DCT\r
\r
/*#define BITS_FRW_ACC 3 //; 2 or 3 for accuracy\r */
/*#define SHIFT_FRW_COL BITS_FRW_ACC\r */
/*#define SHIFT_FRW_ROW (BITS_FRW_ACC + 17)\r */
/*#define RND_FRW_ROW (262144 * (BITS_FRW_ACC - 1)) //; 1 << (SHIFT_FRW_ROW-1)\r */
-\r
-const static __int64 one_corr = 0x0001000100010001;\r
-const static long r_frw_row[2] = {RND_FRW_ROW, RND_FRW_ROW };\r
-\r
+\rconst static __int64 one_corr = 0x0001000100010001;
+\rconst static long r_frw_row[2] = { RND_FRW_ROW, RND_FRW_ROW };
+
+\r\r
/*const static short tg_1_16[4] = {13036, 13036, 13036, 13036 }; //tg * (2<<16) + 0.5\r */
/*const static short tg_2_16[4] = {27146, 27146, 27146, 27146 }; //tg * (2<<16) + 0.5\r */
/*const static short tg_3_16[4] = {-21746, -21746, -21746, -21746 }; //tg * (2<<16) + 0.5\r */
/*const static short cos_4_16[4] = {-19195, -19195, -19195, -19195 }; //cos * (2<<16) + 0.5\r */
/*const static short ocos_4_16[4] = {23170, 23170, 23170, 23170 }; //cos * (2<<15) + 0.5\r */
-\r
+ \r
/*concatenated table, for forward DCT transformation\r */
-const static short tg_all_16[] = {\r
- 13036, 13036, 13036, 13036, /* tg * (2<<16) + 0.5\r */
- 27146, 27146, 27146, 27146, /*tg * (2<<16) + 0.5\r */
- -21746, -21746, -21746, -21746, /* tg * (2<<16) + 0.5\r */
- -19195, -19195, -19195, -19195, /*cos * (2<<16) + 0.5\r */
- 23170, 23170, 23170, 23170 }; /*cos * (2<<15) + 0.5\r */
+const static short tg_all_16[] = { \r13036, 13036, 13036, 13036, /* tg * (2<<16) + 0.5\r */
+ 27146, 27146, 27146, 27146, /*tg * (2<<16) + 0.5\r */
+ -21746, -21746, -21746, -21746, /* tg * (2<<16) + 0.5\r */
+ -19195, -19195, -19195, -19195, /*cos * (2<<16) + 0.5\r */
+ 23170, 23170, 23170, 23170
+}; /*cos * (2<<15) + 0.5\r */
+
\r
#define tg_1_16 (tg_all_16 + 0)\r
#define tg_2_16 (tg_all_16 + 8)\r
#define tg_3_16 (tg_all_16 + 16)\r
#define cos_4_16 (tg_all_16 + 24)\r
#define ocos_4_16 (tg_all_16 + 32)\r
-*/\r
+ */\r
/*\r
;=============================================================================\r
;\r
;=============================================================================\r
\r
/*; Table for rows 0,4 - constants are multiplied by cos_4_16\r */
-const short tab_i_04[] = {\r
- 16384, 16384, 16384, -16384, /* ; movq-> w06 w04 w02 w00\r */
- 21407, 8867, 8867, -21407, /* w07 w05 w03 w01\r */
- 16384, -16384, 16384, 16384, /*; w14 w12 w10 w08\r */
- -8867, 21407, -21407, -8867, /*; w15 w13 w11 w09\r */
- 22725, 12873, 19266, -22725, /*; w22 w20 w18 w16\r */
- 19266, 4520, -4520, -12873, /*; w23 w21 w19 w17\r */
- 12873, 4520, 4520, 19266, /*; w30 w28 w26 w24\r */
- -22725, 19266, -12873, -22725 };/*w31 w29 w27 w25\r */
+const short tab_i_04[] = { \r16384, 16384, 16384, -16384, /* ; movq-> w06 w04 w02 w00\r */
+ 21407, 8867, 8867, -21407, /* w07 w05 w03 w01\r */
+ 16384, -16384, 16384, 16384, /*; w14 w12 w10 w08\r */
+ -8867, 21407, -21407, -8867, /*; w15 w13 w11 w09\r */
+ 22725, 12873, 19266, -22725, /*; w22 w20 w18 w16\r */
+ 19266, 4520, -4520, -12873, /*; w23 w21 w19 w17\r */
+ 12873, 4520, 4520, 19266, /*; w30 w28 w26 w24\r */
+ -22725, 19266, -12873, -22725
+}; /*w31 w29 w27 w25\r */
+
\r
/*; Table for rows 1,7 - constants are multiplied by cos_1_16\r */
-const short tab_i_17[] = {\r
- 22725, 22725, 22725, -22725, /* ; movq-> w06 w04 w02 w00\r */
- 29692, 12299, 12299, -29692, /* ; w07 w05 w03 w01\r */
- 22725, -22725, 22725, 22725, /*; w14 w12 w10 w08\r */
- -12299, 29692, -29692, -12299, /*; w15 w13 w11 w09\r */
- 31521, 17855, 26722, -31521, /*; w22 w20 w18 w16\r */
- 26722, 6270, -6270, -17855, /*; w23 w21 w19 w17\r */
- 17855, 6270, 6270, 26722, /*; w30 w28 w26 w24\r */
- -31521, 26722, -17855, -31521}; /* w31 w29 w27 w25\r */
+const short tab_i_17[] = { \r22725, 22725, 22725, -22725, /* ; movq-> w06 w04 w02 w00\r */
+ 29692, 12299, 12299, -29692, /* ; w07 w05 w03 w01\r */
+ 22725, -22725, 22725, 22725, /*; w14 w12 w10 w08\r */
+ -12299, 29692, -29692, -12299, /*; w15 w13 w11 w09\r */
+ 31521, 17855, 26722, -31521, /*; w22 w20 w18 w16\r */
+ 26722, 6270, -6270, -17855, /*; w23 w21 w19 w17\r */
+ 17855, 6270, 6270, 26722, /*; w30 w28 w26 w24\r */
+ -31521, 26722, -17855, -31521
+}; /* w31 w29 w27 w25\r */
+
\r
/*; Table for rows 2,6 - constants are multiplied by cos_2_16\r */
-const short tab_i_26[] = {\r
- 21407, 21407, 21407, -21407, /* ; movq-> w06 w04 w02 w00\r */
- 27969, 11585, 11585, -27969, /* ; w07 w05 w03 w01\r */
- 21407, -21407, 21407, 21407, /* ; w14 w12 w10 w08\r */
- -11585, 27969, -27969, -11585, /* ;w15 w13 w11 w09\r */
- 29692, 16819, 25172, -29692, /* ;w22 w20 w18 w16\r */
- 25172, 5906, -5906, -16819, /* ;w23 w21 w19 w17\r */
- 16819, 5906, 5906, 25172, /* ;w30 w28 w26 w24\r */
- -29692, 25172, -16819, -29692}; /* ;w31 w29 w27 w25\r */
-\r
-\r
+const short tab_i_26[] = { \r21407, 21407, 21407, -21407, /* ; movq-> w06 w04 w02 w00\r */
+ 27969, 11585, 11585, -27969, /* ; w07 w05 w03 w01\r */
+ 21407, -21407, 21407, 21407, /* ; w14 w12 w10 w08\r */
+ -11585, 27969, -27969, -11585, /* ;w15 w13 w11 w09\r */
+ 29692, 16819, 25172, -29692, /* ;w22 w20 w18 w16\r */
+ 25172, 5906, -5906, -16819, /* ;w23 w21 w19 w17\r */
+ 16819, 5906, 5906, 25172, /* ;w30 w28 w26 w24\r */
+ -29692, 25172, -16819, -29692
+}; /* ;w31 w29 w27 w25\r */
+
+\r\r
/*; Table for rows 3,5 - constants are multiplied by cos_3_16\r */
-const short tab_i_35[] = {\r
- 19266, 19266, 19266, -19266, /*; movq-> w06 w04 w02 w00\r */
- 25172, 10426, 10426, -25172, /*; w07 w05 w03 w01\r */
- 19266, -19266, 19266, 19266, /*; w14 w12 w10 w08\r */
- -10426, 25172, -25172, -10426, /*; w15 w13 w11 w09\r */
- 26722, 15137, 22654, -26722, /*; w22 w20 w18 w16\r */
- 22654, 5315, -5315, -15137, /*; w23 w21 w19 w17\r */
- 15137, 5315, 5315, 22654, /*; w30 w28 w26 w24\r */
- -26722, 22654, -15137, -26722}; /*; w31 w29 w27 w25\r */
-*/\r
-\r
+const short tab_i_35[] = { \r19266, 19266, 19266, -19266, /*; movq-> w06 w04 w02 w00\r */
+ 25172, 10426, 10426, -25172, /*; w07 w05 w03 w01\r */
+ 19266, -19266, 19266, 19266, /*; w14 w12 w10 w08\r */
+ -10426, 25172, -25172, -10426, /*; w15 w13 w11 w09\r */
+ 26722, 15137, 22654, -26722, /*; w22 w20 w18 w16\r */
+ 22654, 5315, -5315, -15137, /*; w23 w21 w19 w17\r */
+ 15137, 5315, 5315, 22654, /*; w30 w28 w26 w24\r */
+ -26722, 22654, -15137, -26722
+}; /*; w31 w29 w27 w25\r */
+
+*/\r\r
/* CONCATENATED TABLE, rows 0,1,2,3,4,5,6,7 (in order )\r */
/*\r */
/* In our implementation, however, we only use row0 !\r */
/*\r */
-static const short tab_i_01234567[] = {\r
- /*row0, this row is required\r */
- 16384, 16384, 16384, -16384, /* ; movq-> w06 w04 w02 w00\r */
- 21407, 8867, 8867, -21407, /* w07 w05 w03 w01\r */
- 16384, -16384, 16384, 16384, /*; w14 w12 w10 w08\r */
- -8867, 21407, -21407, -8867, /*; w15 w13 w11 w09\r */
- 22725, 12873, 19266, -22725, /*; w22 w20 w18 w16\r */
- 19266, 4520, -4520, -12873, /*; w23 w21 w19 w17\r */
- 12873, 4520, 4520, 19266, /*; w30 w28 w26 w24\r */
- -22725, 19266, -12873, -22725, /*w31 w29 w27 w25\r */
-\r
- /* the rest of these rows (1-7), aren't used !\r */
-\r
- /*row1\r */
- 22725, 22725, 22725, -22725, /* ; movq-> w06 w04 w02 w00\r */
- 29692, 12299, 12299, -29692, /* ; w07 w05 w03 w01\r */
- 22725, -22725, 22725, 22725, /*; w14 w12 w10 w08\r */
- -12299, 29692, -29692, -12299, /*; w15 w13 w11 w09\r */
- 31521, 17855, 26722, -31521, /*; w22 w20 w18 w16\r */
- 26722, 6270, -6270, -17855, /*; w23 w21 w19 w17\r */
- 17855, 6270, 6270, 26722, /*; w30 w28 w26 w24\r */
- -31521, 26722, -17855, -31521, /* w31 w29 w27 w25\r */
-\r
- /*row2\r */
- 21407, 21407, 21407, -21407, /* ; movq-> w06 w04 w02 w00\r */
- 27969, 11585, 11585, -27969, /* ; w07 w05 w03 w01\r */
- 21407, -21407, 21407, 21407, /* ; w14 w12 w10 w08\r */
- -11585, 27969, -27969, -11585, /* ;w15 w13 w11 w09\r */
- 29692, 16819, 25172, -29692, /* ;w22 w20 w18 w16\r */
- 25172, 5906, -5906, -16819, /* ;w23 w21 w19 w17\r */
- 16819, 5906, 5906, 25172, /* ;w30 w28 w26 w24\r */
- -29692, 25172, -16819, -29692, /* ;w31 w29 w27 w25\r */
-\r
- /*row3\r */
- 19266, 19266, 19266, -19266, /*; movq-> w06 w04 w02 w00\r */
- 25172, 10426, 10426, -25172, /*; w07 w05 w03 w01\r */
- 19266, -19266, 19266, 19266, /*; w14 w12 w10 w08\r */
- -10426, 25172, -25172, -10426, /*; w15 w13 w11 w09\r */
- 26722, 15137, 22654, -26722, /*; w22 w20 w18 w16\r */
- 22654, 5315, -5315, -15137, /*; w23 w21 w19 w17\r */
- 15137, 5315, 5315, 22654, /*; w30 w28 w26 w24\r */
- -26722, 22654, -15137, -26722, /*; w31 w29 w27 w25\r */
-\r
- /*row4\r */
- 16384, 16384, 16384, -16384, /* ; movq-> w06 w04 w02 w00\r */
- 21407, 8867, 8867, -21407, /* w07 w05 w03 w01\r */
- 16384, -16384, 16384, 16384, /*; w14 w12 w10 w08\r */
- -8867, 21407, -21407, -8867, /*; w15 w13 w11 w09\r */
- 22725, 12873, 19266, -22725, /*; w22 w20 w18 w16\r */
- 19266, 4520, -4520, -12873, /*; w23 w21 w19 w17\r */
- 12873, 4520, 4520, 19266, /*; w30 w28 w26 w24\r */
- -22725, 19266, -12873, -22725, /*w31 w29 w27 w25\r */
-\r
- /*row5\r */
- 19266, 19266, 19266, -19266, /*; movq-> w06 w04 w02 w00\r */
- 25172, 10426, 10426, -25172, /*; w07 w05 w03 w01\r */
- 19266, -19266, 19266, 19266, /*; w14 w12 w10 w08\r */
- -10426, 25172, -25172, -10426, /*; w15 w13 w11 w09\r */
- 26722, 15137, 22654, -26722, /*; w22 w20 w18 w16\r */
- 22654, 5315, -5315, -15137, /*; w23 w21 w19 w17\r */
- 15137, 5315, 5315, 22654, /*; w30 w28 w26 w24\r */
- -26722, 22654, -15137, -26722, /*; w31 w29 w27 w25\r */
-\r
- /*row6\r */
- 21407, 21407, 21407, -21407, /* ; movq-> w06 w04 w02 w00\r */
- 27969, 11585, 11585, -27969, /* ; w07 w05 w03 w01\r */
- 21407, -21407, 21407, 21407, /* ; w14 w12 w10 w08\r */
- -11585, 27969, -27969, -11585, /* ;w15 w13 w11 w09\r */
- 29692, 16819, 25172, -29692, /* ;w22 w20 w18 w16\r */
- 25172, 5906, -5906, -16819, /* ;w23 w21 w19 w17\r */
- 16819, 5906, 5906, 25172, /* ;w30 w28 w26 w24\r */
- -29692, 25172, -16819, -29692, /* ;w31 w29 w27 w25\r */
-\r
- /*row7\r */
- 22725, 22725, 22725, -22725, /* ; movq-> w06 w04 w02 w00\r */
- 29692, 12299, 12299, -29692, /* ; w07 w05 w03 w01\r */
- 22725, -22725, 22725, 22725, /*; w14 w12 w10 w08\r */
- -12299, 29692, -29692, -12299, /*; w15 w13 w11 w09\r */
- 31521, 17855, 26722, -31521, /*; w22 w20 w18 w16\r */
- 26722, 6270, -6270, -17855, /*; w23 w21 w19 w17\r */
- 17855, 6270, 6270, 26722, /*; w30 w28 w26 w24\r */
- -31521, 26722, -17855, -31521}; /* w31 w29 w27 w25\r */
-\r
-\r
-#define INP eax /* pointer to (short *blk)\r */
-#define OUT ecx /* pointer to output (temporary store space qwTemp[])\r */
-#define TABLE ebx /* pointer to tab_i_01234567[]\r */
+static const short tab_i_01234567[] = { \r
+ /*row0, this row is required\r */
+ 16384, 16384, 16384, -16384, /* ; movq-> w06 w04 w02 w00\r */
+ 21407, 8867, 8867, -21407, /* w07 w05 w03 w01\r */
+ 16384, -16384, 16384, 16384, /*; w14 w12 w10 w08\r */
+ -8867, 21407, -21407, -8867, /*; w15 w13 w11 w09\r */
+ 22725, 12873, 19266, -22725, /*; w22 w20 w18 w16\r */
+ 19266, 4520, -4520, -12873, /*; w23 w21 w19 w17\r */
+ 12873, 4520, 4520, 19266, /*; w30 w28 w26 w24\r */
+ -22725, 19266, -12873, -22725, /*w31 w29 w27 w25\r */
+ \r
+ /* the rest of these rows (1-7), aren't used !\r */
+ \r
+ /*row1\r */
+ 22725, 22725, 22725, -22725, /* ; movq-> w06 w04 w02 w00\r */
+ 29692, 12299, 12299, -29692, /* ; w07 w05 w03 w01\r */
+ 22725, -22725, 22725, 22725, /*; w14 w12 w10 w08\r */
+ -12299, 29692, -29692, -12299, /*; w15 w13 w11 w09\r */
+ 31521, 17855, 26722, -31521, /*; w22 w20 w18 w16\r */
+ 26722, 6270, -6270, -17855, /*; w23 w21 w19 w17\r */
+ 17855, 6270, 6270, 26722, /*; w30 w28 w26 w24\r */
+ -31521, 26722, -17855, -31521, /* w31 w29 w27 w25\r */
+ \r
+ /*row2\r */
+ 21407, 21407, 21407, -21407, /* ; movq-> w06 w04 w02 w00\r */
+ 27969, 11585, 11585, -27969, /* ; w07 w05 w03 w01\r */
+ 21407, -21407, 21407, 21407, /* ; w14 w12 w10 w08\r */
+ -11585, 27969, -27969, -11585, /* ;w15 w13 w11 w09\r */
+ 29692, 16819, 25172, -29692, /* ;w22 w20 w18 w16\r */
+ 25172, 5906, -5906, -16819, /* ;w23 w21 w19 w17\r */
+ 16819, 5906, 5906, 25172, /* ;w30 w28 w26 w24\r */
+ -29692, 25172, -16819, -29692, /* ;w31 w29 w27 w25\r */
+ \r
+ /*row3\r */
+ 19266, 19266, 19266, -19266, /*; movq-> w06 w04 w02 w00\r */
+ 25172, 10426, 10426, -25172, /*; w07 w05 w03 w01\r */
+ 19266, -19266, 19266, 19266, /*; w14 w12 w10 w08\r */
+ -10426, 25172, -25172, -10426, /*; w15 w13 w11 w09\r */
+ 26722, 15137, 22654, -26722, /*; w22 w20 w18 w16\r */
+ 22654, 5315, -5315, -15137, /*; w23 w21 w19 w17\r */
+ 15137, 5315, 5315, 22654, /*; w30 w28 w26 w24\r */
+ -26722, 22654, -15137, -26722, /*; w31 w29 w27 w25\r */
+ \r
+ /*row4\r */
+ 16384, 16384, 16384, -16384, /* ; movq-> w06 w04 w02 w00\r */
+ 21407, 8867, 8867, -21407, /* w07 w05 w03 w01\r */
+ 16384, -16384, 16384, 16384, /*; w14 w12 w10 w08\r */
+ -8867, 21407, -21407, -8867, /*; w15 w13 w11 w09\r */
+ 22725, 12873, 19266, -22725, /*; w22 w20 w18 w16\r */
+ 19266, 4520, -4520, -12873, /*; w23 w21 w19 w17\r */
+ 12873, 4520, 4520, 19266, /*; w30 w28 w26 w24\r */
+ -22725, 19266, -12873, -22725, /*w31 w29 w27 w25\r */
+ \r
+ /*row5\r */
+ 19266, 19266, 19266, -19266, /*; movq-> w06 w04 w02 w00\r */
+ 25172, 10426, 10426, -25172, /*; w07 w05 w03 w01\r */
+ 19266, -19266, 19266, 19266, /*; w14 w12 w10 w08\r */
+ -10426, 25172, -25172, -10426, /*; w15 w13 w11 w09\r */
+ 26722, 15137, 22654, -26722, /*; w22 w20 w18 w16\r */
+ 22654, 5315, -5315, -15137, /*; w23 w21 w19 w17\r */
+ 15137, 5315, 5315, 22654, /*; w30 w28 w26 w24\r */
+ -26722, 22654, -15137, -26722, /*; w31 w29 w27 w25\r */
+ \r
+ /*row6\r */
+ 21407, 21407, 21407, -21407, /* ; movq-> w06 w04 w02 w00\r */
+ 27969, 11585, 11585, -27969, /* ; w07 w05 w03 w01\r */
+ 21407, -21407, 21407, 21407, /* ; w14 w12 w10 w08\r */
+ -11585, 27969, -27969, -11585, /* ;w15 w13 w11 w09\r */
+ 29692, 16819, 25172, -29692, /* ;w22 w20 w18 w16\r */
+ 25172, 5906, -5906, -16819, /* ;w23 w21 w19 w17\r */
+ 16819, 5906, 5906, 25172, /* ;w30 w28 w26 w24\r */
+ -29692, 25172, -16819, -29692, /* ;w31 w29 w27 w25\r */
+ \r
+ /*row7\r */
+ 22725, 22725, 22725, -22725, /* ; movq-> w06 w04 w02 w00\r */
+ 29692, 12299, 12299, -29692, /* ; w07 w05 w03 w01\r */
+ 22725, -22725, 22725, 22725, /*; w14 w12 w10 w08\r */
+ -12299, 29692, -29692, -12299, /*; w15 w13 w11 w09\r */
+ 31521, 17855, 26722, -31521, /*; w22 w20 w18 w16\r */
+ 26722, 6270, -6270, -17855, /*; w23 w21 w19 w17\r */
+ 17855, 6270, 6270, 26722, /*; w30 w28 w26 w24\r */
+ -31521, 26722, -17855, -31521
+}; /* w31 w29 w27 w25\r */
+
+\r\r
+#define INP eax /* pointer to (short *blk)\r */
+#define OUT ecx /* pointer to output (temporary store space qwTemp[])\r */
+#define TABLE ebx /* pointer to tab_i_01234567[]\r */
#define round_inv_row edx\r
#define round_inv_col edx\r
-\r
-#define ROW_STRIDE 8 /* for 8x8 matrix transposer\r */
-\r
+ \r
+#define ROW_STRIDE 8 /* for 8x8 matrix transposer\r */
+ \r
/* private variables and functions\r */
-\r
+ \r
/*temporary storage space, 8x8 of shorts\r */
-\r
-__inline static void idct_mmx32_rows( short *blk ); /* transform rows\r */
-__inline static void idct_mmx32_cols( short *blk ); /* transform "columns"\r */
+\r__inline static void idct_mmx32_rows (short *blk); /* transform rows\r */
+__inline static void idct_mmx32_cols (short *blk); /* transform "columns"\r */
+
/* the "column" transform actually transforms rows, it is\r */
/* identical to the row-transform except for the ROUNDING\r */
/* and SHIFTING coefficients.\r */
-\r
- \r
-static void \r
-idct_mmx32_rows( short *blk ) /* transform all 8 rows of 8x8 iDCT block\r */
-{\r
- int x;\r
- short qwTemp[64];\r
- short *out = &qwTemp[0];\r
- short *inptr = blk;\r
- /* this subroutine performs two operations\r */
- /* 1) iDCT row transform\r */
- /* for( i = 0; i < 8; ++ i)\r */
- /* DCT_8_INV_ROW_1( blk[i*8], qwTemp[i] );\r */
- /*\r */
- /* 2) transpose the matrix (which was stored in qwTemp[])\r */
- /* qwTemp[] -> [8x8 matrix transpose] -> blk[]\r */
-\r
- for (x=0; x<8; x++) { /* transform one row per iteration\r */
- movq_m2r(*(inptr), mm0); /* 0 ; x3 x2 x1 x0\r */
-\r
- movq_m2r(*(inptr+4), mm1); /* 1 ; x7 x6 x5 x4\r */
- movq_r2r(mm0, mm2); /* 2 ; x3 x2 x1 x0\r */
-\r
- movq_m2r(*(tab_i_01234567), mm3); /* 3 ; w06 w04 w02 w00\r */
- punpcklwd_r2r(mm1, mm0); /* x5 x1 x4 x0\r */
-\r
- /* ----------\r */
- movq_r2r(mm0, mm5); /* 5 ; x5 x1 x4 x0\r */
- punpckldq_r2r(mm0, mm0); /* x4 x0 x4 x0\r */
-\r
- movq_m2r(*(tab_i_01234567+4), mm4); /* 4 ; w07 w05 w03 w01\r */
- punpckhwd_r2r(mm1, mm2); /* 1 ; x7 x3 x6 x2\r */
-\r
- pmaddwd_r2r(mm0, mm3); /* x4*w06+x0*w04 x4*w02+x0*w00\r */
- movq_r2r(mm2, mm6); /* 6 ; x7 x3 x6 x2\r */
-\r
- movq_m2r(*(tab_i_01234567+16), mm1);/* 1 ; w22 w20 w18 w16\r */
- punpckldq_r2r(mm2, mm2); /* x6 x2 x6 x2\r */
-\r
- pmaddwd_r2r(mm2, mm4); /* x6*w07+x2*w05 x6*w03+x2*w01\r */
- punpckhdq_r2r(mm5, mm5); /* x5 x1 x5 x1\r */
-\r
- pmaddwd_m2r(*(tab_i_01234567+8), mm0);/* x4*w14+x0*w12 x4*w10+x0*w08\r */
- punpckhdq_r2r(mm6, mm6); /* x7 x3 x7 x3\r */
-\r
- movq_m2r(*(tab_i_01234567+20), mm7);/* 7 ; w23 w21 w19 w17\r */
- pmaddwd_r2r(mm5, mm1); /* x5*w22+x1*w20 x5*w18+x1*w16\r */
-\r
- paddd_m2r(*(r_inv_row), mm3);/* +rounder\r */
- pmaddwd_r2r(mm6, mm7); /* x7*w23+x3*w21 x7*w19+x3*w17\r */
-\r
- pmaddwd_m2r(*(tab_i_01234567+12), mm2);/* x6*w15+x2*w13 x6*w11+x2*w09\r */
- paddd_r2r(mm4, mm3); /* 4 ; a1=sum(even1) a0=sum(even0)\r */
-\r
- pmaddwd_m2r(*(tab_i_01234567+24), mm5);/* x5*w30+x1*w28 x5*w26+x1*w24\r */
- movq_r2r(mm3, mm4); /* 4 ; a1 a0\r */
-\r
- pmaddwd_m2r(*(tab_i_01234567+28), mm6);/* x7*w31+x3*w29 x7*w27+x3*w25\r */
- paddd_r2r(mm7, mm1); /* 7 ; b1=sum(odd1) b0=sum(odd0)\r */
-\r
- paddd_m2r(*(r_inv_row), mm0);/* +rounder\r */
- psubd_r2r(mm1, mm3); /* a1-b1 a0-b0\r */
-\r
- psrad_i2r(SHIFT_INV_ROW, mm3); /* y6=a1-b1 y7=a0-b0\r */
- paddd_r2r(mm4, mm1); /* 4 ; a1+b1 a0+b0\r */
-\r
- paddd_r2r(mm2, mm0); /* 2 ; a3=sum(even3) a2=sum(even2)\r */
- psrad_i2r(SHIFT_INV_ROW, mm1); /* y1=a1+b1 y0=a0+b0\r */
-\r
- paddd_r2r(mm6, mm5); /* 6 ; b3=sum(odd3) b2=sum(odd2)\r */
- movq_r2r(mm0, mm4); /* 4 ; a3 a2\r */
-\r
- paddd_r2r(mm5, mm0); /* a3+b3 a2+b2\r */
- psubd_r2r(mm5, mm4); /* 5 ; a3-b3 a2-b2\r */
-\r
- psrad_i2r(SHIFT_INV_ROW, mm4); /* y4=a3-b3 y5=a2-b2\r */
- psrad_i2r(SHIFT_INV_ROW, mm0); /* y3=a3+b3 y2=a2+b2\r */
-\r
- packssdw_r2r(mm3, mm4); /* 3 ; y6 y7 y4 y5\r */
-\r
- packssdw_r2r(mm0, mm1); /* 0 ; y3 y2 y1 y0\r */
- movq_r2r(mm4, mm7); /* 7 ; y6 y7 y4 y5\r */
-\r
- psrld_i2r(16, mm4); /* 0 y6 0 y4\r */
-\r
- movq_r2m(mm1, *(out)); /* 1 ; save y3 y2 y1 y0\r */
- pslld_i2r(16, mm7); /* y7 0 y5 0\r */
-\r
- por_r2r(mm4, mm7); /* 4 ; y7 y6 y5 y4\r */
-\r
- /* begin processing row 1\r */
- movq_r2m(mm7, *(out+4)); /* 7 ; save y7 y6 y5 y4\r */
-\r
- inptr += 8;\r
- out += 8;\r
- }\r
- \r
-\r
- /* done with the iDCT row-transformation\r */
-\r
- /* now we have to transpose the output 8x8 matrix\r */
- /* 8x8 (OUT) -> 8x8't' (IN)\r */
- /* the transposition is implemented as 4 sub-operations.\r */
- /* 1) transpose upper-left quad\r */
- /* 2) transpose lower-right quad\r */
- /* 3) transpose lower-left quad\r */
- /* 4) transpose upper-right quad\r */
-\r
- \r
- /* mm0 = 1st row [ A B C D ] row1\r */
- /* mm1 = 2nd row [ E F G H ] 2\r */
- /* mm2 = 3rd row [ I J K L ] 3\r */
- /* mm3 = 4th row [ M N O P ] 4\r */
-\r
- /* 1) transpose upper-left quad\r */
- out = &qwTemp[0];\r
-\r
- movq_m2r(*(out + ROW_STRIDE * 0), mm0);\r
-\r
- movq_m2r(*(out + ROW_STRIDE * 1), mm1);\r
- movq_r2r(mm0, mm4); /* mm4 = copy of row1[A B C D]\r */
- \r
- movq_m2r(*(out + ROW_STRIDE * 2), mm2);\r
- punpcklwd_r2r(mm1, mm0); /* mm0 = [ 0 4 1 5]\r */
- \r
- movq_m2r(*(out + ROW_STRIDE * 3), mm3);\r
- punpckhwd_r2r(mm1, mm4); /* mm4 = [ 2 6 3 7]\r */
-\r
- movq_r2r(mm2, mm6);\r
- punpcklwd_r2r(mm3, mm2); /* mm2 = [ 8 12 9 13]\r */
-\r
- punpckhwd_r2r(mm3, mm6); /* mm6 = 10 14 11 15]\r */
- movq_r2r(mm0, mm1); /* mm1 = [ 0 4 1 5]\r */
-\r
- inptr = blk;\r
-\r
- punpckldq_r2r(mm2, mm0); /* final result mm0 = row1 [0 4 8 12]\r */
-\r
- movq_r2r(mm4, mm3); /* mm3 = [ 2 6 3 7]\r */
- punpckhdq_r2r(mm2, mm1); /* mm1 = final result mm1 = row2 [1 5 9 13]\r */
-\r
- movq_r2m(mm0, *(inptr + ROW_STRIDE * 0)); /* store row 1\r */
- punpckldq_r2r(mm6, mm4); /* final result mm4 = row3 [2 6 10 14]\r */
-\r
+\r\rstatic void \r
+idct_mmx32_rows (short *blk)
+{ /* transform all 8 rows of 8x8 iDCT block\r */
+ \rint x;
+ \rshort qwTemp[64];
+ \rshort *out = &qwTemp[0];
+ \rshort *inptr = blk;
+
+ \r
+ /* this subroutine performs two operations\r */
+ /* 1) iDCT row transform\r */
+ /* for( i = 0; i < 8; ++ i)\r */
+ /* DCT_8_INV_ROW_1( blk[i*8], qwTemp[i] );\r */
+ /*\r */
+ /* 2) transpose the matrix (which was stored in qwTemp[])\r */
+ /* qwTemp[] -> [8x8 matrix transpose] -> blk[]\r */
+ \rfor (x = 0; x < 8; x++) { /* transform one row per iteration\r */
+ movq_m2r (*(inptr), mm0); /* 0 ; x3 x2 x1 x0\r */
+ \rmovq_m2r (*(inptr + 4), mm1); /* 1 ; x7 x6 x5 x4\r */
+ movq_r2r (mm0, mm2); /* 2 ; x3 x2 x1 x0\r */
+ \rmovq_m2r (*(tab_i_01234567), mm3); /* 3 ; w06 w04 w02 w00\r */
+ punpcklwd_r2r (mm1, mm0); /* x5 x1 x4 x0\r */
+ \r
+ /* ----------\r */
+ movq_r2r (mm0, mm5); /* 5 ; x5 x1 x4 x0\r */
+ punpckldq_r2r (mm0, mm0); /* x4 x0 x4 x0\r */
+ \rmovq_m2r (*(tab_i_01234567 + 4), mm4); /* 4 ; w07 w05 w03 w01\r */
+ punpckhwd_r2r (mm1, mm2); /* 1 ; x7 x3 x6 x2\r */
+ \rpmaddwd_r2r (mm0, mm3); /* x4*w06+x0*w04 x4*w02+x0*w00\r */
+ movq_r2r (mm2, mm6); /* 6 ; x7 x3 x6 x2\r */
+ \rmovq_m2r (*(tab_i_01234567 + 16), mm1); /* 1 ; w22 w20 w18 w16\r */
+ punpckldq_r2r (mm2, mm2); /* x6 x2 x6 x2\r */
+ \rpmaddwd_r2r (mm2, mm4); /* x6*w07+x2*w05 x6*w03+x2*w01\r */
+ punpckhdq_r2r (mm5, mm5); /* x5 x1 x5 x1\r */
+ \rpmaddwd_m2r (*(tab_i_01234567 + 8), mm0); /* x4*w14+x0*w12 x4*w10+x0*w08\r */
+ punpckhdq_r2r (mm6, mm6); /* x7 x3 x7 x3\r */
+ \rmovq_m2r (*(tab_i_01234567 + 20), mm7); /* 7 ; w23 w21 w19 w17\r */
+ pmaddwd_r2r (mm5, mm1); /* x5*w22+x1*w20 x5*w18+x1*w16\r */
+ \rpaddd_m2r (*(r_inv_row), mm3); /* +rounder\r */
+ pmaddwd_r2r (mm6, mm7); /* x7*w23+x3*w21 x7*w19+x3*w17\r */
+ \rpmaddwd_m2r (*(tab_i_01234567 + 12), mm2); /* x6*w15+x2*w13 x6*w11+x2*w09\r */
+ paddd_r2r (mm4, mm3); /* 4 ; a1=sum(even1) a0=sum(even0)\r */
+ \rpmaddwd_m2r (*(tab_i_01234567 + 24), mm5); /* x5*w30+x1*w28 x5*w26+x1*w24\r */
+ movq_r2r (mm3, mm4); /* 4 ; a1 a0\r */
+ \rpmaddwd_m2r (*(tab_i_01234567 + 28), mm6); /* x7*w31+x3*w29 x7*w27+x3*w25\r */
+ paddd_r2r (mm7, mm1); /* 7 ; b1=sum(odd1) b0=sum(odd0)\r */
+ \rpaddd_m2r (*(r_inv_row), mm0); /* +rounder\r */
+ psubd_r2r (mm1, mm3); /* a1-b1 a0-b0\r */
+ \rpsrad_i2r (SHIFT_INV_ROW, mm3); /* y6=a1-b1 y7=a0-b0\r */
+ paddd_r2r (mm4, mm1); /* 4 ; a1+b1 a0+b0\r */
+ \rpaddd_r2r (mm2, mm0); /* 2 ; a3=sum(even3) a2=sum(even2)\r */
+ psrad_i2r (SHIFT_INV_ROW, mm1); /* y1=a1+b1 y0=a0+b0\r */
+ \rpaddd_r2r (mm6, mm5); /* 6 ; b3=sum(odd3) b2=sum(odd2)\r */
+ movq_r2r (mm0, mm4); /* 4 ; a3 a2\r */
+ \rpaddd_r2r (mm5, mm0); /* a3+b3 a2+b2\r */
+ psubd_r2r (mm5, mm4); /* 5 ; a3-b3 a2-b2\r */
+ \rpsrad_i2r (SHIFT_INV_ROW, mm4); /* y4=a3-b3 y5=a2-b2\r */
+ psrad_i2r (SHIFT_INV_ROW, mm0); /* y3=a3+b3 y2=a2+b2\r */
+ \rpackssdw_r2r (mm3, mm4); /* 3 ; y6 y7 y4 y5\r */
+ \rpackssdw_r2r (mm0, mm1); /* 0 ; y3 y2 y1 y0\r */
+ movq_r2r (mm4, mm7); /* 7 ; y6 y7 y4 y5\r */
+ \rpsrld_i2r (16, mm4); /* 0 y6 0 y4\r */
+ \rmovq_r2m (mm1, *(out)); /* 1 ; save y3 y2 y1 y0\r */
+ pslld_i2r (16, mm7); /* y7 0 y5 0\r */
+ \rpor_r2r (mm4, mm7); /* 4 ; y7 y6 y5 y4\r */
+ \r
+ /* begin processing row 1\r */
+ movq_r2m (mm7, *(out + 4)); /* 7 ; save y7 y6 y5 y4\r */
+ \rinptr += 8;
+ \rout += 8;
+ \r}
+ \r\r\r
+ /* done with the iDCT row-transformation\r */
+ \r
+ /* now we have to transpose the output 8x8 matrix\r */
+ /* 8x8 (OUT) -> 8x8't' (IN)\r */
+ /* the transposition is implemented as 4 sub-operations.\r */
+ /* 1) transpose upper-left quad\r */
+ /* 2) transpose lower-right quad\r */
+ /* 3) transpose lower-left quad\r */
+ /* 4) transpose upper-right quad\r */
+ \r\r
+ /* mm0 = 1st row [ A B C D ] row1\r */
+ /* mm1 = 2nd row [ E F G H ] 2\r */
+ /* mm2 = 3rd row [ I J K L ] 3\r */
+ /* mm3 = 4th row [ M N O P ] 4\r */
+ \r
+ /* 1) transpose upper-left quad\r */
+ out = &qwTemp[0];
+ \r\rmovq_m2r (*(out + ROW_STRIDE * 0), mm0);
+ \r\rmovq_m2r (*(out + ROW_STRIDE * 1), mm1);
+ \rmovq_r2r (mm0, mm4); /* mm4 = copy of row1[A B C D]\r */
+ \rmovq_m2r (*(out + ROW_STRIDE * 2), mm2);
+ \rpunpcklwd_r2r (mm1, mm0); /* mm0 = [ 0 4 1 5]\r */
+ \rmovq_m2r (*(out + ROW_STRIDE * 3), mm3);
+ \rpunpckhwd_r2r (mm1, mm4); /* mm4 = [ 2 6 3 7]\r */
+ \rmovq_r2r (mm2, mm6);
+ \rpunpcklwd_r2r (mm3, mm2); /* mm2 = [ 8 12 9 13]\r */
+ \rpunpckhwd_r2r (mm3, mm6); /* mm6 = 10 14 11 15]\r */
+ movq_r2r (mm0, mm1); /* mm1 = [ 0 4 1 5]\r */
+ \rinptr = blk;
+ \r\rpunpckldq_r2r (mm2, mm0); /* final result mm0 = row1 [0 4 8 12]\r */
+ \rmovq_r2r (mm4, mm3); /* mm3 = [ 2 6 3 7]\r */
+ punpckhdq_r2r (mm2, mm1); /* mm1 = final result mm1 = row2 [1 5 9 13]\r */
+ \rmovq_r2m (mm0, *(inptr + ROW_STRIDE * 0)); /* store row 1\r */
+ punpckldq_r2r (mm6, mm4); /* final result mm4 = row3 [2 6 10 14]\r */
+ \r
/* begin reading next quadrant (lower-right)\r */
- movq_m2r(*(out + ROW_STRIDE*4 + 4), mm0); \r
- punpckhdq_r2r(mm6, mm3); /* final result mm3 = row4 [3 7 11 15]\r */
-\r
- movq_r2m(mm4, *(inptr + ROW_STRIDE * 2)); /* store row 3\r */
- movq_r2r(mm0, mm4); /* mm4 = copy of row1[A B C D]\r */
-\r
- movq_r2m(mm1, *(inptr + ROW_STRIDE * 1)); /* store row 2\r */
-\r
- movq_m2r(*(out + ROW_STRIDE*5 + 4), mm1);\r
-\r
- movq_r2m(mm3, *(inptr + ROW_STRIDE * 3)); /* store row 4\r */
- punpcklwd_r2r(mm1, mm0); /* mm0 = [ 0 4 1 5]\r */
-\r
- /* 2) transpose lower-right quadrant\r */
-\r
+ movq_m2r (*(out + ROW_STRIDE * 4 + 4), mm0);
+ \rpunpckhdq_r2r (mm6, mm3); /* final result mm3 = row4 [3 7 11 15]\r */
+ \rmovq_r2m (mm4, *(inptr + ROW_STRIDE * 2)); /* store row 3\r */
+ movq_r2r (mm0, mm4); /* mm4 = copy of row1[A B C D]\r */
+ \rmovq_r2m (mm1, *(inptr + ROW_STRIDE * 1)); /* store row 2\r */
+ \rmovq_m2r (*(out + ROW_STRIDE * 5 + 4), mm1);
+ \r\rmovq_r2m (mm3, *(inptr + ROW_STRIDE * 3)); /* store row 4\r */
+ punpcklwd_r2r (mm1, mm0); /* mm0 = [ 0 4 1 5]\r */
+ \r
+ /* 2) transpose lower-right quadrant\r */
+ \r
/* movq mm0, qword ptr [OUT + ROW_STRIDE*4 + 8]\r */
-\r
+ \r
/* movq mm1, qword ptr [OUT + ROW_STRIDE*5 + 8]\r */
/* movq mm4, mm0; // mm4 = copy of row1[A B C D]\r */
- \r
- movq_m2r(*(out + ROW_STRIDE*6 + 4), mm2);\r
-/* punpcklwd mm0, mm1; // mm0 = [ 0 4 1 5]\r */
- punpckhwd_r2r(mm1, mm4); /* mm4 = [ 2 6 3 7]\r */
- \r
- movq_m2r(*(out + ROW_STRIDE*7 + 4), mm3);\r
- movq_r2r(mm2, mm6);\r
-\r
- punpcklwd_r2r(mm3, mm2); /* mm2 = [ 8 12 9 13]\r */
- movq_r2r(mm0, mm1); /* mm1 = [ 0 4 1 5]\r */
-\r
- punpckhwd_r2r(mm3, mm6); /* mm6 = 10 14 11 15]\r */
- movq_r2r(mm4, mm3); /* mm3 = [ 2 6 3 7]\r */
-\r
- punpckldq_r2r(mm2, mm0); /* final result mm0 = row1 [0 4 8 12]\r */
-\r
- punpckhdq_r2r(mm2, mm1); /* mm1 = final result mm1 = row2 [1 5 9 13]\r */
- ; /* slot\r */
-\r
- movq_r2m(mm0, *(inptr + ROW_STRIDE*4 + 4)); /* store row 1\r */
- punpckldq_r2r(mm6, mm4); /* final result mm4 = row3 [2 6 10 14]\r */
-\r
- movq_m2r(*(out + ROW_STRIDE * 4 ), mm0);\r
- punpckhdq_r2r(mm6, mm3); /* final result mm3 = row4 [3 7 11 15]\r */
+ \rmovq_m2r (*(out + ROW_STRIDE * 6 + 4), mm2);
\r
- movq_r2m(mm4, *(inptr + ROW_STRIDE*6 + 4)); /* store row 3\r */
- movq_r2r(mm0, mm4); /* mm4 = copy of row1[A B C D]\r */
-\r
- movq_r2m(mm1, *(inptr + ROW_STRIDE*5 + 4)); /* store row 2\r */
- ; /* slot\r */
+/* punpcklwd mm0, mm1; // mm0 = [ 0 4 1 5]\r */
+ punpckhwd_r2r (mm1, mm4); /* mm4 = [ 2 6 3 7]\r */
+ \rmovq_m2r (*(out + ROW_STRIDE * 7 + 4), mm3);
+ \rmovq_r2r (mm2, mm6);
+ \r\rpunpcklwd_r2r (mm3, mm2); /* mm2 = [ 8 12 9 13]\r */
+ movq_r2r (mm0, mm1); /* mm1 = [ 0 4 1 5]\r */
+ \rpunpckhwd_r2r (mm3, mm6); /* mm6 = 10 14 11 15]\r */
+ movq_r2r (mm4, mm3); /* mm3 = [ 2 6 3 7]\r */
+ \rpunpckldq_r2r (mm2, mm0); /* final result mm0 = row1 [0 4 8 12]\r */
+ \rpunpckhdq_r2r (mm2, mm1); /* mm1 = final result mm1 = row2 [1 5 9 13]\r */
+ ; /* slot\r */
+ \rmovq_r2m (mm0, *(inptr + ROW_STRIDE * 4 + 4)); /* store row 1\r */
+ punpckldq_r2r (mm6, mm4); /* final result mm4 = row3 [2 6 10 14]\r */
+ \rmovq_m2r (*(out + ROW_STRIDE * 4), mm0);
+ \rpunpckhdq_r2r (mm6, mm3); /* final result mm3 = row4 [3 7 11 15]\r */
+ \rmovq_r2m (mm4, *(inptr + ROW_STRIDE * 6 + 4)); /* store row 3\r */
+ movq_r2r (mm0, mm4); /* mm4 = copy of row1[A B C D]\r */
+ \rmovq_r2m (mm1, *(inptr + ROW_STRIDE * 5 + 4)); /* store row 2\r */
+ ; /* slot\r */
+ \rmovq_m2r (*(out + ROW_STRIDE * 5), mm1);
+ \r; /* slot\r */
+ \rmovq_r2m (mm3, *(inptr + ROW_STRIDE * 7 + 4)); /* store row 4\r */
+ punpcklwd_r2r (mm1, mm0); /* mm0 = [ 0 4 1 5]\r */
\r
- movq_m2r(*(out + ROW_STRIDE * 5 ), mm1);\r
- ; /* slot\r */
-\r
- movq_r2m(mm3, *(inptr + ROW_STRIDE*7 + 4)); /* store row 4\r */
- punpcklwd_r2r(mm1, mm0); /* mm0 = [ 0 4 1 5]\r */
-\r
- /* 3) transpose lower-left\r */
+ /* 3) transpose lower-left\r */
/* movq mm0, qword ptr [OUT + ROW_STRIDE * 4 ]\r */
-\r
+ \r
/* movq mm1, qword ptr [OUT + ROW_STRIDE * 5 ]\r */
/* movq mm4, mm0; // mm4 = copy of row1[A B C D]\r */
- \r
- movq_m2r(*(out + ROW_STRIDE * 6 ), mm2);\r
+ \rmovq_m2r (*(out + ROW_STRIDE * 6), mm2);
+ \r
/* punpcklwd mm0, mm1; // mm0 = [ 0 4 1 5]\r */
- punpckhwd_r2r(mm1, mm4); /* mm4 = [ 2 6 3 7]\r */
- \r
- movq_m2r(*(out + ROW_STRIDE * 7 ), mm3);\r
- movq_r2r(mm2, mm6);\r
-\r
- punpcklwd_r2r(mm3, mm2); /* mm2 = [ 8 12 9 13]\r */
- movq_r2r(mm0, mm1); /* mm1 = [ 0 4 1 5]\r */
-\r
- punpckhwd_r2r(mm3, mm6); /* mm6 = 10 14 11 15]\r */
- movq_r2r(mm4, mm3); /* mm3 = [ 2 6 3 7]\r */
-\r
- punpckldq_r2r(mm2, mm0); /* final result mm0 = row1 [0 4 8 12]\r */
-\r
- punpckhdq_r2r(mm2, mm1); /* mm1 = final result mm1 = row2 [1 5 9 13]\r */
- ;/*slot\r */
-\r
- movq_r2m(mm0, *(inptr + ROW_STRIDE * 0 + 4 )); /* store row 1\r */
- punpckldq_r2r(mm6, mm4); /* final result mm4 = row3 [2 6 10 14]\r */
-\r
+ punpckhwd_r2r (mm1, mm4); /* mm4 = [ 2 6 3 7]\r */
+ \rmovq_m2r (*(out + ROW_STRIDE * 7), mm3);
+ \rmovq_r2r (mm2, mm6);
+ \r\rpunpcklwd_r2r (mm3, mm2); /* mm2 = [ 8 12 9 13]\r */
+ movq_r2r (mm0, mm1); /* mm1 = [ 0 4 1 5]\r */
+ \rpunpckhwd_r2r (mm3, mm6); /* mm6 = 10 14 11 15]\r */
+ movq_r2r (mm4, mm3); /* mm3 = [ 2 6 3 7]\r */
+ \rpunpckldq_r2r (mm2, mm0); /* final result mm0 = row1 [0 4 8 12]\r */
+ \rpunpckhdq_r2r (mm2, mm1); /* mm1 = final result mm1 = row2 [1 5 9 13]\r */
+ ; /*slot\r */
+ \rmovq_r2m (mm0, *(inptr + ROW_STRIDE * 0 + 4)); /* store row 1\r */
+ punpckldq_r2r (mm6, mm4); /* final result mm4 = row3 [2 6 10 14]\r */
+ \r
/* begin reading next quadrant (upper-right)\r */
- movq_m2r(*(out + ROW_STRIDE*0 + 4), mm0);\r
- punpckhdq_r2r(mm6, mm3); /* final result mm3 = row4 [3 7 11 15]\r */
-\r
- movq_r2m(mm4, *(inptr + ROW_STRIDE * 2 + 4)); /* store row 3\r */
- movq_r2r(mm0, mm4); /* mm4 = copy of row1[A B C D]\r */
-\r
- movq_r2m(mm1, *(inptr + ROW_STRIDE * 1 + 4)); /* store row 2\r */
- movq_m2r(*(out + ROW_STRIDE*1 + 4), mm1);\r
-\r
- movq_r2m(mm3, *(inptr + ROW_STRIDE * 3 + 4)); /* store row 4\r */
- punpcklwd_r2r(mm1, mm0); /* mm0 = [ 0 4 1 5]\r */
-\r
-\r
- /* 2) transpose lower-right quadrant\r */
-\r
+ movq_m2r (*(out + ROW_STRIDE * 0 + 4), mm0);
+ \rpunpckhdq_r2r (mm6, mm3); /* final result mm3 = row4 [3 7 11 15]\r */
+ \rmovq_r2m (mm4, *(inptr + ROW_STRIDE * 2 + 4)); /* store row 3\r */
+ movq_r2r (mm0, mm4); /* mm4 = copy of row1[A B C D]\r */
+ \rmovq_r2m (mm1, *(inptr + ROW_STRIDE * 1 + 4)); /* store row 2\r */
+ movq_m2r (*(out + ROW_STRIDE * 1 + 4), mm1);
+ \r\rmovq_r2m (mm3, *(inptr + ROW_STRIDE * 3 + 4)); /* store row 4\r */
+ punpcklwd_r2r (mm1, mm0); /* mm0 = [ 0 4 1 5]\r */
+ \r\r
+ /* 2) transpose lower-right quadrant\r */
+ \r
/* movq mm0, qword ptr [OUT + ROW_STRIDE*4 + 8]\r */
-\r
+ \r
/* movq mm1, qword ptr [OUT + ROW_STRIDE*5 + 8]\r */
/* movq mm4, mm0; // mm4 = copy of row1[A B C D]\r */
- \r
- movq_m2r(*(out + ROW_STRIDE*2 + 4), mm2);\r
+ \rmovq_m2r (*(out + ROW_STRIDE * 2 + 4), mm2);
+ \r
/* punpcklwd mm0, mm1; // mm0 = [ 0 4 1 5]\r */
- punpckhwd_r2r(mm1, mm4); /* mm4 = [ 2 6 3 7]\r */
- \r
- movq_m2r(*(out + ROW_STRIDE*3 + 4), mm3);\r
- movq_r2r(mm2, mm6);\r
-\r
- punpcklwd_r2r(mm3, mm2); /* mm2 = [ 8 12 9 13]\r */
- movq_r2r(mm0, mm1); /* mm1 = [ 0 4 1 5]\r */
-\r
- punpckhwd_r2r(mm3, mm6); /* mm6 = 10 14 11 15]\r */
- movq_r2r(mm4, mm3); /* mm3 = [ 2 6 3 7]\r */
-\r
- punpckldq_r2r(mm2, mm0); /* final result mm0 = row1 [0 4 8 12]\r */
-\r
- punpckhdq_r2r(mm2, mm1); /* mm1 = final result mm1 = row2 [1 5 9 13]\r */
- ; /* slot\r */
-\r
- movq_r2m(mm0, *(inptr + ROW_STRIDE*4)); /* store row 1\r */
- punpckldq_r2r(mm6, mm4); /* final result mm4 = row3 [2 6 10 14]\r */
-\r
- movq_r2m(mm1, *(inptr + ROW_STRIDE*5)); /* store row 2\r */
- punpckhdq_r2r(mm6, mm3); /* final result mm3 = row4 [3 7 11 15]\r */
-\r
- movq_r2m(mm4, *(inptr + ROW_STRIDE*6)); /* store row 3\r */
- ; /* slot\r */
-\r
- movq_r2m(mm3, *(inptr + ROW_STRIDE*7)); /* store row 4\r */
- ; /* slot\r */
- \r
-}\r
-\r
-\r
-static void \r
-idct_mmx32_cols( short *blk ) /* transform all 8 cols of 8x8 iDCT block\r */
-{\r
- int x;\r
- short *inptr = blk;\r
-\r
- /* Despite the function's name, the matrix is transformed\r */
- /* row by row. This function is identical to idct_mmx32_rows(),\r */
- /* except for the SHIFT amount and ROUND_INV amount.\r */
-\r
- /* this subroutine performs two operations\r */
- /* 1) iDCT row transform\r */
- /* for( i = 0; i < 8; ++ i)\r */
- /* DCT_8_INV_ROW_1( blk[i*8], qwTemp[i] );\r */
- /*\r */
- /* 2) transpose the matrix (which was stored in qwTemp[])\r */
- /* qwTemp[] -> [8x8 matrix transpose] -> blk[]\r */
-\r
-\r
- for (x=0; x<8; x++) { /* transform one row per iteration\r */
-\r
- movq_m2r(*(inptr), mm0); /* 0 ; x3 x2 x1 x0\r */
-\r
- movq_m2r(*(inptr+4), mm1); /* 1 ; x7 x6 x5 x4\r */
- movq_r2r(mm0, mm2); /* 2 ; x3 x2 x1 x0\r */
-\r
- movq_m2r(*(tab_i_01234567), mm3); /* 3 ; w06 w04 w02 w00\r */
- punpcklwd_r2r(mm1, mm0); /* x5 x1 x4 x0\r */
-\r
+ punpckhwd_r2r (mm1, mm4); /* mm4 = [ 2 6 3 7]\r */
+ \rmovq_m2r (*(out + ROW_STRIDE * 3 + 4), mm3);
+ \rmovq_r2r (mm2, mm6);
+ \r\rpunpcklwd_r2r (mm3, mm2); /* mm2 = [ 8 12 9 13]\r */
+ movq_r2r (mm0, mm1); /* mm1 = [ 0 4 1 5]\r */
+ \rpunpckhwd_r2r (mm3, mm6); /* mm6 = 10 14 11 15]\r */
+ movq_r2r (mm4, mm3); /* mm3 = [ 2 6 3 7]\r */
+ \rpunpckldq_r2r (mm2, mm0); /* final result mm0 = row1 [0 4 8 12]\r */
+ \rpunpckhdq_r2r (mm2, mm1); /* mm1 = final result mm1 = row2 [1 5 9 13]\r */
+ ; /* slot\r */
+ \rmovq_r2m (mm0, *(inptr + ROW_STRIDE * 4)); /* store row 1\r */
+ punpckldq_r2r (mm6, mm4); /* final result mm4 = row3 [2 6 10 14]\r */
+ \rmovq_r2m (mm1, *(inptr + ROW_STRIDE * 5)); /* store row 2\r */
+ punpckhdq_r2r (mm6, mm3); /* final result mm3 = row4 [3 7 11 15]\r */
+ \rmovq_r2m (mm4, *(inptr + ROW_STRIDE * 6)); /* store row 3\r */
+ ; /* slot\r */
+ \rmovq_r2m (mm3, *(inptr + ROW_STRIDE * 7)); /* store row 4\r */
+ ; /* slot\r */
+\r}
+\r\r\rstatic void \r
+idct_mmx32_cols (short *blk)
+{ /* transform all 8 cols of 8x8 iDCT block\r */
+ \rint x;
+ \rshort *inptr = blk;
+
+ \r\r
+ /* Despite the function's name, the matrix is transformed\r */
+ /* row by row. This function is identical to idct_mmx32_rows(),\r */
+ /* except for the SHIFT amount and ROUND_INV amount.\r */
+ \r
+ /* this subroutine performs two operations\r */
+ /* 1) iDCT row transform\r */
+ /* for( i = 0; i < 8; ++ i)\r */
+ /* DCT_8_INV_ROW_1( blk[i*8], qwTemp[i] );\r */
+ /*\r */
+ /* 2) transpose the matrix (which was stored in qwTemp[])\r */
+ /* qwTemp[] -> [8x8 matrix transpose] -> blk[]\r */
+ \r\rfor (x = 0; x < 8; x++) { /* transform one row per iteration\r */
+ \rmovq_m2r (*(inptr), mm0); /* 0 ; x3 x2 x1 x0\r */
+ \rmovq_m2r (*(inptr + 4), mm1); /* 1 ; x7 x6 x5 x4\r */
+ movq_r2r (mm0, mm2); /* 2 ; x3 x2 x1 x0\r */
+ \rmovq_m2r (*(tab_i_01234567), mm3); /* 3 ; w06 w04 w02 w00\r */
+ punpcklwd_r2r (mm1, mm0); /* x5 x1 x4 x0\r */
+ \r
/* ----------\r */
- movq_r2r(mm0, mm5); /* 5 ; x5 x1 x4 x0\r */
- punpckldq_r2r(mm0, mm0); /* x4 x0 x4 x0\r */
-\r
- movq_m2r(*(tab_i_01234567+4), mm4); /* 4 ; w07 w05 w03 w01\r */
- punpckhwd_r2r(mm1, mm2); /* 1 ; x7 x3 x6 x2\r */
-\r
- pmaddwd_r2r(mm0, mm3); /* x4*w06+x0*w04 x4*w02+x0*w00\r */
- movq_r2r(mm2, mm6); /* 6 ; x7 x3 x6 x2\r */
-\r
- movq_m2r(*(tab_i_01234567+16), mm1);/* 1 ; w22 w20 w18 w16\r */
- punpckldq_r2r(mm2, mm2); /* x6 x2 x6 x2\r */
-\r
- pmaddwd_r2r(mm2, mm4); /* x6*w07+x2*w05 x6*w03+x2*w01\r */
- punpckhdq_r2r(mm5, mm5); /* x5 x1 x5 x1\r */
-\r
- pmaddwd_m2r(*(tab_i_01234567+8), mm0);/* x4*w14+x0*w12 x4*w10+x0*w08\r */
- punpckhdq_r2r(mm6, mm6); /* x7 x3 x7 x3\r */
-\r
- movq_m2r(*(tab_i_01234567+20), mm7);/* 7 ; w23 w21 w19 w17\r */
- pmaddwd_r2r(mm5, mm1); /* x5*w22+x1*w20 x5*w18+x1*w16\r */
-\r
- paddd_m2r(*(r_inv_col), mm3);/* +rounder\r */
- pmaddwd_r2r(mm6, mm7); /* x7*w23+x3*w21 x7*w19+x3*w17\r */
-\r
- pmaddwd_m2r(*(tab_i_01234567+12), mm2);/* x6*w15+x2*w13 x6*w11+x2*w09\r */
- paddd_r2r(mm4, mm3); /* 4 ; a1=sum(even1) a0=sum(even0)\r */
-\r
- pmaddwd_m2r(*(tab_i_01234567+24), mm5);/* x5*w30+x1*w28 x5*w26+x1*w24\r */
- movq_r2r(mm3, mm4); /* 4 ; a1 a0\r */
-\r
- pmaddwd_m2r(*(tab_i_01234567+28), mm6);/* x7*w31+x3*w29 x7*w27+x3*w25\r */
- paddd_r2r(mm7, mm1); /* 7 ; b1=sum(odd1) b0=sum(odd0)\r */
-\r
- paddd_m2r(*(r_inv_col), mm0);/* +rounder\r */
- psubd_r2r(mm1, mm3); /* a1-b1 a0-b0\r */
-\r
- psrad_i2r(SHIFT_INV_COL, mm3); /* y6=a1-b1 y7=a0-b0\r */
- paddd_r2r(mm4, mm1); /* 4 ; a1+b1 a0+b0\r */
-\r
- paddd_r2r(mm2, mm0); /* 2 ; a3=sum(even3) a2=sum(even2)\r */
- psrad_i2r(SHIFT_INV_COL, mm1); /* y1=a1+b1 y0=a0+b0\r */
-\r
- paddd_r2r(mm6, mm5); /* 6 ; b3=sum(odd3) b2=sum(odd2)\r */
- movq_r2r(mm0, mm4); /* 4 ; a3 a2\r */
-\r
- paddd_r2r(mm5, mm0); /* a3+b3 a2+b2\r */
- psubd_r2r(mm5, mm4); /* 5 ; a3-b3 a2-b2\r */
-\r
-\r
- psrad_i2r(SHIFT_INV_COL, mm4); /* y4=a3-b3 y5=a2-b2\r */
- psrad_i2r(SHIFT_INV_COL, mm0); /* y3=a3+b3 y2=a2+b2\r */
-\r
- packssdw_r2r(mm3, mm4); /* 3 ; y6 y7 y4 y5\r */
-\r
- packssdw_r2r(mm0, mm1); /* 0 ; y3 y2 y1 y0\r */
- movq_r2r(mm4, mm7); /* 7 ; y6 y7 y4 y5\r */
-\r
- psrld_i2r(16, mm4); /* 0 y6 0 y4\r */
-\r
- movq_r2m(mm1, *(inptr)); /* 1 ; save y3 y2 y1 y0\r */
- pslld_i2r(16, mm7); /* y7 0 y5 0\r */
-\r
- por_r2r(mm4, mm7); /* 4 ; y7 y6 y5 y4\r */
-\r
- /* begin processing row 1\r */
- movq_r2m(mm7, *(inptr+4)); /* 7 ; save y7 y6 y5 y4\r */
-\r
- inptr += 8;\r
- }\r
- /* done with the iDCT column-transformation\r */
-}\r
-\r
+ movq_r2r (mm0, mm5); /* 5 ; x5 x1 x4 x0\r */
+ punpckldq_r2r (mm0, mm0); /* x4 x0 x4 x0\r */
+ \rmovq_m2r (*(tab_i_01234567 + 4), mm4); /* 4 ; w07 w05 w03 w01\r */
+ punpckhwd_r2r (mm1, mm2); /* 1 ; x7 x3 x6 x2\r */
+ \rpmaddwd_r2r (mm0, mm3); /* x4*w06+x0*w04 x4*w02+x0*w00\r */
+ movq_r2r (mm2, mm6); /* 6 ; x7 x3 x6 x2\r */
+ \rmovq_m2r (*(tab_i_01234567 + 16), mm1); /* 1 ; w22 w20 w18 w16\r */
+ punpckldq_r2r (mm2, mm2); /* x6 x2 x6 x2\r */
+ \rpmaddwd_r2r (mm2, mm4); /* x6*w07+x2*w05 x6*w03+x2*w01\r */
+ punpckhdq_r2r (mm5, mm5); /* x5 x1 x5 x1\r */
+ \rpmaddwd_m2r (*(tab_i_01234567 + 8), mm0); /* x4*w14+x0*w12 x4*w10+x0*w08\r */
+ punpckhdq_r2r (mm6, mm6); /* x7 x3 x7 x3\r */
+ \rmovq_m2r (*(tab_i_01234567 + 20), mm7); /* 7 ; w23 w21 w19 w17\r */
+ pmaddwd_r2r (mm5, mm1); /* x5*w22+x1*w20 x5*w18+x1*w16\r */
+ \rpaddd_m2r (*(r_inv_col), mm3); /* +rounder\r */
+ pmaddwd_r2r (mm6, mm7); /* x7*w23+x3*w21 x7*w19+x3*w17\r */
+ \rpmaddwd_m2r (*(tab_i_01234567 + 12), mm2); /* x6*w15+x2*w13 x6*w11+x2*w09\r */
+ paddd_r2r (mm4, mm3); /* 4 ; a1=sum(even1) a0=sum(even0)\r */
+ \rpmaddwd_m2r (*(tab_i_01234567 + 24), mm5); /* x5*w30+x1*w28 x5*w26+x1*w24\r */
+ movq_r2r (mm3, mm4); /* 4 ; a1 a0\r */
+ \rpmaddwd_m2r (*(tab_i_01234567 + 28), mm6); /* x7*w31+x3*w29 x7*w27+x3*w25\r */
+ paddd_r2r (mm7, mm1); /* 7 ; b1=sum(odd1) b0=sum(odd0)\r */
+ \rpaddd_m2r (*(r_inv_col), mm0); /* +rounder\r */
+ psubd_r2r (mm1, mm3); /* a1-b1 a0-b0\r */
+ \rpsrad_i2r (SHIFT_INV_COL, mm3); /* y6=a1-b1 y7=a0-b0\r */
+ paddd_r2r (mm4, mm1); /* 4 ; a1+b1 a0+b0\r */
+ \rpaddd_r2r (mm2, mm0); /* 2 ; a3=sum(even3) a2=sum(even2)\r */
+ psrad_i2r (SHIFT_INV_COL, mm1); /* y1=a1+b1 y0=a0+b0\r */
+ \rpaddd_r2r (mm6, mm5); /* 6 ; b3=sum(odd3) b2=sum(odd2)\r */
+ movq_r2r (mm0, mm4); /* 4 ; a3 a2\r */
+ \rpaddd_r2r (mm5, mm0); /* a3+b3 a2+b2\r */
+ psubd_r2r (mm5, mm4); /* 5 ; a3-b3 a2-b2\r */
+ \r\rpsrad_i2r (SHIFT_INV_COL, mm4); /* y4=a3-b3 y5=a2-b2\r */
+ psrad_i2r (SHIFT_INV_COL, mm0); /* y3=a3+b3 y2=a2+b2\r */
+ \rpackssdw_r2r (mm3, mm4); /* 3 ; y6 y7 y4 y5\r */
+ \rpackssdw_r2r (mm0, mm1); /* 0 ; y3 y2 y1 y0\r */
+ movq_r2r (mm4, mm7); /* 7 ; y6 y7 y4 y5\r */
+ \rpsrld_i2r (16, mm4); /* 0 y6 0 y4\r */
+ \rmovq_r2m (mm1, *(inptr)); /* 1 ; save y3 y2 y1 y0\r */
+ pslld_i2r (16, mm7); /* y7 0 y5 0\r */
+ \rpor_r2r (mm4, mm7); /* 4 ; y7 y6 y5 y4\r */
+ \r
+ /* begin processing row 1\r */
+ movq_r2m (mm7, *(inptr + 4)); /* 7 ; save y7 y6 y5 y4\r */
+ \rinptr += 8;
+ \r}
+ \r
+ /* done with the iDCT column-transformation\r */
+}
+
+\r\r
/* \r */
/* public interface to MMX32 IDCT 8x8 operation\r */
/*\r */
-void\r
-gst_idct_mmx32_idct( short *blk )\r
-{\r
- /* 1) iDCT row transformation\r */
- idct_mmx32_rows( blk ); /* 1) transform iDCT row, and transpose\r */
-\r
- /* 2) iDCT column transformation\r */
- idct_mmx32_cols( blk ); /* 2) transform iDCT row, and transpose\r */
-\r
- emms(); /* restore processor state\r */
- /* all done\r */
-}\r
+void \r
+gst_idct_mmx32_idct (short *blk) \r
+{
+ \r
+ /* 1) iDCT row transformation\r */
+ idct_mmx32_rows (blk); /* 1) transform iDCT row, and transpose\r */
+ \r
+ /* 2) iDCT column transformation\r */
+ idct_mmx32_cols (blk); /* 2) transform iDCT row, and transpose\r */
+ \remms (); /* restore processor state\r */
+ /* all done\r */
+} \r
}
void
-gmi_stream_free (GstMediaInfoStream *stream)
+gmi_stream_free (GstMediaInfoStream * stream)
{
- if (stream->mime) g_free (stream->mime);
+ if (stream->mime)
+ g_free (stream->mime);
/* FIXME: free tracks */
g_free (stream);
}
/* callbacks */
static void
-have_type_callback (GstElement *typefind, guint probability, GstCaps *type, GstMediaInfoPriv *priv)
+have_type_callback (GstElement * typefind, guint probability, GstCaps * type,
+ GstMediaInfoPriv * priv)
{
GstStructure *str;
const gchar *mime;
/* FIXME: this code doesn't yet work, test it later */
#ifdef DONTWORK
- if (strcmp (mime, "application/x-id3") == 0)
- {
+ if (strcmp (mime, "application/x-id3") == 0) {
/* dig a little deeper */
GST_DEBUG ("dealing with id3, digging deeper");
gst_element_set_state (priv->pipeline, GST_STATE_READY);
if (priv->decontainer == NULL)
/* FIXME: signal error */
g_warning ("Couldn't create id3tag");
- if (!gst_element_link_many (priv->source, priv->decontainer, priv->typefind, NULL));
- g_warning ("Couldn't link in id3tag");
+ if (!gst_element_link_many (priv->source, priv->decontainer, priv->typefind,
+ NULL));
+ g_warning ("Couldn't link in id3tag");
if (gst_element_set_state (priv->pipeline, GST_STATE_PLAYING)
- == GST_STATE_FAILURE)
+ == GST_STATE_FAILURE)
g_warning ("Couldn't set to playing");
}
#endif
}
void
-deep_notify_callback (GObject *object, GstObject *origin,
- GParamSpec *pspec, GstMediaInfoPriv *priv)
+deep_notify_callback (GObject * object, GstObject * origin,
+ GParamSpec * pspec, GstMediaInfoPriv * priv)
{
GValue value = { 0, };
/* we only care about pad notifies */
- if (!GST_IS_PAD (origin)) return;
+ if (!GST_IS_PAD (origin))
+ return;
/*
- GST_DEBUG ("DEBUG: deep_notify: have notify of %s from object %s:%s !",
- pspec->name, gst_element_get_name (gst_pad_get_parent (GST_PAD (origin))),
- gst_object_get_name (origin));
- */
- else if (strcmp (pspec->name, "caps") == 0)
- {
+ GST_DEBUG ("DEBUG: deep_notify: have notify of %s from object %s:%s !",
+ pspec->name, gst_element_get_name (gst_pad_get_parent (GST_PAD (origin))),
+ gst_object_get_name (origin));
+ */
+ else if (strcmp (pspec->name, "caps") == 0) {
/* check if we're getting it from fakesink */
- if (GST_IS_PAD (origin) && GST_PAD_PARENT (origin) == priv->fakesink)
- {
+ if (GST_IS_PAD (origin) && GST_PAD_PARENT (origin) == priv->fakesink) {
GST_DEBUG ("have caps on fakesink pad !");
g_value_init (&value, pspec->value_type);
g_object_get_property (G_OBJECT (origin), pspec->name, &value);
priv->format = g_value_peek_pointer (&value);
GST_DEBUG ("caps: %" GST_PTR_FORMAT, priv->format);
- }
- else GST_DEBUG ("ignoring caps on object %s:%s",
- gst_object_get_name (gst_object_get_parent (origin)),
- gst_object_get_name (origin));
- }
- else if (strcmp (pspec->name, "offset") == 0)
- {
+ } else
+ GST_DEBUG ("ignoring caps on object %s:%s",
+ gst_object_get_name (gst_object_get_parent (origin)),
+ gst_object_get_name (origin));
+ } else if (strcmp (pspec->name, "offset") == 0) {
/* we REALLY ignore offsets, we hate them */
}
- //else GST_DEBUG ("ignoring notify of %s", pspec->name);
+ //else GST_DEBUG ("ignoring notify of %s", pspec->name);
}
-typedef struct {
+typedef struct
+{
guint meta;
guint encoded;
} TagFlagScore;
static void
-tag_flag_score (const GstTagList *list, const gchar *tag, gpointer user_data)
+tag_flag_score (const GstTagList * list, const gchar * tag, gpointer user_data)
{
TagFlagScore *score = (TagFlagScore *) user_data;
GstTagFlag flag;
flag = gst_tag_get_flag (tag);
- if (flag == GST_TAG_FLAG_META) score->meta++;
- if (flag == GST_TAG_FLAG_ENCODED) score->encoded++;
+ if (flag == GST_TAG_FLAG_META)
+ score->meta++;
+ if (flag == GST_TAG_FLAG_ENCODED)
+ score->encoded++;
}
void
-found_tag_callback (GObject *pipeline, GstElement *source, GstTagList *tags, GstMediaInfoPriv *priv)
+found_tag_callback (GObject * pipeline, GstElement * source, GstTagList * tags,
+ GstMediaInfoPriv * priv)
{
TagFlagScore score;
gst_tag_list_foreach (tags, tag_flag_score, &score);
- if (score.meta > score.encoded)
- {
+ if (score.meta > score.encoded) {
GST_DEBUG ("found tags from decoder, adding them as metadata");
priv->metadata = gst_tag_list_copy (tags);
- }
- else
- {
+ } else {
GST_DEBUG ("found tags, adding them as streaminfo");
priv->streaminfo = gst_tag_list_copy (tags);
}
}
void
-error_callback (GObject *element, GstElement *source, GError *error, gchar *debug, GstMediaInfoPriv *priv)
+error_callback (GObject * element, GstElement * source, GError * error,
+ gchar * debug, GstMediaInfoPriv * priv)
{
g_print ("ERROR: %s\n", error->message);
g_error_free (error);
/* General GError creation */
static void
-gst_media_info_error_create (GError **error, const gchar *message)
+gst_media_info_error_create (GError ** error, const gchar * message)
{
/* check if caller wanted an error reported */
if (error == NULL)
/* GError creation when element is missing */
static void
-gst_media_info_error_element (const gchar *element, GError **error)
+gst_media_info_error_element (const gchar * element, GError ** error)
{
gchar *message;
message = g_strdup_printf ("The %s element could not be found. "
- "This element is essential for reading. "
- "Please install the right plug-in and verify "
- "that it works by running 'gst-inspect %s'",
- element, element);
+ "This element is essential for reading. "
+ "Please install the right plug-in and verify "
+ "that it works by running 'gst-inspect %s'", element, element);
gst_media_info_error_create (error, message);
g_free (message);
return;
/* initialise priv; done the first time */
gboolean
-gmip_init (GstMediaInfoPriv *priv, GError **error)
+gmip_init (GstMediaInfoPriv * priv, GError ** error)
{
#define GST_MEDIA_INFO_MAKE_OR_ERROR(el, factory, name, error) \
G_STMT_START { \
/* called at the beginning of each use cycle */
/* reset info to a state where it can be used to query for media info */
void
-gmip_reset (GstMediaInfoPriv *priv)
+gmip_reset (GstMediaInfoPriv * priv)
{
#define STRING_RESET(string) \
string = NULL; \
} G_STMT_END
- STRING_RESET(priv->pipeline_desc);
- STRING_RESET(priv->location);
+ STRING_RESET (priv->pipeline_desc);
+ STRING_RESET (priv->location);
#undef STRING_RESET
#define CAPS_RESET(target) \
if (target) gst_caps_free (target); \
target = NULL; \
} G_STMT_END
- CAPS_RESET(priv->type);
- CAPS_RESET(priv->format);
+ CAPS_RESET (priv->type);
+ CAPS_RESET (priv->format);
#undef CAPS_RESET
#define TAGS_RESET(target) \
gst_tag_list_free (target); \
target = NULL; \
} G_STMT_END
- TAGS_RESET(priv->metadata);
- TAGS_RESET(priv->streaminfo);
+ TAGS_RESET (priv->metadata);
+ TAGS_RESET (priv->streaminfo);
#undef TAGS_RESET
- if (priv->stream)
- {
+ if (priv->stream) {
gmi_stream_free (priv->stream);
priv->stream = NULL;
}
/* seek to a track and reset metadata and streaminfo structs */
gboolean
-gmi_seek_to_track (GstMediaInfo *info, long track)
+gmi_seek_to_track (GstMediaInfo * info, long track)
{
GstEvent *event;
GstFormat track_format = 0;
/* FIXME: consider more nicks as "track" */
track_format = gst_format_get_by_nick ("logical_stream");
- if (track_format == 0) return FALSE;
+ if (track_format == 0)
+ return FALSE;
GST_DEBUG ("Track format: %d", track_format);
if (gst_element_set_state (priv->pipeline, GST_STATE_PLAYING)
- == GST_STATE_FAILURE)
+ == GST_STATE_FAILURE)
g_warning ("Couldn't set to play");
g_assert (GST_IS_PAD (info->priv->decoder_pad));
event = gst_event_new_seek (track_format |
- GST_SEEK_METHOD_SET |
- GST_SEEK_FLAG_FLUSH,
- track);
+ GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, track);
res = gst_pad_send_event (info->priv->decoder_pad, event);
- if (!res)
- {
+ if (!res) {
g_warning ("seek to logical track on pad %s:%s failed",
- GST_DEBUG_PAD_NAME(info->priv->decoder_pad));
+ GST_DEBUG_PAD_NAME (info->priv->decoder_pad));
return FALSE;
}
/* clear structs because of the seek */
- if (priv->metadata)
- {
+ if (priv->metadata) {
gst_tag_list_free (priv->metadata);
priv->metadata = NULL;
}
- if (priv->streaminfo)
- {
+ if (priv->streaminfo) {
gst_tag_list_free (priv->streaminfo);
priv->streaminfo = NULL;
}
/* set the mime type on the media info getter */
gboolean
-gmi_set_mime (GstMediaInfo *info, const char *mime)
+gmi_set_mime (GstMediaInfo * info, const char *mime)
{
gchar *desc = NULL;
GError *error = NULL;
/* FIXME: please figure out proper mp3 mimetypes */
if ((strcmp (mime, "application/x-ogg") == 0) ||
(strcmp (mime, "application/ogg") == 0))
- desc = g_strdup_printf ("%s name=source ! oggdemux ! vorbisdec name=decoder ! fakesink name=sink", priv->source_name);
- else if ((strcmp (mime, "audio/mpeg") == 0) ||
- (strcmp (mime, "audio/x-mp3") == 0) ||
- (strcmp (mime, "audio/mp3") == 0) ||
- (strcmp (mime, "application/x-id3") == 0) ||
- (strcmp (mime, "audio/x-id3") == 0))
- desc = g_strdup_printf ("%s name=source ! id3tag ! mad name=decoder ! audio/x-raw-int ! fakesink name=sink", priv->source_name);
- else if ((strcmp (mime, "application/x-flac") == 0) ||
- (strcmp (mime, "audio/x-flac") == 0))
- desc = g_strdup_printf ("%s name=source ! flacdec name=decoder ! audio/x-raw-int ! fakesink name=sink", priv->source_name);
- else if ((strcmp (mime, "audio/wav") == 0) ||
- (strcmp (mime, "audio/x-wav") == 0))
- desc = g_strdup_printf ("%s ! wavparse name=decoder ! audio/x-raw-int ! fakesink name=sink", priv->source_name);
- else if (strcmp (mime, "audio/x-mod") == 0 ||
- strcmp (mime, "audio/x-s3m") == 0 ||
- strcmp (mime, "audio/x-xm") == 0 ||
- strcmp (mime, "audio/x-it") == 0)
- desc = g_strdup_printf ("%s name=source ! modplug name=decoder ! audio/x-raw-int ! fakesink name=sink", priv->source_name);
- else return FALSE;
+ desc =
+ g_strdup_printf
+ ("%s name=source ! oggdemux ! vorbisdec name=decoder ! fakesink name=sink",
+ priv->source_name);
+ else if ((strcmp (mime, "audio/mpeg") == 0)
+ || (strcmp (mime, "audio/x-mp3") == 0)
+ || (strcmp (mime, "audio/mp3") == 0)
+ || (strcmp (mime, "application/x-id3") == 0)
+ || (strcmp (mime, "audio/x-id3") == 0))
+ desc =
+ g_strdup_printf
+ ("%s name=source ! id3tag ! mad name=decoder ! audio/x-raw-int ! fakesink name=sink",
+ priv->source_name);
+ else if ((strcmp (mime, "application/x-flac") == 0)
+ || (strcmp (mime, "audio/x-flac") == 0))
+ desc =
+ g_strdup_printf
+ ("%s name=source ! flacdec name=decoder ! audio/x-raw-int ! fakesink name=sink",
+ priv->source_name);
+ else if ((strcmp (mime, "audio/wav") == 0)
+ || (strcmp (mime, "audio/x-wav") == 0))
+ desc =
+ g_strdup_printf
+ ("%s ! wavparse name=decoder ! audio/x-raw-int ! fakesink name=sink",
+ priv->source_name);
+ else if (strcmp (mime, "audio/x-mod") == 0
+ || strcmp (mime, "audio/x-s3m") == 0 || strcmp (mime, "audio/x-xm") == 0
+ || strcmp (mime, "audio/x-it") == 0)
+ desc =
+ g_strdup_printf
+ ("%s name=source ! modplug name=decoder ! audio/x-raw-int ! fakesink name=sink",
+ priv->source_name);
+ else
+ return FALSE;
GST_DEBUG ("using description %s", desc);
priv->pipeline_desc = desc;
priv->pipeline = gst_parse_launch (desc, &error);
- if (error)
- {
+ if (error) {
g_warning ("Error parsing pipeline description: %s\n", error->message);
g_error_free (error);
return FALSE;
/* get the "decoder" source pad */
priv->decoder_pad = gst_element_get_pad (priv->decoder, "src");
g_assert (GST_IS_PAD (priv->decoder_pad));
- GST_DEBUG ("decoder pad: %s:%s", gst_object_get_name (gst_object_get_parent (GST_OBJECT (priv->decoder_pad))), gst_pad_get_name (priv->decoder_pad));
+ GST_DEBUG ("decoder pad: %s:%s",
+ gst_object_get_name (gst_object_get_parent (GST_OBJECT (priv->
+ decoder_pad))), gst_pad_get_name (priv->decoder_pad));
/* attach notify handler */
g_signal_connect (G_OBJECT (info->priv->pipeline), "deep_notify",
- G_CALLBACK (deep_notify_callback), info->priv);
- g_signal_connect (G_OBJECT (info->priv->pipeline), "found-tag", G_CALLBACK (found_tag_callback), info->priv);
+ G_CALLBACK (deep_notify_callback), info->priv);
+ g_signal_connect (G_OBJECT (info->priv->pipeline), "found-tag",
+ G_CALLBACK (found_tag_callback), info->priv);
g_signal_connect (G_OBJECT (info->priv->pipeline), "error",
- G_CALLBACK (error_callback), info->priv);
+ G_CALLBACK (error_callback), info->priv);
return TRUE;
}
/* clear the decoding pipeline */
void
-gmi_clear_decoder (GstMediaInfo *info)
+gmi_clear_decoder (GstMediaInfo * info)
{
- if (info->priv->pipeline)
- {
- GST_DEBUG("Unreffing pipeline");
+ if (info->priv->pipeline) {
+ GST_DEBUG ("Unreffing pipeline");
gst_object_unref (GST_OBJECT (info->priv->pipeline));
}
info->priv->pipeline = NULL;
/* prepare for typefind, move from NULL to TYPEFIND */
gboolean
-gmip_find_type_pre (GstMediaInfoPriv *priv, GError **error)
+gmip_find_type_pre (GstMediaInfoPriv * priv, GError ** error)
{
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
* just use it through this function only */
priv->pipeline = gst_pipeline_new ("pipeline-typefind");
- if (!GST_IS_PIPELINE (priv->pipeline))
- {
+ if (!GST_IS_PIPELINE (priv->pipeline)) {
gst_media_info_error_create (error, "Internal GStreamer error.");
return FALSE;
}
gst_bin_add (GST_BIN (priv->pipeline), priv->typefind);
GST_MEDIA_INFO_MAKE_OR_ERROR (priv->source, priv->source_name, "source",
- error);
+ error);
g_object_set (G_OBJECT (priv->source), "location", priv->location, NULL);
gst_bin_add (GST_BIN (priv->pipeline), priv->source);
if (!gst_element_link (priv->source, priv->typefind))
g_warning ("Couldn't connect source and typefind\n");
g_signal_connect (G_OBJECT (priv->typefind), "have-type",
- G_CALLBACK (have_type_callback), priv);
+ G_CALLBACK (have_type_callback), priv);
if (gst_element_set_state (priv->pipeline, GST_STATE_PLAYING)
- == GST_STATE_FAILURE)
- {
+ == GST_STATE_FAILURE) {
g_warning ("Couldn't set to play");
return FALSE;
}
/* finish off typefind */
gboolean
-gmip_find_type_post (GstMediaInfoPriv *priv)
+gmip_find_type_post (GstMediaInfoPriv * priv)
{
/*clear up typefind */
gst_element_set_state (priv->pipeline, GST_STATE_READY);
- if (priv->decontainer)
- {
+ if (priv->decontainer) {
gst_element_unlink (priv->source, priv->decontainer);
gst_element_unlink (priv->decontainer, priv->typefind);
gst_bin_remove (GST_BIN (priv->pipeline), priv->decontainer);
- }
- else
- {
+ } else {
gst_element_unlink (priv->source, priv->typefind);
}
gst_bin_remove (GST_BIN (priv->pipeline), priv->typefind);
- if (priv->type == NULL)
- {
+ if (priv->type == NULL) {
g_warning ("iteration ended, type not found !\n");
return FALSE;
}
/* complete version */
gboolean
-gmip_find_type (GstMediaInfoPriv *priv, GError ** error)
+gmip_find_type (GstMediaInfoPriv * priv, GError ** error)
{
if (!gmip_find_type_pre (priv, error))
return FALSE;
GST_DEBUG ("gmip_find_type: iterating");
- while ((priv->type == NULL) &&
- gst_bin_iterate (GST_BIN (priv->pipeline)))
- GMI_DEBUG("+");
- GMI_DEBUG("\n");
+ while ((priv->type == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline)))
+ GMI_DEBUG ("+");
+ GMI_DEBUG ("\n");
return gmip_find_type_post (priv);
}
/* FIXME: why not have these functions work on priv types ? */
gboolean
-gmip_find_stream_pre (GstMediaInfoPriv *priv)
+gmip_find_stream_pre (GstMediaInfoPriv * priv)
{
if (gst_element_set_state (priv->pipeline, GST_STATE_PLAYING)
- == GST_STATE_FAILURE)
- {
+ == GST_STATE_FAILURE) {
g_warning ("Couldn't set to play");
return FALSE;
}
}
gboolean
-gmip_find_stream_post (GstMediaInfoPriv *priv)
+gmip_find_stream_post (GstMediaInfoPriv * priv)
{
GstMediaInfoStream *stream = priv->stream;
const GstFormat *formats;
/* get supported formats on decoder pad */
formats = gst_pad_get_formats (priv->decoder_pad);
- while (*formats)
- {
+ while (*formats) {
const GstFormatDefinition *definition;
format = *formats;
definition = gst_format_get_details (*formats);
GST_DEBUG ("trying to figure out length for format %s", definition->nick);
- res = gst_pad_query (priv->decoder_pad, GST_QUERY_TOTAL,
- &format, &value);
+ res = gst_pad_query (priv->decoder_pad, GST_QUERY_TOTAL, &format, &value);
- if (res)
- {
- switch (format)
- {
- case GST_FORMAT_TIME:
- stream->length_time = value;
- GST_DEBUG (" total %s: %lld", definition->nick, value);
+ if (res) {
+ switch (format) {
+ case GST_FORMAT_TIME:
+ stream->length_time = value;
+ GST_DEBUG (" total %s: %lld", definition->nick, value);
break;
case GST_FORMAT_DEFAULT:
case GST_FORMAT_BYTES:
default:
/* separation is necessary because track_format doesn't resolve to
* int */
- if (format == track_format)
- {
+ if (format == track_format) {
stream->length_tracks = value;
- GST_DEBUG (" total %s: %lld", definition->nick, value);
- }
- else
+ GST_DEBUG (" total %s: %lld", definition->nick, value);
+ } else
GST_DEBUG ("unhandled format %s", definition->nick);
}
- }
- else
+ } else
GST_DEBUG ("query didn't return result for %s", definition->nick);
formats++;
}
- if (stream->length_tracks == 0) stream->length_tracks = 1;
+ if (stream->length_tracks == 0)
+ stream->length_tracks = 1;
/* now get number of bytes from the sink pad to get the bitrate */
format = GST_FORMAT_BYTES;
g_assert (GST_IS_PAD (priv->source_pad));
- res = gst_pad_query (priv->source_pad, GST_QUERY_TOTAL,
- &format, &value);
- if (!res) g_warning ("Failed to query on sink pad !");
+ res = gst_pad_query (priv->source_pad, GST_QUERY_TOTAL, &format, &value);
+ if (!res)
+ g_warning ("Failed to query on sink pad !");
bytes = value;
GST_DEBUG ("bitrate calc: bytes gotten: %ld", bytes);
- if (bytes)
- {
+ if (bytes) {
double seconds = (double) stream->length_time / GST_SECOND;
double bits = bytes * 8;
+
stream->bitrate = (long) (bits / seconds);
}
GST_DEBUG ("moving to STATE_METADATA\n");
/* get properties of complete physical stream
* and return them in pre-alloced stream struct in priv->stream */
gboolean
-gmip_find_stream (GstMediaInfoPriv *priv)
+gmip_find_stream (GstMediaInfoPriv * priv)
{
GST_DEBUG ("mip_find_stream start");
/* iterate until caps are found */
/* FIXME: this should be done through the plugin sending some signal
* that it is ready for queries */
- while (gst_bin_iterate (GST_BIN (priv->pipeline)) &&
- priv->format == NULL)
- ;
+ while (gst_bin_iterate (GST_BIN (priv->pipeline)) && priv->format == NULL);
if (gst_element_set_state (priv->pipeline, GST_STATE_PAUSED)
- == GST_STATE_FAILURE)
+ == GST_STATE_FAILURE)
g_warning ("Couldn't set to paused");
- if (priv->format == NULL)
- {
- GMI_DEBUG("gmip_find_stream: couldn't get caps !");
+ if (priv->format == NULL) {
+ GMI_DEBUG ("gmip_find_stream: couldn't get caps !");
return FALSE;
}
return gmip_find_stream_post (priv);
/* find metadata encoded in media and store in priv->metadata */
gboolean
-gmip_find_track_metadata_pre (GstMediaInfoPriv *priv)
+gmip_find_track_metadata_pre (GstMediaInfoPriv * priv)
{
/* FIXME: this is a hack to set max allowed iterations for metadata
* querying - we should make gst smarter by itself instead */
priv->metadata_iters = 0;
if (gst_element_set_state (priv->pipeline, GST_STATE_PLAYING)
- == GST_STATE_FAILURE)
- {
+ == GST_STATE_FAILURE) {
g_warning ("Couldn't set to play");
return FALSE;
}
}
gboolean
-gmip_find_track_metadata_post (GstMediaInfoPriv *priv)
+gmip_find_track_metadata_post (GstMediaInfoPriv * priv)
{
if (gst_element_set_state (priv->pipeline, GST_STATE_PAUSED)
- == GST_STATE_FAILURE)
+ == GST_STATE_FAILURE)
return FALSE;
priv->current_track->metadata = priv->metadata;
priv->metadata = NULL;
}
gboolean
-gmip_find_track_metadata (GstMediaInfoPriv *priv)
+gmip_find_track_metadata (GstMediaInfoPriv * priv)
{
gmip_find_track_metadata_pre (priv);
GST_DEBUG ("gmip_find_metadata: iterating");
- while ((priv->metadata == NULL) &&
- gst_bin_iterate (GST_BIN (priv->pipeline)))
- GMI_DEBUG("+");
- GMI_DEBUG("\n");
+ while ((priv->metadata == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline)))
+ GMI_DEBUG ("+");
+ GMI_DEBUG ("\n");
gmip_find_track_metadata_post (priv);
return TRUE;
/* find streaminfo found by decoder and store in priv->streaminfo */
/* FIXME: this is an exact copy, so reuse this function instead */
gboolean
-gmip_find_track_streaminfo_pre (GstMediaInfoPriv *priv)
+gmip_find_track_streaminfo_pre (GstMediaInfoPriv * priv)
{
if (gst_element_set_state (priv->pipeline, GST_STATE_PLAYING)
- == GST_STATE_FAILURE)
- {
+ == GST_STATE_FAILURE) {
g_warning ("Couldn't set to play");
return FALSE;
}
}
gboolean
-gmip_find_track_streaminfo_post (GstMediaInfoPriv *priv)
+gmip_find_track_streaminfo_post (GstMediaInfoPriv * priv)
{
GstFormat format, track_format;
/* now add total length to this, and maybe even bitrate ? FIXME */
track_format = gst_format_get_by_nick ("logical_stream");
- if (track_format == 0)
- {
+ if (track_format == 0) {
g_print ("FIXME: implement getting length of whole track\n");
- }
- else
- {
+ } else {
/* which one are we at ? */
long track_num;
gint64 value_start, value_end;
gboolean res;
res = gst_pad_query (priv->decoder_pad, GST_QUERY_POSITION,
- &track_format, &value_start);
- if (res)
- {
+ &track_format, &value_start);
+ if (res) {
format = GST_FORMAT_TIME;
track_num = value_start;
GST_DEBUG ("we are currently at %ld", track_num);
- res = gst_pad_convert (priv->decoder_pad,
- track_format, track_num,
- &format, &value_start);
+ res = gst_pad_convert (priv->decoder_pad,
+ track_format, track_num, &format, &value_start);
res &= gst_pad_convert (priv->decoder_pad,
- track_format, track_num + 1,
- &format, &value_end);
- if (res)
- {
- /* substract to get the length */
+ track_format, track_num + 1, &format, &value_end);
+ if (res) {
+ /* substract to get the length */
GST_DEBUG ("start %lld, end %lld", value_start, value_end);
value_end -= value_start;
/* FIXME: check units; this is in seconds */
}
gboolean
-gmip_find_track_streaminfo (GstMediaInfoPriv *priv)
+gmip_find_track_streaminfo (GstMediaInfoPriv * priv)
{
gmip_find_track_streaminfo_pre (priv);
GST_DEBUG ("DEBUG: gmip_find_streaminfo: iterating");
while ((priv->streaminfo == NULL) &&
- gst_bin_iterate (GST_BIN (priv->pipeline)))
- GMI_DEBUG("+");
- GMI_DEBUG("\n");
+ gst_bin_iterate (GST_BIN (priv->pipeline)))
+ GMI_DEBUG ("+");
+ GMI_DEBUG ("\n");
gmip_find_track_streaminfo_post (priv);
return TRUE;
/* find format found by decoder and store in priv->format */
gboolean
-gmip_find_track_format_pre (GstMediaInfoPriv *priv)
+gmip_find_track_format_pre (GstMediaInfoPriv * priv)
{
if (gst_element_set_state (priv->pipeline, GST_STATE_PLAYING)
- == GST_STATE_FAILURE)
- {
+ == GST_STATE_FAILURE) {
g_warning ("Couldn't set to play");
return FALSE;
}
}
gboolean
-gmip_find_track_format_post (GstMediaInfoPriv *priv)
+gmip_find_track_format_post (GstMediaInfoPriv * priv)
{
if (gst_element_set_state (priv->pipeline, GST_STATE_PAUSED)
- == GST_STATE_FAILURE)
+ == GST_STATE_FAILURE)
return FALSE;
priv->current_track->format = priv->format;
priv->format = NULL;
}
gboolean
-gmip_find_track_format (GstMediaInfoPriv *priv)
+gmip_find_track_format (GstMediaInfoPriv * priv)
{
gmip_find_track_format_pre (priv);
GST_DEBUG ("DEBUG: gmip_find_format: iterating");
- while ((priv->format == NULL) &&
- gst_bin_iterate (GST_BIN (priv->pipeline)))
- GMI_DEBUG("+");
- GMI_DEBUG("\n");
+ while ((priv->format == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline)))
+ GMI_DEBUG ("+");
+ GMI_DEBUG ("\n");
gmip_find_track_format_post (priv);
return TRUE;
}
-
-
gint metadata_iters;
GstTagList *streaminfo;
- GstElement *pipeline; /* will be != NULL during collection */
- gchar *pipeline_desc; /* will be != NULL during collection */
- GstElement *fakesink; /* so we can get caps from the
- decoder sink pad */
- gchar *source_name; /* type of element used as source */
+ GstElement *pipeline; /* will be != NULL during collection */
+ gchar *pipeline_desc; /* will be != NULL during collection */
+ GstElement *fakesink; /* so we can get caps from the
+ decoder sink pad */
+ gchar *source_name; /* type of element used as source */
GstElement *source;
- GstPad *source_pad; /* pad for querying encoded caps */
+ GstPad *source_pad; /* pad for querying encoded caps */
GstElement *decoder;
- GstPad *decoder_pad; /* pad for querying decoded caps */
- GstElement *decontainer; /* element to typefind in containers */
+ GstPad *decoder_pad; /* pad for querying decoded caps */
+ GstElement *decontainer; /* element to typefind in containers */
- GstMediaInfoState state; /* current state of state machine */
- gchar *location; /* location set on the info object */
- guint16 flags; /* flags supplied for detection */
- GstMediaInfoTrack *current_track; /* track pointer under inspection */
- glong current_track_num; /* current track under inspection */
+ GstMediaInfoState state; /* current state of state machine */
+ gchar *location; /* location set on the info object */
+ guint16 flags; /* flags supplied for detection */
+ GstMediaInfoTrack *current_track; /* track pointer under inspection */
+ glong current_track_num; /* current track under inspection */
- GstMediaInfoStream *stream; /* total stream properties */
- char *cache; /* location of cache */
+ GstMediaInfoStream *stream; /* total stream properties */
+ char *cache; /* location of cache */
- GError *error; /* error for creation problems */
+ GError *error; /* error for creation problems */
};
/* declarations */
-GstMediaInfoStream *
- gmi_stream_new (void);
-void gmi_stream_free (GstMediaInfoStream *stream);
-
-GstMediaInfoTrack *
- gmi_track_new (void);
-
-void gmip_reset (GstMediaInfoPriv *priv);
-gboolean gmip_init (GstMediaInfoPriv *priv, GError **error);
-
-void gmi_clear_decoder (GstMediaInfo *info);
-
-gboolean gmi_seek_to_track (GstMediaInfo *info,
- long track);
-
-gboolean gmi_set_mime (GstMediaInfo *info,
- const char *mime);
-
-void deep_notify_callback (GObject *object,
- GstObject *origin,
- GParamSpec *pspec,
- GstMediaInfoPriv *priv);
-void found_tag_callback (GObject *pipeline, GstElement *source, GstTagList *tags, GstMediaInfoPriv *priv);
-void error_callback (GObject *element, GstElement *source, GError *error, gchar *debug, GstMediaInfoPriv *priv);
-
-gboolean gmip_find_type_pre (GstMediaInfoPriv *priv, GError **error);
-gboolean gmip_find_type_post (GstMediaInfoPriv *priv);
-gboolean gmip_find_type (GstMediaInfoPriv *priv, GError **error);
-gboolean gmip_find_stream_pre (GstMediaInfoPriv *priv);
-gboolean gmip_find_stream_post (GstMediaInfoPriv *priv);
-gboolean gmip_find_stream (GstMediaInfoPriv *priv);
-gboolean gmip_find_track_metadata_pre (GstMediaInfoPriv *priv);
-gboolean gmip_find_track_metadata_post (GstMediaInfoPriv *priv);
-gboolean gmip_find_track_metadata (GstMediaInfoPriv *priv);
-gboolean gmip_find_track_streaminfo_pre (GstMediaInfoPriv *priv);
-gboolean gmip_find_track_streaminfo_post (GstMediaInfoPriv *priv);
-gboolean gmip_find_track_streaminfo (GstMediaInfoPriv *priv);
-gboolean gmip_find_track_format_pre (GstMediaInfoPriv *priv);
-gboolean gmip_find_track_format_post (GstMediaInfoPriv *priv);
-gboolean gmip_find_track_format (GstMediaInfoPriv *priv);
+GstMediaInfoStream *gmi_stream_new (void);
+void gmi_stream_free (GstMediaInfoStream * stream);
+
+GstMediaInfoTrack *gmi_track_new (void);
+
+void gmip_reset (GstMediaInfoPriv * priv);
+gboolean gmip_init (GstMediaInfoPriv * priv, GError ** error);
+
+void gmi_clear_decoder (GstMediaInfo * info);
+
+gboolean gmi_seek_to_track (GstMediaInfo * info, long track);
+
+gboolean gmi_set_mime (GstMediaInfo * info, const char *mime);
+
+void deep_notify_callback (GObject * object,
+ GstObject * origin, GParamSpec * pspec, GstMediaInfoPriv * priv);
+void found_tag_callback (GObject * pipeline, GstElement * source,
+ GstTagList * tags, GstMediaInfoPriv * priv);
+void error_callback (GObject * element, GstElement * source, GError * error,
+ gchar * debug, GstMediaInfoPriv * priv);
+
+gboolean gmip_find_type_pre (GstMediaInfoPriv * priv, GError ** error);
+gboolean gmip_find_type_post (GstMediaInfoPriv * priv);
+gboolean gmip_find_type (GstMediaInfoPriv * priv, GError ** error);
+gboolean gmip_find_stream_pre (GstMediaInfoPriv * priv);
+gboolean gmip_find_stream_post (GstMediaInfoPriv * priv);
+gboolean gmip_find_stream (GstMediaInfoPriv * priv);
+gboolean gmip_find_track_metadata_pre (GstMediaInfoPriv * priv);
+gboolean gmip_find_track_metadata_post (GstMediaInfoPriv * priv);
+gboolean gmip_find_track_metadata (GstMediaInfoPriv * priv);
+gboolean gmip_find_track_streaminfo_pre (GstMediaInfoPriv * priv);
+gboolean gmip_find_track_streaminfo_post (GstMediaInfoPriv * priv);
+gboolean gmip_find_track_streaminfo (GstMediaInfoPriv * priv);
+gboolean gmip_find_track_format_pre (GstMediaInfoPriv * priv);
+gboolean gmip_find_track_format_post (GstMediaInfoPriv * priv);
+gboolean gmip_find_track_format (GstMediaInfoPriv * priv);
#endif /* __GST_MEDIA_INFO_PRIV_H__ */
#include "media-info.h"
static void
-print_tag (const GstTagList *list, const gchar *tag, gpointer unused)
+print_tag (const GstTagList * list, const gchar * tag, gpointer unused)
{
gint i, count;
if (gst_tag_get_type (tag) == G_TYPE_STRING) {
g_assert (gst_tag_list_get_string_index (list, tag, i, &str));
} else {
- str = g_strdup_value_contents (
- gst_tag_list_get_value_index (list, tag, i));
+ str =
+ g_strdup_value_contents (gst_tag_list_get_value_index (list, tag, i));
}
if (i == 0) {
}
static void
-info_print (GstMediaInfoStream *stream)
+info_print (GstMediaInfoStream * stream)
{
int i;
GList *p;
g_print ("- mime type: %s\n", stream->mime);
g_print ("- length: %.3f seconds\n",
- (gdouble) stream->length_time / GST_SECOND);
+ (gdouble) stream->length_time / GST_SECOND);
g_print ("- bitrate: %.3f kbps\n", stream->bitrate / 1000.0);
g_print ("- number of tracks: %ld\n", stream->length_tracks);
p = stream->tracks;
- if (p == NULL)
- {
+ if (p == NULL) {
g_print ("- no track information, probably an error\n");
return;
}
- for (i = 0; i < stream->length_tracks; ++i)
- {
+ for (i = 0; i < stream->length_tracks; ++i) {
g_print ("- track %d\n", i);
track = (GstMediaInfoTrack *) p->data;
g_print (" - metadata:\n");
gst_init (&argc, &argv);
info = gst_media_info_new (&error);
- if (error != NULL)
- {
+ if (error != NULL) {
g_print ("Error creating media-info object: %s\n", error->message);
g_error_free (error);
return -1;
}
g_assert (G_IS_OBJECT (info));
- if (!gst_media_info_set_source (info, "gnomevfssrc", &error))
- {
+ if (!gst_media_info_set_source (info, "gnomevfssrc", &error)) {
g_print ("Could not set gnomevfssrc as a source\n");
g_print ("reason: %s\n", error->message);
g_error_free (error);
}
g_print ("stream: %p, &stream: %p\n", stream, &stream);
- for (i = 1; i < argc; ++i)
- {
+ for (i = 1; i < argc; ++i) {
/*
- stream = gst_media_info_read (info, argv[i], GST_MEDIA_INFO_ALL);
- */
+ stream = gst_media_info_read (info, argv[i], GST_MEDIA_INFO_ALL);
+ */
gst_media_info_read_with_idler (info, argv[i], GST_MEDIA_INFO_ALL, &error);
while (gst_media_info_read_idler (info, &stream, &error) && stream == NULL)
- /* keep idling */ g_print ("+");
+ /* keep idling */
+ g_print ("+");
g_print ("\nFILE: %s\n", argv[i]);
g_print ("stream: %p, &stream: %p\n", stream, &stream);
- if (error)
- {
+ if (error) {
g_print ("Error reading media info: %s\n", error->message);
g_error_free (error);
}
#include "media-info.h"
#include "media-info-priv.h"
-static void gst_media_info_class_init (GstMediaInfoClass *klass);
-static void gst_media_info_instance_init (GstMediaInfo *info);
+static void gst_media_info_class_init (GstMediaInfoClass * klass);
+static void gst_media_info_instance_init (GstMediaInfo * info);
-static void gst_media_info_get_property (GObject *object, guint prop_id,
- GValue *value,
- GParamSpec *pspec);
+static void gst_media_info_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
static gboolean _media_info_inited = FALSE;
gst_media_info_error_quark (void)
{
static GQuark quark = 0;
+
if (quark == 0)
quark = g_quark_from_static_string ("gst-media-info-error-quark");
return quark;
void
gst_media_info_init (void)
{
- if (_media_info_inited) return;
+ if (_media_info_inited)
+ return;
/* register our debugging category */
GST_DEBUG_CATEGORY_INIT (gst_media_info_debug, "GST_MEDIA_INFO", 0,
- "GStreamer media-info library");
+ "GStreamer media-info library");
GST_DEBUG ("Initialized media-info library");
_media_info_inited = TRUE;
}
gst_media_info_get_type (void)
{
static GType gst_media_info_type = 0;
- if (!gst_media_info_type)
- {
+
+ if (!gst_media_info_type) {
static const GTypeInfo gst_media_info_info = {
sizeof (GstMediaInfoClass),
(GBaseInitFunc) NULL,
NULL
};
gst_media_info_type = g_type_register_static (G_TYPE_OBJECT,
- "GstMediaInfo",
- &gst_media_info_info, 0);
+ "GstMediaInfo", &gst_media_info_info, 0);
}
return gst_media_info_type;
}
static void
-gst_media_info_class_init (GstMediaInfoClass *klass)
+gst_media_info_class_init (GstMediaInfoClass * klass)
{
GObjectClass *g_object_class = G_OBJECT_CLASS (klass);
/*
- object_class->finalize = gst_media_info_finalize;
- object_class->dispose = gst_media_info_dispose;
- */
+ object_class->finalize = gst_media_info_finalize;
+ object_class->dispose = gst_media_info_dispose;
+ */
/*
- g_object_class->set_property = gst_media_info_set_property;
- */
+ g_object_class->set_property = gst_media_info_set_property;
+ */
g_object_class->get_property = gst_media_info_get_property;
klass->media_info_signal = NULL;
- gst_media_info_signals [MEDIA_INFO_SIGNAL] =
- g_signal_new ("media-info",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstMediaInfoClass, media_info_signal),
- NULL, NULL,
- gst_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ gst_media_info_signals[MEDIA_INFO_SIGNAL] =
+ g_signal_new ("media-info",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstMediaInfoClass, media_info_signal),
+ NULL, NULL, gst_marshal_VOID__VOID, G_TYPE_NONE, 0);
}
static void
-gst_media_info_instance_init (GstMediaInfo *info)
+gst_media_info_instance_init (GstMediaInfo * info)
{
GError **error;
info->priv = g_new0 (GstMediaInfoPriv, 1);
error = &info->priv->error;
- if (!_media_info_inited) { gst_media_info_init (); }
+ if (!_media_info_inited) {
+ gst_media_info_init ();
+ }
gmip_init (info->priv, error);
gmip_reset (info->priv);
/* get/set */
static void
-gst_media_info_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
+gst_media_info_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
GstMediaInfo *info = GST_MEDIA_INFO (object);
- switch (prop_id)
- {
+ switch (prop_id) {
case PROP_SOURCE:
g_value_set_string (value, info->priv->source_name);
break;
}
GstMediaInfo *
-gst_media_info_new (GError **error)
+gst_media_info_new (GError ** error)
{
GstMediaInfo *info = g_object_new (GST_MEDIA_INFO_TYPE, NULL);
- if (info->priv->error)
- {
- if (error)
- {
+ if (info->priv->error) {
+ if (error) {
*error = info->priv->error;
info->priv->error = NULL;
- }
- else
- {
+ } else {
g_warning ("Error creating GstMediaInfo object.\n%s",
- info->priv->error->message);
+ info->priv->error->message);
g_error_free (info->priv->error);
}
}
* public methods
*/
gboolean
-gst_media_info_set_source (GstMediaInfo *info, const char *source, GError **error)
+gst_media_info_set_source (GstMediaInfo * info, const char *source,
+ GError ** error)
{
info->priv->source_name = g_strdup (source);
return TRUE;
* previous one is done ?
*/
void
-gst_media_info_read_with_idler (GstMediaInfo *info, const char *location,
- guint16 flags, GError **error)
+gst_media_info_read_with_idler (GstMediaInfo * info, const char *location,
+ guint16 flags, GError ** error)
{
GstMediaInfoPriv *priv = info->priv;
- gmip_reset (info->priv); /* reset all structs */
+ gmip_reset (info->priv); /* reset all structs */
priv->location = g_strdup (location);
priv->flags = flags;
}
* returns: TRUE if it was able to idle, FALSE if there was an error
*/
gboolean
-gst_media_info_read_idler (GstMediaInfo *info, GstMediaInfoStream **streamp, GError **error)
+gst_media_info_read_idler (GstMediaInfo * info, GstMediaInfoStream ** streamp,
+ GError ** error)
{
GstMediaInfoPriv *priv;
/* if it's NULL then we're sure something went wrong higher up) */
- if (info == NULL) return FALSE;
+ if (info == NULL)
+ return FALSE;
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
priv = info->priv;
g_assert (streamp != NULL);
g_assert (priv);
- switch (priv->state)
- {
+ switch (priv->state) {
case GST_MEDIA_INFO_STATE_NULL:
/* make sure we have a source */
- if (!priv->source_name)
- {
- *error = g_error_new (GST_MEDIA_INFO_ERROR, 0,
- "No source set on media info.");
- return FALSE;
+ if (!priv->source_name) {
+ *error = g_error_new (GST_MEDIA_INFO_ERROR, 0,
+ "No source set on media info.");
+ return FALSE;
}
/* need to find type */
gchar *mime;
GST_LOG ("STATE_TYPEFIND");
- if ((priv->type == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline)))
- {
+ if ((priv->type == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline))) {
GST_DEBUG ("iterating while in STATE_TYPEFIND");
- GMI_DEBUG("?");
- return TRUE;
+ GMI_DEBUG ("?");
+ return TRUE;
}
- if (priv->type == NULL)
- {
- g_warning ("Couldn't find type\n");
+ if (priv->type == NULL) {
+ g_warning ("Couldn't find type\n");
return FALSE;
}
/* do the state transition */
GST_DEBUG ("doing find_type_post");
gmip_find_type_post (priv);
GST_DEBUG ("finding out mime type");
- mime = g_strdup (gst_structure_get_name (
- gst_caps_get_structure(priv->type, 0)));
+ mime =
+ g_strdup (gst_structure_get_name (gst_caps_get_structure (priv->type,
+ 0)));
GST_DEBUG ("found out mime type: %s", mime);
- if (!gmi_set_mime (info, mime))
- {
- /* FIXME: pop up error */
- GST_DEBUG ("no decoder pipeline found for mime %s", mime);
- return FALSE;
+ if (!gmi_set_mime (info, mime)) {
+ /* FIXME: pop up error */
+ GST_DEBUG ("no decoder pipeline found for mime %s", mime);
+ return FALSE;
}
priv->stream = gmi_stream_new ();
GST_DEBUG ("new stream: %p", priv->stream);
case GST_MEDIA_INFO_STATE_STREAM:
{
GST_LOG ("STATE_STREAM");
- if ((priv->format == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline)))
- {
- GMI_DEBUG("?");
- return TRUE;
+ if ((priv->format == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline))) {
+ GMI_DEBUG ("?");
+ return TRUE;
}
- if (priv->format == NULL)
- {
- g_warning ("Couldn't find format\n");
+ if (priv->format == NULL) {
+ g_warning ("Couldn't find format\n");
return FALSE;
}
/* do state transition; stream -> first track metadata */
gmip_find_track_metadata_pre (priv);
return TRUE;
}
- /* these ones are repeated per track */
+ /* these ones are repeated per track */
case GST_MEDIA_INFO_STATE_METADATA:
{
if ((priv->metadata == NULL) &&
gst_bin_iterate (GST_BIN (priv->pipeline)) &&
- priv->metadata_iters < MAX_METADATA_ITERS)
- {
- GMI_DEBUG("?");
+ priv->metadata_iters < MAX_METADATA_ITERS) {
+ GMI_DEBUG ("?");
priv->metadata_iters++;
- return TRUE;
+ return TRUE;
}
if (priv->metadata_iters == MAX_METADATA_ITERS)
- g_print ("iterated a few times, didn't find metadata\n");
- if (priv->metadata == NULL)
- {
+ g_print ("iterated a few times, didn't find metadata\n");
+ if (priv->metadata == NULL) {
/* this is not a permanent failure */
- GST_DEBUG ("Couldn't find metadata");
+ GST_DEBUG ("Couldn't find metadata");
}
GST_DEBUG ("found metadata of track %ld", priv->current_track_num);
- if (!gmip_find_track_metadata_post (priv)) return FALSE;
+ if (!gmip_find_track_metadata_post (priv))
+ return FALSE;
GST_DEBUG ("METADATA: going to STREAMINFO\n");
priv->state = GST_MEDIA_INFO_STATE_STREAMINFO;
return gmip_find_track_streaminfo_pre (priv);
case GST_MEDIA_INFO_STATE_STREAMINFO:
{
if ((priv->streaminfo == NULL) &&
- gst_bin_iterate (GST_BIN (priv->pipeline)))
- {
- GMI_DEBUG("?");
- return TRUE;
+ gst_bin_iterate (GST_BIN (priv->pipeline))) {
+ GMI_DEBUG ("?");
+ return TRUE;
}
- if (priv->streaminfo == NULL)
- {
+ if (priv->streaminfo == NULL) {
/* this is not a permanent failure */
- GST_DEBUG ("Couldn't find streaminfo");
- }
- else
- GST_DEBUG ("found streaminfo of track %ld", priv->current_track_num);
- if (!gmip_find_track_streaminfo_post (priv)) return FALSE;
+ GST_DEBUG ("Couldn't find streaminfo");
+ } else
+ GST_DEBUG ("found streaminfo of track %ld", priv->current_track_num);
+ if (!gmip_find_track_streaminfo_post (priv))
+ return FALSE;
priv->state = GST_MEDIA_INFO_STATE_FORMAT;
return gmip_find_track_format_pre (priv);
}
case GST_MEDIA_INFO_STATE_FORMAT:
{
- if ((priv->format == NULL) &&
- gst_bin_iterate (GST_BIN (priv->pipeline)))
- {
- GMI_DEBUG("?");
- return TRUE;
+ if ((priv->format == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline))) {
+ GMI_DEBUG ("?");
+ return TRUE;
}
- if (priv->format == NULL)
- {
- g_warning ("Couldn't find format\n");
+ if (priv->format == NULL) {
+ g_warning ("Couldn't find format\n");
return FALSE;
}
GST_DEBUG ("found format of track %ld", priv->current_track_num);
- if (!gmip_find_track_format_post (priv)) return FALSE;
+ if (!gmip_find_track_format_post (priv))
+ return FALSE;
/* save the track info */
priv->stream->tracks = g_list_append (priv->stream->tracks,
- priv->current_track);
+ priv->current_track);
/* these alloc'd data types have been handed off */
priv->current_track = NULL;
priv->location = NULL;
/* now see if we need to seek to a next track or not */
priv->current_track_num++;
- if (priv->current_track_num < priv->stream->length_tracks)
- {
- gmi_seek_to_track (info, priv->current_track_num);
- priv->current_track = gmi_track_new ();
- if (!gmip_find_track_metadata_pre (priv))
- {
+ if (priv->current_track_num < priv->stream->length_tracks) {
+ gmi_seek_to_track (info, priv->current_track_num);
+ priv->current_track = gmi_track_new ();
+ if (!gmip_find_track_metadata_pre (priv)) {
g_free (priv->current_track);
- return FALSE;
+ return FALSE;
}
priv->state = GST_MEDIA_INFO_STATE_METADATA;
return TRUE;
}
case GST_MEDIA_INFO_STATE_DONE:
return TRUE;
- default:
+ default:
g_warning ("don't know what to do\n");
return FALSE;
- }
+ }
}
/* main function
* read all possible info from the file pointed to by location
* use flags to limit the type of information searched for */
GstMediaInfoStream *
-gst_media_info_read (GstMediaInfo *info, const char *location, guint16 flags, GError **error)
+gst_media_info_read (GstMediaInfo * info, const char *location, guint16 flags,
+ GError ** error)
{
GstMediaInfoStream *stream = NULL;
gst_media_info_read_with_idler (info, location, flags, error);
- if (*error) return FALSE;
+ if (*error)
+ return FALSE;
while (gst_media_info_read_idler (info, &stream, error) && stream == NULL)
- /* keep looping */;
+ /* keep looping */ ;
if (*error)
return NULL;
#include <gst/gst.h>
-G_BEGIN_DECLS
-
-typedef struct GstMediaInfoPriv GstMediaInfoPriv;
-typedef struct _GstMediaInfo GstMediaInfo;
-typedef struct _GstMediaInfoClass GstMediaInfoClass;
+G_BEGIN_DECLS typedef struct GstMediaInfoPriv GstMediaInfoPriv;
+typedef struct _GstMediaInfo GstMediaInfo;
+typedef struct _GstMediaInfoClass GstMediaInfoClass;
struct _GstMediaInfo
{
GObjectClass parent_class;
/* signals */
- void (*media_info_signal) (GstMediaInfo *gst_media_info);
- void (*error_signal) (GstMediaInfo *gst_media_info, GError *error, const gchar *debug);
+ void (*media_info_signal) (GstMediaInfo * gst_media_info);
+ void (*error_signal) (GstMediaInfo * gst_media_info, GError * error,
+ const gchar * debug);
gpointer _gst_reserved[GST_PADDING];
};
#define GST_MEDIA_INFO_FORMAT 1 << 5
#define GST_MEDIA_INFO_ALL ((1 << 6) - 1)
-GQuark gst_media_info_error_quark (void);
-
-void gst_media_info_init (void);
-GType gst_media_info_get_type (void);
-
-GstMediaInfo * gst_media_info_new (GError **error);
-
-gboolean gst_media_info_set_source (GstMediaInfo *info,
- const char *source,
- GError **error);
-void gst_media_info_read_with_idler (GstMediaInfo *media_info,
- const char *location,
- guint16 GST_MEDIA_INFO_FLAGS,
- GError **error);
-gboolean gst_media_info_read_idler (GstMediaInfo *media_info,
- GstMediaInfoStream **streamp,
- GError **error);
-GstMediaInfoStream *
- gst_media_info_read (GstMediaInfo *media_info,
- const char *location,
- guint16 GST_MEDIA_INFO_FLAGS,
- GError **error);
-gboolean gst_media_info_read_many (GstMediaInfo *media_info,
- GList *locations,
- guint16 GST_MEDIA_INFO_FLAGS,
- GError **error);
-GstCaps * gst_media_info_get_next (GstMediaInfo *media_info,
- GError **error);
+GQuark gst_media_info_error_quark (void);
+
+void gst_media_info_init (void);
+GType gst_media_info_get_type (void);
+
+GstMediaInfo *gst_media_info_new (GError ** error);
+
+gboolean gst_media_info_set_source (GstMediaInfo * info,
+ const char *source, GError ** error);
+void gst_media_info_read_with_idler (GstMediaInfo * media_info,
+ const char *location, guint16 GST_MEDIA_INFO_FLAGS, GError ** error);
+gboolean gst_media_info_read_idler (GstMediaInfo * media_info,
+ GstMediaInfoStream ** streamp, GError ** error);
+GstMediaInfoStream *gst_media_info_read (GstMediaInfo * media_info,
+ const char *location, guint16 GST_MEDIA_INFO_FLAGS, GError ** error);
+gboolean gst_media_info_read_many (GstMediaInfo * media_info,
+ GList * locations, guint16 GST_MEDIA_INFO_FLAGS, GError ** error);
+GstCaps *gst_media_info_get_next (GstMediaInfo * media_info, GError ** error);
+
/*
* FIXME: reset ?
gboolean gst_media_info_write (GstMediaInfo *media_info,
*/
G_END_DECLS
-
#endif /* __GST_MEDIA_INFO_H__ */
#include "mixer.h"
#include "mixer-marshal.h"
-enum {
+enum
+{
MUTE_TOGGLED,
RECORD_TOGGLED,
VOLUME_CHANGED,
LAST_SIGNAL
};
-static void gst_mixer_class_init (GstMixerClass *klass);
+static void gst_mixer_class_init (GstMixerClass * klass);
static guint gst_mixer_signals[LAST_SIGNAL] = { 0 };
};
gst_mixer_type = g_type_register_static (G_TYPE_INTERFACE,
- "GstMixer",
- &gst_mixer_info, 0);
+ "GstMixer", &gst_mixer_info, 0);
g_type_interface_add_prerequisite (gst_mixer_type,
- GST_TYPE_IMPLEMENTS_INTERFACE);
+ GST_TYPE_IMPLEMENTS_INTERFACE);
}
return gst_mixer_type;
}
static void
-gst_mixer_class_init (GstMixerClass *klass)
+gst_mixer_class_init (GstMixerClass * klass)
{
static gboolean initialized = FALSE;
-
+
if (!initialized) {
gst_mixer_signals[RECORD_TOGGLED] =
- g_signal_new ("record-toggled",
- GST_TYPE_MIXER, G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstMixerClass, record_toggled),
- NULL, NULL,
- gst_mixer_marshal_VOID__OBJECT_BOOLEAN, G_TYPE_NONE, 2,
- GST_TYPE_MIXER_TRACK, G_TYPE_BOOLEAN);
+ g_signal_new ("record-toggled",
+ GST_TYPE_MIXER, G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstMixerClass, record_toggled),
+ NULL, NULL,
+ gst_mixer_marshal_VOID__OBJECT_BOOLEAN, G_TYPE_NONE, 2,
+ GST_TYPE_MIXER_TRACK, G_TYPE_BOOLEAN);
gst_mixer_signals[MUTE_TOGGLED] =
- g_signal_new ("mute-toggled",
- GST_TYPE_MIXER, G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstMixerClass, mute_toggled),
- NULL, NULL,
- gst_mixer_marshal_VOID__OBJECT_BOOLEAN, G_TYPE_NONE, 2,
- GST_TYPE_MIXER_TRACK, G_TYPE_BOOLEAN);
+ g_signal_new ("mute-toggled",
+ GST_TYPE_MIXER, G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstMixerClass, mute_toggled),
+ NULL, NULL,
+ gst_mixer_marshal_VOID__OBJECT_BOOLEAN, G_TYPE_NONE, 2,
+ GST_TYPE_MIXER_TRACK, G_TYPE_BOOLEAN);
gst_mixer_signals[VOLUME_CHANGED] =
- g_signal_new ("volume-changed",
- GST_TYPE_MIXER, G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstMixerClass, volume_changed),
- NULL, NULL,
- gst_mixer_marshal_VOID__OBJECT_POINTER, G_TYPE_NONE, 2,
- GST_TYPE_MIXER_TRACK, G_TYPE_POINTER);
-
+ g_signal_new ("volume-changed",
+ GST_TYPE_MIXER, G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstMixerClass, volume_changed),
+ NULL, NULL,
+ gst_mixer_marshal_VOID__OBJECT_POINTER, G_TYPE_NONE, 2,
+ GST_TYPE_MIXER_TRACK, G_TYPE_POINTER);
+
initialized = TRUE;
}
klass->mixer_type = GST_MIXER_SOFTWARE;
-
+
/* default virtual functions */
klass->list_tracks = NULL;
klass->set_volume = NULL;
*/
const GList *
-gst_mixer_list_tracks (GstMixer *mixer)
+gst_mixer_list_tracks (GstMixer * mixer)
{
GstMixerClass *klass = GST_MIXER_GET_CLASS (mixer);
*/
void
-gst_mixer_set_volume (GstMixer *mixer,
- GstMixerTrack *track,
- gint *volumes)
+gst_mixer_set_volume (GstMixer * mixer, GstMixerTrack * track, gint * volumes)
{
GstMixerClass *klass = GST_MIXER_GET_CLASS (mixer);
*/
void
-gst_mixer_get_volume (GstMixer *mixer,
- GstMixerTrack *track,
- gint *volumes)
+gst_mixer_get_volume (GstMixer * mixer, GstMixerTrack * track, gint * volumes)
{
GstMixerClass *klass = GST_MIXER_GET_CLASS (mixer);
*/
void
-gst_mixer_set_mute (GstMixer *mixer,
- GstMixerTrack *track,
- gboolean mute)
+gst_mixer_set_mute (GstMixer * mixer, GstMixerTrack * track, gboolean mute)
{
GstMixerClass *klass = GST_MIXER_GET_CLASS (mixer);
*/
void
-gst_mixer_set_record (GstMixer *mixer,
- GstMixerTrack *track,
- gboolean record)
+gst_mixer_set_record (GstMixer * mixer, GstMixerTrack * track, gboolean record)
{
GstMixerClass *klass = GST_MIXER_GET_CLASS (mixer);
}
void
-gst_mixer_mute_toggled (GstMixer *mixer,
- GstMixerTrack *track,
- gboolean mute)
+gst_mixer_mute_toggled (GstMixer * mixer, GstMixerTrack * track, gboolean mute)
{
g_signal_emit (G_OBJECT (mixer),
- gst_mixer_signals[MUTE_TOGGLED], 0,
- track, mute);
+ gst_mixer_signals[MUTE_TOGGLED], 0, track, mute);
- g_signal_emit_by_name (G_OBJECT (track),
- "mute_toggled",
- mute);
+ g_signal_emit_by_name (G_OBJECT (track), "mute_toggled", mute);
}
void
-gst_mixer_record_toggled (GstMixer *mixer,
- GstMixerTrack *track,
- gboolean record)
+gst_mixer_record_toggled (GstMixer * mixer,
+ GstMixerTrack * track, gboolean record)
{
g_signal_emit (G_OBJECT (mixer),
- gst_mixer_signals[RECORD_TOGGLED], 0,
- track, record);
+ gst_mixer_signals[RECORD_TOGGLED], 0, track, record);
- g_signal_emit_by_name (G_OBJECT (track),
- "record_toggled",
- record);
+ g_signal_emit_by_name (G_OBJECT (track), "record_toggled", record);
}
void
-gst_mixer_volume_changed (GstMixer *mixer,
- GstMixerTrack *track,
- gint *volumes)
+gst_mixer_volume_changed (GstMixer * mixer,
+ GstMixerTrack * track, gint * volumes)
{
g_signal_emit (G_OBJECT (mixer),
- gst_mixer_signals[VOLUME_CHANGED], 0,
- track, volumes);
+ gst_mixer_signals[VOLUME_CHANGED], 0, track, volumes);
- g_signal_emit_by_name (G_OBJECT (track),
- "volume_changed",
- volumes);
+ g_signal_emit_by_name (G_OBJECT (track), "volume_changed", volumes);
}
#include <gst/mixer/mixer-enumtypes.h>
G_BEGIN_DECLS
-
#define GST_TYPE_MIXER \
(gst_mixer_get_type ())
#define GST_MIXER(obj) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_MIXER))
#define GST_MIXER_GET_CLASS(inst) \
(G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_MIXER, GstMixerClass))
-
#define GST_MIXER_TYPE(klass) (klass->mixer_type)
-
typedef struct _GstMixer GstMixer;
typedef enum
GST_MIXER_SOFTWARE
} GstMixerType;
-typedef struct _GstMixerClass {
+typedef struct _GstMixerClass
+{
GTypeInterface klass;
GstMixerType mixer_type;
-
+
/* virtual functions */
- const GList * (* list_tracks) (GstMixer *mixer);
+ const GList *(*list_tracks) (GstMixer * mixer);
- void (* set_volume) (GstMixer *mixer,
- GstMixerTrack *track,
- gint *volumes);
- void (* get_volume) (GstMixer *mixer,
- GstMixerTrack *track,
- gint *volumes);
+ void (*set_volume) (GstMixer * mixer, GstMixerTrack * track, gint * volumes);
+ void (*get_volume) (GstMixer * mixer, GstMixerTrack * track, gint * volumes);
- void (* set_mute) (GstMixer *mixer,
- GstMixerTrack *track,
- gboolean mute);
- void (* set_record) (GstMixer *mixer,
- GstMixerTrack *track,
- gboolean record);
+ void (*set_mute) (GstMixer * mixer, GstMixerTrack * track, gboolean mute);
+ void (*set_record) (GstMixer * mixer, GstMixerTrack * track, gboolean record);
/* signals */
- void (* mute_toggled) (GstMixer *mixer,
- GstMixerTrack *channel,
- gboolean mute);
- void (* record_toggled) (GstMixer *mixer,
- GstMixerTrack *channel,
- gboolean record);
- void (* volume_changed) (GstMixer *mixer,
- GstMixerTrack *channel,
- gint *volumes);
+ void (*mute_toggled) (GstMixer * mixer,
+ GstMixerTrack * channel, gboolean mute);
+ void (*record_toggled) (GstMixer * mixer,
+ GstMixerTrack * channel, gboolean record);
+ void (*volume_changed) (GstMixer * mixer,
+ GstMixerTrack * channel, gint * volumes);
gpointer _gst_reserved[GST_PADDING];
} GstMixerClass;
-GType gst_mixer_get_type (void);
+GType gst_mixer_get_type (void);
/* virtual class function wrappers */
-const GList * gst_mixer_list_tracks (GstMixer *mixer);
-void gst_mixer_set_volume (GstMixer *mixer,
- GstMixerTrack *track,
- gint *volumes);
-void gst_mixer_get_volume (GstMixer *mixer,
- GstMixerTrack *track,
- gint *volumes);
-void gst_mixer_set_mute (GstMixer *mixer,
- GstMixerTrack *track,
- gboolean mute);
-void gst_mixer_set_record (GstMixer *mixer,
- GstMixerTrack *track,
- gboolean record);
+const GList *gst_mixer_list_tracks (GstMixer * mixer);
+void gst_mixer_set_volume (GstMixer * mixer,
+ GstMixerTrack * track, gint * volumes);
+void gst_mixer_get_volume (GstMixer * mixer,
+ GstMixerTrack * track, gint * volumes);
+void gst_mixer_set_mute (GstMixer * mixer,
+ GstMixerTrack * track, gboolean mute);
+void gst_mixer_set_record (GstMixer * mixer,
+ GstMixerTrack * track, gboolean record);
/* trigger signals */
-void gst_mixer_mute_toggled (GstMixer *mixer,
- GstMixerTrack *track,
- gboolean mute);
-void gst_mixer_record_toggled (GstMixer *mixer,
- GstMixerTrack *track,
- gboolean record);
-void gst_mixer_volume_changed (GstMixer *mixer,
- GstMixerTrack *track,
- gint *volumes);
+void gst_mixer_mute_toggled (GstMixer * mixer,
+ GstMixerTrack * track, gboolean mute);
+void gst_mixer_record_toggled (GstMixer * mixer,
+ GstMixerTrack * track, gboolean record);
+void gst_mixer_volume_changed (GstMixer * mixer,
+ GstMixerTrack * track, gint * volumes);
G_END_DECLS
-
#endif /* __GST_MIXER_H__ */
#include "mixertrack.h"
-enum {
+enum
+{
/* FILL ME */
SIGNAL_VOLUME_CHANGED,
SIGNAL_RECORD_TOGGLED,
LAST_SIGNAL
};
-static void gst_mixer_track_class_init (GstMixerTrackClass *klass);
-static void gst_mixer_track_init (GstMixerTrack *mixer);
-static void gst_mixer_track_dispose (GObject *object);
+static void gst_mixer_track_class_init (GstMixerTrackClass * klass);
+static void gst_mixer_track_init (GstMixerTrack * mixer);
+static void gst_mixer_track_dispose (GObject * object);
static GObjectClass *parent_class = NULL;
static guint signals[LAST_SIGNAL] = { 0 };
gst_mixer_track_type =
g_type_register_static (G_TYPE_OBJECT,
- "GstMixerTrack",
- &mixer_track_info, 0);
+ "GstMixerTrack", &mixer_track_info, 0);
}
return gst_mixer_track_type;
}
static void
-gst_mixer_track_class_init (GstMixerTrackClass *klass)
+gst_mixer_track_class_init (GstMixerTrackClass * klass)
{
GObjectClass *object_klass = (GObjectClass *) klass;
parent_class = g_type_class_ref (G_TYPE_OBJECT);
signals[SIGNAL_RECORD_TOGGLED] =
- g_signal_new ("record_toggled", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstMixerTrackClass,
- record_toggled),
- NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN,
- G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+ g_signal_new ("record_toggled", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstMixerTrackClass,
+ record_toggled),
+ NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN,
+ G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
signals[SIGNAL_MUTE_TOGGLED] =
- g_signal_new ("mute_toggled", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstMixerTrackClass,
- mute_toggled),
- NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN,
- G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+ g_signal_new ("mute_toggled", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstMixerTrackClass,
+ mute_toggled),
+ NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN,
+ G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
signals[SIGNAL_VOLUME_CHANGED] =
- g_signal_new ("volume_changed", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstMixerTrackClass,
- volume_changed),
- NULL, NULL, g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1, G_TYPE_POINTER);
+ g_signal_new ("volume_changed", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstMixerTrackClass,
+ volume_changed),
+ NULL, NULL, g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1, G_TYPE_POINTER);
object_klass->dispose = gst_mixer_track_dispose;
}
static void
-gst_mixer_track_init (GstMixerTrack *channel)
+gst_mixer_track_init (GstMixerTrack * channel)
{
channel->label = NULL;
channel->min_volume = channel->max_volume = 0;
}
static void
-gst_mixer_track_dispose (GObject *object)
+gst_mixer_track_dispose (GObject * object)
{
GstMixerTrack *channel = GST_MIXER_TRACK (object);
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_TYPE_MIXER_TRACK \
(gst_mixer_track_get_type ())
#define GST_MIXER_TRACK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_MIXER_TRACK))
#define GST_IS_MIXER_TRACK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_MIXER_TRACK))
-
/*
* Naming:
*
* mixer, which means that setting this track will change
* the hearable volume on any output.
*/
-
-typedef enum {
- GST_MIXER_TRACK_INPUT = (1<<0),
- GST_MIXER_TRACK_OUTPUT = (1<<1),
- GST_MIXER_TRACK_MUTE = (1<<2),
- GST_MIXER_TRACK_RECORD = (1<<3),
- GST_MIXER_TRACK_MASTER = (1<<4),
- GST_MIXER_TRACK_SOFTWARE = (1<<5)
+ typedef enum
+{
+ GST_MIXER_TRACK_INPUT = (1 << 0),
+ GST_MIXER_TRACK_OUTPUT = (1 << 1),
+ GST_MIXER_TRACK_MUTE = (1 << 2),
+ GST_MIXER_TRACK_RECORD = (1 << 3),
+ GST_MIXER_TRACK_MASTER = (1 << 4),
+ GST_MIXER_TRACK_SOFTWARE = (1 << 5)
} GstMixerTrackFlags;
#define GST_MIXER_TRACK_HAS_FLAG(channel, flag) \
((channel)->flags & flag)
-typedef struct _GstMixerTrack {
- GObject parent;
+typedef struct _GstMixerTrack
+{
+ GObject parent;
- gchar *label;
+ gchar *label;
GstMixerTrackFlags flags;
- gint num_channels,
- min_volume,
- max_volume;
+ gint num_channels, min_volume, max_volume;
} GstMixerTrack;
-typedef struct _GstMixerTrackClass {
+typedef struct _GstMixerTrackClass
+{
GObjectClass parent;
/* signals */
- void (* mute_toggled) (GstMixerTrack *channel,
- gboolean mute);
- void (* record_toggled) (GstMixerTrack *channel,
- gboolean record);
- void (* volume_changed) (GstMixerTrack *channel,
- gint *volumes);
+ void (*mute_toggled) (GstMixerTrack * channel, gboolean mute);
+ void (*record_toggled) (GstMixerTrack * channel, gboolean record);
+ void (*volume_changed) (GstMixerTrack * channel, gint * volumes);
gpointer _gst_reserved[GST_PADDING];
} GstMixerTrackClass;
-GType gst_mixer_track_get_type (void);
+GType gst_mixer_track_get_type (void);
G_END_DECLS
-
#endif /* __GST_MIXER_TRACK_H__ */
#include <gst/navigation/navigation.h>
-static void gst_navigation_class_init (GstNavigationInterface *iface);
+static void gst_navigation_class_init (GstNavigationInterface * iface);
GType
gst_navigation_get_type (void)
};
gst_navigation_type = g_type_register_static (G_TYPE_INTERFACE,
- "GstNavigation",
- &gst_navigation_info, 0);
+ "GstNavigation", &gst_navigation_info, 0);
}
return gst_navigation_type;
}
static void
-gst_navigation_class_init (GstNavigationInterface *iface)
+gst_navigation_class_init (GstNavigationInterface * iface)
{
/* default virtual functions */
iface->send_event = NULL;
}
void
-gst_navigation_send_event (GstNavigation *navigation, GstStructure *structure)
+gst_navigation_send_event (GstNavigation * navigation, GstStructure * structure)
{
GstNavigationInterface *iface = GST_NAVIGATION_GET_IFACE (navigation);
}
void
-gst_navigation_send_key_event (GstNavigation *navigation, const char *event,
- const char *key)
+gst_navigation_send_key_event (GstNavigation * navigation, const char *event,
+ const char *key)
{
- gst_navigation_send_event (navigation, gst_structure_new (
- "application/x-gst-navigation",
- "event", G_TYPE_STRING, event,
- "key", G_TYPE_STRING, key, NULL));
+ gst_navigation_send_event (navigation,
+ gst_structure_new ("application/x-gst-navigation", "event", G_TYPE_STRING,
+ event, "key", G_TYPE_STRING, key, NULL));
}
void
-gst_navigation_send_mouse_event (GstNavigation *navigation, const char *event,
- int button, double x, double y)
+gst_navigation_send_mouse_event (GstNavigation * navigation, const char *event,
+ int button, double x, double y)
{
- gst_navigation_send_event (navigation, gst_structure_new (
- "application/x-gst-navigation",
- "event", G_TYPE_STRING, event,
- "button", G_TYPE_INT, button,
- "pointer_x", G_TYPE_DOUBLE, x,
- "pointer_y", G_TYPE_DOUBLE, y, NULL));
+ gst_navigation_send_event (navigation,
+ gst_structure_new ("application/x-gst-navigation", "event", G_TYPE_STRING,
+ event, "button", G_TYPE_INT, button, "pointer_x", G_TYPE_DOUBLE, x,
+ "pointer_y", G_TYPE_DOUBLE, y, NULL));
}
-
-
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_TYPE_NAVIGATION \
(gst_navigation_get_type ())
#define GST_NAVIGATION(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_NAVIGATION))
#define GST_NAVIGATION_GET_IFACE(obj) \
(G_TYPE_INSTANCE_GET_INTERFACE ((obj), GST_TYPE_NAVIGATION, GstNavigationInterface))
-
typedef struct _GstNavigation GstNavigation;
-typedef struct _GstNavigationInterface {
+typedef struct _GstNavigationInterface
+{
GTypeInterface g_iface;
/* virtual functions */
- void (*send_event) (GstNavigation *navigation, GstStructure *structure);
-
+ void (*send_event) (GstNavigation * navigation, GstStructure * structure);
+
gpointer _gst_reserved[GST_PADDING];
} GstNavigationInterface;
-GType gst_navigation_get_type (void);
+GType gst_navigation_get_type (void);
/* virtual class function wrappers */
-void gst_navigation_send_event (GstNavigation *navigation, GstStructure *structure);
+void gst_navigation_send_event (GstNavigation * navigation,
+ GstStructure * structure);
-void gst_navigation_send_key_event (GstNavigation *navigation,
- const char *event, const char *key);
-void gst_navigation_send_mouse_event (GstNavigation *navigation,
- const char *event, int button, double x, double y);
+void gst_navigation_send_key_event (GstNavigation * navigation,
+ const char *event, const char *key);
+void gst_navigation_send_mouse_event (GstNavigation * navigation,
+ const char *event, int button, double x, double y);
G_END_DECLS
-
#endif /* __GST_NAVIGATION_H__ */
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
-
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
LAST_SIGNAL
};
-struct _GstPlayPrivate {
+struct _GstPlayPrivate
+{
char *location;
-
+
GHashTable *elements;
-
+
gint64 time_nanos;
gint64 length_nanos;
-
+
gint get_length_attempt;
-
- gint tick_unblock_remaining; /* how many msecs left
- to unblock due to seeking */
+
+ gint tick_unblock_remaining; /* how many msecs left
+ to unblock due to seeking */
guint tick_id;
guint length_id;
-
+
gulong handoff_hid;
/* error/debug handling */
/* */
/* ======================================================= */
-static GstCaps * gst_play_video_fixate (GstPad *pad, const GstCaps *caps, gpointer user_data);
-static GstCaps * gst_play_audio_fixate (GstPad *pad, const GstCaps *caps, gpointer user_data);
+static GstCaps *gst_play_video_fixate (GstPad * pad, const GstCaps * caps,
+ gpointer user_data);
+static GstCaps *gst_play_audio_fixate (GstPad * pad, const GstCaps * caps,
+ gpointer user_data);
static GQuark
gst_play_error_quark (void)
{
static GQuark quark = 0;
+
if (quark == 0)
quark = g_quark_from_static_string ("gst-play-error-quark");
return quark;
/* General GError creation */
static void
-gst_play_error_create (GError ** error, const gchar *message)
+gst_play_error_create (GError ** error, const gchar * message)
{
/* check if caller wanted an error reported */
if (error == NULL)
/* FIXME: what if multiple elements could have been used and they're all
* missing ? varargs ? */
static void
-gst_play_error_plugin (const gchar *element, GError ** error)
+gst_play_error_plugin (const gchar * element, GError ** error)
{
gchar *message;
message = g_strdup_printf ("The %s element could not be found. "
- "This element is essential for playback. "
- "Please install the right plug-in and verify "
- "that it works by running 'gst-inspect %s'",
- element, element);
+ "This element is essential for playback. "
+ "Please install the right plug-in and verify "
+ "that it works by running 'gst-inspect %s'", element, element);
gst_play_error_create (error, message);
g_free (message);
return;
static gboolean
-gst_play_pipeline_setup (GstPlay *play, GError **error)
+gst_play_pipeline_setup (GstPlay * play, GError ** error)
{
/* Threads */
GstElement *work_thread, *audio_thread, *video_thread;
+
/* Main Thread elements */
GstElement *source, *autoplugger, *audioconvert, *volume, *tee, *identity;
GstElement *identity_cs;
+
/* Visualization bin */
GstElement *vis_bin, *vis_queue, *vis_element, *vis_cs;
+
/* Video Thread elements */
GstElement *video_queue, *video_switch, *video_cs, *video_balance;
GstElement *balance_cs, *video_scaler, *video_sink;
+
/* Audio Thread elements */
GstElement *audio_queue, *audio_sink;
+
/* Some useful pads */
GstPad *tee_pad1, *tee_pad2;
-
+
g_return_val_if_fail (play != NULL, FALSE);
g_return_val_if_fail (GST_IS_PLAY (play), FALSE);
-
+
/* Creating main thread and its elements */
{
- GST_PLAY_MAKE_OR_ERROR (work_thread, "thread", "work_thread", error);
- g_hash_table_insert (play->priv->elements, "work_thread", work_thread);
- gst_bin_add (GST_BIN (play), work_thread);
-
- /* Placeholder for datasrc */
- GST_PLAY_MAKE_OR_ERROR (source, "fakesrc", "source", error);
- g_hash_table_insert (play->priv->elements, "source", source);
-
- /* Autoplugger */
- GST_PLAY_MAKE_OR_ERROR (autoplugger, "spider", "autoplugger", error);
- g_hash_table_insert (play->priv->elements, "autoplugger", autoplugger);
-
- /* Make sure we convert audio to the needed format */
- GST_PLAY_MAKE_OR_ERROR (audioconvert, "audioconvert", "audioconvert", error);
- g_hash_table_insert (play->priv->elements, "audioconvert", audioconvert);
-
- /* Duplicate audio signal to audio sink and visualization thread */
- GST_PLAY_MAKE_OR_ERROR (tee, "tee", "tee", error);
- tee_pad1 = gst_element_get_request_pad (tee, "src%d");
- tee_pad2 = gst_element_get_request_pad (tee, "src%d");
- g_hash_table_insert (play->priv->elements, "tee_pad1", tee_pad1);
- g_hash_table_insert (play->priv->elements, "tee_pad2", tee_pad2);
- g_hash_table_insert (play->priv->elements, "tee", tee);
-
- gst_bin_add_many (GST_BIN (work_thread), source, autoplugger, audioconvert, tee, NULL);
- if (!gst_element_link_many (source, autoplugger, audioconvert, tee, NULL))
- GST_PLAY_ERROR_RETURN (error, "Could not link source thread elements");
-
- /* identity ! colorspace ! switch */
- GST_PLAY_MAKE_OR_ERROR (identity, "identity", "identity", error);
- g_hash_table_insert (play->priv->elements, "identity", identity);
-
- identity_cs = gst_element_factory_make ("ffcolorspace", "identity_cs");
- if (!GST_IS_ELEMENT (identity_cs)) {
- identity_cs = gst_element_factory_make ("colorspace", "identity_cs");
- if (!GST_IS_ELEMENT (identity_cs))
- {
- gst_play_error_plugin ("colorspace", error);
- return FALSE;
+ GST_PLAY_MAKE_OR_ERROR (work_thread, "thread", "work_thread", error);
+ g_hash_table_insert (play->priv->elements, "work_thread", work_thread);
+ gst_bin_add (GST_BIN (play), work_thread);
+
+ /* Placeholder for datasrc */
+ GST_PLAY_MAKE_OR_ERROR (source, "fakesrc", "source", error);
+ g_hash_table_insert (play->priv->elements, "source", source);
+
+ /* Autoplugger */
+ GST_PLAY_MAKE_OR_ERROR (autoplugger, "spider", "autoplugger", error);
+ g_hash_table_insert (play->priv->elements, "autoplugger", autoplugger);
+
+ /* Make sure we convert audio to the needed format */
+ GST_PLAY_MAKE_OR_ERROR (audioconvert, "audioconvert", "audioconvert",
+ error);
+ g_hash_table_insert (play->priv->elements, "audioconvert", audioconvert);
+
+ /* Duplicate audio signal to audio sink and visualization thread */
+ GST_PLAY_MAKE_OR_ERROR (tee, "tee", "tee", error);
+ tee_pad1 = gst_element_get_request_pad (tee, "src%d");
+ tee_pad2 = gst_element_get_request_pad (tee, "src%d");
+ g_hash_table_insert (play->priv->elements, "tee_pad1", tee_pad1);
+ g_hash_table_insert (play->priv->elements, "tee_pad2", tee_pad2);
+ g_hash_table_insert (play->priv->elements, "tee", tee);
+
+ gst_bin_add_many (GST_BIN (work_thread), source, autoplugger, audioconvert,
+ tee, NULL);
+ if (!gst_element_link_many (source, autoplugger, audioconvert, tee, NULL))
+ GST_PLAY_ERROR_RETURN (error, "Could not link source thread elements");
+
+ /* identity ! colorspace ! switch */
+ GST_PLAY_MAKE_OR_ERROR (identity, "identity", "identity", error);
+ g_hash_table_insert (play->priv->elements, "identity", identity);
+
+ identity_cs = gst_element_factory_make ("ffcolorspace", "identity_cs");
+ if (!GST_IS_ELEMENT (identity_cs)) {
+ identity_cs = gst_element_factory_make ("colorspace", "identity_cs");
+ if (!GST_IS_ELEMENT (identity_cs)) {
+ gst_play_error_plugin ("colorspace", error);
+ return FALSE;
+ }
}
+ g_hash_table_insert (play->priv->elements, "identity_cs", identity_cs);
+ gst_bin_add_many (GST_BIN (work_thread), identity, identity_cs, NULL);
+ if (!gst_element_link_many (autoplugger, identity, identity_cs, NULL))
+ GST_PLAY_ERROR_RETURN (error, "Could not link work thread elements");
}
- g_hash_table_insert (play->priv->elements, "identity_cs", identity_cs);
- gst_bin_add_many (GST_BIN (work_thread), identity, identity_cs, NULL);
- if (!gst_element_link_many (autoplugger, identity, identity_cs, NULL))
- GST_PLAY_ERROR_RETURN (error, "Could not link work thread elements");
- }
-
+
/* Visualization bin (note: it s not added to the pipeline yet) */
{
- vis_bin = gst_bin_new ("vis_bin");
- if (!GST_IS_ELEMENT (vis_bin))
- {
- gst_play_error_plugin ("bin", error);
- return FALSE;
- }
-
- g_hash_table_insert (play->priv->elements, "vis_bin", vis_bin);
-
- /* Buffer queue for video data */
- GST_PLAY_MAKE_OR_ERROR (vis_queue, "queue", "vis_queue", error);
- g_hash_table_insert (play->priv->elements, "vis_queue", vis_queue);
-
- /* Visualization element placeholder */
- GST_PLAY_MAKE_OR_ERROR (vis_element, "identity", "vis_element", error);
- g_hash_table_insert (play->priv->elements, "vis_element", vis_element);
-
- /* Colorspace conversion */
- vis_cs = gst_element_factory_make ("ffcolorspace", "vis_cs");
- if (!GST_IS_ELEMENT (vis_cs)) {
- vis_cs = gst_element_factory_make ("colorspace", "vis_cs");
- if (!GST_IS_ELEMENT (vis_cs))
- {
- gst_play_error_plugin ("colorspace", error);
+ vis_bin = gst_bin_new ("vis_bin");
+ if (!GST_IS_ELEMENT (vis_bin)) {
+ gst_play_error_plugin ("bin", error);
return FALSE;
}
- }
-
- g_hash_table_insert (play->priv->elements, "vis_cs", vis_cs);
-
- gst_bin_add_many (GST_BIN (vis_bin), vis_queue, vis_element, vis_cs, NULL);
- if (!gst_element_link_many (vis_queue, vis_element, vis_cs, NULL))
- GST_PLAY_ERROR_RETURN (error, "Could not link visualisation thread elements");
- gst_element_add_ghost_pad (vis_bin,
- gst_element_get_pad (vis_cs, "src"), "src");
+
+ g_hash_table_insert (play->priv->elements, "vis_bin", vis_bin);
+
+ /* Buffer queue for video data */
+ GST_PLAY_MAKE_OR_ERROR (vis_queue, "queue", "vis_queue", error);
+ g_hash_table_insert (play->priv->elements, "vis_queue", vis_queue);
+
+ /* Visualization element placeholder */
+ GST_PLAY_MAKE_OR_ERROR (vis_element, "identity", "vis_element", error);
+ g_hash_table_insert (play->priv->elements, "vis_element", vis_element);
+
+ /* Colorspace conversion */
+ vis_cs = gst_element_factory_make ("ffcolorspace", "vis_cs");
+ if (!GST_IS_ELEMENT (vis_cs)) {
+ vis_cs = gst_element_factory_make ("colorspace", "vis_cs");
+ if (!GST_IS_ELEMENT (vis_cs)) {
+ gst_play_error_plugin ("colorspace", error);
+ return FALSE;
+ }
+ }
+
+ g_hash_table_insert (play->priv->elements, "vis_cs", vis_cs);
+
+ gst_bin_add_many (GST_BIN (vis_bin), vis_queue, vis_element, vis_cs, NULL);
+ if (!gst_element_link_many (vis_queue, vis_element, vis_cs, NULL))
+ GST_PLAY_ERROR_RETURN (error,
+ "Could not link visualisation thread elements");
+ gst_element_add_ghost_pad (vis_bin, gst_element_get_pad (vis_cs, "src"),
+ "src");
}
/* Creating our video output bin */
{
- GST_PLAY_MAKE_OR_ERROR (video_thread, "thread", "video_thread", error);
- g_hash_table_insert (play->priv->elements, "video_thread", video_thread);
- gst_bin_add (GST_BIN (work_thread), video_thread);
-
- /* Buffer queue for video data */
- GST_PLAY_MAKE_OR_ERROR (video_queue, "queue", "video_queue", error);
- g_hash_table_insert (play->priv->elements, "video_queue", video_queue);
-
- GST_PLAY_MAKE_OR_ERROR (video_switch, "switch", "video_switch", error);
- g_hash_table_insert (play->priv->elements, "video_switch", video_switch);
-
- /* Colorspace conversion */
- video_cs = gst_element_factory_make ("ffcolorspace", "video_cs");
- if (!GST_IS_ELEMENT (video_cs)) {
- video_cs = gst_element_factory_make ("colorspace", "video_cs");
- if (!GST_IS_ELEMENT (video_cs))
- {
- gst_play_error_plugin ("colorspace", error);
- return FALSE;
+ GST_PLAY_MAKE_OR_ERROR (video_thread, "thread", "video_thread", error);
+ g_hash_table_insert (play->priv->elements, "video_thread", video_thread);
+ gst_bin_add (GST_BIN (work_thread), video_thread);
+
+ /* Buffer queue for video data */
+ GST_PLAY_MAKE_OR_ERROR (video_queue, "queue", "video_queue", error);
+ g_hash_table_insert (play->priv->elements, "video_queue", video_queue);
+
+ GST_PLAY_MAKE_OR_ERROR (video_switch, "switch", "video_switch", error);
+ g_hash_table_insert (play->priv->elements, "video_switch", video_switch);
+
+ /* Colorspace conversion */
+ video_cs = gst_element_factory_make ("ffcolorspace", "video_cs");
+ if (!GST_IS_ELEMENT (video_cs)) {
+ video_cs = gst_element_factory_make ("colorspace", "video_cs");
+ if (!GST_IS_ELEMENT (video_cs)) {
+ gst_play_error_plugin ("colorspace", error);
+ return FALSE;
+ }
}
- }
- g_hash_table_insert (play->priv->elements, "video_cs", video_cs);
-
- /* Software colorbalance */
- GST_PLAY_MAKE_OR_ERROR (video_balance, "videobalance", "video_balance", error);
- g_hash_table_insert (play->priv->elements, "video_balance", video_balance);
-
- /* Colorspace conversion */
- balance_cs = gst_element_factory_make ("ffcolorspace", "balance_cs");
- if (!GST_IS_ELEMENT (balance_cs)) {
- balance_cs = gst_element_factory_make ("colorspace", "balance_cs");
- if (!GST_IS_ELEMENT (balance_cs))
- {
- gst_play_error_plugin ("colorspace", error);
- return FALSE;
+ g_hash_table_insert (play->priv->elements, "video_cs", video_cs);
+
+ /* Software colorbalance */
+ GST_PLAY_MAKE_OR_ERROR (video_balance, "videobalance", "video_balance",
+ error);
+ g_hash_table_insert (play->priv->elements, "video_balance", video_balance);
+
+ /* Colorspace conversion */
+ balance_cs = gst_element_factory_make ("ffcolorspace", "balance_cs");
+ if (!GST_IS_ELEMENT (balance_cs)) {
+ balance_cs = gst_element_factory_make ("colorspace", "balance_cs");
+ if (!GST_IS_ELEMENT (balance_cs)) {
+ gst_play_error_plugin ("colorspace", error);
+ return FALSE;
+ }
}
- }
- g_hash_table_insert (play->priv->elements, "balance_cs", balance_cs);
-
- /* Software scaling of video stream */
- GST_PLAY_MAKE_OR_ERROR (video_scaler, "videoscale", "video_scaler", error);
- g_hash_table_insert (play->priv->elements, "video_scaler", video_scaler);
- g_signal_connect (gst_element_get_pad(video_scaler, "src"), "fixate",
- G_CALLBACK (gst_play_video_fixate), play);
-
- /* Placeholder for future video sink bin */
- GST_PLAY_MAKE_OR_ERROR (video_sink, "fakesink", "video_sink", error);
- g_hash_table_insert (play->priv->elements, "video_sink", video_sink);
-
- gst_bin_add_many (GST_BIN (video_thread), video_queue, video_switch, video_cs,
- video_balance, balance_cs, video_scaler, video_sink, NULL);
- /* break down linking so we can figure out what might be failing */
- if (!gst_element_link (video_queue, video_switch))
- GST_PLAY_ERROR_RETURN (error, "Could not link video output thread (queue and switch)");
- if (!gst_element_link (video_switch, video_cs))
- GST_PLAY_ERROR_RETURN (error, "Could not link video output thread (switch and cs)");
- if (!gst_element_link (video_cs, video_balance))
- GST_PLAY_ERROR_RETURN (error, "Could not link video output thread (cs and balance)");
- if (!gst_element_link (video_balance, balance_cs))
- GST_PLAY_ERROR_RETURN (error, "Could not link video output thread (balance and balance_cs)");
- if (!gst_element_link (balance_cs, video_scaler))
- GST_PLAY_ERROR_RETURN (error, "Could not link video output thread (balance_cs and scaler)");
- if (!gst_element_link (video_scaler, video_sink))
- GST_PLAY_ERROR_RETURN (error, "Could not link video output thread (balance_cs and scaler)");
- gst_element_add_ghost_pad (video_thread,
- gst_element_get_pad (video_queue, "sink"),
- "sink");
- if (!gst_element_link (identity_cs, video_thread))
- GST_PLAY_ERROR_RETURN (error, "Could not link video output thread elements");
+ g_hash_table_insert (play->priv->elements, "balance_cs", balance_cs);
+
+ /* Software scaling of video stream */
+ GST_PLAY_MAKE_OR_ERROR (video_scaler, "videoscale", "video_scaler", error);
+ g_hash_table_insert (play->priv->elements, "video_scaler", video_scaler);
+ g_signal_connect (gst_element_get_pad (video_scaler, "src"), "fixate",
+ G_CALLBACK (gst_play_video_fixate), play);
+
+ /* Placeholder for future video sink bin */
+ GST_PLAY_MAKE_OR_ERROR (video_sink, "fakesink", "video_sink", error);
+ g_hash_table_insert (play->priv->elements, "video_sink", video_sink);
+
+ gst_bin_add_many (GST_BIN (video_thread), video_queue, video_switch,
+ video_cs, video_balance, balance_cs, video_scaler, video_sink, NULL);
+ /* break down linking so we can figure out what might be failing */
+ if (!gst_element_link (video_queue, video_switch))
+ GST_PLAY_ERROR_RETURN (error,
+ "Could not link video output thread (queue and switch)");
+ if (!gst_element_link (video_switch, video_cs))
+ GST_PLAY_ERROR_RETURN (error,
+ "Could not link video output thread (switch and cs)");
+ if (!gst_element_link (video_cs, video_balance))
+ GST_PLAY_ERROR_RETURN (error,
+ "Could not link video output thread (cs and balance)");
+ if (!gst_element_link (video_balance, balance_cs))
+ GST_PLAY_ERROR_RETURN (error,
+ "Could not link video output thread (balance and balance_cs)");
+ if (!gst_element_link (balance_cs, video_scaler))
+ GST_PLAY_ERROR_RETURN (error,
+ "Could not link video output thread (balance_cs and scaler)");
+ if (!gst_element_link (video_scaler, video_sink))
+ GST_PLAY_ERROR_RETURN (error,
+ "Could not link video output thread (balance_cs and scaler)");
+ gst_element_add_ghost_pad (video_thread, gst_element_get_pad (video_queue,
+ "sink"), "sink");
+ if (!gst_element_link (identity_cs, video_thread))
+ GST_PLAY_ERROR_RETURN (error,
+ "Could not link video output thread elements");
}
/* Creating our audio output bin
{ queue ! fakesink } */
{
- GST_PLAY_MAKE_OR_ERROR (audio_thread, "thread", "audio_thread", error);
- g_hash_table_insert (play->priv->elements, "audio_thread", audio_thread);
- gst_bin_add (GST_BIN (work_thread), audio_thread);
-
- /* Buffer queue for our audio thread */
- GST_PLAY_MAKE_OR_ERROR (audio_queue, "queue", "audio_queue", error);
- g_hash_table_insert (play->priv->elements, "audio_queue", audio_queue);
-
- /* Volume control */
- GST_PLAY_MAKE_OR_ERROR (volume, "volume", "volume", error);
- g_hash_table_insert (play->priv->elements, "volume", volume);
- g_signal_connect (gst_element_get_pad(volume, "src"), "fixate",
- G_CALLBACK (gst_play_audio_fixate), play);
-
- /* Placeholder for future audio sink bin */
- GST_PLAY_MAKE_OR_ERROR (audio_sink, "fakesink", "audio_sink", error);
- g_hash_table_insert (play->priv->elements, "audio_sink", audio_sink);
-
- gst_bin_add_many (GST_BIN (audio_thread), audio_queue, volume, audio_sink, NULL);
- if (!gst_element_link_many (audio_queue, volume, audio_sink, NULL))
- GST_PLAY_ERROR_RETURN (error, "Could not link audio output thread elements");
- gst_element_add_ghost_pad (audio_thread,
- gst_element_get_pad (audio_queue, "sink"),
- "sink");
- gst_pad_link (tee_pad2, gst_element_get_pad (audio_queue, "sink"));
+ GST_PLAY_MAKE_OR_ERROR (audio_thread, "thread", "audio_thread", error);
+ g_hash_table_insert (play->priv->elements, "audio_thread", audio_thread);
+ gst_bin_add (GST_BIN (work_thread), audio_thread);
+
+ /* Buffer queue for our audio thread */
+ GST_PLAY_MAKE_OR_ERROR (audio_queue, "queue", "audio_queue", error);
+ g_hash_table_insert (play->priv->elements, "audio_queue", audio_queue);
+
+ /* Volume control */
+ GST_PLAY_MAKE_OR_ERROR (volume, "volume", "volume", error);
+ g_hash_table_insert (play->priv->elements, "volume", volume);
+ g_signal_connect (gst_element_get_pad (volume, "src"), "fixate",
+ G_CALLBACK (gst_play_audio_fixate), play);
+
+ /* Placeholder for future audio sink bin */
+ GST_PLAY_MAKE_OR_ERROR (audio_sink, "fakesink", "audio_sink", error);
+ g_hash_table_insert (play->priv->elements, "audio_sink", audio_sink);
+
+ gst_bin_add_many (GST_BIN (audio_thread), audio_queue, volume, audio_sink,
+ NULL);
+ if (!gst_element_link_many (audio_queue, volume, audio_sink, NULL))
+ GST_PLAY_ERROR_RETURN (error,
+ "Could not link audio output thread elements");
+ gst_element_add_ghost_pad (audio_thread, gst_element_get_pad (audio_queue,
+ "sink"), "sink");
+ gst_pad_link (tee_pad2, gst_element_get_pad (audio_queue, "sink"));
}
-
+
return TRUE;
}
static void
-gst_play_have_video_size (GstElement *element, gint width,
- gint height, GstPlay *play)
+gst_play_have_video_size (GstElement * element, gint width,
+ gint height, GstPlay * play)
{
g_return_if_fail (play != NULL);
g_return_if_fail (GST_IS_PLAY (play));
g_signal_emit (G_OBJECT (play), gst_play_signals[HAVE_VIDEO_SIZE],
- 0, width, height);
+ 0, width, height);
}
static gboolean
-gst_play_tick_callback (GstPlay *play)
+gst_play_tick_callback (GstPlay * play)
{
GstFormat format = GST_FORMAT_TIME;
gboolean q = FALSE;
GstElement *audio_sink_element = NULL;
-
+
g_return_val_if_fail (play != NULL, FALSE);
/* just return without updating the UI when we are in the middle of seeking */
- if (play->priv->tick_unblock_remaining > 0)
- {
+ if (play->priv->tick_unblock_remaining > 0) {
play->priv->tick_unblock_remaining -= TICK_INTERVAL_MSEC;
return TRUE;
}
-
+
if (!GST_IS_PLAY (play)) {
play->priv->tick_id = 0;
return FALSE;
}
-
+
audio_sink_element = g_hash_table_lookup (play->priv->elements,
- "audio_sink_element");
-
+ "audio_sink_element");
+
if (!GST_IS_ELEMENT (audio_sink_element)) {
play->priv->tick_id = 0;
return FALSE;
}
-
+
q = gst_element_query (audio_sink_element, GST_QUERY_POSITION, &format,
- &(play->priv->time_nanos));
-
+ &(play->priv->time_nanos));
+
if (q)
g_signal_emit (G_OBJECT (play), gst_play_signals[TIME_TICK],
- 0,play->priv->time_nanos);
-
+ 0, play->priv->time_nanos);
+
if (GST_STATE (GST_ELEMENT (play)) == GST_STATE_PLAYING)
return TRUE;
else {
}
static gboolean
-gst_play_get_length_callback (GstPlay *play)
+gst_play_get_length_callback (GstPlay * play)
{
GstElement *audio_sink_element, *video_sink_element;
GstFormat format = GST_FORMAT_TIME;
gint64 value;
gboolean q = FALSE;
-
+
g_return_val_if_fail (play != NULL, FALSE);
g_return_val_if_fail (GST_IS_PLAY (play), FALSE);
-
+
/* We try to get length from all real sink elements */
audio_sink_element = g_hash_table_lookup (play->priv->elements,
- "audio_sink_element");
+ "audio_sink_element");
video_sink_element = g_hash_table_lookup (play->priv->elements,
- "video_sink_element");
+ "video_sink_element");
if (!GST_IS_ELEMENT (audio_sink_element) &&
!GST_IS_ELEMENT (video_sink_element)) {
play->priv->length_id = 0;
return FALSE;
}
-
+
/* Audio first and then Video */
if (GST_IS_ELEMENT (audio_sink_element))
q = gst_element_query (audio_sink_element, GST_QUERY_TOTAL, &format,
- &value);
- if ( (!q) && (GST_IS_ELEMENT (video_sink_element)) )
+ &value);
+ if ((!q) && (GST_IS_ELEMENT (video_sink_element)))
q = gst_element_query (video_sink_element, GST_QUERY_TOTAL, &format,
- &value);
-
+ &value);
+
if (q) {
play->priv->length_nanos = value;
g_signal_emit (G_OBJECT (play), gst_play_signals[STREAM_LENGTH],
- 0,play->priv->length_nanos);
+ 0, play->priv->length_nanos);
play->priv->length_id = 0;
return FALSE;
}
-
+
play->priv->get_length_attempt++;
-
+
/* We try 16 times */
if (play->priv->get_length_attempt > 15) {
play->priv->length_id = 0;
return FALSE;
- }
- else
+ } else
return TRUE;
}
static GstCaps *
-gst_play_video_fixate (GstPad *pad, const GstCaps *caps, gpointer user_data)
+gst_play_video_fixate (GstPad * pad, const GstCaps * caps, gpointer user_data)
{
GstStructure *structure;
GstCaps *newcaps;
GST_DEBUG ("video fixate %p %" GST_PTR_FORMAT, pad, caps);
- if (gst_caps_get_size (caps) > 1) return NULL;
+ if (gst_caps_get_size (caps) > 1)
+ return NULL;
newcaps = gst_caps_copy (caps);
structure = gst_caps_get_structure (newcaps, 0);
return newcaps;
}
if (gst_caps_structure_fixate_field_nearest_double (structure, "framerate",
- 30.0)) {
+ 30.0)) {
return newcaps;
}
}
static GstCaps *
-gst_play_audio_fixate (GstPad *pad, const GstCaps *caps, gpointer user_data)
+gst_play_audio_fixate (GstPad * pad, const GstCaps * caps, gpointer user_data)
{
GstCaps *newcaps;
GstStructure *structure;
GST_DEBUG ("audio fixate %p %" GST_PTR_FORMAT, pad, caps);
- newcaps = gst_caps_new_full (gst_structure_copy (
- gst_caps_get_structure (caps, 0)), NULL);
+ newcaps =
+ gst_caps_new_full (gst_structure_copy (gst_caps_get_structure (caps, 0)),
+ NULL);
structure = gst_caps_get_structure (newcaps, 0);
if (gst_caps_structure_fixate_field_nearest_int (structure, "rate", 44100)) {
}
static void
-gst_play_state_change (GstElement *element, GstElementState old,
- GstElementState state)
+gst_play_state_change (GstElement * element, GstElementState old,
+ GstElementState state)
{
GstPlay *play;
-
+
g_return_if_fail (element != NULL);
g_return_if_fail (GST_IS_PLAY (element));
-
+
play = GST_PLAY (element);
-
+
if (state == GST_STATE_PLAYING) {
if (play->priv->tick_id) {
g_source_remove (play->priv->tick_id);
play->priv->tick_id = 0;
}
-
+
play->priv->tick_id = g_timeout_add (TICK_INTERVAL_MSEC,
- (GSourceFunc) gst_play_tick_callback,
- play);
-
+ (GSourceFunc) gst_play_tick_callback, play);
+
play->priv->get_length_attempt = 0;
-
+
if (play->priv->length_id) {
g_source_remove (play->priv->length_id);
play->priv->length_id = 0;
}
-
+
play->priv->length_id = g_timeout_add (TICK_INTERVAL_MSEC,
- (GSourceFunc) gst_play_get_length_callback,
- play);
- }
- else {
+ (GSourceFunc) gst_play_get_length_callback, play);
+ } else {
if (play->priv->tick_id) {
g_source_remove (play->priv->tick_id);
play->priv->tick_id = 0;
play->priv->length_id = 0;
}
}
-
+
if (GST_ELEMENT_CLASS (parent_class)->state_change)
GST_ELEMENT_CLASS (parent_class)->state_change (element, old, state);
}
static void
-gst_play_identity_handoff (GstElement *identity, GstBuffer *buf, GstPlay *play)
+gst_play_identity_handoff (GstElement * identity, GstBuffer * buf,
+ GstPlay * play)
{
g_signal_handler_disconnect (G_OBJECT (identity), play->priv->handoff_hid);
play->priv->handoff_hid = 0;
/* =========================================== */
static void
-gst_play_dispose (GObject *object)
+gst_play_dispose (GObject * object)
{
GstPlay *play;
-
+
g_return_if_fail (object != NULL);
g_return_if_fail (GST_IS_PLAY (object));
-
+
play = GST_PLAY (object);
-
+
if (play->priv->length_id) {
g_source_remove (play->priv->length_id);
play->priv->length_id = 0;
}
-
+
if (play->priv->tick_id) {
g_source_remove (play->priv->tick_id);
play->priv->tick_id = 0;
}
-
+
if (play->priv->location) {
g_free (play->priv->location);
play->priv->location = NULL;
}
-
+
if (play->priv->elements) {
g_hash_table_destroy (play->priv->elements);
play->priv->elements = NULL;
}
-
+
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
-gst_play_init (GstPlay *play)
+gst_play_init (GstPlay * play)
{
play->priv = g_new0 (GstPlayPrivate, 1);
play->priv->location = NULL;
play->priv->elements = g_hash_table_new (g_str_hash, g_str_equal);
play->priv->error = NULL;
play->priv->debug = NULL;
-
- if (!gst_play_pipeline_setup (play, &play->priv->error))
- {
+
+ if (!gst_play_pipeline_setup (play, &play->priv->error)) {
g_warning ("libgstplay: failed initializing pipeline, error: %s",
- play->priv->error->message);
+ play->priv->error->message);
}
}
static void
-gst_play_class_init (GstPlayClass *klass)
+gst_play_class_init (GstPlayClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
+
parent_class = g_type_class_peek_parent (klass);
gobject_class->dispose = gst_play_dispose;
element_class->state_change = gst_play_state_change;
-
+
gst_play_signals[TIME_TICK] =
- g_signal_new ("time-tick", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GstPlayClass, time_tick), NULL, NULL,
- gst_marshal_VOID__INT64, G_TYPE_NONE, 1, G_TYPE_INT64);
+ g_signal_new ("time-tick", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GstPlayClass, time_tick), NULL, NULL,
+ gst_marshal_VOID__INT64, G_TYPE_NONE, 1, G_TYPE_INT64);
gst_play_signals[STREAM_LENGTH] =
- g_signal_new ("stream-length", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GstPlayClass, stream_length), NULL, NULL,
- gst_marshal_VOID__INT64, G_TYPE_NONE, 1, G_TYPE_INT64);
+ g_signal_new ("stream-length", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GstPlayClass, stream_length), NULL, NULL,
+ gst_marshal_VOID__INT64, G_TYPE_NONE, 1, G_TYPE_INT64);
gst_play_signals[HAVE_VIDEO_SIZE] =
- g_signal_new ("have-video-size", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (GstPlayClass, have_video_size), NULL, NULL,
- gst_marshal_VOID__INT_INT, G_TYPE_NONE, 2,
- G_TYPE_INT, G_TYPE_INT);
+ g_signal_new ("have-video-size", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GstPlayClass, have_video_size), NULL, NULL,
+ gst_marshal_VOID__INT_INT, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
}
/* ======================================================= */
* Returns: TRUE if location was set successfully.
*/
gboolean
-gst_play_set_location (GstPlay *play, const char *location)
+gst_play_set_location (GstPlay * play, const char *location)
{
GstElement *work_thread, *source, *autoplugger;
GstElement *audioconvert, *identity;
-
+
g_return_val_if_fail (play != NULL, FALSE);
g_return_val_if_fail (GST_IS_PLAY (play), FALSE);
-
+
if (play->priv->location)
g_free (play->priv->location);
-
+
play->priv->location = g_strdup (location);
-
+
if (GST_STATE (GST_ELEMENT (play)) != GST_STATE_READY)
gst_element_set_state (GST_ELEMENT (play), GST_STATE_READY);
-
+
work_thread = g_hash_table_lookup (play->priv->elements, "work_thread");
if (!GST_IS_ELEMENT (work_thread))
return FALSE;
identity = g_hash_table_lookup (play->priv->elements, "identity");
if (!GST_IS_ELEMENT (identity))
return FALSE;
-
+
/* Spider can autoplugg only once. We remove the actual one and put a new
autoplugger */
gst_element_unlink (source, autoplugger);
gst_element_unlink (autoplugger, identity);
gst_element_unlink (autoplugger, audioconvert);
gst_bin_remove (GST_BIN (work_thread), autoplugger);
-
+
autoplugger = gst_element_factory_make ("spider", "autoplugger");
if (!GST_IS_ELEMENT (autoplugger))
return FALSE;
-
+
gst_bin_add (GST_BIN (work_thread), autoplugger);
gst_element_link (source, autoplugger);
gst_element_link (autoplugger, audioconvert);
gst_element_link (autoplugger, identity);
-
+
g_hash_table_replace (play->priv->elements, "autoplugger", autoplugger);
-
+
/* FIXME: Why don't we have an interface to do that kind of stuff ? */
g_object_set (G_OBJECT (source), "location", play->priv->location, NULL);
-
+
play->priv->length_nanos = 0LL;
play->priv->time_nanos = 0LL;
-
+
g_signal_emit (G_OBJECT (play), gst_play_signals[STREAM_LENGTH], 0, 0LL);
g_signal_emit (G_OBJECT (play), gst_play_signals[TIME_TICK], 0, 0LL);
-
+
return TRUE;
}
* Returns: a const #char* pointer to current location.
*/
char *
-gst_play_get_location (GstPlay *play)
+gst_play_get_location (GstPlay * play)
{
g_return_val_if_fail (play != NULL, NULL);
g_return_val_if_fail (GST_IS_PLAY (play), NULL);
gst_play_seek_to_time (GstPlay * play, gint64 time_nanos)
{
GstElement *audio_seek_element, *video_seek_element, *audio_sink_element;
-
+
g_return_val_if_fail (play != NULL, FALSE);
g_return_val_if_fail (GST_IS_PLAY (play), FALSE);
-
+
if (time_nanos < 0LL)
time_nanos = 0LL;
-
+
audio_seek_element = g_hash_table_lookup (play->priv->elements,
- "audioconvert");
+ "audioconvert");
audio_sink_element = g_hash_table_lookup (play->priv->elements,
- "audio_sink_element");
- video_seek_element = g_hash_table_lookup (play->priv->elements,
- "identity");
-
+ "audio_sink_element");
+ video_seek_element = g_hash_table_lookup (play->priv->elements, "identity");
+
if (GST_IS_ELEMENT (audio_seek_element) &&
GST_IS_ELEMENT (video_seek_element) &&
GST_IS_ELEMENT (audio_sink_element)) {
gboolean s = FALSE;
-
+
/* HACK: block tick signal from idler for 500 msec */
/* GStreamer can't currently report when seeking is finished,
so we just chose a .5 sec default block time */
play->priv->tick_unblock_remaining = 500;
-
+
s = gst_element_seek (video_seek_element, GST_FORMAT_TIME |
- GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH,
- time_nanos);
+ GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, time_nanos);
if (!s) {
s = gst_element_seek (audio_seek_element, GST_FORMAT_TIME |
- GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH,
- time_nanos);
+ GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, time_nanos);
}
-
+
if (s) {
GstFormat format = GST_FORMAT_TIME;
gboolean q = FALSE;
-
+
q = gst_element_query (audio_sink_element, GST_QUERY_POSITION, &format,
- &(play->priv->time_nanos));
+ &(play->priv->time_nanos));
if (q)
- g_signal_emit (G_OBJECT (play), gst_play_signals[TIME_TICK],
- 0,play->priv->time_nanos);
+ g_signal_emit (G_OBJECT (play), gst_play_signals[TIME_TICK],
+ 0, play->priv->time_nanos);
}
}
-
+
return TRUE;
}
* Returns: TRUE if call succeeded.
*/
gboolean
-gst_play_set_data_src (GstPlay *play, GstElement *data_src)
+gst_play_set_data_src (GstPlay * play, GstElement * data_src)
{
GstElement *work_thread, *old_data_src, *autoplugger;
-
+
g_return_val_if_fail (play != NULL, FALSE);
g_return_val_if_fail (GST_IS_PLAY (play), FALSE);
-
+
/* We bring back the pipeline to READY */
if (GST_STATE (GST_ELEMENT (play)) != GST_STATE_READY)
gst_element_set_state (GST_ELEMENT (play), GST_STATE_READY);
-
+
/* Getting needed objects */
work_thread = g_hash_table_lookup (play->priv->elements, "work_thread");
if (!GST_IS_ELEMENT (work_thread))
autoplugger = g_hash_table_lookup (play->priv->elements, "autoplugger");
if (!GST_IS_ELEMENT (autoplugger))
return FALSE;
-
+
/* Unlinking old source from autoplugger, removing it from pipeline, adding
the new one and connecting it to autoplugger FIXME: we should put a new
autoplugger here as spider can autoplugg only once */
gst_bin_remove (GST_BIN (work_thread), old_data_src);
gst_bin_add (GST_BIN (work_thread), data_src);
gst_element_link (data_src, autoplugger);
-
+
g_hash_table_replace (play->priv->elements, "source", data_src);
-
+
return TRUE;
}
* Returns: TRUE if call succeeded.
*/
gboolean
-gst_play_set_video_sink (GstPlay *play, GstElement *video_sink)
+gst_play_set_video_sink (GstPlay * play, GstElement * video_sink)
{
GstElement *video_thread, *old_video_sink, *video_scaler, *video_sink_element;
-
+
g_return_val_if_fail (play != NULL, FALSE);
g_return_val_if_fail (GST_IS_PLAY (play), FALSE);
g_return_val_if_fail (video_sink != NULL, FALSE);
g_return_val_if_fail (GST_IS_ELEMENT (video_sink), FALSE);
-
+
/* We bring back the pipeline to READY */
if (GST_STATE (GST_ELEMENT (play)) != GST_STATE_READY)
gst_element_set_state (GST_ELEMENT (play), GST_STATE_READY);
-
+
/* Getting needed objects */
video_thread = g_hash_table_lookup (play->priv->elements, "video_thread");
if (!GST_IS_ELEMENT (video_thread))
video_scaler = g_hash_table_lookup (play->priv->elements, "video_scaler");
if (!GST_IS_ELEMENT (video_scaler))
return FALSE;
-
+
/* Unlinking old video sink from video scaler, removing it from pipeline,
adding the new one and linking it */
gst_element_unlink (video_scaler, old_video_sink);
gst_bin_remove (GST_BIN (video_thread), old_video_sink);
gst_bin_add (GST_BIN (video_thread), video_sink);
gst_element_link (video_scaler, video_sink);
-
+
g_hash_table_replace (play->priv->elements, "video_sink", video_sink);
-
+
video_sink_element = gst_play_get_sink_element (play, video_sink,
- GST_PLAY_SINK_TYPE_VIDEO);
+ GST_PLAY_SINK_TYPE_VIDEO);
if (GST_IS_ELEMENT (video_sink_element)) {
g_hash_table_replace (play->priv->elements, "video_sink_element",
- video_sink_element);
+ video_sink_element);
if (GST_IS_X_OVERLAY (video_sink_element)) {
g_signal_connect (G_OBJECT (video_sink_element),
- "desired_size_changed",
- G_CALLBACK (gst_play_have_video_size), play);
+ "desired_size_changed", G_CALLBACK (gst_play_have_video_size), play);
}
- }
-
- gst_element_set_state (video_sink, GST_STATE (GST_ELEMENT(play)));
-
+ }
+
+ gst_element_set_state (video_sink, GST_STATE (GST_ELEMENT (play)));
+
return TRUE;
}
* Returns: TRUE if call succeeded.
*/
gboolean
-gst_play_set_audio_sink (GstPlay *play, GstElement *audio_sink)
+gst_play_set_audio_sink (GstPlay * play, GstElement * audio_sink)
{
GstElement *old_audio_sink, *audio_thread, *volume, *audio_sink_element;
-
+
g_return_val_if_fail (play != NULL, FALSE);
g_return_val_if_fail (GST_IS_PLAY (play), FALSE);
g_return_val_if_fail (audio_sink != NULL, FALSE);
g_return_val_if_fail (GST_IS_ELEMENT (audio_sink), FALSE);
-
+
/* We bring back the pipeline to READY */
if (GST_STATE (GST_ELEMENT (play)) != GST_STATE_READY)
gst_element_set_state (GST_ELEMENT (play), GST_STATE_READY);
-
+
/* Getting needed objects */
old_audio_sink = g_hash_table_lookup (play->priv->elements, "audio_sink");
if (!GST_IS_ELEMENT (old_audio_sink))
volume = g_hash_table_lookup (play->priv->elements, "volume");
if (!GST_IS_ELEMENT (volume))
return FALSE;
-
+
/* Unlinking old audiosink, removing it from pipeline, putting the new one
and linking it */
gst_element_unlink (volume, old_audio_sink);
gst_bin_remove (GST_BIN (audio_thread), old_audio_sink);
gst_bin_add (GST_BIN (audio_thread), audio_sink);
gst_element_link (volume, audio_sink);
-
+
g_hash_table_replace (play->priv->elements, "audio_sink", audio_sink);
-
+
audio_sink_element = gst_play_get_sink_element (play, audio_sink,
- GST_PLAY_SINK_TYPE_AUDIO);
+ GST_PLAY_SINK_TYPE_AUDIO);
if (GST_IS_ELEMENT (audio_sink_element)) {
g_hash_table_replace (play->priv->elements, "audio_sink_element",
- audio_sink_element);
+ audio_sink_element);
}
-
- gst_element_set_state (audio_sink, GST_STATE (GST_ELEMENT(play)));
-
+
+ gst_element_set_state (audio_sink, GST_STATE (GST_ELEMENT (play)));
+
return TRUE;
}
* Returns: TRUE if call succeeded.
*/
gboolean
-gst_play_set_visualization (GstPlay *play, GstElement *vis_element)
+gst_play_set_visualization (GstPlay * play, GstElement * vis_element)
{
GstElement *vis_bin, *vis_queue, *old_vis_element, *vis_cs;
gboolean was_playing = FALSE;
-
+
g_return_val_if_fail (play != NULL, FALSE);
g_return_val_if_fail (GST_IS_PLAY (play), FALSE);
g_return_val_if_fail (vis_element != NULL, FALSE);
g_return_val_if_fail (GST_IS_ELEMENT (vis_element), FALSE);
-
+
/* Getting needed objects */
vis_bin = g_hash_table_lookup (play->priv->elements, "vis_bin");
if (!GST_IS_ELEMENT (vis_bin))
vis_queue = g_hash_table_lookup (play->priv->elements, "vis_queue");
if (!GST_IS_ELEMENT (vis_queue))
return FALSE;
- old_vis_element = g_hash_table_lookup (play->priv->elements,
- "vis_element");
+ old_vis_element = g_hash_table_lookup (play->priv->elements, "vis_element");
if (!GST_IS_ELEMENT (old_vis_element))
return FALSE;
vis_cs = g_hash_table_lookup (play->priv->elements, "vis_cs");
if (!GST_IS_ELEMENT (vis_cs))
return FALSE;
-
+
/* We bring back the pipeline to PAUSED */
if (GST_STATE (GST_ELEMENT (play)) == GST_STATE_PLAYING) {
gst_element_set_state (GST_ELEMENT (play), GST_STATE_PAUSED);
gst_bin_remove (GST_BIN (vis_bin), old_vis_element);
gst_bin_add (GST_BIN (vis_bin), vis_element);
gst_element_link_many (vis_queue, vis_element, vis_cs, NULL);
-
+
g_hash_table_replace (play->priv->elements, "vis_element", vis_element);
-
+
if (was_playing)
gst_element_set_state (GST_ELEMENT (play), GST_STATE_PLAYING);
-
+
return TRUE;
}
GstElement *video_thread, *vis_queue, *vis_bin, *video_switch, *identity;
GstPad *tee_pad1, *vis_queue_pad, *vis_bin_pad, *switch_pad;
gboolean was_playing = FALSE;
-
+
g_return_val_if_fail (play != NULL, FALSE);
g_return_val_if_fail (GST_IS_PLAY (play), FALSE);
-
+
/* Until i fix the switch */
return TRUE;
-
+
/* Getting needed objects */
video_thread = g_hash_table_lookup (play->priv->elements, "video_thread");
if (!GST_IS_ELEMENT (video_thread))
tee_pad1 = g_hash_table_lookup (play->priv->elements, "tee_pad1");
if (!GST_IS_PAD (tee_pad1))
return FALSE;
-
+
vis_queue_pad = gst_element_get_pad (vis_queue, "sink");
-
+
/* Check if the vis element is in the pipeline. That means visualization is
connected already */
if (gst_element_get_managing_bin (vis_bin)) {
-
+
/* If we are supposed to connect then nothing to do we return */
if (connect) {
return TRUE;
}
-
+
/* Disconnecting visualization */
-
+
/* We bring back the pipeline to PAUSED */
if (GST_STATE (GST_ELEMENT (play)) == GST_STATE_PLAYING) {
gst_element_set_state (GST_ELEMENT (play), GST_STATE_PAUSED);
was_playing = TRUE;
}
-
+
/* Unlinking, removing */
gst_pad_unlink (tee_pad1, vis_queue_pad);
vis_bin_pad = gst_element_get_pad (vis_bin, "src");
gst_element_release_request_pad (video_switch, switch_pad);
gst_object_ref (GST_OBJECT (vis_bin));
gst_bin_remove (GST_BIN (video_thread), vis_bin);
- }
- else {
-
+ } else {
+
/* If we are supposed to disconnect then nothing to do we return */
if (!connect) {
return TRUE;
}
-
+
/* Connecting visualization */
-
+
/* We bring back the pipeline to PAUSED */
if (GST_STATE (GST_ELEMENT (play)) == GST_STATE_PLAYING) {
gst_element_set_state (GST_ELEMENT (play), GST_STATE_PAUSED);
was_playing = TRUE;
}
-
+
/* Adding, linking */
play->priv->handoff_hid = g_signal_connect (G_OBJECT (identity),
- "handoff",
- G_CALLBACK (gst_play_identity_handoff), play);
+ "handoff", G_CALLBACK (gst_play_identity_handoff), play);
gst_bin_add (GST_BIN (video_thread), vis_bin);
gst_pad_link (tee_pad1, vis_queue_pad);
gst_element_link (vis_bin, video_switch);
if (was_playing)
gst_element_set_state (GST_ELEMENT (play), GST_STATE_PLAYING);
-
+
return TRUE;
}
* Returns: the sink #GstElement of @element.
*/
GstElement *
-gst_play_get_sink_element (GstPlay *play,
- GstElement *element, GstPlaySinkType sink_type)
+gst_play_get_sink_element (GstPlay * play,
+ GstElement * element, GstPlaySinkType sink_type)
{
GList *elements = NULL;
const GList *pads = NULL;
if (GST_IS_BIN (element)) {
element = gst_play_get_sink_element (play, element, sink_type);
if (GST_IS_ELEMENT (element))
- return element;
- }
- else {
+ return element;
+ } else {
pads = gst_element_get_pad_list (element);
has_src = FALSE;
has_correct_type = FALSE;
while (pads) {
- /* check for src pad */
- if (GST_PAD_DIRECTION (GST_PAD (pads->data)) == GST_PAD_SRC) {
- has_src = TRUE;
- break;
- }
- else {
- /* If not a src pad checking caps */
- GstCaps *caps;
- GstStructure *structure;
- gboolean has_video_cap = FALSE;
- gboolean has_audio_cap = FALSE;
-
- caps = gst_pad_get_caps (GST_PAD (pads->data));
- structure = gst_caps_get_structure (caps, 0);
-
- if (strcmp (gst_structure_get_name (structure),
- "audio/x-raw-int") == 0) {
- has_audio_cap = TRUE;
- }
-
- if (strcmp (gst_structure_get_name (structure),
- "video/x-raw-yuv") == 0 ||
- strcmp (gst_structure_get_name (structure),
- "video/x-raw-rgb") == 0) {
- has_video_cap = TRUE;
- }
-
- gst_caps_free (caps);
-
- switch (sink_type) {
- case GST_PLAY_SINK_TYPE_AUDIO:
- if (has_audio_cap)
- has_correct_type = TRUE;
- break;
- case GST_PLAY_SINK_TYPE_VIDEO:
- if (has_video_cap)
- has_correct_type = TRUE;
- break;
- case GST_PLAY_SINK_TYPE_ANY:
- if ((has_video_cap) || (has_audio_cap))
- has_correct_type = TRUE;
- break;
- default:
- has_correct_type = FALSE;
- }
- }
-
- pads = g_list_next (pads);
-
+ /* check for src pad */
+ if (GST_PAD_DIRECTION (GST_PAD (pads->data)) == GST_PAD_SRC) {
+ has_src = TRUE;
+ break;
+ } else {
+ /* If not a src pad checking caps */
+ GstCaps *caps;
+ GstStructure *structure;
+ gboolean has_video_cap = FALSE;
+ gboolean has_audio_cap = FALSE;
+
+ caps = gst_pad_get_caps (GST_PAD (pads->data));
+ structure = gst_caps_get_structure (caps, 0);
+
+ if (strcmp (gst_structure_get_name (structure),
+ "audio/x-raw-int") == 0) {
+ has_audio_cap = TRUE;
+ }
+
+ if (strcmp (gst_structure_get_name (structure),
+ "video/x-raw-yuv") == 0 ||
+ strcmp (gst_structure_get_name (structure),
+ "video/x-raw-rgb") == 0) {
+ has_video_cap = TRUE;
+ }
+
+ gst_caps_free (caps);
+
+ switch (sink_type) {
+ case GST_PLAY_SINK_TYPE_AUDIO:
+ if (has_audio_cap)
+ has_correct_type = TRUE;
+ break;
+ case GST_PLAY_SINK_TYPE_VIDEO:
+ if (has_video_cap)
+ has_correct_type = TRUE;
+ break;
+ case GST_PLAY_SINK_TYPE_ANY:
+ if ((has_video_cap) || (has_audio_cap))
+ has_correct_type = TRUE;
+ break;
+ default:
+ has_correct_type = FALSE;
+ }
+ }
+
+ pads = g_list_next (pads);
+
}
-
+
if ((!has_src) && (has_correct_type))
- return element;
+ return element;
}
-
+
elements = g_list_next (elements);
}
-
+
/* we didn't find a sink element */
-
+
return NULL;
}
GstPlay *
-gst_play_new (GError **error)
+gst_play_new (GError ** error)
{
GstPlay *play = g_object_new (GST_TYPE_PLAY, NULL);
- if (play->priv->error)
- {
- if (error)
- {
+ if (play->priv->error) {
+ if (error) {
*error = play->priv->error;
play->priv->error = NULL;
- }
- else
- {
- g_warning ("Error creating GstPlay object.\n%s", play->priv->error->message);
+ } else {
+ g_warning ("Error creating GstPlay object.\n%s",
+ play->priv->error->message);
g_error_free (play->priv->error);
}
}
(GInstanceInitFunc) gst_play_init,
NULL
};
-
+
play_type = g_type_register_static (GST_TYPE_PIPELINE, "GstPlay",
- &play_info, 0);
+ &play_info, 0);
}
return play_type;
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
-
+
#ifndef __GST_PLAY_H__
#define __GST_PLAY_H__
typedef struct _GstPlay GstPlay;
typedef struct _GstPlayClass GstPlayClass;
typedef struct _GstPlayPrivate GstPlayPrivate;
-
+
struct _GstPlay
{
GstPipeline pipeline;
-
+
GstPlayPrivate *priv;
-
+
gpointer _gst_reserved[GST_PADDING];
};
-
+
struct _GstPlayClass
{
GstPipelineClass parent_class;
-
- void (*time_tick) (GstPlay *play, gint64 time_nanos);
- void (*stream_length) (GstPlay *play, gint64 length_nanos);
- void (*have_video_size) (GstPlay *play, gint width, gint height);
-
+
+ void (*time_tick) (GstPlay * play, gint64 time_nanos);
+ void (*stream_length) (GstPlay * play, gint64 length_nanos);
+ void (*have_video_size) (GstPlay * play, gint width, gint height);
+
gpointer _gst_reserved[GST_PADDING];
};
-GType gst_play_get_type (void);
-GstPlay * gst_play_new (GError **error);
+GType gst_play_get_type (void);
+GstPlay *gst_play_new (GError ** error);
-gboolean gst_play_set_data_src (GstPlay *play,
- GstElement *data_src);
-gboolean gst_play_set_video_sink (GstPlay *play,
- GstElement *video_sink);
-gboolean gst_play_set_audio_sink (GstPlay *play,
- GstElement *audio_sink);
+gboolean gst_play_set_data_src (GstPlay * play, GstElement * data_src);
+gboolean gst_play_set_video_sink (GstPlay * play, GstElement * video_sink);
+gboolean gst_play_set_audio_sink (GstPlay * play, GstElement * audio_sink);
-gboolean gst_play_set_visualization (GstPlay *play,
- GstElement *element);
-gboolean gst_play_connect_visualization (GstPlay *play,
- gboolean connect);
+gboolean gst_play_set_visualization (GstPlay * play, GstElement * element);
+gboolean gst_play_connect_visualization (GstPlay * play, gboolean connect);
-gboolean gst_play_set_location (GstPlay *play,
- const char *location);
-char * gst_play_get_location (GstPlay *play);
+gboolean gst_play_set_location (GstPlay * play, const char *location);
+char *gst_play_get_location (GstPlay * play);
-gboolean gst_play_seek_to_time (GstPlay *play,
- gint64 time_nanos);
+gboolean gst_play_seek_to_time (GstPlay * play, gint64 time_nanos);
-GstElement * gst_play_get_sink_element (GstPlay *play,
- GstElement *element,
- GstPlaySinkType sink_type);
+GstElement *gst_play_get_sink_element (GstPlay * play,
+ GstElement * element, GstPlaySinkType sink_type);
#endif /* __GST_PLAY_H__ */
#include "propertyprobe.h"
-enum {
+enum
+{
SIGNAL_PROBE_NEEDED,
LAST_SIGNAL
};
-static void gst_property_probe_iface_init (GstPropertyProbeInterface *iface);
+static void gst_property_probe_iface_init (GstPropertyProbeInterface * iface);
static guint gst_property_probe_signals[LAST_SIGNAL] = { 0 };
gst_property_probe_type =
g_type_register_static (G_TYPE_INTERFACE,
- "GstPropertyProbe",
- &gst_property_probe_info, 0);
+ "GstPropertyProbe", &gst_property_probe_info, 0);
}
return gst_property_probe_type;
}
static void
-gst_property_probe_iface_init (GstPropertyProbeInterface *iface)
+gst_property_probe_iface_init (GstPropertyProbeInterface * iface)
{
static gboolean initialized = FALSE;
if (!initialized) {
gst_property_probe_signals[SIGNAL_PROBE_NEEDED] =
- g_signal_new ("probe-needed", G_TYPE_FROM_CLASS (iface), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstPropertyProbeInterface, probe_needed),
- NULL, NULL, g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1, G_TYPE_POINTER);
+ g_signal_new ("probe-needed", G_TYPE_FROM_CLASS (iface),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstPropertyProbeInterface,
+ probe_needed), NULL, NULL, g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1, G_TYPE_POINTER);
initialized = TRUE;
}
/* default virtual functions */
iface->get_properties = NULL;
- iface->get_values = NULL;
+ iface->get_values = NULL;
}
/**
*/
const GList *
-gst_property_probe_get_properties (GstPropertyProbe *probe)
+gst_property_probe_get_properties (GstPropertyProbe * probe)
{
GstPropertyProbeInterface *iface;
g_return_val_if_fail (probe != NULL, NULL);
-
+
iface = GST_PROPERTY_PROBE_GET_IFACE (probe);
-
+
if (iface->get_properties)
return iface->get_properties (probe);
-
+
return NULL;
}
const GParamSpec *
-gst_property_probe_get_property (GstPropertyProbe *probe,
- const gchar *name)
+gst_property_probe_get_property (GstPropertyProbe * probe, const gchar * name)
{
const GList *pspecs = gst_property_probe_get_properties (probe);
}
void
-gst_property_probe_probe_property (GstPropertyProbe *probe,
- const GParamSpec *pspec)
+gst_property_probe_probe_property (GstPropertyProbe * probe,
+ const GParamSpec * pspec)
{
GstPropertyProbeInterface *iface;
*/
void
-gst_property_probe_probe_property_name (GstPropertyProbe *probe,
- const gchar *name)
+gst_property_probe_probe_property_name (GstPropertyProbe * probe,
+ const gchar * name)
{
const GParamSpec *pspec;
*/
gboolean
-gst_property_probe_needs_probe (GstPropertyProbe *probe,
- const GParamSpec *pspec)
+gst_property_probe_needs_probe (GstPropertyProbe * probe,
+ const GParamSpec * pspec)
{
GstPropertyProbeInterface *iface;
*/
gboolean
-gst_property_probe_needs_probe_name (GstPropertyProbe *probe,
- const gchar *name)
+gst_property_probe_needs_probe_name (GstPropertyProbe * probe,
+ const gchar * name)
{
const GParamSpec *pspec;
*
* Returns: A list of valid values for the given property.
*/
-
+
GValueArray *
-gst_property_probe_get_values (GstPropertyProbe *probe,
- const GParamSpec *pspec)
+gst_property_probe_get_values (GstPropertyProbe * probe,
+ const GParamSpec * pspec)
{
GstPropertyProbeInterface *iface;
*/
GValueArray *
-gst_property_probe_get_values_name (GstPropertyProbe *probe,
- const gchar *name)
+gst_property_probe_get_values_name (GstPropertyProbe * probe,
+ const gchar * name)
{
const GParamSpec *pspec;
*/
GValueArray *
-gst_property_probe_probe_and_get_values (GstPropertyProbe *probe,
- const GParamSpec *pspec)
+gst_property_probe_probe_and_get_values (GstPropertyProbe * probe,
+ const GParamSpec * pspec)
{
GstPropertyProbeInterface *iface;
*/
GValueArray *
-gst_property_probe_probe_and_get_values_name (GstPropertyProbe *probe,
- const gchar *name)
+gst_property_probe_probe_and_get_values_name (GstPropertyProbe * probe,
+ const gchar * name)
{
const GParamSpec *pspec;
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_TYPE_PROPERTY_PROBE \
(gst_property_probe_get_type ())
#define GST_PROPERTY_PROBE(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PROPERTY_PROBE))
#define GST_PROPERTY_PROBE_GET_IFACE(obj) \
(G_TYPE_INSTANCE_GET_INTERFACE ((obj), GST_TYPE_PROPERTY_PROBE, GstPropertyProbeInterface))
+typedef struct _GstPropertyProbe GstPropertyProbe; /* dummy typedef */
-typedef struct _GstPropertyProbe GstPropertyProbe; /* dummy typedef */
-
-typedef struct _GstPropertyProbeInterface {
+typedef struct _GstPropertyProbeInterface
+{
GTypeInterface klass;
/* signals */
- void (*probe_needed) (GstPropertyProbe *probe,
- const GParamSpec *pspec);
+ void (*probe_needed) (GstPropertyProbe * probe, const GParamSpec * pspec);
/* virtual functions */
- const GList * (*get_properties) (GstPropertyProbe *probe);
- gboolean (*needs_probe) (GstPropertyProbe *probe,
- guint prop_id,
- const GParamSpec *pspec);
- void (*probe_property) (GstPropertyProbe *probe,
- guint prop_id,
- const GParamSpec *pspec);
- GValueArray * (*get_values) (GstPropertyProbe *probe,
- guint prop_id,
- const GParamSpec *pspec);
+ const GList *(*get_properties) (GstPropertyProbe * probe);
+ gboolean (*needs_probe) (GstPropertyProbe * probe,
+ guint prop_id, const GParamSpec * pspec);
+ void (*probe_property) (GstPropertyProbe * probe,
+ guint prop_id, const GParamSpec * pspec);
+ GValueArray *(*get_values) (GstPropertyProbe * probe,
+ guint prop_id, const GParamSpec * pspec);
gpointer _gst_reserved[GST_PADDING];
} GstPropertyProbeInterface;
-GType gst_property_probe_get_type (void);
+GType gst_property_probe_get_type (void);
/* virtual class function wrappers */
/* returns list of GParamSpecs */
-const GList * gst_property_probe_get_properties (GstPropertyProbe *probe);
-const GParamSpec *gst_property_probe_get_property (GstPropertyProbe *probe,
- const gchar *name);
+const GList *gst_property_probe_get_properties (GstPropertyProbe * probe);
+const GParamSpec *gst_property_probe_get_property (GstPropertyProbe * probe,
+ const gchar * name);
/* probe one property */
-void gst_property_probe_probe_property (GstPropertyProbe *probe,
- const GParamSpec *pspec);
-void gst_property_probe_probe_property_name (GstPropertyProbe *probe,
- const gchar *name);
+void gst_property_probe_probe_property (GstPropertyProbe * probe,
+ const GParamSpec * pspec);
+void gst_property_probe_probe_property_name (GstPropertyProbe * probe,
+ const gchar * name);
/* do we need a probe? */
-gboolean gst_property_probe_needs_probe (GstPropertyProbe *probe,
- const GParamSpec *pspec);
-gboolean gst_property_probe_needs_probe_name (GstPropertyProbe *probe,
- const gchar *name);
+gboolean gst_property_probe_needs_probe (GstPropertyProbe * probe,
+ const GParamSpec * pspec);
+gboolean gst_property_probe_needs_probe_name (GstPropertyProbe * probe,
+ const gchar * name);
/* returns list of GValues */
-GValueArray * gst_property_probe_get_values (GstPropertyProbe *probe,
- const GParamSpec *pspec);
-GValueArray * gst_property_probe_get_values_name (GstPropertyProbe *probe,
- const gchar *name);
+GValueArray *gst_property_probe_get_values (GstPropertyProbe * probe,
+ const GParamSpec * pspec);
+GValueArray *gst_property_probe_get_values_name (GstPropertyProbe * probe,
+ const gchar * name);
/* sugar */
-GValueArray * gst_property_probe_probe_and_get_values (GstPropertyProbe *probe,
- const GParamSpec *pspec);
-GValueArray * gst_property_probe_probe_and_get_values_name (GstPropertyProbe *probe,
- const gchar *name);
+GValueArray *gst_property_probe_probe_and_get_values (GstPropertyProbe * probe,
+ const GParamSpec * pspec);
+GValueArray *gst_property_probe_probe_and_get_values_name (GstPropertyProbe *
+ probe, const gchar * name);
G_END_DECLS
-
#endif /* __GST_PROPERTY_PROBE_H__ */
/*#include <ml.h> */
#include "private.h"
-void conv_double_float_ref(double *dest, float *src, int n)
+void
+conv_double_float_ref (double *dest, float *src, int n)
{
- int i;
- for(i=0;i<n;i++){
- dest[i]=src[i];
- }
+ int i;
+
+ for (i = 0; i < n; i++) {
+ dest[i] = src[i];
+ }
}
-void conv_float_double_ref(float *dest, double *src, int n)
+void
+conv_float_double_ref (float *dest, double *src, int n)
{
- int i;
- for(i=0;i<n;i++){
- dest[i]=src[i];
- }
+ int i;
+
+ for (i = 0; i < n; i++) {
+ dest[i] = src[i];
+ }
}
-void conv_double_float_dstr(double *dest, float *src, int n, int dstr)
+void
+conv_double_float_dstr (double *dest, float *src, int n, int dstr)
{
- int i;
- void *d = dest;
- for(i=0;i<n;i++){
- (*(double *)d)=*src++;
- d += dstr;
- }
+ int i;
+ void *d = dest;
+
+ for (i = 0; i < n; i++) {
+ (*(double *) d) = *src++;
+ d += dstr;
+ }
}
-void conv_float_double_sstr(float *dest, double *src, int n, int sstr)
+void
+conv_float_double_sstr (float *dest, double *src, int n, int sstr)
{
- int i;
- void *s = src;
+ int i;
+ void *s = src;
- for(i=0;i<n;i++){
- *dest++ = *(double *)s;
- s += sstr;
- }
+ for (i = 0; i < n; i++) {
+ *dest++ = *(double *) s;
+ s += sstr;
+ }
}
-
static float ints_high[256];
static float ints_low[256];
-void conv_double_short_table(double *dest, short *src, int n)
+void
+conv_double_short_table (double *dest, short *src, int n)
{
- static int init = 0;
- int i;
- unsigned int idx;
- if(!init){
- for(i=0;i<256;i++){
- ints_high[i]=256.0*((i<128)?i:i-256);
- ints_low[i]=i;
- }
- init = 1;
- }
-
- if(n&1){
- idx = (unsigned short)*src++;
- *dest++ = ints_high[(idx>>8)] + ints_low[(idx&0xff)];
- n-=1;
- }
- for(i=0;i<n;i+=2){
- idx = (unsigned short)*src++;
- *dest++ = ints_high[(idx>>8)] + ints_low[(idx&0xff)];
- idx = (unsigned short)*src++;
- *dest++ = ints_high[(idx>>8)] + ints_low[(idx&0xff)];
- }
+ static int init = 0;
+ int i;
+ unsigned int idx;
+
+ if (!init) {
+ for (i = 0; i < 256; i++) {
+ ints_high[i] = 256.0 * ((i < 128) ? i : i - 256);
+ ints_low[i] = i;
+ }
+ init = 1;
+ }
+
+ if (n & 1) {
+ idx = (unsigned short) *src++;
+ *dest++ = ints_high[(idx >> 8)] + ints_low[(idx & 0xff)];
+ n -= 1;
+ }
+ for (i = 0; i < n; i += 2) {
+ idx = (unsigned short) *src++;
+ *dest++ = ints_high[(idx >> 8)] + ints_low[(idx & 0xff)];
+ idx = (unsigned short) *src++;
+ *dest++ = ints_high[(idx >> 8)] + ints_low[(idx & 0xff)];
+ }
}
#endif
#ifdef short_to_double_unroll
-void conv_double_short_unroll(double *dest, short *src, int n)
+void
+conv_double_short_unroll (double *dest, short *src, int n)
{
- if(n&1){
- *dest++ = *src++;
- n--;
- }
- if(n&2){
- *dest++ = *src++;
- *dest++ = *src++;
- n-=2;
- }
- while(n>0){
- *dest++ = *src++;
- *dest++ = *src++;
- *dest++ = *src++;
- *dest++ = *src++;
- n-=4;
- }
+ if (n & 1) {
+ *dest++ = *src++;
+ n--;
+ }
+ if (n & 2) {
+ *dest++ = *src++;
+ *dest++ = *src++;
+ n -= 2;
+ }
+ while (n > 0) {
+ *dest++ = *src++;
+ *dest++ = *src++;
+ *dest++ = *src++;
+ *dest++ = *src++;
+ n -= 4;
+ }
}
#endif
-void conv_double_short_ref(double *dest, short *src, int n)
+void
+conv_double_short_ref (double *dest, short *src, int n)
{
- int i;
- for(i=0;i<n;i++){
- dest[i]=src[i];
- }
+ int i;
+
+ for (i = 0; i < n; i++) {
+ dest[i] = src[i];
+ }
}
#ifdef HAVE_CPU_PPC
#if 0
-static union { int i[4]; float f[4]; } av_tmp __attribute__ ((__aligned__ (16)));
+static union
+{
+ int i[4];
+ float f[4];
+} av_tmp __attribute__ ((__aligned__ (16)));
-void conv_double_short_altivec(double *dest, short *src, int n)
+void
+conv_double_short_altivec (double *dest, short *src, int n)
{
- int i;
-
- for(i=0;i<n;i+=4){
- av_tmp.i[0] = src[0];
- av_tmp.i[1] = src[1];
- av_tmp.i[2] = src[2];
- av_tmp.i[3] = src[3];
-
- asm(
- " lvx 0,0,%0\n"
- " vcfsx 1,0,0\n"
- " stvx 1,0,%0\n"
- : : "r" (&av_tmp)
- );
-
- dest[0]=av_tmp.f[0];
- dest[1]=av_tmp.f[1];
- dest[2]=av_tmp.f[2];
- dest[3]=av_tmp.f[3];
- src += 4;
- dest += 4;
- }
+ int i;
+
+ for (i = 0; i < n; i += 4) {
+ av_tmp.i[0] = src[0];
+ av_tmp.i[1] = src[1];
+ av_tmp.i[2] = src[2];
+ av_tmp.i[3] = src[3];
+
+ asm (" lvx 0,0,%0\n" " vcfsx 1,0,0\n" " stvx 1,0,%0\n": :"r" (&av_tmp)
+ );
+
+ dest[0] = av_tmp.f[0];
+ dest[1] = av_tmp.f[1];
+ dest[2] = av_tmp.f[2];
+ dest[3] = av_tmp.f[3];
+ src += 4;
+ dest += 4;
+ }
}
#endif
#endif
/* double to short */
-void conv_short_double_ref(short *dest, double *src, int n)
+void
+conv_short_double_ref (short *dest, double *src, int n)
{
- int i;
- double x;
-
- for(i=0;i<n;i++){
- x = *src++;
- if(x<-32768.0)x=-32768.0;
- if(x>32767.0)x=32767.0;
- *dest++ = rint(x);
- }
+ int i;
+ double x;
+
+ for (i = 0; i < n; i++) {
+ x = *src++;
+ if (x < -32768.0)
+ x = -32768.0;
+ if (x > 32767.0)
+ x = 32767.0;
+ *dest++ = rint (x);
+ }
}
/* #ifdef HAVE_CPU_PPC */
#if 0
-void conv_short_double_ppcasm(short *dest, double *src, int n)
+void
+conv_short_double_ppcasm (short *dest, double *src, int n)
{
- int tmp[2];
- double min = -32768.0;
- double max = 32767.0;
- double ftmp0, ftmp1;
-
- asm __volatile__(
- "\taddic. %3,%3,-8\n"
- "\taddic. %6,%6,-2\n"
- "loop:\n"
- "\tlfdu %0,8(%3)\n"
- "\tfsub %1,%0,%4\n"
- "\tfsel %0,%1,%0,%4\n"
- "\tfsub %1,%0,%5\n"
- "\tfsel %0,%1,%5,%0\n"
- "\tfctiw %1,%0\n"
- "\taddic. 5,5,-1\n"
- "\tstfd %1,0(%2)\n"
- "\tlhz 9,6(%2)\n"
- "\tsthu 9,2(%6)\n"
- "\tbne loop\n"
- : "=&f" (ftmp0), "=&f" (ftmp1)
- : "b" (tmp), "r" (src), "f" (min), "f" (max), "r" (dest)
- : "r9", "r5" );
+ int tmp[2];
+ double min = -32768.0;
+ double max = 32767.0;
+ double ftmp0, ftmp1;
+
+ asm __volatile__ ("\taddic. %3,%3,-8\n"
+ "\taddic. %6,%6,-2\n"
+ "loop:\n"
+ "\tlfdu %0,8(%3)\n"
+ "\tfsub %1,%0,%4\n"
+ "\tfsel %0,%1,%0,%4\n"
+ "\tfsub %1,%0,%5\n"
+ "\tfsel %0,%1,%5,%0\n"
+ "\tfctiw %1,%0\n"
+ "\taddic. 5,5,-1\n"
+ "\tstfd %1,0(%2)\n"
+ "\tlhz 9,6(%2)\n"
+ "\tsthu 9,2(%6)\n" "\tbne loop\n":"=&f" (ftmp0), "=&f" (ftmp1)
+ :"b" (tmp), "r" (src), "f" (min), "f" (max), "r" (dest)
+ :"r9", "r5");
}
#endif
-void conv_double_short_dstr(double *dest, short *src, int n, int dstr)
+void
+conv_double_short_dstr (double *dest, short *src, int n, int dstr)
{
- int i;
- void *d = dest;
- for(i=0;i<n;i++){
- (*(double *)d)=*src++;
- d += dstr;
- }
+ int i;
+ void *d = dest;
+
+ for (i = 0; i < n; i++) {
+ (*(double *) d) = *src++;
+ d += dstr;
+ }
}
-void conv_short_double_sstr(short *dest, double *src, int n, int sstr)
+void
+conv_short_double_sstr (short *dest, double *src, int n, int sstr)
{
- int i;
- double x;
- void *s = src;
-
- for(i=0;i<n;i++){
- x = *(double *)s;
- if(x<-32768.0)x=-32768.0;
- if(x>32767.0)x=32767.0;
- *dest++ = rint(x);
- s += sstr;
- }
+ int i;
+ double x;
+ void *s = src;
+
+ for (i = 0; i < n; i++) {
+ x = *(double *) s;
+ if (x < -32768.0)
+ x = -32768.0;
+ if (x > 32767.0)
+ x = 32767.0;
+ *dest++ = rint (x);
+ s += sstr;
+ }
}
-
-double functable_sinc(void *p,double x)
+double
+functable_sinc (void *p, double x)
{
- if(x==0)return 1;
- return sin(x)/x;
+ if (x == 0)
+ return 1;
+ return sin (x) / x;
}
-double functable_dsinc(void *p,double x)
+double
+functable_dsinc (void *p, double x)
{
- if(x==0)return 0;
- return cos(x)/x - sin(x)/(x*x);
+ if (x == 0)
+ return 0;
+ return cos (x) / x - sin (x) / (x * x);
}
-double functable_window_boxcar(void *p,double x)
+double
+functable_window_boxcar (void *p, double x)
{
- if(x<-1 || x>1)return 0;
- return 1;
+ if (x < -1 || x > 1)
+ return 0;
+ return 1;
}
-double functable_window_dboxcar(void *p,double x)
+double
+functable_window_dboxcar (void *p, double x)
{
- return 0;
+ return 0;
}
-double functable_window_std(void *p,double x)
+double
+functable_window_std (void *p, double x)
{
- if(x<-1 || x>1)return 0;
- return (1-x*x)*(1-x*x);
+ if (x < -1 || x > 1)
+ return 0;
+ return (1 - x * x) * (1 - x * x);
}
-double functable_window_dstd(void *p,double x)
+double
+functable_window_dstd (void *p, double x)
{
- if(x<-1 || x>1)return 0;
- return -4*x*(1-x*x);
+ if (x < -1 || x > 1)
+ return 0;
+ return -4 * x * (1 - x * x);
}
-void functable_init(functable_t *t)
+void
+functable_init (functable_t * t)
{
- int i;
- double x;
+ int i;
+ double x;
- t->fx = malloc(sizeof(double)*(t->len+1));
- t->fdx = malloc(sizeof(double)*(t->len+1));
+ t->fx = malloc (sizeof (double) * (t->len + 1));
+ t->fdx = malloc (sizeof (double) * (t->len + 1));
- t->invoffset = 1.0 / t->offset;
+ t->invoffset = 1.0 / t->offset;
- for(i=0;i<t->len+1;i++){
- x = t->start + t->offset * i;
- x *= t->scale;
+ for (i = 0; i < t->len + 1; i++) {
+ x = t->start + t->offset * i;
+ x *= t->scale;
- t->fx[i] = t->func_x(t->priv,x);
- t->fdx[i] = t->scale * t->func_dx(t->priv,x);
- }
- if(t->func2_x){
- double f1x,f1dx;
- double f2x,f2dx;
+ t->fx[i] = t->func_x (t->priv, x);
+ t->fdx[i] = t->scale * t->func_dx (t->priv, x);
+ }
+ if (t->func2_x) {
+ double f1x, f1dx;
+ double f2x, f2dx;
- for(i=0;i<t->len+1;i++){
- x = t->start + t->offset * i;
- x *= t->scale2;
+ for (i = 0; i < t->len + 1; i++) {
+ x = t->start + t->offset * i;
+ x *= t->scale2;
- f2x = t->func2_x(t->priv,x);
- f2dx = t->scale2 * t->func2_dx(t->priv,x);
+ f2x = t->func2_x (t->priv, x);
+ f2dx = t->scale2 * t->func2_dx (t->priv, x);
- f1x = t->fx[i];
- f1dx = t->fdx[i];
+ f1x = t->fx[i];
+ f1dx = t->fdx[i];
- t->fx[i] = f1x * f2x;
- t->fdx[i] = f1x * f2dx + f1dx * f2x;
- }
- }
+ t->fx[i] = f1x * f2x;
+ t->fdx[i] = f1x * f2dx + f1dx * f2x;
+ }
+ }
}
-double functable_eval(functable_t *t,double x)
+double
+functable_eval (functable_t * t, double x)
{
- int i;
- double f0, f1, w0, w1;
- double x2, x3;
- double w;
+ int i;
+ double f0, f1, w0, w1;
+ double x2, x3;
+ double w;
- if(x<t->start || x>(t->start+(t->len+1)*t->offset)){
- printf("x out of range %g\n",x);
- }
- x -= t->start;
- x /= t->offset;
- i = floor(x);
- x -= i;
+ if (x < t->start || x > (t->start + (t->len + 1) * t->offset)) {
+ printf ("x out of range %g\n", x);
+ }
+ x -= t->start;
+ x /= t->offset;
+ i = floor (x);
+ x -= i;
- x2 = x * x;
- x3 = x2 * x;
+ x2 = x * x;
+ x3 = x2 * x;
- f1 = 3 * x2 - 2 * x3;
- f0 = 1 - f1;
- w0 = (x - 2 * x2 + x3) * t->offset;
- w1 = (-x2 + x3) * t->offset;
+ f1 = 3 * x2 - 2 * x3;
+ f0 = 1 - f1;
+ w0 = (x - 2 * x2 + x3) * t->offset;
+ w1 = (-x2 + x3) * t->offset;
- /*printf("i=%d x=%g f0=%g f1=%g w0=%g w1=%g\n",i,x,f0,f1,w0,w1); */
+ /*printf("i=%d x=%g f0=%g f1=%g w0=%g w1=%g\n",i,x,f0,f1,w0,w1); */
- w = t->fx[i] * f0 + t->fx[i + 1] * f1 +
- t->fdx[i] * w0 + t->fdx[i + 1] * w1;
+ w = t->fx[i] * f0 + t->fx[i + 1] * f1 + t->fdx[i] * w0 + t->fdx[i + 1] * w1;
- /*w = t->fx[i] * (1-x) + t->fx[i+1] * x; */
+ /*w = t->fx[i] * (1-x) + t->fx[i+1] * x; */
- return w;
+ return w;
}
-double functable_fir(functable_t *t, double x, int n, double *data, int len)
+double
+functable_fir (functable_t * t, double x, int n, double *data, int len)
{
- int i,j;
- double f0, f1, w0, w1;
- double x2, x3;
- double w;
- double sum;
-
- x -= t->start;
- x /= t->offset;
- i = floor(x);
- x -= i;
-
- x2 = x * x;
- x3 = x2 * x;
-
- f1 = 3 * x2 - 2 * x3;
- f0 = 1 - f1;
- w0 = (x - 2 * x2 + x3) * t->offset;
- w1 = (-x2 + x3) * t->offset;
-
- sum = 0;
- for(j=0;j<len;j++){
- w = t->fx[i] * f0 + t->fx[i + 1] * f1 +
- t->fdx[i] * w0 + t->fdx[i + 1] * w1;
- sum += data[j*2] * w;
- i += n;
- }
-
- return sum;
+ int i, j;
+ double f0, f1, w0, w1;
+ double x2, x3;
+ double w;
+ double sum;
+
+ x -= t->start;
+ x /= t->offset;
+ i = floor (x);
+ x -= i;
+
+ x2 = x * x;
+ x3 = x2 * x;
+
+ f1 = 3 * x2 - 2 * x3;
+ f0 = 1 - f1;
+ w0 = (x - 2 * x2 + x3) * t->offset;
+ w1 = (-x2 + x3) * t->offset;
+
+ sum = 0;
+ for (j = 0; j < len; j++) {
+ w = t->fx[i] * f0 + t->fx[i + 1] * f1 + t->fdx[i] * w0 + t->fdx[i + 1] * w1;
+ sum += data[j * 2] * w;
+ i += n;
+ }
+
+ return sum;
}
-void functable_fir2(functable_t *t, double *r0, double *r1, double x,
- int n, double *data, int len)
+void
+functable_fir2 (functable_t * t, double *r0, double *r1, double x,
+ int n, double *data, int len)
{
- int i,j;
- double f0, f1, w0, w1;
- double x2, x3;
- double w;
- double sum0, sum1;
- double floor_x;
-
- x -= t->start;
- x *= t->invoffset;
- floor_x = floor(x);
- i = floor_x;
- x -= floor_x;
-
- x2 = x * x;
- x3 = x2 * x;
-
- f1 = 3 * x2 - 2 * x3;
- f0 = 1 - f1;
- w0 = (x - 2 * x2 + x3) * t->offset;
- w1 = (-x2 + x3) * t->offset;
-
- sum0 = 0;
- sum1 = 0;
- for(j=0;j<len;j++){
- w = t->fx[i] * f0 + t->fx[i + 1] * f1 +
- t->fdx[i] * w0 + t->fdx[i + 1] * w1;
- sum0 += data[j*2] * w;
- sum1 += data[j*2+1] * w;
- i += n;
+ int i, j;
+ double f0, f1, w0, w1;
+ double x2, x3;
+ double w;
+ double sum0, sum1;
+ double floor_x;
+
+ x -= t->start;
+ x *= t->invoffset;
+ floor_x = floor (x);
+ i = floor_x;
+ x -= floor_x;
+
+ x2 = x * x;
+ x3 = x2 * x;
+
+ f1 = 3 * x2 - 2 * x3;
+ f0 = 1 - f1;
+ w0 = (x - 2 * x2 + x3) * t->offset;
+ w1 = (-x2 + x3) * t->offset;
+
+ sum0 = 0;
+ sum1 = 0;
+ for (j = 0; j < len; j++) {
+ w = t->fx[i] * f0 + t->fx[i + 1] * f1 + t->fdx[i] * w0 + t->fdx[i + 1] * w1;
+ sum0 += data[j * 2] * w;
+ sum1 += data[j * 2 + 1] * w;
+ i += n;
#define unroll2
#define unroll3
#define unroll4
#ifdef unroll2
- j++;
+ j++;
- w = t->fx[i] * f0 + t->fx[i + 1] * f1 +
- t->fdx[i] * w0 + t->fdx[i + 1] * w1;
- sum0 += data[j*2] * w;
- sum1 += data[j*2+1] * w;
- i += n;
+ w = t->fx[i] * f0 + t->fx[i + 1] * f1 + t->fdx[i] * w0 + t->fdx[i + 1] * w1;
+ sum0 += data[j * 2] * w;
+ sum1 += data[j * 2 + 1] * w;
+ i += n;
#endif
#ifdef unroll3
- j++;
+ j++;
- w = t->fx[i] * f0 + t->fx[i + 1] * f1 +
- t->fdx[i] * w0 + t->fdx[i + 1] * w1;
- sum0 += data[j*2] * w;
- sum1 += data[j*2+1] * w;
- i += n;
+ w = t->fx[i] * f0 + t->fx[i + 1] * f1 + t->fdx[i] * w0 + t->fdx[i + 1] * w1;
+ sum0 += data[j * 2] * w;
+ sum1 += data[j * 2 + 1] * w;
+ i += n;
#endif
#ifdef unroll4
- j++;
+ j++;
- w = t->fx[i] * f0 + t->fx[i + 1] * f1 +
- t->fdx[i] * w0 + t->fdx[i + 1] * w1;
- sum0 += data[j*2] * w;
- sum1 += data[j*2+1] * w;
- i += n;
+ w = t->fx[i] * f0 + t->fx[i + 1] * f1 + t->fdx[i] * w0 + t->fdx[i + 1] * w1;
+ sum0 += data[j * 2] * w;
+ sum1 += data[j * 2 + 1] * w;
+ i += n;
#endif
- }
+ }
- *r0 = sum0;
- *r1 = sum1;
+ *r0 = sum0;
+ *r1 = sum1;
}
#ifdef unused
-void functable_fir2_altivec(functable_t *t, float *r0, float *r1,
- double x, int n, float *data, int len)
+void
+functable_fir2_altivec (functable_t * t, float *r0, float *r1,
+ double x, int n, float *data, int len)
{
- int i,j;
- double f0, f1, w0, w1;
- double x2, x3;
- double w;
- double sum0, sum1;
- double floor_x;
-
- x -= t->start;
- x *= t->invoffset;
- floor_x = floor(x);
- i = floor_x;
- x -= floor_x;
-
- x2 = x * x;
- x3 = x2 * x;
-
- f1 = 3 * x2 - 2 * x3;
- f0 = 1 - f1;
- w0 = (x - 2 * x2 + x3) * t->offset;
- w1 = (-x2 + x3) * t->offset;
-
- sum0 = 0;
- sum1 = 0;
- for(j=0;j<len;j++){
- /* t->fx, t->fdx needs to be multiplexed by n */
- /* we need 5 consecutive floats, which fit into 2 vecs */
- /* load v0, t->fx[i] */
- /* load v1, t->fx[i+n] */
- /* v2 = v0 (not correct) */
- /* v3 = (v0>>32) || (v1<<3*32) (not correct) */
- /* */
- /* load v4, t->dfx[i] */
- /* load v5, t->dfx[i+n] */
- /* v6 = v4 (not correct) */
- /* v7 = (v4>>32) || (v5<<3*32) (not correct) */
- /* */
- /* v8 = splat(f0) */
- /* v9 = splat(f1) */
- /* v10 = splat(w0) */
- /* v11 = splat(w1) */
- /* */
- /* v12 = v2 * v8 */
- /* v12 += v3 * v9 */
- /* v12 += v6 * v10 */
- /* v12 += v7 * v11 */
-
- w = t->fx[i] * f0 + t->fx[i + 1] * f1 +
- t->fdx[i] * w0 + t->fdx[i + 1] * w1;
-
- /* v13 = data[j*2] */
- /* v14 = data[j*2+4] */
- /* v15 = deinterlace_high(v13,v14) */
- /* v16 = deinterlace_low(v13,v14) */
- /* (sum0) v17 += multsum(v13,v15) */
- /* (sum1) v18 += multsum(v14,v16) */
-
- sum0 += data[j*2] * w;
- sum1 += data[j*2+1] * w;
- i += n;
-
- }
-
- *r0 = sum0;
- *r1 = sum1;
+ int i, j;
+ double f0, f1, w0, w1;
+ double x2, x3;
+ double w;
+ double sum0, sum1;
+ double floor_x;
+
+ x -= t->start;
+ x *= t->invoffset;
+ floor_x = floor (x);
+ i = floor_x;
+ x -= floor_x;
+
+ x2 = x * x;
+ x3 = x2 * x;
+
+ f1 = 3 * x2 - 2 * x3;
+ f0 = 1 - f1;
+ w0 = (x - 2 * x2 + x3) * t->offset;
+ w1 = (-x2 + x3) * t->offset;
+
+ sum0 = 0;
+ sum1 = 0;
+ for (j = 0; j < len; j++) {
+ /* t->fx, t->fdx needs to be multiplexed by n */
+ /* we need 5 consecutive floats, which fit into 2 vecs */
+ /* load v0, t->fx[i] */
+ /* load v1, t->fx[i+n] */
+ /* v2 = v0 (not correct) */
+ /* v3 = (v0>>32) || (v1<<3*32) (not correct) */
+ /* */
+ /* load v4, t->dfx[i] */
+ /* load v5, t->dfx[i+n] */
+ /* v6 = v4 (not correct) */
+ /* v7 = (v4>>32) || (v5<<3*32) (not correct) */
+ /* */
+ /* v8 = splat(f0) */
+ /* v9 = splat(f1) */
+ /* v10 = splat(w0) */
+ /* v11 = splat(w1) */
+ /* */
+ /* v12 = v2 * v8 */
+ /* v12 += v3 * v9 */
+ /* v12 += v6 * v10 */
+ /* v12 += v7 * v11 */
+
+ w = t->fx[i] * f0 + t->fx[i + 1] * f1 + t->fdx[i] * w0 + t->fdx[i + 1] * w1;
+
+ /* v13 = data[j*2] */
+ /* v14 = data[j*2+4] */
+ /* v15 = deinterlace_high(v13,v14) */
+ /* v16 = deinterlace_low(v13,v14) */
+ /* (sum0) v17 += multsum(v13,v15) */
+ /* (sum1) v18 += multsum(v14,v16) */
+
+ sum0 += data[j * 2] * w;
+ sum1 += data[j * 2 + 1] * w;
+ i += n;
+
+ }
+
+ *r0 = sum0;
+ *r1 = sum1;
}
#endif
-
#include "resample.h"
-void gst_resample_nearest_s16(gst_resample_t *r);
-void gst_resample_bilinear_s16(gst_resample_t *r);
-void gst_resample_sinc_s16(gst_resample_t *r);
-void gst_resample_sinc_slow_s16(gst_resample_t *r);
-void gst_resample_sinc_ft_s16(gst_resample_t * r);
+void gst_resample_nearest_s16 (gst_resample_t * r);
+void gst_resample_bilinear_s16 (gst_resample_t * r);
+void gst_resample_sinc_s16 (gst_resample_t * r);
+void gst_resample_sinc_slow_s16 (gst_resample_t * r);
+void gst_resample_sinc_ft_s16 (gst_resample_t * r);
-void gst_resample_nearest_float(gst_resample_t *r);
-void gst_resample_bilinear_float(gst_resample_t *r);
-void gst_resample_sinc_float(gst_resample_t *r);
-void gst_resample_sinc_slow_float(gst_resample_t *r);
-void gst_resample_sinc_ft_float(gst_resample_t * r);
+void gst_resample_nearest_float (gst_resample_t * r);
+void gst_resample_bilinear_float (gst_resample_t * r);
+void gst_resample_sinc_float (gst_resample_t * r);
+void gst_resample_sinc_slow_float (gst_resample_t * r);
+void gst_resample_sinc_ft_float (gst_resample_t * r);
typedef struct functable_s functable_t;
-struct functable_s {
- double start;
- double offset;
- int len;
+struct functable_s
+{
+ double start;
+ double offset;
+ int len;
- double invoffset;
+ double invoffset;
- double scale;
- double scale2;
+ double scale;
+ double scale2;
- double (*func_x)(void *,double x);
- double (*func_dx)(void *,double x);
+ double (*func_x) (void *, double x);
+ double (*func_dx) (void *, double x);
- double (*func2_x)(void *,double x);
- double (*func2_dx)(void *,double x);
+ double (*func2_x) (void *, double x);
+ double (*func2_dx) (void *, double x);
- double *fx;
- double *fdx;
+ double *fx;
+ double *fdx;
- void *priv;
+ void *priv;
};
-void functable_init(functable_t *t);
-double functable_eval(functable_t *t,double x);
+void functable_init (functable_t * t);
+double functable_eval (functable_t * t, double x);
-double functable_fir(functable_t *t,double x0,int n,double *data,int len);
-void functable_fir2(functable_t *t,double *r0, double *r1, double x0,
- int n,double *data,int len);
+double functable_fir (functable_t * t, double x0, int n, double *data, int len);
+void functable_fir2 (functable_t * t, double *r0, double *r1, double x0,
+ int n, double *data, int len);
-double functable_sinc(void *p, double x);
-double functable_dsinc(void *p, double x);
-double functable_window_std(void *p, double x);
-double functable_window_dstd(void *p, double x);
-double functable_window_boxcar(void *p, double x);
-double functable_window_dboxcar(void *p, double x);
+double functable_sinc (void *p, double x);
+double functable_dsinc (void *p, double x);
+double functable_window_std (void *p, double x);
+double functable_window_dstd (void *p, double x);
+double functable_window_boxcar (void *p, double x);
+double functable_window_dboxcar (void *p, double x);
/* math lib stuff */
-void conv_double_short_table(double *dest, short *src, int n);
-void conv_double_short_unroll(double *dest, short *src, int n);
-void conv_double_short_ref(double *dest, short *src, int n);
+void conv_double_short_table (double *dest, short *src, int n);
+void conv_double_short_unroll (double *dest, short *src, int n);
+void conv_double_short_ref (double *dest, short *src, int n);
+
#ifdef HAVE_CPU_PPC
-void conv_double_short_altivec(double *dest, short *src, int n);
+void conv_double_short_altivec (double *dest, short *src, int n);
#endif
-void conv_short_double_ref(short *dest, double *src, int n);
+void conv_short_double_ref (short *dest, double *src, int n);
+
#ifdef HAVE_CPU_PPC
-void conv_short_double_ppcasm(short *dest, double *src, int n);
+void conv_short_double_ppcasm (short *dest, double *src, int n);
#endif
#ifdef HAVE_CPU_PPC
#define conv_double_float conv_double_float_ref
#define conv_float_double conv_float_double_ref
-void conv_double_short_dstr(double *dest, short *src, int n, int dstr);
-void conv_short_double_sstr(short *dest, double *src, int n, int dstr);
+void conv_double_short_dstr (double *dest, short *src, int n, int dstr);
+void conv_short_double_sstr (short *dest, double *src, int n, int dstr);
-void conv_double_float_ref(double *dest, float *src, int n);
-void conv_float_double_ref(float *dest, double *src, int n);
-void conv_double_float_dstr(double *dest, float *src, int n, int dstr);
-void conv_float_double_sstr(float *dest, double *src, int n, int sstr);
+void conv_double_float_ref (double *dest, float *src, int n);
+void conv_float_double_ref (float *dest, double *src, int n);
+void conv_double_float_dstr (double *dest, float *src, int n, int dstr);
+void conv_float_double_sstr (float *dest, double *src, int n, int sstr);
#endif /* __PRIVATE_H__ */
#include <gst/gstplugin.h>
#include <gst/gstversion.h>
-inline double sinc(double x)
+inline double
+sinc (double x)
{
- if(x==0)return 1;
- return sin(x) / x;
+ if (x == 0)
+ return 1;
+ return sin (x) / x;
}
-inline double window_func(double x)
+inline double
+window_func (double x)
{
- x = 1 - x*x;
- return x*x;
+ x = 1 - x * x;
+ return x * x;
}
-signed short double_to_s16(double x)
+signed short
+double_to_s16 (double x)
{
- if(x<-32768){
- printf("clipped\n");
- return -32768;
- }
- if(x>32767){
- printf("clipped\n");
- return -32767;
- }
- return rint(x);
+ if (x < -32768) {
+ printf ("clipped\n");
+ return -32768;
+ }
+ if (x > 32767) {
+ printf ("clipped\n");
+ return -32767;
+ }
+ return rint (x);
}
-signed short double_to_s16_ppcasm(double x)
+signed short
+double_to_s16_ppcasm (double x)
{
- if(x<-32768){
- return -32768;
- }
- if(x>32767){
- return -32767;
- }
- return rint(x);
+ if (x < -32768) {
+ return -32768;
+ }
+ if (x > 32767) {
+ return -32767;
+ }
+ return rint (x);
}
-void gst_resample_init(gst_resample_t * r)
+void
+gst_resample_init (gst_resample_t * r)
{
- r->i_start = 0;
- if(r->filter_length&1){
- r->o_start = 0;
- }else{
- r->o_start = r->o_inc * 0.5;
- }
+ r->i_start = 0;
+ if (r->filter_length & 1) {
+ r->o_start = 0;
+ } else {
+ r->o_start = r->o_inc * 0.5;
+ }
- memset(r->acc, 0, sizeof(r->acc));
+ memset (r->acc, 0, sizeof (r->acc));
- gst_resample_reinit(r);
+ gst_resample_reinit (r);
}
-void gst_resample_reinit(gst_resample_t * r)
+void
+gst_resample_reinit (gst_resample_t * r)
{
- /* i_inc is the number of samples that the output increments for
- * each input sample. o_inc is the opposite. */
- r->i_inc = (double) r->o_rate / r->i_rate;
- r->o_inc = (double) r->i_rate / r->o_rate;
-
- r->halftaps = (r->filter_length - 1.0) * 0.5;
-
- if (r->format == GST_RESAMPLE_S16) {
- switch (r->method) {
- default:
- case GST_RESAMPLE_NEAREST:
- r->scale = gst_resample_nearest_s16;
- break;
- case GST_RESAMPLE_BILINEAR:
- r->scale = gst_resample_bilinear_s16;
- break;
- case GST_RESAMPLE_SINC_SLOW:
- r->scale = gst_resample_sinc_s16;
- break;
- case GST_RESAMPLE_SINC:
- r->scale = gst_resample_sinc_ft_s16;
- break;
- }
- } else if (r->format == GST_RESAMPLE_FLOAT) {
- switch (r->method) {
- default:
- case GST_RESAMPLE_NEAREST:
- r->scale = gst_resample_nearest_float;
- break;
- case GST_RESAMPLE_BILINEAR:
- r->scale = gst_resample_bilinear_float;
- break;
- case GST_RESAMPLE_SINC_SLOW:
- r->scale = gst_resample_sinc_float;
- break;
- case GST_RESAMPLE_SINC:
- r->scale = gst_resample_sinc_ft_float;
- break;
- }
- } else {
- fprintf (stderr, "gst_resample: Unexpected format \"%d\"\n", r->format);
- }
+ /* i_inc is the number of samples that the output increments for
+ * each input sample. o_inc is the opposite. */
+ r->i_inc = (double) r->o_rate / r->i_rate;
+ r->o_inc = (double) r->i_rate / r->o_rate;
+
+ r->halftaps = (r->filter_length - 1.0) * 0.5;
+
+ if (r->format == GST_RESAMPLE_S16) {
+ switch (r->method) {
+ default:
+ case GST_RESAMPLE_NEAREST:
+ r->scale = gst_resample_nearest_s16;
+ break;
+ case GST_RESAMPLE_BILINEAR:
+ r->scale = gst_resample_bilinear_s16;
+ break;
+ case GST_RESAMPLE_SINC_SLOW:
+ r->scale = gst_resample_sinc_s16;
+ break;
+ case GST_RESAMPLE_SINC:
+ r->scale = gst_resample_sinc_ft_s16;
+ break;
+ }
+ } else if (r->format == GST_RESAMPLE_FLOAT) {
+ switch (r->method) {
+ default:
+ case GST_RESAMPLE_NEAREST:
+ r->scale = gst_resample_nearest_float;
+ break;
+ case GST_RESAMPLE_BILINEAR:
+ r->scale = gst_resample_bilinear_float;
+ break;
+ case GST_RESAMPLE_SINC_SLOW:
+ r->scale = gst_resample_sinc_float;
+ break;
+ case GST_RESAMPLE_SINC:
+ r->scale = gst_resample_sinc_ft_float;
+ break;
+ }
+ } else {
+ fprintf (stderr, "gst_resample: Unexpected format \"%d\"\n", r->format);
+ }
}
/*
* i_start_buf is the time of the first sample in the temporary
* buffer.
*/
-void gst_resample_scale(gst_resample_t * r, void *i_buf, unsigned int i_size)
+void
+gst_resample_scale (gst_resample_t * r, void *i_buf, unsigned int i_size)
{
- int o_size;
-
- r->i_buf = i_buf;
-
- r->i_samples = i_size / 2 / r->channels;
-
- r->i_start_buf = r->i_start - r->filter_length * r->i_inc;
-
- /* i_start is the offset (in a given output sample) that is the
- * beginning of the current input buffer */
- r->i_end = r->i_start + r->i_inc * r->i_samples;
-
- r->o_samples = floor(r->i_end - r->halftaps * r->i_inc);
-
- o_size = r->o_samples * r->channels * 2;
- r->o_buf = r->get_buffer(r->priv, o_size);
-
- if(r->verbose){
- printf("gst_resample_scale: i_buf=%p i_size=%d\n",
- i_buf,i_size);
- printf("gst_resample_scale: i_samples=%d o_samples=%d i_inc=%g o_buf=%p\n",
- r->i_samples, r->o_samples, r->i_inc, r->o_buf);
- printf("gst_resample_scale: i_start=%g i_end=%g o_start=%g\n",
- r->i_start, r->i_end, r->o_start);
- }
-
- if ((r->filter_length + r->i_samples)*sizeof(double)*2 > r->buffer_len) {
- int size = (r->filter_length + r->i_samples) * sizeof(double) * 2;
-
- if(r->verbose){
- printf("gst_resample temp buffer size=%d\n",size);
- }
- if(r->buffer)free(r->buffer);
- r->buffer_len = size;
- r->buffer = malloc(size);
- memset(r->buffer, 0, size);
- }
-
- if (r->format==GST_RESAMPLE_S16) {
- if(r->channels==2){
- conv_double_short(
- r->buffer + r->filter_length * sizeof(double) * 2,
- r->i_buf, r->i_samples * 2);
- } else {
- conv_double_short_dstr(
- r->buffer + r->filter_length * sizeof(double) * 2,
- r->i_buf, r->i_samples, sizeof(double) * 2);
- }
- } else if (r->format==GST_RESAMPLE_FLOAT) {
- if(r->channels==2){
- conv_double_float(
- r->buffer + r->filter_length * sizeof(double) * 2,
- r->i_buf, r->i_samples * 2);
- } else {
- conv_double_float_dstr(
- r->buffer + r->filter_length * sizeof(double) * 2,
- r->i_buf, r->i_samples, sizeof(double) * 2);
- }
- }
-
- r->scale(r);
-
- memcpy(r->buffer,
- r->buffer + r->i_samples * sizeof(double) * 2,
- r->filter_length * sizeof(double) * 2);
-
- /* updating times */
- r->i_start += r->i_samples * r->i_inc;
- r->o_start += r->o_samples * r->o_inc - r->i_samples;
-
- /* adjusting timebase zero */
- r->i_start -= r->o_samples;
+ int o_size;
+
+ r->i_buf = i_buf;
+
+ r->i_samples = i_size / 2 / r->channels;
+
+ r->i_start_buf = r->i_start - r->filter_length * r->i_inc;
+
+ /* i_start is the offset (in a given output sample) that is the
+ * beginning of the current input buffer */
+ r->i_end = r->i_start + r->i_inc * r->i_samples;
+
+ r->o_samples = floor (r->i_end - r->halftaps * r->i_inc);
+
+ o_size = r->o_samples * r->channels * 2;
+ r->o_buf = r->get_buffer (r->priv, o_size);
+
+ if (r->verbose) {
+ printf ("gst_resample_scale: i_buf=%p i_size=%d\n", i_buf, i_size);
+ printf ("gst_resample_scale: i_samples=%d o_samples=%d i_inc=%g o_buf=%p\n",
+ r->i_samples, r->o_samples, r->i_inc, r->o_buf);
+ printf ("gst_resample_scale: i_start=%g i_end=%g o_start=%g\n",
+ r->i_start, r->i_end, r->o_start);
+ }
+
+ if ((r->filter_length + r->i_samples) * sizeof (double) * 2 > r->buffer_len) {
+ int size = (r->filter_length + r->i_samples) * sizeof (double) * 2;
+
+ if (r->verbose) {
+ printf ("gst_resample temp buffer size=%d\n", size);
+ }
+ if (r->buffer)
+ free (r->buffer);
+ r->buffer_len = size;
+ r->buffer = malloc (size);
+ memset (r->buffer, 0, size);
+ }
+
+ if (r->format == GST_RESAMPLE_S16) {
+ if (r->channels == 2) {
+ conv_double_short (r->buffer + r->filter_length * sizeof (double) * 2,
+ r->i_buf, r->i_samples * 2);
+ } else {
+ conv_double_short_dstr (r->buffer +
+ r->filter_length * sizeof (double) * 2, r->i_buf, r->i_samples,
+ sizeof (double) * 2);
+ }
+ } else if (r->format == GST_RESAMPLE_FLOAT) {
+ if (r->channels == 2) {
+ conv_double_float (r->buffer + r->filter_length * sizeof (double) * 2,
+ r->i_buf, r->i_samples * 2);
+ } else {
+ conv_double_float_dstr (r->buffer +
+ r->filter_length * sizeof (double) * 2, r->i_buf, r->i_samples,
+ sizeof (double) * 2);
+ }
+ }
+
+ r->scale (r);
+
+ memcpy (r->buffer,
+ r->buffer + r->i_samples * sizeof (double) * 2,
+ r->filter_length * sizeof (double) * 2);
+
+ /* updating times */
+ r->i_start += r->i_samples * r->i_inc;
+ r->o_start += r->o_samples * r->o_inc - r->i_samples;
+
+ /* adjusting timebase zero */
+ r->i_start -= r->o_samples;
}
-void gst_resample_nearest_s16(gst_resample_t * r)
+void
+gst_resample_nearest_s16 (gst_resample_t * r)
{
- signed short *i_ptr, *o_ptr;
- int i_count = 0;
- double a;
- int i;
+ signed short *i_ptr, *o_ptr;
+ int i_count = 0;
+ double a;
+ int i;
- i_ptr = (signed short *) r->i_buf;
- o_ptr = (signed short *) r->o_buf;
+ i_ptr = (signed short *) r->i_buf;
+ o_ptr = (signed short *) r->o_buf;
- a = r->o_start;
- i_count = 0;
+ a = r->o_start;
+ i_count = 0;
#define SCALE_LOOP(COPY,INC) \
for (i = 0; i < r->o_samples; i++) { \
COPY; \
o_ptr+=INC; \
}
- switch (r->channels) {
- case 1:
- SCALE_LOOP(o_ptr[0] = i_ptr[0], 1);
- break;
- case 2:
- SCALE_LOOP(o_ptr[0] = i_ptr[0];
- o_ptr[1] = i_ptr[1], 2);
- break;
- default:
- {
- int n, n_chan = r->channels;
-
- SCALE_LOOP(for (n = 0; n < n_chan; n++) o_ptr[n] =
- i_ptr[n], n_chan);
- }
- }
- if (i_count != r->i_samples) {
- printf("handled %d in samples (expected %d)\n", i_count,
- r->i_samples);
- }
+ switch (r->channels) {
+ case 1:
+ SCALE_LOOP (o_ptr[0] = i_ptr[0], 1);
+ break;
+ case 2:
+ SCALE_LOOP (o_ptr[0] = i_ptr[0]; o_ptr[1] = i_ptr[1], 2);
+ break;
+ default:
+ {
+ int n, n_chan = r->channels;
+
+ SCALE_LOOP (for (n = 0; n < n_chan; n++) o_ptr[n] = i_ptr[n], n_chan);
+ }
+ }
+ if (i_count != r->i_samples) {
+ printf ("handled %d in samples (expected %d)\n", i_count, r->i_samples);
+ }
}
-void gst_resample_bilinear_s16(gst_resample_t * r)
+void
+gst_resample_bilinear_s16 (gst_resample_t * r)
{
- signed short *i_ptr, *o_ptr;
- int o_count = 0;
- double b;
- int i;
- double acc0, acc1;
-
- i_ptr = (signed short *) r->i_buf;
- o_ptr = (signed short *) r->o_buf;
-
- acc0 = r->acc[0];
- acc1 = r->acc[1];
- b = r->i_start;
- for (i = 0; i < r->i_samples; i++) {
- b += r->i_inc;
- /*printf("in %d\n",i_ptr[0]); */
- if(b>=2){
- printf("not expecting b>=2\n");
- }
- if (b >= 1) {
- acc0 += (1.0 - (b-r->i_inc)) * i_ptr[0];
- acc1 += (1.0 - (b-r->i_inc)) * i_ptr[1];
-
- o_ptr[0] = rint(acc0);
- /*printf("out %d\n",o_ptr[0]); */
- o_ptr[1] = rint(acc1);
- o_ptr += 2;
- o_count++;
-
- b -= 1.0;
-
- acc0 = b * i_ptr[0];
- acc1 = b * i_ptr[1];
- } else {
- acc0 += i_ptr[0] * r->i_inc;
- acc1 += i_ptr[1] * r->i_inc;
- }
- i_ptr += 2;
- }
- r->acc[0] = acc0;
- r->acc[1] = acc1;
-
- if (o_count != r->o_samples) {
- printf("handled %d out samples (expected %d)\n", o_count,
- r->o_samples);
- }
+ signed short *i_ptr, *o_ptr;
+ int o_count = 0;
+ double b;
+ int i;
+ double acc0, acc1;
+
+ i_ptr = (signed short *) r->i_buf;
+ o_ptr = (signed short *) r->o_buf;
+
+ acc0 = r->acc[0];
+ acc1 = r->acc[1];
+ b = r->i_start;
+ for (i = 0; i < r->i_samples; i++) {
+ b += r->i_inc;
+ /*printf("in %d\n",i_ptr[0]); */
+ if (b >= 2) {
+ printf ("not expecting b>=2\n");
+ }
+ if (b >= 1) {
+ acc0 += (1.0 - (b - r->i_inc)) * i_ptr[0];
+ acc1 += (1.0 - (b - r->i_inc)) * i_ptr[1];
+
+ o_ptr[0] = rint (acc0);
+ /*printf("out %d\n",o_ptr[0]); */
+ o_ptr[1] = rint (acc1);
+ o_ptr += 2;
+ o_count++;
+
+ b -= 1.0;
+
+ acc0 = b * i_ptr[0];
+ acc1 = b * i_ptr[1];
+ } else {
+ acc0 += i_ptr[0] * r->i_inc;
+ acc1 += i_ptr[1] * r->i_inc;
+ }
+ i_ptr += 2;
+ }
+ r->acc[0] = acc0;
+ r->acc[1] = acc1;
+
+ if (o_count != r->o_samples) {
+ printf ("handled %d out samples (expected %d)\n", o_count, r->o_samples);
+ }
}
-void gst_resample_sinc_slow_s16(gst_resample_t * r)
+void
+gst_resample_sinc_slow_s16 (gst_resample_t * r)
{
- signed short *i_ptr, *o_ptr;
- int i, j;
- double c0, c1;
- double a;
- int start;
- double center;
- double weight;
-
- if (!r->buffer) {
- int size = r->filter_length * 2 * r->channels;
-
- printf("gst_resample temp buffer\n");
- r->buffer = malloc(size);
- memset(r->buffer, 0, size);
- }
-
- i_ptr = (signed short *) r->i_buf;
- o_ptr = (signed short *) r->o_buf;
-
- a = r->i_start;
+ signed short *i_ptr, *o_ptr;
+ int i, j;
+ double c0, c1;
+ double a;
+ int start;
+ double center;
+ double weight;
+
+ if (!r->buffer) {
+ int size = r->filter_length * 2 * r->channels;
+
+ printf ("gst_resample temp buffer\n");
+ r->buffer = malloc (size);
+ memset (r->buffer, 0, size);
+ }
+
+ i_ptr = (signed short *) r->i_buf;
+ o_ptr = (signed short *) r->o_buf;
+
+ a = r->i_start;
#define GETBUF(index,chan) (((index)<0) \
? ((short *)(r->buffer))[((index)+r->filter_length)*2+(chan)] \
: i_ptr[(index)*2+(chan)])
- {
- double sinx, cosx, sind, cosd;
- double x, d;
- double t;
-
- for (i = 0; i < r->o_samples; i++) {
- start = floor(a) - r->filter_length;
- center = a - r->halftaps;
- x = M_PI * (start - center) * r->o_inc;
- sinx = sin(M_PI * (start - center) * r->o_inc);
- cosx = cos(M_PI * (start - center) * r->o_inc);
- d = M_PI * r->o_inc;
- sind = sin(M_PI * r->o_inc);
- cosd = cos(M_PI * r->o_inc);
- c0 = 0;
- c1 = 0;
- for (j = 0; j < r->filter_length; j++) {
- weight = (x==0)?1:(sinx/x);
+ {
+ double sinx, cosx, sind, cosd;
+ double x, d;
+ double t;
+
+ for (i = 0; i < r->o_samples; i++) {
+ start = floor (a) - r->filter_length;
+ center = a - r->halftaps;
+ x = M_PI * (start - center) * r->o_inc;
+ sinx = sin (M_PI * (start - center) * r->o_inc);
+ cosx = cos (M_PI * (start - center) * r->o_inc);
+ d = M_PI * r->o_inc;
+ sind = sin (M_PI * r->o_inc);
+ cosd = cos (M_PI * r->o_inc);
+ c0 = 0;
+ c1 = 0;
+ for (j = 0; j < r->filter_length; j++) {
+ weight = (x == 0) ? 1 : (sinx / x);
/*printf("j %d sin %g cos %g\n",j,sinx,cosx); */
/*printf("j %d sin %g x %g sinc %g\n",j,sinx,x,weight); */
- c0 += weight * GETBUF((start + j), 0);
- c1 += weight * GETBUF((start + j), 1);
- t = cosx * cosd - sinx * sind;
- sinx = cosx * sind + sinx * cosd;
- cosx = t;
- x += d;
- }
- o_ptr[0] = rint(c0);
- o_ptr[1] = rint(c1);
- o_ptr += 2;
- a += r->o_inc;
- }
- }
+ c0 += weight * GETBUF ((start + j), 0);
+ c1 += weight * GETBUF ((start + j), 1);
+ t = cosx * cosd - sinx * sind;
+ sinx = cosx * sind + sinx * cosd;
+ cosx = t;
+ x += d;
+ }
+ o_ptr[0] = rint (c0);
+ o_ptr[1] = rint (c1);
+ o_ptr += 2;
+ a += r->o_inc;
+ }
+ }
#undef GETBUF
- memcpy(r->buffer,
- i_ptr + (r->i_samples - r->filter_length) * r->channels,
- r->filter_length * 2 * r->channels);
+ memcpy (r->buffer,
+ i_ptr + (r->i_samples - r->filter_length) * r->channels,
+ r->filter_length * 2 * r->channels);
}
/* only works for channels == 2 ???? */
-void gst_resample_sinc_s16(gst_resample_t * r)
+void
+gst_resample_sinc_s16 (gst_resample_t * r)
{
- double *ptr;
- signed short *o_ptr;
- int i, j;
- double c0, c1;
- double a;
- int start;
- double center;
- double weight;
- double x0, x, d;
- double scale;
-
- ptr = (double *) r->buffer;
- o_ptr = (signed short *) r->o_buf;
-
- /* scale provides a cutoff frequency for the low
- * pass filter aspects of sinc(). scale=M_PI
- * will cut off at the input frequency, which is
- * good for up-sampling, but will cause aliasing
- * for downsampling. Downsampling needs to be
- * cut off at o_rate, thus scale=M_PI*r->i_inc. */
- /* actually, it needs to be M_PI*r->i_inc*r->i_inc.
- * Need to research why. */
- scale = M_PI*r->i_inc;
- for (i = 0; i < r->o_samples; i++) {
- a = r->o_start + i * r->o_inc;
- start = floor(a - r->halftaps);
+ double *ptr;
+ signed short *o_ptr;
+ int i, j;
+ double c0, c1;
+ double a;
+ int start;
+ double center;
+ double weight;
+ double x0, x, d;
+ double scale;
+
+ ptr = (double *) r->buffer;
+ o_ptr = (signed short *) r->o_buf;
+
+ /* scale provides a cutoff frequency for the low
+ * pass filter aspects of sinc(). scale=M_PI
+ * will cut off at the input frequency, which is
+ * good for up-sampling, but will cause aliasing
+ * for downsampling. Downsampling needs to be
+ * cut off at o_rate, thus scale=M_PI*r->i_inc. */
+ /* actually, it needs to be M_PI*r->i_inc*r->i_inc.
+ * Need to research why. */
+ scale = M_PI * r->i_inc;
+ for (i = 0; i < r->o_samples; i++) {
+ a = r->o_start + i * r->o_inc;
+ start = floor (a - r->halftaps);
/*printf("%d: a=%g start=%d end=%d\n",i,a,start,start+r->filter_length-1); */
- center = a;
- /*x = M_PI * (start - center) * r->o_inc; */
- /*d = M_PI * r->o_inc; */
- /*x = (start - center) * r->o_inc; */
- x0 = (start - center) * r->o_inc;
- d = r->o_inc;
- c0 = 0;
- c1 = 0;
- for (j = 0; j < r->filter_length; j++) {
- x = x0 + d * j;
- weight = sinc(x*scale*r->i_inc)*scale/M_PI;
- weight *= window_func(x/r->halftaps*r->i_inc);
- c0 += weight * ptr[(start + j + r->filter_length)*2 + 0];
- c1 += weight * ptr[(start + j + r->filter_length)*2 + 1];
- }
- o_ptr[0] = double_to_s16(c0);
- o_ptr[1] = double_to_s16(c1);
- o_ptr += 2;
- }
+ center = a;
+ /*x = M_PI * (start - center) * r->o_inc; */
+ /*d = M_PI * r->o_inc; */
+ /*x = (start - center) * r->o_inc; */
+ x0 = (start - center) * r->o_inc;
+ d = r->o_inc;
+ c0 = 0;
+ c1 = 0;
+ for (j = 0; j < r->filter_length; j++) {
+ x = x0 + d * j;
+ weight = sinc (x * scale * r->i_inc) * scale / M_PI;
+ weight *= window_func (x / r->halftaps * r->i_inc);
+ c0 += weight * ptr[(start + j + r->filter_length) * 2 + 0];
+ c1 += weight * ptr[(start + j + r->filter_length) * 2 + 1];
+ }
+ o_ptr[0] = double_to_s16 (c0);
+ o_ptr[1] = double_to_s16 (c1);
+ o_ptr += 2;
+ }
}
/*
double out_tmp[10000];
-void gst_resample_sinc_ft_s16(gst_resample_t * r)
+void
+gst_resample_sinc_ft_s16 (gst_resample_t * r)
{
- double *ptr;
- signed short *o_ptr;
- int i;
- /*int j; */
- double c0, c1;
- /*double a; */
- double start_f, start_x;
- int start;
- double center;
- /*double weight; */
- double x, d;
- double scale;
- int n = 4;
-
- scale = r->i_inc; /* cutoff at 22050 */
- /*scale = 1.0; // cutoff at 24000 */
- /*scale = r->i_inc * 0.5; // cutoff at 11025 */
-
- if(!ft){
- ft = malloc(sizeof(*ft));
- memset(ft,0,sizeof(*ft));
-
- ft->len = (r->filter_length + 2) * n;
- ft->offset = 1.0 / n;
- ft->start = - ft->len * 0.5 * ft->offset;
-
- ft->func_x = functable_sinc;
- ft->func_dx = functable_dsinc;
- ft->scale = M_PI * scale;
-
- ft->func2_x = functable_window_std;
- ft->func2_dx = functable_window_dstd;
- ft->scale2 = 1.0 / r->halftaps;
-
- functable_init(ft);
-
- /*printf("len=%d offset=%g start=%g\n",ft->len,ft->offset,ft->start); */
- }
-
- ptr = r->buffer;
- o_ptr = (signed short *) r->o_buf;
-
- center = r->o_start;
- start_x = center - r->halftaps;
- start_f = floor(start_x);
- start_x -= start_f;
- start = start_f;
- for (i = 0; i < r->o_samples; i++) {
- /*start_f = floor(center - r->halftaps); */
+ double *ptr;
+ signed short *o_ptr;
+ int i;
+
+ /*int j; */
+ double c0, c1;
+
+ /*double a; */
+ double start_f, start_x;
+ int start;
+ double center;
+
+ /*double weight; */
+ double x, d;
+ double scale;
+ int n = 4;
+
+ scale = r->i_inc; /* cutoff at 22050 */
+ /*scale = 1.0; // cutoff at 24000 */
+ /*scale = r->i_inc * 0.5; // cutoff at 11025 */
+
+ if (!ft) {
+ ft = malloc (sizeof (*ft));
+ memset (ft, 0, sizeof (*ft));
+
+ ft->len = (r->filter_length + 2) * n;
+ ft->offset = 1.0 / n;
+ ft->start = -ft->len * 0.5 * ft->offset;
+
+ ft->func_x = functable_sinc;
+ ft->func_dx = functable_dsinc;
+ ft->scale = M_PI * scale;
+
+ ft->func2_x = functable_window_std;
+ ft->func2_dx = functable_window_dstd;
+ ft->scale2 = 1.0 / r->halftaps;
+
+ functable_init (ft);
+
+ /*printf("len=%d offset=%g start=%g\n",ft->len,ft->offset,ft->start); */
+ }
+
+ ptr = r->buffer;
+ o_ptr = (signed short *) r->o_buf;
+
+ center = r->o_start;
+ start_x = center - r->halftaps;
+ start_f = floor (start_x);
+ start_x -= start_f;
+ start = start_f;
+ for (i = 0; i < r->o_samples; i++) {
+ /*start_f = floor(center - r->halftaps); */
/*printf("%d: a=%g start=%d end=%d\n",i,a,start,start+r->filter_length-1); */
- x = start_f - center;
- d = 1;
- c0 = 0;
- c1 = 0;
+ x = start_f - center;
+ d = 1;
+ c0 = 0;
+ c1 = 0;
/*#define slow */
#ifdef slow
- for (j = 0; j < r->filter_length; j++) {
- weight = functable_eval(ft,x)*scale;
- /*weight = sinc(M_PI * scale * x)*scale*r->i_inc; */
- /*weight *= window_func(x / r->halftaps); */
- c0 += weight * ptr[(start + j + r->filter_length)*2 + 0];
- c1 += weight * ptr[(start + j + r->filter_length)*2 + 1];
- x += d;
- }
+ for (j = 0; j < r->filter_length; j++) {
+ weight = functable_eval (ft, x) * scale;
+ /*weight = sinc(M_PI * scale * x)*scale*r->i_inc; */
+ /*weight *= window_func(x / r->halftaps); */
+ c0 += weight * ptr[(start + j + r->filter_length) * 2 + 0];
+ c1 += weight * ptr[(start + j + r->filter_length) * 2 + 1];
+ x += d;
+ }
#else
- functable_fir2(ft,
- &c0,&c1,
- x, n,
- ptr+(start + r->filter_length)*2,
- r->filter_length);
- c0 *= scale;
- c1 *= scale;
+ functable_fir2 (ft,
+ &c0, &c1, x, n, ptr + (start + r->filter_length) * 2, r->filter_length);
+ c0 *= scale;
+ c1 *= scale;
#endif
- out_tmp[2 * i + 0] = c0;
- out_tmp[2 * i + 1] = c1;
- center += r->o_inc;
- start_x += r->o_inc;
- while(start_x>=1.0){
- start_f++;
- start_x -= 1.0;
- start++;
- }
- }
-
- if(r->channels==2){
- conv_short_double(r->o_buf,out_tmp,2 * r->o_samples);
- }else{
- conv_short_double_sstr(r->o_buf,out_tmp,r->o_samples,2 * sizeof(double));
- }
+ out_tmp[2 * i + 0] = c0;
+ out_tmp[2 * i + 1] = c1;
+ center += r->o_inc;
+ start_x += r->o_inc;
+ while (start_x >= 1.0) {
+ start_f++;
+ start_x -= 1.0;
+ start++;
+ }
+ }
+
+ if (r->channels == 2) {
+ conv_short_double (r->o_buf, out_tmp, 2 * r->o_samples);
+ } else {
+ conv_short_double_sstr (r->o_buf, out_tmp, r->o_samples,
+ 2 * sizeof (double));
+ }
}
/********
********/
-void gst_resample_nearest_float(gst_resample_t * r)
+void
+gst_resample_nearest_float (gst_resample_t * r)
{
- float *i_ptr, *o_ptr;
- int i_count = 0;
- double a;
- int i;
+ float *i_ptr, *o_ptr;
+ int i_count = 0;
+ double a;
+ int i;
- i_ptr = (float *) r->i_buf;
- o_ptr = (float *) r->o_buf;
+ i_ptr = (float *) r->i_buf;
+ o_ptr = (float *) r->o_buf;
- a = r->o_start;
- i_count = 0;
+ a = r->o_start;
+ i_count = 0;
#define SCALE_LOOP(COPY,INC) \
for (i = 0; i < r->o_samples; i++) { \
COPY; \
o_ptr+=INC; \
}
- switch (r->channels) {
- case 1:
- SCALE_LOOP(o_ptr[0] = i_ptr[0], 1);
- break;
- case 2:
- SCALE_LOOP(o_ptr[0] = i_ptr[0];
- o_ptr[1] = i_ptr[1], 2);
- break;
- default:
- {
- int n, n_chan = r->channels;
-
- SCALE_LOOP(for (n = 0; n < n_chan; n++) o_ptr[n] =
- i_ptr[n], n_chan);
- }
- }
- if (i_count != r->i_samples) {
- printf("handled %d in samples (expected %d)\n", i_count,
- r->i_samples);
- }
+ switch (r->channels) {
+ case 1:
+ SCALE_LOOP (o_ptr[0] = i_ptr[0], 1);
+ break;
+ case 2:
+ SCALE_LOOP (o_ptr[0] = i_ptr[0]; o_ptr[1] = i_ptr[1], 2);
+ break;
+ default:
+ {
+ int n, n_chan = r->channels;
+
+ SCALE_LOOP (for (n = 0; n < n_chan; n++) o_ptr[n] = i_ptr[n], n_chan);
+ }
+ }
+ if (i_count != r->i_samples) {
+ printf ("handled %d in samples (expected %d)\n", i_count, r->i_samples);
+ }
}
-void gst_resample_bilinear_float(gst_resample_t * r)
+void
+gst_resample_bilinear_float (gst_resample_t * r)
{
- float *i_ptr, *o_ptr;
- int o_count = 0;
- double b;
- int i;
- double acc0, acc1;
-
- i_ptr = (float *) r->i_buf;
- o_ptr = (float *) r->o_buf;
-
- acc0 = r->acc[0];
- acc1 = r->acc[1];
- b = r->i_start;
- for (i = 0; i < r->i_samples; i++) {
- b += r->i_inc;
- /*printf("in %d\n",i_ptr[0]); */
- if(b>=2){
- printf("not expecting b>=2\n");
- }
- if (b >= 1) {
- acc0 += (1.0 - (b-r->i_inc)) * i_ptr[0];
- acc1 += (1.0 - (b-r->i_inc)) * i_ptr[1];
-
- o_ptr[0] = acc0;
- /*printf("out %d\n",o_ptr[0]); */
- o_ptr[1] = acc1;
- o_ptr += 2;
- o_count++;
-
- b -= 1.0;
-
- acc0 = b * i_ptr[0];
- acc1 = b * i_ptr[1];
- } else {
- acc0 += i_ptr[0] * r->i_inc;
- acc1 += i_ptr[1] * r->i_inc;
- }
- i_ptr += 2;
- }
- r->acc[0] = acc0;
- r->acc[1] = acc1;
-
- if (o_count != r->o_samples) {
- printf("handled %d out samples (expected %d)\n", o_count,
- r->o_samples);
- }
+ float *i_ptr, *o_ptr;
+ int o_count = 0;
+ double b;
+ int i;
+ double acc0, acc1;
+
+ i_ptr = (float *) r->i_buf;
+ o_ptr = (float *) r->o_buf;
+
+ acc0 = r->acc[0];
+ acc1 = r->acc[1];
+ b = r->i_start;
+ for (i = 0; i < r->i_samples; i++) {
+ b += r->i_inc;
+ /*printf("in %d\n",i_ptr[0]); */
+ if (b >= 2) {
+ printf ("not expecting b>=2\n");
+ }
+ if (b >= 1) {
+ acc0 += (1.0 - (b - r->i_inc)) * i_ptr[0];
+ acc1 += (1.0 - (b - r->i_inc)) * i_ptr[1];
+
+ o_ptr[0] = acc0;
+ /*printf("out %d\n",o_ptr[0]); */
+ o_ptr[1] = acc1;
+ o_ptr += 2;
+ o_count++;
+
+ b -= 1.0;
+
+ acc0 = b * i_ptr[0];
+ acc1 = b * i_ptr[1];
+ } else {
+ acc0 += i_ptr[0] * r->i_inc;
+ acc1 += i_ptr[1] * r->i_inc;
+ }
+ i_ptr += 2;
+ }
+ r->acc[0] = acc0;
+ r->acc[1] = acc1;
+
+ if (o_count != r->o_samples) {
+ printf ("handled %d out samples (expected %d)\n", o_count, r->o_samples);
+ }
}
-void gst_resample_sinc_slow_float(gst_resample_t * r)
+void
+gst_resample_sinc_slow_float (gst_resample_t * r)
{
- float *i_ptr, *o_ptr;
- int i, j;
- double c0, c1;
- double a;
- int start;
- double center;
- double weight;
-
- if (!r->buffer) {
- int size = r->filter_length * sizeof(float) * r->channels;
-
- printf("gst_resample temp buffer\n");
- r->buffer = malloc(size);
- memset(r->buffer, 0, size);
- }
-
- i_ptr = (float *) r->i_buf;
- o_ptr = (float *) r->o_buf;
-
- a = r->i_start;
+ float *i_ptr, *o_ptr;
+ int i, j;
+ double c0, c1;
+ double a;
+ int start;
+ double center;
+ double weight;
+
+ if (!r->buffer) {
+ int size = r->filter_length * sizeof (float) * r->channels;
+
+ printf ("gst_resample temp buffer\n");
+ r->buffer = malloc (size);
+ memset (r->buffer, 0, size);
+ }
+
+ i_ptr = (float *) r->i_buf;
+ o_ptr = (float *) r->o_buf;
+
+ a = r->i_start;
#define GETBUF(index,chan) (((index)<0) \
? ((float *)(r->buffer))[((index)+r->filter_length)*2+(chan)] \
: i_ptr[(index)*2+(chan)])
- {
- double sinx, cosx, sind, cosd;
- double x, d;
- double t;
-
- for (i = 0; i < r->o_samples; i++) {
- start = floor(a) - r->filter_length;
- center = a - r->halftaps;
- x = M_PI * (start - center) * r->o_inc;
- sinx = sin(M_PI * (start - center) * r->o_inc);
- cosx = cos(M_PI * (start - center) * r->o_inc);
- d = M_PI * r->o_inc;
- sind = sin(M_PI * r->o_inc);
- cosd = cos(M_PI * r->o_inc);
- c0 = 0;
- c1 = 0;
- for (j = 0; j < r->filter_length; j++) {
- weight = (x==0)?1:(sinx/x);
+ {
+ double sinx, cosx, sind, cosd;
+ double x, d;
+ double t;
+
+ for (i = 0; i < r->o_samples; i++) {
+ start = floor (a) - r->filter_length;
+ center = a - r->halftaps;
+ x = M_PI * (start - center) * r->o_inc;
+ sinx = sin (M_PI * (start - center) * r->o_inc);
+ cosx = cos (M_PI * (start - center) * r->o_inc);
+ d = M_PI * r->o_inc;
+ sind = sin (M_PI * r->o_inc);
+ cosd = cos (M_PI * r->o_inc);
+ c0 = 0;
+ c1 = 0;
+ for (j = 0; j < r->filter_length; j++) {
+ weight = (x == 0) ? 1 : (sinx / x);
/*printf("j %d sin %g cos %g\n",j,sinx,cosx); */
/*printf("j %d sin %g x %g sinc %g\n",j,sinx,x,weight); */
- c0 += weight * GETBUF((start + j), 0);
- c1 += weight * GETBUF((start + j), 1);
- t = cosx * cosd - sinx * sind;
- sinx = cosx * sind + sinx * cosd;
- cosx = t;
- x += d;
- }
- o_ptr[0] = c0;
- o_ptr[1] = c1;
- o_ptr += 2;
- a += r->o_inc;
- }
- }
+ c0 += weight * GETBUF ((start + j), 0);
+ c1 += weight * GETBUF ((start + j), 1);
+ t = cosx * cosd - sinx * sind;
+ sinx = cosx * sind + sinx * cosd;
+ cosx = t;
+ x += d;
+ }
+ o_ptr[0] = c0;
+ o_ptr[1] = c1;
+ o_ptr += 2;
+ a += r->o_inc;
+ }
+ }
#undef GETBUF
- memcpy(r->buffer,
- i_ptr + (r->i_samples - r->filter_length) * r->channels,
- r->filter_length * sizeof(float) * r->channels);
+ memcpy (r->buffer,
+ i_ptr + (r->i_samples - r->filter_length) * r->channels,
+ r->filter_length * sizeof (float) * r->channels);
}
/* only works for channels == 2 ???? */
-void gst_resample_sinc_float(gst_resample_t * r)
+void
+gst_resample_sinc_float (gst_resample_t * r)
{
- double *ptr;
- float *o_ptr;
- int i, j;
- double c0, c1;
- double a;
- int start;
- double center;
- double weight;
- double x0, x, d;
- double scale;
-
- ptr = (double *) r->buffer;
- o_ptr = (float *) r->o_buf;
-
- /* scale provides a cutoff frequency for the low
- * pass filter aspects of sinc(). scale=M_PI
- * will cut off at the input frequency, which is
- * good for up-sampling, but will cause aliasing
- * for downsampling. Downsampling needs to be
- * cut off at o_rate, thus scale=M_PI*r->i_inc. */
- /* actually, it needs to be M_PI*r->i_inc*r->i_inc.
- * Need to research why. */
- scale = M_PI*r->i_inc;
- for (i = 0; i < r->o_samples; i++) {
- a = r->o_start + i * r->o_inc;
- start = floor(a - r->halftaps);
+ double *ptr;
+ float *o_ptr;
+ int i, j;
+ double c0, c1;
+ double a;
+ int start;
+ double center;
+ double weight;
+ double x0, x, d;
+ double scale;
+
+ ptr = (double *) r->buffer;
+ o_ptr = (float *) r->o_buf;
+
+ /* scale provides a cutoff frequency for the low
+ * pass filter aspects of sinc(). scale=M_PI
+ * will cut off at the input frequency, which is
+ * good for up-sampling, but will cause aliasing
+ * for downsampling. Downsampling needs to be
+ * cut off at o_rate, thus scale=M_PI*r->i_inc. */
+ /* actually, it needs to be M_PI*r->i_inc*r->i_inc.
+ * Need to research why. */
+ scale = M_PI * r->i_inc;
+ for (i = 0; i < r->o_samples; i++) {
+ a = r->o_start + i * r->o_inc;
+ start = floor (a - r->halftaps);
/*printf("%d: a=%g start=%d end=%d\n",i,a,start,start+r->filter_length-1); */
- center = a;
- /*x = M_PI * (start - center) * r->o_inc; */
- /*d = M_PI * r->o_inc; */
- /*x = (start - center) * r->o_inc; */
- x0 = (start - center) * r->o_inc;
- d = r->o_inc;
- c0 = 0;
- c1 = 0;
- for (j = 0; j < r->filter_length; j++) {
- x = x0 + d * j;
- weight = sinc(x*scale*r->i_inc)*scale/M_PI;
- weight *= window_func(x/r->halftaps*r->i_inc);
- c0 += weight * ptr[(start + j + r->filter_length)*2 + 0];
- c1 += weight * ptr[(start + j + r->filter_length)*2 + 1];
- }
- o_ptr[0] = c0;
- o_ptr[1] = c1;
- o_ptr += 2;
- }
+ center = a;
+ /*x = M_PI * (start - center) * r->o_inc; */
+ /*d = M_PI * r->o_inc; */
+ /*x = (start - center) * r->o_inc; */
+ x0 = (start - center) * r->o_inc;
+ d = r->o_inc;
+ c0 = 0;
+ c1 = 0;
+ for (j = 0; j < r->filter_length; j++) {
+ x = x0 + d * j;
+ weight = sinc (x * scale * r->i_inc) * scale / M_PI;
+ weight *= window_func (x / r->halftaps * r->i_inc);
+ c0 += weight * ptr[(start + j + r->filter_length) * 2 + 0];
+ c1 += weight * ptr[(start + j + r->filter_length) * 2 + 1];
+ }
+ o_ptr[0] = c0;
+ o_ptr[1] = c1;
+ o_ptr += 2;
+ }
}
-void gst_resample_sinc_ft_float(gst_resample_t * r)
+void
+gst_resample_sinc_ft_float (gst_resample_t * r)
{
- double *ptr;
- float *o_ptr;
- int i;
- /*int j; */
- double c0, c1;
- /*double a; */
- double start_f, start_x;
- int start;
- double center;
- /*double weight; */
- double x, d;
- double scale;
- int n = 4;
-
- scale = r->i_inc; /* cutoff at 22050 */
- /*scale = 1.0; // cutoff at 24000 */
- /*scale = r->i_inc * 0.5; // cutoff at 11025 */
-
- if(!ft){
- ft = malloc(sizeof(*ft));
- memset(ft,0,sizeof(*ft));
-
- ft->len = (r->filter_length + 2) * n;
- ft->offset = 1.0 / n;
- ft->start = - ft->len * 0.5 * ft->offset;
-
- ft->func_x = functable_sinc;
- ft->func_dx = functable_dsinc;
- ft->scale = M_PI * scale;
-
- ft->func2_x = functable_window_std;
- ft->func2_dx = functable_window_dstd;
- ft->scale2 = 1.0 / r->halftaps;
-
- functable_init(ft);
-
- /*printf("len=%d offset=%g start=%g\n",ft->len,ft->offset,ft->start); */
- }
-
- ptr = r->buffer;
- o_ptr = (float *) r->o_buf;
-
- center = r->o_start;
- start_x = center - r->halftaps;
- start_f = floor(start_x);
- start_x -= start_f;
- start = start_f;
- for (i = 0; i < r->o_samples; i++) {
- /*start_f = floor(center - r->halftaps); */
+ double *ptr;
+ float *o_ptr;
+ int i;
+
+ /*int j; */
+ double c0, c1;
+
+ /*double a; */
+ double start_f, start_x;
+ int start;
+ double center;
+
+ /*double weight; */
+ double x, d;
+ double scale;
+ int n = 4;
+
+ scale = r->i_inc; /* cutoff at 22050 */
+ /*scale = 1.0; // cutoff at 24000 */
+ /*scale = r->i_inc * 0.5; // cutoff at 11025 */
+
+ if (!ft) {
+ ft = malloc (sizeof (*ft));
+ memset (ft, 0, sizeof (*ft));
+
+ ft->len = (r->filter_length + 2) * n;
+ ft->offset = 1.0 / n;
+ ft->start = -ft->len * 0.5 * ft->offset;
+
+ ft->func_x = functable_sinc;
+ ft->func_dx = functable_dsinc;
+ ft->scale = M_PI * scale;
+
+ ft->func2_x = functable_window_std;
+ ft->func2_dx = functable_window_dstd;
+ ft->scale2 = 1.0 / r->halftaps;
+
+ functable_init (ft);
+
+ /*printf("len=%d offset=%g start=%g\n",ft->len,ft->offset,ft->start); */
+ }
+
+ ptr = r->buffer;
+ o_ptr = (float *) r->o_buf;
+
+ center = r->o_start;
+ start_x = center - r->halftaps;
+ start_f = floor (start_x);
+ start_x -= start_f;
+ start = start_f;
+ for (i = 0; i < r->o_samples; i++) {
+ /*start_f = floor(center - r->halftaps); */
/*printf("%d: a=%g start=%d end=%d\n",i,a,start,start+r->filter_length-1); */
- x = start_f - center;
- d = 1;
- c0 = 0;
- c1 = 0;
+ x = start_f - center;
+ d = 1;
+ c0 = 0;
+ c1 = 0;
/*#define slow */
#ifdef slow
- for (j = 0; j < r->filter_length; j++) {
- weight = functable_eval(ft,x)*scale;
- /*weight = sinc(M_PI * scale * x)*scale*r->i_inc; */
- /*weight *= window_func(x / r->halftaps); */
- c0 += weight * ptr[(start + j + r->filter_length)*2 + 0];
- c1 += weight * ptr[(start + j + r->filter_length)*2 + 1];
- x += d;
- }
+ for (j = 0; j < r->filter_length; j++) {
+ weight = functable_eval (ft, x) * scale;
+ /*weight = sinc(M_PI * scale * x)*scale*r->i_inc; */
+ /*weight *= window_func(x / r->halftaps); */
+ c0 += weight * ptr[(start + j + r->filter_length) * 2 + 0];
+ c1 += weight * ptr[(start + j + r->filter_length) * 2 + 1];
+ x += d;
+ }
#else
- functable_fir2(ft,
- &c0,&c1,
- x, n,
- ptr+(start + r->filter_length)*2,
- r->filter_length);
- c0 *= scale;
- c1 *= scale;
+ functable_fir2 (ft,
+ &c0, &c1, x, n, ptr + (start + r->filter_length) * 2, r->filter_length);
+ c0 *= scale;
+ c1 *= scale;
#endif
- out_tmp[2 * i + 0] = c0;
- out_tmp[2 * i + 1] = c1;
- center += r->o_inc;
- start_x += r->o_inc;
- while(start_x>=1.0){
- start_f++;
- start_x -= 1.0;
- start++;
- }
- }
-
- if(r->channels==2){
- conv_float_double(r->o_buf,out_tmp,2 * r->o_samples);
- }else{
- conv_float_double_sstr(r->o_buf,out_tmp,r->o_samples,2 * sizeof(double));
- }
+ out_tmp[2 * i + 0] = c0;
+ out_tmp[2 * i + 1] = c1;
+ center += r->o_inc;
+ start_x += r->o_inc;
+ while (start_x >= 1.0) {
+ start_f++;
+ start_x -= 1.0;
+ start++;
+ }
+ }
+
+ if (r->channels == 2) {
+ conv_float_double (r->o_buf, out_tmp, 2 * r->o_samples);
+ } else {
+ conv_float_double_sstr (r->o_buf, out_tmp, r->o_samples,
+ 2 * sizeof (double));
+ }
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "gstresample",
- "Resampling routines for use in audio plugins",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-);
-
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "gstresample",
+ "Resampling routines for use in audio plugins",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN);
#ifndef __GST_RESAMPLE_H__
#define __GST_RESAMPLE_H__
-typedef enum {
- GST_RESAMPLE_NEAREST = 0,
- GST_RESAMPLE_BILINEAR,
- GST_RESAMPLE_SINC_SLOW,
- GST_RESAMPLE_SINC,
+typedef enum
+{
+ GST_RESAMPLE_NEAREST = 0,
+ GST_RESAMPLE_BILINEAR,
+ GST_RESAMPLE_SINC_SLOW,
+ GST_RESAMPLE_SINC,
} gst_resample_method;
-typedef enum {
- GST_RESAMPLE_S16 = 0,
- GST_RESAMPLE_FLOAT
+typedef enum
+{
+ GST_RESAMPLE_S16 = 0,
+ GST_RESAMPLE_FLOAT
} gst_resample_format;
typedef struct gst_resample_s gst_resample_t;
-struct gst_resample_s {
- /* parameters */
+struct gst_resample_s
+{
+ /* parameters */
- gst_resample_method method;
- int channels;
- int verbose;
- gst_resample_format format;
+ gst_resample_method method;
+ int channels;
+ int verbose;
+ gst_resample_format format;
- int filter_length;
+ int filter_length;
- double i_rate;
- double o_rate;
+ double i_rate;
+ double o_rate;
- void *priv;
+ void *priv;
- void *(*get_buffer)(void *priv, unsigned int size);
+ void *(*get_buffer) (void *priv, unsigned int size);
- /* internal parameters */
+ /* internal parameters */
- double halftaps;
+ double halftaps;
- /* filter state */
+ /* filter state */
- void *buffer;
- int buffer_len;
+ void *buffer;
+ int buffer_len;
- double i_start;
- double o_start;
+ double i_start;
+ double o_start;
- double i_start_buf;
- double i_end_buf;
+ double i_start_buf;
+ double i_end_buf;
- double i_inc;
- double o_inc;
+ double i_inc;
+ double o_inc;
- double i_end;
- double o_end;
+ double i_end;
+ double o_end;
- int i_samples;
- int o_samples;
+ int i_samples;
+ int o_samples;
- void *i_buf, *o_buf;
+ void *i_buf, *o_buf;
- double acc[10];
+ double acc[10];
- /* methods */
- void (*scale)(gst_resample_t *r);
+ /* methods */
+ void (*scale) (gst_resample_t * r);
- double ack;
+ double ack;
};
-void gst_resample_init(gst_resample_t *r);
+void gst_resample_init (gst_resample_t * r);
-void gst_resample_reinit(gst_resample_t *r);
+void gst_resample_reinit (gst_resample_t * r);
-void gst_resample_scale(gst_resample_t *r, void *i_buf, unsigned int size);
+void gst_resample_scale (gst_resample_t * r, void *i_buf, unsigned int size);
#endif /* __GST_RESAMPLE_H__ */
-
/*#define test_func(x) sin(2*M_PI*(x)*(x)*1000) */
#define test_func(x) sin(2*M_PI*(x)*(x)*12000)
-short i_buf[I_RATE*2*2];
-short o_buf[O_RATE*2*2];
+short i_buf[I_RATE * 2 * 2];
+short o_buf[O_RATE * 2 * 2];
static int i_offset;
static int o_offset;
FILE *out;
-void test_res1(void);
-void test_res2(void);
-void test_res3(void);
-void test_res4(void);
-void test_res5(void);
-void test_res6(void);
-void test_res7(void);
+void test_res1 (void);
+void test_res2 (void);
+void test_res3 (void);
+void test_res4 (void);
+void test_res5 (void);
+void test_res6 (void);
+void test_res7 (void);
-int main(int argc,char *argv[])
+int
+main (int argc, char *argv[])
{
- out = fopen("out","w");
+ out = fopen ("out", "w");
- test_res7();
+ test_res7 ();
- return 0;
+ return 0;
}
-void *get_buffer(void *priv, unsigned int size)
+void *
+get_buffer (void *priv, unsigned int size)
{
- void *ret;
- ret = ((void *)o_buf) + o_offset;
- o_offset += size;
- return ret;
+ void *ret;
+
+ ret = ((void *) o_buf) + o_offset;
+ o_offset += size;
+ return ret;
}
struct timeval start_time;
-void start_timer(void)
+void
+start_timer (void)
{
- gettimeofday(&start_time,NULL);
- /*printf("start %ld.%06ld\n",start_time.tv_sec,start_time.tv_usec); */
+ gettimeofday (&start_time, NULL);
+ /*printf("start %ld.%06ld\n",start_time.tv_sec,start_time.tv_usec); */
}
-void end_timer(void)
+void
+end_timer (void)
{
- struct timeval end_time;
- double diff;
+ struct timeval end_time;
+ double diff;
- gettimeofday(&end_time,NULL);
- /*printf("end %ld.%06ld\n",end_time.tv_sec,end_time.tv_usec); */
- diff = (end_time.tv_sec - start_time.tv_sec) +
- 1e-6*(end_time.tv_usec - start_time.tv_usec);
+ gettimeofday (&end_time, NULL);
+ /*printf("end %ld.%06ld\n",end_time.tv_sec,end_time.tv_usec); */
+ diff = (end_time.tv_sec - start_time.tv_sec) +
+ 1e-6 * (end_time.tv_usec - start_time.tv_usec);
- printf("time %g\n",diff);
+ printf ("time %g\n", diff);
}
-void test_res1(void)
+void
+test_res1 (void)
{
- resample_t *r;
- int i;
- double sum10k,sum22k;
- double f;
- int n10k,n22k;
- double x;
-
- for(i=0;i<I_RATE;i++){
- i_buf[i*2+0] = rint(AMP * test_func((double)i/I_RATE));
- /*i_buf[i*2+1] = rint(AMP * test_func((double)i/I_RATE)); */
- i_buf[i*2+1] = (i<1000)?AMP:0;
- }
-
- r = malloc(sizeof(resample_t));
- memset(r,0,sizeof(resample_t));
-
- r->i_rate = I_RATE;
- r->o_rate = O_RATE;
- /*r->method = RESAMPLE_SINC_SLOW; */
- r->method = RESAMPLE_SINC;
- r->channels = 2;
- /*r->verbose = 1; */
- r->filter_length = 64;
- r->get_buffer = get_buffer;
-
- resample_init(r);
-
- start_timer();
+ resample_t *r;
+ int i;
+ double sum10k, sum22k;
+ double f;
+ int n10k, n22k;
+ double x;
+
+ for (i = 0; i < I_RATE; i++) {
+ i_buf[i * 2 + 0] = rint (AMP * test_func ((double) i / I_RATE));
+ /*i_buf[i*2+1] = rint(AMP * test_func((double)i/I_RATE)); */
+ i_buf[i * 2 + 1] = (i < 1000) ? AMP : 0;
+ }
+
+ r = malloc (sizeof (resample_t));
+ memset (r, 0, sizeof (resample_t));
+
+ r->i_rate = I_RATE;
+ r->o_rate = O_RATE;
+ /*r->method = RESAMPLE_SINC_SLOW; */
+ r->method = RESAMPLE_SINC;
+ r->channels = 2;
+ /*r->verbose = 1; */
+ r->filter_length = 64;
+ r->get_buffer = get_buffer;
+
+ resample_init (r);
+
+ start_timer ();
#define blocked
#ifdef blocked
- for(i=0;i+256<I_RATE;i+=256){
- resample_scale(r,i_buf+i*2,256*2*2);
- }
- if(I_RATE-i){
- resample_scale(r,i_buf+i*2,(I_RATE-i)*2*2);
- }
+ for (i = 0; i + 256 < I_RATE; i += 256) {
+ resample_scale (r, i_buf + i * 2, 256 * 2 * 2);
+ }
+ if (I_RATE - i) {
+ resample_scale (r, i_buf + i * 2, (I_RATE - i) * 2 * 2);
+ }
#else
- resample_scale(r,i_buf,I_RATE*2*2);
+ resample_scale (r, i_buf, I_RATE * 2 * 2);
#endif
- end_timer();
-
- for(i=0;i<O_RATE;i++){
- f = AMP*test_func((double)i/O_RATE);
- /*f = rint(AMP*test_func((double)i/O_RATE)); */
- fprintf(out,"%d %d %d %g %g\n",i,
- o_buf[2*i+0],o_buf[2*i+1],
- f,o_buf[2*i+0]-f);
- }
-
- sum10k=0;
- sum22k=0;
- n10k=0;
- n22k=0;
- for(i=0;i<O_RATE;i++){
- f = AMP*test_func((double)i/O_RATE);
- /*f = rint(AMP*test_func((double)i/O_RATE)); */
- x = o_buf[2*i+0]-f;
- if(((0.5*i)/O_RATE*I_RATE)<10000){
- sum10k += x*x;
- n10k++;
- }
- if(((0.5*i)/O_RATE*I_RATE)<22050){
- sum22k += x*x;
- n22k++;
- }
- }
- printf("average error 10k=%g 22k=%g\n",
- sqrt(sum10k/n10k),
- sqrt(sum22k/n22k));
+ end_timer ();
+
+ for (i = 0; i < O_RATE; i++) {
+ f = AMP * test_func ((double) i / O_RATE);
+ /*f = rint(AMP*test_func((double)i/O_RATE)); */
+ fprintf (out, "%d %d %d %g %g\n", i,
+ o_buf[2 * i + 0], o_buf[2 * i + 1], f, o_buf[2 * i + 0] - f);
+ }
+
+ sum10k = 0;
+ sum22k = 0;
+ n10k = 0;
+ n22k = 0;
+ for (i = 0; i < O_RATE; i++) {
+ f = AMP * test_func ((double) i / O_RATE);
+ /*f = rint(AMP*test_func((double)i/O_RATE)); */
+ x = o_buf[2 * i + 0] - f;
+ if (((0.5 * i) / O_RATE * I_RATE) < 10000) {
+ sum10k += x * x;
+ n10k++;
+ }
+ if (((0.5 * i) / O_RATE * I_RATE) < 22050) {
+ sum22k += x * x;
+ n22k++;
+ }
+ }
+ printf ("average error 10k=%g 22k=%g\n",
+ sqrt (sum10k / n10k), sqrt (sum22k / n22k));
}
-void test_res2(void)
+void
+test_res2 (void)
{
- functable_t *t;
- int i;
- double x;
- double f1,f2;
+ functable_t *t;
+ int i;
+ double x;
+ double f1, f2;
- t = malloc(sizeof(*t));
- memset(t,0,sizeof(*t));
+ t = malloc (sizeof (*t));
+ memset (t, 0, sizeof (*t));
- t->start = -50.0;
- t->offset = 1;
- t->len = 100;
+ t->start = -50.0;
+ t->offset = 1;
+ t->len = 100;
- t->func_x = functable_sinc;
- t->func_dx = functable_dsinc;
+ t->func_x = functable_sinc;
+ t->func_dx = functable_dsinc;
- functable_init(t);
+ functable_init (t);
- for(i=0;i<1000;i++){
- x = -50.0 + 0.1 * i;
- f1 = functable_sinc(NULL,x);
- f2 = functable_eval(t,x);
- fprintf(out,"%d %g %g %g\n",i,f1,f2,f1-f2);
- }
+ for (i = 0; i < 1000; i++) {
+ x = -50.0 + 0.1 * i;
+ f1 = functable_sinc (NULL, x);
+ f2 = functable_eval (t, x);
+ fprintf (out, "%d %g %g %g\n", i, f1, f2, f1 - f2);
+ }
}
-void test_res3(void)
+void
+test_res3 (void)
{
- functable_t *t;
- int i;
- double x;
- double f1,f2;
- int n = 1;
+ functable_t *t;
+ int i;
+ double x;
+ double f1, f2;
+ int n = 1;
- t = malloc(sizeof(*t));
- memset(t,0,sizeof(*t));
+ t = malloc (sizeof (*t));
+ memset (t, 0, sizeof (*t));
- t->start = -50.0;
- t->offset = 1.0 / n;
- t->len = 100 * n;
+ t->start = -50.0;
+ t->offset = 1.0 / n;
+ t->len = 100 * n;
- t->func_x = functable_sinc;
- t->func_dx = functable_dsinc;
+ t->func_x = functable_sinc;
+ t->func_dx = functable_dsinc;
- t->func2_x = functable_window_std;
- t->func2_dx = functable_window_dstd;
+ t->func2_x = functable_window_std;
+ t->func2_dx = functable_window_dstd;
- t->scale = 1.0;
- t->scale2 = 1.0 / (M_PI * 16);
+ t->scale = 1.0;
+ t->scale2 = 1.0 / (M_PI * 16);
- functable_init(t);
+ functable_init (t);
- for(i=0;i<1000 * n;i++){
- x = -50.0 + 0.1/n * i;
- f1 = functable_sinc(NULL,t->scale * x) *
- functable_window_std(NULL,t->scale2 * x);
- f2 = functable_eval(t,x);
- fprintf(out,"%d %g %g %g\n",i,f1,f2,f2-f1);
- }
+ for (i = 0; i < 1000 * n; i++) {
+ x = -50.0 + 0.1 / n * i;
+ f1 = functable_sinc (NULL, t->scale * x) *
+ functable_window_std (NULL, t->scale2 * x);
+ f2 = functable_eval (t, x);
+ fprintf (out, "%d %g %g %g\n", i, f1, f2, f2 - f1);
+ }
}
-double sinc_poly(double x)
+double
+sinc_poly (double x)
{
#define INV3FAC 1.66666666666666666e-1
#define INV5FAC 8.33333333333333333e-3
#define INV7FAC 1.984126984e-4
#define INV9FAC 2.755731922e-6
#define INV11FAC 2.505210839e-8
- double x2 = x * x;
+ double x2 = x * x;
- return 1
- - x2 * INV3FAC
- + x2 * x2 * INV5FAC
- - x2 * x2 * x2 * INV7FAC;
- /*+ x2 * x2 * x2 * x2 * INV9FAC */
+ return 1 - x2 * INV3FAC + x2 * x2 * INV5FAC - x2 * x2 * x2 * INV7FAC;
+ /*+ x2 * x2 * x2 * x2 * INV9FAC */
/*- x2 * x2 * x2 * x2 * x2 * INV11FAC; */
}
-void test_res4(void)
+void
+test_res4 (void)
{
- int i;
- double x,f1,f2;
-
- for(i=1;i<100;i++){
- x = 0.01 * i;
- f1 = 1 - sin(x)/x;
- f2 = 1 - sinc_poly(x);
-
- fprintf(out,"%g %.20g %.20g %.20g\n",x,f1,f2,f2-f1);
- }
+ int i;
+ double x, f1, f2;
+
+ for (i = 1; i < 100; i++) {
+ x = 0.01 * i;
+ f1 = 1 - sin (x) / x;
+ f2 = 1 - sinc_poly (x);
+
+ fprintf (out, "%g %.20g %.20g %.20g\n", x, f1, f2, f2 - f1);
+ }
}
-void test_res5(void)
+void
+test_res5 (void)
{
- int i;
- double sum;
-
- start_timer();
- sum = 0;
- for(i=0;i<I_RATE;i++){
- sum += i_buf[i*2];
- }
- end_timer();
- i_buf[0] = sum;
+ int i;
+ double sum;
+
+ start_timer ();
+ sum = 0;
+ for (i = 0; i < I_RATE; i++) {
+ sum += i_buf[i * 2];
+ }
+ end_timer ();
+ i_buf[0] = sum;
}
-void short_to_double(double *d,short *x) { *d = *x; }
-void short_to_float(float *f,short *x) { *f = *x; }
-void float_to_double(double *f,float *x) { *f = *x; }
-void double_to_short(short *f,double *x) { *f = *x; }
+void
+short_to_double (double *d, short *x)
+{
+ *d = *x;
+}
+
+void
+short_to_float (float *f, short *x)
+{
+ *f = *x;
+}
+
+void
+float_to_double (double *f, float *x)
+{
+ *f = *x;
+}
+
+void
+double_to_short (short *f, double *x)
+{
+ *f = *x;
+}
double res6_tmp[1000];
-void test_res6(void)
+void
+test_res6 (void)
{
- int i;
+ int i;
- for(i=0;i<I_RATE;i++){
- i_buf[i] = rint(AMP * test_func((double)i/I_RATE));
- }
+ for (i = 0; i < I_RATE; i++) {
+ i_buf[i] = rint (AMP * test_func ((double) i / I_RATE));
+ }
- conv_double_short_ref(res6_tmp,i_buf,1000);
- for(i=0;i<1000;i++){
- res6_tmp[i] *= 3.0;
- }
- conv_short_double_ppcasm(o_buf,res6_tmp,1000);
+ conv_double_short_ref (res6_tmp, i_buf, 1000);
+ for (i = 0; i < 1000; i++) {
+ res6_tmp[i] *= 3.0;
+ }
+ conv_short_double_ppcasm (o_buf, res6_tmp, 1000);
- for(i=0;i<1000;i++){
- fprintf(out,"%d %d %g %d\n",i,i_buf[i],res6_tmp[i],o_buf[i]);
- }
+ for (i = 0; i < 1000; i++) {
+ fprintf (out, "%d %d %g %d\n", i, i_buf[i], res6_tmp[i], o_buf[i]);
+ }
}
-void test_res7(void)
+void
+test_res7 (void)
{
- resample_t *r;
- int i;
- double sum10k,sum22k;
- double f;
- int n10k,n22k;
- double x;
-
- for(i=0;i<I_RATE;i++){
- i_buf[i] = rint(AMP * test_func((double)i/I_RATE));
- }
-
- r = malloc(sizeof(resample_t));
- memset(r,0,sizeof(resample_t));
-
- r->i_rate = I_RATE;
- r->o_rate = O_RATE;
- /*r->method = RESAMPLE_SINC_SLOW; */
- r->method = RESAMPLE_SINC;
- r->channels = 1;
- /*r->verbose = 1; */
- r->filter_length = 64;
- r->get_buffer = get_buffer;
-
- resample_init(r);
-
- start_timer();
+ resample_t *r;
+ int i;
+ double sum10k, sum22k;
+ double f;
+ int n10k, n22k;
+ double x;
+
+ for (i = 0; i < I_RATE; i++) {
+ i_buf[i] = rint (AMP * test_func ((double) i / I_RATE));
+ }
+
+ r = malloc (sizeof (resample_t));
+ memset (r, 0, sizeof (resample_t));
+
+ r->i_rate = I_RATE;
+ r->o_rate = O_RATE;
+ /*r->method = RESAMPLE_SINC_SLOW; */
+ r->method = RESAMPLE_SINC;
+ r->channels = 1;
+ /*r->verbose = 1; */
+ r->filter_length = 64;
+ r->get_buffer = get_buffer;
+
+ resample_init (r);
+
+ start_timer ();
#define blocked
#ifdef blocked
- for(i=0;i+256<I_RATE;i+=256){
- resample_scale(r,i_buf+i,256*2);
- }
- if(I_RATE-i){
- resample_scale(r,i_buf+i,(I_RATE-i)*2);
- }
+ for (i = 0; i + 256 < I_RATE; i += 256) {
+ resample_scale (r, i_buf + i, 256 * 2);
+ }
+ if (I_RATE - i) {
+ resample_scale (r, i_buf + i, (I_RATE - i) * 2);
+ }
#else
- resample_scale(r,i_buf,I_RATE*2);
+ resample_scale (r, i_buf, I_RATE * 2);
#endif
- end_timer();
-
- for(i=0;i<O_RATE;i++){
- f = AMP*test_func((double)i/O_RATE);
- /*f = rint(AMP*test_func((double)i/O_RATE)); */
- fprintf(out,"%d %d %d %g %g\n",i,
- o_buf[i],0,
- f,o_buf[i]-f);
- }
-
- sum10k=0;
- sum22k=0;
- n10k=0;
- n22k=0;
- for(i=0;i<O_RATE;i++){
- f = AMP*test_func((double)i/O_RATE);
- /*f = rint(AMP*test_func((double)i/O_RATE)); */
- x = o_buf[i]-f;
- if(((0.5*i)/O_RATE*I_RATE)<10000){
- sum10k += x*x;
- n10k++;
- }
- if(((0.5*i)/O_RATE*I_RATE)<22050){
- sum22k += x*x;
- n22k++;
- }
- }
- printf("average error 10k=%g 22k=%g\n",
- sqrt(sum10k/n10k),
- sqrt(sum22k/n22k));
+ end_timer ();
+
+ for (i = 0; i < O_RATE; i++) {
+ f = AMP * test_func ((double) i / O_RATE);
+ /*f = rint(AMP*test_func((double)i/O_RATE)); */
+ fprintf (out, "%d %d %d %g %g\n", i, o_buf[i], 0, f, o_buf[i] - f);
+ }
+
+ sum10k = 0;
+ sum22k = 0;
+ n10k = 0;
+ n22k = 0;
+ for (i = 0; i < O_RATE; i++) {
+ f = AMP * test_func ((double) i / O_RATE);
+ /*f = rint(AMP*test_func((double)i/O_RATE)); */
+ x = o_buf[i] - f;
+ if (((0.5 * i) / O_RATE * I_RATE) < 10000) {
+ sum10k += x * x;
+ n10k++;
+ }
+ if (((0.5 * i) / O_RATE * I_RATE) < 22050) {
+ sum22k += x * x;
+ n22k++;
+ }
+ }
+ printf ("average error 10k=%g 22k=%g\n",
+ sqrt (sum10k / n10k), sqrt (sum22k / n22k));
}
-
#define GST_RIFF_FCCH_MSVC GST_MAKE_FOURCC ('M','S','V','C')
/* INFO types - see http://www.saettler.com/RIFFMCI/riffmci.html */
-#define GST_RIFF_INFO_IARL GST_MAKE_FOURCC ('I','A','R','L') /* location */
-#define GST_RIFF_INFO_IART GST_MAKE_FOURCC ('I','A','R','T') /* artist */
-#define GST_RIFF_INFO_ICMS GST_MAKE_FOURCC ('I','C','M','S') /* commissioned */
-#define GST_RIFF_INFO_ICMT GST_MAKE_FOURCC ('I','C','M','T') /* comment */
-#define GST_RIFF_INFO_ICOP GST_MAKE_FOURCC ('I','C','O','P') /* copyright */
-#define GST_RIFF_INFO_ICRD GST_MAKE_FOURCC ('I','C','R','D') /* creation date */
-#define GST_RIFF_INFO_ICRP GST_MAKE_FOURCC ('I','C','R','P') /* cropped */
-#define GST_RIFF_INFO_IDIM GST_MAKE_FOURCC ('I','D','I','M') /* dimensions */
-#define GST_RIFF_INFO_IDPI GST_MAKE_FOURCC ('I','D','P','I') /* dots-per-inch */
-#define GST_RIFF_INFO_IENG GST_MAKE_FOURCC ('I','E','N','G') /* engineer(s) */
-#define GST_RIFF_INFO_IGNR GST_MAKE_FOURCC ('I','G','N','R') /* genre */
-#define GST_RIFF_INFO_IKEY GST_MAKE_FOURCC ('I','K','E','Y') /* keywords */
-#define GST_RIFF_INFO_ILGT GST_MAKE_FOURCC ('I','L','G','T') /* lightness */
-#define GST_RIFF_INFO_IMED GST_MAKE_FOURCC ('I','M','E','D') /* medium */
-#define GST_RIFF_INFO_INAM GST_MAKE_FOURCC ('I','N','A','M') /* name */
-#define GST_RIFF_INFO_IPLT GST_MAKE_FOURCC ('I','P','L','T') /* palette setting */
-#define GST_RIFF_INFO_IPRD GST_MAKE_FOURCC ('I','P','R','D') /* product */
-#define GST_RIFF_INFO_ISBJ GST_MAKE_FOURCC ('I','S','B','J') /* subject */
-#define GST_RIFF_INFO_ISFT GST_MAKE_FOURCC ('I','S','F','T') /* software */
-#define GST_RIFF_INFO_ISHP GST_MAKE_FOURCC ('I','S','H','P') /* sharpness */
-#define GST_RIFF_INFO_ISRC GST_MAKE_FOURCC ('I','S','R','C') /* source */
-#define GST_RIFF_INFO_ISRF GST_MAKE_FOURCC ('I','S','R','F') /* source form */
-#define GST_RIFF_INFO_ITCH GST_MAKE_FOURCC ('I','T','C','H') /* technician(s) */
+#define GST_RIFF_INFO_IARL GST_MAKE_FOURCC ('I','A','R','L') /* location */
+#define GST_RIFF_INFO_IART GST_MAKE_FOURCC ('I','A','R','T') /* artist */
+#define GST_RIFF_INFO_ICMS GST_MAKE_FOURCC ('I','C','M','S') /* commissioned */
+#define GST_RIFF_INFO_ICMT GST_MAKE_FOURCC ('I','C','M','T') /* comment */
+#define GST_RIFF_INFO_ICOP GST_MAKE_FOURCC ('I','C','O','P') /* copyright */
+#define GST_RIFF_INFO_ICRD GST_MAKE_FOURCC ('I','C','R','D') /* creation date */
+#define GST_RIFF_INFO_ICRP GST_MAKE_FOURCC ('I','C','R','P') /* cropped */
+#define GST_RIFF_INFO_IDIM GST_MAKE_FOURCC ('I','D','I','M') /* dimensions */
+#define GST_RIFF_INFO_IDPI GST_MAKE_FOURCC ('I','D','P','I') /* dots-per-inch */
+#define GST_RIFF_INFO_IENG GST_MAKE_FOURCC ('I','E','N','G') /* engineer(s) */
+#define GST_RIFF_INFO_IGNR GST_MAKE_FOURCC ('I','G','N','R') /* genre */
+#define GST_RIFF_INFO_IKEY GST_MAKE_FOURCC ('I','K','E','Y') /* keywords */
+#define GST_RIFF_INFO_ILGT GST_MAKE_FOURCC ('I','L','G','T') /* lightness */
+#define GST_RIFF_INFO_IMED GST_MAKE_FOURCC ('I','M','E','D') /* medium */
+#define GST_RIFF_INFO_INAM GST_MAKE_FOURCC ('I','N','A','M') /* name */
+#define GST_RIFF_INFO_IPLT GST_MAKE_FOURCC ('I','P','L','T') /* palette setting */
+#define GST_RIFF_INFO_IPRD GST_MAKE_FOURCC ('I','P','R','D') /* product */
+#define GST_RIFF_INFO_ISBJ GST_MAKE_FOURCC ('I','S','B','J') /* subject */
+#define GST_RIFF_INFO_ISFT GST_MAKE_FOURCC ('I','S','F','T') /* software */
+#define GST_RIFF_INFO_ISHP GST_MAKE_FOURCC ('I','S','H','P') /* sharpness */
+#define GST_RIFF_INFO_ISRC GST_MAKE_FOURCC ('I','S','R','C') /* source */
+#define GST_RIFF_INFO_ISRF GST_MAKE_FOURCC ('I','S','R','F') /* source form */
+#define GST_RIFF_INFO_ITCH GST_MAKE_FOURCC ('I','T','C','H') /* technician(s) */
/*********Chunk Names***************/
#define GST_RIFF_FF00 GST_MAKE_FOURCC (0xFF,0xFF,0x00,0x00)
#define GST_RIFF_v422 GST_MAKE_FOURCC ('v', '4', '2', '2')
#define GST_RIFF_V422 GST_MAKE_FOURCC ('V', '4', '2', '2')
#define GST_RIFF_mvi1 GST_MAKE_FOURCC ('m', 'v', 'i', '1')
-#define GST_RIFF_MPIX GST_MAKE_FOURCC (0x04,0x00, 'i', '1') /* MotionPixels munged their id */
+#define GST_RIFF_MPIX GST_MAKE_FOURCC (0x04,0x00, 'i', '1') /* MotionPixels munged their id */
#define GST_RIFF_AURA GST_MAKE_FOURCC ('A', 'U', 'R', 'A')
#define GST_RIFF_DMB1 GST_MAKE_FOURCC ('D', 'M', 'B', '1')
#define GST_RIFF_dmb1 GST_MAKE_FOURCC ('d', 'm', 'b', '1')
#define GST_RIFF_rpza GST_MAKE_FOURCC ('r', 'p', 'z', 'a')
/* And this here's the mistakes that need to be supported */
-#define GST_RIFF_azpr GST_MAKE_FOURCC ('a', 'z', 'p', 'r') /* recognize Apple's rpza mangled? */
+#define GST_RIFF_azpr GST_MAKE_FOURCC ('a', 'z', 'p', 'r') /* recognize Apple's rpza mangled? */
/*********** FND in MJPG **********/
#define GST_RIFF_ISFT GST_MAKE_FOURCC ('I', 'S', 'F', 'T')
#define GST_RIFF_rec GST_MAKE_FOURCC ('r', 'e', 'c', ' ')
/* common data structures */
-typedef struct _gst_riff_strh {
- guint32 type; /* stream type */
- guint32 fcc_handler; /* fcc_handler */
+typedef struct _gst_riff_strh
+{
+ guint32 type; /* stream type */
+ guint32 fcc_handler; /* fcc_handler */
guint32 flags;
/* flags values */
#define GST_RIFF_STRH_DISABLED 0x000000001
#define GST_RIFF_STRH_VIDEOPALCHANGES 0x000010000
guint32 priority;
- guint32 init_frames; /* initial frames (???) */
+ guint32 init_frames; /* initial frames (???) */
guint32 scale;
guint32 rate;
guint32 start;
guint32 length;
- guint32 bufsize; /* suggested buffer size */
+ guint32 bufsize; /* suggested buffer size */
guint32 quality;
guint32 samplesize;
/* XXX 16 bytes ? */
} gst_riff_strh;
-typedef struct _gst_riff_strf_vids { /* == BitMapInfoHeader */
+typedef struct _gst_riff_strf_vids
+{ /* == BitMapInfoHeader */
guint32 size;
guint32 width;
guint32 height;
guint32 image_size;
guint32 xpels_meter;
guint32 ypels_meter;
- guint32 num_colors; /* used colors */
- guint32 imp_colors; /* important colors */
+ guint32 num_colors; /* used colors */
+ guint32 imp_colors; /* important colors */
/* may be more for some codecs */
} gst_riff_strf_vids;
-typedef struct _gst_riff_strf_auds { /* == WaveHeader (?) */
+typedef struct _gst_riff_strf_auds
+{ /* == WaveHeader (?) */
guint16 format;
/**** from public Microsoft RIFF docs ******/
#define GST_RIFF_WAVE_FORMAT_UNKNOWN (0x0000)
guint16 size;
} gst_riff_strf_auds;
-typedef struct _gst_riff_strf_iavs {
+typedef struct _gst_riff_strf_iavs
+{
guint32 DVAAuxSrc;
guint32 DVAAuxCtl;
guint32 DVAAuxSrc1;
guint32 DVReserved2;
} gst_riff_strf_iavs;
-typedef struct _gst_riff_index_entry {
+typedef struct _gst_riff_index_entry
+{
guint32 id;
guint32 flags;
#define GST_RIFF_IF_LIST (0x00000001L)
guint32 size;
} gst_riff_index_entry;
-typedef struct _gst_riff_dmlh {
+typedef struct _gst_riff_dmlh
+{
guint32 totalframes;
} gst_riff_dmlh;
#include "riff-media.h"
GstCaps *
-gst_riff_create_video_caps (guint32 codec_fcc,
- gst_riff_strh *strh,
- gst_riff_strf_vids *strf,
- char **codec_name)
+gst_riff_create_video_caps (guint32 codec_fcc,
+ gst_riff_strh * strh, gst_riff_strf_vids * strf, char **codec_name)
{
GstCaps *caps = NULL;
switch (codec_fcc) {
- case GST_MAKE_FOURCC('I','4','2','0'):
+ case GST_MAKE_FOURCC ('I', '4', '2', '0'):
caps = gst_caps_new_simple ("video/x-raw-yuv",
- "format", GST_TYPE_FOURCC, codec_fcc,
- NULL);
+ "format", GST_TYPE_FOURCC, codec_fcc, NULL);
if (codec_name)
- *codec_name = g_strdup ("Raw, uncompressed I420");
+ *codec_name = g_strdup ("Raw, uncompressed I420");
break;
- case GST_MAKE_FOURCC('Y','U','Y','2'):
+ case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
caps = gst_caps_new_simple ("video/x-raw-yuv",
- "format", GST_TYPE_FOURCC, codec_fcc,
- NULL);
+ "format", GST_TYPE_FOURCC, codec_fcc, NULL);
if (codec_name)
- *codec_name = g_strdup ("Raw, uncompressed YUV 4:2:2");
+ *codec_name = g_strdup ("Raw, uncompressed YUV 4:2:2");
break;
- case GST_MAKE_FOURCC('M','J','P','G'): /* YUY2 MJPEG */
+ case GST_MAKE_FOURCC ('M', 'J', 'P', 'G'): /* YUY2 MJPEG */
caps = gst_caps_new_simple ("video/x-jpeg", NULL);
if (codec_name)
- *codec_name = g_strdup ("Motion JPEG");
+ *codec_name = g_strdup ("Motion JPEG");
break;
- case GST_MAKE_FOURCC('J','P','E','G'): /* generic (mostly RGB) MJPEG */
+ case GST_MAKE_FOURCC ('J', 'P', 'E', 'G'): /* generic (mostly RGB) MJPEG */
caps = gst_caps_new_simple ("video/x-jpeg", NULL);
if (codec_name)
- *codec_name = g_strdup ("JPEG Still Image");
+ *codec_name = g_strdup ("JPEG Still Image");
break;
-
- case GST_MAKE_FOURCC('P','I','X','L'): /* Miro/Pinnacle fourccs */
- case GST_MAKE_FOURCC('V','I','X','L'): /* Miro/Pinnacle fourccs */
+
+ case GST_MAKE_FOURCC ('P', 'I', 'X', 'L'): /* Miro/Pinnacle fourccs */
+ case GST_MAKE_FOURCC ('V', 'I', 'X', 'L'): /* Miro/Pinnacle fourccs */
caps = gst_caps_new_simple ("video/x-jpeg", NULL);
if (codec_name)
- *codec_name = g_strdup ("Miro/Pinnacle Video XL");
+ *codec_name = g_strdup ("Miro/Pinnacle Video XL");
break;
-
- case GST_MAKE_FOURCC('H','F','Y','U'):
- caps = gst_caps_new_simple ( "video/x-huffyuv", NULL);
+
+ case GST_MAKE_FOURCC ('H', 'F', 'Y', 'U'):
+ caps = gst_caps_new_simple ("video/x-huffyuv", NULL);
if (codec_name)
- *codec_name = g_strdup ("Huffman Lossless Codec");
+ *codec_name = g_strdup ("Huffman Lossless Codec");
break;
-
- case GST_MAKE_FOURCC('M','P','E','G'):
- case GST_MAKE_FOURCC('M','P','G','I'):
+
+ case GST_MAKE_FOURCC ('M', 'P', 'E', 'G'):
+ case GST_MAKE_FOURCC ('M', 'P', 'G', 'I'):
caps = gst_caps_new_simple ("video/mpeg",
- "systemstream", G_TYPE_BOOLEAN, FALSE,
- "mpegversion", G_TYPE_BOOLEAN, 1,
- NULL);
+ "systemstream", G_TYPE_BOOLEAN, FALSE,
+ "mpegversion", G_TYPE_BOOLEAN, 1, NULL);
if (codec_name)
- *codec_name = g_strdup ("MPEG video");
+ *codec_name = g_strdup ("MPEG video");
break;
- case GST_MAKE_FOURCC('H','2','6','3'):
+ case GST_MAKE_FOURCC ('H', '2', '6', '3'):
caps = gst_caps_new_simple ("video/x-h263", NULL);
if (codec_name)
- *codec_name = g_strdup ("ITU H.26n");
+ *codec_name = g_strdup ("ITU H.26n");
break;
- case GST_MAKE_FOURCC('i','2','6','3'):
+ case GST_MAKE_FOURCC ('i', '2', '6', '3'):
caps = gst_caps_new_simple ("video/x-h263", NULL);
if (codec_name)
- *codec_name = g_strdup ("ITU H.263");
+ *codec_name = g_strdup ("ITU H.263");
break;
- case GST_MAKE_FOURCC('L','2','6','3'):
+ case GST_MAKE_FOURCC ('L', '2', '6', '3'):
caps = gst_caps_new_simple ("video/x-h263", NULL);
if (codec_name)
- *codec_name = g_strdup ("Lead H.263");
+ *codec_name = g_strdup ("Lead H.263");
break;
- case GST_MAKE_FOURCC('M','2','6','3'):
+ case GST_MAKE_FOURCC ('M', '2', '6', '3'):
caps = gst_caps_new_simple ("video/x-h263", NULL);
if (codec_name)
- *codec_name = g_strdup ("Microsoft H.263");
+ *codec_name = g_strdup ("Microsoft H.263");
break;
- case GST_MAKE_FOURCC('V','D','O','W'):
+ case GST_MAKE_FOURCC ('V', 'D', 'O', 'W'):
caps = gst_caps_new_simple ("video/x-h263", NULL);
if (codec_name)
- *codec_name = g_strdup ("VDOLive");
+ *codec_name = g_strdup ("VDOLive");
break;
- case GST_MAKE_FOURCC('V','I','V','O'):
+ case GST_MAKE_FOURCC ('V', 'I', 'V', 'O'):
caps = gst_caps_new_simple ("video/x-h263", NULL);
if (codec_name)
- *codec_name = g_strdup ("Vivo H.263");
+ *codec_name = g_strdup ("Vivo H.263");
break;
- case GST_MAKE_FOURCC('x','2','6','3'):
+ case GST_MAKE_FOURCC ('x', '2', '6', '3'):
caps = gst_caps_new_simple ("video/x-h263", NULL);
if (codec_name)
- *codec_name = g_strdup ("Xirlink H.263");
+ *codec_name = g_strdup ("Xirlink H.263");
break;
- case GST_MAKE_FOURCC('D','I','V','3'):
+ case GST_MAKE_FOURCC ('D', 'I', 'V', '3'):
caps = gst_caps_new_simple ("video/x-divx",
- "divxversion", G_TYPE_INT, 3,
- NULL);
+ "divxversion", G_TYPE_INT, 3, NULL);
if (codec_name)
- *codec_name = g_strdup ("DivX MPEG-4 Version 3");
+ *codec_name = g_strdup ("DivX MPEG-4 Version 3");
break;
- case GST_MAKE_FOURCC('D','I','V','4'):
+ case GST_MAKE_FOURCC ('D', 'I', 'V', '4'):
caps = gst_caps_new_simple ("video/x-divx",
- "divxversion", G_TYPE_INT, 4,
- NULL);
+ "divxversion", G_TYPE_INT, 4, NULL);
if (codec_name)
- *codec_name = g_strdup ("DivX MPEG-4 Version 4");
+ *codec_name = g_strdup ("DivX MPEG-4 Version 4");
break;
- case GST_MAKE_FOURCC('d','i','v','x'):
- case GST_MAKE_FOURCC('D','I','V','X'):
- case GST_MAKE_FOURCC('D','X','5','0'):
- case GST_MAKE_FOURCC('D','I','V','5'):
+ case GST_MAKE_FOURCC ('d', 'i', 'v', 'x'):
+ case GST_MAKE_FOURCC ('D', 'I', 'V', 'X'):
+ case GST_MAKE_FOURCC ('D', 'X', '5', '0'):
+ case GST_MAKE_FOURCC ('D', 'I', 'V', '5'):
caps = gst_caps_new_simple ("video/x-divx",
- "divxversion", G_TYPE_INT, 5,
- NULL);
+ "divxversion", G_TYPE_INT, 5, NULL);
if (codec_name)
- *codec_name = g_strdup ("DivX MPEG-4 Version 5");
+ *codec_name = g_strdup ("DivX MPEG-4 Version 5");
break;
- case GST_MAKE_FOURCC('X','V','I','D'):
- case GST_MAKE_FOURCC('x','v','i','d'):
+ case GST_MAKE_FOURCC ('X', 'V', 'I', 'D'):
+ case GST_MAKE_FOURCC ('x', 'v', 'i', 'd'):
caps = gst_caps_new_simple ("video/x-xvid", NULL);
if (codec_name)
- *codec_name = g_strdup ("XVID MPEG-4");
+ *codec_name = g_strdup ("XVID MPEG-4");
break;
- case GST_MAKE_FOURCC('M','P','G','4'):
+ case GST_MAKE_FOURCC ('M', 'P', 'G', '4'):
caps = gst_caps_new_simple ("video/x-msmpeg",
- "msmpegversion", G_TYPE_INT, 41,
- NULL);
+ "msmpegversion", G_TYPE_INT, 41, NULL);
if (codec_name)
- *codec_name = g_strdup ("Microsoft MPEG-4 4.1");
+ *codec_name = g_strdup ("Microsoft MPEG-4 4.1");
break;
- case GST_MAKE_FOURCC('M','P','4','2'):
+ case GST_MAKE_FOURCC ('M', 'P', '4', '2'):
caps = gst_caps_new_simple ("video/x-msmpeg",
- "msmpegversion", G_TYPE_INT, 42,
- NULL);
+ "msmpegversion", G_TYPE_INT, 42, NULL);
if (codec_name)
- *codec_name = g_strdup ("Microsoft MPEG-4 4.2");
+ *codec_name = g_strdup ("Microsoft MPEG-4 4.2");
break;
- case GST_MAKE_FOURCC('M','P','4','3'):
+ case GST_MAKE_FOURCC ('M', 'P', '4', '3'):
caps = gst_caps_new_simple ("video/x-msmpeg",
- "msmpegversion", G_TYPE_INT, 43,
- NULL);
+ "msmpegversion", G_TYPE_INT, 43, NULL);
if (codec_name)
- *codec_name = g_strdup ("Microsoft MPEG-4 4.3");
+ *codec_name = g_strdup ("Microsoft MPEG-4 4.3");
break;
- case GST_MAKE_FOURCC('3','I','V','1'):
- case GST_MAKE_FOURCC('3','I','V','2'):
- caps = gst_caps_new_simple ( "video/x-3ivx", NULL);
+ case GST_MAKE_FOURCC ('3', 'I', 'V', '1'):
+ case GST_MAKE_FOURCC ('3', 'I', 'V', '2'):
+ caps = gst_caps_new_simple ("video/x-3ivx", NULL);
if (codec_name)
- *codec_name = g_strdup ("3ivx");
+ *codec_name = g_strdup ("3ivx");
break;
- case GST_MAKE_FOURCC('D','V','S','D'):
- case GST_MAKE_FOURCC('d','v','s','d'):
+ case GST_MAKE_FOURCC ('D', 'V', 'S', 'D'):
+ case GST_MAKE_FOURCC ('d', 'v', 's', 'd'):
caps = gst_caps_new_simple ("video/x-dv",
- "systemstream", G_TYPE_BOOLEAN, FALSE,
- NULL);
+ "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
if (codec_name)
- *codec_name = g_strdup ("Generic DV");
+ *codec_name = g_strdup ("Generic DV");
break;
- case GST_MAKE_FOURCC('W','M','V','1'):
+ case GST_MAKE_FOURCC ('W', 'M', 'V', '1'):
caps = gst_caps_new_simple ("video/x-wmv",
- "wmvversion", G_TYPE_INT, 1,
- NULL);
+ "wmvversion", G_TYPE_INT, 1, NULL);
if (codec_name)
- *codec_name = g_strdup ("Windows Media Video 7");
+ *codec_name = g_strdup ("Windows Media Video 7");
break;
- case GST_MAKE_FOURCC('W','M','V','2'):
+ case GST_MAKE_FOURCC ('W', 'M', 'V', '2'):
caps = gst_caps_new_simple ("video/x-wmv",
- "wmvversion", G_TYPE_INT, 2,
- NULL);
+ "wmvversion", G_TYPE_INT, 2, NULL);
if (codec_name)
- *codec_name = g_strdup ("Windows Media Video 8");
+ *codec_name = g_strdup ("Windows Media Video 8");
break;
-
- case GST_MAKE_FOURCC('W','M','V','3'):
+
+ case GST_MAKE_FOURCC ('W', 'M', 'V', '3'):
caps = gst_caps_new_simple ("video/x-wmv",
- "wmvversion", G_TYPE_INT, 3,
- NULL);
+ "wmvversion", G_TYPE_INT, 3, NULL);
if (codec_name)
- *codec_name = g_strdup ("Windows Media Video 9");
+ *codec_name = g_strdup ("Windows Media Video 9");
break;
default:
GST_WARNING ("Unkown video fourcc " GST_FOURCC_FORMAT,
- GST_FOURCC_ARGS (codec_fcc));
+ GST_FOURCC_ARGS (codec_fcc));
return NULL;
}
gst_caps_set_simple (caps, "framerate", G_TYPE_DOUBLE, fps, NULL);
} else {
gst_caps_set_simple (caps,
- "framerate", GST_TYPE_DOUBLE_RANGE, 0., G_MAXDOUBLE,
- NULL);
+ "framerate", GST_TYPE_DOUBLE_RANGE, 0., G_MAXDOUBLE, NULL);
}
if (strf != NULL) {
gst_caps_set_simple (caps,
- "width", G_TYPE_INT, strf->width,
- "height", G_TYPE_INT, strf->height,
- NULL);
+ "width", G_TYPE_INT, strf->width,
+ "height", G_TYPE_INT, strf->height, NULL);
} else {
gst_caps_set_simple (caps,
- "width", GST_TYPE_INT_RANGE, 16, 4096,
- "height", GST_TYPE_INT_RANGE, 16, 4096,
- NULL);
+ "width", GST_TYPE_INT_RANGE, 16, 4096,
+ "height", GST_TYPE_INT_RANGE, 16, 4096, NULL);
}
return caps;
}
GstCaps *
-gst_riff_create_audio_caps (guint16 codec_id,
- gst_riff_strh *strh,
- gst_riff_strf_auds *strf,
- char **codec_name)
+gst_riff_create_audio_caps (guint16 codec_id,
+ gst_riff_strh * strh, gst_riff_strf_auds * strf, char **codec_name)
{
GstCaps *caps = NULL;
switch (codec_id) {
- case GST_RIFF_WAVE_FORMAT_MPEGL3: /* mp3 */
+ case GST_RIFF_WAVE_FORMAT_MPEGL3: /* mp3 */
caps = gst_caps_new_simple ("audio/mpeg",
- "mpegversion", G_TYPE_INT, 1,
- "layer", G_TYPE_INT, 3,
- NULL);
+ "mpegversion", G_TYPE_INT, 1, "layer", G_TYPE_INT, 3, NULL);
if (codec_name)
- *codec_name = g_strdup ("MPEG 1 layer 3");
+ *codec_name = g_strdup ("MPEG 1 layer 3");
break;
- case GST_RIFF_WAVE_FORMAT_MPEGL12: /* mp1 or mp2 */
+ case GST_RIFF_WAVE_FORMAT_MPEGL12: /* mp1 or mp2 */
caps = gst_caps_new_simple ("audio/mpeg",
- "mpegversion", G_TYPE_INT, 1,
- "layer", G_TYPE_INT, 2,
- NULL);
+ "mpegversion", G_TYPE_INT, 1, "layer", G_TYPE_INT, 2, NULL);
if (codec_name)
- *codec_name = g_strdup ("MPEG 1 layer 2");
+ *codec_name = g_strdup ("MPEG 1 layer 2");
break;
- case GST_RIFF_WAVE_FORMAT_PCM: /* PCM/wav */
+ case GST_RIFF_WAVE_FORMAT_PCM: /* PCM/wav */
if (strf != NULL) {
- gint ba = GUINT16_FROM_LE (strf->blockalign);
- gint ch = GUINT16_FROM_LE (strf->channels);
- gint ws = GUINT16_FROM_LE (strf->size);
-
- caps = gst_caps_new_simple ("audio/x-raw-int",
- "endianness", G_TYPE_INT, G_LITTLE_ENDIAN,
- "width", G_TYPE_INT, (int)(ba * 8 / ch),
- "depth", G_TYPE_INT, ws,
- "signed", G_TYPE_BOOLEAN, ws != 8,
- NULL);
+ gint ba = GUINT16_FROM_LE (strf->blockalign);
+ gint ch = GUINT16_FROM_LE (strf->channels);
+ gint ws = GUINT16_FROM_LE (strf->size);
+
+ caps = gst_caps_new_simple ("audio/x-raw-int",
+ "endianness", G_TYPE_INT, G_LITTLE_ENDIAN,
+ "width", G_TYPE_INT, (int) (ba * 8 / ch),
+ "depth", G_TYPE_INT, ws, "signed", G_TYPE_BOOLEAN, ws != 8, NULL);
} else {
- caps = gst_caps_from_string ("audio/x-raw-int, "
- "endianness = (int) LITTLE_ENDIAN, "
- "signed = (boolean) { true, false }, "
- "width = (int) { 8, 16 }, "
- "height = (int) { 8, 16 }");
+ caps = gst_caps_from_string ("audio/x-raw-int, "
+ "endianness = (int) LITTLE_ENDIAN, "
+ "signed = (boolean) { true, false }, "
+ "width = (int) { 8, 16 }, " "height = (int) { 8, 16 }");
}
if (codec_name)
- *codec_name = g_strdup ("PCM WAV");
+ *codec_name = g_strdup ("PCM WAV");
break;
case GST_RIFF_WAVE_FORMAT_MULAW:
if (strf != NULL && strf->size != 8) {
- GST_WARNING ("invalid depth (%d) of mulaw audio, overwriting.",
- strf->size);
+ GST_WARNING ("invalid depth (%d) of mulaw audio, overwriting.",
+ strf->size);
}
caps = gst_caps_new_simple ("audio/x-mulaw", NULL);
if (codec_name)
- *codec_name = g_strdup ("Mulaw");
+ *codec_name = g_strdup ("Mulaw");
break;
case GST_RIFF_WAVE_FORMAT_ALAW:
if (strf != NULL && strf->size != 8) {
- GST_WARNING ("invalid depth (%d) of alaw audio, overwriting.",
- strf->size);
+ GST_WARNING ("invalid depth (%d) of alaw audio, overwriting.",
+ strf->size);
}
caps = gst_caps_new_simple ("audio/x-alaw", NULL);
if (codec_name)
- *codec_name = g_strdup ("Alaw");
+ *codec_name = g_strdup ("Alaw");
break;
- case GST_RIFF_WAVE_FORMAT_VORBIS1: /* ogg/vorbis mode 1 */
- case GST_RIFF_WAVE_FORMAT_VORBIS2: /* ogg/vorbis mode 2 */
- case GST_RIFF_WAVE_FORMAT_VORBIS3: /* ogg/vorbis mode 3 */
- case GST_RIFF_WAVE_FORMAT_VORBIS1PLUS: /* ogg/vorbis mode 1+ */
- case GST_RIFF_WAVE_FORMAT_VORBIS2PLUS: /* ogg/vorbis mode 2+ */
- case GST_RIFF_WAVE_FORMAT_VORBIS3PLUS: /* ogg/vorbis mode 3+ */
+ case GST_RIFF_WAVE_FORMAT_VORBIS1: /* ogg/vorbis mode 1 */
+ case GST_RIFF_WAVE_FORMAT_VORBIS2: /* ogg/vorbis mode 2 */
+ case GST_RIFF_WAVE_FORMAT_VORBIS3: /* ogg/vorbis mode 3 */
+ case GST_RIFF_WAVE_FORMAT_VORBIS1PLUS: /* ogg/vorbis mode 1+ */
+ case GST_RIFF_WAVE_FORMAT_VORBIS2PLUS: /* ogg/vorbis mode 2+ */
+ case GST_RIFF_WAVE_FORMAT_VORBIS3PLUS: /* ogg/vorbis mode 3+ */
caps = gst_caps_new_simple ("audio/x-vorbis", NULL);
if (codec_name)
- *codec_name = g_strdup ("Vorbis");
+ *codec_name = g_strdup ("Vorbis");
break;
case GST_RIFF_WAVE_FORMAT_A52:
caps = gst_caps_new_simple ("audio/x-ac3", NULL);
if (codec_name)
- *codec_name = g_strdup ("AC3");
+ *codec_name = g_strdup ("AC3");
break;
default:
- GST_WARNING ("Unkown audio tag 0x%04x",
- codec_id);
+ GST_WARNING ("Unkown audio tag 0x%04x", codec_id);
break;
}
if (strf != NULL) {
gst_caps_set_simple (caps,
- "rate", G_TYPE_INT, strf->rate,
- "channels", G_TYPE_INT, strf->channels,
- NULL);
+ "rate", G_TYPE_INT, strf->rate,
+ "channels", G_TYPE_INT, strf->channels, NULL);
} else {
gst_caps_set_simple (caps,
- "rate", GST_TYPE_INT_RANGE, 8000, 96000,
- "channels", GST_TYPE_INT_RANGE, 1, 2,
- NULL);
+ "rate", GST_TYPE_INT_RANGE, 8000, 96000,
+ "channels", GST_TYPE_INT_RANGE, 1, 2, NULL);
}
return caps;
}
GstCaps *
-gst_riff_create_iavs_caps (guint32 codec_fcc,
- gst_riff_strh *strh,
- gst_riff_strf_iavs *strf,
- char **codec_name)
+gst_riff_create_iavs_caps (guint32 codec_fcc,
+ gst_riff_strh * strh, gst_riff_strf_iavs * strf, char **codec_name)
{
GstCaps *caps = NULL;
switch (codec_fcc) {
- /* is this correct? */
- case GST_MAKE_FOURCC ('D','V','S','D'):
- case GST_MAKE_FOURCC ('d','v','s','d'):
- caps = gst_caps_new_simple ("video/x-dv",
- "systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
+ /* is this correct? */
+ case GST_MAKE_FOURCC ('D', 'V', 'S', 'D'):
+ case GST_MAKE_FOURCC ('d', 'v', 's', 'd'):
+ caps = gst_caps_new_simple ("video/x-dv",
+ "systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
if (codec_name)
- *codec_name = g_strdup ("Generic DV");
+ *codec_name = g_strdup ("Generic DV");
default:
GST_WARNING ("Unkown IAVS fourcc " GST_FOURCC_FORMAT,
- GST_FOURCC_ARGS (codec_fcc));
+ GST_FOURCC_ARGS (codec_fcc));
return NULL;
}
gst_riff_create_video_template_caps (void)
{
guint32 tags[] = {
- GST_MAKE_FOURCC ('I','4','2','0'),
- GST_MAKE_FOURCC ('Y','U','Y','2'),
- GST_MAKE_FOURCC ('M','J','P','G'),
- GST_MAKE_FOURCC ('D','V','S','D'),
- GST_MAKE_FOURCC ('W','M','V','1'),
- GST_MAKE_FOURCC ('W','M','V','2'),
- GST_MAKE_FOURCC ('M','P','G','4'),
- GST_MAKE_FOURCC ('M','P','4','2'),
- GST_MAKE_FOURCC ('M','P','4','3'),
- GST_MAKE_FOURCC ('H','F','Y','U'),
- GST_MAKE_FOURCC ('D','I','V','3'),
- GST_MAKE_FOURCC ('M','P','E','G'),
- GST_MAKE_FOURCC ('H','2','6','3'),
- GST_MAKE_FOURCC ('D','I','V','X'),
- GST_MAKE_FOURCC ('X','V','I','D'),
- GST_MAKE_FOURCC ('3','I','V','1'),
+ GST_MAKE_FOURCC ('I', '4', '2', '0'),
+ GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'),
+ GST_MAKE_FOURCC ('M', 'J', 'P', 'G'),
+ GST_MAKE_FOURCC ('D', 'V', 'S', 'D'),
+ GST_MAKE_FOURCC ('W', 'M', 'V', '1'),
+ GST_MAKE_FOURCC ('W', 'M', 'V', '2'),
+ GST_MAKE_FOURCC ('M', 'P', 'G', '4'),
+ GST_MAKE_FOURCC ('M', 'P', '4', '2'),
+ GST_MAKE_FOURCC ('M', 'P', '4', '3'),
+ GST_MAKE_FOURCC ('H', 'F', 'Y', 'U'),
+ GST_MAKE_FOURCC ('D', 'I', 'V', '3'),
+ GST_MAKE_FOURCC ('M', 'P', 'E', 'G'),
+ GST_MAKE_FOURCC ('H', '2', '6', '3'),
+ GST_MAKE_FOURCC ('D', 'I', 'V', 'X'),
+ GST_MAKE_FOURCC ('X', 'V', 'I', 'D'),
+ GST_MAKE_FOURCC ('3', 'I', 'V', '1'),
/* FILL ME */
0
};
gst_riff_create_iavs_template_caps (void)
{
guint32 tags[] = {
- GST_MAKE_FOURCC ('D','V','S','D'),
+ GST_MAKE_FOURCC ('D', 'V', 'S', 'D'),
/* FILL ME */
0
};
#include "riff-ids.h"
G_BEGIN_DECLS
-
/*
* Create one caps. strh/strf can be NULL (for non-fixed caps).
*/
-
-GstCaps *gst_riff_create_video_caps (guint32 codec_fcc,
- gst_riff_strh *strh,
- gst_riff_strf_vids *strf,
- char **codec_name);
-GstCaps *gst_riff_create_audio_caps (guint16 codec_id,
- gst_riff_strh *strh,
- gst_riff_strf_auds *strf,
- char **codec_name);
-GstCaps *gst_riff_create_iavs_caps (guint32 codec_fcc,
- gst_riff_strh *strh,
- gst_riff_strf_iavs *strf,
- char **codec_name);
+ GstCaps * gst_riff_create_video_caps (guint32 codec_fcc,
+ gst_riff_strh * strh, gst_riff_strf_vids * strf, char **codec_name);
+GstCaps *gst_riff_create_audio_caps (guint16 codec_id,
+ gst_riff_strh * strh, gst_riff_strf_auds * strf, char **codec_name);
+GstCaps *gst_riff_create_iavs_caps (guint32 codec_fcc,
+ gst_riff_strh * strh, gst_riff_strf_iavs * strf, char **codec_name);
/*
* Create template caps (includes all known types).
GstCaps *gst_riff_create_video_template_caps (void);
GstCaps *gst_riff_create_audio_template_caps (void);
-GstCaps *gst_riff_create_iavs_template_caps (void);
+GstCaps *gst_riff_create_iavs_template_caps (void);
G_END_DECLS
-
#endif /* __GST_RIFF_READ_H__ */
#include "riff-ids.h"
#include "riff-read.h"
-enum {
+enum
+{
ARG_0,
ARG_METADATA
- /* FILL ME */
+ /* FILL ME */
};
-static void gst_riff_read_class_init (GstRiffReadClass *klass);
-static void gst_riff_read_init (GstRiffRead *riff);
+static void gst_riff_read_class_init (GstRiffReadClass * klass);
+static void gst_riff_read_init (GstRiffRead * riff);
-static GstElementStateReturn
- gst_riff_read_change_state (GstElement *element);
+static GstElementStateReturn gst_riff_read_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
GType
-gst_riff_read_get_type (void)
+gst_riff_read_get_type (void)
{
static GType gst_riff_read_type = 0;
if (!gst_riff_read_type) {
static const GTypeInfo gst_riff_read_info = {
- sizeof (GstRiffReadClass),
+ sizeof (GstRiffReadClass),
NULL,
NULL,
(GClassInitFunc) gst_riff_read_class_init,
gst_riff_read_type =
g_type_register_static (GST_TYPE_ELEMENT, "GstRiffRead",
- &gst_riff_read_info, 0);
+ &gst_riff_read_info, 0);
}
return gst_riff_read_type;
}
static void
-gst_riff_read_class_init (GstRiffReadClass *klass)
+gst_riff_read_class_init (GstRiffReadClass * klass)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
-
+
gstelement_class->change_state = gst_riff_read_change_state;
}
static void
-gst_riff_read_init (GstRiffRead *riff)
+gst_riff_read_init (GstRiffRead * riff)
{
riff->sinkpad = NULL;
riff->bs = NULL;
}
static GstElementStateReturn
-gst_riff_read_change_state (GstElement *element)
+gst_riff_read_change_state (GstElement * element)
{
GstRiffRead *riff = GST_RIFF_READ (element);
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_READY_TO_PAUSED:
if (!riff->sinkpad)
- return GST_STATE_FAILURE;
+ return GST_STATE_FAILURE;
riff->bs = gst_bytestream_new (riff->sinkpad);
break;
case GST_STATE_PAUSED_TO_READY:
gst_bytestream_destroy (riff->bs);
while (riff->level) {
- GstRiffLevel *level = riff->level->data;
+ GstRiffLevel *level = riff->level->data;
- riff->level = g_list_remove (riff->level, level);
- g_free (level);
+ riff->level = g_list_remove (riff->level, level);
+ g_free (level);
}
break;
default:
*/
static guint
-gst_riff_read_element_level_up (GstRiffRead *riff)
+gst_riff_read_element_level_up (GstRiffRead * riff)
{
guint num = 0;
guint64 pos = gst_bytestream_tell (riff->bs);
*/
static gboolean
-gst_riff_peek_head (GstRiffRead *riff,
- guint32 *tag,
- guint32 *length,
- guint *level_up)
+gst_riff_peek_head (GstRiffRead * riff,
+ guint32 * tag, guint32 * length, guint * level_up)
{
guint8 *data;
if (GST_IS_EVENT (event)) {
gst_pad_event_default (riff->sinkpad, event);
if (GST_EVENT_TYPE (event) == GST_EVENT_EOS)
- return FALSE;
+ return FALSE;
} else {
GST_ELEMENT_ERROR (riff, RESOURCE, READ, (NULL), (NULL));
return FALSE;
*/
static GstBuffer *
-gst_riff_read_element_data (GstRiffRead *riff,
- guint length)
+gst_riff_read_element_data (GstRiffRead * riff, guint length)
{
GstBuffer *buf = NULL;
*/
GstEvent *
-gst_riff_read_seek (GstRiffRead *riff,
- guint64 offset)
+gst_riff_read_seek (GstRiffRead * riff, guint64 offset)
{
guint64 length = gst_bytestream_length (riff->bs);
guint32 remaining;
} else if (GST_EVENT_TYPE (event) != GST_EVENT_DISCONTINUOUS) {
gst_pad_event_default (riff->sinkpad, event);
if (GST_EVENT_TYPE (event) == GST_EVENT_EOS)
- return NULL;
+ return NULL;
event = NULL;
}
}
*/
guint32
-gst_riff_peek_tag (GstRiffRead *riff,
- guint *level_up)
+gst_riff_peek_tag (GstRiffRead * riff, guint * level_up)
{
guint32 tag;
*/
guint32
-gst_riff_peek_list (GstRiffRead *riff)
+gst_riff_peek_list (GstRiffRead * riff)
{
guint32 lst;
guint8 *data;
*/
gboolean
-gst_riff_read_skip (GstRiffRead *riff)
+gst_riff_read_skip (GstRiffRead * riff)
{
guint32 tag, length;
GstEvent *event;
/* no */
if (!(event = gst_riff_read_seek (riff,
- gst_bytestream_tell (riff->bs) + length)))
+ gst_bytestream_tell (riff->bs) + length)))
return FALSE;
gst_event_unref (event);
*/
gboolean
-gst_riff_read_data (GstRiffRead *riff,
- guint32 *tag,
- GstBuffer **buf)
+gst_riff_read_data (GstRiffRead * riff, guint32 * tag, GstBuffer ** buf)
{
guint32 length;
*/
gboolean
-gst_riff_read_ascii (GstRiffRead *riff,
- guint32 *tag,
- gchar **str)
+gst_riff_read_ascii (GstRiffRead * riff, guint32 * tag, gchar ** str)
{
GstBuffer *buf;
*/
gboolean
-gst_riff_read_strh (GstRiffRead *riff,
- gst_riff_strh **header)
+gst_riff_read_strh (GstRiffRead * riff, gst_riff_strh ** header)
{
guint32 tag;
GstBuffer *buf;
}
if (GST_BUFFER_SIZE (buf) < sizeof (gst_riff_strh)) {
g_warning ("Too small strh (%d available, %d needed)",
- GST_BUFFER_SIZE (buf), (int) sizeof (gst_riff_strh));
+ GST_BUFFER_SIZE (buf), (int) sizeof (gst_riff_strh));
gst_buffer_unref (buf);
return FALSE;
}
- strh = g_memdup (GST_BUFFER_DATA (buf),
- GST_BUFFER_SIZE (buf));
+ strh = g_memdup (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
gst_buffer_unref (buf);
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
- strh->type = GUINT32_FROM_LE (strh->type);
+ strh->type = GUINT32_FROM_LE (strh->type);
strh->fcc_handler = GUINT32_FROM_LE (strh->fcc_handler);
- strh->flags = GUINT32_FROM_LE (strh->flags);
- strh->priority = GUINT32_FROM_LE (strh->priority);
+ strh->flags = GUINT32_FROM_LE (strh->flags);
+ strh->priority = GUINT32_FROM_LE (strh->priority);
strh->init_frames = GUINT32_FROM_LE (strh->init_frames);
- strh->scale = GUINT32_FROM_LE (strh->scale);
- strh->rate = GUINT32_FROM_LE (strh->rate);
- strh->start = GUINT32_FROM_LE (strh->start);
- strh->length = GUINT32_FROM_LE (strh->length);
- strh->bufsize = GUINT32_FROM_LE (strh->bufsize);
- strh->quality = GUINT32_FROM_LE (strh->quality);
- strh->samplesize = GUINT32_FROM_LE (strh->samplesize);
+ strh->scale = GUINT32_FROM_LE (strh->scale);
+ strh->rate = GUINT32_FROM_LE (strh->rate);
+ strh->start = GUINT32_FROM_LE (strh->start);
+ strh->length = GUINT32_FROM_LE (strh->length);
+ strh->bufsize = GUINT32_FROM_LE (strh->bufsize);
+ strh->quality = GUINT32_FROM_LE (strh->quality);
+ strh->samplesize = GUINT32_FROM_LE (strh->samplesize);
#endif
/* avoid divisions by zero */
/* debug */
GST_INFO ("strh tag found");
- GST_INFO (" type " GST_FOURCC_FORMAT,
- GST_FOURCC_ARGS (strh->type));
+ GST_INFO (" type " GST_FOURCC_FORMAT, GST_FOURCC_ARGS (strh->type));
GST_INFO (" fcc_handler " GST_FOURCC_FORMAT,
- GST_FOURCC_ARGS (strh->fcc_handler));
+ GST_FOURCC_ARGS (strh->fcc_handler));
GST_INFO (" flags 0x%08x", strh->flags);
- GST_INFO (" priority %d", strh->priority);
- GST_INFO (" init_frames %d", strh->init_frames);
- GST_INFO (" scale %d", strh->scale);
- GST_INFO (" rate %d", strh->rate);
- GST_INFO (" start %d", strh->start);
- GST_INFO (" length %d", strh->length);
- GST_INFO (" bufsize %d", strh->bufsize);
- GST_INFO (" quality %d", strh->quality);
- GST_INFO (" samplesize %d", strh->samplesize);
+ GST_INFO (" priority %d", strh->priority);
+ GST_INFO (" init_frames %d", strh->init_frames);
+ GST_INFO (" scale %d", strh->scale);
+ GST_INFO (" rate %d", strh->rate);
+ GST_INFO (" start %d", strh->start);
+ GST_INFO (" length %d", strh->length);
+ GST_INFO (" bufsize %d", strh->bufsize);
+ GST_INFO (" quality %d", strh->quality);
+ GST_INFO (" samplesize %d", strh->samplesize);
*header = strh;
}
gboolean
-gst_riff_read_strf_vids (GstRiffRead *riff,
- gst_riff_strf_vids **header)
+gst_riff_read_strf_vids (GstRiffRead * riff, gst_riff_strf_vids ** header)
{
guint32 tag;
GstBuffer *buf;
}
if (GST_BUFFER_SIZE (buf) < sizeof (gst_riff_strf_vids)) {
g_warning ("Too small strf_vids (%d available, %d needed)",
- GST_BUFFER_SIZE (buf), (int) sizeof (gst_riff_strf_vids));
+ GST_BUFFER_SIZE (buf), (int) sizeof (gst_riff_strf_vids));
gst_buffer_unref (buf);
return FALSE;
}
- strf = g_memdup (GST_BUFFER_DATA (buf),
- GST_BUFFER_SIZE (buf));
+ strf = g_memdup (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
- strf->size = GUINT32_FROM_LE (strf->size);
- strf->width = GUINT32_FROM_LE (strf->width);
- strf->height = GUINT32_FROM_LE (strf->height);
- strf->planes = GUINT16_FROM_LE (strf->planes);
- strf->bit_cnt = GUINT16_FROM_LE (strf->bit_cnt);
+ strf->size = GUINT32_FROM_LE (strf->size);
+ strf->width = GUINT32_FROM_LE (strf->width);
+ strf->height = GUINT32_FROM_LE (strf->height);
+ strf->planes = GUINT16_FROM_LE (strf->planes);
+ strf->bit_cnt = GUINT16_FROM_LE (strf->bit_cnt);
strf->compression = GUINT32_FROM_LE (strf->compression);
- strf->image_size = GUINT32_FROM_LE (strf->image_size);
+ strf->image_size = GUINT32_FROM_LE (strf->image_size);
strf->xpels_meter = GUINT32_FROM_LE (strf->xpels_meter);
strf->ypels_meter = GUINT32_FROM_LE (strf->ypels_meter);
- strf->num_colors = GUINT32_FROM_LE (strf->num_colors);
- strf->imp_colors = GUINT32_FROM_LE (strf->imp_colors);
+ strf->num_colors = GUINT32_FROM_LE (strf->num_colors);
+ strf->imp_colors = GUINT32_FROM_LE (strf->imp_colors);
#endif
/* size checking */
if (strf->size > GST_BUFFER_SIZE (buf)) {
g_warning ("strf_vids header gave %d bytes data, only %d available",
- strf->size, GST_BUFFER_SIZE (buf));
+ strf->size, GST_BUFFER_SIZE (buf));
strf->size = GST_BUFFER_SIZE (buf);
}
GST_INFO (" planes %d", strf->planes);
GST_INFO (" bit_cnt %d", strf->bit_cnt);
GST_INFO (" compression " GST_FOURCC_FORMAT,
- GST_FOURCC_ARGS (strf->compression));
+ GST_FOURCC_ARGS (strf->compression));
GST_INFO (" image_size %d", strf->image_size);
GST_INFO (" xpels_meter %d", strf->xpels_meter);
GST_INFO (" ypels_meter %d", strf->ypels_meter);
}
gboolean
-gst_riff_read_strf_auds (GstRiffRead *riff,
- gst_riff_strf_auds **header)
+gst_riff_read_strf_auds (GstRiffRead * riff, gst_riff_strf_auds ** header)
{
guint32 tag;
GstBuffer *buf;
}
if (GST_BUFFER_SIZE (buf) < sizeof (gst_riff_strf_auds)) {
g_warning ("Too small strf_auds (%d available, %d needed)",
- GST_BUFFER_SIZE (buf), (int) sizeof (gst_riff_strf_auds));
+ GST_BUFFER_SIZE (buf), (int) sizeof (gst_riff_strf_auds));
gst_buffer_unref (buf);
return FALSE;
}
- strf = g_memdup (GST_BUFFER_DATA (buf),
- GST_BUFFER_SIZE (buf));
+ strf = g_memdup (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
- strf->format = GUINT16_FROM_LE (strf->format);
- strf->channels = GUINT16_FROM_LE (strf->channels);
- strf->rate = GUINT32_FROM_LE (strf->rate);
- strf->av_bps = GUINT32_FROM_LE (strf->av_bps);
+ strf->format = GUINT16_FROM_LE (strf->format);
+ strf->channels = GUINT16_FROM_LE (strf->channels);
+ strf->rate = GUINT32_FROM_LE (strf->rate);
+ strf->av_bps = GUINT32_FROM_LE (strf->av_bps);
strf->blockalign = GUINT16_FROM_LE (strf->blockalign);
- strf->size = GUINT16_FROM_LE (strf->size);
+ strf->size = GUINT16_FROM_LE (strf->size);
#endif
/* debug */
GST_INFO (" rate %d", strf->rate);
GST_INFO (" av_bps %d", strf->av_bps);
GST_INFO (" blockalign %d", strf->blockalign);
- GST_INFO (" size %d", strf->size); /* wordsize, not extrasize! */
+ GST_INFO (" size %d", strf->size); /* wordsize, not extrasize! */
gst_buffer_unref (buf);
}
gboolean
-gst_riff_read_strf_iavs (GstRiffRead *riff,
- gst_riff_strf_iavs **header)
+gst_riff_read_strf_iavs (GstRiffRead * riff, gst_riff_strf_iavs ** header)
{
guint32 tag;
GstBuffer *buf;
}
if (GST_BUFFER_SIZE (buf) < sizeof (gst_riff_strf_iavs)) {
g_warning ("Too small strf_iavs (%d available, %d needed)",
- GST_BUFFER_SIZE (buf), (int) sizeof (gst_riff_strf_iavs));
+ GST_BUFFER_SIZE (buf), (int) sizeof (gst_riff_strf_iavs));
gst_buffer_unref (buf);
return FALSE;
}
- strf = g_memdup (GST_BUFFER_DATA (buf),
- GST_BUFFER_SIZE (buf));
+ strf = g_memdup (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
gst_buffer_unref (buf);
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
- strf->DVAAuxSrc = GUINT32_FROM_LE (strf->DVAAuxSrc);
- strf->DVAAuxCtl = GUINT32_FROM_LE (strf->DVAAuxCtl);
- strf->DVAAuxSrc1 = GUINT32_FROM_LE (strf->DVAAuxSrc1);
- strf->DVAAuxCtl1 = GUINT32_FROM_LE (strf->DVAAuxCtl1);
- strf->DVVAuxSrc = GUINT32_FROM_LE (strf->DVVAuxSrc);
- strf->DVVAuxCtl = GUINT32_FROM_LE (strf->DVVAuxCtl);
+ strf->DVAAuxSrc = GUINT32_FROM_LE (strf->DVAAuxSrc);
+ strf->DVAAuxCtl = GUINT32_FROM_LE (strf->DVAAuxCtl);
+ strf->DVAAuxSrc1 = GUINT32_FROM_LE (strf->DVAAuxSrc1);
+ strf->DVAAuxCtl1 = GUINT32_FROM_LE (strf->DVAAuxCtl1);
+ strf->DVVAuxSrc = GUINT32_FROM_LE (strf->DVVAuxSrc);
+ strf->DVVAuxCtl = GUINT32_FROM_LE (strf->DVVAuxCtl);
strf->DVReserved1 = GUINT32_FROM_LE (strf->DVReserved1);
strf->DVReserved2 = GUINT32_FROM_LE (strf->DVReserved2);
#endif
*/
gboolean
-gst_riff_read_list (GstRiffRead *riff,
- guint32 *tag)
+gst_riff_read_list (GstRiffRead * riff, guint32 * tag)
{
guint32 length, lst;
GstRiffLevel *level;
return FALSE;
}
gst_bytestream_flush_fast (riff->bs, 4);
- *tag = GUINT32_FROM_LE (* (guint32 *) data);
+ *tag = GUINT32_FROM_LE (*(guint32 *) data);
/* remember level */
level = g_new (GstRiffLevel, 1);
*/
gboolean
-gst_riff_read_info (GstRiffRead *riff)
+gst_riff_read_info (GstRiffRead * riff)
{
guint32 tag;
guint64 end;
/* find out the type of metadata */
switch (tag) {
case GST_RIFF_INFO_IARL:
- type = GST_TAG_LOCATION;
- break;
+ type = GST_TAG_LOCATION;
+ break;
case GST_RIFF_INFO_IART:
- type = GST_TAG_ARTIST;
- break;
+ type = GST_TAG_ARTIST;
+ break;
case GST_RIFF_INFO_ICMS:
- type = NULL; /*"Commissioner";*/
- break;
+ type = NULL; /*"Commissioner"; */
+ break;
case GST_RIFF_INFO_ICMT:
- type = GST_TAG_COMMENT;
- break;
+ type = GST_TAG_COMMENT;
+ break;
case GST_RIFF_INFO_ICOP:
- type = GST_TAG_COPYRIGHT;
- break;
+ type = GST_TAG_COPYRIGHT;
+ break;
case GST_RIFF_INFO_ICRD:
- type = GST_TAG_DATE;
- break;
+ type = GST_TAG_DATE;
+ break;
case GST_RIFF_INFO_ICRP:
- type = NULL; /*"Cropped";*/
- break;
+ type = NULL; /*"Cropped"; */
+ break;
case GST_RIFF_INFO_IDIM:
- type = NULL; /*"Dimensions";*/
- break;
+ type = NULL; /*"Dimensions"; */
+ break;
case GST_RIFF_INFO_IDPI:
- type = NULL; /*"Dots per Inch";*/
- break;
+ type = NULL; /*"Dots per Inch"; */
+ break;
case GST_RIFF_INFO_IENG:
- type = NULL; /*"Engineer";*/
- break;
+ type = NULL; /*"Engineer"; */
+ break;
case GST_RIFF_INFO_IGNR:
- type = GST_TAG_GENRE;
- break;
+ type = GST_TAG_GENRE;
+ break;
case GST_RIFF_INFO_IKEY:
- type = NULL; /*"Keywords";*/;
- break;
+ type = NULL; /*"Keywords"; */ ;
+ break;
case GST_RIFF_INFO_ILGT:
- type = NULL; /*"Lightness";*/
- break;
+ type = NULL; /*"Lightness"; */
+ break;
case GST_RIFF_INFO_IMED:
- type = NULL; /*"Medium";*/
- break;
+ type = NULL; /*"Medium"; */
+ break;
case GST_RIFF_INFO_INAM:
- type = GST_TAG_TITLE;
- break;
+ type = GST_TAG_TITLE;
+ break;
case GST_RIFF_INFO_IPLT:
- type = NULL; /*"Palette";*/
- break;
+ type = NULL; /*"Palette"; */
+ break;
case GST_RIFF_INFO_IPRD:
- type = NULL; /*"Product";*/
- break;
+ type = NULL; /*"Product"; */
+ break;
case GST_RIFF_INFO_ISBJ:
- type = NULL; /*"Subject";*/
- break;
+ type = NULL; /*"Subject"; */
+ break;
case GST_RIFF_INFO_ISFT:
- type = GST_TAG_ENCODER;
- break;
+ type = GST_TAG_ENCODER;
+ break;
case GST_RIFF_INFO_ISHP:
- type = NULL; /*"Sharpness";*/
- break;
+ type = NULL; /*"Sharpness"; */
+ break;
case GST_RIFF_INFO_ISRC:
- type = GST_TAG_ISRC;
- break;
+ type = GST_TAG_ISRC;
+ break;
case GST_RIFF_INFO_ISRF:
- type = NULL; /*"Source Form";*/
- break;
+ type = NULL; /*"Source Form"; */
+ break;
case GST_RIFF_INFO_ITCH:
- type = NULL; /*"Technician";*/
- break;
+ type = NULL; /*"Technician"; */
+ break;
default:
- type = NULL;
- GST_WARNING ("Unknown INFO (metadata) tag entry " GST_FOURCC_FORMAT,
- GST_FOURCC_ARGS (tag));
- break;
+ type = NULL;
+ GST_WARNING ("Unknown INFO (metadata) tag entry " GST_FOURCC_FORMAT,
+ GST_FOURCC_ARGS (tag));
+ break;
}
if (type) {
name = NULL;
if (!gst_riff_read_ascii (riff, &tag, &name)) {
- return FALSE;
+ return FALSE;
}
if (name && name[0] != '\0') {
- GValue src = { 0 }, dest = { 0 };
- GType dest_type = gst_tag_get_type (type);
-
- have_tags = TRUE;
- g_value_init (&src, G_TYPE_STRING);
- g_value_set_string (&src, name);
- g_value_init (&dest, dest_type);
- g_value_transform (&src, &dest);
- g_value_unset (&src);
- gst_tag_list_add_values (taglist, GST_TAG_MERGE_APPEND,
- type, &dest, NULL);
- g_value_unset (&dest);
+ GValue src = { 0 }
+ , dest = {
+ 0};
+ GType dest_type = gst_tag_get_type (type);
+
+ have_tags = TRUE;
+ g_value_init (&src, G_TYPE_STRING);
+ g_value_set_string (&src, name);
+ g_value_init (&dest, dest_type);
+ g_value_transform (&src, &dest);
+ g_value_unset (&src);
+ gst_tag_list_add_values (taglist, GST_TAG_MERGE_APPEND,
+ type, &dest, NULL);
+ g_value_unset (&dest);
}
g_free (name);
} else {
/* let the world know about this wonderful thing */
for (padlist = gst_element_get_pad_list (element);
- padlist != NULL; padlist = padlist->next) {
- if (GST_PAD_IS_SRC (padlist->data) && GST_PAD_IS_USABLE(padlist->data)) {
- gst_event_ref (event);
- gst_pad_push (GST_PAD (padlist->data), GST_DATA (event));
+ padlist != NULL; padlist = padlist->next) {
+ if (GST_PAD_IS_SRC (padlist->data) && GST_PAD_IS_USABLE (padlist->data)) {
+ gst_event_ref (event);
+ gst_pad_push (GST_PAD (padlist->data), GST_DATA (event));
}
}
gst_event_unref (event);
*/
gboolean
-gst_riff_read_header (GstRiffRead *riff,
- guint32 *doctype)
+gst_riff_read_header (GstRiffRead * riff, guint32 * doctype)
{
GstRiffLevel *level;
guint32 tag, length;
return FALSE;
}
gst_bytestream_flush_fast (riff->bs, 4);
- *doctype = GUINT32_FROM_LE (* (guint32 *) data);
+ *doctype = GUINT32_FROM_LE (*(guint32 *) data);
/* remember level */
level = g_new (GstRiffLevel, 1);
#include <gst/bytestream/bytestream.h>
G_BEGIN_DECLS
-
#define GST_TYPE_RIFF_READ \
(gst_riff_read_get_type ())
#define GST_RIFF_READ(obj) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RIFF_READ))
#define GST_RIFF_READ_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RIFF_READ, GstRiffReadClass))
-
-typedef struct _GstRiffLevel {
- guint64 start,
- length;
+ typedef struct _GstRiffLevel
+{
+ guint64 start, length;
} GstRiffLevel;
-typedef struct _GstRiffRead {
+typedef struct _GstRiffRead
+{
GstElement parent;
GstPad *sinkpad;
GList *level;
} GstRiffRead;
-typedef struct _GstRiffReadClass {
+typedef struct _GstRiffReadClass
+{
GstElementClass parent;
} GstRiffReadClass;
-GType gst_riff_read_get_type (void);
+GType gst_riff_read_get_type (void);
-guint32 gst_riff_peek_tag (GstRiffRead *riff,
- guint *level_up);
-guint32 gst_riff_peek_list (GstRiffRead *riff);
+guint32 gst_riff_peek_tag (GstRiffRead * riff, guint * level_up);
+guint32 gst_riff_peek_list (GstRiffRead * riff);
-GstEvent *gst_riff_read_seek (GstRiffRead *riff,
- guint64 offset);
-gboolean gst_riff_read_skip (GstRiffRead *riff);
-gboolean gst_riff_read_data (GstRiffRead *riff,
- guint32 *tag,
- GstBuffer **buf);
-gboolean gst_riff_read_ascii (GstRiffRead *riff,
- guint32 *tag,
- gchar **str);
-gboolean gst_riff_read_list (GstRiffRead *riff,
- guint32 *tag);
-gboolean gst_riff_read_header (GstRiffRead *read,
- guint32 *doctype);
+GstEvent *gst_riff_read_seek (GstRiffRead * riff, guint64 offset);
+gboolean gst_riff_read_skip (GstRiffRead * riff);
+gboolean gst_riff_read_data (GstRiffRead * riff,
+ guint32 * tag, GstBuffer ** buf);
+gboolean gst_riff_read_ascii (GstRiffRead * riff, guint32 * tag, gchar ** str);
+gboolean gst_riff_read_list (GstRiffRead * riff, guint32 * tag);
+gboolean gst_riff_read_header (GstRiffRead * read, guint32 * doctype);
/*
* Utility functions (including byteswapping).
*/
-gboolean gst_riff_read_strh (GstRiffRead *riff,
- gst_riff_strh **header);
-gboolean gst_riff_read_strf_vids (GstRiffRead *riff,
- gst_riff_strf_vids **header);
-gboolean gst_riff_read_strf_auds (GstRiffRead *riff,
- gst_riff_strf_auds **header);
-gboolean gst_riff_read_strf_iavs (GstRiffRead *riff,
- gst_riff_strf_iavs **header);
-gboolean gst_riff_read_info (GstRiffRead *riff);
+gboolean gst_riff_read_strh (GstRiffRead * riff, gst_riff_strh ** header);
+gboolean gst_riff_read_strf_vids (GstRiffRead * riff,
+ gst_riff_strf_vids ** header);
+gboolean gst_riff_read_strf_auds (GstRiffRead * riff,
+ gst_riff_strf_auds ** header);
+gboolean gst_riff_read_strf_iavs (GstRiffRead * riff,
+ gst_riff_strf_iavs ** header);
+gboolean gst_riff_read_info (GstRiffRead * riff);
G_END_DECLS
-
#endif /* __GST_RIFF_READ_H__ */
#include <gst/gst.h>
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
return gst_library_load ("gstbytestream");
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "riff",
- "RIFF I/O functions",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "riff",
+ "RIFF I/O functions",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
#include <gst/gst.h>
G_BEGIN_DECLS
-
-
/* functions for vorbis comment manipulation */
+ G_CONST_RETURN gchar * gst_tag_from_vorbis_tag (const gchar * vorbis_tag);
+G_CONST_RETURN gchar *gst_tag_to_vorbis_tag (const gchar * gst_tag);
+void gst_vorbis_tag_add (GstTagList * list,
+ const gchar * tag, const gchar * value);
-G_CONST_RETURN gchar * gst_tag_from_vorbis_tag (const gchar * vorbis_tag);
-G_CONST_RETURN gchar * gst_tag_to_vorbis_tag (const gchar * gst_tag);
-void gst_vorbis_tag_add (GstTagList * list,
- const gchar * tag,
- const gchar * value);
-
-GList * gst_tag_to_vorbis_comments (const GstTagList * list,
- const gchar * tag);
+GList *gst_tag_to_vorbis_comments (const GstTagList * list, const gchar * tag);
/* functions to convert GstBuffers with vorbiscomment contents to GstTagLists and back */
-GstTagList * gst_tag_list_from_vorbiscomment_buffer (const GstBuffer * buffer,
- const guint8 * id_data,
- const guint id_data_length,
- gchar ** vendor_string);
-GstBuffer * gst_tag_list_to_vorbiscomment_buffer (const GstTagList * list,
- const guint8 * id_data,
- const guint id_data_length,
- const gchar * vendor_string);
+GstTagList *gst_tag_list_from_vorbiscomment_buffer (const GstBuffer * buffer,
+ const guint8 * id_data, const guint id_data_length, gchar ** vendor_string);
+GstBuffer *gst_tag_list_to_vorbiscomment_buffer (const GstTagList * list,
+ const guint8 * id_data,
+ const guint id_data_length, const gchar * vendor_string);
/* functions for ID3 tag manipulation */
-guint gst_tag_id3_genre_count (void);
-G_CONST_RETURN gchar * gst_tag_id3_genre_get (const guint id);
-GstTagList * gst_tag_list_new_from_id3v1 (const guint8 * data);
+guint gst_tag_id3_genre_count (void);
+G_CONST_RETURN gchar *gst_tag_id3_genre_get (const guint id);
+GstTagList *gst_tag_list_new_from_id3v1 (const guint8 * data);
-G_CONST_RETURN gchar * gst_tag_from_id3_tag (const gchar * vorbis_tag);
-G_CONST_RETURN gchar * gst_tag_to_id3_tag (const gchar * gst_tag);
+G_CONST_RETURN gchar *gst_tag_from_id3_tag (const gchar * vorbis_tag);
+G_CONST_RETURN gchar *gst_tag_to_id3_tag (const gchar * gst_tag);
G_END_DECLS
-
#endif /* __GST_TAG_TAG_H__ */
#include <string.h>
-enum {
+enum
+{
NORM_CHANGED,
CHANNEL_CHANGED,
FREQUENCY_CHANGED,
LAST_SIGNAL
};
-static void gst_tuner_class_init (GstTunerClass *klass);
+static void gst_tuner_class_init (GstTunerClass * klass);
static guint gst_tuner_signals[LAST_SIGNAL] = { 0 };
};
gst_tuner_type = g_type_register_static (G_TYPE_INTERFACE,
- "GstTuner",
- &gst_tuner_info, 0);
+ "GstTuner", &gst_tuner_info, 0);
g_type_interface_add_prerequisite (gst_tuner_type,
- GST_TYPE_IMPLEMENTS_INTERFACE);
+ GST_TYPE_IMPLEMENTS_INTERFACE);
}
return gst_tuner_type;
}
static void
-gst_tuner_class_init (GstTunerClass *klass)
+gst_tuner_class_init (GstTunerClass * klass)
{
static gboolean initialized = FALSE;
if (!initialized) {
gst_tuner_signals[NORM_CHANGED] =
- g_signal_new ("norm-changed",
- GST_TYPE_TUNER, G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstTunerClass, norm_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
- GST_TYPE_TUNER_NORM);
+ g_signal_new ("norm-changed",
+ GST_TYPE_TUNER, G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstTunerClass, norm_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GST_TYPE_TUNER_NORM);
gst_tuner_signals[CHANNEL_CHANGED] =
- g_signal_new ("channel-changed",
- GST_TYPE_TUNER, G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstTunerClass, channel_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
- GST_TYPE_TUNER_CHANNEL);
+ g_signal_new ("channel-changed",
+ GST_TYPE_TUNER, G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstTunerClass, channel_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
+ GST_TYPE_TUNER_CHANNEL);
gst_tuner_signals[FREQUENCY_CHANGED] =
- g_signal_new ("frequency-changed",
- GST_TYPE_TUNER, G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstTunerClass, frequency_changed),
- NULL, NULL,
- gst_tuner_marshal_VOID__OBJECT_ULONG, G_TYPE_NONE, 2,
- GST_TYPE_TUNER_CHANNEL, G_TYPE_ULONG);
+ g_signal_new ("frequency-changed",
+ GST_TYPE_TUNER, G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstTunerClass, frequency_changed),
+ NULL, NULL,
+ gst_tuner_marshal_VOID__OBJECT_ULONG, G_TYPE_NONE, 2,
+ GST_TYPE_TUNER_CHANNEL, G_TYPE_ULONG);
gst_tuner_signals[SIGNAL_CHANGED] =
- g_signal_new ("signal-changed",
- GST_TYPE_TUNER, G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstTunerClass, signal_changed),
- NULL, NULL,
- gst_tuner_marshal_VOID__OBJECT_INT, G_TYPE_NONE, 2,
- GST_TYPE_TUNER_CHANNEL, G_TYPE_INT);
+ g_signal_new ("signal-changed",
+ GST_TYPE_TUNER, G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstTunerClass, signal_changed),
+ NULL, NULL,
+ gst_tuner_marshal_VOID__OBJECT_INT, G_TYPE_NONE, 2,
+ GST_TYPE_TUNER_CHANNEL, G_TYPE_INT);
initialized = TRUE;
}
*/
const GList *
-gst_tuner_list_channels (GstTuner *tuner)
+gst_tuner_list_channels (GstTuner * tuner)
{
GstTunerClass *klass = GST_TUNER_GET_CLASS (tuner);
*/
void
-gst_tuner_set_channel (GstTuner *tuner,
- GstTunerChannel *channel)
+gst_tuner_set_channel (GstTuner * tuner, GstTunerChannel * channel)
{
GstTunerClass *klass = GST_TUNER_GET_CLASS (tuner);
*/
GstTunerChannel *
-gst_tuner_get_channel (GstTuner *tuner)
+gst_tuner_get_channel (GstTuner * tuner)
{
GstTunerClass *klass = GST_TUNER_GET_CLASS (tuner);
*/
const GList *
-gst_tuner_list_norms (GstTuner *tuner)
+gst_tuner_list_norms (GstTuner * tuner)
{
GstTunerClass *klass = GST_TUNER_GET_CLASS (tuner);
*/
void
-gst_tuner_set_norm (GstTuner *tuner,
- GstTunerNorm *norm)
+gst_tuner_set_norm (GstTuner * tuner, GstTunerNorm * norm)
{
GstTunerClass *klass = GST_TUNER_GET_CLASS (tuner);
*/
GstTunerNorm *
-gst_tuner_get_norm (GstTuner *tuner)
+gst_tuner_get_norm (GstTuner * tuner)
{
GstTunerClass *klass = GST_TUNER_GET_CLASS (tuner);
*/
void
-gst_tuner_set_frequency (GstTuner *tuner,
- GstTunerChannel *channel,
- gulong frequency)
+gst_tuner_set_frequency (GstTuner * tuner,
+ GstTunerChannel * channel, gulong frequency)
{
GstTunerClass *klass = GST_TUNER_GET_CLASS (tuner);
g_return_if_fail (GST_TUNER_CHANNEL_HAS_FLAG (channel,
- GST_TUNER_CHANNEL_FREQUENCY));
+ GST_TUNER_CHANNEL_FREQUENCY));
if (klass->set_frequency) {
klass->set_frequency (tuner, channel, frequency);
*/
gulong
-gst_tuner_get_frequency (GstTuner *tuner,
- GstTunerChannel *channel)
+gst_tuner_get_frequency (GstTuner * tuner, GstTunerChannel * channel)
{
GstTunerClass *klass = GST_TUNER_GET_CLASS (tuner);
g_return_val_if_fail (GST_TUNER_CHANNEL_HAS_FLAG (channel,
- GST_TUNER_CHANNEL_FREQUENCY), 0);
+ GST_TUNER_CHANNEL_FREQUENCY), 0);
if (klass->get_frequency) {
return klass->get_frequency (tuner, channel);
*/
gint
-gst_tuner_signal_strength (GstTuner *tuner,
- GstTunerChannel *channel)
+gst_tuner_signal_strength (GstTuner * tuner, GstTunerChannel * channel)
{
GstTunerClass *klass = GST_TUNER_GET_CLASS (tuner);
g_return_val_if_fail (GST_TUNER_CHANNEL_HAS_FLAG (channel,
- GST_TUNER_CHANNEL_FREQUENCY), 0);
+ GST_TUNER_CHANNEL_FREQUENCY), 0);
if (klass->signal_strength) {
return klass->signal_strength (tuner, channel);
}
GstTunerNorm *
-gst_tuner_find_norm_by_name (GstTuner *tuner,
- gchar *norm)
+gst_tuner_find_norm_by_name (GstTuner * tuner, gchar * norm)
{
GList *walk;
}
GstTunerChannel *
-gst_tuner_find_channel_by_name (GstTuner *tuner,
- gchar *channel)
+gst_tuner_find_channel_by_name (GstTuner * tuner, gchar * channel)
{
GList *walk;
}
void
-gst_tuner_channel_changed (GstTuner *tuner,
- GstTunerChannel *channel)
+gst_tuner_channel_changed (GstTuner * tuner, GstTunerChannel * channel)
{
g_return_if_fail (GST_IS_TUNER (tuner));
g_return_if_fail (GST_IS_TUNER_CHANNEL (channel));
g_signal_emit (G_OBJECT (tuner),
- gst_tuner_signals[CHANNEL_CHANGED], 0,
- channel);
+ gst_tuner_signals[CHANNEL_CHANGED], 0, channel);
}
void
-gst_tuner_norm_changed (GstTuner *tuner,
- GstTunerNorm *norm)
+gst_tuner_norm_changed (GstTuner * tuner, GstTunerNorm * norm)
{
g_return_if_fail (GST_IS_TUNER (tuner));
g_return_if_fail (GST_IS_TUNER_NORM (norm));
- g_signal_emit (G_OBJECT (tuner),
- gst_tuner_signals[NORM_CHANGED], 0,
- norm);
+ g_signal_emit (G_OBJECT (tuner), gst_tuner_signals[NORM_CHANGED], 0, norm);
}
void
-gst_tuner_frequency_changed (GstTuner *tuner,
- GstTunerChannel *channel,
- gulong frequency)
+gst_tuner_frequency_changed (GstTuner * tuner,
+ GstTunerChannel * channel, gulong frequency)
{
g_return_if_fail (GST_IS_TUNER (tuner));
g_return_if_fail (GST_IS_TUNER_CHANNEL (channel));
g_signal_emit (G_OBJECT (tuner),
- gst_tuner_signals[FREQUENCY_CHANGED], 0,
- channel, frequency);
+ gst_tuner_signals[FREQUENCY_CHANGED], 0, channel, frequency);
- g_signal_emit_by_name (G_OBJECT (channel),
- "frequency_changed",
- frequency);
+ g_signal_emit_by_name (G_OBJECT (channel), "frequency_changed", frequency);
}
void
-gst_tuner_signal_changed (GstTuner *tuner,
- GstTunerChannel *channel,
- gint signal)
+gst_tuner_signal_changed (GstTuner * tuner,
+ GstTunerChannel * channel, gint signal)
{
g_return_if_fail (GST_IS_TUNER (tuner));
g_return_if_fail (GST_IS_TUNER_CHANNEL (channel));
g_signal_emit (G_OBJECT (tuner),
- gst_tuner_signals[SIGNAL_CHANGED], 0,
- channel, signal);
+ gst_tuner_signals[SIGNAL_CHANGED], 0, channel, signal);
- g_signal_emit_by_name (G_OBJECT (channel),
- "signal_changed",
- signal);
+ g_signal_emit_by_name (G_OBJECT (channel), "signal_changed", signal);
}
#include <gst/tuner/tuner-enumtypes.h>
G_BEGIN_DECLS
-
#define GST_TYPE_TUNER \
(gst_tuner_get_type ())
#define GST_TUNER(obj) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_TUNER))
#define GST_TUNER_GET_CLASS(inst) \
(G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_TUNER, GstTunerClass))
-
typedef struct _GstTuner GstTuner;
-typedef struct _GstTunerClass {
+typedef struct _GstTunerClass
+{
GTypeInterface klass;
/* virtual functions */
- const GList * (* list_channels) (GstTuner *tuner);
- void (* set_channel) (GstTuner *tuner,
- GstTunerChannel *channel);
- GstTunerChannel *
- (* get_channel) (GstTuner *tuner);
-
- const GList * (* list_norms) (GstTuner *tuner);
- void (* set_norm) (GstTuner *tuner,
- GstTunerNorm *norm);
- GstTunerNorm *(* get_norm) (GstTuner *tuner);
-
- void (* set_frequency) (GstTuner *tuner,
- GstTunerChannel *channel,
- gulong frequency);
- gulong (* get_frequency) (GstTuner *tuner,
- GstTunerChannel *channel);
- gint (* signal_strength) (GstTuner *tuner,
- GstTunerChannel *channel);
+ const GList *(*list_channels) (GstTuner * tuner);
+ void (*set_channel) (GstTuner * tuner, GstTunerChannel * channel);
+ GstTunerChannel *(*get_channel) (GstTuner * tuner);
+
+ const GList *(*list_norms) (GstTuner * tuner);
+ void (*set_norm) (GstTuner * tuner, GstTunerNorm * norm);
+ GstTunerNorm *(*get_norm) (GstTuner * tuner);
+
+ void (*set_frequency) (GstTuner * tuner,
+ GstTunerChannel * channel, gulong frequency);
+ gulong (*get_frequency) (GstTuner * tuner, GstTunerChannel * channel);
+ gint (*signal_strength) (GstTuner * tuner, GstTunerChannel * channel);
/* signals */
- void (*channel_changed) (GstTuner *tuner,
- GstTunerChannel *channel);
- void (*norm_changed) (GstTuner *tuner,
- GstTunerNorm *norm);
- void (*frequency_changed) (GstTuner *tuner,
- GstTunerChannel *channel,
- gulong frequency);
- void (*signal_changed) (GstTuner *tuner,
- GstTunerChannel *channel,
- gint signal);
+ void (*channel_changed) (GstTuner * tuner, GstTunerChannel * channel);
+ void (*norm_changed) (GstTuner * tuner, GstTunerNorm * norm);
+ void (*frequency_changed) (GstTuner * tuner,
+ GstTunerChannel * channel, gulong frequency);
+ void (*signal_changed) (GstTuner * tuner,
+ GstTunerChannel * channel, gint signal);
gpointer _gst_reserved[GST_PADDING];
} GstTunerClass;
-GType gst_tuner_get_type (void);
+GType gst_tuner_get_type (void);
/* virtual class function wrappers */
-const GList * gst_tuner_list_channels (GstTuner *tuner);
-void gst_tuner_set_channel (GstTuner *tuner,
- GstTunerChannel *channel);
-GstTunerChannel *
- gst_tuner_get_channel (GstTuner *tuner);
-
-const GList * gst_tuner_list_norms (GstTuner *tuner);
-void gst_tuner_set_norm (GstTuner *tuner,
- GstTunerNorm *channel);
-GstTunerNorm * gst_tuner_get_norm (GstTuner *tuner);
-
-void gst_tuner_set_frequency (GstTuner *tuner,
- GstTunerChannel *channel,
- gulong frequency);
-gulong gst_tuner_get_frequency (GstTuner *tuner,
- GstTunerChannel *channel);
-gint gst_tuner_signal_strength (GstTuner *tuner,
- GstTunerChannel *channel);
+const GList *gst_tuner_list_channels (GstTuner * tuner);
+void gst_tuner_set_channel (GstTuner * tuner, GstTunerChannel * channel);
+GstTunerChannel *gst_tuner_get_channel (GstTuner * tuner);
+
+const GList *gst_tuner_list_norms (GstTuner * tuner);
+void gst_tuner_set_norm (GstTuner * tuner, GstTunerNorm * channel);
+GstTunerNorm *gst_tuner_get_norm (GstTuner * tuner);
+
+void gst_tuner_set_frequency (GstTuner * tuner,
+ GstTunerChannel * channel, gulong frequency);
+gulong gst_tuner_get_frequency (GstTuner * tuner, GstTunerChannel * channel);
+gint gst_tuner_signal_strength (GstTuner * tuner, GstTunerChannel * channel);
/* helper functions */
-GstTunerNorm * gst_tuner_find_norm_by_name (GstTuner *tuner,
- gchar *norm);
-GstTunerChannel *gst_tuner_find_channel_by_name (GstTuner *tuner,
- gchar *channel);
+GstTunerNorm *gst_tuner_find_norm_by_name (GstTuner * tuner, gchar * norm);
+GstTunerChannel *gst_tuner_find_channel_by_name (GstTuner * tuner,
+ gchar * channel);
/* trigger signals */
-void gst_tuner_channel_changed (GstTuner *tuner,
- GstTunerChannel *channel);
-void gst_tuner_norm_changed (GstTuner *tuner,
- GstTunerNorm *norm);
-void gst_tuner_frequency_changed (GstTuner *tuner,
- GstTunerChannel *channel,
- gulong frequency);
-void gst_tuner_signal_changed (GstTuner *tuner,
- GstTunerChannel *channel,
- gint signal);
+void gst_tuner_channel_changed (GstTuner * tuner, GstTunerChannel * channel);
+void gst_tuner_norm_changed (GstTuner * tuner, GstTunerNorm * norm);
+void gst_tuner_frequency_changed (GstTuner * tuner,
+ GstTunerChannel * channel, gulong frequency);
+void gst_tuner_signal_changed (GstTuner * tuner,
+ GstTunerChannel * channel, gint signal);
G_END_DECLS
-
#endif /* __GST_TUNER_H__ */
#include "tunerchannel.h"
-enum {
+enum
+{
/* FILL ME */
SIGNAL_FREQUENCY_CHANGED,
SIGNAL_SIGNAL_CHANGED,
LAST_SIGNAL
};
-static void gst_tuner_channel_class_init (GstTunerChannelClass *klass);
-static void gst_tuner_channel_init (GstTunerChannel *channel);
-static void gst_tuner_channel_dispose (GObject *object);
+static void gst_tuner_channel_class_init (GstTunerChannelClass * klass);
+static void gst_tuner_channel_init (GstTunerChannel * channel);
+static void gst_tuner_channel_dispose (GObject * object);
static GObjectClass *parent_class = NULL;
static guint signals[LAST_SIGNAL] = { 0 };
gst_tuner_channel_type =
g_type_register_static (G_TYPE_OBJECT,
- "GstTunerChannel",
- &tuner_channel_info, 0);
+ "GstTunerChannel", &tuner_channel_info, 0);
}
return gst_tuner_channel_type;
}
static void
-gst_tuner_channel_class_init (GstTunerChannelClass *klass)
+gst_tuner_channel_class_init (GstTunerChannelClass * klass)
{
GObjectClass *object_klass = (GObjectClass *) klass;
parent_class = g_type_class_ref (G_TYPE_OBJECT);
signals[SIGNAL_FREQUENCY_CHANGED] =
- g_signal_new ("frequency-changed", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstTunerChannelClass,
- frequency_changed),
- NULL, NULL, g_cclosure_marshal_VOID__ULONG,
- G_TYPE_NONE, 1, G_TYPE_ULONG);
+ g_signal_new ("frequency-changed", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstTunerChannelClass,
+ frequency_changed),
+ NULL, NULL, g_cclosure_marshal_VOID__ULONG, G_TYPE_NONE, 1, G_TYPE_ULONG);
signals[SIGNAL_SIGNAL_CHANGED] =
- g_signal_new ("signal-changed", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstTunerChannelClass,
- signal_changed),
- NULL, NULL, g_cclosure_marshal_VOID__INT,
- G_TYPE_NONE, 1, G_TYPE_INT);
+ g_signal_new ("signal-changed", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstTunerChannelClass,
+ signal_changed),
+ NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
object_klass->dispose = gst_tuner_channel_dispose;
}
static void
-gst_tuner_channel_init (GstTunerChannel *channel)
+gst_tuner_channel_init (GstTunerChannel * channel)
{
channel->label = NULL;
channel->flags = 0;
}
static void
-gst_tuner_channel_dispose (GObject *object)
+gst_tuner_channel_dispose (GObject * object)
{
GstTunerChannel *channel = GST_TUNER_CHANNEL (object);
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_TYPE_TUNER_CHANNEL \
(gst_tuner_channel_get_type ())
#define GST_TUNER_CHANNEL(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_TUNER_CHANNEL))
#define GST_IS_TUNER_CHANNEL_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_TUNER_CHANNEL))
-
-typedef enum {
- GST_TUNER_CHANNEL_INPUT = (1<<0),
- GST_TUNER_CHANNEL_OUTPUT = (1<<1),
- GST_TUNER_CHANNEL_FREQUENCY = (1<<2),
- GST_TUNER_CHANNEL_AUDIO = (1<<3),
+ typedef enum
+{
+ GST_TUNER_CHANNEL_INPUT = (1 << 0),
+ GST_TUNER_CHANNEL_OUTPUT = (1 << 1),
+ GST_TUNER_CHANNEL_FREQUENCY = (1 << 2),
+ GST_TUNER_CHANNEL_AUDIO = (1 << 3),
} GstTunerChannelFlags;
#define GST_TUNER_CHANNEL_HAS_FLAG(channel, flag) \
((channel)->flags & flag)
-typedef struct _GstTunerChannel {
- GObject parent;
+typedef struct _GstTunerChannel
+{
+ GObject parent;
- gchar *label;
+ gchar *label;
GstTunerChannelFlags flags;
- gulong min_frequency,
- max_frequency;
- gint min_signal,
- max_signal;
+ gulong min_frequency, max_frequency;
+ gint min_signal, max_signal;
} GstTunerChannel;
-typedef struct _GstTunerChannelClass {
+typedef struct _GstTunerChannelClass
+{
GObjectClass parent;
/* signals */
- void (*frequency_changed) (GstTunerChannel *channel,
- gulong frequency);
- void (*signal_changed) (GstTunerChannel *channel,
- gint signal);
+ void (*frequency_changed) (GstTunerChannel * channel, gulong frequency);
+ void (*signal_changed) (GstTunerChannel * channel, gint signal);
gpointer _gst_reserved[GST_PADDING];
} GstTunerChannelClass;
-GType gst_tuner_channel_get_type (void);
+GType gst_tuner_channel_get_type (void);
G_END_DECLS
-
#endif /* __GST_TUNER_CHANNEL_H__ */
#include "tunernorm.h"
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-static void gst_tuner_norm_class_init (GstTunerNormClass *klass);
-static void gst_tuner_norm_init (GstTunerNorm *norm);
-static void gst_tuner_norm_dispose (GObject *object);
+static void gst_tuner_norm_class_init (GstTunerNormClass * klass);
+static void gst_tuner_norm_init (GstTunerNorm * norm);
+static void gst_tuner_norm_dispose (GObject * object);
static GObjectClass *parent_class = NULL;
+
/*static guint signals[LAST_SIGNAL] = { 0 };*/
GType
gst_tuner_norm_type =
g_type_register_static (G_TYPE_OBJECT,
- "GstTunerNorm",
- &tuner_norm_info, 0);
+ "GstTunerNorm", &tuner_norm_info, 0);
}
return gst_tuner_norm_type;
}
static void
-gst_tuner_norm_class_init (GstTunerNormClass *klass)
+gst_tuner_norm_class_init (GstTunerNormClass * klass)
{
GObjectClass *object_klass = (GObjectClass *) klass;
}
static void
-gst_tuner_norm_init (GstTunerNorm *norm)
+gst_tuner_norm_init (GstTunerNorm * norm)
{
norm->label = NULL;
norm->fps = 0.;
}
static void
-gst_tuner_norm_dispose (GObject *object)
+gst_tuner_norm_dispose (GObject * object)
{
GstTunerNorm *norm = GST_TUNER_NORM (object);
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_TYPE_TUNER_NORM \
(gst_tuner_norm_get_type ())
#define GST_TUNER_NORM(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_TUNER_NORM))
#define GST_IS_TUNER_NORM_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_TUNER_NORM))
-
-typedef struct _GstTunerNorm {
+ typedef struct _GstTunerNorm
+{
GObject parent;
- gchar *label;
- gfloat fps;
+ gchar *label;
+ gfloat fps;
} GstTunerNorm;
-typedef struct _GstTunerNormClass {
+typedef struct _GstTunerNormClass
+{
GObjectClass parent;
gpointer _gst_reserved[GST_PADDING];
} GstTunerNormClass;
-GType gst_tuner_norm_get_type (void);
+GType gst_tuner_norm_get_type (void);
G_END_DECLS
-
#endif /* __GST_TUNER_NORM_H__ */
/* Private methods */
static void
-gst_videosink_set_clock (GstElement *element, GstClock *clock)
+gst_videosink_set_clock (GstElement * element, GstClock * clock)
{
GstVideoSink *videosink;
videosink = GST_VIDEOSINK (element);
-
+
videosink->clock = clock;
}
/* Initing stuff */
static void
-gst_videosink_init (GstVideoSink *videosink)
+gst_videosink_init (GstVideoSink * videosink)
{
videosink->width = 0;
videosink->height = 0;
}
static void
-gst_videosink_class_init (GstVideoSinkClass *klass)
+gst_videosink_class_init (GstVideoSinkClass * 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);
{
static GType videosink_type = 0;
- if (!videosink_type)
- {
- static const GTypeInfo videosink_info = {
- sizeof (GstVideoSinkClass),
- NULL,
- NULL,
- (GClassInitFunc) gst_videosink_class_init,
- NULL,
- NULL,
- sizeof (GstVideoSink),
- 0,
- (GInstanceInitFunc) gst_videosink_init,
- };
-
- videosink_type = g_type_register_static (GST_TYPE_ELEMENT,
- "GstVideoSink",
- &videosink_info, 0);
- }
-
+ if (!videosink_type) {
+ static const GTypeInfo videosink_info = {
+ sizeof (GstVideoSinkClass),
+ NULL,
+ NULL,
+ (GClassInitFunc) gst_videosink_class_init,
+ NULL,
+ NULL,
+ sizeof (GstVideoSink),
+ 0,
+ (GInstanceInitFunc) gst_videosink_init,
+ };
+
+ videosink_type = g_type_register_static (GST_TYPE_ELEMENT,
+ "GstVideoSink", &videosink_info, 0);
+ }
+
return videosink_type;
}
/* This is simply a convenience function, nothing more or less */
gdouble
-gst_video_frame_rate (GstPad *pad)
+gst_video_frame_rate (GstPad * pad)
{
gdouble fps = 0.;
const GstCaps *caps = NULL;
caps = GST_PAD_CAPS (pad);
if (caps == NULL) {
g_warning ("gstvideo: failed to get caps of pad %s:%s",
- GST_ELEMENT_NAME (gst_pad_get_parent (pad)),
- GST_PAD_NAME(pad));
+ GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad));
return 0.;
}
structure = gst_caps_get_structure (caps, 0);
- if (!gst_structure_get_double (structure, "framerate", &fps)){
+ if (!gst_structure_get_double (structure, "framerate", &fps)) {
g_warning ("gstvideo: failed to get framerate property of pad %s:%s",
- GST_ELEMENT_NAME (gst_pad_get_parent (pad)),
- GST_PAD_NAME (pad));
+ GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad));
return 0.;
}
GST_DEBUG ("Framerate request on pad %s:%s: %f",
- GST_ELEMENT_NAME (gst_pad_get_parent (pad)),
- GST_PAD_NAME(pad), fps);
+ GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad), fps);
return fps;
}
gboolean
-gst_video_get_size (GstPad *pad,
- gint *width,
- gint *height)
+gst_video_get_size (GstPad * pad, gint * width, gint * height)
{
const GstCaps *caps = NULL;
GstStructure *structure;
if (caps == NULL) {
g_warning ("gstvideo: failed to get caps of pad %s:%s",
- GST_ELEMENT_NAME (gst_pad_get_parent (pad)),
- GST_PAD_NAME(pad));
+ GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad));
return FALSE;
}
if (!ret) {
g_warning ("gstvideo: failed to get size properties on pad %s:%s",
- GST_ELEMENT_NAME (gst_pad_get_parent (pad)),
- GST_PAD_NAME(pad));
+ GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad));
return FALSE;
}
GST_DEBUG ("size request on pad %s:%s: %dx%d",
- GST_ELEMENT_NAME (gst_pad_get_parent (pad)),
- GST_PAD_NAME (pad),
- width ? *width : -1,
- height ? *height : -1);
+ GST_ELEMENT_NAME (gst_pad_get_parent (pad)),
+ GST_PAD_NAME (pad), width ? *width : -1, height ? *height : -1);
return TRUE;
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "gstvideo",
- "Convenience routines for video plugins",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "gstvideo",
+ "Convenience routines for video plugins",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
#define GST_VIDEO_CAPS_RGBx \
__GST_VIDEO_CAPS_MAKE_32 (1, 2, 3)
-
+
#define GST_VIDEO_CAPS_xRGB \
__GST_VIDEO_CAPS_MAKE_32 (2, 3, 4)
-
+
#define GST_VIDEO_CAPS_BGRx \
__GST_VIDEO_CAPS_MAKE_32 (3, 2, 1)
-
+
#define GST_VIDEO_CAPS_xBGR \
__GST_VIDEO_CAPS_MAKE_32 (4, 3, 2)
/* note: the macro name uses the order on BE systems */
#if G_BYTE_ORDER == G_BIG_ENDIAN
- #define GST_VIDEO_CAPS_xRGB_HOST_ENDIAN \
+#define GST_VIDEO_CAPS_xRGB_HOST_ENDIAN \
GST_VIDEO_CAPS_xRGB
- #define GST_VIDEO_CAPS_BGRx_HOST_ENDIAN \
+#define GST_VIDEO_CAPS_BGRx_HOST_ENDIAN \
GST_VIDEO_CAPS_BGRx
#else
- #define GST_VIDEO_CAPS_xRGB_HOST_ENDIAN \
+#define GST_VIDEO_CAPS_xRGB_HOST_ENDIAN \
GST_VIDEO_CAPS_BGRx
- #define GST_VIDEO_CAPS_BGRx_HOST_ENDIAN \
+#define GST_VIDEO_CAPS_BGRx_HOST_ENDIAN \
GST_VIDEO_CAPS_xRGB
#endif
-
+
/* 15/16 bit */
-
+
#define GST_VIDEO_CAPS_RGB_16 \
"video/x-raw-rgb, " \
"bpp = (int) 16, " \
"framerate = " GST_VIDEO_FPS_RANGE
/* functions */
-gdouble gst_video_frame_rate (GstPad *pad);
-gboolean gst_video_get_size (GstPad *pad,
- gint *width,
- gint *height);
+gdouble gst_video_frame_rate (GstPad * pad);
+gboolean gst_video_get_size (GstPad * pad, gint * width, gint * height);
#endif /* __GST_VIDEO_H__ */
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-
+
#ifndef __GST_VIDEOSINK_H__
#define __GST_VIDEOSINK_H__
#include <gst/gst.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
+extern "C"
+{
+#endif /* __cplusplus */
+
#define GST_TYPE_VIDEOSINK (gst_videosink_get_type())
#define GST_VIDEOSINK(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VIDEOSINK, GstVideoSink))
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_VIDEOSINK))
#define GST_VIDEOSINK_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_VIDEOSINK, GstVideoSinkClass))
-
+
#define GST_VIDEOSINK_PAD(obj) (GST_VIDEOSINK (obj)->sinkpad)
#define GST_VIDEOSINK_WIDTH(obj) (GST_VIDEOSINK (obj)->width)
#define GST_VIDEOSINK_HEIGHT(obj) (GST_VIDEOSINK (obj)->height)
#define GST_VIDEOSINK_CLOCK(obj) (GST_VIDEOSINK (obj)->clock)
-
-typedef struct _GstVideoSink GstVideoSink;
-typedef struct _GstVideoSinkClass GstVideoSinkClass;
-
-struct _GstVideoSink {
- GstElement element;
-
- GstPad *sinkpad;
-
- gint width, height;
-
- GstClock *clock;
-
- gpointer _gst_reserved[GST_PADDING];
-};
-
-struct _GstVideoSinkClass {
- GstElementClass parent_class;
-
- gpointer _gst_reserved[GST_PADDING];
-};
-
-GType gst_videosink_get_type (void);
+
+ typedef struct _GstVideoSink GstVideoSink;
+ typedef struct _GstVideoSinkClass GstVideoSinkClass;
+
+ struct _GstVideoSink
+ {
+ GstElement element;
+
+ GstPad *sinkpad;
+
+ gint width, height;
+
+ GstClock *clock;
+
+ gpointer _gst_reserved[GST_PADDING];
+ };
+
+ struct _GstVideoSinkClass
+ {
+ GstElementClass parent_class;
+
+ gpointer _gst_reserved[GST_PADDING];
+ };
+
+ GType gst_videosink_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_VIDEOSINK_H__ */
+#endif /* __GST_VIDEOSINK_H__ */
#include "xoverlay.h"
-enum {
+enum
+{
HAVE_XWINDOW_ID,
DESIRED_SIZE,
LAST_SIGNAL
};
gst_x_overlay_type = g_type_register_static (G_TYPE_INTERFACE,
- "GstXOverlay",
- &gst_x_overlay_info, 0);
+ "GstXOverlay", &gst_x_overlay_info, 0);
g_type_interface_add_prerequisite (gst_x_overlay_type,
- GST_TYPE_IMPLEMENTS_INTERFACE);
+ GST_TYPE_IMPLEMENTS_INTERFACE);
}
return gst_x_overlay_type;
}
/* FIXME: evil hack, we should figure out our marshal handling in this interfaces some day */
-extern void gst_marshal_VOID__INT_INT (GClosure *closure, GValue *return_value, guint n_param_values,
- const GValue *param_values, gpointer invocation_hint, gpointer marshal_data);
+extern void gst_marshal_VOID__INT_INT (GClosure * closure,
+ GValue * return_value, guint n_param_values, const GValue * param_values,
+ gpointer invocation_hint, gpointer marshal_data);
static void
gst_x_overlay_base_init (gpointer g_class)
{
GstXOverlayClass *overlay_class = (GstXOverlayClass *) g_class;
static gboolean initialized = FALSE;
-
- if (! initialized)
- {
- gst_x_overlay_signals[HAVE_XWINDOW_ID] =
- g_signal_new ("have-xwindow-id",
- GST_TYPE_X_OVERLAY, G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstXOverlayClass, have_xwindow_id),
- NULL, NULL,
- g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1,
- G_TYPE_INT);
- gst_x_overlay_signals[DESIRED_SIZE] =
- g_signal_new ("desired-size-changed",
- GST_TYPE_X_OVERLAY, G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstXOverlayClass, desired_size),
- NULL, NULL,
- gst_marshal_VOID__INT_INT, G_TYPE_NONE, 2,
- G_TYPE_INT, G_TYPE_INT);
-
- initialized = TRUE;
- }
+
+ if (!initialized) {
+ gst_x_overlay_signals[HAVE_XWINDOW_ID] =
+ g_signal_new ("have-xwindow-id",
+ GST_TYPE_X_OVERLAY, G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstXOverlayClass, have_xwindow_id),
+ NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
+ gst_x_overlay_signals[DESIRED_SIZE] =
+ g_signal_new ("desired-size-changed",
+ GST_TYPE_X_OVERLAY, G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstXOverlayClass, desired_size),
+ NULL, NULL,
+ gst_marshal_VOID__INT_INT, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
+
+ initialized = TRUE;
+ }
overlay_class->set_xwindow_id = NULL;
}
* stop using that window and create an internal one.
*/
void
-gst_x_overlay_set_xwindow_id (GstXOverlay *overlay, gulong xwindow_id)
+gst_x_overlay_set_xwindow_id (GstXOverlay * overlay, gulong xwindow_id)
{
GstXOverlayClass *klass = GST_X_OVERLAY_GET_CLASS (overlay);
* This function should be used by video overlay developpers.
*/
void
-gst_x_overlay_got_xwindow_id (GstXOverlay *overlay, gulong xwindow_id)
+gst_x_overlay_got_xwindow_id (GstXOverlay * overlay, gulong xwindow_id)
{
g_return_if_fail (overlay != NULL);
g_return_if_fail (GST_IS_X_OVERLAY (overlay));
-
+
g_signal_emit (G_OBJECT (overlay),
- gst_x_overlay_signals[HAVE_XWINDOW_ID], 0, (gint) xwindow_id);
+ gst_x_overlay_signals[HAVE_XWINDOW_ID], 0, (gint) xwindow_id);
}
/**
* size, width and height are set to 0.
*/
void
-gst_x_overlay_get_desired_size (GstXOverlay *overlay, guint *width, guint *height)
+gst_x_overlay_get_desired_size (GstXOverlay * overlay, guint * width,
+ guint * height)
{
guint width_tmp, height_tmp;
GstXOverlayClass *klass;
-
+
g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE ((overlay), GST_TYPE_X_OVERLAY));
-
+
klass = GST_X_OVERLAY_GET_CLASS (overlay);
if (klass->get_desired_size && GST_IS_X_OVERLAY (overlay)) {
/* this ensures that elements don't need to check width and height for NULL
but apps may use NULL */
- klass->get_desired_size (overlay, width ? width : &width_tmp, height ? height : &height_tmp);
+ klass->get_desired_size (overlay, width ? width : &width_tmp,
+ height ? height : &height_tmp);
} else {
if (width)
*width = 0;
* This function should be used by video overlay developpers.
*/
void
-gst_x_overlay_got_desired_size (GstXOverlay *overlay, guint width, guint height)
+gst_x_overlay_got_desired_size (GstXOverlay * overlay, guint width,
+ guint height)
{
g_return_if_fail (GST_IS_X_OVERLAY (overlay));
-
+
g_signal_emit (G_OBJECT (overlay),
- gst_x_overlay_signals[DESIRED_SIZE], 0, width, height);
+ gst_x_overlay_signals[DESIRED_SIZE], 0, width, height);
}
/**
* in the drawable even if the pipeline is PAUSED.
*/
void
-gst_x_overlay_expose (GstXOverlay *overlay)
+gst_x_overlay_expose (GstXOverlay * overlay)
{
GstXOverlayClass *klass = GST_X_OVERLAY_GET_CLASS (overlay);
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_TYPE_X_OVERLAY \
(gst_x_overlay_get_type ())
#define GST_X_OVERLAY(obj) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_X_OVERLAY))
#define GST_X_OVERLAY_GET_CLASS(inst) \
(G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_X_OVERLAY, GstXOverlayClass))
-
typedef struct _GstXOverlay GstXOverlay;
-typedef struct _GstXOverlayClass {
+typedef struct _GstXOverlayClass
+{
GTypeInterface klass;
/* virtual functions */
- void (* set_xwindow_id) (GstXOverlay *overlay,
- gulong xwindow_id);
+ void (*set_xwindow_id) (GstXOverlay * overlay, gulong xwindow_id);
/* optional virtual functions */
- void (* get_desired_size) (GstXOverlay *overlay,
- guint *width,
- guint *height);
- void (* expose) (GstXOverlay *overlay);
-
+ void (*get_desired_size) (GstXOverlay * overlay,
+ guint * width, guint * height);
+ void (*expose) (GstXOverlay * overlay);
+
/* signals */
- void (*have_xwindow_id) (GstXOverlay *overlay,
- gulong xwindow_id);
- void (* desired_size) (GstXOverlay *overlay,
- guint width,
- guint height);
+ void (*have_xwindow_id) (GstXOverlay * overlay, gulong xwindow_id);
+ void (*desired_size) (GstXOverlay * overlay, guint width, guint height);
gpointer _gst_reserved[GST_PADDING];
} GstXOverlayClass;
-GType gst_x_overlay_get_type (void);
+GType gst_x_overlay_get_type (void);
/* virtual class function wrappers */
-void gst_x_overlay_set_xwindow_id (GstXOverlay *overlay, gulong xwindow_id);
-void gst_x_overlay_get_desired_size (GstXOverlay *overlay, guint *width, guint *height);
-void gst_x_overlay_expose (GstXOverlay *overlay);
+void gst_x_overlay_set_xwindow_id (GstXOverlay * overlay, gulong xwindow_id);
+void gst_x_overlay_get_desired_size (GstXOverlay * overlay, guint * width,
+ guint * height);
+void gst_x_overlay_expose (GstXOverlay * overlay);
/* public methods to fire signals */
-void gst_x_overlay_got_xwindow_id (GstXOverlay *overlay, gulong xwindow_id);
-void gst_x_overlay_got_desired_size (GstXOverlay *overlay, guint width, guint height);
+void gst_x_overlay_got_xwindow_id (GstXOverlay * overlay, gulong xwindow_id);
+void gst_x_overlay_got_desired_size (GstXOverlay * overlay, guint width,
+ guint height);
G_END_DECLS
-
#endif /* __GST_X_OVERLAY_H__ */
#define NUM_CLIPS 1024
-static void gst_x_window_listener_class_init (GstXWindowListenerClass *klass);
-static void gst_x_window_listener_init (GstXWindowListener *xwin);
-static void gst_x_window_listener_dispose (GObject *object);
+static void gst_x_window_listener_class_init (GstXWindowListenerClass * klass);
+static void gst_x_window_listener_init (GstXWindowListener * xwin);
+static void gst_x_window_listener_dispose (GObject * object);
-static void gst_xwin_start (GstXWindowListener *xwin);
-static void gst_xwin_stop (GstXWindowListener *xwin);
+static void gst_xwin_start (GstXWindowListener * xwin);
+static void gst_xwin_stop (GstXWindowListener * xwin);
static GObjectClass *parent_class = NULL;
x_window_listener_type =
g_type_register_static (G_TYPE_OBJECT,
- "GstXWindowListener",
- &x_window_listener_info, 0);
+ "GstXWindowListener", &x_window_listener_info, 0);
}
return x_window_listener_type;
}
static void
-gst_x_window_listener_class_init (GstXWindowListenerClass *klass)
+gst_x_window_listener_class_init (GstXWindowListenerClass * klass)
{
GObjectClass *object_klass = (GObjectClass *) klass;
}
static void
-gst_x_window_listener_init (GstXWindowListener *xwin)
+gst_x_window_listener_init (GstXWindowListener * xwin)
{
xwin->xwindow_id = 0;
xwin->display_name = NULL;
}
static void
-gst_x_window_listener_dispose (GObject *object)
+gst_x_window_listener_dispose (GObject * object)
{
GstXWindowListener *xwin = GST_X_WINDOW_LISTENER (object);
}
GstXWindowListener *
-gst_x_window_listener_new (gchar *display,
- MapWindowFunc map_window_func,
- SetWindowFunc set_window_func,
- gpointer private_data)
+gst_x_window_listener_new (gchar * display,
+ MapWindowFunc map_window_func,
+ SetWindowFunc set_window_func, gpointer private_data)
{
- GstXWindowListener *xwin =
- g_object_new (GST_TYPE_X_WINDOW_LISTENER, NULL);
+ GstXWindowListener *xwin = g_object_new (GST_TYPE_X_WINDOW_LISTENER, NULL);
xwin->display_name = g_strdup (display);
xwin->map_window_func = map_window_func;
}
void
-gst_x_window_listener_set_xid (GstXWindowListener *xwin,
- XID id)
+gst_x_window_listener_set_xid (GstXWindowListener * xwin, XID id)
{
g_return_if_fail (xwin != NULL);
xwin->xwindow_id = id;
- if (xwin->xwindow_id &&
- xwin->display_name &&
- xwin->display_name[0] == ':') {
+ if (xwin->xwindow_id && xwin->display_name && xwin->display_name[0] == ':') {
g_return_if_fail (xwin->map_window_func != NULL);
g_return_if_fail (xwin->set_window_func != NULL);
GST_DEBUG ("XWL: " format, ##args)
static void
-gst_xwin_set_overlay (GstXWindowListener *xwin,
- gboolean on)
+gst_xwin_set_overlay (GstXWindowListener * xwin, gboolean on)
{
xwin->map_window_func (xwin->private_data, on);
if (!xwin->ov_move && xwin->ov_map &&
xwin->ov_visibility == VisibilityUnobscured) {
g_mutex_unlock (xwin->main_lock);
- return FALSE; /* skip */
+ return FALSE; /* skip */
}
- if (xwin->ov_map &&
- xwin->ov_visibility != VisibilityFullyObscured) {
+ if (xwin->ov_map && xwin->ov_visibility != VisibilityFullyObscured) {
xwin->ov_refresh = TRUE;
}
xswa.override_redirect = True;
xswa.backing_store = NotUseful;
xswa.save_under = False;
- tmp = XCreateWindow (xwin->main_display,win, 0, 0,
- attr.width, attr.height, 0,
- CopyFromParent, InputOutput, CopyFromParent,
- (CWSaveUnder | CWBackingStore| CWOverrideRedirect ),
- &xswa);
+ tmp = XCreateWindow (xwin->main_display, win, 0, 0,
+ attr.width, attr.height, 0,
+ CopyFromParent, InputOutput, CopyFromParent,
+ (CWSaveUnder | CWBackingStore | CWOverrideRedirect), &xswa);
XMapWindow (xwin->main_display, tmp);
XUnmapWindow (xwin->main_display, tmp);
XDestroyWindow (xwin->main_display, tmp);
}
static int
-x11_error_dev_null (Display *display,
- XErrorEvent *event)
+x11_error_dev_null (Display * display, XErrorEvent * event)
{
- return 0;
+ return 0;
}
#define ADD_CLIP(_x, _y, _w, _h) \
} while (0);
static void
-gst_xwin_set_clips (GstXWindowListener *xwin)
+gst_xwin_set_clips (GstXWindowListener * xwin)
{
Window root, rroot, parent, *kids, me;
XWindowAttributes attr;
y1 = attr.y - xwin->y;
w1 = attr.width + 2 * attr.border_width;
h1 = attr.height + 2 * attr.border_width;
- if (((x1 + w1) < 0) || (x1 > xwin->w) ||
- ((y1 + h1) < 0) || (y1 > xwin->h))
+ if (((x1 + w1) < 0) || (x1 > xwin->w) || ((y1 + h1) < 0) || (y1 > xwin->h))
continue;
-
+
if (x1 < 0)
x1 = 0;
if (y1 < 0)
static gboolean
-gst_xwin_window (GstXWindowListener *xwin)
+gst_xwin_window (GstXWindowListener * xwin)
{
if (xwin->ov_map && xwin->ov_wmmap &&
xwin->ov_visibility != VisibilityFullyObscured) {
if (xwin->ov_conf) {
xwin->set_window_func (xwin->private_data,
- xwin->x, xwin->y,
- xwin->w, xwin->h,
- xwin->clips, xwin->num_clips);
+ xwin->x, xwin->y, xwin->w, xwin->h, xwin->clips, xwin->num_clips);
if (!xwin->ov_visible)
- gst_xwin_set_overlay (xwin, TRUE);
+ gst_xwin_set_overlay (xwin, TRUE);
g_mutex_lock (xwin->main_lock);
if (xwin->ov_refresh_id)
- g_source_remove (xwin->ov_refresh_id);
+ g_source_remove (xwin->ov_refresh_id);
xwin->ov_refresh_id =
- g_timeout_add (200, (GSourceFunc) gst_xwin_refresh,
- (gpointer) xwin);
+ g_timeout_add (200, (GSourceFunc) gst_xwin_refresh, (gpointer) xwin);
xwin->ov_conf = FALSE;
g_mutex_lock (xwin->main_lock);
if (xwin->ov_refresh_id)
- g_source_remove (xwin->ov_refresh_id);
+ g_source_remove (xwin->ov_refresh_id);
xwin->ov_refresh_id =
- g_timeout_add (200, (GSourceFunc) gst_xwin_refresh,
- (gpointer) xwin);
+ g_timeout_add (200, (GSourceFunc) gst_xwin_refresh, (gpointer) xwin);
xwin->ov_conf = FALSE;
}
static void
-gst_xwin_configure (GstXWindowListener *xwin)
+gst_xwin_configure (GstXWindowListener * xwin)
{
#if 0
/* This part is disabled, because the idle task will be done
* in the main thread instead of here. */
if (!xwin->ov_conf_id)
xwin->ov_conf_id =
- g_idle_add ((GSourceFunc) gst_rec_xoverlay_window,
- (gpointer) xwin);
+ g_idle_add ((GSourceFunc) gst_rec_xoverlay_window, (gpointer) xwin);
#endif
gst_xwin_window ((gpointer) xwin);
}
static void
-gst_xwin_resize (GstXWindowListener *xwin)
+gst_xwin_resize (GstXWindowListener * xwin)
{
Drawable drawable, parent, *kids, root;
guint numkids;
XWindowAttributes attr;
- XGetWindowAttributes (xwin->display,
- xwin->xwindow_id, &attr);
- XMoveResizeWindow (xwin->display, xwin->child,
- 0, 0, attr.width, attr.height);
+ XGetWindowAttributes (xwin->display, xwin->xwindow_id, &attr);
+ XMoveResizeWindow (xwin->display, xwin->child, 0, 0, attr.width, attr.height);
/* set the video window - the first clip is our own window */
xwin->x = 0;
drawable = xwin->child;
while (1) {
- XQueryTree (xwin->display, drawable,
- &root, &parent, &kids, &numkids);
+ XQueryTree (xwin->display, drawable, &root, &parent, &kids, &numkids);
if (numkids)
- XFree(kids);
+ XFree (kids);
drawable = parent;
XGetWindowAttributes (xwin->display, drawable, &attr);
xwin->x += attr.x;
}
static void
-gst_xwin_init_window (GstXWindowListener *xwin)
+gst_xwin_init_window (GstXWindowListener * xwin)
{
XWindowAttributes attr;
xwin->display = XOpenDisplay (xwin->display_name);
/* window */
- XGetWindowAttributes (xwin->display,
- xwin->xwindow_id, &attr);
+ XGetWindowAttributes (xwin->display, xwin->xwindow_id, &attr);
xwin->child = XCreateSimpleWindow (xwin->display,
- xwin->xwindow_id, 0, 0,
- attr.width, attr.height, 0, 0, 0);
+ xwin->xwindow_id, 0, 0, attr.width, attr.height, 0, 0, 0);
/* listen to certain X events */
- XSelectInput (xwin->display, xwin->xwindow_id,
- StructureNotifyMask);
+ XSelectInput (xwin->display, xwin->xwindow_id, StructureNotifyMask);
XSelectInput (xwin->display, xwin->child,
- VisibilityChangeMask | StructureNotifyMask);
+ VisibilityChangeMask | StructureNotifyMask);
XSelectInput (xwin->display, DefaultRootWindow (xwin->display),
- VisibilityChangeMask | StructureNotifyMask |
- SubstructureNotifyMask);
+ VisibilityChangeMask | StructureNotifyMask | SubstructureNotifyMask);
/* show */
XMapWindow (xwin->display, xwin->child);
}
static void
-gst_xwin_exit_window (GstXWindowListener *xwin)
+gst_xwin_exit_window (GstXWindowListener * xwin)
{
/* disable overlay */
gst_xwin_set_overlay (xwin, FALSE);
break;
if ((event.type == ConfigureNotify &&
- event.xconfigure.window == xwin->xwindow_id) ||
- (event.type == MapNotify &&
- event.xmap.window == xwin->xwindow_id) ||
- (event.type == UnmapNotify &&
- event.xunmap.window == xwin->xwindow_id)) {
+ event.xconfigure.window == xwin->xwindow_id) ||
+ (event.type == MapNotify &&
+ event.xmap.window == xwin->xwindow_id) ||
+ (event.type == UnmapNotify &&
+ event.xunmap.window == xwin->xwindow_id)) {
/* the 'parent' window, i.e. the widget provided by client */
switch (event.type) {
- case MapNotify:
- xwin->ov_map = TRUE;
- xwin->ov_conf = TRUE;
- gst_xwin_configure (xwin);
- break;
-
- case UnmapNotify:
- xwin->ov_map = FALSE;
- xwin->ov_conf = TRUE;
- gst_xwin_configure (xwin);
- break;
-
- case ConfigureNotify:
- gst_xwin_resize (xwin);
- break;
-
- default:
- /* nothing */
- break;
+ case MapNotify:
+ xwin->ov_map = TRUE;
+ xwin->ov_conf = TRUE;
+ gst_xwin_configure (xwin);
+ break;
+
+ case UnmapNotify:
+ xwin->ov_map = FALSE;
+ xwin->ov_conf = TRUE;
+ gst_xwin_configure (xwin);
+ break;
+
+ case ConfigureNotify:
+ gst_xwin_resize (xwin);
+ break;
+
+ default:
+ /* nothing */
+ break;
}
} else if (event.xany.window == xwin->child) {
/* our own private window */
switch (event.type) {
- case Expose:
- if (!event.xexpose.count) {
- if (xwin->ov_refresh) {
- xwin->ov_refresh = FALSE;
- } else {
- xwin->ov_conf = TRUE;
- gst_xwin_configure (xwin);
- }
- }
- break;
-
- case VisibilityNotify:
- xwin->ov_visibility = event.xvisibility.state;
- if (xwin->ov_refresh) {
- if (event.xvisibility.state != VisibilityFullyObscured)
- xwin->ov_refresh = FALSE;
- } else {
- xwin->ov_conf = TRUE;
- gst_xwin_configure (xwin);
- }
- break;
-
- default:
- /* nothing */
- break;
+ case Expose:
+ if (!event.xexpose.count) {
+ if (xwin->ov_refresh) {
+ xwin->ov_refresh = FALSE;
+ } else {
+ xwin->ov_conf = TRUE;
+ gst_xwin_configure (xwin);
+ }
+ }
+ break;
+
+ case VisibilityNotify:
+ xwin->ov_visibility = event.xvisibility.state;
+ if (xwin->ov_refresh) {
+ if (event.xvisibility.state != VisibilityFullyObscured)
+ xwin->ov_refresh = FALSE;
+ } else {
+ xwin->ov_conf = TRUE;
+ gst_xwin_configure (xwin);
+ }
+ break;
+
+ default:
+ /* nothing */
+ break;
}
} else {
/* root window */
switch (event.type) {
- case MapNotify:
- case UnmapNotify:
- /* are we still visible? */
- if (!xwin->ov_refresh) {
- XWindowAttributes attr;
- gboolean on;
- XGetWindowAttributes (xwin->display,
- xwin->xwindow_id, &attr);
- on = (attr.map_state == IsViewable);
- xwin->ov_wmmap = on;
- xwin->ov_conf = TRUE;
- gst_xwin_configure (xwin);
- }
- break;
-
- case ConfigureNotify:
- if (!xwin->ov_refresh) {
- gst_xwin_resize (xwin);
- }
- break;
-
- default:
- /* nothing */
- break;
+ case MapNotify:
+ case UnmapNotify:
+ /* are we still visible? */
+ if (!xwin->ov_refresh) {
+ XWindowAttributes attr;
+ gboolean on;
+
+ XGetWindowAttributes (xwin->display, xwin->xwindow_id, &attr);
+ on = (attr.map_state == IsViewable);
+ xwin->ov_wmmap = on;
+ xwin->ov_conf = TRUE;
+ gst_xwin_configure (xwin);
+ }
+ break;
+
+ case ConfigureNotify:
+ if (!xwin->ov_refresh) {
+ gst_xwin_resize (xwin);
+ }
+ break;
+
+ default:
+ /* nothing */
+ break;
}
}
}
}
static void
-gst_xwin_start (GstXWindowListener *xwin)
+gst_xwin_start (GstXWindowListener * xwin)
{
DEBUG ("Starting XWindow listener");
* event handler after we've stopped it */
xwin->main_lock = g_mutex_new ();
xwin->main_display = XOpenDisplay (xwin->display_name);
- xwin->thread = g_thread_create (gst_xwin_thread,
- (gpointer) xwin,
- TRUE, NULL);
+ xwin->thread = g_thread_create (gst_xwin_thread, (gpointer) xwin, TRUE, NULL);
DEBUG ("Started X-overlay");
}
static void
-gst_xwin_stop (GstXWindowListener *xwin)
+gst_xwin_stop (GstXWindowListener * xwin)
{
DEBUG ("Stopping XWindow listener");
*/
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "xwindowlistener",
- "X11-based XWindow event/motion listener",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "xwindowlistener",
+ "X11-based XWindow event/motion listener",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
#include <X11/Xlib.h>
G_BEGIN_DECLS
-
#define GST_TYPE_X_WINDOW_LISTENER \
(gst_x_window_listener_get_type())
#define GST_X_WINDOW_LISTENER(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_X_WINDOW_LISTENER))
#define GST_IS_X_WINDOW_LISTENER_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_X_WINDOW_LISTENER))
-
-typedef struct _GstXWindowListener GstXWindowListener;
-typedef struct _GstXWindowListenerClass GstXWindowListenerClass;
-typedef struct _GstXWindowClip GstXWindowClip;
-typedef void (* MapWindowFunc) (gpointer your_data,
- gboolean visible);
-typedef void (* SetWindowFunc) (gpointer your_data,
- gint x, gint y,
- gint w, gint h,
- GstXWindowClip *clips,
- gint num_clips);
-
-struct _GstXWindowClip {
- gint32 x_offset,
- y_offset,
- width,
- height;
+typedef struct _GstXWindowListener GstXWindowListener;
+typedef struct _GstXWindowListenerClass GstXWindowListenerClass;
+typedef struct _GstXWindowClip GstXWindowClip;
+typedef void (*MapWindowFunc) (gpointer your_data, gboolean visible);
+typedef void (*SetWindowFunc) (gpointer your_data,
+ gint x, gint y, gint w, gint h, GstXWindowClip * clips, gint num_clips);
+
+struct _GstXWindowClip
+{
+ gint32 x_offset, y_offset, width, height;
gpointer data;
};
-struct _GstXWindowListener {
- GObject parent;
+struct _GstXWindowListener
+{
+ GObject parent;
/* "per-instance virtual functions" */
MapWindowFunc map_window_func;
gpointer private_data;
/* general information of what we're doing */
- gchar *display_name;
- XID xwindow_id;
+ gchar *display_name;
+ XID xwindow_id;
/* one extra... */
Display *main_display;
- GMutex *main_lock;
+ GMutex *main_lock;
/* oh my g*d, this is going to be so horribly ugly */
GThread *thread;
/* the overlay window + own thread */
Display *display;
Drawable child;
- gboolean ov_conf,
- ov_map,
- ov_visible,
- ov_refresh,
- ov_move,
- ov_wmmap;
- gint ov_visibility;
- guint ov_conf_id,
- ov_refresh_id;
- gint x, y, w, h;
+ gboolean ov_conf, ov_map, ov_visible, ov_refresh, ov_move, ov_wmmap;
+ gint ov_visibility;
+ guint ov_conf_id, ov_refresh_id;
+ gint x, y, w, h;
GstXWindowClip *clips;
- gint num_clips;
+ gint num_clips;
};
-struct _GstXWindowListenerClass {
+struct _GstXWindowListenerClass
+{
GObjectClass parent;
};
-GType gst_x_window_listener_get_type (void);
-GstXWindowListener *
- gst_x_window_listener_new (gchar *display,
- MapWindowFunc map_window_func,
- SetWindowFunc set_window_func,
- gpointer private_data);
-void gst_x_window_listener_set_xid (GstXWindowListener *xwin,
- XID id);
+GType gst_x_window_listener_get_type (void);
+GstXWindowListener *gst_x_window_listener_new (gchar * display,
+ MapWindowFunc map_window_func,
+ SetWindowFunc set_window_func, gpointer private_data);
+void gst_x_window_listener_set_xid (GstXWindowListener * xwin, XID id);
G_END_DECLS
-
#endif /* __X_WINDOW_LISTENER_H__ */
};
/* CDXAParse signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
/* FILL ME */
};
-static GstStaticPadTemplate sink_templ =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ( "video/x-cdxa" )
-);
-
-static GstStaticPadTemplate src_templ =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ( "video/mpeg, "
- "systemstream = (boolean) TRUE"
- )
-);
-
-static void gst_cdxa_parse_base_init (gpointer g_class);
-static void gst_cdxa_parse_class_init (GstCDXAParseClass *klass);
-static void gst_cdxa_parse_init (GstCDXAParse *cdxa_parse);
-
-static void gst_cdxa_parse_loop (GstElement *element);
+static GstStaticPadTemplate sink_templ = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/x-cdxa")
+ );
-static GstElementStateReturn
- gst_cdxa_parse_change_state (GstElement *element);
+static GstStaticPadTemplate src_templ = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/mpeg, " "systemstream = (boolean) TRUE")
+ );
+
+static void gst_cdxa_parse_base_init (gpointer g_class);
+static void gst_cdxa_parse_class_init (GstCDXAParseClass * klass);
+static void gst_cdxa_parse_init (GstCDXAParse * cdxa_parse);
+
+static void gst_cdxa_parse_loop (GstElement * element);
+
+static GstElementStateReturn gst_cdxa_parse_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_cdxa_parse_signals[LAST_SIGNAL] = { 0 }; */
GType
-gst_cdxa_parse_get_type(void)
+gst_cdxa_parse_get_type (void)
{
static GType cdxa_parse_type = 0;
if (!cdxa_parse_type) {
static const GTypeInfo cdxa_parse_info = {
- sizeof(GstCDXAParseClass),
+ sizeof (GstCDXAParseClass),
gst_cdxa_parse_base_init,
NULL,
- (GClassInitFunc)gst_cdxa_parse_class_init,
+ (GClassInitFunc) gst_cdxa_parse_class_init,
NULL,
NULL,
- sizeof(GstCDXAParse),
+ sizeof (GstCDXAParse),
0,
- (GInstanceInitFunc)gst_cdxa_parse_init,
+ (GInstanceInitFunc) gst_cdxa_parse_init,
};
- cdxa_parse_type = g_type_register_static(GST_TYPE_ELEMENT, "GstCDXAParse", &cdxa_parse_info, 0);
+ cdxa_parse_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstCDXAParse",
+ &cdxa_parse_info, 0);
}
return cdxa_parse_type;
}
}
static void
-gst_cdxa_parse_class_init (GstCDXAParseClass *klass)
+gst_cdxa_parse_class_init (GstCDXAParseClass * 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);
-
+
gstelement_class->change_state = gst_cdxa_parse_change_state;
}
-static void
-gst_cdxa_parse_init (GstCDXAParse *cdxa_parse)
+static void
+gst_cdxa_parse_init (GstCDXAParse * cdxa_parse)
{
GST_FLAG_SET (cdxa_parse, GST_ELEMENT_EVENT_AWARE);
-
- cdxa_parse->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&sink_templ), "sink");
+
+ cdxa_parse->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get (&sink_templ),
+ "sink");
gst_element_add_pad (GST_ELEMENT (cdxa_parse), cdxa_parse->sinkpad);
- cdxa_parse->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&src_templ), "src");
+ cdxa_parse->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get (&src_templ),
+ "src");
gst_element_add_pad (GST_ELEMENT (cdxa_parse), cdxa_parse->srcpad);
gst_element_set_loop_function (GST_ELEMENT (cdxa_parse), gst_cdxa_parse_loop);
}
static gboolean
-gst_cdxa_parse_handle_event (GstCDXAParse *cdxa_parse)
+gst_cdxa_parse_handle_event (GstCDXAParse * cdxa_parse)
{
guint32 remaining;
GstEvent *event;
GstEventType type;
-
+
gst_bytestream_get_status (cdxa_parse->bs, &remaining, &event);
- type = event? GST_EVENT_TYPE (event) : GST_EVENT_UNKNOWN;
+ type = event ? GST_EVENT_TYPE (event) : GST_EVENT_UNKNOWN;
switch (type) {
case GST_EVENT_EOS:
*/
-typedef struct
+typedef struct
{
- gchar RIFF_tag[4];
+ gchar RIFF_tag[4];
guint32 riff_size;
- gchar CDXA_tag[4];
- gchar fmt_tag[4];
+ gchar CDXA_tag[4];
+ gchar fmt_tag[4];
guint32 fmt_size;
} CDXAParseHeader;
-
+
/*
A sectors is 2352 bytes long and is composed of:
*/
static void
-gst_cdxa_parse_loop (GstElement *element)
+gst_cdxa_parse_loop (GstElement * element)
{
GstCDXAParse *cdxa_parse;
CDXAParseHeader *header;
return;
cdxa_parse->riff_size = GUINT32_FROM_LE (header->riff_size);
- fmt_size = (GUINT32_FROM_LE (header->fmt_size) + 1)&~1;
+ fmt_size = (GUINT32_FROM_LE (header->fmt_size) + 1) & ~1;
/* flush the header + fmt_size bytes + 4 bytes "data" */
if (!gst_bytestream_flush (cdxa_parse->bs, 20 + fmt_size + 4))
return;
-
+
/* get the data size */
- got_bytes = gst_bytestream_peek_bytes (cdxa_parse->bs, (guint8**)&buf, 4);
+ got_bytes =
+ gst_bytestream_peek_bytes (cdxa_parse->bs, (guint8 **) & buf, 4);
if (got_bytes < 4)
return;
- cdxa_parse->data_size = GUINT32_FROM_LE (*((guint32 *)buf));
+ cdxa_parse->data_size = GUINT32_FROM_LE (*((guint32 *) buf));
/* flush the data size */
if (!gst_bytestream_flush (cdxa_parse->bs, 4))
g_warning ("cdxa_parse: size not multiple of %d bytes", CDXA_SECTOR_SIZE);
cdxa_parse->sectors = cdxa_parse->data_size / CDXA_SECTOR_SIZE;
-
+
cdxa_parse->state = CDXA_PARSE_DATA;
- }
- else {
+ } else {
GstBuffer *buf;
GstBuffer *outbuf;
guint32 got_bytes;
}
static GstElementStateReturn
-gst_cdxa_parse_change_state (GstElement *element)
+gst_cdxa_parse_change_state (GstElement * element)
{
GstCDXAParse *cdxa_parse = GST_CDXA_PARSE (element);
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
if (!gst_library_load ("gstbytestream"))
return FALSE;
- if (!gst_element_register (plugin, "cdxaparse", GST_RANK_NONE, GST_TYPE_CDXA_PARSE))
+ if (!gst_element_register (plugin, "cdxaparse", GST_RANK_NONE,
+ GST_TYPE_CDXA_PARSE))
return FALSE;
-
+
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "cdxaparse",
- "Parse a .dat file (VCD) into raw mpeg1",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN)
-
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "cdxaparse",
+ "Parse a .dat file (VCD) into raw mpeg1",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
#include <gst/bytestream/bytestream.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_CDXA_PARSE \
(gst_cdxa_parse_get_type())
#define CDXA_SECTOR_SIZE 2352
#define CDXA_DATA_SIZE 2324
-typedef enum
-{
- CDXA_PARSE_HEADER,
- CDXA_PARSE_DATA,
-} GstCDXAParseState;
+ typedef enum
+ {
+ CDXA_PARSE_HEADER,
+ CDXA_PARSE_DATA,
+ } GstCDXAParseState;
-typedef struct _GstCDXAParse GstCDXAParse;
-typedef struct _GstCDXAParseClass GstCDXAParseClass;
+ typedef struct _GstCDXAParse GstCDXAParse;
+ typedef struct _GstCDXAParseClass GstCDXAParseClass;
-struct _GstCDXAParse {
- GstElement element;
+ struct _GstCDXAParse
+ {
+ GstElement element;
- /* pads */
- GstPad *sinkpad, *srcpad;
+ /* pads */
+ GstPad *sinkpad, *srcpad;
- GstByteStream *bs;
+ GstByteStream *bs;
- GstCDXAParseState state;
+ GstCDXAParseState state;
- guint32 riff_size;
- guint32 data_size;
- guint32 sectors;
-};
+ guint32 riff_size;
+ guint32 data_size;
+ guint32 sectors;
+ };
-struct _GstCDXAParseClass {
- GstElementClass parent_class;
-};
+ struct _GstCDXAParseClass
+ {
+ GstElementClass parent_class;
+ };
-GType gst_cdxa_parse_get_type (void);
+ GType gst_cdxa_parse_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_CDXA_PARSE_H__ */
+#endif /* __GST_CDXA_PARSE_H__ */
typedef struct _GstChart GstChart;
typedef struct _GstChartClass GstChartClass;
-struct _GstChart {
+struct _GstChart
+{
GstElement element;
/* pads */
- GstPad *sinkpad,*srcpad;
+ GstPad *sinkpad, *srcpad;
/* the timestamp of the next frame */
guint64 next_time;
gint height;
gint samplerate;
- gdouble framerate; /* desired frame rate */
- gint samples_between_frames; /* number of samples between start of successive frames */
- gint samples_since_last_frame; /* number of samples between start of successive frames */
+ gdouble framerate; /* desired frame rate */
+ gint samples_between_frames; /* number of samples between start of successive frames */
+ gint samples_since_last_frame; /* number of samples between start of successive frames */
};
-struct _GstChartClass {
+struct _GstChartClass
+{
GstElementClass parent_class;
};
-GType gst_chart_get_type(void);
+GType gst_chart_get_type (void);
/* elementfactory information */
};
/* signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
/* FILL ME */
};
-static GstStaticPadTemplate src_factory =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ( GST_VIDEO_CAPS_RGB_16)
-);
-
-static GstStaticPadTemplate sink_factory =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-raw-int, "
- "endianness = (int) BYTE_ORDER, "
- "signed = (boolean) TRUE, "
- "width = (int) 16, "
- "depth = (int) 16, "
- "rate = (int) [ 8000, 96000 ], "
- "channels = (int) 1")
-);
-
-static void gst_chart_base_init (gpointer g_class);
-static void gst_chart_class_init (GstChartClass *klass);
-static void gst_chart_init (GstChart *chart);
-
-static void gst_chart_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void gst_chart_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
-
-static void gst_chart_chain (GstPad *pad, GstData *_data);
-
-static GstPadLinkReturn
- gst_chart_sinkconnect (GstPad *pad, const GstCaps *caps);
-static GstPadLinkReturn
- gst_chart_srcconnect (GstPad *pad, const GstCaps *caps);
+static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB_16)
+ );
+
+static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "endianness = (int) BYTE_ORDER, "
+ "signed = (boolean) TRUE, "
+ "width = (int) 16, "
+ "depth = (int) 16, "
+ "rate = (int) [ 8000, 96000 ], " "channels = (int) 1")
+ );
+
+static void gst_chart_base_init (gpointer g_class);
+static void gst_chart_class_init (GstChartClass * klass);
+static void gst_chart_init (GstChart * chart);
+
+static void gst_chart_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_chart_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+
+static void gst_chart_chain (GstPad * pad, GstData * _data);
+
+static GstPadLinkReturn
+gst_chart_sinkconnect (GstPad * pad, const GstCaps * caps);
+static GstPadLinkReturn
+gst_chart_srcconnect (GstPad * pad, const GstCaps * caps);
static GstElementClass *parent_class = NULL;
if (!type) {
static const GTypeInfo info = {
- sizeof(GstChartClass),
+ sizeof (GstChartClass),
gst_chart_base_init,
NULL,
- (GClassInitFunc)gst_chart_class_init,
+ (GClassInitFunc) gst_chart_class_init,
NULL,
NULL,
- sizeof(GstChart),
+ sizeof (GstChart),
0,
- (GInstanceInitFunc)gst_chart_init,
+ (GInstanceInitFunc) gst_chart_init,
};
- type = g_type_register_static(GST_TYPE_ELEMENT, "GstChart", &info, 0);
+ type = g_type_register_static (GST_TYPE_ELEMENT, "GstChart", &info, 0);
}
return type;
}
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&src_factory));
- gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&sink_factory));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&src_factory));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&sink_factory));
gst_element_class_set_details (element_class, &gst_chart_details);
}
static void
-gst_chart_class_init(GstChartClass *klass)
+gst_chart_class_init (GstChartClass * 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);
gobject_class->set_property = gst_chart_set_property;
gobject_class->get_property = gst_chart_get_property;
}
static void
-gst_chart_init (GstChart *chart)
+gst_chart_init (GstChart * chart)
{
/* create the sink and src pads */
- chart->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&sink_factory),
- "sink");
- chart->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&src_factory),
- "src");
+ chart->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get (&sink_factory),
+ "sink");
+ chart->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get (&src_factory),
+ "src");
gst_element_add_pad (GST_ELEMENT (chart), chart->sinkpad);
gst_element_add_pad (GST_ELEMENT (chart), chart->srcpad);
chart->height = 128;
chart->samplerate = -1;
- chart->framerate = 25; /* desired frame rate */
- chart->samples_between_frames = 0; /* number of samples between start of successive frames */
+ chart->framerate = 25; /* desired frame rate */
+ chart->samples_between_frames = 0; /* number of samples between start of successive frames */
chart->samples_since_last_frame = 0;
}
static GstPadLinkReturn
-gst_chart_sinkconnect (GstPad *pad, const GstCaps *caps)
+gst_chart_sinkconnect (GstPad * pad, const GstCaps * caps)
{
GstChart *chart;
GstStructure *structure;
gst_structure_get_int (structure, "rate", &chart->samplerate);
chart->samples_between_frames = chart->samplerate / chart->framerate;
- GST_DEBUG ("CHART: new sink caps: rate %d",
- chart->samplerate);
+ GST_DEBUG ("CHART: new sink caps: rate %d", chart->samplerate);
/*gst_chart_sync_parms (chart); */
/* */
return GST_PAD_LINK_OK;
}
static GstPadLinkReturn
-gst_chart_srcconnect (GstPad *pad, const GstCaps*caps)
+gst_chart_srcconnect (GstPad * pad, const GstCaps * caps)
{
GstChart *chart;
GstStructure *structure;
gst_structure_get_int (structure, "height", &chart->height);
GST_DEBUG ("CHART: new src caps: framerate %f, %dx%d",
- chart->framerate, chart->width, chart->height);
+ chart->framerate, chart->width, chart->height);
return GST_PAD_LINK_OK;
}
static void
-draw_chart_16bpp(guchar * output, gint width, gint height,
- gint16 * src_data, gint src_size)
+draw_chart_16bpp (guchar * output, gint width, gint height,
+ gint16 * src_data, gint src_size)
{
- gint i;
- guint16 *colstart;
- gint16 * in;
-
- GST_DEBUG ("CHART: drawing frame to %p, width = %d, height = %d, src_data = %p, src_size = %d",
- output, width, height, src_data, src_size);
-
- for (colstart = (guint16 *)output, in = (gint16 *)src_data, i = 0;
- i < width;
- colstart++, in++, i++) {
- guint16 * pos = colstart;
- gint h1;
-
- h1 = (((gint)(*in)) * height / (1 << 16)) + height / 2;
- if (h1 >= height) h1 = height;
-
- if (h1 < height / 2) {
- while (pos < colstart + h1 * width) {
- *pos = 0x0000;
- pos += width;
- }
- while (pos < colstart + height / 2 * width) {
- *pos = 0x07e0;
- pos += width;
- }
- while (pos < colstart + height * width) {
- *pos = 0x0000;
- pos += width;
- }
- } else {
- while (pos < colstart + height / 2 * width) {
- *pos = 0x0000;
- pos += width;
- }
- while (pos < colstart + h1 * width) {
- *pos = 0x07e0;
- pos += width;
- }
- while (pos < colstart + height * width) {
- *pos = 0x0000;
- pos += width;
- }
- }
+ gint i;
+ guint16 *colstart;
+ gint16 *in;
+
+ GST_DEBUG
+ ("CHART: drawing frame to %p, width = %d, height = %d, src_data = %p, src_size = %d",
+ output, width, height, src_data, src_size);
+
+ for (colstart = (guint16 *) output, in = (gint16 *) src_data, i = 0;
+ i < width; colstart++, in++, i++) {
+ guint16 *pos = colstart;
+ gint h1;
+
+ h1 = (((gint) (*in)) * height / (1 << 16)) + height / 2;
+ if (h1 >= height)
+ h1 = height;
+
+ if (h1 < height / 2) {
+ while (pos < colstart + h1 * width) {
+ *pos = 0x0000;
+ pos += width;
+ }
+ while (pos < colstart + height / 2 * width) {
+ *pos = 0x07e0;
+ pos += width;
+ }
+ while (pos < colstart + height * width) {
+ *pos = 0x0000;
+ pos += width;
+ }
+ } else {
+ while (pos < colstart + height / 2 * width) {
+ *pos = 0x0000;
+ pos += width;
+ }
+ while (pos < colstart + h1 * width) {
+ *pos = 0x07e0;
+ pos += width;
+ }
+ while (pos < colstart + height * width) {
+ *pos = 0x0000;
+ pos += width;
+ }
}
+ }
}
static void
-gst_chart_chain (GstPad *pad, GstData *_data)
+gst_chart_chain (GstPad * pad, GstData * _data)
{
GstBuffer *bufin = GST_BUFFER (_data);
GstChart *chart;
g_return_if_fail (bufin != NULL);
g_return_if_fail (pad != NULL);
- g_return_if_fail (GST_IS_PAD(pad));
- g_return_if_fail (GST_IS_CHART(GST_OBJECT_PARENT(pad)));
- chart = GST_CHART(GST_OBJECT_PARENT (pad));
+ g_return_if_fail (GST_IS_PAD (pad));
+ g_return_if_fail (GST_IS_CHART (GST_OBJECT_PARENT (pad)));
+ chart = GST_CHART (GST_OBJECT_PARENT (pad));
g_return_if_fail (chart != NULL);
GST_DEBUG ("CHART: chainfunc called");
- samples_in = GST_BUFFER_SIZE (bufin) / sizeof(gint16);
+ samples_in = GST_BUFFER_SIZE (bufin) / sizeof (gint16);
datain = (gint16 *) (GST_BUFFER_DATA (bufin));
GST_DEBUG ("input buffer has %d samples", samples_in);
if (chart->next_time <= GST_BUFFER_TIMESTAMP (bufin)) {
chart->samples_since_last_frame += samples_in;
if (chart->samples_between_frames <= chart->samples_since_last_frame) {
- chart->samples_since_last_frame = 0;
-
- /* get data to draw into buffer */
- if (samples_in >= chart->width) {
- /* make a new buffer for the output */
- bufout = gst_buffer_new ();
- sizeout = chart->bpp / 8 * chart->width * chart->height;
- dataout = g_malloc (sizeout);
- GST_BUFFER_SIZE(bufout) = sizeout;
- GST_BUFFER_DATA(bufout) = dataout;
- GST_DEBUG ("CHART: made new buffer: size %d, width %d, height %d",
- sizeout, chart->width, chart->height);
-
- /* take data and draw to new buffer */
- /* FIXME: call different routines for different properties */
- draw_chart_16bpp(dataout, chart->width, chart->height, (gint16 *)datain, samples_in);
-
- gst_buffer_unref(bufin);
-
- /* set timestamp */
- GST_BUFFER_TIMESTAMP (bufout) = chart->next_time;
-
- GST_DEBUG ("CHART: outputting buffer");
- /* output buffer */
- GST_BUFFER_FLAG_SET (bufout, GST_BUFFER_READONLY);
- gst_pad_push (chart->srcpad, GST_DATA (bufout));
- }
+ chart->samples_since_last_frame = 0;
+
+ /* get data to draw into buffer */
+ if (samples_in >= chart->width) {
+ /* make a new buffer for the output */
+ bufout = gst_buffer_new ();
+ sizeout = chart->bpp / 8 * chart->width * chart->height;
+ dataout = g_malloc (sizeout);
+ GST_BUFFER_SIZE (bufout) = sizeout;
+ GST_BUFFER_DATA (bufout) = dataout;
+ GST_DEBUG ("CHART: made new buffer: size %d, width %d, height %d",
+ sizeout, chart->width, chart->height);
+
+ /* take data and draw to new buffer */
+ /* FIXME: call different routines for different properties */
+ draw_chart_16bpp (dataout, chart->width, chart->height, (gint16 *) datain,
+ samples_in);
+
+ gst_buffer_unref (bufin);
+
+ /* set timestamp */
+ GST_BUFFER_TIMESTAMP (bufout) = chart->next_time;
+
+ GST_DEBUG ("CHART: outputting buffer");
+ /* output buffer */
+ GST_BUFFER_FLAG_SET (bufout, GST_BUFFER_READONLY);
+ gst_pad_push (chart->srcpad, GST_DATA (bufout));
+ }
} else {
- GST_DEBUG ("CHART: skipping buffer");
- gst_buffer_unref(bufin);
+ GST_DEBUG ("CHART: skipping buffer");
+ gst_buffer_unref (bufin);
}
GST_DEBUG ("CHART: exiting chainfunc");
}
static void
-gst_chart_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_chart_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstChart *chart;
}
static void
-gst_chart_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_chart_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstChart *chart;
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
if (!gst_element_register (plugin, "chart", GST_RANK_NONE, GST_TYPE_CHART))
return FALSE;
-
+
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "chart",
- "Takes frames of data and outputs video frames of a chart of data",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "chart",
+ "Takes frames of data and outputs video frames of a chart of data",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
static GstColorspaceFormat gst_colorspace_formats[] = {
- { GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV("I420")) },
- { GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV("YV12")) },
- { GST_STATIC_CAPS (GST_VIDEO_CAPS_xRGB) },
- { GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB) },
- { GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB_16) },
+ {GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420"))},
+ {GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("YV12"))},
+ {GST_STATIC_CAPS (GST_VIDEO_CAPS_xRGB)},
+ {GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB)},
+ {GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB_16)},
};
static GstColorspaceConverter gst_colorspace_converters[] = {
- { GST_COLORSPACE_I420, GST_COLORSPACE_RGB32, gst_colorspace_I420_to_rgb32 },
- { GST_COLORSPACE_YV12, GST_COLORSPACE_RGB32, gst_colorspace_YV12_to_rgb32 },
- { GST_COLORSPACE_I420, GST_COLORSPACE_RGB24, gst_colorspace_I420_to_rgb24 },
- { GST_COLORSPACE_YV12, GST_COLORSPACE_RGB24, gst_colorspace_YV12_to_rgb24 },
- { GST_COLORSPACE_I420, GST_COLORSPACE_RGB16, gst_colorspace_I420_to_rgb16 },
- { GST_COLORSPACE_YV12, GST_COLORSPACE_RGB16, gst_colorspace_YV12_to_rgb16 },
+ {GST_COLORSPACE_I420, GST_COLORSPACE_RGB32, gst_colorspace_I420_to_rgb32},
+ {GST_COLORSPACE_YV12, GST_COLORSPACE_RGB32, gst_colorspace_YV12_to_rgb32},
+ {GST_COLORSPACE_I420, GST_COLORSPACE_RGB24, gst_colorspace_I420_to_rgb24},
+ {GST_COLORSPACE_YV12, GST_COLORSPACE_RGB24, gst_colorspace_YV12_to_rgb24},
+ {GST_COLORSPACE_I420, GST_COLORSPACE_RGB16, gst_colorspace_I420_to_rgb16},
+ {GST_COLORSPACE_YV12, GST_COLORSPACE_RGB16, gst_colorspace_YV12_to_rgb16},
};
-static GstElementDetails colorspace_details = GST_ELEMENT_DETAILS (
- "Colorspace converter",
- "Filter/Converter/Video",
- "Converts video from one colorspace to another",
- "Wim Taymans <wim.taymans@chello.be>"
-);
+static GstElementDetails colorspace_details =
+GST_ELEMENT_DETAILS ("Colorspace converter",
+ "Filter/Converter/Video",
+ "Converts video from one colorspace to another",
+ "Wim Taymans <wim.taymans@chello.be>");
static GstStaticPadTemplate gst_colorspace_sink_template =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
+GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("{ I420, YV12 }"))
-);
+ );
static GstStaticPadTemplate gst_colorspace_src_template =
-GST_STATIC_PAD_TEMPLATE (
- "src",
+ GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- GST_VIDEO_CAPS_xRGB "; "
- GST_VIDEO_CAPS_BGRx "; "
- GST_VIDEO_CAPS_RGB "; "
- GST_VIDEO_CAPS_RGB_16
- )
-);
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_xRGB "; "
+ GST_VIDEO_CAPS_BGRx "; " GST_VIDEO_CAPS_RGB "; " GST_VIDEO_CAPS_RGB_16)
+ );
/* Stereo signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_SOURCE,
ARG_DEST,
};
-static void gst_colorspace_base_init (gpointer g_class);
-static void gst_colorspace_class_init (GstColorspaceClass *klass);
-static void gst_colorspace_init (GstColorspace *space);
+static void gst_colorspace_base_init (gpointer g_class);
+static void gst_colorspace_class_init (GstColorspaceClass * klass);
+static void gst_colorspace_init (GstColorspace * space);
-static void gst_colorspace_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_colorspace_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static void gst_colorspace_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_colorspace_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
static GstPadLinkReturn
- gst_colorspace_link (GstPad *pad, const GstCaps *caps);
-static void gst_colorspace_chain (GstPad *pad, GstData *_data);
-static GstElementStateReturn
- gst_colorspace_change_state (GstElement *element);
+gst_colorspace_link (GstPad * pad, const GstCaps * caps);
+static void gst_colorspace_chain (GstPad * pad, GstData * _data);
+static GstElementStateReturn gst_colorspace_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_colorspace_signals[LAST_SIGNAL] = { 0 }; */
#if 0
-static gboolean
-colorspace_setup_converter (GstColorspace *space, GstCaps *from_caps, GstCaps *to_caps)
+static gboolean
+colorspace_setup_converter (GstColorspace * space, GstCaps * from_caps,
+ GstCaps * to_caps)
{
guint32 from_space, to_space;
GstStructure *from_struct;
from_struct = gst_caps_get_structure (from_caps, 0);
to_struct = gst_caps_get_structure (to_caps, 0);
- from_space = GST_MAKE_FOURCC ('R','G','B',' ');
+ from_space = GST_MAKE_FOURCC ('R', 'G', 'B', ' ');
gst_structure_get_fourcc (from_struct, "format", &from_space);
- to_space = GST_MAKE_FOURCC ('R','G','B',' ');
+ to_space = GST_MAKE_FOURCC ('R', 'G', 'B', ' ');
gst_structure_get_fourcc (to_struct, "format", &to_space);
- GST_INFO ("set up converter for " GST_FOURCC_FORMAT
- " (%08x) to " GST_FOURCC_FORMAT " (%08x)",
- GST_FOURCC_ARGS (from_space), from_space,
- GST_FOURCC_ARGS (to_space), to_space);
+ GST_INFO ("set up converter for " GST_FOURCC_FORMAT
+ " (%08x) to " GST_FOURCC_FORMAT " (%08x)",
+ GST_FOURCC_ARGS (from_space), from_space,
+ GST_FOURCC_ARGS (to_space), to_space);
switch (from_space) {
- case GST_MAKE_FOURCC ('R','G','B',' '):
+ case GST_MAKE_FOURCC ('R', 'G', 'B', ' '):
{
gint from_bpp;
-
+
gst_structure_get_int (from_struct, "bpp", &from_bpp);
switch (to_space) {
- case GST_MAKE_FOURCC ('R','G','B',' '):
+ case GST_MAKE_FOURCC ('R', 'G', 'B', ' '):
#ifdef HAVE_HERMES
- {
- gint to_bpp;
-
- gst_structure_get_int (to_struct, "bpp", &to_bpp);
+ {
+ gint to_bpp;
+
+ gst_structure_get_int (to_struct, "bpp", &to_bpp);
- gst_structure_get_int (from_struct, "red_mask", &space->source.r);
+ gst_structure_get_int (from_struct, "red_mask", &space->source.r);
gst_structure_get_int (from_struct, "green_mask", &space->source.g);
- gst_structure_get_int (from_struct, "blue_mask", &space->source.b);
+ gst_structure_get_int (from_struct, "blue_mask", &space->source.b);
space->source.a = 0;
space->srcbpp = space->source.bits = from_bpp;
space->source.indexed = 0;
space->source.has_colorkey = 0;
- GST_INFO ( "source red mask %08x", space->source.r);
- GST_INFO ( "source green mask %08x", space->source.g);
- GST_INFO ( "source blue mask %08x", space->source.b);
- GST_INFO ( "source bpp %08x", space->srcbpp);
+ GST_INFO ("source red mask %08x", space->source.r);
+ GST_INFO ("source green mask %08x", space->source.g);
+ GST_INFO ("source blue mask %08x", space->source.b);
+ GST_INFO ("source bpp %08x", space->srcbpp);
- gst_structure_get_int (to_struct, "red_mask", &space->dest.r);
+ gst_structure_get_int (to_struct, "red_mask", &space->dest.r);
gst_structure_get_int (to_struct, "green_mask", &space->dest.g);
- gst_structure_get_int (to_struct, "blue_mask", &space->dest.b);
+ gst_structure_get_int (to_struct, "blue_mask", &space->dest.b);
space->dest.a = 0;
space->destbpp = space->dest.bits = to_bpp;
space->dest.indexed = 0;
space->dest.has_colorkey = 0;
- GST_INFO ( "dest red mask %08x", space->dest.r);
- GST_INFO ( "dest green mask %08x", space->dest.g);
- GST_INFO ( "dest blue mask %08x", space->dest.b);
- GST_INFO ( "dest bpp %08x", space->destbpp);
+ GST_INFO ("dest red mask %08x", space->dest.r);
+ GST_INFO ("dest green mask %08x", space->dest.g);
+ GST_INFO ("dest blue mask %08x", space->dest.b);
+ GST_INFO ("dest bpp %08x", space->destbpp);
- if (!Hermes_ConverterRequest (space->h_handle, &space->source, &space->dest)) {
+ if (!Hermes_ConverterRequest (space->h_handle, &space->source,
+ &space->dest)) {
g_warning ("Hermes: could not get converter\n");
return FALSE;
}
- GST_INFO ( "converter set up");
- space->type = GST_COLORSPACE_HERMES;
+ GST_INFO ("converter set up");
+ space->type = GST_COLORSPACE_HERMES;
return TRUE;
}
#else
g_warning ("colorspace: compiled without hermes!");
return FALSE;
#endif
- case GST_MAKE_FOURCC ('Y','V','1','2'):
+ case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
if (from_bpp == 32) {
- space->type = GST_COLORSPACE_RGB32_YV12;
+ space->type = GST_COLORSPACE_RGB32_YV12;
space->destbpp = 12;
return TRUE;
}
- case GST_MAKE_FOURCC ('I','4','2','0'):
+ case GST_MAKE_FOURCC ('I', '4', '2', '0'):
if (from_bpp == 32) {
- space->type = GST_COLORSPACE_RGB32_I420;
+ space->type = GST_COLORSPACE_RGB32_I420;
space->destbpp = 12;
return TRUE;
}
- case GST_MAKE_FOURCC ('Y','U','Y','2'):
- GST_INFO ( "colorspace: RGB to YUV with bpp %d not implemented!!", from_bpp);
+ case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
+ GST_INFO ("colorspace: RGB to YUV with bpp %d not implemented!!",
+ from_bpp);
return FALSE;
}
break;
}
- case GST_MAKE_FOURCC ('I','4','2','0'):
+ case GST_MAKE_FOURCC ('I', '4', '2', '0'):
switch (to_space) {
- case GST_MAKE_FOURCC ('R','G','B',' '):
- GST_INFO ( "colorspace: YUV to RGB");
+ case GST_MAKE_FOURCC ('R', 'G', 'B', ' '):
+ GST_INFO ("colorspace: YUV to RGB");
gst_structure_get_int (to_struct, "bpp", &space->destbpp);
- space->converter = gst_colorspace_yuv2rgb_get_converter (from_caps, to_caps);
- space->type = GST_COLORSPACE_YUV_RGB;
+ space->converter =
+ gst_colorspace_yuv2rgb_get_converter (from_caps, to_caps);
+ space->type = GST_COLORSPACE_YUV_RGB;
return TRUE;
- case GST_MAKE_FOURCC ('I','4','2','0'):
- space->type = GST_COLORSPACE_NONE;
+ case GST_MAKE_FOURCC ('I', '4', '2', '0'):
+ space->type = GST_COLORSPACE_NONE;
space->destbpp = 12;
return TRUE;
- case GST_MAKE_FOURCC ('Y','V','1','2'):
- space->type = GST_COLORSPACE_420_SWAP;
+ case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
+ space->type = GST_COLORSPACE_420_SWAP;
space->destbpp = 12;
return TRUE;
}
break;
- case GST_MAKE_FOURCC ('Y','U','Y','2'):
+ case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
switch (to_space) {
- case GST_MAKE_FOURCC ('I','4','2','0'):
- space->type = GST_COLORSPACE_YUY2_I420;
+ case GST_MAKE_FOURCC ('I', '4', '2', '0'):
+ space->type = GST_COLORSPACE_YUY2_I420;
space->destbpp = 12;
return TRUE;
- case GST_MAKE_FOURCC ('Y','U','Y','2'):
- space->type = GST_COLORSPACE_NONE;
+ case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
+ space->type = GST_COLORSPACE_NONE;
space->destbpp = 16;
return TRUE;
- case GST_MAKE_FOURCC ('R','G','B',' '):
- GST_INFO ( "colorspace: YUY2 to RGB not implemented!!");
+ case GST_MAKE_FOURCC ('R', 'G', 'B', ' '):
+ GST_INFO ("colorspace: YUY2 to RGB not implemented!!");
return FALSE;
}
break;
- case GST_MAKE_FOURCC ('Y','V','1','2'):
+ case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
switch (to_space) {
- case GST_MAKE_FOURCC ('R','G','B',' '):
- GST_INFO ( "colorspace: YV12 to RGB");
+ case GST_MAKE_FOURCC ('R', 'G', 'B', ' '):
+ GST_INFO ("colorspace: YV12 to RGB");
gst_structure_get_int (to_struct, "bpp", &space->destbpp);
- space->converter = gst_colorspace_yuv2rgb_get_converter (from_caps, to_caps);
- space->type = GST_COLORSPACE_YUV_RGB;
+ space->converter =
+ gst_colorspace_yuv2rgb_get_converter (from_caps, to_caps);
+ space->type = GST_COLORSPACE_YUV_RGB;
return TRUE;
- case GST_MAKE_FOURCC ('I','4','2','0'):
- space->type = GST_COLORSPACE_420_SWAP;
+ case GST_MAKE_FOURCC ('I', '4', '2', '0'):
+ space->type = GST_COLORSPACE_420_SWAP;
space->destbpp = 12;
return TRUE;
- case GST_MAKE_FOURCC ('Y','V','1','2'):
- space->type = GST_COLORSPACE_NONE;
+ case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
+ space->type = GST_COLORSPACE_NONE;
space->destbpp = 12;
return TRUE;
}
#endif
static GstCaps *
-gst_colorspace_caps_remove_format_info (GstCaps *caps, const char *media_type)
+gst_colorspace_caps_remove_format_info (GstCaps * caps, const char *media_type)
{
int i;
GstStructure *structure;
GstCaps *rgbcaps;
- for (i=0; i<gst_caps_get_size (caps); i++) {
+ for (i = 0; i < gst_caps_get_size (caps); i++) {
structure = gst_caps_get_structure (caps, i);
gst_structure_set_name (structure, media_type);
return rgbcaps;
}
-static GstCaps*
-gst_colorspace_getcaps (GstPad *pad)
+static GstCaps *
+gst_colorspace_getcaps (GstPad * pad)
{
GstColorspace *space;
GstPad *otherpad;
GstCaps *othercaps;
GstCaps *caps;
-
+
space = GST_COLORSPACE (gst_pad_get_parent (pad));
otherpad = (pad == space->srcpad) ? space->sinkpad : space->srcpad;
}
static GstColorSpaceFormatType
-gst_colorspace_get_format (const GstCaps *caps)
+gst_colorspace_get_format (const GstCaps * caps)
{
int i;
- for(i=0; i<G_N_ELEMENTS (gst_colorspace_formats); i++) {
+ for (i = 0; i < G_N_ELEMENTS (gst_colorspace_formats); i++) {
GstCaps *icaps;
GstCaps *fcaps;
-
- fcaps = gst_caps_copy (gst_static_caps_get (
- &gst_colorspace_formats[i].caps));
+
+ fcaps =
+ gst_caps_copy (gst_static_caps_get (&gst_colorspace_formats[i].caps));
icaps = gst_caps_intersect (caps, fcaps);
if (!gst_caps_is_empty (icaps)) {
gst_caps_free (icaps);
}
- g_assert_not_reached();
+ g_assert_not_reached ();
return -1;
}
#define ROUND_UP_8(x) (((x)+7)&~7)
static int
-gst_colorspace_format_get_size(GstColorSpaceFormatType index, int width,
+gst_colorspace_format_get_size (GstColorSpaceFormatType index, int width,
int height)
{
int size;
case GST_COLORSPACE_I420:
case GST_COLORSPACE_YV12:
size = ROUND_UP_4 (width) * ROUND_UP_2 (height);
- size += ROUND_UP_8 (width)/2 * ROUND_UP_2 (height)/2;
- size += ROUND_UP_8 (width)/2 * ROUND_UP_2 (height)/2;
+ size += ROUND_UP_8 (width) / 2 * ROUND_UP_2 (height) / 2;
+ size += ROUND_UP_8 (width) / 2 * ROUND_UP_2 (height) / 2;
return size;
break;
case GST_COLORSPACE_RGB32:
- return width*height*4;
+ return width * height * 4;
break;
case GST_COLORSPACE_RGB24:
- return ROUND_UP_4 (width*3) * height;
+ return ROUND_UP_4 (width * 3) * height;
break;
case GST_COLORSPACE_RGB16:
- return ROUND_UP_4 (width*2) * height;
+ return ROUND_UP_4 (width * 2) * height;
break;
}
- g_assert_not_reached();
+ g_assert_not_reached ();
return 0;
}
{
int i;
- for (i=0; i<G_N_ELEMENTS (gst_colorspace_converters); i++) {
+ for (i = 0; i < G_N_ELEMENTS (gst_colorspace_converters); i++) {
GstColorspaceConverter *converter = gst_colorspace_converters + i;
+
if (from == converter->from && to == converter->to) {
return i;
}
}
- g_assert_not_reached();
+ g_assert_not_reached ();
return -1;
}
static GstPadLinkReturn
-gst_colorspace_link (GstPad *pad, const GstCaps *caps)
+gst_colorspace_link (GstPad * pad, const GstCaps * caps)
{
GstColorspace *space;
GstPad *otherpad;
structure = gst_caps_get_structure (caps, 0);
format_index = gst_colorspace_get_format (caps);
- g_print("format index is %d\n", format_index);
+ g_print ("format index is %d\n", format_index);
gst_structure_get_int (structure, "width", &width);
gst_structure_get_int (structure, "height", &height);
gst_structure_get_double (structure, "framerate", &fps);
- GST_INFO ( "size: %dx%d", space->width, space->height);
+ GST_INFO ("size: %dx%d", space->width, space->height);
if (gst_pad_is_negotiated (otherpad)) {
GstCaps *othercaps;
-
+
othercaps = gst_caps_copy (gst_pad_get_negotiated_caps (otherpad));
gst_caps_set_simple (othercaps,
- "width", G_TYPE_INT, width,
- "height", G_TYPE_INT, height,
- "framerate", G_TYPE_DOUBLE, fps, NULL);
+ "width", G_TYPE_INT, width,
+ "height", G_TYPE_INT, height, "framerate", G_TYPE_DOUBLE, fps, NULL);
link_ret = gst_pad_try_set_caps (otherpad, othercaps);
if (link_ret != GST_PAD_LINK_OK) {
}
if (gst_pad_is_negotiated (otherpad)) {
- space->converter_index = gst_colorspace_get_converter (
- space->sink_format_index, space->src_format_index);
+ space->converter_index =
+ gst_colorspace_get_converter (space->sink_format_index,
+ space->src_format_index);
- g_print("using index %d\n", space->converter_index);
+ g_print ("using index %d\n", space->converter_index);
- space->sink_size = gst_colorspace_format_get_size(space->sink_format_index,
- width,height);
- space->src_size = gst_colorspace_format_get_size(space->src_format_index,
- width,height);
+ space->sink_size = gst_colorspace_format_get_size (space->sink_format_index,
+ width, height);
+ space->src_size = gst_colorspace_format_get_size (space->src_format_index,
+ width, height);
space->width = width;
space->height = height;
space->fps = fps;
}
-
#if 0
if (gst_pad_is_negotiated (otherpad)) {
g_warning ("could not get converter\n");
if (!colorspace_type) {
static const GTypeInfo colorspace_info = {
- sizeof(GstColorspaceClass),
+ sizeof (GstColorspaceClass),
gst_colorspace_base_init,
NULL,
- (GClassInitFunc)gst_colorspace_class_init,
+ (GClassInitFunc) gst_colorspace_class_init,
NULL,
NULL,
- sizeof(GstColorspace),
+ sizeof (GstColorspace),
0,
- (GInstanceInitFunc)gst_colorspace_init,
+ (GInstanceInitFunc) gst_colorspace_init,
};
- colorspace_type = g_type_register_static(GST_TYPE_ELEMENT, "GstColorspace", &colorspace_info, 0);
+ colorspace_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstColorspace",
+ &colorspace_info, 0);
}
return colorspace_type;
}
gst_colorspace_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
+
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_colorspace_src_template));
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&gst_colorspace_sink_template));
+ gst_static_pad_template_get (&gst_colorspace_sink_template));
gst_element_class_set_details (element_class, &colorspace_details);
}
-
+
static void
-gst_colorspace_class_init (GstColorspaceClass *klass)
+gst_colorspace_class_init (GstColorspaceClass * 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);
gobject_class->set_property = gst_colorspace_set_property;
gobject_class->get_property = gst_colorspace_get_property;
gstelement_class->change_state = gst_colorspace_change_state;
- gst_colorspace_table_init(NULL);
+ gst_colorspace_table_init (NULL);
}
static void
-gst_colorspace_init (GstColorspace *space)
+gst_colorspace_init (GstColorspace * space)
{
- space->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&gst_colorspace_sink_template),
- "sink");
+ space->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_colorspace_sink_template), "sink");
gst_pad_set_link_function (space->sinkpad, gst_colorspace_link);
gst_pad_set_getcaps_function (space->sinkpad, gst_colorspace_getcaps);
- gst_pad_set_chain_function(space->sinkpad,gst_colorspace_chain);
- gst_element_add_pad(GST_ELEMENT(space),space->sinkpad);
+ gst_pad_set_chain_function (space->sinkpad, gst_colorspace_chain);
+ gst_element_add_pad (GST_ELEMENT (space), space->sinkpad);
- space->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&gst_colorspace_src_template),
- "src");
- gst_element_add_pad(GST_ELEMENT(space),space->srcpad);
+ space->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_colorspace_src_template), "src");
+ gst_element_add_pad (GST_ELEMENT (space), space->srcpad);
gst_pad_set_link_function (space->srcpad, gst_colorspace_link);
}
static void
-gst_colorspace_chain (GstPad *pad,GstData *_data)
+gst_colorspace_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstColorspace *space;
g_return_if_fail (buf != NULL);
space = GST_COLORSPACE (gst_pad_get_parent (pad));
-
+
g_return_if_fail (space != NULL);
g_return_if_fail (GST_IS_COLORSPACE (space));
outbuf = gst_pad_alloc_buffer (space->srcpad, GST_BUFFER_OFFSET_NONE,
space->src_size);
-
+
converter = gst_colorspace_converters + space->converter_index;
- converter->convert (space, GST_BUFFER_DATA (outbuf),
- GST_BUFFER_DATA (buf));
+ converter->convert (space, GST_BUFFER_DATA (outbuf), GST_BUFFER_DATA (buf));
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buf);
}
static GstElementStateReturn
-gst_colorspace_change_state (GstElement *element)
+gst_colorspace_change_state (GstElement * element)
{
GstColorspace *space;
}
static void
-gst_colorspace_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_colorspace_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstColorspace *space;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_COLORSPACE(object));
- space = GST_COLORSPACE(object);
+ g_return_if_fail (GST_IS_COLORSPACE (object));
+ space = GST_COLORSPACE (object);
switch (prop_id) {
default:
}
static void
-gst_colorspace_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_colorspace_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstColorspace *space;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_COLORSPACE(object));
- space = GST_COLORSPACE(object);
+ g_return_if_fail (GST_IS_COLORSPACE (object));
+ space = GST_COLORSPACE (object);
switch (prop_id) {
default:
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
if (!gst_element_register (plugin, "colorspace", GST_RANK_PRIMARY,
- GST_TYPE_COLORSPACE))
+ GST_TYPE_COLORSPACE))
return FALSE;
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "colorspace",
- "internal colorspace converter",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "colorspace",
+ "internal colorspace converter",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_TYPE_COLORSPACE \
(gst_colorspace_get_type())
#define GST_COLORSPACE(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_COLORSPACE))
#define GST_IS_COLORSPACE_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_COLORSPACE))
-
typedef struct _GstColorspace GstColorspace;
typedef struct _GstColorspaceClass GstColorspaceClass;
-typedef enum {
+typedef enum
+{
GST_COLORSPACE_NONE,
GST_COLORSPACE_HERMES,
GST_COLORSPACE_YUV_RGB,
GST_COLORSPACE_420_SWAP,
} GstColorSpaceConverterType;
-struct _GstColorspace {
+struct _GstColorspace
+{
GstElement element;
- GstPad *sinkpad,*srcpad;
+ GstPad *sinkpad, *srcpad;
int converter_index;
int src_size;
int sink_size;
-
+
int src_stride;
int sink_stride;
gdouble fps;
};
-struct _GstColorspaceClass {
+struct _GstColorspaceClass
+{
GstElementClass parent_class;
};
-GType gst_colorspace_get_type(void);
+GType gst_colorspace_get_type (void);
-typedef struct _GstColorspaceFormat {
+typedef struct _GstColorspaceFormat
+{
GstStaticCaps caps;
} GstColorspaceFormat;
-typedef enum {
+typedef enum
+{
GST_COLORSPACE_I420,
GST_COLORSPACE_YV12,
GST_COLORSPACE_RGB32,
GST_COLORSPACE_RGB16,
} GstColorSpaceFormatType;
-typedef struct _GstColorspaceConverter {
+typedef struct _GstColorspaceConverter
+{
GstColorSpaceFormatType from;
GstColorSpaceFormatType to;
- void (*convert) (GstColorspace *colorspace, unsigned char *dest, unsigned char *src);
+ void (*convert) (GstColorspace * colorspace, unsigned char *dest,
+ unsigned char *src);
} GstColorspaceConverter;
G_END_DECLS
-
#endif
-
#undef HAVE_LIBMMX
-#ifdef HAVE_LIBMMX
+#ifdef HAVE_LIBMMX
#include <mmx.h>
#endif
-static int V_r_tab [256];
-static int V_g_tab [256];
-static int U_g_tab [256];
-static int U_b_tab [256];
+static int V_r_tab[256];
+static int V_g_tab[256];
+static int U_g_tab[256];
+static int U_b_tab[256];
#define CB_BASE 1
#define CR_BASE (CB_BASE*CB_RANGE)
: Max(-128.0, ((x) * chromaCorrect)))
-void gst_colorspace_I420_to_rgb16 (GstColorspace *space, unsigned char *src, unsigned char *dest);
-void gst_colorspace_I420_to_rgb24 (GstColorspace *space, unsigned char *src, unsigned char *dest);
-void gst_colorspace_I420_to_rgb32 (GstColorspace *space, unsigned char *src, unsigned char *dest);
+void gst_colorspace_I420_to_rgb16 (GstColorspace * space, unsigned char *src,
+ unsigned char *dest);
+void gst_colorspace_I420_to_rgb24 (GstColorspace * space, unsigned char *src,
+ unsigned char *dest);
+void gst_colorspace_I420_to_rgb32 (GstColorspace * space, unsigned char *src,
+ unsigned char *dest);
#ifdef HAVE_LIBMMX
-void gst_colorspace_I420_to_bgr16_mmx (GstColorspace *space, unsigned char *src, unsigned char *dest);
-void gst_colorspace_I420_to_bgr32_mmx (GstColorspace *space, unsigned char *src, unsigned char *dest);
+void gst_colorspace_I420_to_bgr16_mmx (GstColorspace * space,
+ unsigned char *src, unsigned char *dest);
+void gst_colorspace_I420_to_bgr32_mmx (GstColorspace * space,
+ unsigned char *src, unsigned char *dest);
#endif
-void gst_colorspace_YV12_to_rgb16 (GstColorspace *space, unsigned char *src, unsigned char *dest);
-void gst_colorspace_YV12_to_rgb24 (GstColorspace *space, unsigned char *src, unsigned char *dest);
-void gst_colorspace_YV12_to_rgb32 (GstColorspace *space, unsigned char *src, unsigned char *dest);
+void gst_colorspace_YV12_to_rgb16 (GstColorspace * space, unsigned char *src,
+ unsigned char *dest);
+void gst_colorspace_YV12_to_rgb24 (GstColorspace * space, unsigned char *src,
+ unsigned char *dest);
+void gst_colorspace_YV12_to_rgb32 (GstColorspace * space, unsigned char *src,
+ unsigned char *dest);
#ifdef HAVE_LIBMMX
-void gst_colorspace_YV12_to_bgr16_mmx (GstColorspace *space, unsigned char *src, unsigned char *dest);
-void gst_colorspace_YV12_to_bgr32_mmx (GstColorspace *space, unsigned char *src, unsigned char *dest);
+void gst_colorspace_YV12_to_bgr16_mmx (GstColorspace * space,
+ unsigned char *src, unsigned char *dest);
+void gst_colorspace_YV12_to_bgr32_mmx (GstColorspace * space,
+ unsigned char *src, unsigned char *dest);
#endif
static void
-gst_colorspace_yuv_to_rgb16(GstColorspace *space,
- unsigned char *out,
- unsigned char *lum,
- unsigned char *cr,
- unsigned char *cb,
- int cols, int rows);
+gst_colorspace_yuv_to_rgb16 (GstColorspace * space,
+ unsigned char *out,
+ unsigned char *lum,
+ unsigned char *cr, unsigned char *cb, int cols, int rows);
static void
-gst_colorspace_yuv_to_rgb24(GstColorspace *space,
- unsigned char *out,
- unsigned char *lum,
- unsigned char *cr,
- unsigned char *cb,
- int cols, int rows);
+gst_colorspace_yuv_to_rgb24 (GstColorspace * space,
+ unsigned char *out,
+ unsigned char *lum,
+ unsigned char *cr, unsigned char *cb, int cols, int rows);
static void
-gst_colorspace_yuv_to_rgb32(GstColorspace *space,
- unsigned char *out,
- unsigned char *lum,
- unsigned char *cr,
- unsigned char *cb,
- int cols, int rows);
+gst_colorspace_yuv_to_rgb32 (GstColorspace * space,
+ unsigned char *out,
+ unsigned char *lum,
+ unsigned char *cr, unsigned char *cb, int cols, int rows);
#if 0
-static void gst_colorspace_yuv_to_rgb16(GstColorspaceYUVTables *tables,
- unsigned char *lum,
- unsigned char *cr,
- unsigned char *cb,
- unsigned char *out,
- int cols, int rows);
-static void gst_colorspace_yuv_to_rgb24(GstColorspaceYUVTables *tables,
- unsigned char *lum,
- unsigned char *cr,
- unsigned char *cb,
- unsigned char *out,
- int cols, int rows);
-static void gst_colorspace_yuv_to_rgb32(GstColorspaceYUVTables *tables,
- unsigned char *lum,
- unsigned char *cr,
- unsigned char *cb,
- unsigned char *out,
- int cols, int rows);
+static void gst_colorspace_yuv_to_rgb16 (GstColorspaceYUVTables * tables,
+ unsigned char *lum,
+ unsigned char *cr,
+ unsigned char *cb, unsigned char *out, int cols, int rows);
+static void gst_colorspace_yuv_to_rgb24 (GstColorspaceYUVTables * tables,
+ unsigned char *lum,
+ unsigned char *cr,
+ unsigned char *cb, unsigned char *out, int cols, int rows);
+static void gst_colorspace_yuv_to_rgb32 (GstColorspaceYUVTables * tables,
+ unsigned char *lum,
+ unsigned char *cr,
+ unsigned char *cb, unsigned char *out, int cols, int rows);
#ifdef HAVE_LIBMMX
-void gst_colorspace_yuv_to_bgr32_mmx(GstColorspaceYUVTables *tables,
- unsigned char *lum,
- unsigned char *cr,
- unsigned char *cb,
- unsigned char *out,
- int cols, int rows);
-extern void gst_colorspace_yuv_to_bgr16_mmx(GstColorspaceYUVTables *tables,
- unsigned char *lum,
- unsigned char *cr,
- unsigned char *cb,
- unsigned char *out,
- int cols, int rows);
+void gst_colorspace_yuv_to_bgr32_mmx (GstColorspaceYUVTables * tables,
+ unsigned char *lum,
+ unsigned char *cr,
+ unsigned char *cb, unsigned char *out, int cols, int rows);
+extern void gst_colorspace_yuv_to_bgr16_mmx (GstColorspaceYUVTables * tables,
+ unsigned char *lum,
+ unsigned char *cr,
+ unsigned char *cb, unsigned char *out, int cols, int rows);
#endif
#endif
#define ROUND_UP_8(x) (((x)+7)&~7)
-void gst_colorspace_I420_to_rgb32(GstColorspace *space, unsigned char *dest,
- unsigned char *src)
+void
+gst_colorspace_I420_to_rgb32 (GstColorspace * space, unsigned char *dest,
+ unsigned char *src)
{
unsigned char *src_U;
unsigned char *src_V;
src_U = src + ROUND_UP_4 (space->width) * ROUND_UP_2 (space->height);
- src_V = src_U + ROUND_UP_8 (space->width)/2 * ROUND_UP_2 (space->height)/2;
+ src_V =
+ src_U + ROUND_UP_8 (space->width) / 2 * ROUND_UP_2 (space->height) / 2;
- gst_colorspace_yuv_to_rgb32(space,
- dest,
- src, src_U, src_V,
- space->width, space->height);
+ gst_colorspace_yuv_to_rgb32 (space,
+ dest, src, src_U, src_V, space->width, space->height);
}
-void gst_colorspace_I420_to_rgb24(GstColorspace *space, unsigned char *dest,
- unsigned char *src)
+void
+gst_colorspace_I420_to_rgb24 (GstColorspace * space, unsigned char *dest,
+ unsigned char *src)
{
unsigned char *src_U;
unsigned char *src_V;
src_U = src + ROUND_UP_4 (space->width) * ROUND_UP_2 (space->height);
- src_V = src_U + ROUND_UP_8 (space->width)/2 * ROUND_UP_2 (space->height)/2;
+ src_V =
+ src_U + ROUND_UP_8 (space->width) / 2 * ROUND_UP_2 (space->height) / 2;
- gst_colorspace_yuv_to_rgb24(space,
- dest,
- src, src_U, src_V,
- space->width, space->height);
+ gst_colorspace_yuv_to_rgb24 (space,
+ dest, src, src_U, src_V, space->width, space->height);
}
-void gst_colorspace_I420_to_rgb16(GstColorspace *space, unsigned char *dest,
- unsigned char *src)
+void
+gst_colorspace_I420_to_rgb16 (GstColorspace * space, unsigned char *dest,
+ unsigned char *src)
{
unsigned char *src_U;
unsigned char *src_V;
src_U = src + ROUND_UP_4 (space->width) * ROUND_UP_2 (space->height);
- src_V = src_U + ROUND_UP_8 (space->width)/2 * ROUND_UP_2 (space->height)/2;
+ src_V =
+ src_U + ROUND_UP_8 (space->width) / 2 * ROUND_UP_2 (space->height) / 2;
- gst_colorspace_yuv_to_rgb16(space,
- dest,
- src, src_U, src_V,
- space->width, space->height);
+ gst_colorspace_yuv_to_rgb16 (space,
+ dest, src, src_U, src_V, space->width, space->height);
}
-void gst_colorspace_YV12_to_rgb32(GstColorspace *space, unsigned char *dest,
- unsigned char *src)
+void
+gst_colorspace_YV12_to_rgb32 (GstColorspace * space, unsigned char *dest,
+ unsigned char *src)
{
unsigned char *src_U;
unsigned char *src_V;
src_V = src + ROUND_UP_4 (space->width) * ROUND_UP_2 (space->height);
- src_U = src_V + ROUND_UP_8 (space->width)/2 * ROUND_UP_2 (space->height)/2;
+ src_U =
+ src_V + ROUND_UP_8 (space->width) / 2 * ROUND_UP_2 (space->height) / 2;
- gst_colorspace_yuv_to_rgb32(space,
- dest,
- src, src_U, src_V,
- space->width, space->height);
+ gst_colorspace_yuv_to_rgb32 (space,
+ dest, src, src_U, src_V, space->width, space->height);
}
-void gst_colorspace_YV12_to_rgb24(GstColorspace *space, unsigned char *dest,
- unsigned char *src)
+void
+gst_colorspace_YV12_to_rgb24 (GstColorspace * space, unsigned char *dest,
+ unsigned char *src)
{
unsigned char *src_U;
unsigned char *src_V;
src_V = src + ROUND_UP_4 (space->width) * ROUND_UP_2 (space->height);
- src_U = src_V + ROUND_UP_8 (space->width)/2 * ROUND_UP_2 (space->height)/2;
+ src_U =
+ src_V + ROUND_UP_8 (space->width) / 2 * ROUND_UP_2 (space->height) / 2;
- gst_colorspace_yuv_to_rgb24(space,
- dest,
- src, src_U, src_V,
- space->width, space->height);
+ gst_colorspace_yuv_to_rgb24 (space,
+ dest, src, src_U, src_V, space->width, space->height);
}
-void gst_colorspace_YV12_to_rgb16(GstColorspace *space, unsigned char *dest,
- unsigned char *src)
+void
+gst_colorspace_YV12_to_rgb16 (GstColorspace * space, unsigned char *dest,
+ unsigned char *src)
{
unsigned char *src_U;
unsigned char *src_V;
src_V = src + ROUND_UP_4 (space->width) * ROUND_UP_2 (space->height);
- src_U = src_V + ROUND_UP_8 (space->width)/2 * ROUND_UP_2 (space->height)/2;
+ src_U =
+ src_V + ROUND_UP_8 (space->width) / 2 * ROUND_UP_2 (space->height) / 2;
- gst_colorspace_yuv_to_rgb16(space,
- dest,
- src, src_U, src_V,
- space->width, space->height);
+ gst_colorspace_yuv_to_rgb16 (space,
+ dest, src, src_U, src_V, space->width, space->height);
}
#ifdef HAVE_LIBMMX
-void gst_colorspace_I420_to_bgr32_mmx(GstColorspace *space, unsigned char *src, unsigned char *dest) {
+void
+gst_colorspace_I420_to_bgr32_mmx (GstColorspace * space, unsigned char *src,
+ unsigned char *dest)
+{
int size;
+
GST_DEBUG ("gst_colorspace_I420_to_rgb32_mmx");
size = space->width * space->height;
- gst_colorspace_yuv_to_bgr32_mmx(NULL,
- src, /* Y component */
- src+size, /* cr component */
- src+size+(size>>2), /* cb component */
- dest,
- space->height,
- space->width);
+ gst_colorspace_yuv_to_bgr32_mmx (NULL, src, /* Y component */
+ src + size, /* cr component */
+ src + size + (size >> 2), /* cb component */
+ dest, space->height, space->width);
}
-void gst_colorspace_I420_to_bgr16_mmx(GstColorspace *space, unsigned char *src, unsigned char *dest) {
+void
+gst_colorspace_I420_to_bgr16_mmx (GstColorspace * space, unsigned char *src,
+ unsigned char *dest)
+{
int size;
+
GST_DEBUG ("gst_colorspace_I420_to_bgr16_mmx ");
size = space->width * space->height;
- gst_colorspace_yuv_to_bgr16_mmx(NULL,
- src, /* Y component */
- src+size, /* cr component */
- src+size+(size>>2), /* cb component */
- dest,
- space->height,
- space->width);
+ gst_colorspace_yuv_to_bgr16_mmx (NULL, src, /* Y component */
+ src + size, /* cr component */
+ src + size + (size >> 2), /* cb component */
+ dest, space->height, space->width);
GST_DEBUG ("gst_colorspace_I420_to_bgr16_mmx done");
}
-void gst_colorspace_YV12_to_bgr32_mmx(GstColorspace *space, unsigned char *src, unsigned char *dest) {
+void
+gst_colorspace_YV12_to_bgr32_mmx (GstColorspace * space, unsigned char *src,
+ unsigned char *dest)
+{
int size;
+
GST_DEBUG ("gst_colorspace_YV12_to_rgb32_mmx");
size = space->width * space->height;
- gst_colorspace_yuv_to_bgr32_mmx(NULL,
- src, /* Y component */
- src+size+(size>>2), /* cb component */
- src+size, /* cr component */
- dest,
- space->height,
- space->width);
+ gst_colorspace_yuv_to_bgr32_mmx (NULL, src, /* Y component */
+ src + size + (size >> 2), /* cb component */
+ src + size, /* cr component */
+ dest, space->height, space->width);
}
-void gst_colorspace_YV12_to_bgr16_mmx(GstColorspace *space, unsigned char *src, unsigned char *dest) {
+void
+gst_colorspace_YV12_to_bgr16_mmx (GstColorspace * space, unsigned char *src,
+ unsigned char *dest)
+{
int size;
+
GST_DEBUG ("gst_colorspace_YV12_to_bgr16_mmx ");
size = space->width * space->height;
- gst_colorspace_yuv_to_bgr16_mmx(NULL,
- src, /* Y component */
- src+size+(size>>2), /* cb component */
- src+size, /* cr component */
- dest,
- space->height,
- space->width);
+ gst_colorspace_yuv_to_bgr16_mmx (NULL, src, /* Y component */
+ src + size + (size >> 2), /* cb component */
+ src + size, /* cr component */
+ dest, space->height, space->width);
GST_DEBUG ("gst_colorspace_YV12_to_bgr16_mmx done");
}
*/
static int
-number_of_bits_set(a)
-unsigned long a;
+number_of_bits_set (a)
+ unsigned long a;
{
- if(!a) return 0;
- if(a & 1) return 1 + number_of_bits_set(a >> 1);
- return(number_of_bits_set(a >> 1));
+ if (!a)
+ return 0;
+ if (a & 1)
+ return 1 + number_of_bits_set (a >> 1);
+ return (number_of_bits_set (a >> 1));
}
/*
* Low performance, do not call often.
*/
static int
-free_bits_at_top(a)
-unsigned long a;
+free_bits_at_top (a)
+ unsigned long a;
{
- /* assume char is 8 bits */
- if(!a) return sizeof(unsigned long) * 8;
- /* assume twos complement */
- if(((long)a) < 0l) return 0;
- return 1 + free_bits_at_top ( a << 1);
+ /* assume char is 8 bits */
+ if (!a)
+ return sizeof (unsigned long) * 8;
+ /* assume twos complement */
+ if (((long) a) < 0l)
+ return 0;
+ return 1 + free_bits_at_top (a << 1);
}
/*
* Low performance, do not call often.
*/
static int
-free_bits_at_bottom(a)
-unsigned long a;
+free_bits_at_bottom (a)
+ unsigned long a;
{
- /* assume char is 8 bits */
- if(!a) return sizeof(unsigned long) * 8;
- if(((long)a) & 1l) return 0;
- return 1 + free_bits_at_bottom ( a >> 1);
+ /* assume char is 8 bits */
+ if (!a)
+ return sizeof (unsigned long) * 8;
+ if (((long) a) & 1l)
+ return 0;
+ return 1 + free_bits_at_bottom (a >> 1);
}
/*
*/
void
-gst_colorspace_table_init (GstColorspace *space)
+gst_colorspace_table_init (GstColorspace * space)
{
int i;
- for (i=0; i<256; i++) {
- V_r_tab[i] = (0.419/0.299) * (i-128);
- V_g_tab[i] = -(0.299/0.419) * (i-128);
- U_g_tab[i] = -(0.114/0.331) * (i-128);
- U_b_tab[i] = (0.587/0.331) * (i-128);
+ for (i = 0; i < 256; i++) {
+ V_r_tab[i] = (0.419 / 0.299) * (i - 128);
+ V_g_tab[i] = -(0.299 / 0.419) * (i - 128);
+ U_g_tab[i] = -(0.114 / 0.331) * (i - 128);
+ U_b_tab[i] = (0.587 / 0.331) * (i - 128);
}
#if 0
- int CR, CB, i;
- int *L_tab, *Cr_r_tab, *Cr_g_tab, *Cb_g_tab, *Cb_b_tab;
- long *r_2_pix_alloc;
- long *g_2_pix_alloc;
- long *b_2_pix_alloc;
- long depth = 32;
- long red_mask = 0xff0000;
- long green_mask = 0x00ff00;
- long blue_mask = 0x0000ff;
-
- L_tab = space->L_tab = (int *)malloc(256*sizeof(int));
- Cr_r_tab = space->Cr_r_tab = (int *)malloc(256*sizeof(int));
- Cr_g_tab = space->Cr_g_tab = (int *)malloc(256*sizeof(int));
- Cb_g_tab = space->Cb_g_tab = (int *)malloc(256*sizeof(int));
- Cb_b_tab = space->Cb_b_tab = (int *)malloc(256*sizeof(int));
-
- r_2_pix_alloc = (long *)malloc(768*sizeof(long));
- g_2_pix_alloc = (long *)malloc(768*sizeof(long));
- b_2_pix_alloc = (long *)malloc(768*sizeof(long));
-
- if (L_tab == NULL ||
- Cr_r_tab == NULL ||
- Cr_g_tab == NULL ||
- Cb_g_tab == NULL ||
- Cb_b_tab == NULL ||
- r_2_pix_alloc == NULL ||
- g_2_pix_alloc == NULL ||
- b_2_pix_alloc == NULL) {
- fprintf(stderr, "Could not get enough memory in InitColorDither\n");
- exit(1);
- }
+ int CR, CB, i;
+ int *L_tab, *Cr_r_tab, *Cr_g_tab, *Cb_g_tab, *Cb_b_tab;
+ long *r_2_pix_alloc;
+ long *g_2_pix_alloc;
+ long *b_2_pix_alloc;
+ long depth = 32;
+ long red_mask = 0xff0000;
+ long green_mask = 0x00ff00;
+ long blue_mask = 0x0000ff;
+
+ L_tab = space->L_tab = (int *) malloc (256 * sizeof (int));
+ Cr_r_tab = space->Cr_r_tab = (int *) malloc (256 * sizeof (int));
+ Cr_g_tab = space->Cr_g_tab = (int *) malloc (256 * sizeof (int));
+ Cb_g_tab = space->Cb_g_tab = (int *) malloc (256 * sizeof (int));
+ Cb_b_tab = space->Cb_b_tab = (int *) malloc (256 * sizeof (int));
+
+ r_2_pix_alloc = (long *) malloc (768 * sizeof (long));
+ g_2_pix_alloc = (long *) malloc (768 * sizeof (long));
+ b_2_pix_alloc = (long *) malloc (768 * sizeof (long));
+
+ if (L_tab == NULL ||
+ Cr_r_tab == NULL ||
+ Cr_g_tab == NULL ||
+ Cb_g_tab == NULL ||
+ Cb_b_tab == NULL ||
+ r_2_pix_alloc == NULL || g_2_pix_alloc == NULL || b_2_pix_alloc == NULL) {
+ fprintf (stderr, "Could not get enough memory in InitColorDither\n");
+ exit (1);
+ }
- for (i=0; i<256; i++) {
- L_tab[i] = i;
- /*
- if (gammaCorrectFlag) {
- L_tab[i] = GAMMA_CORRECTION(i);
- }
- */
-
- CB = CR = i;
- /*
- if (chromaCorrectFlag) {
- CB -= 128;
- CB = CHROMA_CORRECTION128(CB);
- CR -= 128;
- CR = CHROMA_CORRECTION128(CR);
- }
- else
- */
- {
- CB -= 128; CR -= 128;
- }
- Cr_r_tab[i] = (0.419/0.299) * CR;
- Cr_g_tab[i] = -(0.299/0.419) * CR;
- Cb_g_tab[i] = -(0.114/0.331) * CB;
- Cb_b_tab[i] = (0.587/0.331) * CB;
+ for (i = 0; i < 256; i++) {
+ L_tab[i] = i;
+ /*
+ if (gammaCorrectFlag) {
+ L_tab[i] = GAMMA_CORRECTION(i);
+ }
+ */
+ CB = CR = i;
+ /*
+ if (chromaCorrectFlag) {
+ CB -= 128;
+ CB = CHROMA_CORRECTION128(CB);
+ CR -= 128;
+ CR = CHROMA_CORRECTION128(CR);
+ }
+ else
+ */
+ {
+ CB -= 128;
+ CR -= 128;
}
+ Cr_r_tab[i] = (0.419 / 0.299) * CR;
+ Cr_g_tab[i] = -(0.299 / 0.419) * CR;
+ Cb_g_tab[i] = -(0.114 / 0.331) * CB;
+ Cb_b_tab[i] = (0.587 / 0.331) * CB;
- /*
- * Set up entries 0-255 in rgb-to-pixel value tables.
+ }
+
+ /*
+ * Set up entries 0-255 in rgb-to-pixel value tables.
+ */
+ for (i = 0; i < 256; i++) {
+ r_2_pix_alloc[i + 256] = i >> (8 - number_of_bits_set (red_mask));
+ r_2_pix_alloc[i + 256] <<= free_bits_at_bottom (red_mask);
+ g_2_pix_alloc[i + 256] = i >> (8 - number_of_bits_set (green_mask));
+ g_2_pix_alloc[i + 256] <<= free_bits_at_bottom (green_mask);
+ b_2_pix_alloc[i + 256] = i >> (8 - number_of_bits_set (blue_mask));
+ b_2_pix_alloc[i + 256] <<= free_bits_at_bottom (blue_mask);
+ /*
+ * If we have 16-bit output depth, then we double the value
+ * in the top word. This means that we can write out both
+ * pixels in the pixel doubling mode with one op. It is
+ * harmless in the normal case as storing a 32-bit value
+ * through a short pointer will lose the top bits anyway.
+ * A similar optimisation for Alpha for 64 bit has been
+ * prepared for, but is not yet implemented.
*/
- for (i = 0; i < 256; i++) {
- r_2_pix_alloc[i + 256] = i >> (8 - number_of_bits_set(red_mask));
- r_2_pix_alloc[i + 256] <<= free_bits_at_bottom(red_mask);
- g_2_pix_alloc[i + 256] = i >> (8 - number_of_bits_set(green_mask));
- g_2_pix_alloc[i + 256] <<= free_bits_at_bottom(green_mask);
- b_2_pix_alloc[i + 256] = i >> (8 - number_of_bits_set(blue_mask));
- b_2_pix_alloc[i + 256] <<= free_bits_at_bottom(blue_mask);
- /*
- * If we have 16-bit output depth, then we double the value
- * in the top word. This means that we can write out both
- * pixels in the pixel doubling mode with one op. It is
- * harmless in the normal case as storing a 32-bit value
- * through a short pointer will lose the top bits anyway.
- * A similar optimisation for Alpha for 64 bit has been
- * prepared for, but is not yet implemented.
- */
- if(!(depth == 32) && !(depth == 24)) {
-
- r_2_pix_alloc[i + 256] |= (r_2_pix_alloc[i + 256]) << 16;
- g_2_pix_alloc[i + 256] |= (g_2_pix_alloc[i + 256]) << 16;
- b_2_pix_alloc[i + 256] |= (b_2_pix_alloc[i + 256]) << 16;
-
- }
-#ifdef SIXTYFOUR_BIT
- if(depth == 32) {
+ if (!(depth == 32) && !(depth == 24)) {
- r_2_pix_alloc[i + 256] |= (r_2_pix_alloc[i + 256]) << 32;
- g_2_pix_alloc[i + 256] |= (g_2_pix_alloc[i + 256]) << 32;
- b_2_pix_alloc[i + 256] |= (b_2_pix_alloc[i + 256]) << 32;
+ r_2_pix_alloc[i + 256] |= (r_2_pix_alloc[i + 256]) << 16;
+ g_2_pix_alloc[i + 256] |= (g_2_pix_alloc[i + 256]) << 16;
+ b_2_pix_alloc[i + 256] |= (b_2_pix_alloc[i + 256]) << 16;
- }
-#endif
}
+#ifdef SIXTYFOUR_BIT
+ if (depth == 32) {
+
+ r_2_pix_alloc[i + 256] |= (r_2_pix_alloc[i + 256]) << 32;
+ g_2_pix_alloc[i + 256] |= (g_2_pix_alloc[i + 256]) << 32;
+ b_2_pix_alloc[i + 256] |= (b_2_pix_alloc[i + 256]) << 32;
- /*
- * Spread out the values we have to the rest of the array so that
- * we do not need to check for overflow.
- */
- for (i = 0; i < 256; i++) {
- r_2_pix_alloc[i] = r_2_pix_alloc[256];
- r_2_pix_alloc[i+ 512] = r_2_pix_alloc[511];
- g_2_pix_alloc[i] = g_2_pix_alloc[256];
- g_2_pix_alloc[i+ 512] = g_2_pix_alloc[511];
- b_2_pix_alloc[i] = b_2_pix_alloc[256];
- b_2_pix_alloc[i+ 512] = b_2_pix_alloc[511];
}
+#endif
+ }
+
+ /*
+ * Spread out the values we have to the rest of the array so that
+ * we do not need to check for overflow.
+ */
+ for (i = 0; i < 256; i++) {
+ r_2_pix_alloc[i] = r_2_pix_alloc[256];
+ r_2_pix_alloc[i + 512] = r_2_pix_alloc[511];
+ g_2_pix_alloc[i] = g_2_pix_alloc[256];
+ g_2_pix_alloc[i + 512] = g_2_pix_alloc[511];
+ b_2_pix_alloc[i] = b_2_pix_alloc[256];
+ b_2_pix_alloc[i + 512] = b_2_pix_alloc[511];
+ }
- space->r_2_pix = r_2_pix_alloc + 256;
- space->g_2_pix = g_2_pix_alloc + 256;
- space->b_2_pix = b_2_pix_alloc + 256;
+ space->r_2_pix = r_2_pix_alloc + 256;
+ space->g_2_pix = g_2_pix_alloc + 256;
+ space->b_2_pix = b_2_pix_alloc + 256;
#endif
}
static void
-gst_colorspace_yuv_to_rgb32(GstColorspace *space,
- unsigned char *dest,
- unsigned char *Y,
- unsigned char *U,
- unsigned char *V,
- int width, int height)
+gst_colorspace_yuv_to_rgb32 (GstColorspace * space,
+ unsigned char *dest,
+ unsigned char *Y, unsigned char *U, unsigned char *V, int width, int height)
{
- int x,y;
+ int x, y;
int src_rowstride;
int dest_rowstride;
src_rowstride = ROUND_UP_4 (space->width);
dest_rowstride = width * 4;
- for(y=0;y<height;y++){
- for(x=0;x<width;x++){
- dest[x*4 + 0] = 0;
- dest[x*3 + 1] = CLAMP (Y[x] + V_r_tab[V[x/2]], 0, 255);
- dest[x*3 + 2] = CLAMP (Y[x] + U_g_tab[U[x/2]] + V_g_tab[V[x/2]], 0, 255);
- dest[x*3 + 3] = CLAMP (Y[x] + U_b_tab[U[x/2]], 0, 255);
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++) {
+ dest[x * 4 + 0] = 0;
+ dest[x * 3 + 1] = CLAMP (Y[x] + V_r_tab[V[x / 2]], 0, 255);
+ dest[x * 3 + 2] =
+ CLAMP (Y[x] + U_g_tab[U[x / 2]] + V_g_tab[V[x / 2]], 0, 255);
+ dest[x * 3 + 3] = CLAMP (Y[x] + U_b_tab[U[x / 2]], 0, 255);
}
Y += src_rowstride;
dest += dest_rowstride;
- if (y&1) {
- U += src_rowstride/2;
- V += src_rowstride/2;
+ if (y & 1) {
+ U += src_rowstride / 2;
+ V += src_rowstride / 2;
}
}
}
static void
-gst_colorspace_yuv_to_rgb24(GstColorspace *space,
- unsigned char *dest,
- unsigned char *Y,
- unsigned char *U,
- unsigned char *V,
- int width, int height)
+gst_colorspace_yuv_to_rgb24 (GstColorspace * space,
+ unsigned char *dest,
+ unsigned char *Y, unsigned char *U, unsigned char *V, int width, int height)
{
- int x,y;
+ int x, y;
int src_rowstride;
int dest_rowstride;
src_rowstride = ROUND_UP_4 (space->width);
dest_rowstride = ROUND_UP_4 (width * 3);
- for(y=0;y<height;y++){
- for(x=0;x<width;x++){
- dest[x*3 + 0] = CLAMP (Y[x] + V_r_tab[V[x/2]], 0, 255);
- dest[x*3 + 1] = CLAMP (Y[x] + U_g_tab[U[x/2]] + V_g_tab[V[x/2]], 0, 255);
- dest[x*3 + 2] = CLAMP (Y[x] + U_b_tab[U[x/2]], 0, 255);
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++) {
+ dest[x * 3 + 0] = CLAMP (Y[x] + V_r_tab[V[x / 2]], 0, 255);
+ dest[x * 3 + 1] =
+ CLAMP (Y[x] + U_g_tab[U[x / 2]] + V_g_tab[V[x / 2]], 0, 255);
+ dest[x * 3 + 2] = CLAMP (Y[x] + U_b_tab[U[x / 2]], 0, 255);
}
Y += src_rowstride;
dest += dest_rowstride;
- if (y&1) {
- U += src_rowstride/2;
- V += src_rowstride/2;
+ if (y & 1) {
+ U += src_rowstride / 2;
+ V += src_rowstride / 2;
}
}
}
static void
-gst_colorspace_yuv_to_rgb16(GstColorspace *space,
- unsigned char *dest,
- unsigned char *Y,
- unsigned char *U,
- unsigned char *V,
- int width, int height)
+gst_colorspace_yuv_to_rgb16 (GstColorspace * space,
+ unsigned char *dest,
+ unsigned char *Y, unsigned char *U, unsigned char *V, int width, int height)
{
- int x,y;
+ int x, y;
int src_rowstride;
int dest_rowstride;
int r, g, b;
src_rowstride = ROUND_UP_4 (space->width);
dest_rowstride = ROUND_UP_4 (width * 2);
- for(y=0;y<height;y++){
- for(x=0;x<width;x++){
- r = CLAMP (Y[x] + V_r_tab[V[x/2]], 0, 255);
- g = CLAMP (Y[x] + U_g_tab[U[x/2]] + V_g_tab[V[x/2]], 0, 255);
- b = CLAMP (Y[x] + U_b_tab[U[x/2]], 0, 255);
- *(unsigned short *)(dest + x*2) = ((r&0xf8)<<8) | ((g&0xfc)<<3) | (b>>3);
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++) {
+ r = CLAMP (Y[x] + V_r_tab[V[x / 2]], 0, 255);
+ g = CLAMP (Y[x] + U_g_tab[U[x / 2]] + V_g_tab[V[x / 2]], 0, 255);
+ b = CLAMP (Y[x] + U_b_tab[U[x / 2]], 0, 255);
+ *(unsigned short *) (dest + x * 2) =
+ ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | (b >> 3);
}
Y += src_rowstride;
dest += dest_rowstride;
- if (y&1) {
- U += src_rowstride/2;
- V += src_rowstride/2;
+ if (y & 1) {
+ U += src_rowstride / 2;
+ V += src_rowstride / 2;
}
}
}
#ifdef HAVE_LIBMMX
-static mmx_t MMX_80w = (mmx_t)(long long)0x0080008000800080LL; /*dd 00080 0080h, 000800080h */
+static mmx_t MMX_80w = (mmx_t) (long long) 0x0080008000800080LL; /*dd 00080 0080h, 000800080h */
-static mmx_t MMX_00FFw = (mmx_t)(long long)0x00ff00ff00ff00ffLL; /*dd 000FF 00FFh, 000FF00FFh */
-static mmx_t MMX_FF00w = (mmx_t)(long long)0xff00ff00ff00ff00LL; /*dd 000FF 00FFh, 000FF00FFh */
+static mmx_t MMX_00FFw = (mmx_t) (long long) 0x00ff00ff00ff00ffLL; /*dd 000FF 00FFh, 000FF00FFh */
+static mmx_t MMX_FF00w = (mmx_t) (long long) 0xff00ff00ff00ff00LL; /*dd 000FF 00FFh, 000FF00FFh */
-static mmx_t MMX32_Vredcoeff = (mmx_t)(long long)0x0059005900590059LL;
-static mmx_t MMX32_Ubluecoeff = (mmx_t)(long long)0x0072007200720072LL;
-static mmx_t MMX32_Ugrncoeff = (mmx_t)(long long)0xffeaffeaffeaffeaLL;
-static mmx_t MMX32_Vgrncoeff = (mmx_t)(long long)0xffd2ffd2ffd2ffd2LL;
+static mmx_t MMX32_Vredcoeff = (mmx_t) (long long) 0x0059005900590059LL;
+static mmx_t MMX32_Ubluecoeff = (mmx_t) (long long) 0x0072007200720072LL;
+static mmx_t MMX32_Ugrncoeff = (mmx_t) (long long) 0xffeaffeaffeaffeaLL;
+static mmx_t MMX32_Vgrncoeff = (mmx_t) (long long) 0xffd2ffd2ffd2ffd2LL;
static void
-gst_colorspace_yuv_to_bgr32_mmx(tables, lum, cr, cb, out, rows, cols)
- GstColorspaceYUVTables *tables;
- unsigned char *lum;
- unsigned char *cr;
- unsigned char *cb;
- unsigned char *out;
- int cols, rows;
+gst_colorspace_yuv_to_bgr32_mmx (tables, lum, cr, cb, out, rows, cols)
+ GstColorspaceYUVTables *tables;
+ unsigned char *lum;
+ unsigned char *cr;
+ unsigned char *cb;
+ unsigned char *out;
+ int cols, rows;
{
- guint32 *row1 = (guint32 *)out; /* 32 bit target */
- int cols4 = cols>>2;
-
- int y, x;
-
- for (y=rows>>1; y; y--) {
- for (x=cols4; x; x--) {
-
- /* create Cr (result in mm1) */
- movd_m2r(*(mmx_t *)cb, mm1); /* 0 0 0 0 v3 v2 v1 v0 */
- pxor_r2r(mm7, mm7); /* 00 00 00 00 00 00 00 00 */
- movd_m2r(*(mmx_t *)lum, mm2); /* 0 0 0 0 l3 l2 l1 l0 */
- punpcklbw_r2r(mm7, mm1); /* 0 v3 0 v2 00 v1 00 v0 */
- punpckldq_r2r(mm1, mm1); /* 00 v1 00 v0 00 v1 00 v0 */
- psubw_m2r(MMX_80w, mm1); /* mm1-128:r1 r1 r0 r0 r1 r1 r0 r0 */
-
- /* create Cr_g (result in mm0) */
- movq_r2r(mm1, mm0); /* r1 r1 r0 r0 r1 r1 r0 r0 */
- pmullw_m2r(MMX32_Vgrncoeff, mm0); /* red*-46dec=0.7136*64 */
- pmullw_m2r(MMX32_Vredcoeff, mm1); /* red*89dec=1.4013*64 */
- psraw_i2r(6, mm0); /* red=red/64 */
- psraw_i2r(6, mm1); /* red=red/64 */
-
- /* create L1 L2 (result in mm2,mm4) */
- /* L2=lum+cols */
- movq_m2r(*(mmx_t *)(lum+cols),mm3); /* 0 0 0 0 L3 L2 L1 L0 */
- punpckldq_r2r(mm3, mm2); /* L3 L2 L1 L0 l3 l2 l1 l0 */
- movq_r2r(mm2, mm4); /* L3 L2 L1 L0 l3 l2 l1 l0 */
- pand_m2r(MMX_FF00w, mm2); /* L3 0 L1 0 l3 0 l1 0 */
- pand_m2r(MMX_00FFw, mm4); /* 0 L2 0 L0 0 l2 0 l0 */
- psrlw_i2r(8, mm2); /* 0 L3 0 L1 0 l3 0 l1 */
-
- /* create R (result in mm6) */
- movq_r2r(mm2, mm5); /* 0 L3 0 L1 0 l3 0 l1 */
- movq_r2r(mm4, mm6); /* 0 L2 0 L0 0 l2 0 l0 */
- paddsw_r2r(mm1, mm5); /* lum1+red:x R3 x R1 x r3 x r1 */
- paddsw_r2r(mm1, mm6); /* lum1+red:x R2 x R0 x r2 x r0 */
- packuswb_r2r(mm5, mm5); /* R3 R1 r3 r1 R3 R1 r3 r1 */
- packuswb_r2r(mm6, mm6); /* R2 R0 r2 r0 R2 R0 r2 r0 */
- pxor_r2r(mm7, mm7); /* 00 00 00 00 00 00 00 00 */
- punpcklbw_r2r(mm5, mm6); /* R3 R2 R1 R0 r3 r2 r1 r0 */
-
- /* create Cb (result in mm1) */
- movd_m2r(*(mmx_t *)cr, mm1); /* 0 0 0 0 u3 u2 u1 u0 */
- punpcklbw_r2r(mm7, mm1); /* 0 u3 0 u2 00 u1 00 u0 */
- punpckldq_r2r(mm1, mm1); /* 00 u1 00 u0 00 u1 00 u0 */
- psubw_m2r(MMX_80w, mm1); /* mm1-128:u1 u1 u0 u0 u1 u1 u0 u0 */
- /* create Cb_g (result in mm5) */
- movq_r2r(mm1, mm5); /* u1 u1 u0 u0 u1 u1 u0 u0 */
- pmullw_m2r(MMX32_Ugrncoeff, mm5); /* blue*-109dec=1.7129*64 */
- pmullw_m2r(MMX32_Ubluecoeff, mm1); /* blue*114dec=1.78125*64 */
- psraw_i2r(6, mm5); /* blue=red/64 */
- psraw_i2r(6, mm1); /* blue=blue/64 */
-
- /* create G (result in mm7) */
- movq_r2r(mm2, mm3); /* 0 L3 0 L1 0 l3 0 l1 */
- movq_r2r(mm4, mm7); /* 0 L2 0 L0 0 l2 0 l1 */
- paddsw_r2r(mm5, mm3); /* lum1+Cb_g:x G3t x G1t x g3t x g1t */
- paddsw_r2r(mm5, mm7); /* lum1+Cb_g:x G2t x G0t x g2t x g0t */
- paddsw_r2r(mm0, mm3); /* lum1+Cr_g:x G3 x G1 x g3 x g1 */
- paddsw_r2r(mm0, mm7); /* lum1+blue:x G2 x G0 x g2 x g0 */
- packuswb_r2r(mm3, mm3); /* G3 G1 g3 g1 G3 G1 g3 g1 */
- packuswb_r2r(mm7, mm7); /* G2 G0 g2 g0 G2 G0 g2 g0 */
- punpcklbw_r2r(mm3, mm7); /* G3 G2 G1 G0 g3 g2 g1 g0 */
-
- /* create B (result in mm5) */
- movq_r2r(mm2, mm3); /* 0 L3 0 L1 0 l3 0 l1 */
- movq_r2r(mm4, mm5); /* 0 L2 0 L0 0 l2 0 l1 */
- paddsw_r2r(mm1, mm3); /* lum1+blue:x B3 x B1 x b3 x b1 */
- paddsw_r2r(mm1, mm5); /* lum1+blue:x B2 x B0 x b2 x b0 */
- packuswb_r2r(mm3, mm3); /* B3 B1 b3 b1 B3 B1 b3 b1 */
- packuswb_r2r(mm5, mm5); /* B2 B0 b2 b0 B2 B0 b2 b0 */
- punpcklbw_r2r(mm3, mm5); /* B3 B2 B1 B0 b3 b2 b1 b0 */
-
- /* fill destination row1 (needed are mm6=Rr,mm7=Gg,mm5=Bb) */
-
- pxor_r2r(mm2, mm2); /* 0 0 0 0 0 0 0 0 */
- pxor_r2r(mm4, mm4); /* 0 0 0 0 0 0 0 0 */
- movq_r2r(mm6, mm1); /* R3 R2 R1 R0 r3 r2 r1 r0 */
- movq_r2r(mm5, mm3); /* B3 B2 B1 B0 b3 b2 b1 b0 */
- /* process lower lum */
- punpcklbw_r2r(mm4, mm1); /* 0 r3 0 r2 0 r1 0 r0 */
- punpcklbw_r2r(mm4, mm3); /* 0 b3 0 b2 0 b1 0 b0 */
- movq_r2r(mm1, mm2); /* 0 r3 0 r2 0 r1 0 r0 */
- movq_r2r(mm3, mm0); /* 0 b3 0 b2 0 b1 0 b0 */
- punpcklwd_r2r(mm1, mm3); /* 0 r1 0 b1 0 r0 0 b0 */
- punpckhwd_r2r(mm2, mm0); /* 0 r3 0 b3 0 r2 0 b2 */
-
- pxor_r2r(mm2, mm2); /* 0 0 0 0 0 0 0 0 */
- movq_r2r(mm7, mm1); /* G3 G2 G1 G0 g3 g2 g1 g0 */
- punpcklbw_r2r(mm1, mm2); /* g3 0 g2 0 g1 0 g0 0 */
- punpcklwd_r2r(mm4, mm2); /* 0 0 g1 0 0 0 g0 0 */
- por_r2r(mm3, mm2); /* 0 r1 g1 b1 0 r0 g0 b0 */
- movq_r2m(mm2, *(mmx_t *)row1); /* wrote out ! row1 */
-
- pxor_r2r(mm2, mm2); /* 0 0 0 0 0 0 0 0 */
- punpcklbw_r2r(mm1, mm4); /* g3 0 g2 0 g1 0 g0 0 */
- punpckhwd_r2r(mm2, mm4); /* 0 0 g3 0 0 0 g2 0 */
- por_r2r(mm0, mm4); /* 0 r3 g3 b3 0 r2 g2 b2 */
- movq_r2m(mm4, *(mmx_t *)(row1+2)); /* wrote out ! row1 */
-
- /* fill destination row2 (needed are mm6=Rr,mm7=Gg,mm5=Bb) */
- /* this can be done "destructive" */
- pxor_r2r(mm2, mm2); /* 0 0 0 0 0 0 0 0 */
- punpckhbw_r2r(mm2, mm6); /* 0 R3 0 R2 0 R1 0 R0 */
- punpckhbw_r2r(mm1, mm5); /* G3 B3 G2 B2 G1 B1 G0 B0 */
- movq_r2r(mm5, mm1); /* G3 B3 G2 B2 G1 B1 G0 B0 */
- punpcklwd_r2r(mm6, mm1); /* 0 R1 G1 B1 0 R0 G0 B0 */
- movq_r2m(mm1, *(mmx_t *)(row1+cols)); /* wrote out ! row2 */
- punpckhwd_r2r(mm6, mm5); /* 0 R3 G3 B3 0 R2 G2 B2 */
- movq_r2m(mm5, *(mmx_t *)(row1+cols+2)); /* wrote out ! row2 */
-
- lum+=4;
- cr+=2;
- cb+=2;
- row1 +=4;
- }
- lum += cols;
- row1 += cols;
+ guint32 *row1 = (guint32 *) out; /* 32 bit target */
+ int cols4 = cols >> 2;
+
+ int y, x;
+
+ for (y = rows >> 1; y; y--) {
+ for (x = cols4; x; x--) {
+
+ /* create Cr (result in mm1) */
+ movd_m2r (*(mmx_t *) cb, mm1); /* 0 0 0 0 v3 v2 v1 v0 */
+ pxor_r2r (mm7, mm7); /* 00 00 00 00 00 00 00 00 */
+ movd_m2r (*(mmx_t *) lum, mm2); /* 0 0 0 0 l3 l2 l1 l0 */
+ punpcklbw_r2r (mm7, mm1); /* 0 v3 0 v2 00 v1 00 v0 */
+ punpckldq_r2r (mm1, mm1); /* 00 v1 00 v0 00 v1 00 v0 */
+ psubw_m2r (MMX_80w, mm1); /* mm1-128:r1 r1 r0 r0 r1 r1 r0 r0 */
+
+ /* create Cr_g (result in mm0) */
+ movq_r2r (mm1, mm0); /* r1 r1 r0 r0 r1 r1 r0 r0 */
+ pmullw_m2r (MMX32_Vgrncoeff, mm0); /* red*-46dec=0.7136*64 */
+ pmullw_m2r (MMX32_Vredcoeff, mm1); /* red*89dec=1.4013*64 */
+ psraw_i2r (6, mm0); /* red=red/64 */
+ psraw_i2r (6, mm1); /* red=red/64 */
+
+ /* create L1 L2 (result in mm2,mm4) */
+ /* L2=lum+cols */
+ movq_m2r (*(mmx_t *) (lum + cols), mm3); /* 0 0 0 0 L3 L2 L1 L0 */
+ punpckldq_r2r (mm3, mm2); /* L3 L2 L1 L0 l3 l2 l1 l0 */
+ movq_r2r (mm2, mm4); /* L3 L2 L1 L0 l3 l2 l1 l0 */
+ pand_m2r (MMX_FF00w, mm2); /* L3 0 L1 0 l3 0 l1 0 */
+ pand_m2r (MMX_00FFw, mm4); /* 0 L2 0 L0 0 l2 0 l0 */
+ psrlw_i2r (8, mm2); /* 0 L3 0 L1 0 l3 0 l1 */
+
+ /* create R (result in mm6) */
+ movq_r2r (mm2, mm5); /* 0 L3 0 L1 0 l3 0 l1 */
+ movq_r2r (mm4, mm6); /* 0 L2 0 L0 0 l2 0 l0 */
+ paddsw_r2r (mm1, mm5); /* lum1+red:x R3 x R1 x r3 x r1 */
+ paddsw_r2r (mm1, mm6); /* lum1+red:x R2 x R0 x r2 x r0 */
+ packuswb_r2r (mm5, mm5); /* R3 R1 r3 r1 R3 R1 r3 r1 */
+ packuswb_r2r (mm6, mm6); /* R2 R0 r2 r0 R2 R0 r2 r0 */
+ pxor_r2r (mm7, mm7); /* 00 00 00 00 00 00 00 00 */
+ punpcklbw_r2r (mm5, mm6); /* R3 R2 R1 R0 r3 r2 r1 r0 */
+
+ /* create Cb (result in mm1) */
+ movd_m2r (*(mmx_t *) cr, mm1); /* 0 0 0 0 u3 u2 u1 u0 */
+ punpcklbw_r2r (mm7, mm1); /* 0 u3 0 u2 00 u1 00 u0 */
+ punpckldq_r2r (mm1, mm1); /* 00 u1 00 u0 00 u1 00 u0 */
+ psubw_m2r (MMX_80w, mm1); /* mm1-128:u1 u1 u0 u0 u1 u1 u0 u0 */
+ /* create Cb_g (result in mm5) */
+ movq_r2r (mm1, mm5); /* u1 u1 u0 u0 u1 u1 u0 u0 */
+ pmullw_m2r (MMX32_Ugrncoeff, mm5); /* blue*-109dec=1.7129*64 */
+ pmullw_m2r (MMX32_Ubluecoeff, mm1); /* blue*114dec=1.78125*64 */
+ psraw_i2r (6, mm5); /* blue=red/64 */
+ psraw_i2r (6, mm1); /* blue=blue/64 */
+
+ /* create G (result in mm7) */
+ movq_r2r (mm2, mm3); /* 0 L3 0 L1 0 l3 0 l1 */
+ movq_r2r (mm4, mm7); /* 0 L2 0 L0 0 l2 0 l1 */
+ paddsw_r2r (mm5, mm3); /* lum1+Cb_g:x G3t x G1t x g3t x g1t */
+ paddsw_r2r (mm5, mm7); /* lum1+Cb_g:x G2t x G0t x g2t x g0t */
+ paddsw_r2r (mm0, mm3); /* lum1+Cr_g:x G3 x G1 x g3 x g1 */
+ paddsw_r2r (mm0, mm7); /* lum1+blue:x G2 x G0 x g2 x g0 */
+ packuswb_r2r (mm3, mm3); /* G3 G1 g3 g1 G3 G1 g3 g1 */
+ packuswb_r2r (mm7, mm7); /* G2 G0 g2 g0 G2 G0 g2 g0 */
+ punpcklbw_r2r (mm3, mm7); /* G3 G2 G1 G0 g3 g2 g1 g0 */
+
+ /* create B (result in mm5) */
+ movq_r2r (mm2, mm3); /* 0 L3 0 L1 0 l3 0 l1 */
+ movq_r2r (mm4, mm5); /* 0 L2 0 L0 0 l2 0 l1 */
+ paddsw_r2r (mm1, mm3); /* lum1+blue:x B3 x B1 x b3 x b1 */
+ paddsw_r2r (mm1, mm5); /* lum1+blue:x B2 x B0 x b2 x b0 */
+ packuswb_r2r (mm3, mm3); /* B3 B1 b3 b1 B3 B1 b3 b1 */
+ packuswb_r2r (mm5, mm5); /* B2 B0 b2 b0 B2 B0 b2 b0 */
+ punpcklbw_r2r (mm3, mm5); /* B3 B2 B1 B0 b3 b2 b1 b0 */
+
+ /* fill destination row1 (needed are mm6=Rr,mm7=Gg,mm5=Bb) */
+
+ pxor_r2r (mm2, mm2); /* 0 0 0 0 0 0 0 0 */
+ pxor_r2r (mm4, mm4); /* 0 0 0 0 0 0 0 0 */
+ movq_r2r (mm6, mm1); /* R3 R2 R1 R0 r3 r2 r1 r0 */
+ movq_r2r (mm5, mm3); /* B3 B2 B1 B0 b3 b2 b1 b0 */
+ /* process lower lum */
+ punpcklbw_r2r (mm4, mm1); /* 0 r3 0 r2 0 r1 0 r0 */
+ punpcklbw_r2r (mm4, mm3); /* 0 b3 0 b2 0 b1 0 b0 */
+ movq_r2r (mm1, mm2); /* 0 r3 0 r2 0 r1 0 r0 */
+ movq_r2r (mm3, mm0); /* 0 b3 0 b2 0 b1 0 b0 */
+ punpcklwd_r2r (mm1, mm3); /* 0 r1 0 b1 0 r0 0 b0 */
+ punpckhwd_r2r (mm2, mm0); /* 0 r3 0 b3 0 r2 0 b2 */
+
+ pxor_r2r (mm2, mm2); /* 0 0 0 0 0 0 0 0 */
+ movq_r2r (mm7, mm1); /* G3 G2 G1 G0 g3 g2 g1 g0 */
+ punpcklbw_r2r (mm1, mm2); /* g3 0 g2 0 g1 0 g0 0 */
+ punpcklwd_r2r (mm4, mm2); /* 0 0 g1 0 0 0 g0 0 */
+ por_r2r (mm3, mm2); /* 0 r1 g1 b1 0 r0 g0 b0 */
+ movq_r2m (mm2, *(mmx_t *) row1); /* wrote out ! row1 */
+
+ pxor_r2r (mm2, mm2); /* 0 0 0 0 0 0 0 0 */
+ punpcklbw_r2r (mm1, mm4); /* g3 0 g2 0 g1 0 g0 0 */
+ punpckhwd_r2r (mm2, mm4); /* 0 0 g3 0 0 0 g2 0 */
+ por_r2r (mm0, mm4); /* 0 r3 g3 b3 0 r2 g2 b2 */
+ movq_r2m (mm4, *(mmx_t *) (row1 + 2)); /* wrote out ! row1 */
+
+ /* fill destination row2 (needed are mm6=Rr,mm7=Gg,mm5=Bb) */
+ /* this can be done "destructive" */
+ pxor_r2r (mm2, mm2); /* 0 0 0 0 0 0 0 0 */
+ punpckhbw_r2r (mm2, mm6); /* 0 R3 0 R2 0 R1 0 R0 */
+ punpckhbw_r2r (mm1, mm5); /* G3 B3 G2 B2 G1 B1 G0 B0 */
+ movq_r2r (mm5, mm1); /* G3 B3 G2 B2 G1 B1 G0 B0 */
+ punpcklwd_r2r (mm6, mm1); /* 0 R1 G1 B1 0 R0 G0 B0 */
+ movq_r2m (mm1, *(mmx_t *) (row1 + cols)); /* wrote out ! row2 */
+ punpckhwd_r2r (mm6, mm5); /* 0 R3 G3 B3 0 R2 G2 B2 */
+ movq_r2m (mm5, *(mmx_t *) (row1 + cols + 2)); /* wrote out ! row2 */
+
+ lum += 4;
+ cr += 2;
+ cb += 2;
+ row1 += 4;
}
+ lum += cols;
+ row1 += cols;
+ }
- emms();
+ emms ();
}
#endif
-
#include <gstcolorspace.h>
G_BEGIN_DECLS
-
#if 0
typedef struct _GstColorspaceYUVTables GstColorspaceYUVTables;
-struct _GstColorspaceYUVTables {
+struct _GstColorspaceYUVTables
+{
int gammaCorrectFlag;
double gammaCorrect;
int chromaCorrectFlag;
typedef struct _GstColorspaceConverter GstColorspaceConverter;
-typedef void (*GstColorspaceConvertFunction) (GstColorspaceConverter *space, guchar *src, guchar *dest);
+typedef void (*GstColorspaceConvertFunction) (GstColorspaceConverter * space,
+ guchar * src, guchar * dest);
-struct _GstColorspaceConverter {
+struct _GstColorspaceConverter
+{
guint width;
guint height;
guint insize;
};
#endif
-void gst_colorspace_table_init (GstColorspace *space);
+void gst_colorspace_table_init (GstColorspace * space);
-void gst_colorspace_I420_to_rgb32(GstColorspace *space,
+void gst_colorspace_I420_to_rgb32 (GstColorspace * space,
unsigned char *src, unsigned char *dest);
-void gst_colorspace_I420_to_rgb24(GstColorspace *space,
+void gst_colorspace_I420_to_rgb24 (GstColorspace * space,
unsigned char *src, unsigned char *dest);
-void gst_colorspace_I420_to_rgb16(GstColorspace *space,
+void gst_colorspace_I420_to_rgb16 (GstColorspace * space,
unsigned char *src, unsigned char *dest);
-void gst_colorspace_YV12_to_rgb32(GstColorspace *space,
+void gst_colorspace_YV12_to_rgb32 (GstColorspace * space,
unsigned char *src, unsigned char *dest);
-void gst_colorspace_YV12_to_rgb24(GstColorspace *space,
+void gst_colorspace_YV12_to_rgb24 (GstColorspace * space,
unsigned char *src, unsigned char *dest);
-void gst_colorspace_YV12_to_rgb16(GstColorspace *space,
+void gst_colorspace_YV12_to_rgb16 (GstColorspace * space,
unsigned char *src, unsigned char *dest);
#if 0
-GstColorspaceYUVTables * gst_colorspace_init_yuv(long depth,
+GstColorspaceYUVTables *gst_colorspace_init_yuv (long depth,
long red_mask, long green_mask, long blue_mask);
#endif
#if 0
-GstColorspaceConverter* gst_colorspace_yuv2rgb_get_converter (const GstCaps *from, const GstCaps *to);
+GstColorspaceConverter *gst_colorspace_yuv2rgb_get_converter (const GstCaps *
+ from, const GstCaps * to);
#define gst_colorspace_convert(converter, src, dest) \
(converter)->convert((converter), (src), (dest))
-void gst_colorspace_converter_destroy (GstColorspaceConverter *space);
+void gst_colorspace_converter_destroy (GstColorspaceConverter * space);
#endif
G_END_DECLS
-
#endif
-
#include "gstdeinterlace.h"
/* elementfactory information */
-static GstElementDetails deinterlace_details = GST_ELEMENT_DETAILS (
- "Deinterlace",
- "Filter/Effect/Video",
- "Deinterlace video",
- "Wim Taymans <wim.taymans@chello.be>"
-);
+static GstElementDetails deinterlace_details =
+GST_ELEMENT_DETAILS ("Deinterlace",
+ "Filter/Effect/Video",
+ "Deinterlace video",
+ "Wim Taymans <wim.taymans@chello.be>");
/* Filter signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_DI_ONLY,
ARG_BLEND,
};
static GstStaticPadTemplate deinterlace_src_factory =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ( GST_VIDEO_CAPS_YUV ("I420"))
-);
+GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420"))
+ );
static GstStaticPadTemplate deinterlace_sink_factory =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ( GST_VIDEO_CAPS_YUV ("I420"))
-);
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420"))
+ );
-static GType gst_deinterlace_get_type (void);
+static GType gst_deinterlace_get_type (void);
-static void gst_deinterlace_base_init (gpointer g_class);
-static void gst_deinterlace_class_init (GstDeInterlaceClass *klass);
-static void gst_deinterlace_init (GstDeInterlace *filter);
+static void gst_deinterlace_base_init (gpointer g_class);
+static void gst_deinterlace_class_init (GstDeInterlaceClass * klass);
+static void gst_deinterlace_init (GstDeInterlace * filter);
-static void gst_deinterlace_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_deinterlace_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static void gst_deinterlace_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_deinterlace_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static void gst_deinterlace_chain (GstPad *pad, GstData *_data);
+static void gst_deinterlace_chain (GstPad * pad, GstData * _data);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_filter_signals[LAST_SIGNAL] = { 0 }; */
static GType
-gst_deinterlace_get_type(void) {
+gst_deinterlace_get_type (void)
+{
static GType deinterlace_type = 0;
if (!deinterlace_type) {
static const GTypeInfo deinterlace_info = {
- sizeof(GstDeInterlaceClass),
+ sizeof (GstDeInterlaceClass),
gst_deinterlace_base_init,
NULL,
- (GClassInitFunc)gst_deinterlace_class_init,
+ (GClassInitFunc) gst_deinterlace_class_init,
NULL,
NULL,
- sizeof(GstDeInterlace),
+ sizeof (GstDeInterlace),
0,
- (GInstanceInitFunc)gst_deinterlace_init,
+ (GInstanceInitFunc) gst_deinterlace_init,
};
- deinterlace_type = g_type_register_static(GST_TYPE_ELEMENT, "GstDeInterlace", &deinterlace_info, 0);
+ deinterlace_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstDeInterlace",
+ &deinterlace_info, 0);
}
return deinterlace_type;
}
static void
gst_deinterlace_base_init (gpointer g_class)
-{
+{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&deinterlace_src_factory));
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&deinterlace_sink_factory));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&deinterlace_src_factory));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&deinterlace_sink_factory));
gst_element_class_set_details (element_class, &deinterlace_details);
}
static void
-gst_deinterlace_class_init (GstDeInterlaceClass *klass)
+gst_deinterlace_class_init (GstDeInterlaceClass * 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);
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_DI_ONLY,
- g_param_spec_boolean("di_area_only","di_area_only","di_area_only",
- TRUE,G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_BLEND,
- g_param_spec_boolean("blend","blend","blend",
- TRUE,G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_THRESHOLD,
- g_param_spec_int("threshold","threshold","threshold",
- G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_EDGE_DETECT,
- g_param_spec_int("edge_detect","edge_detect","edge_detect",
- G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DI_ONLY, g_param_spec_boolean ("di_area_only", "di_area_only", "di_area_only", TRUE, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BLEND, g_param_spec_boolean ("blend", "blend", "blend", TRUE, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_THRESHOLD, g_param_spec_int ("threshold", "threshold", "threshold", G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_EDGE_DETECT, g_param_spec_int ("edge_detect", "edge_detect", "edge_detect", G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */
gobject_class->set_property = gst_deinterlace_set_property;
gobject_class->get_property = gst_deinterlace_get_property;
}
static GstPadLinkReturn
-gst_deinterlace_link (GstPad *pad, const GstCaps *caps)
+gst_deinterlace_link (GstPad * pad, const GstCaps * caps)
{
GstDeInterlace *filter;
GstStructure *structure;
GstPadLinkReturn ret;
- filter = GST_DEINTERLACE(gst_pad_get_parent (pad));
-
+ filter = GST_DEINTERLACE (gst_pad_get_parent (pad));
+
ret = gst_pad_try_set_caps (filter->srcpad, caps);
if (GST_PAD_LINK_FAILED (ret)) {
return ret;
gst_structure_get_int (structure, "width", &filter->width);
gst_structure_get_int (structure, "height", &filter->height);
- if (filter->picsize != (filter->width*filter->height)) {
- if (filter->src)
- g_free(filter->src);
- filter->picsize = filter->width*filter->height;
- filter->src = g_malloc(filter->picsize);
+ if (filter->picsize != (filter->width * filter->height)) {
+ if (filter->src)
+ g_free (filter->src);
+ filter->picsize = filter->width * filter->height;
+ filter->src = g_malloc (filter->picsize);
}
return GST_PAD_LINK_OK;
}
static void
-gst_deinterlace_init (GstDeInterlace *filter)
+gst_deinterlace_init (GstDeInterlace * filter)
{
- filter->sinkpad = gst_pad_new_from_template(
- gst_static_pad_template_get(&deinterlace_sink_factory),"sink");
- gst_pad_set_chain_function(filter->sinkpad,gst_deinterlace_chain);
- gst_pad_set_link_function(filter->sinkpad,gst_deinterlace_link);
- gst_element_add_pad(GST_ELEMENT(filter),filter->sinkpad);
-
- filter->srcpad = gst_pad_new_from_template(
- gst_static_pad_template_get(&deinterlace_src_factory),"src");
- gst_pad_set_link_function(filter->srcpad,gst_deinterlace_link);
- gst_element_add_pad(GST_ELEMENT(filter),filter->srcpad);
+ filter->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&deinterlace_sink_factory), "sink");
+ gst_pad_set_chain_function (filter->sinkpad, gst_deinterlace_chain);
+ gst_pad_set_link_function (filter->sinkpad, gst_deinterlace_link);
+ gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
+
+ filter->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&deinterlace_src_factory), "src");
+ gst_pad_set_link_function (filter->srcpad, gst_deinterlace_link);
+ gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
filter->show_deinterlaced_area_only = FALSE;
filter->blend = FALSE;
}
static void
-gst_deinterlace_chain (GstPad *pad, GstData *_data)
+gst_deinterlace_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstDeInterlace *filter;
yuvptr = GST_BUFFER_DATA (buf);
bShowDeinterlacedAreaOnly = filter->show_deinterlaced_area_only;
- memcpy(filter->src, yuvptr, filter->picsize);
+ memcpy (filter->src, yuvptr, filter->picsize);
- y_dst = yuvptr; /* dst y pointer */
- /* we should not change u,v because one u, v value stands for */
- /* 2 pixels per 2 lines = 4 pixel and we don't want to change */
- /* the color of */
+ y_dst = yuvptr; /* dst y pointer */
+ /* we should not change u,v because one u, v value stands for */
+ /* 2 pixels per 2 lines = 4 pixel and we don't want to change */
+ /* the color of */
- y_line = width;
+ y_line = width;
y_src = src;
iThreshold = iThreshold * iThreshold * 4;
iEdgeDetect = 180;
iEdgeDetect = iEdgeDetect * iEdgeDetect;
- y1 = 0; /* Avoid compiler warning. The value is not used. */
+ y1 = 0; /* Avoid compiler warning. The value is not used. */
for (x = 0; x < width; x++) {
psrc3 = y_src + x;
- y3 = *psrc3;
+ y3 = *psrc3;
psrc2 = psrc3 + y_line;
y2 = *psrc2;
pdst1 = y_dst + x;
y1 = y2;
y2 = y3;
if (y < height - 1) {
- y3 = *psrc3;
+ y3 = *psrc3;
} else {
- y3 = y1;
+ y3 = y1;
}
iInterlaceValue0 = iInterlaceValue1;
iInterlaceValue1 = iInterlaceValue2;
if (y < height)
- iInterlaceValue2 = ((y1 - y2) * (y3 - y2) -
- ((iEdgeDetect * (y1 - y3) * (y1 - y3)) >> 12))*10;
+ iInterlaceValue2 = ((y1 - y2) * (y3 - y2) -
+ ((iEdgeDetect * (y1 - y3) * (y1 - y3)) >> 12)) * 10;
else
- iInterlaceValue2 = 0;
-
- if (y > 0) {
- if (iInterlaceValue0 + 2 * iInterlaceValue1 + iInterlaceValue2 > iThreshold) {
- if (bBlend) {
- *pdst1 = (unsigned char)((y0 + 2*y1 + y2) >> 2);
- } else {
- /* this method seems to work better than blending if the */
- /* quality is pretty bad and the half pics don't fit together */
- if ((y % 2)==1) { /* if odd simply copy the value */
- *pdst1 = *psrc1;
- /**pdst1 = 0; // FIXME this is for adjusting an initial iThreshold */
- } else { /* even interpolate the even line (upper + lower)/2 */
- *pdst1 = (unsigned char)((y0 + y2) >> 1);
- /**pdst1 = 0; // FIXME this is for adjusting an initial iThreshold */
- }
- }
- } else {
- /* so we went below the treshold and therefore we don't have to */
- /* change anything */
- if (bShowDeinterlacedAreaOnly) {
- /* this is for testing to see how we should tune the treshhold */
- /* and shows as the things that haven't change because the */
- /* threshhold was to low?? (or shows that everything is ok :-) */
- *pdst1 = 0; /* blank the point and so the interlac area */
- } else {
- *pdst1 = *psrc1;
- }
- }
- pdst1 = pdst1 + y_line;
+ iInterlaceValue2 = 0;
+
+ if (y > 0) {
+ if (iInterlaceValue0 + 2 * iInterlaceValue1 + iInterlaceValue2 >
+ iThreshold) {
+ if (bBlend) {
+ *pdst1 = (unsigned char) ((y0 + 2 * y1 + y2) >> 2);
+ } else {
+ /* this method seems to work better than blending if the */
+ /* quality is pretty bad and the half pics don't fit together */
+ if ((y % 2) == 1) { /* if odd simply copy the value */
+ *pdst1 = *psrc1;
+ /**pdst1 = 0; // FIXME this is for adjusting an initial iThreshold */
+ } else { /* even interpolate the even line (upper + lower)/2 */
+ *pdst1 = (unsigned char) ((y0 + y2) >> 1);
+ /**pdst1 = 0; // FIXME this is for adjusting an initial iThreshold */
+ }
+ }
+ } else {
+ /* so we went below the treshold and therefore we don't have to */
+ /* change anything */
+ if (bShowDeinterlacedAreaOnly) {
+ /* this is for testing to see how we should tune the treshhold */
+ /* and shows as the things that haven't change because the */
+ /* threshhold was to low?? (or shows that everything is ok :-) */
+ *pdst1 = 0; /* blank the point and so the interlac area */
+ } else {
+ *pdst1 = *psrc1;
+ }
+ }
+ pdst1 = pdst1 + y_line;
}
}
}
}
static void
-gst_deinterlace_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_deinterlace_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstDeInterlace *filter;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_DEINTERLACE(object));
+ g_return_if_fail (GST_IS_DEINTERLACE (object));
- filter = GST_DEINTERLACE(object);
+ filter = GST_DEINTERLACE (object);
- switch (prop_id)
- {
+ switch (prop_id) {
case ARG_DI_ONLY:
filter->show_deinterlaced_area_only = g_value_get_boolean (value);
break;
}
static void
-gst_deinterlace_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_deinterlace_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstDeInterlace *filter;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_DEINTERLACE(object));
+ g_return_if_fail (GST_IS_DEINTERLACE (object));
- filter = GST_DEINTERLACE(object);
+ filter = GST_DEINTERLACE (object);
switch (prop_id) {
case ARG_DI_ONLY:
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- if (!gst_element_register (plugin, "deinterlace", GST_RANK_NONE, gst_deinterlace_get_type()))
+ if (!gst_element_register (plugin, "deinterlace", GST_RANK_NONE,
+ gst_deinterlace_get_type ()))
return FALSE;
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "deinterlace",
- "Deinterlace video",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN
-);
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "deinterlace",
+ "Deinterlace video", plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN);
/* #include <gst/meta/audioraw.h> */
G_BEGIN_DECLS
-
#define GST_TYPE_DEINTERLACE \
(gst_deinterlace_get_type())
#define GST_DEINTERLACE(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DEINTERLACE))
#define GST_IS_DEINTERLACE_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DEINTERLACE))
-
typedef struct _GstDeInterlace GstDeInterlace;
typedef struct _GstDeInterlaceClass GstDeInterlaceClass;
-struct _GstDeInterlace {
+struct _GstDeInterlace
+{
GstElement element;
GstPad *sinkpad, *srcpad;
gboolean show_deinterlaced_area_only;
gboolean blend;
- gint threshold_blend; /* here we start blending */
- gint threshold; /* here we start interpolating TODO FIXME */
+ gint threshold_blend; /* here we start blending */
+ gint threshold; /* here we start interpolating TODO FIXME */
gint edge_detect;
gint picsize;
};
-struct _GstDeInterlaceClass {
+struct _GstDeInterlaceClass
+{
GstElementClass parent_class;
};
G_END_DECLS
-
#endif /* __GST_DEINTERLACE_H__ */
#include "gstfestival.h"
#include <gst/audio/audio.h>
-static void gst_festival_base_init (gpointer g_class);
-static void gst_festival_class_init (GstFestivalClass *klass);
-static void gst_festival_init (GstFestival *festival);
+static void gst_festival_base_init (gpointer g_class);
+static void gst_festival_class_init (GstFestivalClass * klass);
+static void gst_festival_init (GstFestival * festival);
-static void gst_festival_chain (GstPad *pad, GstData *_data);
-static GstElementStateReturn
- gst_festival_change_state (GstElement *element);
+static void gst_festival_chain (GstPad * pad, GstData * _data);
+static GstElementStateReturn gst_festival_change_state (GstElement * element);
-static FT_Info* festival_default_info (void);
-static char* socket_receive_file_to_buff (int fd,int *size);
-static char* client_accept_s_expr (int fd);
+static FT_Info *festival_default_info (void);
+static char *socket_receive_file_to_buff (int fd, int *size);
+static char *client_accept_s_expr (int fd);
/* elementfactory information */
-static GstElementDetails gst_festival_details = GST_ELEMENT_DETAILS (
- "Festival synthesizer",
- "Filter/Effect/Audio",
- "Synthesizes plain text into audio",
- "Wim Taymans <wim.taymans@chello.be>"
-);
+static GstElementDetails gst_festival_details =
+GST_ELEMENT_DETAILS ("Festival synthesizer",
+ "Filter/Effect/Audio",
+ "Synthesizes plain text into audio",
+ "Wim Taymans <wim.taymans@chello.be>");
static GstStaticPadTemplate sink_template_factory =
-GST_STATIC_PAD_TEMPLATE (
- "festival_sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ( "text/plain" )
-);
+GST_STATIC_PAD_TEMPLATE ("festival_sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("text/plain")
+ );
static GstStaticPadTemplate src_template_factory =
-GST_STATIC_PAD_TEMPLATE (
- "festival_src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ( "audio/x-raw-int, "
- "endianness = (int) BYTE_ORDER, "
- "signed = (boolean) TRUE, "
- "width = (int) 16, "
- "depth = (int) 16, "
- "rate = (int) 16000, "
- "channels = (int) 1"
- )
-);
+GST_STATIC_PAD_TEMPLATE ("festival_src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "endianness = (int) BYTE_ORDER, "
+ "signed = (boolean) TRUE, "
+ "width = (int) 16, "
+ "depth = (int) 16, " "rate = (int) 16000, " "channels = (int) 1")
+ );
/* Festival signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
/* FILL ME */
};
static GstElementClass *parent_class = NULL;
+
/*static guint gst_festival_signals[LAST_SIGNAL] = { 0 }; */
GType
-gst_festival_get_type (void)
+gst_festival_get_type (void)
{
static GType festival_type = 0;
if (!festival_type) {
static const GTypeInfo festival_info = {
- sizeof(GstFestivalClass),
+ sizeof (GstFestivalClass),
gst_festival_base_init,
NULL,
(GClassInitFunc) gst_festival_class_init,
NULL,
NULL,
- sizeof(GstFestival),
+ sizeof (GstFestival),
0,
(GInstanceInitFunc) gst_festival_init,
};
- festival_type = g_type_register_static (GST_TYPE_ELEMENT, "GstFestival", &festival_info, 0);
+ festival_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstFestival", &festival_info,
+ 0);
}
return festival_type;
}
static void
gst_festival_base_init (gpointer g_class)
-{
+{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
/* register src pads */
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&src_template_factory));
- gst_element_class_set_details (element_class, &gst_festival_details);
+ gst_element_class_set_details (element_class, &gst_festival_details);
}
static void
-gst_festival_class_init (GstFestivalClass *klass)
+gst_festival_class_init (GstFestivalClass * klass)
{
GstElementClass *gstelement_class;
- gstelement_class = (GstElementClass*) klass;
+ gstelement_class = (GstElementClass *) klass;
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
gstelement_class->change_state = gst_festival_change_state;
}
-static void
-gst_festival_init (GstFestival *festival)
+static void
+gst_festival_init (GstFestival * festival)
{
- festival->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&sink_template_factory), "sink");
+ festival->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&sink_template_factory), "sink");
gst_pad_set_chain_function (festival->sinkpad, gst_festival_chain);
gst_element_add_pad (GST_ELEMENT (festival), festival->sinkpad);
- festival->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&src_template_factory), "src");
+ festival->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&src_template_factory), "src");
gst_element_add_pad (GST_ELEMENT (festival), festival->srcpad);
- festival->info = festival_default_info();
+ festival->info = festival_default_info ();
}
static void
-gst_festival_chain (GstPad *pad, GstData *_data)
+gst_festival_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
gchar *wavefile;
festival = GST_FESTIVAL (gst_pad_get_parent (pad));
GST_DEBUG ("gst_festival_chain: got buffer in '%s'",
- gst_object_get_name (GST_OBJECT (festival)));
+ gst_object_get_name (GST_OBJECT (festival)));
+
+ fd = fdopen (dup (festival->info->server_fd), "wb");
- fd = fdopen(dup(festival->info->server_fd),"wb");
-
size = GST_BUFFER_SIZE (buf);
/* Copy text over to server, escaping any quotes */
- fprintf(fd,"(tts_textall \"\n");
- for (p=GST_BUFFER_DATA(buf); p && (*p != '\0') && size; p++, size--)
- {
+ fprintf (fd, "(tts_textall \"\n");
+ for (p = GST_BUFFER_DATA (buf); p && (*p != '\0') && size; p++, size--) {
if ((*p == '"') || (*p == '\\'))
- putc('\\',fd);
- putc(*p,fd);
+ putc ('\\', fd);
+ putc (*p, fd);
}
- fprintf(fd,"\" \"%s\")\n",festival->info->text_mode);
- fclose(fd);
+ fprintf (fd, "\" \"%s\")\n", festival->info->text_mode);
+ fclose (fd);
/* Read back info from server */
/* This assumes only one waveform will come back, also LP is unlikely */
wavefile = NULL;
do {
- for (n=0; n < 3; )
- n += read(festival->info->server_fd,ack+n,3-n);
+ for (n = 0; n < 3;)
+ n += read (festival->info->server_fd, ack + n, 3 - n);
ack[3] = '\0';
- if (strcmp(ack,"WV\n") == 0) /* receive a waveform */
- wavefile = socket_receive_file_to_buff (festival->info->server_fd, &filesize);
- else if (strcmp(ack,"LP\n") == 0) /* receive an s-expr */
- client_accept_s_expr(festival->info->server_fd);
- else if (strcmp(ack,"ER\n") == 0) /* server got an error */
- {
- fprintf(stderr,"festival_client: server returned error\n");
- break;
+ if (strcmp (ack, "WV\n") == 0) /* receive a waveform */
+ wavefile =
+ socket_receive_file_to_buff (festival->info->server_fd, &filesize);
+ else if (strcmp (ack, "LP\n") == 0) /* receive an s-expr */
+ client_accept_s_expr (festival->info->server_fd);
+ else if (strcmp (ack, "ER\n") == 0) { /* server got an error */
+ fprintf (stderr, "festival_client: server returned error\n");
+ break;
}
if (wavefile) {
outbuf = gst_buffer_new ();
GST_BUFFER_DATA (outbuf) = wavefile;
GST_BUFFER_SIZE (outbuf) = filesize;
-
+
gst_pad_push (festival->srcpad, GST_DATA (outbuf));
wavefile = NULL;
}
- } while (strcmp(ack,"OK\n") != 0);
-
+ } while (strcmp (ack, "OK\n") != 0);
+
gst_buffer_unref (buf);
}
-static FT_Info*
+static FT_Info *
festival_default_info (void)
{
FT_Info *info;
- info = (FT_Info *)malloc(1 * sizeof(FT_Info));
-
+
+ info = (FT_Info *) malloc (1 * sizeof (FT_Info));
+
info->server_host = FESTIVAL_DEFAULT_SERVER_HOST;
info->server_port = FESTIVAL_DEFAULT_SERVER_PORT;
info->text_mode = FESTIVAL_DEFAULT_TEXT_MODE;
info->server_fd = -1;
-
+
return info;
}
static int
festival_socket_open (const char *host, int port)
-{
- /* Return an FD to a remote server */
+{
+ /* Return an FD to a remote server */
struct sockaddr_in serv_addr;
struct hostent *serverhost;
int fd;
- fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ fd = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
- if (fd < 0)
- {
- fprintf(stderr,"festival_client: can't get socket\n");
+ if (fd < 0) {
+ fprintf (stderr, "festival_client: can't get socket\n");
return -1;
}
- memset(&serv_addr, 0, sizeof(serv_addr));
- if ((serv_addr.sin_addr.s_addr = inet_addr(host)) == -1)
- {
+ memset (&serv_addr, 0, sizeof (serv_addr));
+ if ((serv_addr.sin_addr.s_addr = inet_addr (host)) == -1) {
/* its a name rather than an ipnum */
- serverhost = gethostbyname(host);
- if (serverhost == (struct hostent *)0)
- {
- fprintf(stderr,"festival_client: gethostbyname failed\n");
+ serverhost = gethostbyname (host);
+ if (serverhost == (struct hostent *) 0) {
+ fprintf (stderr, "festival_client: gethostbyname failed\n");
return -1;
}
- memmove(&serv_addr.sin_addr,serverhost->h_addr, serverhost->h_length);
+ memmove (&serv_addr.sin_addr, serverhost->h_addr, serverhost->h_length);
}
serv_addr.sin_family = AF_INET;
- serv_addr.sin_port = htons(port);
+ serv_addr.sin_port = htons (port);
- if (connect(fd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) != 0)
- {
- fprintf(stderr,"festival_client: connect to server failed\n");
+ if (connect (fd, (struct sockaddr *) &serv_addr, sizeof (serv_addr)) != 0) {
+ fprintf (stderr, "festival_client: connect to server failed\n");
return -1;
}
}
-static char*
+static char *
client_accept_s_expr (int fd)
{
/* Read s-expression from server, as a char * */
char *expr;
int filesize;
- expr = socket_receive_file_to_buff(fd,&filesize);
+ expr = socket_receive_file_to_buff (fd, &filesize);
expr[filesize] = '\0';
return expr;
}
-static char*
+static char *
socket_receive_file_to_buff (int fd, int *size)
{
/* Receive file (probably a waveform file) from socket using */
/* Festival key stuff technique, but long winded I know, sorry */
/* but will receive any file without closeing the stream or */
/* using OOB data */
- static const char *file_stuff_key = "ft_StUfF_key"; /* must == Festival's key */
+ static const char *file_stuff_key = "ft_StUfF_key"; /* must == Festival's key */
char *buff;
int bufflen;
- int n,k,i;
+ int n, k, i;
char c;
bufflen = 1024;
- buff = (char *)malloc(bufflen);
- *size=0;
-
- for (k=0; file_stuff_key[k] != '\0';)
- {
- n = read(fd,&c,1);
- if (n==0) break; /* hit stream eof before end of file */
- if ((*size)+k+1 >= bufflen) {
+ buff = (char *) malloc (bufflen);
+ *size = 0;
+
+ for (k = 0; file_stuff_key[k] != '\0';) {
+ n = read (fd, &c, 1);
+ if (n == 0)
+ break; /* hit stream eof before end of file */
+ if ((*size) + k + 1 >= bufflen) {
/* +1 so you can add a NULL if you want */
- bufflen += bufflen/4;
- buff = (char *)realloc(buff,bufflen);
+ bufflen += bufflen / 4;
+ buff = (char *) realloc (buff, bufflen);
}
if (file_stuff_key[k] == c)
k++;
- else if ((c == 'X') && (file_stuff_key[k+1] == '\0')) {
+ else if ((c == 'X') && (file_stuff_key[k + 1] == '\0')) {
/* It looked like the key but wasn't */
- for (i=0; i < k; i++,(*size)++)
- buff[*size] = file_stuff_key[i];
- k=0;
+ for (i = 0; i < k; i++, (*size)++)
+ buff[*size] = file_stuff_key[i];
+ k = 0;
/* omit the stuffed 'X' */
- }
- else {
- for (i=0; i < k; i++,(*size)++)
- buff[*size] = file_stuff_key[i];
- k=0;
+ } else {
+ for (i = 0; i < k; i++, (*size)++)
+ buff[*size] = file_stuff_key[i];
+ k = 0;
buff[*size] = c;
(*size)++;
}
/***********************************************************************/
static gboolean
-gst_festival_open (GstFestival *festival)
+gst_festival_open (GstFestival * festival)
{
/* Open socket to server */
if (festival->info == NULL)
- festival->info = festival_default_info();
+ festival->info = festival_default_info ();
- festival->info->server_fd =
- festival_socket_open(festival->info->server_host, festival->info->server_port);
+ festival->info->server_fd =
+ festival_socket_open (festival->info->server_host,
+ festival->info->server_port);
if (festival->info->server_fd == -1)
return FALSE;
}
static void
-gst_festival_close (GstFestival *festival)
+gst_festival_close (GstFestival * festival)
{
if (festival->info == NULL)
return;
if (festival->info->server_fd != -1)
- close(festival->info->server_fd);
+ close (festival->info->server_fd);
return;
}
static GstElementStateReturn
-gst_festival_change_state (GstElement *element)
+gst_festival_change_state (GstElement * element)
{
g_return_val_if_fail (GST_IS_FESTIVAL (element), GST_STATE_FAILURE);
} else {
if (!GST_FLAG_IS_SET (element, GST_FESTIVAL_OPEN)) {
if (!gst_festival_open (GST_FESTIVAL (element)))
- return GST_STATE_FAILURE;
+ return GST_STATE_FAILURE;
}
}
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- if (!gst_element_register (plugin, "festival", GST_RANK_NONE, GST_TYPE_FESTIVAL))
+ if (!gst_element_register (plugin, "festival", GST_RANK_NONE,
+ GST_TYPE_FESTIVAL))
return FALSE;
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "festival",
- "Synthesizes plain text into audio",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN
-);
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "festival",
+ "Synthesizes plain text into audio",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN);
#include <gst/gst.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define FESTIVAL_DEFAULT_SERVER_HOST "localhost"
#define FESTIVAL_DEFAULT_SERVER_PORT 1314
#define FESTIVAL_DEFAULT_TEXT_MODE "fundamental"
-typedef struct FT_Info
-{
+ typedef struct FT_Info
+ {
int encoding;
char *server_host;
int server_port;
char *text_mode;
-
+
int server_fd;
-} FT_Info;
+ } FT_Info;
#define GST_TYPE_FESTIVAL \
(gst_festival_get_type())
#define GST_IS_FESTIVAL_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FESTIVAL))
-typedef enum {
- GST_FESTIVAL_OPEN = GST_ELEMENT_FLAG_LAST,
+ typedef enum
+ {
+ GST_FESTIVAL_OPEN = GST_ELEMENT_FLAG_LAST,
- GST_FESTIVAL_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
-} GstFestivalFlags;
+ GST_FESTIVAL_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
+ } GstFestivalFlags;
-typedef struct _GstFestival GstFestival;
-typedef struct _GstFestivalClass GstFestivalClass;
+ typedef struct _GstFestival GstFestival;
+ typedef struct _GstFestivalClass GstFestivalClass;
-struct _GstFestival {
- GstElement element;
+ struct _GstFestival
+ {
+ GstElement element;
- /* pads */
- GstPad *sinkpad,*srcpad;
+ /* pads */
+ GstPad *sinkpad, *srcpad;
- FT_Info *info;
-};
+ FT_Info *info;
+ };
-struct _GstFestivalClass {
- GstElementClass parent_class;
-};
+ struct _GstFestivalClass
+ {
+ GstElementClass parent_class;
+ };
-GType gst_festival_get_type(void);
+ GType gst_festival_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_FESTIVAL_H__ */
+#endif /* __GST_FESTIVAL_H__ */
#include <string.h> /* memmove */
/* elementfactory information */
-static GstElementDetails gst_bpwsinc_details = GST_ELEMENT_DETAILS (
- "BPWSinc",
- "Filter/Effect/Audio",
- "Band-Pass Windowed sinc filter",
- "Thomas <thomas@apestaart.org>, "
- "Steven W. Smith"
-);
-
-enum {
+static GstElementDetails gst_bpwsinc_details = GST_ELEMENT_DETAILS ("BPWSinc",
+ "Filter/Effect/Audio",
+ "Band-Pass Windowed sinc filter",
+ "Thomas <thomas@apestaart.org>, " "Steven W. Smith");
+
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_LENGTH,
ARG_LOWER_FREQUENCY,
double frequency;
double lower_frequency, upper_frequency;
- int wing_size; /* length of a "wing" of the filter;
- actual length is 2 * wing_size + 1 */
+ int wing_size; /* length of a "wing" of the filter;
+ actual length is 2 * wing_size + 1 */
- gfloat *residue; /* buffer for left-over samples from previous buffer */
+ gfloat *residue; /* buffer for left-over samples from previous buffer */
double *kernel;
};
struct _GstBPWSincClass
{
- GstElementClass parent_class;
+ GstElementClass parent_class;
};
-static void gst_bpwsinc_base_init (gpointer g_class);
-static void gst_bpwsinc_class_init (GstBPWSincClass * klass);
-static void gst_bpwsinc_init (GstBPWSinc * filter);
+static void gst_bpwsinc_base_init (gpointer g_class);
+static void gst_bpwsinc_class_init (GstBPWSincClass * klass);
+static void gst_bpwsinc_init (GstBPWSinc * filter);
-static void gst_bpwsinc_set_property (GObject * object, guint prop_id,
- const GValue * value,
- GParamSpec * pspec);
-static void gst_bpwsinc_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec);
+static void gst_bpwsinc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_bpwsinc_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static void gst_bpwsinc_chain (GstPad * pad, GstData *_data);
+static void gst_bpwsinc_chain (GstPad * pad, GstData * _data);
static GstPadLinkReturn
- gst_bpwsinc_sink_connect (GstPad * pad, const GstCaps * caps);
+gst_bpwsinc_sink_connect (GstPad * pad, const GstCaps * caps);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_bpwsinc_signals[LAST_SIGNAL] = { 0 }; */
-GType gst_bpwsinc_get_type (void)
+GType
+gst_bpwsinc_get_type (void)
{
static GType bpwsinc_type = 0;
if (!bpwsinc_type) {
static const GTypeInfo bpwsinc_info = {
- sizeof (GstBPWSincClass),
- gst_bpwsinc_base_init,
+ sizeof (GstBPWSincClass),
+ gst_bpwsinc_base_init,
NULL,
(GClassInitFunc) gst_bpwsinc_class_init, NULL, NULL,
sizeof (GstBPWSinc), 0,
(GInstanceInitFunc) gst_bpwsinc_init,
};
- bpwsinc_type = g_type_register_static (GST_TYPE_ELEMENT, "GstBPWSinc",
- &bpwsinc_info, 0);
+ bpwsinc_type = g_type_register_static (GST_TYPE_ELEMENT, "GstBPWSinc",
+ &bpwsinc_info, 0);
}
return bpwsinc_type;
}
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_filter_src_template));
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&gst_filter_sink_template));
+ gst_static_pad_template_get (&gst_filter_sink_template));
- gst_element_class_set_details (element_class, &gst_bpwsinc_details);
+ gst_element_class_set_details (element_class, &gst_bpwsinc_details);
}
static void
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOWER_FREQUENCY,
- g_param_spec_double ("lower-frequency", "Lower Frequency",
- "Cut-off lower frequency (relative to sample rate)",
- 0.0, 0.5,
- 0, G_PARAM_READWRITE));
+ g_param_spec_double ("lower-frequency", "Lower Frequency",
+ "Cut-off lower frequency (relative to sample rate)",
+ 0.0, 0.5, 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_UPPER_FREQUENCY,
- g_param_spec_double ("upper-frequency", "Upper Frequency",
- "Cut-off upper frequency (relative to sample rate)",
- 0.0, 0.5,
- 0, G_PARAM_READWRITE));
+ g_param_spec_double ("upper-frequency", "Upper Frequency",
+ "Cut-off upper frequency (relative to sample rate)",
+ 0.0, 0.5, 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LENGTH,
- g_param_spec_int ("length", "Length",
- "N such that the filter length = 2N + 1",
- 1, G_MAXINT,
- 1, G_PARAM_READWRITE));
+ g_param_spec_int ("length", "Length",
+ "N such that the filter length = 2N + 1",
+ 1, G_MAXINT, 1, G_PARAM_READWRITE));
gobject_class->set_property = gst_bpwsinc_set_property;
gobject_class->get_property = gst_bpwsinc_get_property;
static void
gst_bpwsinc_init (GstBPWSinc * filter)
{
- filter->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&gst_filter_sink_template), "sink");
+ filter->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_filter_sink_template), "sink");
gst_pad_set_chain_function (filter->sinkpad, gst_bpwsinc_chain);
gst_pad_set_link_function (filter->sinkpad, gst_bpwsinc_sink_connect);
gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
- filter->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&gst_filter_src_template), "src");
+ filter->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_filter_src_template), "src");
gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
filter->wing_size = 50;
int len = 0;
double *kernel_lp, *kernel_hp;
GstPadLinkReturn set_retval;
-
+
GstBPWSinc *filter = GST_BPWSINC (gst_pad_get_parent (pad));
g_assert (GST_IS_PAD (pad));
g_assert (caps != NULL);
set_retval = gst_pad_try_set_caps (filter->srcpad, caps);
-
- if (set_retval > 0)
- {
+
+ if (set_retval > 0) {
len = filter->wing_size;
/* fill the lp kernel */
- GST_DEBUG (
- "bpwsinc: initializing LP kernel of length %d with cut-off %f",
- len * 2 + 1, filter->lower_frequency);
+ GST_DEBUG ("bpwsinc: initializing LP kernel of length %d with cut-off %f",
+ len * 2 + 1, filter->lower_frequency);
kernel_lp = (double *) g_malloc (sizeof (double) * (2 * len + 1));
- for (i = 0; i <= len * 2; ++i)
- {
+ for (i = 0; i <= len * 2; ++i) {
if (i == len)
kernel_lp[i] = 2 * M_PI * filter->lower_frequency;
else
- kernel_lp[i] = sin (2 * M_PI * filter->lower_frequency * (i - len))
- / (i - len);
+ kernel_lp[i] = sin (2 * M_PI * filter->lower_frequency * (i - len))
+ / (i - len);
/* Blackman windowing */
- kernel_lp[i] *= (0.42 - 0.5 * cos (M_PI * i / len)
- + 0.08 * cos (2 * M_PI * i / len));
+ kernel_lp[i] *= (0.42 - 0.5 * cos (M_PI * i / len)
+ + 0.08 * cos (2 * M_PI * i / len));
}
/* normalize for unity gain at DC
* FIXME: sure this is not supposed to be quadratic ? */
sum = 0.0;
- for (i = 0; i <= len * 2; ++i) sum += kernel_lp[i];
- for (i = 0; i <= len * 2; ++i) kernel_lp[i] /= sum;
+ for (i = 0; i <= len * 2; ++i)
+ sum += kernel_lp[i];
+ for (i = 0; i <= len * 2; ++i)
+ kernel_lp[i] /= sum;
/* fill the hp kernel */
- GST_DEBUG (
- "bpwsinc: initializing HP kernel of length %d with cut-off %f",
- len * 2 + 1, filter->upper_frequency);
+ GST_DEBUG ("bpwsinc: initializing HP kernel of length %d with cut-off %f",
+ len * 2 + 1, filter->upper_frequency);
kernel_hp = (double *) g_malloc (sizeof (double) * (2 * len + 1));
- for (i = 0; i <= len * 2; ++i)
- {
+ for (i = 0; i <= len * 2; ++i) {
if (i == len)
kernel_hp[i] = 2 * M_PI * filter->upper_frequency;
else
- kernel_hp[i] = sin (2 * M_PI * filter->upper_frequency * (i - len))
- / (i - len);
+ kernel_hp[i] = sin (2 * M_PI * filter->upper_frequency * (i - len))
+ / (i - len);
/* Blackman windowing */
- kernel_hp[i] *= (0.42 - 0.5 * cos (M_PI * i / len)
- + 0.08 * cos (2 * M_PI * i / len));
+ kernel_hp[i] *= (0.42 - 0.5 * cos (M_PI * i / len)
+ + 0.08 * cos (2 * M_PI * i / len));
}
/* normalize for unity gain at DC
* FIXME: sure this is not supposed to be quadratic ? */
sum = 0.0;
- for (i = 0; i <= len * 2; ++i) sum += kernel_hp[i];
- for (i = 0; i <= len * 2; ++i) kernel_hp[i] /= sum;
+ for (i = 0; i <= len * 2; ++i)
+ sum += kernel_hp[i];
+ for (i = 0; i <= len * 2; ++i)
+ kernel_hp[i] /= sum;
/* do spectral inversion to get a HP filter */
- for (i = 0; i <= len * 2; ++i) kernel_hp[i] = -kernel_hp[i];
+ for (i = 0; i <= len * 2; ++i)
+ kernel_hp[i] = -kernel_hp[i];
kernel_hp[len] += 1;
/* combine the two filters */
filter->kernel[i] = kernel_lp[i] + kernel_hp[i];
/* do spectral inversion to go from band reject to bandpass */
- for (i = 0; i <= len * 2; ++i) filter->kernel[i] = -filter->kernel[i];
+ for (i = 0; i <= len * 2; ++i)
+ filter->kernel[i] = -filter->kernel[i];
filter->kernel[len] += 1;
/* free the helper kernels */
/* set up the residue memory space */
filter->residue = (gfloat *) g_malloc (sizeof (gfloat) * (len * 2 + 1));
- for (i = 0; i <= len * 2; ++i) filter->residue[i] = 0.0;
+ for (i = 0; i <= len * 2; ++i)
+ filter->residue[i] = 0.0;
}
return set_retval;
}
static void
-gst_bpwsinc_chain (GstPad *pad, GstData *_data)
+gst_bpwsinc_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstBPWSinc *filter;
memcpy (&input[residue_samples], src, sizeof (gfloat) * input_samples);
/* copy the tail of the current input buffer to the residue */
memcpy (filter->residue, &src[input_samples - residue_samples],
- sizeof (gfloat) * residue_samples);
+ sizeof (gfloat) * residue_samples);
/* convolution */
/* since we copied the previous set of samples we needed before the actual
* input data, we need to add the filter length to our indices for input */
- for (i = 0; i < input_samples; ++i)
- {
+ for (i = 0; i < input_samples; ++i) {
src[i] = 0.0;
for (j = 0; j < residue_samples; ++j)
src[i] += input[i - j + residue_samples] * filter->kernel[j];
}
-
+
g_free (input);
gst_pad_push (filter->srcpad, GST_DATA (buf));
}
static void
-gst_bpwsinc_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec)
+gst_bpwsinc_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstBPWSinc *filter;
switch (prop_id) {
case ARG_LENGTH:
- filter->wing_size = g_value_get_int (value);
- break;
+ filter->wing_size = g_value_get_int (value);
+ break;
case ARG_LOWER_FREQUENCY:
- filter->lower_frequency = g_value_get_double (value);
- break;
+ filter->lower_frequency = g_value_get_double (value);
+ break;
case ARG_UPPER_FREQUENCY:
- filter->upper_frequency = g_value_get_double (value);
- break;
+ filter->upper_frequency = g_value_get_double (value);
+ break;
default:
break;
}
}
static void
-gst_bpwsinc_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec)
+gst_bpwsinc_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstBPWSinc *filter;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_BPWSINC (object));
-
+
filter = GST_BPWSINC (object);
switch (prop_id) {
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
-}
-
+}
#include <gst/audio/audio.h>
-struct _elements_entry {
+struct _elements_entry
+{
gchar *name;
- GType (*type) (void);
+ GType (*type) (void);
};
static struct _elements_entry _elements[] = {
- { "iir", gst_iir_get_type },
- { "lpwsinc", gst_lpwsinc_get_type },
- { "bpwsinc", gst_bpwsinc_get_type },
- { NULL, 0 },
+ {"iir", gst_iir_get_type},
+ {"lpwsinc", gst_lpwsinc_get_type},
+ {"bpwsinc", gst_bpwsinc_get_type},
+ {NULL, 0},
};
-GstStaticPadTemplate gst_filter_src_template =
-GST_STATIC_PAD_TEMPLATE (
- "src",
+GstStaticPadTemplate gst_filter_src_template = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ( GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS )
-);
+ GST_STATIC_CAPS (GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS)
+ );
-GstStaticPadTemplate gst_filter_sink_template =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
+GstStaticPadTemplate gst_filter_sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ( GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS )
-);
+ GST_STATIC_CAPS (GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS)
+ );
static gboolean
plugin_init (GstPlugin * plugin)
gint i = 0;
while (_elements[i].name) {
- if (!gst_element_register (plugin, _elements[i].name, GST_RANK_NONE, _elements[i].type()))
+ if (!gst_element_register (plugin, _elements[i].name, GST_RANK_NONE,
+ _elements[i].type ()))
return FALSE;
i++;
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "filter",
- "IIR, lpwsinc and bpwsinc audio filter elements",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN
-);
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "filter",
+ "IIR, lpwsinc and bpwsinc audio filter elements",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN);
#include "gstfilter.h"
#include "iir.h"
-static GstElementDetails gst_iir_details = GST_ELEMENT_DETAILS (
- "IIR",
- "Filter/Effect/Audio",
- "IIR filter based on vorbis code",
- "Monty <monty@xiph.org>, "
- "Thomas <thomas@apestaart.org>"
-);
-
-enum {
+static GstElementDetails gst_iir_details = GST_ELEMENT_DETAILS ("IIR",
+ "Filter/Effect/Audio",
+ "IIR filter based on vorbis code",
+ "Monty <monty@xiph.org>, " "Thomas <thomas@apestaart.org>");
+
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_A,
ARG_B,
struct _GstIIRClass
{
- GstElementClass parent_class;
+ GstElementClass parent_class;
};
-static void gst_iir_base_init (gpointer g_class);
-static void gst_iir_class_init (GstIIRClass * klass);
-static void gst_iir_init (GstIIR * filter);
+static void gst_iir_base_init (gpointer g_class);
+static void gst_iir_class_init (GstIIRClass * klass);
+static void gst_iir_init (GstIIR * filter);
-static void gst_iir_set_property (GObject * object, guint prop_id,
- const GValue * value,
- GParamSpec * pspec);
-static void gst_iir_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec);
+static void gst_iir_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_iir_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static void gst_iir_chain (GstPad * pad, GstData *_data);
+static void gst_iir_chain (GstPad * pad, GstData * _data);
static GstPadLinkReturn
- gst_iir_sink_connect (GstPad * pad, const GstCaps * caps);
+gst_iir_sink_connect (GstPad * pad, const GstCaps * caps);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_iir_signals[LAST_SIGNAL] = { 0 }; */
-GType gst_iir_get_type (void)
+GType
+gst_iir_get_type (void)
{
static GType iir_type = 0;
if (!iir_type) {
static const GTypeInfo iir_info = {
- sizeof (GstIIRClass),
+ sizeof (GstIIRClass),
gst_iir_base_init,
NULL,
(GClassInitFunc) gst_iir_class_init, NULL, NULL,
(GInstanceInitFunc) gst_iir_init,
};
- iir_type = g_type_register_static (GST_TYPE_ELEMENT, "GstIIR",
- &iir_info, 0);
+ iir_type = g_type_register_static (GST_TYPE_ELEMENT, "GstIIR",
+ &iir_info, 0);
}
return iir_type;
}
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_filter_src_template));
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&gst_filter_sink_template));
+ gst_static_pad_template_get (&gst_filter_sink_template));
- gst_element_class_set_details (element_class, &gst_iir_details);
+ gst_element_class_set_details (element_class, &gst_iir_details);
}
static void
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_A,
- g_param_spec_double ("A", "A", "A filter coefficient",
- -G_MAXDOUBLE, G_MAXDOUBLE,
- 0, G_PARAM_READWRITE));
+ g_param_spec_double ("A", "A", "A filter coefficient",
+ -G_MAXDOUBLE, G_MAXDOUBLE, 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_B,
- g_param_spec_double ("B", "B", "B filter coefficient",
- -G_MAXDOUBLE, G_MAXDOUBLE,
- 0, G_PARAM_READWRITE));
+ g_param_spec_double ("B", "B", "B filter coefficient",
+ -G_MAXDOUBLE, G_MAXDOUBLE, 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_GAIN,
- g_param_spec_double ("gain", "Gain", "Filter gain",
- -G_MAXDOUBLE, G_MAXDOUBLE,
- 0, G_PARAM_READWRITE));
+ g_param_spec_double ("gain", "Gain", "Filter gain",
+ -G_MAXDOUBLE, G_MAXDOUBLE, 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_STAGES,
- g_param_spec_int ("stages", "Stages", "Number of filter stages",
- 1, G_MAXINT,
- 1, G_PARAM_READWRITE));
+ g_param_spec_int ("stages", "Stages", "Number of filter stages",
+ 1, G_MAXINT, 1, G_PARAM_READWRITE));
gobject_class->set_property = gst_iir_set_property;
gobject_class->get_property = gst_iir_get_property;
static void
gst_iir_init (GstIIR * filter)
{
- filter->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&gst_filter_sink_template), "sink");
+ filter->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_filter_sink_template), "sink");
gst_pad_set_chain_function (filter->sinkpad, gst_iir_chain);
gst_pad_set_link_function (filter->sinkpad, gst_iir_sink_connect);
gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
- filter->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&gst_filter_src_template), "src");
+ filter->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_filter_src_template), "src");
gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
filter->A = 0.0;
filter->B = 0.0;
- filter->gain = 1.0; /* unity gain as default */
+ filter->gain = 1.0; /* unity gain as default */
filter->stages = 1;
filter->state = NULL;
}
{
GstIIR *filter;
GstPadLinkReturn set_retval;
-
+
filter = GST_IIR (gst_pad_get_parent (pad));
-
- set_retval = gst_pad_try_set_caps(filter->srcpad, caps);
+
+ set_retval = gst_pad_try_set_caps (filter->srcpad, caps);
if (set_retval > 0) {
/* connection works, so init the filter */
/* FIXME: remember to free it */
filter->state = (IIR_state *) g_malloc (sizeof (IIR_state));
- IIR_init (filter->state, filter->stages,
- filter->gain, &(filter->A), &(filter->B));
+ IIR_init (filter->state, filter->stages,
+ filter->gain, &(filter->A), &(filter->B));
}
return set_retval;
}
static void
-gst_iir_chain (GstPad * pad, GstData *_data)
+gst_iir_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstIIR *filter;
}
static void
-gst_iir_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec)
+gst_iir_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstIIR *filter;
switch (prop_id) {
case ARG_A:
- filter->A = g_value_get_double (value);
- break;
+ filter->A = g_value_get_double (value);
+ break;
case ARG_B:
- filter->B = g_value_get_double (value);
- break;
+ filter->B = g_value_get_double (value);
+ break;
case ARG_GAIN:
- filter->gain = g_value_get_double (value);
- break;
+ filter->gain = g_value_get_double (value);
+ break;
case ARG_STAGES:
- filter->stages = g_value_get_int (value);
- break;
+ filter->stages = g_value_get_int (value);
+ break;
default:
break;
}
}
static void
-gst_iir_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec)
+gst_iir_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstIIR *filter;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_IIR (object));
-
+
filter = GST_IIR (object);
switch (prop_id) {
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
-}
-
+}
#include <math.h> /* M_PI */
#include <string.h> /* memmove */
-static GstElementDetails gst_lpwsinc_details = GST_ELEMENT_DETAILS (
- "LPWSinc",
- "Filter/Effect/Audio",
- "Low-pass Windowed sinc filter",
- "Thomas <thomas@apestaart.org>, "
- "Steven W. Smith"
-);
-
-enum {
+static GstElementDetails gst_lpwsinc_details = GST_ELEMENT_DETAILS ("LPWSinc",
+ "Filter/Effect/Audio",
+ "Low-pass Windowed sinc filter",
+ "Thomas <thomas@apestaart.org>, " "Steven W. Smith");
+
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_LENGTH,
ARG_FREQUENCY,
GstPad *sinkpad, *srcpad;
double frequency;
- int wing_size; /* length of a "wing" of the filter;
- actual length is 2 * wing_size + 1 */
+ int wing_size; /* length of a "wing" of the filter;
+ actual length is 2 * wing_size + 1 */
- gfloat *residue; /* buffer for left-over samples from previous buffer */
+ gfloat *residue; /* buffer for left-over samples from previous buffer */
double *kernel;
};
struct _GstLPWSincClass
{
- GstElementClass parent_class;
+ GstElementClass parent_class;
};
-static void gst_lpwsinc_base_init (gpointer g_class);
-static void gst_lpwsinc_class_init (GstLPWSincClass * klass);
-static void gst_lpwsinc_init (GstLPWSinc * filter);
+static void gst_lpwsinc_base_init (gpointer g_class);
+static void gst_lpwsinc_class_init (GstLPWSincClass * klass);
+static void gst_lpwsinc_init (GstLPWSinc * filter);
-static void gst_lpwsinc_set_property (GObject * object, guint prop_id,
- const GValue * value,
- GParamSpec * pspec);
-static void gst_lpwsinc_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec);
+static void gst_lpwsinc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_lpwsinc_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static void gst_lpwsinc_chain (GstPad * pad, GstData *_data);
+static void gst_lpwsinc_chain (GstPad * pad, GstData * _data);
static GstPadLinkReturn
- gst_lpwsinc_sink_connect (GstPad * pad, const GstCaps * caps);
+gst_lpwsinc_sink_connect (GstPad * pad, const GstCaps * caps);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_lpwsinc_signals[LAST_SIGNAL] = { 0 }; */
-GType gst_lpwsinc_get_type (void)
+GType
+gst_lpwsinc_get_type (void)
{
static GType lpwsinc_type = 0;
if (!lpwsinc_type) {
static const GTypeInfo lpwsinc_info = {
- sizeof (GstLPWSincClass),
+ sizeof (GstLPWSincClass),
gst_lpwsinc_base_init,
NULL,
(GClassInitFunc) gst_lpwsinc_class_init, NULL, NULL,
(GInstanceInitFunc) gst_lpwsinc_init,
};
- lpwsinc_type = g_type_register_static (GST_TYPE_ELEMENT, "GstLPWSinc",
- &lpwsinc_info, 0);
+ lpwsinc_type = g_type_register_static (GST_TYPE_ELEMENT, "GstLPWSinc",
+ &lpwsinc_info, 0);
}
return lpwsinc_type;
}
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_filter_src_template));
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&gst_filter_sink_template));
+ gst_static_pad_template_get (&gst_filter_sink_template));
- gst_element_class_set_details (element_class, &gst_lpwsinc_details);
+ gst_element_class_set_details (element_class, &gst_lpwsinc_details);
}
static void
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FREQUENCY,
- g_param_spec_double ("frequency", "Frequency",
- "Cut-off Frequency relative to sample rate)",
- 0.0, 0.5,
- 0, G_PARAM_READWRITE));
+ g_param_spec_double ("frequency", "Frequency",
+ "Cut-off Frequency relative to sample rate)",
+ 0.0, 0.5, 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LENGTH,
- g_param_spec_int ("length", "Length",
- "N such that the filter length = 2N + 1",
- 1, G_MAXINT,
- 1, G_PARAM_READWRITE));
+ g_param_spec_int ("length", "Length",
+ "N such that the filter length = 2N + 1",
+ 1, G_MAXINT, 1, G_PARAM_READWRITE));
gobject_class->set_property = gst_lpwsinc_set_property;
gobject_class->get_property = gst_lpwsinc_get_property;
static void
gst_lpwsinc_init (GstLPWSinc * filter)
{
- filter->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&gst_filter_sink_template), "sink");
+ filter->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_filter_sink_template), "sink");
gst_pad_set_chain_function (filter->sinkpad, gst_lpwsinc_chain);
gst_pad_set_link_function (filter->sinkpad, gst_lpwsinc_sink_connect);
gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
- filter->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&gst_filter_src_template), "src");
+ filter->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_filter_src_template), "src");
gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
filter->wing_size = 50;
g_assert (GST_IS_PAD (pad));
g_assert (caps != NULL);
- set_retval = gst_pad_try_set_caps(filter->srcpad, caps);
-
- if (set_retval > 0)
- {
+ set_retval = gst_pad_try_set_caps (filter->srcpad, caps);
+
+ if (set_retval > 0) {
/* connection works, so init the filter */
/* FIXME: remember to free it */
/* fill the kernel */
g_print ("DEBUG: initing filter kernel\n");
len = filter->wing_size;
- GST_DEBUG (
- "lpwsinc: initializing filter kernel of length %d", len * 2 + 1);
+ GST_DEBUG ("lpwsinc: initializing filter kernel of length %d", len * 2 + 1);
filter->kernel = (double *) g_malloc (sizeof (double) * (2 * len + 1));
- for (i = 0; i <= len * 2; ++i)
- {
+ for (i = 0; i <= len * 2; ++i) {
if (i == len)
filter->kernel[i] = 2 * M_PI * filter->frequency;
else
- filter->kernel[i] = sin (2 * M_PI * filter->frequency * (i - len))
- / (i - len);
+ filter->kernel[i] = sin (2 * M_PI * filter->frequency * (i - len))
+ / (i - len);
/* windowing */
filter->kernel[i] *= (0.54 - 0.46 * cos (M_PI * i / len));
}
/* normalize for unity gain at DC
* FIXME: sure this is not supposed to be quadratic ? */
- for (i = 0; i <= len * 2; ++i) sum += filter->kernel[i];
- for (i = 0; i <= len * 2; ++i) filter->kernel[i] /= sum;
+ for (i = 0; i <= len * 2; ++i)
+ sum += filter->kernel[i];
+ for (i = 0; i <= len * 2; ++i)
+ filter->kernel[i] /= sum;
/* set up the residue memory space */
filter->residue = (gfloat *) g_malloc (sizeof (gfloat) * (len * 2 + 1));
- for (i = 0; i <= len * 2; ++i) filter->residue[i] = 0.0;
+ for (i = 0; i <= len * 2; ++i)
+ filter->residue[i] = 0.0;
}
return set_retval;
}
static void
-gst_lpwsinc_chain (GstPad * pad, GstData *_data)
+gst_lpwsinc_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstLPWSinc *filter;
memcpy (&input[residue_samples], src, sizeof (gfloat) * input_samples);
/* copy the tail of the current input buffer to the residue */
memcpy (filter->residue, &src[input_samples - residue_samples],
- sizeof (gfloat) * residue_samples);
+ sizeof (gfloat) * residue_samples);
/* convolution */
/* since we copied the previous set of samples we needed before the actual
* input data, we need to add the filter length to our indices for input */
- for (i = 0; i < input_samples; ++i)
- {
+ for (i = 0; i < input_samples; ++i) {
src[i] = 0.0;
for (j = 0; j < residue_samples; ++j)
src[i] += input[i - j + residue_samples] * filter->kernel[j];
}
-
+
g_free (input);
gst_pad_push (filter->srcpad, GST_DATA (buf));
}
static void
-gst_lpwsinc_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec)
+gst_lpwsinc_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstLPWSinc *filter;
switch (prop_id) {
case ARG_LENGTH:
- filter->wing_size = g_value_get_int (value);
- break;
+ filter->wing_size = g_value_get_int (value);
+ break;
case ARG_FREQUENCY:
- filter->frequency = g_value_get_double (value);
- break;
+ filter->frequency = g_value_get_double (value);
+ break;
default:
break;
}
}
static void
-gst_lpwsinc_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec)
+gst_lpwsinc_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstLPWSinc *filter;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_LPWSINC (object));
-
+
filter = GST_LPWSINC (object);
switch (prop_id) {
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
-}
-
+}
#include <math.h>
#include "iir.h"
-void IIR_init(IIR_state *s,int stages,double gain, double *A, double *B){
- memset(s,0,sizeof(IIR_state));
- s->stages=stages;
- s->gain=gain;
- s->coeff_A=malloc(stages*sizeof(double));
- s->coeff_B=malloc((stages+1)*sizeof(double));
- s->z_A=calloc(stages*2,sizeof(double));
- s->z_B=calloc(stages*2,sizeof(double));
-
- memcpy(s->coeff_A,A,stages*sizeof(double));
- memcpy(s->coeff_B,B,(stages+1)*sizeof(double));
+void
+IIR_init (IIR_state * s, int stages, double gain, double *A, double *B)
+{
+ memset (s, 0, sizeof (IIR_state));
+ s->stages = stages;
+ s->gain = gain;
+ s->coeff_A = malloc (stages * sizeof (double));
+ s->coeff_B = malloc ((stages + 1) * sizeof (double));
+ s->z_A = calloc (stages * 2, sizeof (double));
+ s->z_B = calloc (stages * 2, sizeof (double));
+
+ memcpy (s->coeff_A, A, stages * sizeof (double));
+ memcpy (s->coeff_B, B, (stages + 1) * sizeof (double));
}
-void IIR_clear(IIR_state *s){
- if(s){
- free(s->coeff_A);
- free(s->coeff_B);
- free(s->z_A);
- free(s->z_B);
- memset(s,0,sizeof(IIR_state));
+void
+IIR_clear (IIR_state * s)
+{
+ if (s) {
+ free (s->coeff_A);
+ free (s->coeff_B);
+ free (s->z_A);
+ free (s->z_B);
+ memset (s, 0, sizeof (IIR_state));
}
}
-double IIR_filter(IIR_state *s,double in){
- int stages=s->stages,i;
+double
+IIR_filter (IIR_state * s, double in)
+{
+ int stages = s->stages, i;
double newA;
- double newB=0;
- double *zA=s->z_A+s->ring;
+ double newB = 0;
+ double *zA = s->z_A + s->ring;
- newA=in/=s->gain;
- for(i=0;i<stages;i++){
- newA+= s->coeff_A[i] * zA[i];
- newB+= s->coeff_B[i] * zA[i];
+ newA = in /= s->gain;
+ for (i = 0; i < stages; i++) {
+ newA += s->coeff_A[i] * zA[i];
+ newB += s->coeff_B[i] * zA[i];
}
- newB+=newA*s->coeff_B[stages];
+ newB += newA * s->coeff_B[stages];
- zA[0]=zA[stages]=newA;
- if(++s->ring>=stages)s->ring=0;
+ zA[0] = zA[stages] = newA;
+ if (++s->ring >= stages)
+ s->ring = 0;
- return(newB);
+ return (newB);
}
/* this assumes the symmetrical structure of the feed-forward stage of
a Chebyshev bandpass to save multiplies */
-double IIR_filter_ChebBand(IIR_state *s,double in){
- int stages=s->stages,i;
+double
+IIR_filter_ChebBand (IIR_state * s, double in)
+{
+ int stages = s->stages, i;
double newA;
- double newB=0;
- double *zA=s->z_A+s->ring;
+ double newB = 0;
+ double *zA = s->z_A + s->ring;
- newA=in/=s->gain;
+ newA = in /= s->gain;
- newA+= s->coeff_A[0] * zA[0];
- for(i=1;i<(stages>>1);i++){
- newA+= s->coeff_A[i] * zA[i];
- newB+= s->coeff_B[i] * (zA[i]-zA[stages-i]);
+ newA += s->coeff_A[0] * zA[0];
+ for (i = 1; i < (stages >> 1); i++) {
+ newA += s->coeff_A[i] * zA[i];
+ newB += s->coeff_B[i] * (zA[i] - zA[stages - i]);
}
- newB+= s->coeff_B[i] * zA[i];
- for(;i<stages;i++)
- newA+= s->coeff_A[i] * zA[i];
+ newB += s->coeff_B[i] * zA[i];
+ for (; i < stages; i++)
+ newA += s->coeff_A[i] * zA[i];
- newB+= newA-zA[0];
+ newB += newA - zA[0];
- zA[0]=zA[stages]=newA;
- if(++s->ring>=stages)s->ring=0;
+ zA[0] = zA[stages] = newA;
+ if (++s->ring >= stages)
+ s->ring = 0;
- return(newB);
+ return (newB);
}
#ifdef _V_SELFTEST
/* z^-stage, z^-stage+1... */
-static double cheb_bandpass_B[]={-1.,0.,5.,0.,-10.,0.,10.,0.,-5.,0.,1};
-static double cheb_bandpass_A[]={-0.6665900311,
- 1.0070146601,
- -3.1262875409,
- 3.5017171569,
- -6.2779211945,
- 5.2966481740,
- -6.7570216587,
- 4.0760335768,
- -3.9134284363,
- 1.3997338886};
-
-static double data[128]={
+static double cheb_bandpass_B[] =
+ { -1., 0., 5., 0., -10., 0., 10., 0., -5., 0., 1 };
+static double cheb_bandpass_A[] = { -0.6665900311,
+ 1.0070146601,
+ -3.1262875409,
+ 3.5017171569,
+ -6.2779211945,
+ 5.2966481740,
+ -6.7570216587,
+ 4.0760335768,
+ -3.9134284363,
+ 1.3997338886
+};
+
+static double data[128] = {
0.0426331,
0.0384521,
0.0345764,
-0.0537415,
-0.0610046,
-0.0609741,
- -0.0547791};
+ -0.0547791
+};
/* comparison test code from http://www-users.cs.york.ac.uk/~fisher/mkfilter/
(the above page kicks ass, BTW)*/
#define NPOLES 10
#define GAIN 4.599477515e+02
-static float xv[NZEROS+1], yv[NPOLES+1];
-
-static double filterloop(double next){
- xv[0] = xv[1]; xv[1] = xv[2]; xv[2] = xv[3]; xv[3] = xv[4]; xv[4] = xv[5];
- xv[5] = xv[6]; xv[6] = xv[7]; xv[7] = xv[8]; xv[8] = xv[9]; xv[9] = xv[10];
+static float xv[NZEROS + 1], yv[NPOLES + 1];
+
+static double
+filterloop (double next)
+{
+ xv[0] = xv[1];
+ xv[1] = xv[2];
+ xv[2] = xv[3];
+ xv[3] = xv[4];
+ xv[4] = xv[5];
+ xv[5] = xv[6];
+ xv[6] = xv[7];
+ xv[7] = xv[8];
+ xv[8] = xv[9];
+ xv[9] = xv[10];
xv[10] = next / GAIN;
- yv[0] = yv[1]; yv[1] = yv[2]; yv[2] = yv[3]; yv[3] = yv[4]; yv[4] = yv[5];
- yv[5] = yv[6]; yv[6] = yv[7]; yv[7] = yv[8]; yv[8] = yv[9]; yv[9] = yv[10];
- yv[10] = (xv[10] - xv[0]) + 5 * (xv[2] - xv[8]) + 10 * (xv[6] - xv[4])
- + ( -0.6665900311 * yv[0]) + ( 1.0070146601 * yv[1])
- + ( -3.1262875409 * yv[2]) + ( 3.5017171569 * yv[3])
- + ( -6.2779211945 * yv[4]) + ( 5.2966481740 * yv[5])
- + ( -6.7570216587 * yv[6]) + ( 4.0760335768 * yv[7])
- + ( -3.9134284363 * yv[8]) + ( 1.3997338886 * yv[9]);
- return(yv[10]);
+ yv[0] = yv[1];
+ yv[1] = yv[2];
+ yv[2] = yv[3];
+ yv[3] = yv[4];
+ yv[4] = yv[5];
+ yv[5] = yv[6];
+ yv[6] = yv[7];
+ yv[7] = yv[8];
+ yv[8] = yv[9];
+ yv[9] = yv[10];
+ yv[10] = (xv[10] - xv[0]) + 5 * (xv[2] - xv[8]) + 10 * (xv[6] - xv[4])
+ + (-0.6665900311 * yv[0]) + (1.0070146601 * yv[1])
+ + (-3.1262875409 * yv[2]) + (3.5017171569 * yv[3])
+ + (-6.2779211945 * yv[4]) + (5.2966481740 * yv[5])
+ + (-6.7570216587 * yv[6]) + (4.0760335768 * yv[7])
+ + (-3.9134284363 * yv[8]) + (1.3997338886 * yv[9]);
+ return (yv[10]);
}
#include <stdio.h>
-int main(){
+int
+main ()
+{
/* run the pregenerated Chebyshev filter, then our own distillation
through the generic and specialized code */
- double *work=malloc(128*sizeof(double));
+ double *work = malloc (128 * sizeof (double));
IIR_state iir;
int i;
- for(i=0;i<128;i++)work[i]=filterloop(data[i]);
+ for (i = 0; i < 128; i++)
+ work[i] = filterloop (data[i]);
{
- FILE *out=fopen("IIR_ref.m","w");
- for(i=0;i<128;i++)fprintf(out,"%g\n",work[i]);
- fclose(out);
+ FILE *out = fopen ("IIR_ref.m", "w");
+
+ for (i = 0; i < 128; i++)
+ fprintf (out, "%g\n", work[i]);
+ fclose (out);
}
- IIR_init(&iir,NPOLES,GAIN,cheb_bandpass_A,cheb_bandpass_B);
- for(i=0;i<128;i++)work[i]=IIR_filter(&iir,data[i]);
+ IIR_init (&iir, NPOLES, GAIN, cheb_bandpass_A, cheb_bandpass_B);
+ for (i = 0; i < 128; i++)
+ work[i] = IIR_filter (&iir, data[i]);
{
- FILE *out=fopen("IIR_gen.m","w");
- for(i=0;i<128;i++)fprintf(out,"%g\n",work[i]);
- fclose(out);
+ FILE *out = fopen ("IIR_gen.m", "w");
+
+ for (i = 0; i < 128; i++)
+ fprintf (out, "%g\n", work[i]);
+ fclose (out);
}
- IIR_clear(&iir);
+ IIR_clear (&iir);
- IIR_init(&iir,NPOLES,GAIN,cheb_bandpass_A,cheb_bandpass_B);
- for(i=0;i<128;i++)work[i]=IIR_filter_ChebBand(&iir,data[i]);
+ IIR_init (&iir, NPOLES, GAIN, cheb_bandpass_A, cheb_bandpass_B);
+ for (i = 0; i < 128; i++)
+ work[i] = IIR_filter_ChebBand (&iir, data[i]);
{
- FILE *out=fopen("IIR_cheb.m","w");
- for(i=0;i<128;i++)fprintf(out,"%g\n",work[i]);
- fclose(out);
+ FILE *out = fopen ("IIR_cheb.m", "w");
+
+ for (i = 0; i < 128; i++)
+ fprintf (out, "%g\n", work[i]);
+ fclose (out);
}
- IIR_clear(&iir);
+ IIR_clear (&iir);
- return(0);
+ return (0);
}
#endif
#ifndef _V_IIR_H_
#define _V_IIR_H_
-typedef struct {
+typedef struct
+{
int stages;
double *coeff_A;
double *coeff_B;
double gain;
} IIR_state;
-void IIR_init(IIR_state *s,int stages,double gain, double *A, double *B);
-void IIR_clear(IIR_state *s);
-double IIR_filter(IIR_state *s,double in);
-double IIR_filter_ChebBand(IIR_state *s,double in);
+void IIR_init (IIR_state * s, int stages, double gain, double *A, double *B);
+void IIR_clear (IIR_state * s);
+double IIR_filter (IIR_state * s, double in);
+double IIR_filter_ChebBand (IIR_state * s, double in);
#endif
#include "flx_color.h"
FlxColorSpaceConverter *
-flx_colorspace_converter_new(gint width, gint height)
+flx_colorspace_converter_new (gint width, gint height)
{
- FlxColorSpaceConverter *new = g_malloc(sizeof(FlxColorSpaceConverter));
+ FlxColorSpaceConverter *new = g_malloc (sizeof (FlxColorSpaceConverter));
new->width = width;
new->height = height;
- memset(new->palvec, 0, sizeof(new->palvec));
+ memset (new->palvec, 0, sizeof (new->palvec));
return new;
}
void
-flx_colorspace_converter_destroy(FlxColorSpaceConverter *flxpal)
+flx_colorspace_converter_destroy (FlxColorSpaceConverter * flxpal)
{
- g_return_if_fail(flxpal != NULL);
+ g_return_if_fail (flxpal != NULL);
- g_free(flxpal);
+ g_free (flxpal);
}
void
-flx_colorspace_convert(FlxColorSpaceConverter *flxpal, guchar *src, guchar *dest)
+flx_colorspace_convert (FlxColorSpaceConverter * flxpal, guchar * src,
+ guchar * dest)
{
guint size, col;
- g_return_if_fail(flxpal != NULL);
- g_return_if_fail(src != dest);
+ g_return_if_fail (flxpal != NULL);
+ g_return_if_fail (src != dest);
size = flxpal->width * flxpal->height;
- while(size--) {
- col = (*src++ * 3);
- *dest++ = flxpal->palvec[col+2];
- *dest++ = flxpal->palvec[col+1];
+ while (size--) {
+ col = (*src++ * 3);
+ *dest++ = flxpal->palvec[col + 2];
+ *dest++ = flxpal->palvec[col + 1];
*dest++ = flxpal->palvec[col];
*dest++ = 0;
}
}
-void
-flx_set_palette_vector(FlxColorSpaceConverter *flxpal, guint start, guint num, guchar *newpal, gint scale)
+void
+flx_set_palette_vector (FlxColorSpaceConverter * flxpal, guint start, guint num,
+ guchar * newpal, gint scale)
{
- guint grab;
-
- g_return_if_fail(flxpal != NULL);
- g_return_if_fail(start < 0x100);
+ guint grab;
+
+ g_return_if_fail (flxpal != NULL);
+ g_return_if_fail (start < 0x100);
grab = ((start + num) > 0x100 ? 0x100 - start : num);
flxpal->palvec[start++] = newpal[i++] << scale;
grab--;
}
- }
- else {
- memcpy(&flxpal->palvec[start * 3], newpal, grab * 3);
+ } else {
+ memcpy (&flxpal->palvec[start * 3], newpal, grab * 3);
}
}
void
-flx_set_color(FlxColorSpaceConverter *flxpal, guint colr, guint red, guint green, guint blue, gint scale)
+flx_set_color (FlxColorSpaceConverter * flxpal, guint colr, guint red,
+ guint green, guint blue, gint scale)
{
-
- g_return_if_fail(flxpal != NULL);
- g_return_if_fail(colr < 0x100);
- flxpal->palvec[(colr * 3)] = red << scale;
+ g_return_if_fail (flxpal != NULL);
+ g_return_if_fail (colr < 0x100);
+
+ flxpal->palvec[(colr * 3)] = red << scale;
flxpal->palvec[(colr * 3) + 1] = green << scale;
flxpal->palvec[(colr * 3) + 2] = blue << scale;
}
-
-
* Boston, MA 02111-1307, USA.
*/
-typedef enum {
+typedef enum
+{
FLX_COLORSPACE_RGB8,
FLX_COLORSPACE_RGB32,
} FlxColorSpaceType;
typedef struct _FlxColorSpaceConverter FlxColorSpaceConverter;
-struct _FlxColorSpaceConverter {
- guint width;
- guint height;
- guchar palvec[768];
+struct _FlxColorSpaceConverter
+{
+ guint width;
+ guint height;
+ guchar palvec[768];
};
-void flx_colorspace_converter_destroy(FlxColorSpaceConverter *flxpal);
-void flx_colorspace_convert(FlxColorSpaceConverter *flxpal, guchar *src, guchar *dest);
-FlxColorSpaceConverter * flx_colorspace_converter_new(gint width, gint height);
-
-void flx_set_palette_vector(FlxColorSpaceConverter *flxpal, guint start, guint num,
- guchar *newpal, gint scale);
-void flx_set_color(FlxColorSpaceConverter *flxpal, guint colr, guint red, guint green,
- guint blue, gint scale);
+void flx_colorspace_converter_destroy (FlxColorSpaceConverter * flxpal);
+void flx_colorspace_convert (FlxColorSpaceConverter * flxpal, guchar * src,
+ guchar * dest);
+FlxColorSpaceConverter *flx_colorspace_converter_new (gint width, gint height);
+void flx_set_palette_vector (FlxColorSpaceConverter * flxpal, guint start,
+ guint num, guchar * newpal, gint scale);
+void flx_set_color (FlxColorSpaceConverter * flxpal, guint colr, guint red,
+ guint green, guint blue, gint scale);
#include <gst/gst.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-enum Flx_TypeChunk
-{
- /* frame chunks */
- FLX_PREFIX_TYPE = 0xf100,
- FLX_SCRIPT_CHUNK = 0xf1e0,
- FLX_FRAME_TYPE = 0xf1fa,
- FLX_SEGMENT_TABLE = 0xf1fb,
- FLX_HUFFMAN_TABLE = 0xf1fc,
-
- /* sub chunks */
- FLX_CEL_DATA = 3,
- FLX_COLOR256 = 4,
- FLX_SS2 = 7,
- FLX_COLOR64 = 11,
- FLX_LC = 12,
- FLX_BLACK = 13,
- FLX_BRUN = 15,
- FLX_COPY = 16,
- FLX_MINI = 18,
- FLX_DTA_RUN = 25,
- FLX_DTA_COPY = 26,
- FLX_DTA_LC = 27,
- FLX_LABEL = 31,
- FLX_BMP_MASK = 32,
- FLX_MLEV_MASK = 33,
- FLX_SEGMENT = 34,
- FLX_KEY_IMAGE = 35,
- FLX_KEY_PAL = 36,
- FLX_REGION = 37,
- FLX_WAVE = 38,
- FLX_USERSTRING = 39,
- FLX_RGN_MASK = 40,
-
-};
-
-enum Flx_MagicHdr
+extern "C"
{
- FLX_MAGICHDR_FLI = 0xaf11,
- FLX_MAGICHDR_FLC = 0xaf12,
- FLX_MAGICHDR_FLX = 0xaf44,
- FLX_MAGICHDR_HUFFBWT = 0xaf30,
-};
-
-
-
-typedef struct _FlxHeader
-{
- guint32 size;
- guint16 type;
- guint16 frames;
- guint16 width,height,depth,flags;
- guint32 speed;
- guint16 reserved1;
- /* FLC */
- guint32 created,creator,updated,updater;
- guint16 aspect_dx, aspect_dy;
- /* EGI */
- guint16 ext_flags,keyframes,totalframes;
- guint32 req_memory;
- guint16 max_regions,transp_num;
- guchar reserved2[24];
- /* FLC */
- guint32 oframe1,oframe2;
- guchar reserved3[40];
-} FlxHeader;
+#endif /* __cplusplus */
+
+ enum Flx_TypeChunk
+ {
+ /* frame chunks */
+ FLX_PREFIX_TYPE = 0xf100,
+ FLX_SCRIPT_CHUNK = 0xf1e0,
+ FLX_FRAME_TYPE = 0xf1fa,
+ FLX_SEGMENT_TABLE = 0xf1fb,
+ FLX_HUFFMAN_TABLE = 0xf1fc,
+
+ /* sub chunks */
+ FLX_CEL_DATA = 3,
+ FLX_COLOR256 = 4,
+ FLX_SS2 = 7,
+ FLX_COLOR64 = 11,
+ FLX_LC = 12,
+ FLX_BLACK = 13,
+ FLX_BRUN = 15,
+ FLX_COPY = 16,
+ FLX_MINI = 18,
+ FLX_DTA_RUN = 25,
+ FLX_DTA_COPY = 26,
+ FLX_DTA_LC = 27,
+ FLX_LABEL = 31,
+ FLX_BMP_MASK = 32,
+ FLX_MLEV_MASK = 33,
+ FLX_SEGMENT = 34,
+ FLX_KEY_IMAGE = 35,
+ FLX_KEY_PAL = 36,
+ FLX_REGION = 37,
+ FLX_WAVE = 38,
+ FLX_USERSTRING = 39,
+ FLX_RGN_MASK = 40,
+
+ };
+
+ enum Flx_MagicHdr
+ {
+ FLX_MAGICHDR_FLI = 0xaf11,
+ FLX_MAGICHDR_FLC = 0xaf12,
+ FLX_MAGICHDR_FLX = 0xaf44,
+ FLX_MAGICHDR_HUFFBWT = 0xaf30,
+ };
+
+
+
+ typedef struct _FlxHeader
+ {
+ guint32 size;
+ guint16 type;
+ guint16 frames;
+ guint16 width, height, depth, flags;
+ guint32 speed;
+ guint16 reserved1;
+ /* FLC */
+ guint32 created, creator, updated, updater;
+ guint16 aspect_dx, aspect_dy;
+ /* EGI */
+ guint16 ext_flags, keyframes, totalframes;
+ guint32 req_memory;
+ guint16 max_regions, transp_num;
+ guchar reserved2[24];
+ /* FLC */
+ guint32 oframe1, oframe2;
+ guchar reserved3[40];
+ } FlxHeader;
#define FlxHeaderSize 128
-typedef struct _FlxFrameChunk
-{
- guint32 size;
- guint16 id;
-} FlxFrameChunk;
+ typedef struct _FlxFrameChunk
+ {
+ guint32 size;
+ guint16 id;
+ } FlxFrameChunk;
#define FlxFrameChunkSize 6
-typedef struct _FlxPrefixChunk
-{
- guint16 chunks;
- guchar reserved[8];
-} FlxPrefixChunk;
-
-typedef struct _FlxSegmentTable
-{
- guint16 segments;
-} FlxSegmentTable;
-
-typedef struct _FlxHuffmanTable
-{
- guint16 codelength;
- guint16 numcodes;
- guchar reserved[6];
-} FlxHuffmanTable;
-
-typedef struct _FlxFrameType
-{
- guint16 chunks;
- guint16 delay;
- guchar reserved[6];
-} FlxFrameType;
+ typedef struct _FlxPrefixChunk
+ {
+ guint16 chunks;
+ guchar reserved[8];
+ } FlxPrefixChunk;
+
+ typedef struct _FlxSegmentTable
+ {
+ guint16 segments;
+ } FlxSegmentTable;
+
+ typedef struct _FlxHuffmanTable
+ {
+ guint16 codelength;
+ guint16 numcodes;
+ guchar reserved[6];
+ } FlxHuffmanTable;
+
+ typedef struct _FlxFrameType
+ {
+ guint16 chunks;
+ guint16 delay;
+ guchar reserved[6];
+ } FlxFrameType;
#define FlxFrameTypeSize 10
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_FLX_FMT_H__ */
+#endif /* __GST_FLX_FMT_H__ */
};
/* Flx signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0
};
/* input */
-static GstStaticPadTemplate sink_factory =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ( "video/x-fli" )
-);
+static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/x-fli")
+ );
/* output */
-static GstStaticPadTemplate src_video_factory =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ( GST_VIDEO_CAPS_xRGB_HOST_ENDIAN )
-);
+static GstStaticPadTemplate src_video_factory = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_xRGB_HOST_ENDIAN)
+ );
-static void gst_flxdec_class_init (GstFlxDecClass *klass);
-static void gst_flxdec_base_init (GstFlxDecClass *klass);
-static void gst_flxdec_init (GstFlxDec *flxdec);
+static void gst_flxdec_class_init (GstFlxDecClass * klass);
+static void gst_flxdec_base_init (GstFlxDecClass * klass);
+static void gst_flxdec_init (GstFlxDec * flxdec);
-static void gst_flxdec_loop (GstElement *element);
+static void gst_flxdec_loop (GstElement * element);
-static GstElementStateReturn
- gst_flxdec_change_state (GstElement *element);
+static GstElementStateReturn gst_flxdec_change_state (GstElement * element);
-static void gst_flxdec_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void gst_flxdec_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+static void gst_flxdec_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_flxdec_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static void flx_decode_color (GstFlxDec *, guchar *, guchar *, gint);
-static void flx_decode_brun (GstFlxDec *, guchar *, guchar *);
-static void flx_decode_delta_fli (GstFlxDec *, guchar *, guchar *);
-static void flx_decode_delta_flc (GstFlxDec *, guchar *, guchar *);
+static void flx_decode_color (GstFlxDec *, guchar *, guchar *, gint);
+static void flx_decode_brun (GstFlxDec *, guchar *, guchar *);
+static void flx_decode_delta_fli (GstFlxDec *, guchar *, guchar *);
+static void flx_decode_delta_flc (GstFlxDec *, guchar *, guchar *);
#define rndalign(off) ((off) + ((off) % 2))
static GstElementClass *parent_class = NULL;
GType
-gst_flxdec_get_type(void)
+gst_flxdec_get_type (void)
{
static GType flxdec_type = 0;
if (!flxdec_type) {
static const GTypeInfo flxdec_info = {
- sizeof(GstFlxDecClass),
- (GBaseInitFunc)gst_flxdec_base_init,
+ sizeof (GstFlxDecClass),
+ (GBaseInitFunc) gst_flxdec_base_init,
NULL,
- (GClassInitFunc)gst_flxdec_class_init,
+ (GClassInitFunc) gst_flxdec_class_init,
NULL,
NULL,
- sizeof(GstFlxDec),
+ sizeof (GstFlxDec),
0,
- (GInstanceInitFunc)gst_flxdec_init,
+ (GInstanceInitFunc) gst_flxdec_init,
};
- flxdec_type = g_type_register_static(GST_TYPE_ELEMENT, "GstFlxDec", &flxdec_info, 0);
+ flxdec_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstFlxDec", &flxdec_info, 0);
}
return flxdec_type;
}
static void
-gst_flxdec_base_init (GstFlxDecClass *klass)
+gst_flxdec_base_init (GstFlxDecClass * klass)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
-
+
gst_element_class_set_details (gstelement_class, &flxdec_details);
gst_element_class_add_pad_template (gstelement_class,
- gst_static_pad_template_get (&sink_factory));
+ gst_static_pad_template_get (&sink_factory));
gst_element_class_add_pad_template (gstelement_class,
- gst_static_pad_template_get (&src_video_factory));
+ gst_static_pad_template_get (&src_video_factory));
}
-static void
-gst_flxdec_class_init (GstFlxDecClass *klass)
+static void
+gst_flxdec_class_init (GstFlxDecClass * 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);
- gobject_class->set_property = gst_flxdec_set_property;
+ gobject_class->set_property = gst_flxdec_set_property;
gobject_class->get_property = gst_flxdec_get_property;
gstelement_class->change_state = gst_flxdec_change_state;
}
-
-static void
-gst_flxdec_init(GstFlxDec *flxdec)
+
+static void
+gst_flxdec_init (GstFlxDec * flxdec)
{
- flxdec->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&sink_factory), "sink");
- gst_element_add_pad(GST_ELEMENT(flxdec),flxdec->sinkpad);
- gst_element_set_loop_function(GST_ELEMENT(flxdec),gst_flxdec_loop);
+ flxdec->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get (&sink_factory),
+ "sink");
+ gst_element_add_pad (GST_ELEMENT (flxdec), flxdec->sinkpad);
+ gst_element_set_loop_function (GST_ELEMENT (flxdec), gst_flxdec_loop);
- flxdec->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&src_video_factory), "src");
- gst_element_add_pad(GST_ELEMENT(flxdec),flxdec->srcpad);
+ flxdec->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&src_video_factory), "src");
+ gst_element_add_pad (GST_ELEMENT (flxdec), flxdec->srcpad);
flxdec->bs = NULL;
flxdec->frame = NULL;
}
static void
-flx_decode_chunks (GstFlxDec *flxdec , gulong count, gchar *data, gchar *dest)
+flx_decode_chunks (GstFlxDec * flxdec, gulong count, gchar * data, gchar * dest)
{
- FlxFrameChunk *hdr;
+ FlxFrameChunk *hdr;
- g_return_if_fail(data != NULL);
+ g_return_if_fail (data != NULL);
while (count--) {
- hdr = (FlxFrameChunk *) data;
+ hdr = (FlxFrameChunk *) data;
data += FlxFrameChunkSize;
- switch(hdr->id)
- {
+ switch (hdr->id) {
case FLX_COLOR64:
- flx_decode_color(flxdec, data, dest, 2);
- data += rndalign(hdr->size) - FlxFrameChunkSize;
- break;
+ flx_decode_color (flxdec, data, dest, 2);
+ data += rndalign (hdr->size) - FlxFrameChunkSize;
+ break;
case FLX_COLOR256:
- flx_decode_color(flxdec, data, dest, 0);
- data += rndalign(hdr->size) - FlxFrameChunkSize;
- break;
+ flx_decode_color (flxdec, data, dest, 0);
+ data += rndalign (hdr->size) - FlxFrameChunkSize;
+ break;
case FLX_BRUN:
- flx_decode_brun(flxdec, data, dest);
- data += rndalign(hdr->size) - FlxFrameChunkSize;
- break;
+ flx_decode_brun (flxdec, data, dest);
+ data += rndalign (hdr->size) - FlxFrameChunkSize;
+ break;
case FLX_LC:
- flx_decode_delta_fli(flxdec, data, dest);
- data += rndalign(hdr->size) - FlxFrameChunkSize;
- break;
+ flx_decode_delta_fli (flxdec, data, dest);
+ data += rndalign (hdr->size) - FlxFrameChunkSize;
+ break;
case FLX_SS2:
- flx_decode_delta_flc(flxdec, data, dest);
- data += rndalign(hdr->size) - FlxFrameChunkSize;
- break;
+ flx_decode_delta_flc (flxdec, data, dest);
+ data += rndalign (hdr->size) - FlxFrameChunkSize;
+ break;
case FLX_BLACK:
- memset(dest, 0, flxdec->size);
- break;
+ memset (dest, 0, flxdec->size);
+ break;
case FLX_MINI:
- data += rndalign(hdr->size) - FlxFrameChunkSize;
- break;
+ data += rndalign (hdr->size) - FlxFrameChunkSize;
+ break;
default:
- g_print("GstFlxDec: Unimplented chunk type: 0x%02x size: %d\n",
- hdr->id, hdr->size);
- g_print("GstFlxDec: Skipping...\n");
- data += rndalign(hdr->size) - FlxFrameChunkSize;
- break;
+ g_print ("GstFlxDec: Unimplented chunk type: 0x%02x size: %d\n",
+ hdr->id, hdr->size);
+ g_print ("GstFlxDec: Skipping...\n");
+ data += rndalign (hdr->size) - FlxFrameChunkSize;
+ break;
}
}
}
static void
-flx_decode_color(GstFlxDec *flxdec, guchar *data, guchar *dest, gint scale)
+flx_decode_color (GstFlxDec * flxdec, guchar * data, guchar * dest, gint scale)
{
guint packs, count, indx;
- g_return_if_fail(flxdec != NULL);
+ g_return_if_fail (flxdec != NULL);
packs = (data[0] + (data[1] << 8));
data += 2;
- indx = 0;
+ indx = 0;
- g_print("GstFlxDec: cmap packs: %d\n", packs);
+ g_print ("GstFlxDec: cmap packs: %d\n", packs);
while (packs--) {
/* color map index + skip count */
indx += *data++;
if (count == 0)
count = 256;
- g_print("GstFlxDec: cmap count: %d (indx: %d)\n", count, indx);
- flx_set_palette_vector(flxdec->converter, indx, count, data, scale);
+ g_print ("GstFlxDec: cmap count: %d (indx: %d)\n", count, indx);
+ flx_set_palette_vector (flxdec->converter, indx, count, data, scale);
data += (count * 3);
}
}
-static void
-flx_decode_brun(GstFlxDec *flxdec, guchar *data, guchar *dest)
+static void
+flx_decode_brun (GstFlxDec * flxdec, guchar * data, guchar * dest)
{
- gulong count, lines, row;
- guchar x;
-
- g_return_if_fail(flxdec != NULL);
+ gulong count, lines, row;
+ guchar x;
+
+ g_return_if_fail (flxdec != NULL);
lines = flxdec->hdr.height;
- while(lines--) {
+ while (lines--) {
/* packet count.
* should not be used anymore, since the flc format can
* contain more then 255 RLE packets. we use the frame
data++;
row = flxdec->hdr.width;
- while(row) {
+ while (row) {
count = *data++;
- if (count > 0x7f) {
- /* literal run */
- count = 0x100 - count;
- row -= count;
+ if (count > 0x7f) {
+ /* literal run */
+ count = 0x100 - count;
+ row -= count;
+
+ while (count--)
+ *dest++ = *data++;
- while(count--)
- *dest++ = *data++;
-
} else {
- /* replicate run */
- row -= count;
- x = *data++;
+ /* replicate run */
+ row -= count;
+ x = *data++;
- while(count--)
- *dest++ = x;
+ while (count--)
+ *dest++ = x;
}
}
}
}
-static void
-flx_decode_delta_fli(GstFlxDec *flxdec, guchar *data, guchar *dest)
+static void
+flx_decode_delta_fli (GstFlxDec * flxdec, guchar * data, guchar * dest)
{
- gulong count, packets, lines, start_line, start_l;
- guchar *start_p, x;
-
- g_return_if_fail(flxdec != NULL);
- g_return_if_fail(flxdec->delta != NULL);
+ gulong count, packets, lines, start_line, start_l;
+ guchar *start_p, x;
+
+ g_return_if_fail (flxdec != NULL);
+ g_return_if_fail (flxdec->delta != NULL);
/* use last frame for delta */
- memcpy(dest, GST_BUFFER_DATA(flxdec->delta),
- GST_BUFFER_SIZE(flxdec->delta));
+ memcpy (dest, GST_BUFFER_DATA (flxdec->delta),
+ GST_BUFFER_SIZE (flxdec->delta));
start_line = (data[0] + (data[1] << 8));
- lines = (data[2] + (data[3] << 8));
- data += 4;
+ lines = (data[2] + (data[3] << 8));
+ data += 4;
/* start position of delta */
dest += (flxdec->hdr.width * start_line);
start_p = dest;
start_l = lines;
- while(lines--) {
+ while (lines--) {
/* packet count */
packets = *data++;
- while(packets--) {
+ while (packets--) {
/* skip count */
dest += *data++;
/* RLE count */
count = *data++;
- if (count > 0x7f) {
- /* literal run */
- count = 0x100 - count;
- x = *data++;
+ if (count > 0x7f) {
+ /* literal run */
+ count = 0x100 - count;
+ x = *data++;
- while (count--)
- *dest++ = x;
+ while (count--)
+ *dest++ = x;
} else {
- /* replicate run */
- while (count--)
- *dest++ = *data++;
+ /* replicate run */
+ while (count--)
+ *dest++ = *data++;
}
}
start_p += flxdec->hdr.width;
dest = start_p;
- }
+ }
}
-static void
-flx_decode_delta_flc(GstFlxDec *flxdec, guchar *data, guchar *dest)
+static void
+flx_decode_delta_flc (GstFlxDec * flxdec, guchar * data, guchar * dest)
{
- gulong count, lines, start_l, opcode;
- guchar *start_p;
-
- g_return_if_fail(flxdec != NULL);
- g_return_if_fail(flxdec->delta != NULL);
+ gulong count, lines, start_l, opcode;
+ guchar *start_p;
+
+ g_return_if_fail (flxdec != NULL);
+ g_return_if_fail (flxdec->delta != NULL);
/* use last frame for delta */
- memcpy(dest, GST_BUFFER_DATA(flxdec->delta),
- GST_BUFFER_SIZE(flxdec->delta));
+ memcpy (dest, GST_BUFFER_DATA (flxdec->delta),
+ GST_BUFFER_SIZE (flxdec->delta));
- lines = (data[0] + (data[1] << 8));
- data += 2;
+ lines = (data[0] + (data[1] << 8));
+ data += 2;
- start_p = dest;
- start_l = lines;
+ start_p = dest;
+ start_l = lines;
while (lines) {
dest = start_p + (flxdec->hdr.width * (start_l - lines));
while ((opcode = (data[0] + (data[1] << 8))) & 0xc000) {
data += 2;
if ((opcode & 0xc000) == 0xc000) {
- /* skip count */
- start_l += (0x10000 - opcode);
- dest += flxdec->hdr.width * (0x10000 - opcode);
+ /* skip count */
+ start_l += (0x10000 - opcode);
+ dest += flxdec->hdr.width * (0x10000 - opcode);
} else {
- /* last pixel */
- dest += flxdec->hdr.width;
- *dest++ = (opcode & 0xff);
- }
+ /* last pixel */
+ dest += flxdec->hdr.width;
+ *dest++ = (opcode & 0xff);
+ }
}
data += 2;
/* last opcode is the packet count */
- while(opcode--) {
+ while (opcode--) {
/* skip count */
dest += *data++;
-
+
/* RLE count */
count = *data++;
-
+
if (count > 0x7f) {
- /* replicate word run */
- count = 0x100 - count;
- while (count--) {
- *dest++ = data[0];
- *dest++ = data[1];
- }
- data += 2;
+ /* replicate word run */
+ count = 0x100 - count;
+ while (count--) {
+ *dest++ = data[0];
+ *dest++ = data[1];
+ }
+ data += 2;
} else {
- /* literal word run */
- while (count--) {
- *dest++ = *data++;
- *dest++ = *data++;
- }
+ /* literal word run */
+ while (count--) {
+ *dest++ = *data++;
+ *dest++ = *data++;
+ }
}
}
lines--;
}
}
-
-static GstBuffer*
-flx_get_data(GstFlxDec *flxdec, gulong size)
+
+static GstBuffer *
+flx_get_data (GstFlxDec * flxdec, gulong size)
{
GstBuffer *retbuf;
guint32 got_bytes;
}
-static void
-gst_flxdec_loop (GstElement *element)
+static void
+gst_flxdec_loop (GstElement * element)
{
- GstBuffer *buf;
- GstBuffer *databuf;
- guchar *data, *chunk;
- GstCaps *caps;
-
- GstFlxDec *flxdec;
- FlxHeader *flxh;
- FlxFrameChunk *flxfh;
-
+ GstBuffer *buf;
+ GstBuffer *databuf;
+ guchar *data, *chunk;
+ GstCaps *caps;
+
+ GstFlxDec *flxdec;
+ FlxHeader *flxh;
+ FlxFrameChunk *flxfh;
+
g_return_if_fail (element != NULL);
- g_return_if_fail (GST_IS_FLXDEC(element));
+ g_return_if_fail (GST_IS_FLXDEC (element));
GST_DEBUG ("entering loop function");
-
- flxdec = GST_FLXDEC(element);
+
+ flxdec = GST_FLXDEC (element);
if (flxdec->state == GST_FLXDEC_READ_HEADER) {
- databuf = flx_get_data(flxdec, FlxHeaderSize);
+ databuf = flx_get_data (flxdec, FlxHeaderSize);
if (!databuf) {
g_print ("empty buffer\n");
return;
}
- data = GST_BUFFER_DATA(databuf);
+ data = GST_BUFFER_DATA (databuf);
- memcpy((char *) &flxdec->hdr, data, sizeof(FlxHeader));
+ memcpy ((char *) &flxdec->hdr, data, sizeof (FlxHeader));
gst_buffer_unref (databuf);
/* check header */
if (flxh->type != FLX_MAGICHDR_FLI &&
- flxh->type != FLX_MAGICHDR_FLC &&
- flxh->type != FLX_MAGICHDR_FLX) {
- GST_ELEMENT_ERROR (element, STREAM, WRONG_TYPE, (NULL), ("not a flx file (type %d)\n", flxh->type));
+ flxh->type != FLX_MAGICHDR_FLC && flxh->type != FLX_MAGICHDR_FLX) {
+ GST_ELEMENT_ERROR (element, STREAM, WRONG_TYPE, (NULL),
+ ("not a flx file (type %d)\n", flxh->type));
return;
}
-
-
- g_print("GstFlxDec: size : %d\n", flxh->size);
- g_print("GstFlxDec: frames : %d\n", flxh->frames);
- g_print("GstFlxDec: width : %d\n", flxh->width);
- g_print("GstFlxDec: height : %d\n", flxh->height);
- g_print("GstFlxDec: depth : %d\n", flxh->depth);
- g_print("GstFlxDec: speed : %d\n", flxh->speed);
+
+
+ g_print ("GstFlxDec: size : %d\n", flxh->size);
+ g_print ("GstFlxDec: frames : %d\n", flxh->frames);
+ g_print ("GstFlxDec: width : %d\n", flxh->width);
+ g_print ("GstFlxDec: height : %d\n", flxh->height);
+ g_print ("GstFlxDec: depth : %d\n", flxh->depth);
+ g_print ("GstFlxDec: speed : %d\n", flxh->speed);
flxdec->next_time = 0;
if (flxh->type == FLX_MAGICHDR_FLI) {
flxdec->frame_time = JIFFIE * flxh->speed;
- }
- else {
+ } else {
flxdec->frame_time = flxh->speed * GST_MSECOND;
}
-
+
caps = gst_caps_from_string (GST_VIDEO_CAPS_xRGB_HOST_ENDIAN);
gst_caps_set_simple (caps,
- "width", G_TYPE_INT, flxh->width,
+ "width", G_TYPE_INT, flxh->width,
"height", G_TYPE_INT, flxh->height,
- "framerate", G_TYPE_DOUBLE, GST_SECOND/flxdec->frame_time, NULL);
+ "framerate", G_TYPE_DOUBLE, GST_SECOND / flxdec->frame_time, NULL);
- if (flxh->depth <= 8)
- flxdec->converter = flx_colorspace_converter_new(flxh->width, flxh->height);
+ if (flxh->depth <= 8)
+ flxdec->converter =
+ flx_colorspace_converter_new (flxh->width, flxh->height);
- if (flxh->type == FLX_MAGICHDR_FLC ||
- flxh->type == FLX_MAGICHDR_FLX) {
- g_print("GstFlxDec: (FLC) aspect_dx : %d\n", flxh->aspect_dx);
- g_print("GstFlxDec: (FLC) aspect_dy : %d\n", flxh->aspect_dy);
- g_print("GstFlxDec: (FLC) oframe1 : 0x%08x\n", flxh->oframe1);
- g_print("GstFlxDec: (FLC) oframe2 : 0x%08x\n", flxh->oframe2);
+ if (flxh->type == FLX_MAGICHDR_FLC || flxh->type == FLX_MAGICHDR_FLX) {
+ g_print ("GstFlxDec: (FLC) aspect_dx : %d\n", flxh->aspect_dx);
+ g_print ("GstFlxDec: (FLC) aspect_dy : %d\n", flxh->aspect_dy);
+ g_print ("GstFlxDec: (FLC) oframe1 : 0x%08x\n", flxh->oframe1);
+ g_print ("GstFlxDec: (FLC) oframe2 : 0x%08x\n", flxh->oframe2);
}
-
+
flxdec->size = (flxh->width * flxh->height);
-
+
/* create delta and output frame */
- flxdec->frame = gst_buffer_new();
- flxdec->delta = gst_buffer_new();
- GST_BUFFER_DATA(flxdec->frame) = g_malloc(flxdec->size);
- GST_BUFFER_SIZE(flxdec->frame) = flxdec->size;
- GST_BUFFER_DATA(flxdec->delta) = g_malloc(flxdec->size);
- GST_BUFFER_SIZE(flxdec->delta) = flxdec->size;
+ flxdec->frame = gst_buffer_new ();
+ flxdec->delta = gst_buffer_new ();
+ GST_BUFFER_DATA (flxdec->frame) = g_malloc (flxdec->size);
+ GST_BUFFER_SIZE (flxdec->frame) = flxdec->size;
+ GST_BUFFER_DATA (flxdec->delta) = g_malloc (flxdec->size);
+ GST_BUFFER_SIZE (flxdec->delta) = flxdec->size;
flxdec->state = GST_FLXDEC_PLAYING;
- }
- else if (flxdec->state == GST_FLXDEC_PLAYING) {
+ } else if (flxdec->state == GST_FLXDEC_PLAYING) {
GstBuffer *out;
- databuf = flx_get_data(flxdec, FlxFrameChunkSize);
+ databuf = flx_get_data (flxdec, FlxFrameChunkSize);
if (!databuf)
return;
- flxfh = (FlxFrameChunk *) GST_BUFFER_DATA(databuf);
-
- switch(flxfh->id) {
+ flxfh = (FlxFrameChunk *) GST_BUFFER_DATA (databuf);
+
+ switch (flxfh->id) {
case FLX_FRAME_TYPE:
- buf = flx_get_data(flxdec, flxfh->size-FlxFrameChunkSize);
-
- chunk = GST_BUFFER_DATA(buf);
-
- if (((FlxFrameType *)chunk)->chunks == 0)
- break;
-
- /* create 32 bits output frame */
- out = gst_buffer_new();
- GST_BUFFER_DATA(out) = g_malloc(flxdec->size * 4);
- GST_BUFFER_SIZE(out) = flxdec->size * 4;
-
- /* decode chunks */
- flx_decode_chunks(flxdec,
- ((FlxFrameType *)chunk)->chunks,
- GST_BUFFER_DATA(buf) + FlxFrameTypeSize,
- GST_BUFFER_DATA(flxdec->frame));
-
- /* destroy input buffer*/
- gst_buffer_unref(buf);
-
- /* save copy of the current frame for possible delta. */
- memcpy(GST_BUFFER_DATA(flxdec->delta),
- GST_BUFFER_DATA(flxdec->frame),
- GST_BUFFER_SIZE(flxdec->delta));
-
- /* convert current frame. */
- flx_colorspace_convert(flxdec->converter,
- GST_BUFFER_DATA(flxdec->frame),
- GST_BUFFER_DATA(out));
+ buf = flx_get_data (flxdec, flxfh->size - FlxFrameChunkSize);
+
+ chunk = GST_BUFFER_DATA (buf);
+
+ if (((FlxFrameType *) chunk)->chunks == 0)
+ break;
+
+ /* create 32 bits output frame */
+ out = gst_buffer_new ();
+ GST_BUFFER_DATA (out) = g_malloc (flxdec->size * 4);
+ GST_BUFFER_SIZE (out) = flxdec->size * 4;
+
+ /* decode chunks */
+ flx_decode_chunks (flxdec,
+ ((FlxFrameType *) chunk)->chunks,
+ GST_BUFFER_DATA (buf) + FlxFrameTypeSize,
+ GST_BUFFER_DATA (flxdec->frame));
+
+ /* destroy input buffer */
+ gst_buffer_unref (buf);
+
+ /* save copy of the current frame for possible delta. */
+ memcpy (GST_BUFFER_DATA (flxdec->delta),
+ GST_BUFFER_DATA (flxdec->frame), GST_BUFFER_SIZE (flxdec->delta));
+
+ /* convert current frame. */
+ flx_colorspace_convert (flxdec->converter,
+ GST_BUFFER_DATA (flxdec->frame), GST_BUFFER_DATA (out));
GST_BUFFER_TIMESTAMP (out) = flxdec->next_time;
flxdec->next_time += flxdec->frame_time;
- gst_pad_push(flxdec->srcpad, GST_DATA (out));
-
- break;
+ gst_pad_push (flxdec->srcpad, GST_DATA (out));
+
+ break;
}
/* destroy header buffer */
- gst_buffer_unref(databuf);
+ gst_buffer_unref (databuf);
}
}
-static GstElementStateReturn
-gst_flxdec_change_state (GstElement *element)
+static GstElementStateReturn
+gst_flxdec_change_state (GstElement * element)
{
GstFlxDec *flxdec;
- flxdec = GST_FLXDEC(element);
+ flxdec = GST_FLXDEC (element);
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY:
case GST_STATE_READY_TO_NULL:
break;
}
-
+
parent_class->change_state (element);
return GST_STATE_SUCCESS;
}
-static void
-gst_flxdec_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+static void
+gst_flxdec_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstFlxDec *flxdec;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_FLXDEC(object));
- flxdec = GST_FLXDEC(object);
+ g_return_if_fail (GST_IS_FLXDEC (object));
+ flxdec = GST_FLXDEC (object);
switch (prop_id) {
default:
}
}
-static void
-gst_flxdec_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+static void
+gst_flxdec_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstFlxDec *flxdec;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_FLXDEC(object));
- flxdec = GST_FLXDEC(object);
+ g_return_if_fail (GST_IS_FLXDEC (object));
+ flxdec = GST_FLXDEC (object);
switch (prop_id) {
default:
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
if (!gst_library_load ("gstbytestream"))
return FALSE;
return gst_element_register (plugin, "flxdec",
- GST_RANK_PRIMARY, GST_TYPE_FLXDEC);
+ GST_RANK_PRIMARY, GST_TYPE_FLXDEC);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "flxdec",
- "FLX video decoder",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "flxdec",
+ "FLX video decoder",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
+
+ typedef enum
+ {
+ GST_FLXDEC_READ_HEADER,
+ GST_FLXDEC_PLAYING,
+ } GstFlxDecState;
-typedef enum {
- GST_FLXDEC_READ_HEADER,
- GST_FLXDEC_PLAYING,
-} GstFlxDecState;
-
/* Definition of structure storing data for this element. */
-typedef struct _GstFlxDec GstFlxDec;
+ typedef struct _GstFlxDec GstFlxDec;
-struct _GstFlxDec {
- GstElement element;
+ struct _GstFlxDec
+ {
+ GstElement element;
- GstPad *sinkpad,*srcpad;
+ GstPad *sinkpad, *srcpad;
- gboolean active, new_meta;
+ gboolean active, new_meta;
- GstBuffer *delta, *frame;
- GstByteStream *bs;
- gulong size;
- GstFlxDecState state;
- glong frame_time;
- gint64 next_time;
+ GstBuffer *delta, *frame;
+ GstByteStream *bs;
+ gulong size;
+ GstFlxDecState state;
+ glong frame_time;
+ gint64 next_time;
- FlxColorSpaceConverter *converter;
+ FlxColorSpaceConverter *converter;
- FlxHeader hdr;
-};
+ FlxHeader hdr;
+ };
/* Standard definition defining a class for this element. */
-typedef struct _GstFlxDecClass GstFlxDecClass;
-struct _GstFlxDecClass {
- GstElementClass parent_class;
-};
+ typedef struct _GstFlxDecClass GstFlxDecClass;
+ struct _GstFlxDecClass
+ {
+ GstElementClass parent_class;
+ };
/* Standard macros for defining types for this element. */
#define GST_TYPE_FLXDEC \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FLXDEC))
/* Standard function returning type information. */
-GType gst_flxdec_get_type(void);
+ GType gst_flxdec_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_FLX_DECODER_H__ */
+#endif /* __GST_FLX_DECODER_H__ */
typedef struct _GstMixMatrix GstMixMatrix;
typedef struct _GstMixMatrixClass GstMixMatrixClass;
-struct _GstMixMatrix {
+struct _GstMixMatrix
+{
GstElement element;
GstCaps *caps;
gfloat **matrix;
};
-struct _GstMixMatrixClass {
+struct _GstMixMatrixClass
+{
GstElementClass parent_class;
- void (*resize) (GstMixMatrix *mix);
+ void (*resize) (GstMixMatrix * mix);
};
/* elementfactory information */
"Erik Walthinsen <omega@temple-baptist.com>"
};
-enum {
+enum
+{
/* FILL ME */
RESIZE_SIGNAL,
LAST_SIGNAL,
};
-enum {
+enum
+{
ARG_0,
ARG_GRPSIZE,
ARG_OUTSIZE,
};
static GstStaticPadTemplate mixmatrix_sink_template =
-GST_STATIC_PAD_TEMPLATE (
- "sink%d",
- GST_PAD_SINK,
- GST_PAD_REQUEST,
- GST_STATIC_CAPS ( GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS )
-);
+GST_STATIC_PAD_TEMPLATE ("sink%d",
+ GST_PAD_SINK,
+ GST_PAD_REQUEST,
+ GST_STATIC_CAPS (GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS)
+ );
static GstStaticPadTemplate mixmatrix_src_template =
-GST_STATIC_PAD_TEMPLATE (
- "src%d",
- GST_PAD_SRC,
- GST_PAD_REQUEST,
- GST_STATIC_CAPS ( GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS )
-);
+GST_STATIC_PAD_TEMPLATE ("src%d",
+ GST_PAD_SRC,
+ GST_PAD_REQUEST,
+ GST_STATIC_CAPS (GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS)
+ );
-static void gst_mixmatrix_class_init (GstMixMatrixClass *klass);
-static void gst_mixmatrix_base_init (GstMixMatrixClass *klass);
-static void gst_mixmatrix_init (GstMixMatrix *element);
+static void gst_mixmatrix_class_init (GstMixMatrixClass * klass);
+static void gst_mixmatrix_base_init (GstMixMatrixClass * klass);
+static void gst_mixmatrix_init (GstMixMatrix * element);
-static void gst_mixmatrix_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void gst_mixmatrix_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
-static GstPad * gst_mixmatrix_request_new_pad (GstElement *element, GstPadTemplate *temp, const gchar *name);
+static void gst_mixmatrix_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_mixmatrix_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+static GstPad *gst_mixmatrix_request_new_pad (GstElement * element,
+ GstPadTemplate * temp, const gchar * name);
-static GstPadLinkReturn gst_mixmatrix_connect (GstPad *pad, const GstCaps *caps);
+static GstPadLinkReturn gst_mixmatrix_connect (GstPad * pad,
+ const GstCaps * caps);
-static void gst_mixmatrix_loop (GstElement *element);
+static void gst_mixmatrix_loop (GstElement * element);
-static guint gst_mixmatrix_signals[LAST_SIGNAL] = { 0 };
-static GstElementClass *parent_class = NULL;
+static guint gst_mixmatrix_signals[LAST_SIGNAL] = { 0 };
+static GstElementClass *parent_class = NULL;
GType
-gst_mixmatrix_get_type(void) {
+gst_mixmatrix_get_type (void)
+{
static GType mixmatrix_type = 0;
if (!mixmatrix_type) {
static const GTypeInfo mixmatrix_info = {
- sizeof(GstMixMatrixClass),
- (GBaseInitFunc)gst_mixmatrix_base_init,
+ sizeof (GstMixMatrixClass),
+ (GBaseInitFunc) gst_mixmatrix_base_init,
NULL,
- (GClassInitFunc)gst_mixmatrix_class_init,
+ (GClassInitFunc) gst_mixmatrix_class_init,
NULL,
NULL,
- sizeof(GstMixMatrix),
+ sizeof (GstMixMatrix),
0,
- (GInstanceInitFunc)gst_mixmatrix_init,
+ (GInstanceInitFunc) gst_mixmatrix_init,
};
- mixmatrix_type = g_type_register_static(GST_TYPE_ELEMENT, "GstMixMatrix", &mixmatrix_info, 0);
+ mixmatrix_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstMixMatrix",
+ &mixmatrix_info, 0);
}
return mixmatrix_type;
}
static void
-gst_mixmatrix_base_init (GstMixMatrixClass *klass)
+gst_mixmatrix_base_init (GstMixMatrixClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
}
static void
-gst_mixmatrix_class_init (GstMixMatrixClass *klass)
+gst_mixmatrix_class_init (GstMixMatrixClass * 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);
gst_mixmatrix_signals[RESIZE_SIGNAL] =
- g_signal_new("resize",
- G_TYPE_FROM_CLASS(klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GstMixMatrixClass, resize),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_SINKPADS,
- g_param_spec_int("sinkpads","Sink Pads","Number of sink pads in matrix",
- 0, G_MAXINT, 8, G_PARAM_READABLE));
-
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_SRCPADS,
- g_param_spec_int("srcpads","Src Pads","Number of src pads in matrix",
- 0, G_MAXINT, 8, G_PARAM_READABLE));
-
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_MATRIXPTR,
- g_param_spec_pointer("matrixptr","Matrix Pointer","Pointer to gfloat mix matrix",
- G_PARAM_READABLE));
+ g_signal_new ("resize",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstMixMatrixClass, resize),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SINKPADS,
+ g_param_spec_int ("sinkpads", "Sink Pads",
+ "Number of sink pads in matrix", 0, G_MAXINT, 8, G_PARAM_READABLE));
+
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SRCPADS,
+ g_param_spec_int ("srcpads", "Src Pads", "Number of src pads in matrix",
+ 0, G_MAXINT, 8, G_PARAM_READABLE));
+
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MATRIXPTR,
+ g_param_spec_pointer ("matrixptr", "Matrix Pointer",
+ "Pointer to gfloat mix matrix", G_PARAM_READABLE));
gobject_class->set_property = gst_mixmatrix_set_property;
gobject_class->get_property = gst_mixmatrix_get_property;
}
static gfloat **
-mixmatrix_alloc_matrix (int x,int y)
+mixmatrix_alloc_matrix (int x, int y)
{
gfloat **matrix;
int i;
- GST_DEBUG ("mixmatrix: allocating a %dx%d matrix of floats\n",x,y);
- matrix = g_new(gfloat *,x);
- GST_DEBUG ("mixmatrix: %p: ",matrix);
- for (i=0;i<x;i++) {
- matrix[i] = g_new(gfloat,y);
- GST_DEBUG ("%p, ",matrix[i]);
+
+ GST_DEBUG ("mixmatrix: allocating a %dx%d matrix of floats\n", x, y);
+ matrix = g_new (gfloat *, x);
+ GST_DEBUG ("mixmatrix: %p: ", matrix);
+ for (i = 0; i < x; i++) {
+ matrix[i] = g_new (gfloat, y);
+ GST_DEBUG ("%p, ", matrix[i]);
}
GST_DEBUG ("\n");
return matrix;
}
static void
-mixmatrix_free_matrix (gfloat **matrix,int x)
+mixmatrix_free_matrix (gfloat ** matrix, int x)
{
int i;
- for (i=0;i<x;i++)
- g_free(matrix[i]);
- g_free(matrix);
+
+ for (i = 0; i < x; i++)
+ g_free (matrix[i]);
+ g_free (matrix);
}
static void
-gst_mixmatrix_init (GstMixMatrix *mix)
+gst_mixmatrix_init (GstMixMatrix * mix)
{
mix->grpsize = 8;
mix->outsize = 1024;
mix->srcpadalloc = mix->grpsize;
// allocate the pads
- mix->sinkpads = g_new(GstPad *,mix->sinkpadalloc);
- mix->sinkbs = g_new(GstByteStream *,mix->sinkpadalloc);
+ mix->sinkpads = g_new (GstPad *, mix->sinkpadalloc);
+ mix->sinkbs = g_new (GstByteStream *, mix->sinkpadalloc);
- mix->srcpads = g_new(GstPad *,mix->srcpadalloc);
+ mix->srcpads = g_new (GstPad *, mix->srcpadalloc);
// allocate a similarly sized matrix
- mix->matrix = mixmatrix_alloc_matrix(mix->sinkpadalloc,mix->srcpadalloc);
+ mix->matrix = mixmatrix_alloc_matrix (mix->sinkpadalloc, mix->srcpadalloc);
// set the loop function that does all the work
- gst_element_set_loop_function(GST_ELEMENT(mix), gst_mixmatrix_loop);
+ gst_element_set_loop_function (GST_ELEMENT (mix), gst_mixmatrix_loop);
}
#define ROUND_UP(val,bound) ((((val)/bound)+1)*bound)
-static void **grow_ptrlist(void **origlist,int origsize,int newsize) {
- void **newlist = g_new(void *,newsize);
- memcpy(newlist,origlist,sizeof(void*)*origsize);
- g_free(origlist);
+static void **
+grow_ptrlist (void **origlist, int origsize, int newsize)
+{
+ void **newlist = g_new (void *, newsize);
+ memcpy (newlist, origlist, sizeof (void *) * origsize);
+ g_free (origlist);
return newlist;
}
void
-mixmatrix_resize(GstMixMatrix *mix, int sinkpads, int srcpads)
+mixmatrix_resize (GstMixMatrix * mix, int sinkpads, int srcpads)
{
int sinkresize = (sinkpads != mix->sinkpadalloc);
int srcresize = (srcpads != mix->srcpadalloc);
// check the sinkpads list
if (sinkresize) {
- mix->sinkpads = (GstPad **)grow_ptrlist((void **)mix->sinkpads,mix->sinkpadalloc,sinkpads);
- mix->sinkbs = (GstByteStream **)grow_ptrlist((void **)mix->sinkbs,mix->sinkpadalloc,sinkpads);
+ mix->sinkpads =
+ (GstPad **) grow_ptrlist ((void **) mix->sinkpads, mix->sinkpadalloc,
+ sinkpads);
+ mix->sinkbs =
+ (GstByteStream **) grow_ptrlist ((void **) mix->sinkbs,
+ mix->sinkpadalloc, sinkpads);
}
-
// check the srcpads list
if (srcresize) {
- mix->srcpads = (GstPad **)grow_ptrlist((void **)mix->srcpads,mix->srcpadalloc,srcpads);
+ mix->srcpads =
+ (GstPad **) grow_ptrlist ((void **) mix->srcpads, mix->srcpadalloc,
+ srcpads);
}
-
// now resize the matrix if either has changed
if (sinkresize || srcresize) {
// allocate the new matrix
- newmatrix = mixmatrix_alloc_matrix(sinkpads,srcpads);
+ newmatrix = mixmatrix_alloc_matrix (sinkpads, srcpads);
// if only the srcpad count changed (y axis), we can just copy
if (!sinkresize) {
- memcpy(newmatrix,mix->matrix,sizeof(gfloat *)*sinkpads);
- // otherwise we have to copy line by line
+ memcpy (newmatrix, mix->matrix, sizeof (gfloat *) * sinkpads);
+ // otherwise we have to copy line by line
} else {
- for (i=0;i<mix->srcpadalloc;i++)
- memcpy(newmatrix[i], mix->matrix[i], sizeof(gfloat) * mix->srcpadalloc);
+ for (i = 0; i < mix->srcpadalloc; i++)
+ memcpy (newmatrix[i], mix->matrix[i],
+ sizeof (gfloat) * mix->srcpadalloc);
}
// would signal here!
// free old matrix and replace it
- mixmatrix_free_matrix(mix->matrix, mix->sinkpadalloc);
+ mixmatrix_free_matrix (mix->matrix, mix->sinkpadalloc);
mix->matrix = newmatrix;
}
*/
static GstPadLinkReturn
-gst_mixmatrix_connect (GstPad *pad, const GstCaps *caps)
+gst_mixmatrix_connect (GstPad * pad, const GstCaps * caps)
{
- GstMixMatrix *mix = GST_MIXMATRIX(GST_PAD_PARENT(pad));
+ GstMixMatrix *mix = GST_MIXMATRIX (GST_PAD_PARENT (pad));
gint i;
- for (i=0;i<mix->srcpadalloc;i++) {
+ for (i = 0; i < mix->srcpadalloc; i++) {
if (mix->srcpads[i]) {
- if (GST_PAD_CAPS(mix->srcpads[i]) == NULL) {
- if (gst_pad_try_set_caps(mix->srcpads[i], caps) <= 0) {
+ if (GST_PAD_CAPS (mix->srcpads[i]) == NULL) {
+ if (gst_pad_try_set_caps (mix->srcpads[i], caps) <= 0) {
return GST_PAD_LINK_REFUSED;
}
}
}
}
- mix->caps = gst_caps_copy(caps);
+ mix->caps = gst_caps_copy (caps);
return GST_PAD_LINK_OK;
}
static GstPad *
-gst_mixmatrix_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar *name)
+gst_mixmatrix_request_new_pad (GstElement * element, GstPadTemplate * templ,
+ const gchar * name)
{
GstMixMatrix *mix;
gint padnum;
GstPad *pad = NULL;
- g_return_val_if_fail(element != NULL, NULL);
- g_return_val_if_fail(GST_IS_MIXMATRIX(element), NULL);
+ g_return_val_if_fail (element != NULL, NULL);
+ g_return_val_if_fail (GST_IS_MIXMATRIX (element), NULL);
- mix = GST_MIXMATRIX(element);
+ mix = GST_MIXMATRIX (element);
// figure out if it's a sink pad
- if (sscanf(name,"sink%d",&padnum)) {
+ if (sscanf (name, "sink%d", &padnum)) {
// check to see if it already exists
if (padnum < mix->sinkpadalloc && mix->sinkpads[padnum])
return mix->sinkpads[padnum];
// determine if it's bigger than the current size
if (padnum >= mix->sinkpadalloc)
- mixmatrix_resize(mix, ROUND_UP(padnum,mix->grpsize), mix->sinkpadalloc);
-
- pad = gst_pad_new_from_template(
- gst_static_pad_template_get (&mixmatrix_sink_template), name);
- GST_PAD_ELEMENT_PRIVATE(pad) = GINT_TO_POINTER(padnum);
- gst_element_add_pad(GST_ELEMENT(mix), pad);
+ mixmatrix_resize (mix, ROUND_UP (padnum, mix->grpsize),
+ mix->sinkpadalloc);
+
+ pad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&mixmatrix_sink_template), name);
+ GST_PAD_ELEMENT_PRIVATE (pad) = GINT_TO_POINTER (padnum);
+ gst_element_add_pad (GST_ELEMENT (mix), pad);
// g_signal_connect(G_OBJECT(pad), "unlink", G_CALLBACK(sink_unlinked), mix);
gst_pad_set_link_function (pad, gst_mixmatrix_connect);
// create a bytestream for it
- mix->sinkbs[padnum] = gst_bytestream_new(pad);
+ mix->sinkbs[padnum] = gst_bytestream_new (pad);
// store away the pad and account for it
mix->sinkpads[padnum] = pad;
}
-
// or it's a src pad
- else if (sscanf(name,"src%d",&padnum)) {
+ else if (sscanf (name, "src%d", &padnum)) {
// check to see if it already exists
if (padnum < mix->srcpadalloc && mix->srcpads[padnum])
return mix->srcpads[padnum];
// determine if it's bigger than the current size
if (padnum >= mix->srcpadalloc)
- mixmatrix_resize(mix, ROUND_UP(padnum,mix->grpsize), mix->srcpadalloc);
+ mixmatrix_resize (mix, ROUND_UP (padnum, mix->grpsize), mix->srcpadalloc);
- pad = gst_pad_new_from_template(
- gst_static_pad_template_get (&mixmatrix_src_template), name);
- GST_PAD_ELEMENT_PRIVATE(pad) = GINT_TO_POINTER(padnum);
- gst_element_add_pad(GST_ELEMENT(mix), pad);
+ pad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&mixmatrix_src_template), name);
+ GST_PAD_ELEMENT_PRIVATE (pad) = GINT_TO_POINTER (padnum);
+ gst_element_add_pad (GST_ELEMENT (mix), pad);
// g_signal_connect(G_OBJECT(pad), "unlink", G_CALLBACK(sink_unlinked), mix);
//gst_pad_set_link_function (pad, gst_mixmatrix_connect);
}
static void
-gst_mixmatrix_loop (GstElement *element)
+gst_mixmatrix_loop (GstElement * element)
{
- GstMixMatrix *mix = GST_MIXMATRIX(element);
- int i,j,k;
+ GstMixMatrix *mix = GST_MIXMATRIX (element);
+ int i, j, k;
GstBuffer **inbufs;
gfloat **infloats;
GstBuffer **outbufs;
gfloat **outfloats;
- int bytesize = sizeof(gfloat)*mix->outsize;
+ int bytesize = sizeof (gfloat) * mix->outsize;
gfloat gain;
// create the output buffers
- outbufs = g_new(GstBuffer *,mix->srcpadalloc);
- outfloats = g_new(gfloat *,mix->srcpadalloc);
- for (i=0;i<mix->srcpadalloc;i++) {
+ outbufs = g_new (GstBuffer *, mix->srcpadalloc);
+ outfloats = g_new (gfloat *, mix->srcpadalloc);
+ for (i = 0; i < mix->srcpadalloc; i++) {
if (mix->srcpads[i] != NULL) {
- outbufs[i] = gst_buffer_new_and_alloc(bytesize);
- outfloats[i] = (gfloat *)GST_BUFFER_DATA(outbufs[i]);
- memset(outfloats[i],0,bytesize);
+ outbufs[i] = gst_buffer_new_and_alloc (bytesize);
+ outfloats[i] = (gfloat *) GST_BUFFER_DATA (outbufs[i]);
+ memset (outfloats[i], 0, bytesize);
}
}
// go through all the input buffers and pull them
- inbufs = g_new(GstBuffer *,mix->sinkpadalloc);
- infloats = g_new(gfloat *,mix->sinkpadalloc);
- for (i=0;i<mix->sinkpadalloc;i++) {
+ inbufs = g_new (GstBuffer *, mix->sinkpadalloc);
+ infloats = g_new (gfloat *, mix->sinkpadalloc);
+ for (i = 0; i < mix->sinkpadalloc; i++) {
if (mix->sinkpads[i] != NULL) {
- gst_bytestream_read(mix->sinkbs[i],&inbufs[i],bytesize);
- infloats[i] = (gfloat *)GST_BUFFER_DATA(inbufs[i]);
+ gst_bytestream_read (mix->sinkbs[i], &inbufs[i], bytesize);
+ infloats[i] = (gfloat *) GST_BUFFER_DATA (inbufs[i]);
// loop through each src pad
- for (j=0;j<mix->srcpadalloc;j++) {
- if (mix->srcpads[j] != NULL) {
+ for (j = 0; j < mix->srcpadalloc; j++) {
+ if (mix->srcpads[j] != NULL) {
/*
{
int z;
}
fprintf(stderr,"attempting to get gain for %dx%d\n",i,j);
*/
- gain = mix->matrix[i][j];
+ gain = mix->matrix[i][j];
// fprintf(stderr,"%d->%d=%0.2f ",i,j,gain);
- for (k=0;k<mix->outsize;k++) {
- outfloats[j][k] += infloats[i][k] * gain;
- }
- }
+ for (k = 0; k < mix->outsize; k++) {
+ outfloats[j][k] += infloats[i][k] * gain;
+ }
+ }
}
}
}
// fprintf(stderr,"\n");
- for (i=0;i<mix->srcpadalloc;i++) {
+ for (i = 0; i < mix->srcpadalloc; i++) {
if (mix->srcpads[i] != NULL) {
- gst_pad_push(mix->srcpads[i],GST_DATA (outbufs[i]));
+ gst_pad_push (mix->srcpads[i], GST_DATA (outbufs[i]));
}
}
}
static void
-gst_mixmatrix_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_mixmatrix_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstMixMatrix *mix;
- g_return_if_fail(GST_IS_MIXMATRIX(object));
- mix = GST_MIXMATRIX(object);
+ g_return_if_fail (GST_IS_MIXMATRIX (object));
+ mix = GST_MIXMATRIX (object);
switch (prop_id) {
default:
}
static void
-gst_mixmatrix_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_mixmatrix_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstMixMatrix *mix;
- g_return_if_fail(GST_IS_MIXMATRIX(object));
- mix = GST_MIXMATRIX(object);
+ g_return_if_fail (GST_IS_MIXMATRIX (object));
+ mix = GST_MIXMATRIX (object);
switch (prop_id) {
case ARG_SINKPADS:
- g_value_set_int(value, mix->sinkpadalloc);
+ g_value_set_int (value, mix->sinkpadalloc);
break;
case ARG_SRCPADS:
- g_value_set_int(value, mix->srcpadalloc);
+ g_value_set_int (value, mix->srcpadalloc);
break;
case ARG_MATRIXPTR:
- g_value_set_pointer(value, mix->matrix);
+ g_value_set_pointer (value, mix->matrix);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
if (!gst_library_load ("gstbytestream"))
return FALSE;
return gst_element_register (plugin, "mixmatrix",
- GST_RANK_NONE, GST_TYPE_MIXMATRIX);
+ GST_RANK_NONE, GST_TYPE_MIXMATRIX);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "mixmatrix",
- "An audio mixer matrix",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "mixmatrix",
+ "An audio mixer matrix",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
#define __GST_MODPLUG_H__
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#include <gst/gst.h>
#include <gst/bytestream/bytestream.h>
-
+
#define GST_TYPE_MODPLUG \
(gst_modplug_get_type())
-
+
#define GST_MODPLUG(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_MODPLUG,GstModPlug))
#define GST_MODPLUG_CLASS(klass) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_MODPLUG))
#define GST_IS_MODPLUG_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MODPLUG))
-
-struct _GstModPlug {
- GstElement element;
- GstPad *sinkpad, *srcpad;
- guint8 *buffer_in;
- GstByteStream *bs;
-
- const gchar *songname;
- gboolean reverb;
- gint reverb_depth;
- gint reverb_delay;
- gboolean megabass;
- gint megabass_amount;
- gint megabass_range;
- gboolean surround;
- gint surround_depth;
- gint surround_delay;
- gboolean noise_reduction;
- gboolean _16bit;
- gboolean oversamp;
- gint channel;
- gint frequency;
-
- guchar *audiobuffer;
- gint32 length;
- guint state;
- guint bitsPerSample;
- gboolean need_discont;
- gboolean eos;
- gint64 seek_at;
- guint64 song_size;
- guint64 timestamp;
-
- CSoundFile *mSoundFile;
- gboolean opened; /* set to TRUE when mSoundFile is created */
-};
-
-struct _GstModPlugClass {
- GstElementClass parent_class;
-};
-
-typedef struct _GstModPlug GstModPlug;
-typedef struct _GstModPlugClass GstModPlugClass;
-
-GstPad *srcpad;
-int need_sync;
-
-GType gst_modplug_get_type(void);
+
+ struct _GstModPlug
+ {
+ GstElement element;
+ GstPad *sinkpad, *srcpad;
+ guint8 *buffer_in;
+ GstByteStream *bs;
+
+ const gchar *songname;
+ gboolean reverb;
+ gint reverb_depth;
+ gint reverb_delay;
+ gboolean megabass;
+ gint megabass_amount;
+ gint megabass_range;
+ gboolean surround;
+ gint surround_depth;
+ gint surround_delay;
+ gboolean noise_reduction;
+ gboolean _16bit;
+ gboolean oversamp;
+ gint channel;
+ gint frequency;
+
+ guchar *audiobuffer;
+ gint32 length;
+ guint state;
+ guint bitsPerSample;
+ gboolean need_discont;
+ gboolean eos;
+ gint64 seek_at;
+ guint64 song_size;
+ guint64 timestamp;
+
+ CSoundFile *mSoundFile;
+ gboolean opened; /* set to TRUE when mSoundFile is created */
+ };
+
+ struct _GstModPlugClass
+ {
+ GstElementClass parent_class;
+ };
+
+ typedef struct _GstModPlug GstModPlug;
+ typedef struct _GstModPlugClass GstModPlugClass;
+
+ GstPad *srcpad;
+ int need_sync;
+
+ GType gst_modplug_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_MODPLUG_H__ */
+#endif /* __GST_MODPLUG_H__ */
typedef struct tagITFILEHEADER
{
- DWORD id; /* 0x4D504D49 */
- CHAR songname[26];
- WORD reserved1; /* 0x1004 */
- WORD ordnum;
- WORD insnum;
- WORD smpnum;
- WORD patnum;
- WORD cwtv;
- WORD cmwt;
- WORD flags;
- WORD special;
- BYTE globalvol;
- BYTE mv;
- BYTE speed;
- BYTE tempo;
- BYTE sep;
- BYTE zero;
- WORD msglength;
- DWORD msgoffset;
- DWORD reserved2;
- BYTE chnpan[64];
- BYTE chnvol[64];
+ DWORD id; /* 0x4D504D49 */
+ CHAR songname[26];
+ WORD reserved1; /* 0x1004 */
+ WORD ordnum;
+ WORD insnum;
+ WORD smpnum;
+ WORD patnum;
+ WORD cwtv;
+ WORD cmwt;
+ WORD flags;
+ WORD special;
+ BYTE globalvol;
+ BYTE mv;
+ BYTE speed;
+ BYTE tempo;
+ BYTE sep;
+ BYTE zero;
+ WORD msglength;
+ DWORD msgoffset;
+ DWORD reserved2;
+ BYTE chnpan[64];
+ BYTE chnvol[64];
} ITFILEHEADER;
typedef struct tagITENVELOPE
{
- BYTE flags;
- BYTE num;
- BYTE lpb;
- BYTE lpe;
- BYTE slb;
- BYTE sle;
- BYTE data[25*3];
- BYTE reserved;
+ BYTE flags;
+ BYTE num;
+ BYTE lpb;
+ BYTE lpe;
+ BYTE slb;
+ BYTE sle;
+ BYTE data[25 * 3];
+ BYTE reserved;
} ITENVELOPE;
/* Old Impulse Instrument Format (cmwt < 0x200) */
typedef struct tagITOLDINSTRUMENT
{
- DWORD id; /* IMPI = 0x49504D49 */
- CHAR filename[12]; /* DOS file name */
- BYTE zero;
- BYTE flags;
- BYTE vls;
- BYTE vle;
- BYTE sls;
- BYTE sle;
- WORD reserved1;
- WORD fadeout;
- BYTE nna;
- BYTE dnc;
- WORD trkvers;
- BYTE nos;
- BYTE reserved2;
- CHAR name[26];
- WORD reserved3[3];
- BYTE keyboard[240];
- BYTE volenv[200];
- BYTE nodes[50];
+ DWORD id; /* IMPI = 0x49504D49 */
+ CHAR filename[12]; /* DOS file name */
+ BYTE zero;
+ BYTE flags;
+ BYTE vls;
+ BYTE vle;
+ BYTE sls;
+ BYTE sle;
+ WORD reserved1;
+ WORD fadeout;
+ BYTE nna;
+ BYTE dnc;
+ WORD trkvers;
+ BYTE nos;
+ BYTE reserved2;
+ CHAR name[26];
+ WORD reserved3[3];
+ BYTE keyboard[240];
+ BYTE volenv[200];
+ BYTE nodes[50];
} ITOLDINSTRUMENT;
/* Impulse Instrument Format */
typedef struct tagITINSTRUMENT
{
- DWORD id;
- CHAR filename[12];
- BYTE zero;
- BYTE nna;
- BYTE dct;
- BYTE dca;
- WORD fadeout;
- signed char pps;
- BYTE ppc;
- BYTE gbv;
- BYTE dfp;
- BYTE rv;
- BYTE rp;
- WORD trkvers;
- BYTE nos;
- BYTE reserved1;
- CHAR name[26];
- BYTE ifc;
- BYTE ifr;
- BYTE mch;
- BYTE mpr;
- WORD mbank;
- BYTE keyboard[240];
- ITENVELOPE volenv;
- ITENVELOPE panenv;
- ITENVELOPE pitchenv;
- BYTE dummy[4]; /* was 7, but IT v2.17 saves 554 bytes */
+ DWORD id;
+ CHAR filename[12];
+ BYTE zero;
+ BYTE nna;
+ BYTE dct;
+ BYTE dca;
+ WORD fadeout;
+ signed char pps;
+ BYTE ppc;
+ BYTE gbv;
+ BYTE dfp;
+ BYTE rv;
+ BYTE rp;
+ WORD trkvers;
+ BYTE nos;
+ BYTE reserved1;
+ CHAR name[26];
+ BYTE ifc;
+ BYTE ifr;
+ BYTE mch;
+ BYTE mpr;
+ WORD mbank;
+ BYTE keyboard[240];
+ ITENVELOPE volenv;
+ ITENVELOPE panenv;
+ ITENVELOPE pitchenv;
+ BYTE dummy[4]; /* was 7, but IT v2.17 saves 554 bytes */
} ITINSTRUMENT;
/* IT Sample Format */
typedef struct ITSAMPLESTRUCT
{
- DWORD id; /* 0x53504D49 */
- CHAR filename[12];
- BYTE zero;
- BYTE gvl;
- BYTE flags;
- BYTE vol;
- CHAR name[26];
- BYTE cvt;
- BYTE dfp;
- DWORD length;
- DWORD loopbegin;
- DWORD loopend;
- DWORD C5Speed;
- DWORD susloopbegin;
- DWORD susloopend;
- DWORD samplepointer;
- BYTE vis;
- BYTE vid;
- BYTE vir;
- BYTE vit;
+ DWORD id; /* 0x53504D49 */
+ CHAR filename[12];
+ BYTE zero;
+ BYTE gvl;
+ BYTE flags;
+ BYTE vol;
+ CHAR name[26];
+ BYTE cvt;
+ BYTE dfp;
+ DWORD length;
+ DWORD loopbegin;
+ DWORD loopend;
+ DWORD C5Speed;
+ DWORD susloopbegin;
+ DWORD susloopend;
+ DWORD samplepointer;
+ BYTE vis;
+ BYTE vid;
+ BYTE vir;
+ BYTE vit;
} ITSAMPLESTRUCT;
#pragma pack()
#define MODPLUG_H__INCLUDED
#ifdef __cplusplus
-extern "C" {
+extern "C"
+{
#endif
-struct _ModPlugFile;
-typedef struct _ModPlugFile ModPlugFile;
+ struct _ModPlugFile;
+ typedef struct _ModPlugFile ModPlugFile;
/* Load a mod file. [data] should point to a block of memory containing the complete
* file, and [size] should be the size of that block.
* Return the loaded mod file on success, or NULL on failure. */
-ModPlugFile* ModPlug_Load(const void* data, int size);
+ ModPlugFile *ModPlug_Load (const void *data, int size);
/* Unload a mod file. */
-void ModPlug_Unload(ModPlugFile* file);
+ void ModPlug_Unload (ModPlugFile * file);
/* Read sample data into the buffer. Returns the number of bytes read. If the end
* of the mod has been reached, zero is returned. */
-int ModPlug_Read(ModPlugFile* file, void* buffer, int size);
+ int ModPlug_Read (ModPlugFile * file, void *buffer, int size);
/* Get the name of the mod. The returned buffer is stored within the ModPlugFile
* structure and will remain valid until you unload the file. */
-const char* ModPlug_GetName(ModPlugFile* file);
+ const char *ModPlug_GetName (ModPlugFile * file);
/* Get the length of the mod, in milliseconds. Note that this result is not always
* accurate, especially in the case of mods with loops. */
-int ModPlug_GetLength(ModPlugFile* file);
+ int ModPlug_GetLength (ModPlugFile * file);
/* Seek to a particular position in the song. Note that seeking and MODs don't mix very
* well. Some mods will be missing instruments for a short time after a seek, as ModPlug
* playing at that time. (Doing so would be difficult and not very reliable.) Also,
* note that seeking is not very exact in some mods -- especially those for which
* ModPlug_GetLength() does not report the full length. */
-void ModPlug_Seek(ModPlugFile* file, int millisecond);
+ void ModPlug_Seek (ModPlugFile * file, int millisecond);
-enum _ModPlug_Flags
-{
- MODPLUG_ENABLE_OVERSAMPLING = 1 << 0, /* Enable oversampling (*highly* recommended) */
- MODPLUG_ENABLE_NOISE_REDUCTION = 1 << 1, /* Enable noise reduction */
- MODPLUG_ENABLE_REVERB = 1 << 2, /* Enable reverb */
- MODPLUG_ENABLE_MEGABASS = 1 << 3, /* Enable megabass */
- MODPLUG_ENABLE_SURROUND = 1 << 4 /* Enable surround sound. */
-};
-
-enum _ModPlug_ResamplingMode
-{
- MODPLUG_RESAMPLE_NEAREST = 0, /* No interpolation (very fast, extremely bad sound quality) */
- MODPLUG_RESAMPLE_LINEAR = 1, /* Linear interpolation (fast, good quality) */
- MODPLUG_RESAMPLE_SPLINE = 2, /* Cubic spline interpolation (high quality) */
- MODPLUG_RESAMPLE_FIR = 3 /* 8-tap fir filter (extremely high quality) */
-};
+ enum _ModPlug_Flags
+ {
+ MODPLUG_ENABLE_OVERSAMPLING = 1 << 0, /* Enable oversampling (*highly* recommended) */
+ MODPLUG_ENABLE_NOISE_REDUCTION = 1 << 1, /* Enable noise reduction */
+ MODPLUG_ENABLE_REVERB = 1 << 2, /* Enable reverb */
+ MODPLUG_ENABLE_MEGABASS = 1 << 3, /* Enable megabass */
+ MODPLUG_ENABLE_SURROUND = 1 << 4 /* Enable surround sound. */
+ };
-typedef struct _ModPlug_Settings
-{
- int mFlags; /* One or more of the MODPLUG_ENABLE_* flags above, bitwise-OR'ed */
-
- /* Note that ModPlug always decodes sound at 44100kHz, 32 bit, stereo and then
- * down-mixes to the settings you choose. */
- int mChannels; /* Number of channels - 1 for mono or 2 for stereo */
- int mBits; /* Bits per sample - 8, 16, or 32 */
- int mFrequency; /* Sampling rate - 11025, 22050, or 44100 */
- int mResamplingMode; /* One of MODPLUG_RESAMPLE_*, above */
-
- int mReverbDepth; /* Reverb level 0(quiet)-100(loud) */
- int mReverbDelay; /* Reverb delay in ms, usually 40-200ms */
- int mBassAmount; /* XBass level 0(quiet)-100(loud) */
- int mBassRange; /* XBass cutoff in Hz 10-100 */
- int mSurroundDepth; /* Surround level 0(quiet)-100(heavy) */
- int mSurroundDelay; /* Surround delay in ms, usually 5-40ms */
- int mLoopCount; /* Number of times to loop. Zero prevents looping.
- -1 loops forever. */
-} ModPlug_Settings;
+ enum _ModPlug_ResamplingMode
+ {
+ MODPLUG_RESAMPLE_NEAREST = 0, /* No interpolation (very fast, extremely bad sound quality) */
+ MODPLUG_RESAMPLE_LINEAR = 1, /* Linear interpolation (fast, good quality) */
+ MODPLUG_RESAMPLE_SPLINE = 2, /* Cubic spline interpolation (high quality) */
+ MODPLUG_RESAMPLE_FIR = 3 /* 8-tap fir filter (extremely high quality) */
+ };
+
+ typedef struct _ModPlug_Settings
+ {
+ int mFlags; /* One or more of the MODPLUG_ENABLE_* flags above, bitwise-OR'ed */
+
+ /* Note that ModPlug always decodes sound at 44100kHz, 32 bit, stereo and then
+ * down-mixes to the settings you choose. */
+ int mChannels; /* Number of channels - 1 for mono or 2 for stereo */
+ int mBits; /* Bits per sample - 8, 16, or 32 */
+ int mFrequency; /* Sampling rate - 11025, 22050, or 44100 */
+ int mResamplingMode; /* One of MODPLUG_RESAMPLE_*, above */
+
+ int mReverbDepth; /* Reverb level 0(quiet)-100(loud) */
+ int mReverbDelay; /* Reverb delay in ms, usually 40-200ms */
+ int mBassAmount; /* XBass level 0(quiet)-100(loud) */
+ int mBassRange; /* XBass cutoff in Hz 10-100 */
+ int mSurroundDepth; /* Surround level 0(quiet)-100(heavy) */
+ int mSurroundDelay; /* Surround delay in ms, usually 5-40ms */
+ int mLoopCount; /* Number of times to loop. Zero prevents looping.
+ -1 loops forever. */
+ } ModPlug_Settings;
/* Get and set the mod decoder settings. All options, except for channels, bits-per-sample,
* sampling rate, and loop count, will take effect immediately. Those options which don't
* take effect immediately will take effect the next time you load a mod. */
-void ModPlug_GetSettings(ModPlug_Settings* settings);
-void ModPlug_SetSettings(const ModPlug_Settings* settings);
+ void ModPlug_GetSettings (ModPlug_Settings * settings);
+ void ModPlug_SetSettings (const ModPlug_Settings * settings);
#ifdef __cplusplus
-} /* extern "C" */
+} /* extern "C" */
#endif
#endif
#define __SNDFILE_H
#ifndef LPCBYTE
-typedef const BYTE * LPCBYTE;
+typedef const BYTE *LPCBYTE;
#endif
#define MOD_AMIGAC2 0x1AB
#define MOD_TYPE_AMF0 0x200000
#define MOD_TYPE_PSM 0x400000
#define MOD_TYPE_J2B 0x800000
-#define MOD_TYPE_UMX 0x80000000 /* Fake type */
+#define MOD_TYPE_UMX 0x80000000 /* Fake type */
#define MAX_MODTYPE 23
#define RS_STIPCM16U (RS_PCM16U|0x40|RSF_STEREO) /* stereo 16-bit unsigned */
#define RS_STIPCM16M (RS_PCM16M|0x40|RSF_STEREO) /* stereo 16-bit signed big endian */
/* 24-bit signed */
-#define RS_PCM24S (RS_PCM16S|0x80) /* mono 24-bit signed */
+#define RS_PCM24S (RS_PCM16S|0x80) /* mono 24-bit signed */
#define RS_STIPCM24S (RS_PCM16S|0x80|RSF_STEREO) /* stereo 24-bit signed */
-#define RS_PCM32S (RS_PCM16S|0xC0) /* mono 24-bit signed */
+#define RS_PCM32S (RS_PCM16S|0xC0) /* mono 24-bit signed */
#define RS_STIPCM32S (RS_PCM16S|0xC0|RSF_STEREO) /* stereo 24-bit signed */
/* NNA types */
/* Reverb Types (GM2 Presets) */
-enum {
- REVERBTYPE_SMALLROOM,
- REVERBTYPE_MEDIUMROOM,
- REVERBTYPE_LARGEROOM,
- REVERBTYPE_SMALLHALL,
- REVERBTYPE_MEDIUMHALL,
- REVERBTYPE_LARGEHALL,
- NUM_REVERBTYPES
+enum
+{
+ REVERBTYPE_SMALLROOM,
+ REVERBTYPE_MEDIUMROOM,
+ REVERBTYPE_LARGEROOM,
+ REVERBTYPE_SMALLHALL,
+ REVERBTYPE_MEDIUMHALL,
+ REVERBTYPE_LARGEHALL,
+ NUM_REVERBTYPES
};
-enum {
- SRCMODE_NEAREST,
- SRCMODE_LINEAR,
- SRCMODE_SPLINE,
- SRCMODE_POLYPHASE,
- NUM_SRC_MODES
+enum
+{
+ SRCMODE_NEAREST,
+ SRCMODE_LINEAR,
+ SRCMODE_SPLINE,
+ SRCMODE_POLYPHASE,
+ NUM_SRC_MODES
};
/* Sample Struct */
typedef struct _MODINSTRUMENT
{
- UINT nLength,nLoopStart,nLoopEnd;
- UINT nSustainStart, nSustainEnd;
- signed char *pSample;
- UINT nC4Speed;
- WORD nPan;
- WORD nVolume;
- WORD nGlobalVol;
- WORD uFlags;
- signed char RelativeTone;
- signed char nFineTune;
- BYTE nVibType;
- BYTE nVibSweep;
- BYTE nVibDepth;
- BYTE nVibRate;
- CHAR name[22];
+ UINT nLength, nLoopStart, nLoopEnd;
+ UINT nSustainStart, nSustainEnd;
+ signed char *pSample;
+ UINT nC4Speed;
+ WORD nPan;
+ WORD nVolume;
+ WORD nGlobalVol;
+ WORD uFlags;
+ signed char RelativeTone;
+ signed char nFineTune;
+ BYTE nVibType;
+ BYTE nVibSweep;
+ BYTE nVibDepth;
+ BYTE nVibRate;
+ CHAR name[22];
} MODINSTRUMENT;
/* Instrument Struct */
typedef struct _INSTRUMENTHEADER
{
- UINT nFadeOut;
- DWORD dwFlags;
- WORD nGlobalVol;
- WORD nPan;
- WORD VolPoints[MAX_ENVPOINTS];
- WORD PanPoints[MAX_ENVPOINTS];
- WORD PitchPoints[MAX_ENVPOINTS];
- BYTE VolEnv[MAX_ENVPOINTS];
- BYTE PanEnv[MAX_ENVPOINTS];
- BYTE PitchEnv[MAX_ENVPOINTS];
- BYTE Keyboard[128];
- BYTE NoteMap[128];
-
- BYTE nVolEnv;
- BYTE nPanEnv;
- BYTE nPitchEnv;
- BYTE nVolLoopStart;
- BYTE nVolLoopEnd;
- BYTE nVolSustainBegin;
- BYTE nVolSustainEnd;
- BYTE nPanLoopStart;
- BYTE nPanLoopEnd;
- BYTE nPanSustainBegin;
- BYTE nPanSustainEnd;
- BYTE nPitchLoopStart;
- BYTE nPitchLoopEnd;
- BYTE nPitchSustainBegin;
- BYTE nPitchSustainEnd;
- BYTE nNNA;
- BYTE nDCT;
- BYTE nDNA;
- BYTE nPanSwing;
- BYTE nVolSwing;
- BYTE nIFC;
- BYTE nIFR;
- WORD wMidiBank;
- BYTE nMidiProgram;
- BYTE nMidiChannel;
- BYTE nMidiDrumKey;
- signed char nPPS;
- unsigned char nPPC;
- CHAR name[32];
- CHAR filename[12];
+ UINT nFadeOut;
+ DWORD dwFlags;
+ WORD nGlobalVol;
+ WORD nPan;
+ WORD VolPoints[MAX_ENVPOINTS];
+ WORD PanPoints[MAX_ENVPOINTS];
+ WORD PitchPoints[MAX_ENVPOINTS];
+ BYTE VolEnv[MAX_ENVPOINTS];
+ BYTE PanEnv[MAX_ENVPOINTS];
+ BYTE PitchEnv[MAX_ENVPOINTS];
+ BYTE Keyboard[128];
+ BYTE NoteMap[128];
+
+ BYTE nVolEnv;
+ BYTE nPanEnv;
+ BYTE nPitchEnv;
+ BYTE nVolLoopStart;
+ BYTE nVolLoopEnd;
+ BYTE nVolSustainBegin;
+ BYTE nVolSustainEnd;
+ BYTE nPanLoopStart;
+ BYTE nPanLoopEnd;
+ BYTE nPanSustainBegin;
+ BYTE nPanSustainEnd;
+ BYTE nPitchLoopStart;
+ BYTE nPitchLoopEnd;
+ BYTE nPitchSustainBegin;
+ BYTE nPitchSustainEnd;
+ BYTE nNNA;
+ BYTE nDCT;
+ BYTE nDNA;
+ BYTE nPanSwing;
+ BYTE nVolSwing;
+ BYTE nIFC;
+ BYTE nIFR;
+ WORD wMidiBank;
+ BYTE nMidiProgram;
+ BYTE nMidiChannel;
+ BYTE nMidiDrumKey;
+ signed char nPPS;
+ unsigned char nPPC;
+ CHAR name[32];
+ CHAR filename[12];
} INSTRUMENTHEADER;
/* Channel Struct */
typedef struct _MODCHANNEL
{
- /* First 32-bytes: Most used mixing information: don't change it */
- signed char * pCurrentSample;
- DWORD nPos;
- DWORD nPosLo; /* actually 16-bit */
- LONG nInc; /* 16.16 */
- LONG nRightVol;
- LONG nLeftVol;
- LONG nRightRamp;
- LONG nLeftRamp;
- /* 2nd cache line */
- DWORD nLength;
- DWORD dwFlags;
- DWORD nLoopStart;
- DWORD nLoopEnd;
- LONG nRampRightVol;
- LONG nRampLeftVol;
- LONG nFilter_Y1, nFilter_Y2, nFilter_Y3, nFilter_Y4;
- LONG nFilter_A0, nFilter_B0, nFilter_B1;
- LONG nROfs, nLOfs;
- LONG nRampLength;
- /* Information not used in the mixer */
- signed char * pSample;
- LONG nNewRightVol, nNewLeftVol;
- LONG nRealVolume, nRealPan;
- LONG nVolume, nPan, nFadeOutVol;
- LONG nPeriod, nC4Speed, nPortamentoDest;
- INSTRUMENTHEADER *pHeader;
- MODINSTRUMENT *pInstrument;
- DWORD nVolEnvPosition, nPanEnvPosition, nPitchEnvPosition;
- DWORD nMasterChn, nVUMeter;
- LONG nGlobalVol, nInsVol;
- LONG nFineTune, nTranspose;
- LONG nPortamentoSlide, nAutoVibDepth;
- UINT nAutoVibPos, nVibratoPos, nTremoloPos, nPanbrelloPos;
- /* 16-bit members */
- signed short nVolSwing, nPanSwing;
- /* 8-bit members */
- BYTE nNote, nNNA;
- BYTE nNewNote, nNewIns, nCommand, nArpeggio;
- BYTE nOldVolumeSlide, nOldFineVolUpDown;
- BYTE nOldPortaUpDown, nOldFinePortaUpDown;
- BYTE nOldPanSlide, nOldChnVolSlide;
- BYTE nVibratoType, nVibratoSpeed, nVibratoDepth;
- BYTE nTremoloType, nTremoloSpeed, nTremoloDepth;
- BYTE nPanbrelloType, nPanbrelloSpeed, nPanbrelloDepth;
- BYTE nOldCmdEx, nOldVolParam, nOldTempo;
- BYTE nOldOffset, nOldHiOffset;
- BYTE nCutOff, nResonance;
- BYTE nRetrigCount, nRetrigParam;
- BYTE nTremorCount, nTremorParam;
- BYTE nPatternLoop, nPatternLoopCount;
- BYTE nRowNote, nRowInstr;
- BYTE nRowVolCmd, nRowVolume;
- BYTE nRowCommand, nRowParam;
- BYTE nLeftVU, nRightVU;
- BYTE nActiveMacro, nPadding;
+ /* First 32-bytes: Most used mixing information: don't change it */
+ signed char *pCurrentSample;
+ DWORD nPos;
+ DWORD nPosLo; /* actually 16-bit */
+ LONG nInc; /* 16.16 */
+ LONG nRightVol;
+ LONG nLeftVol;
+ LONG nRightRamp;
+ LONG nLeftRamp;
+ /* 2nd cache line */
+ DWORD nLength;
+ DWORD dwFlags;
+ DWORD nLoopStart;
+ DWORD nLoopEnd;
+ LONG nRampRightVol;
+ LONG nRampLeftVol;
+ LONG nFilter_Y1, nFilter_Y2, nFilter_Y3, nFilter_Y4;
+ LONG nFilter_A0, nFilter_B0, nFilter_B1;
+ LONG nROfs, nLOfs;
+ LONG nRampLength;
+ /* Information not used in the mixer */
+ signed char *pSample;
+ LONG nNewRightVol, nNewLeftVol;
+ LONG nRealVolume, nRealPan;
+ LONG nVolume, nPan, nFadeOutVol;
+ LONG nPeriod, nC4Speed, nPortamentoDest;
+ INSTRUMENTHEADER *pHeader;
+ MODINSTRUMENT *pInstrument;
+ DWORD nVolEnvPosition, nPanEnvPosition, nPitchEnvPosition;
+ DWORD nMasterChn, nVUMeter;
+ LONG nGlobalVol, nInsVol;
+ LONG nFineTune, nTranspose;
+ LONG nPortamentoSlide, nAutoVibDepth;
+ UINT nAutoVibPos, nVibratoPos, nTremoloPos, nPanbrelloPos;
+ /* 16-bit members */
+ signed short nVolSwing, nPanSwing;
+ /* 8-bit members */
+ BYTE nNote, nNNA;
+ BYTE nNewNote, nNewIns, nCommand, nArpeggio;
+ BYTE nOldVolumeSlide, nOldFineVolUpDown;
+ BYTE nOldPortaUpDown, nOldFinePortaUpDown;
+ BYTE nOldPanSlide, nOldChnVolSlide;
+ BYTE nVibratoType, nVibratoSpeed, nVibratoDepth;
+ BYTE nTremoloType, nTremoloSpeed, nTremoloDepth;
+ BYTE nPanbrelloType, nPanbrelloSpeed, nPanbrelloDepth;
+ BYTE nOldCmdEx, nOldVolParam, nOldTempo;
+ BYTE nOldOffset, nOldHiOffset;
+ BYTE nCutOff, nResonance;
+ BYTE nRetrigCount, nRetrigParam;
+ BYTE nTremorCount, nTremorParam;
+ BYTE nPatternLoop, nPatternLoopCount;
+ BYTE nRowNote, nRowInstr;
+ BYTE nRowVolCmd, nRowVolume;
+ BYTE nRowCommand, nRowParam;
+ BYTE nLeftVU, nRightVU;
+ BYTE nActiveMacro, nPadding;
} MODCHANNEL;
typedef struct _MODCHANNELSETTINGS
{
- UINT nPan;
- UINT nVolume;
- DWORD dwFlags;
- UINT nMixPlugin;
- char szName[MAX_CHANNELNAME]; /* changed from CHAR */
+ UINT nPan;
+ UINT nVolume;
+ DWORD dwFlags;
+ UINT nMixPlugin;
+ char szName[MAX_CHANNELNAME]; /* changed from CHAR */
} MODCHANNELSETTINGS;
typedef struct _MODCOMMAND
{
- BYTE note;
- BYTE instr;
- BYTE volcmd;
- BYTE command;
- BYTE vol;
- BYTE param;
+ BYTE note;
+ BYTE instr;
+ BYTE volcmd;
+ BYTE command;
+ BYTE vol;
+ BYTE param;
} MODCOMMAND, *LPMODCOMMAND;
/*////////////////////////////////////////////////////////////////// */
class IMixPlugin
{
public:
- virtual int AddRef() = 0;
- virtual int Release() = 0;
- virtual void SaveAllParameters() = 0;
- virtual void RestoreAllParameters() = 0;
- virtual void Process(float *pOutL, float *pOutR, unsigned long nSamples) = 0;
- virtual void Init(unsigned long nFreq, int bReset) = 0;
- virtual void MidiSend(DWORD dwMidiCode) = 0;
- virtual void MidiCommand(UINT nMidiCh, UINT nMidiProg, UINT note, UINT vol) = 0;
+ virtual int AddRef () = 0;
+ virtual int Release () = 0;
+ virtual void SaveAllParameters () = 0;
+ virtual void RestoreAllParameters () = 0;
+ virtual void Process (float *pOutL, float *pOutR, unsigned long nSamples) = 0;
+ virtual void Init (unsigned long nFreq, int bReset) = 0;
+ virtual void MidiSend (DWORD dwMidiCode) = 0;
+ virtual void MidiCommand (UINT nMidiCh, UINT nMidiProg, UINT note, UINT vol) =
+ 0;
};
typedef struct _SNDMIXPLUGINSTATE
{
- DWORD dwFlags; /* MIXPLUG_XXXX */
- LONG nVolDecayL, nVolDecayR; /* Buffer click removal */
- int *pMixBuffer; /* Stereo effect send buffer */
- float *pOutBufferL; /* Temp storage for int -> float conversion */
- float *pOutBufferR;
+ DWORD dwFlags; /* MIXPLUG_XXXX */
+ LONG nVolDecayL, nVolDecayR; /* Buffer click removal */
+ int *pMixBuffer; /* Stereo effect send buffer */
+ float *pOutBufferL; /* Temp storage for int -> float conversion */
+ float *pOutBufferR;
} SNDMIXPLUGINSTATE, *PSNDMIXPLUGINSTATE;
typedef struct _SNDMIXPLUGININFO
{
- DWORD dwPluginId1;
- DWORD dwPluginId2;
- DWORD dwInputRouting; /* MIXPLUG_INPUTF_XXXX */
- DWORD dwOutputRouting; /* 0=mix 0x80+=fx */
- DWORD dwReserved[4]; /* Reserved for routing info */
- CHAR szName[32];
- CHAR szLibraryName[64]; /* original DLL name */
-} SNDMIXPLUGININFO, *PSNDMIXPLUGININFO; /* Size should be 128 */
+ DWORD dwPluginId1;
+ DWORD dwPluginId2;
+ DWORD dwInputRouting; /* MIXPLUG_INPUTF_XXXX */
+ DWORD dwOutputRouting; /* 0=mix 0x80+=fx */
+ DWORD dwReserved[4]; /* Reserved for routing info */
+ CHAR szName[32];
+ CHAR szLibraryName[64]; /* original DLL name */
+} SNDMIXPLUGININFO, *PSNDMIXPLUGININFO; /* Size should be 128 */
typedef struct _SNDMIXPLUGIN
{
- IMixPlugin *pMixPlugin;
- PSNDMIXPLUGINSTATE pMixState;
- ULONG nPluginDataSize;
- PVOID pPluginData;
- SNDMIXPLUGININFO Info;
+ IMixPlugin *pMixPlugin;
+ PSNDMIXPLUGINSTATE pMixState;
+ ULONG nPluginDataSize;
+ PVOID pPluginData;
+ SNDMIXPLUGININFO Info;
} SNDMIXPLUGIN, *PSNDMIXPLUGIN;
-typedef BOOL (*PMIXPLUGINCREATEPROC)(PSNDMIXPLUGIN);
+typedef BOOL (*PMIXPLUGINCREATEPROC) (PSNDMIXPLUGIN);
/*////////////////////////////////////////////////////////////////// */
-enum {
- MIDIOUT_START=0,
- MIDIOUT_STOP,
- MIDIOUT_TICK,
- MIDIOUT_NOTEON,
- MIDIOUT_NOTEOFF,
- MIDIOUT_VOLUME,
- MIDIOUT_PAN,
- MIDIOUT_BANKSEL,
- MIDIOUT_PROGRAM
+enum
+{
+ MIDIOUT_START = 0,
+ MIDIOUT_STOP,
+ MIDIOUT_TICK,
+ MIDIOUT_NOTEON,
+ MIDIOUT_NOTEOFF,
+ MIDIOUT_VOLUME,
+ MIDIOUT_PAN,
+ MIDIOUT_BANKSEL,
+ MIDIOUT_PROGRAM
};
typedef struct MODMIDICFG
{
- char szMidiGlb[9*32]; /* changed from CHAR */
- char szMidiSFXExt[16*32]; /* changed from CHAR */
- char szMidiZXXExt[128*32]; /* changed from CHAR */
+ char szMidiGlb[9 * 32]; /* changed from CHAR */
+ char szMidiSFXExt[16 * 32]; /* changed from CHAR */
+ char szMidiZXXExt[128 * 32]; /* changed from CHAR */
} MODMIDICFG, *LPMODMIDICFG;
-typedef VOID (* LPSNDMIXHOOKPROC)(int *, unsigned long, unsigned long); /* buffer, samples, channels */
+typedef VOID (*LPSNDMIXHOOKPROC) (int *, unsigned long, unsigned long); /* buffer, samples, channels */
class CSoundFile
/*============== */
{
-public: /* Static Members */
- static UINT m_nXBassDepth, m_nXBassRange;
- static UINT m_nReverbDepth, m_nReverbDelay, gnReverbType;
- static UINT m_nProLogicDepth, m_nProLogicDelay;
- static UINT m_nStereoSeparation;
- static UINT m_nMaxMixChannels;
- static LONG m_nStreamVolume;
- static DWORD gdwSysInfo, gdwSoundSetup, gdwMixingFreq, gnBitsPerSample, gnChannels;
- static UINT gnAGC, gnVolumeRampSamples, gnVUMeter, gnCPUUsage;
- static LPSNDMIXHOOKPROC gpSndMixHook;
- static PMIXPLUGINCREATEPROC gpMixPluginCreateProc;
-
-public: /* for Editing */
- MODCHANNEL Chn[MAX_CHANNELS]; /* Channels */
- UINT ChnMix[MAX_CHANNELS]; /* Channels to be mixed */
- MODINSTRUMENT Ins[MAX_SAMPLES]; /* Instruments */
- INSTRUMENTHEADER *Headers[MAX_INSTRUMENTS]; /* Instrument Headers */
- MODCHANNELSETTINGS ChnSettings[MAX_BASECHANNELS]; /* Channels settings */
- MODCOMMAND *Patterns[MAX_PATTERNS]; /* Patterns */
- WORD PatternSize[MAX_PATTERNS]; /* Patterns Lengths */
- BYTE Order[MAX_ORDERS]; /* Pattern Orders */
- MODMIDICFG m_MidiCfg; /* Midi macro config table */
- SNDMIXPLUGIN m_MixPlugins[MAX_MIXPLUGINS]; /* Mix plugins */
- UINT m_nDefaultSpeed, m_nDefaultTempo, m_nDefaultGlobalVolume;
- DWORD m_dwSongFlags; /* Song flags SONG_XXXX */
- UINT m_nChannels, m_nMixChannels, m_nMixStat, m_nBufferCount;
- UINT m_nType, m_nSamples, m_nInstruments;
- UINT m_nTickCount, m_nTotalCount, m_nPatternDelay, m_nFrameDelay;
- UINT m_nMusicSpeed, m_nMusicTempo;
- UINT m_nNextRow, m_nRow;
- UINT m_nPattern,m_nCurrentPattern,m_nNextPattern,m_nRestartPos;
- UINT m_nMasterVolume, m_nGlobalVolume, m_nSongPreAmp;
- UINT m_nFreqFactor, m_nTempoFactor, m_nOldGlbVolSlide;
- LONG m_nMinPeriod, m_nMaxPeriod, m_nRepeatCount, m_nInitialRepeatCount;
- DWORD m_nGlobalFadeSamples, m_nGlobalFadeMaxSamples;
- UINT m_nMaxOrderPosition;
- UINT m_nPatternNames;
- LPSTR m_lpszSongComments, m_lpszPatternNames;
- char m_szNames[MAX_INSTRUMENTS][32]; /* changed from CHAR */
- CHAR CompressionTable[16];
+public: /* Static Members */
+ static UINT m_nXBassDepth, m_nXBassRange;
+ static UINT m_nReverbDepth, m_nReverbDelay, gnReverbType;
+ static UINT m_nProLogicDepth, m_nProLogicDelay;
+ static UINT m_nStereoSeparation;
+ static UINT m_nMaxMixChannels;
+ static LONG m_nStreamVolume;
+ static DWORD gdwSysInfo, gdwSoundSetup, gdwMixingFreq, gnBitsPerSample,
+ gnChannels;
+ static UINT gnAGC, gnVolumeRampSamples, gnVUMeter, gnCPUUsage;
+ static LPSNDMIXHOOKPROC gpSndMixHook;
+ static PMIXPLUGINCREATEPROC gpMixPluginCreateProc;
+
+public: /* for Editing */
+ MODCHANNEL Chn[MAX_CHANNELS]; /* Channels */
+ UINT ChnMix[MAX_CHANNELS]; /* Channels to be mixed */
+ MODINSTRUMENT Ins[MAX_SAMPLES]; /* Instruments */
+ INSTRUMENTHEADER *Headers[MAX_INSTRUMENTS]; /* Instrument Headers */
+ MODCHANNELSETTINGS ChnSettings[MAX_BASECHANNELS]; /* Channels settings */
+ MODCOMMAND *Patterns[MAX_PATTERNS]; /* Patterns */
+ WORD PatternSize[MAX_PATTERNS]; /* Patterns Lengths */
+ BYTE Order[MAX_ORDERS]; /* Pattern Orders */
+ MODMIDICFG m_MidiCfg; /* Midi macro config table */
+ SNDMIXPLUGIN m_MixPlugins[MAX_MIXPLUGINS]; /* Mix plugins */
+ UINT m_nDefaultSpeed, m_nDefaultTempo, m_nDefaultGlobalVolume;
+ DWORD m_dwSongFlags; /* Song flags SONG_XXXX */
+ UINT m_nChannels, m_nMixChannels, m_nMixStat, m_nBufferCount;
+ UINT m_nType, m_nSamples, m_nInstruments;
+ UINT m_nTickCount, m_nTotalCount, m_nPatternDelay, m_nFrameDelay;
+ UINT m_nMusicSpeed, m_nMusicTempo;
+ UINT m_nNextRow, m_nRow;
+ UINT m_nPattern, m_nCurrentPattern, m_nNextPattern, m_nRestartPos;
+ UINT m_nMasterVolume, m_nGlobalVolume, m_nSongPreAmp;
+ UINT m_nFreqFactor, m_nTempoFactor, m_nOldGlbVolSlide;
+ LONG m_nMinPeriod, m_nMaxPeriod, m_nRepeatCount, m_nInitialRepeatCount;
+ DWORD m_nGlobalFadeSamples, m_nGlobalFadeMaxSamples;
+ UINT m_nMaxOrderPosition;
+ UINT m_nPatternNames;
+ LPSTR m_lpszSongComments, m_lpszPatternNames;
+ char m_szNames[MAX_INSTRUMENTS][32]; /* changed from CHAR */
+ CHAR CompressionTable[16];
public:
- CSoundFile();
- ~CSoundFile();
+ CSoundFile ();
+ ~CSoundFile ();
public:
- BOOL Create(LPCBYTE lpStream, DWORD dwMemLength=0);
- BOOL Destroy();
- UINT GetType() const { return m_nType; }
- UINT GetNumChannels() const;
- UINT GetLogicalChannels() const { return m_nChannels; }
- BOOL SetMasterVolume(UINT vol, BOOL bAdjustAGC=FALSE);
- UINT GetMasterVolume() const { return m_nMasterVolume; }
- UINT GetNumPatterns() const;
- UINT GetNumInstruments() const;
- UINT GetNumSamples() const { return m_nSamples; }
- UINT GetCurrentPos() const;
- UINT GetCurrentPattern() const { return m_nPattern; }
- UINT GetCurrentOrder() const { return m_nCurrentPattern; }
- UINT GetSongComments(LPSTR s, UINT cbsize, UINT linesize=32);
- UINT GetRawSongComments(LPSTR s, UINT cbsize, UINT linesize=32);
- UINT GetMaxPosition() const;
- void SetCurrentPos(UINT nPos);
- void SetCurrentOrder(UINT nOrder);
- void GetTitle(LPSTR s) const { lstrcpyn(s,m_szNames[0],32); }
- LPCSTR GetTitle() const { return m_szNames[0]; }
- UINT GetSampleName(UINT nSample,LPSTR s=NULL) const;
- UINT GetInstrumentName(UINT nInstr,LPSTR s=NULL) const;
- UINT GetMusicSpeed() const { return m_nMusicSpeed; }
- UINT GetMusicTempo() const { return m_nMusicTempo; }
- DWORD GetLength(BOOL bAdjust, BOOL bTotal=FALSE);
- DWORD GetSongTime() { return GetLength(FALSE, TRUE); }
- void SetRepeatCount(int n) { m_nRepeatCount = n; m_nInitialRepeatCount = n; }
- int GetRepeatCount() const { return m_nRepeatCount; }
- BOOL IsPaused() const { return (m_dwSongFlags & SONG_PAUSED) ? TRUE : FALSE; }
- void LoopPattern(int nPat, int nRow=0);
- void CheckCPUUsage(UINT nCPU);
- BOOL SetPatternName(UINT nPat, LPCSTR lpszName);
- BOOL GetPatternName(UINT nPat, LPSTR lpszName, UINT cbSize=MAX_PATTERNNAME) const;
- /* Module Loaders */
- BOOL ReadXM(LPCBYTE lpStream, DWORD dwMemLength);
- BOOL ReadS3M(LPCBYTE lpStream, DWORD dwMemLength);
- BOOL ReadMod(LPCBYTE lpStream, DWORD dwMemLength);
- BOOL ReadMed(LPCBYTE lpStream, DWORD dwMemLength);
- BOOL ReadMTM(LPCBYTE lpStream, DWORD dwMemLength);
- BOOL ReadSTM(LPCBYTE lpStream, DWORD dwMemLength);
- BOOL ReadIT(LPCBYTE lpStream, DWORD dwMemLength);
- BOOL Read669(LPCBYTE lpStream, DWORD dwMemLength);
- BOOL ReadUlt(LPCBYTE lpStream, DWORD dwMemLength);
- BOOL ReadWav(LPCBYTE lpStream, DWORD dwMemLength);
- BOOL ReadDSM(LPCBYTE lpStream, DWORD dwMemLength);
- BOOL ReadFAR(LPCBYTE lpStream, DWORD dwMemLength);
- BOOL ReadAMS(LPCBYTE lpStream, DWORD dwMemLength);
- BOOL ReadAMS2(LPCBYTE lpStream, DWORD dwMemLength);
- BOOL ReadMDL(LPCBYTE lpStream, DWORD dwMemLength);
- BOOL ReadOKT(LPCBYTE lpStream, DWORD dwMemLength);
- BOOL ReadDMF(LPCBYTE lpStream, DWORD dwMemLength);
- BOOL ReadPTM(LPCBYTE lpStream, DWORD dwMemLength);
- BOOL ReadDBM(LPCBYTE lpStream, DWORD dwMemLength);
- BOOL ReadAMF(LPCBYTE lpStream, DWORD dwMemLength);
- BOOL ReadMT2(LPCBYTE lpStream, DWORD dwMemLength);
- BOOL ReadPSM(LPCBYTE lpStream, DWORD dwMemLength);
- BOOL ReadJ2B(LPCBYTE lpStream, DWORD dwMemLength);
- BOOL ReadUMX(LPCBYTE lpStream, DWORD dwMemLength);
- /* Save Functions */
+ BOOL Create (LPCBYTE lpStream, DWORD dwMemLength = 0);
+ BOOL Destroy ();
+ UINT GetType () const
+ {
+ return m_nType;
+ }
+ UINT GetNumChannels () const;
+ UINT GetLogicalChannels () const
+ {
+ return m_nChannels;
+ }
+ BOOL SetMasterVolume (UINT vol, BOOL bAdjustAGC = FALSE);
+ UINT GetMasterVolume () const
+ {
+ return m_nMasterVolume;
+ }
+ UINT GetNumPatterns () const;
+ UINT GetNumInstruments () const;
+ UINT GetNumSamples () const
+ {
+ return m_nSamples;
+ }
+ UINT GetCurrentPos () const;
+ UINT GetCurrentPattern () const
+ {
+ return m_nPattern;
+ }
+ UINT GetCurrentOrder () const
+ {
+ return m_nCurrentPattern;
+ }
+ UINT GetSongComments (LPSTR s, UINT cbsize, UINT linesize = 32);
+ UINT GetRawSongComments (LPSTR s, UINT cbsize, UINT linesize = 32);
+ UINT GetMaxPosition () const;
+ void SetCurrentPos (UINT nPos);
+ void SetCurrentOrder (UINT nOrder);
+ void GetTitle (LPSTR s) const
+ {
+ lstrcpyn (s, m_szNames[0], 32);
+ }
+ LPCSTR GetTitle () const
+ {
+ return m_szNames[0];
+ }
+ UINT GetSampleName (UINT nSample, LPSTR s = NULL) const;
+ UINT GetInstrumentName (UINT nInstr, LPSTR s = NULL) const;
+ UINT GetMusicSpeed () const
+ {
+ return m_nMusicSpeed;
+ }
+ UINT GetMusicTempo () const
+ {
+ return m_nMusicTempo;
+ }
+ DWORD GetLength (BOOL bAdjust, BOOL bTotal = FALSE);
+ DWORD GetSongTime ()
+ {
+ return GetLength (FALSE, TRUE);
+ }
+ void SetRepeatCount (int n)
+ {
+ m_nRepeatCount = n;
+ m_nInitialRepeatCount = n;
+ }
+ int GetRepeatCount () const
+ {
+ return m_nRepeatCount;
+ }
+ BOOL IsPaused () const
+ {
+ return (m_dwSongFlags & SONG_PAUSED) ? TRUE : FALSE;
+ }
+ void LoopPattern (int nPat, int nRow = 0);
+ void CheckCPUUsage (UINT nCPU);
+ BOOL SetPatternName (UINT nPat, LPCSTR lpszName);
+ BOOL GetPatternName (UINT nPat, LPSTR lpszName, UINT cbSize =
+ MAX_PATTERNNAME) const;
+ /* Module Loaders */
+ BOOL ReadXM (LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadS3M (LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadMod (LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadMed (LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadMTM (LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadSTM (LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadIT (LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL Read669 (LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadUlt (LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadWav (LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadDSM (LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadFAR (LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadAMS (LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadAMS2 (LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadMDL (LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadOKT (LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadDMF (LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadPTM (LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadDBM (LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadAMF (LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadMT2 (LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadPSM (LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadJ2B (LPCBYTE lpStream, DWORD dwMemLength);
+ BOOL ReadUMX (LPCBYTE lpStream, DWORD dwMemLength);
+
+ /* Save Functions */
#ifndef MODPLUG_NO_FILESAVE
- UINT WriteSample(FILE *f, MODINSTRUMENT *pins, UINT nFlags, UINT nMaxLen=0);
- BOOL SaveXM(LPCSTR lpszFileName, UINT nPacking=0);
- BOOL SaveS3M(LPCSTR lpszFileName, UINT nPacking=0);
- BOOL SaveMod(LPCSTR lpszFileName, UINT nPacking=0);
- BOOL SaveIT(LPCSTR lpszFileName, UINT nPacking=0);
+ UINT WriteSample (FILE * f, MODINSTRUMENT * pins, UINT nFlags, UINT nMaxLen =
+ 0);
+ BOOL SaveXM (LPCSTR lpszFileName, UINT nPacking = 0);
+ BOOL SaveS3M (LPCSTR lpszFileName, UINT nPacking = 0);
+ BOOL SaveMod (LPCSTR lpszFileName, UINT nPacking = 0);
+ BOOL SaveIT (LPCSTR lpszFileName, UINT nPacking = 0);
#endif /* MODPLUG_NO_FILESAVE */
- /* MOD Convert function */
- UINT GetBestSaveFormat() const;
- UINT GetSaveFormats() const;
- void ConvertModCommand(MODCOMMAND *) const;
- void S3MConvert(MODCOMMAND *m, BOOL bIT) const;
- void S3MSaveConvert(UINT *pcmd, UINT *pprm, BOOL bIT) const;
- WORD ModSaveCommand(const MODCOMMAND *m, BOOL bXM) const;
+ /* MOD Convert function */
+ UINT GetBestSaveFormat () const;
+ UINT GetSaveFormats () const;
+ void ConvertModCommand (MODCOMMAND *) const;
+ void S3MConvert (MODCOMMAND * m, BOOL bIT) const;
+ void S3MSaveConvert (UINT * pcmd, UINT * pprm, BOOL bIT) const;
+ WORD ModSaveCommand (const MODCOMMAND * m, BOOL bXM) const;
public:
- /* Real-time sound functions */
- VOID ResetChannels();
-
- UINT Read(LPVOID lpBuffer, UINT cbBuffer);
- UINT CreateStereoMix(int count);
- BOOL FadeSong(UINT msec);
- BOOL GlobalFadeSong(UINT msec);
- UINT GetTotalTickCount() const { return m_nTotalCount; }
- VOID ResetTotalTickCount() { m_nTotalCount = 0; }
+ /* Real-time sound functions */
+ VOID ResetChannels ();
+
+ UINT Read (LPVOID lpBuffer, UINT cbBuffer);
+ UINT CreateStereoMix (int count);
+ BOOL FadeSong (UINT msec);
+ BOOL GlobalFadeSong (UINT msec);
+ UINT GetTotalTickCount () const
+ {
+ return m_nTotalCount;
+ }
+ VOID ResetTotalTickCount ()
+ {
+ m_nTotalCount = 0;
+ }
public:
- /* Mixer Config */
- static BOOL InitPlayer(BOOL bReset=FALSE);
- static BOOL SetWaveConfig(UINT nRate,UINT nBits,UINT nChannels,BOOL bMMX=FALSE);
- static BOOL SetResamplingMode(UINT nMode); /* SRCMODE_XXXX */
- static BOOL IsStereo() { return (gnChannels > 1) ? TRUE : FALSE; }
- static DWORD GetSampleRate() { return gdwMixingFreq; }
- static DWORD GetBitsPerSample() { return gnBitsPerSample; }
- static DWORD InitSysInfo();
- static DWORD GetSysInfo() { return gdwSysInfo; }
- /* AGC */
- static BOOL GetAGC() { return (gdwSoundSetup & SNDMIX_AGC) ? TRUE : FALSE; }
- static void SetAGC(BOOL b);
- static void ResetAGC();
- static void ProcessAGC(int count);
-
- /*GCCFIX -- added these functions back in! */
- static BOOL SetWaveConfigEx(BOOL bSurround,BOOL bNoOverSampling,BOOL bReverb,BOOL hqido,BOOL bMegaBass,BOOL bNR,BOOL bEQ);
- /* DSP Effects */
- static void InitializeDSP(BOOL bReset);
- static void ProcessStereoDSP(int count);
- static void ProcessMonoDSP(int count);
- /* [Reverb level 0(quiet)-100(loud)], [delay in ms, usually 40-200ms] */
- static BOOL SetReverbParameters(UINT nDepth, UINT nDelay);
- /* [XBass level 0(quiet)-100(loud)], [cutoff in Hz 10-100] */
- static BOOL SetXBassParameters(UINT nDepth, UINT nRange);
- /* [Surround level 0(quiet)-100(heavy)] [delay in ms, usually 5-40ms] */
- static BOOL SetSurroundParameters(UINT nDepth, UINT nDelay);
+ /* Mixer Config */
+ static BOOL InitPlayer (BOOL bReset = FALSE);
+ static BOOL SetWaveConfig (UINT nRate, UINT nBits, UINT nChannels, BOOL bMMX =
+ FALSE);
+ static BOOL SetResamplingMode (UINT nMode); /* SRCMODE_XXXX */
+ static BOOL IsStereo ()
+ {
+ return (gnChannels > 1) ? TRUE : FALSE;
+ }
+ static DWORD GetSampleRate ()
+ {
+ return gdwMixingFreq;
+ }
+ static DWORD GetBitsPerSample ()
+ {
+ return gnBitsPerSample;
+ }
+ static DWORD InitSysInfo ();
+ static DWORD GetSysInfo ()
+ {
+ return gdwSysInfo;
+ }
+ /* AGC */
+ static BOOL GetAGC ()
+ {
+ return (gdwSoundSetup & SNDMIX_AGC) ? TRUE : FALSE;
+ }
+ static void SetAGC (BOOL b);
+ static void ResetAGC ();
+ static void ProcessAGC (int count);
+
+ /*GCCFIX -- added these functions back in! */
+ static BOOL SetWaveConfigEx (BOOL bSurround, BOOL bNoOverSampling,
+ BOOL bReverb, BOOL hqido, BOOL bMegaBass, BOOL bNR, BOOL bEQ);
+ /* DSP Effects */
+ static void InitializeDSP (BOOL bReset);
+ static void ProcessStereoDSP (int count);
+ static void ProcessMonoDSP (int count);
+
+ /* [Reverb level 0(quiet)-100(loud)], [delay in ms, usually 40-200ms] */
+ static BOOL SetReverbParameters (UINT nDepth, UINT nDelay);
+
+ /* [XBass level 0(quiet)-100(loud)], [cutoff in Hz 10-100] */
+ static BOOL SetXBassParameters (UINT nDepth, UINT nRange);
+
+ /* [Surround level 0(quiet)-100(heavy)] [delay in ms, usually 5-40ms] */
+ static BOOL SetSurroundParameters (UINT nDepth, UINT nDelay);
+
public:
- BOOL ReadNote();
- BOOL ProcessRow();
- BOOL ProcessEffects();
- UINT GetNNAChannel(UINT nChn) const;
- void CheckNNA(UINT nChn, UINT instr, int note, BOOL bForceCut);
- void NoteChange(UINT nChn, int note, BOOL bPorta=FALSE, BOOL bResetEnv=TRUE);
- void InstrumentChange(MODCHANNEL *pChn, UINT instr, BOOL bPorta=FALSE,BOOL bUpdVol=TRUE,BOOL bResetEnv=TRUE);
- /* Channel Effects */
- void PortamentoUp(MODCHANNEL *pChn, UINT param);
- void PortamentoDown(MODCHANNEL *pChn, UINT param);
- void FinePortamentoUp(MODCHANNEL *pChn, UINT param);
- void FinePortamentoDown(MODCHANNEL *pChn, UINT param);
- void ExtraFinePortamentoUp(MODCHANNEL *pChn, UINT param);
- void ExtraFinePortamentoDown(MODCHANNEL *pChn, UINT param);
- void TonePortamento(MODCHANNEL *pChn, UINT param);
- void Vibrato(MODCHANNEL *pChn, UINT param);
- void FineVibrato(MODCHANNEL *pChn, UINT param);
- void VolumeSlide(MODCHANNEL *pChn, UINT param);
- void PanningSlide(MODCHANNEL *pChn, UINT param);
- void ChannelVolSlide(MODCHANNEL *pChn, UINT param);
- void FineVolumeUp(MODCHANNEL *pChn, UINT param);
- void FineVolumeDown(MODCHANNEL *pChn, UINT param);
- void Tremolo(MODCHANNEL *pChn, UINT param);
- void Panbrello(MODCHANNEL *pChn, UINT param);
- void RetrigNote(UINT nChn, UINT param);
- void NoteCut(UINT nChn, UINT nTick);
- void KeyOff(UINT nChn);
- int PatternLoop(MODCHANNEL *, UINT param);
- void ExtendedMODCommands(UINT nChn, UINT param);
- void ExtendedS3MCommands(UINT nChn, UINT param);
- void ExtendedChannelEffect(MODCHANNEL *, UINT param);
- void ProcessMidiMacro(UINT nChn, LPCSTR pszMidiMacro, UINT param=0);
- void SetupChannelFilter(MODCHANNEL *pChn, BOOL bReset, int flt_modifier=256) const;
- /* Low-Level effect processing */
- void DoFreqSlide(MODCHANNEL *pChn, LONG nFreqSlide);
- /* Global Effects */
- void SetTempo(UINT param);
- void SetSpeed(UINT param);
- void GlobalVolSlide(UINT param);
- DWORD IsSongFinished(UINT nOrder, UINT nRow) const;
- BOOL IsValidBackwardJump(UINT nStartOrder, UINT nStartRow, UINT nJumpOrder, UINT nJumpRow) const;
- /* Read/Write sample functions */
- signed char GetDeltaValue(signed char prev, UINT n) const { return (signed char)(prev + CompressionTable[n & 0x0F]); }
- UINT PackSample(int &sample, int next);
- BOOL CanPackSample(LPSTR pSample, UINT nLen, UINT nPacking, BYTE *result=NULL);
- UINT ReadSample(MODINSTRUMENT *pIns, UINT nFlags, LPCSTR pMemFile, DWORD dwMemLength);
- BOOL DestroySample(UINT nSample);
- BOOL DestroyInstrument(UINT nInstr);
- BOOL IsSampleUsed(UINT nSample);
- BOOL IsInstrumentUsed(UINT nInstr);
- BOOL RemoveInstrumentSamples(UINT nInstr);
- UINT DetectUnusedSamples(BOOL *);
- BOOL RemoveSelectedSamples(BOOL *);
- void AdjustSampleLoop(MODINSTRUMENT *pIns);
- /* I/O from another sound file */
- BOOL ReadInstrumentFromSong(UINT nInstr, CSoundFile *, UINT nSrcInstrument);
- BOOL ReadSampleFromSong(UINT nSample, CSoundFile *, UINT nSrcSample);
- /* Period/Note functions */
- UINT GetNoteFromPeriod(UINT period) const;
- UINT GetPeriodFromNote(UINT note, int nFineTune, UINT nC4Speed) const;
- UINT GetFreqFromPeriod(UINT period, UINT nC4Speed, int nPeriodFrac=0) const;
- /* Misc functions */
- MODINSTRUMENT *GetSample(UINT n) { return Ins+n; }
- void ResetMidiCfg();
- UINT MapMidiInstrument(DWORD dwProgram, UINT nChannel, UINT nNote);
- BOOL ITInstrToMPT(const void *p, INSTRUMENTHEADER *penv, UINT trkvers);
- UINT SaveMixPlugins(FILE *f=NULL, BOOL bUpdate=TRUE);
- UINT LoadMixPlugins(const void *pData, UINT nLen);
+ BOOL ReadNote ();
+ BOOL ProcessRow ();
+ BOOL ProcessEffects ();
+ UINT GetNNAChannel (UINT nChn) const;
+ void CheckNNA (UINT nChn, UINT instr, int note, BOOL bForceCut);
+ void NoteChange (UINT nChn, int note, BOOL bPorta = FALSE, BOOL bResetEnv =
+ TRUE);
+ void InstrumentChange (MODCHANNEL * pChn, UINT instr, BOOL bPorta =
+ FALSE, BOOL bUpdVol = TRUE, BOOL bResetEnv = TRUE);
+ /* Channel Effects */
+ void PortamentoUp (MODCHANNEL * pChn, UINT param);
+ void PortamentoDown (MODCHANNEL * pChn, UINT param);
+ void FinePortamentoUp (MODCHANNEL * pChn, UINT param);
+ void FinePortamentoDown (MODCHANNEL * pChn, UINT param);
+ void ExtraFinePortamentoUp (MODCHANNEL * pChn, UINT param);
+ void ExtraFinePortamentoDown (MODCHANNEL * pChn, UINT param);
+ void TonePortamento (MODCHANNEL * pChn, UINT param);
+ void Vibrato (MODCHANNEL * pChn, UINT param);
+ void FineVibrato (MODCHANNEL * pChn, UINT param);
+ void VolumeSlide (MODCHANNEL * pChn, UINT param);
+ void PanningSlide (MODCHANNEL * pChn, UINT param);
+ void ChannelVolSlide (MODCHANNEL * pChn, UINT param);
+ void FineVolumeUp (MODCHANNEL * pChn, UINT param);
+ void FineVolumeDown (MODCHANNEL * pChn, UINT param);
+ void Tremolo (MODCHANNEL * pChn, UINT param);
+ void Panbrello (MODCHANNEL * pChn, UINT param);
+ void RetrigNote (UINT nChn, UINT param);
+ void NoteCut (UINT nChn, UINT nTick);
+ void KeyOff (UINT nChn);
+ int PatternLoop (MODCHANNEL *, UINT param);
+ void ExtendedMODCommands (UINT nChn, UINT param);
+ void ExtendedS3MCommands (UINT nChn, UINT param);
+ void ExtendedChannelEffect (MODCHANNEL *, UINT param);
+ void ProcessMidiMacro (UINT nChn, LPCSTR pszMidiMacro, UINT param = 0);
+ void SetupChannelFilter (MODCHANNEL * pChn, BOOL bReset, int flt_modifier =
+ 256) const;
+ /* Low-Level effect processing */
+ void DoFreqSlide (MODCHANNEL * pChn, LONG nFreqSlide);
+
+ /* Global Effects */
+ void SetTempo (UINT param);
+ void SetSpeed (UINT param);
+ void GlobalVolSlide (UINT param);
+ DWORD IsSongFinished (UINT nOrder, UINT nRow) const;
+ BOOL IsValidBackwardJump (UINT nStartOrder, UINT nStartRow, UINT nJumpOrder,
+ UINT nJumpRow) const;
+ /* Read/Write sample functions */
+ signed char GetDeltaValue (signed char prev, UINT n) const
+ {
+ return (signed char) (prev + CompressionTable[n & 0x0F]);
+ }
+ UINT PackSample (int &sample, int next);
+ BOOL CanPackSample (LPSTR pSample, UINT nLen, UINT nPacking, BYTE * result =
+ NULL);
+ UINT ReadSample (MODINSTRUMENT * pIns, UINT nFlags, LPCSTR pMemFile,
+ DWORD dwMemLength);
+ BOOL DestroySample (UINT nSample);
+ BOOL DestroyInstrument (UINT nInstr);
+ BOOL IsSampleUsed (UINT nSample);
+ BOOL IsInstrumentUsed (UINT nInstr);
+ BOOL RemoveInstrumentSamples (UINT nInstr);
+ UINT DetectUnusedSamples (BOOL *);
+ BOOL RemoveSelectedSamples (BOOL *);
+ void AdjustSampleLoop (MODINSTRUMENT * pIns);
+
+ /* I/O from another sound file */
+ BOOL ReadInstrumentFromSong (UINT nInstr, CSoundFile *, UINT nSrcInstrument);
+ BOOL ReadSampleFromSong (UINT nSample, CSoundFile *, UINT nSrcSample);
+
+ /* Period/Note functions */
+ UINT GetNoteFromPeriod (UINT period) const;
+ UINT GetPeriodFromNote (UINT note, int nFineTune, UINT nC4Speed) const;
+ UINT GetFreqFromPeriod (UINT period, UINT nC4Speed, int nPeriodFrac =
+ 0) const;
+ /* Misc functions */
+ MODINSTRUMENT *GetSample (UINT n)
+ {
+ return Ins + n;
+ }
+ void ResetMidiCfg ();
+ UINT MapMidiInstrument (DWORD dwProgram, UINT nChannel, UINT nNote);
+ BOOL ITInstrToMPT (const void *p, INSTRUMENTHEADER * penv, UINT trkvers);
+ UINT SaveMixPlugins (FILE * f = NULL, BOOL bUpdate = TRUE);
+ UINT LoadMixPlugins (const void *pData, UINT nLen);
+
#ifndef NO_FILTER
- DWORD CutOffToFrequency(UINT nCutOff, int flt_modifier=256) const; /* [0-255] => [1-10KHz] */
+ DWORD CutOffToFrequency (UINT nCutOff, int flt_modifier = 256) const; /* [0-255] => [1-10KHz] */
#endif
- /* Static helper functions */
+ /* Static helper functions */
public:
- static DWORD TransposeToFrequency(int transp, int ftune=0);
- static int FrequencyToTranspose(DWORD freq);
- static void FrequencyToTranspose(MODINSTRUMENT *psmp);
+ static DWORD TransposeToFrequency (int transp, int ftune = 0);
+ static int FrequencyToTranspose (DWORD freq);
+ static void FrequencyToTranspose (MODINSTRUMENT * psmp);
- /* System-Dependant functions */
+ /* System-Dependant functions */
public:
- static MODCOMMAND *AllocatePattern(UINT rows, UINT nchns);
- static signed char* AllocateSample(UINT nbytes);
- static void FreePattern(LPVOID pat);
- static void FreeSample(LPVOID p);
- static UINT Normalize24BitBuffer(LPBYTE pbuffer, UINT cbsizebytes, DWORD lmax24, DWORD dwByteInc);
+ static MODCOMMAND *AllocatePattern (UINT rows, UINT nchns);
+ static signed char *AllocateSample (UINT nbytes);
+ static void FreePattern (LPVOID pat);
+ static void FreeSample (LPVOID p);
+ static UINT Normalize24BitBuffer (LPBYTE pbuffer, UINT cbsizebytes,
+ DWORD lmax24, DWORD dwByteInc);
};
typedef struct WAVEFILEHEADER
{
- DWORD id_RIFF; /* "RIFF" */
- DWORD filesize; /* file length-8 */
- DWORD id_WAVE;
+ DWORD id_RIFF; /* "RIFF" */
+ DWORD filesize; /* file length-8 */
+ DWORD id_WAVE;
} WAVEFILEHEADER;
typedef struct WAVEFORMATHEADER
{
- DWORD id_fmt; /* "fmt " */
- DWORD hdrlen; /* 16 */
- WORD format; /* 1 */
- WORD channels; /* 1:mono, 2:stereo */
- DWORD freqHz; /* sampling freq */
- DWORD bytessec; /* bytes/sec=freqHz*samplesize */
- WORD samplesize; /* sizeof(sample) */
- WORD bitspersample; /* bits per sample (8/16) */
+ DWORD id_fmt; /* "fmt " */
+ DWORD hdrlen; /* 16 */
+ WORD format; /* 1 */
+ WORD channels; /* 1:mono, 2:stereo */
+ DWORD freqHz; /* sampling freq */
+ DWORD bytessec; /* bytes/sec=freqHz*samplesize */
+ WORD samplesize; /* sizeof(sample) */
+ WORD bitspersample; /* bits per sample (8/16) */
} WAVEFORMATHEADER;
typedef struct WAVEDATAHEADER
{
- DWORD id_data; /* "data" */
- DWORD length; /* length of data */
+ DWORD id_data; /* "data" */
+ DWORD length; /* length of data */
} WAVEDATAHEADER;
typedef struct WAVESMPLHEADER
{
- /* SMPL */
- DWORD smpl_id; /* "smpl" -> 0x6C706D73 */
- DWORD smpl_len; /* length of smpl: 3Ch (54h with sustain loop) */
- DWORD dwManufacturer;
- DWORD dwProduct;
- DWORD dwSamplePeriod; /* 1000000000/freqHz */
- DWORD dwBaseNote; /* 3Ch = C-4 -> 60 + RelativeTone */
- DWORD dwPitchFraction;
- DWORD dwSMPTEFormat;
- DWORD dwSMPTEOffset;
- DWORD dwSampleLoops; /* number of loops */
- DWORD cbSamplerData;
+ /* SMPL */
+ DWORD smpl_id; /* "smpl" -> 0x6C706D73 */
+ DWORD smpl_len; /* length of smpl: 3Ch (54h with sustain loop) */
+ DWORD dwManufacturer;
+ DWORD dwProduct;
+ DWORD dwSamplePeriod; /* 1000000000/freqHz */
+ DWORD dwBaseNote; /* 3Ch = C-4 -> 60 + RelativeTone */
+ DWORD dwPitchFraction;
+ DWORD dwSMPTEFormat;
+ DWORD dwSMPTEOffset;
+ DWORD dwSampleLoops; /* number of loops */
+ DWORD cbSamplerData;
} WAVESMPLHEADER;
typedef struct SAMPLELOOPSTRUCT
{
- DWORD dwIdentifier;
- DWORD dwLoopType; /* 0=normal, 1=bidi */
- DWORD dwLoopStart;
- DWORD dwLoopEnd; /* Byte offset ? */
- DWORD dwFraction;
- DWORD dwPlayCount; /* Loop Count, 0=infinite */
+ DWORD dwIdentifier;
+ DWORD dwLoopType; /* 0=normal, 1=bidi */
+ DWORD dwLoopStart;
+ DWORD dwLoopEnd; /* Byte offset ? */
+ DWORD dwFraction;
+ DWORD dwPlayCount; /* Loop Count, 0=infinite */
} SAMPLELOOPSTRUCT;
typedef struct WAVESAMPLERINFO
{
- WAVESMPLHEADER wsiHdr;
- SAMPLELOOPSTRUCT wsiLoops[2];
+ WAVESMPLHEADER wsiHdr;
+ SAMPLELOOPSTRUCT wsiLoops[2];
} WAVESAMPLERINFO;
typedef struct WAVELISTHEADER
{
- DWORD list_id; /* "LIST" -> 0x5453494C */
- DWORD list_len;
- DWORD info; /* "INFO" */
+ DWORD list_id; /* "LIST" -> 0x5453494C */
+ DWORD list_len;
+ DWORD info; /* "INFO" */
} WAVELISTHEADER;
typedef struct WAVEEXTRAHEADER
{
- DWORD xtra_id; /* "xtra" -> 0x61727478 */
- DWORD xtra_len;
- DWORD dwFlags;
- WORD wPan;
- WORD wVolume;
- WORD wGlobalVol;
- WORD wReserved;
- BYTE nVibType;
- BYTE nVibSweep;
- BYTE nVibDepth;
- BYTE nVibRate;
+ DWORD xtra_id; /* "xtra" -> 0x61727478 */
+ DWORD xtra_len;
+ DWORD dwFlags;
+ WORD wPan;
+ WORD wVolume;
+ WORD wGlobalVol;
+ WORD wReserved;
+ BYTE nVibType;
+ BYTE nVibSweep;
+ BYTE nVibDepth;
+ BYTE nVibRate;
} WAVEEXTRAHEADER;
#pragma pack()
#define MOD2XMFineTune(k) ((int)( (signed char)((k)<<4) ))
#define XM2MODFineTune(k) ((int)( (k>>4)&0x0f ))
-int _muldiv(long a, long b, long c);
-int _muldivr(long a, long b, long c);
+int _muldiv (long a, long b, long c);
+int _muldivr (long a, long b, long c);
/* Byte swapping functions from the GNU C Library and libsdl */
static inline unsigned int
bswap_32 (unsigned int __bsx)
{
- return ((((__bsx) & 0xff000000) >> 24) | (((__bsx) & 0x00ff0000) >> 8) |
- (((__bsx) & 0x0000ff00) << 8) | (((__bsx) & 0x000000ff) << 24));
+ return ((((__bsx) & 0xff000000) >> 24) | (((__bsx) & 0x00ff0000) >> 8) |
+ (((__bsx) & 0x0000ff00) << 8) | (((__bsx) & 0x000000ff) << 24));
}
#endif
#include <mmsystem.h>
#include <stdio.h>
-inline void ProcessPlugins(int n) {}
+inline void
+ProcessPlugins (int n)
+{
+}
#else
typedef signed char CHAR;
typedef unsigned char UCHAR;
-typedef unsigned char* PUCHAR;
+typedef unsigned char *PUCHAR;
typedef unsigned short USHORT;
typedef unsigned long ULONG;
typedef unsigned long UINT;
typedef long LONG;
typedef unsigned short WORD;
typedef unsigned char BYTE;
-typedef unsigned char * LPBYTE;
+typedef unsigned char *LPBYTE;
typedef bool BOOL;
-typedef char * LPSTR;
-typedef void * LPVOID;
-typedef long * LPLONG;
-typedef unsigned long * LPDWORD;
-typedef unsigned short * LPWORD;
-typedef const char * LPCSTR;
+typedef char *LPSTR;
+typedef void *LPVOID;
+typedef long *LPLONG;
+typedef unsigned long *LPDWORD;
+typedef unsigned short *LPWORD;
+typedef const char *LPCSTR;
typedef long long LONGLONG;
-typedef void * PVOID;
+typedef void *PVOID;
typedef void VOID;
-inline LONG MulDiv (long a, long b, long c)
+inline LONG
+MulDiv (long a, long b, long c)
{
/* if (!c) return 0; */
- return ((unsigned long long) a * (unsigned long long) b ) / c;
+ return ((unsigned long long) a * (unsigned long long) b) / c;
}
#define MODPLUG_NO_FILESAVE
#define GHND 0
-inline signed char * GlobalAllocPtr(unsigned int, size_t size)
+inline signed char *
+GlobalAllocPtr (unsigned int, size_t size)
{
- signed char * p = (signed char *) malloc(size);
+ signed char *p = (signed char *) malloc (size);
- if (p != NULL) memset(p, 0, size);
+ if (p != NULL)
+ memset (p, 0, size);
return p;
}
-inline void ProcessPlugins(int n) {}
+inline void
+ProcessPlugins (int n)
+{
+}
#define GlobalFreePtr(p) free((void *)(p))
#endif /* MSC_VER */
#endif
-
-
-
#define AUDIO_SYNCWORD 0xfff
-#define CLOCKS 90000.0
+#define CLOCKS 90000.0
#ifdef G_HAVE_ISO_VARARGS
#endif
/* This must match decoder and encoder tables */
-static double picture_rates [16] =
-{
- 0.0,
- 24000.0/1001.,
- 24.0,
- 25.0,
- 30000.0/1001.,
- 30.0,
- 50.0,
- 60000.0/1001.,
- 60.0,
-
- 1,
- 5,
- 10,
- 12,
- 15,
- 0,
- 0
+static double picture_rates[16] = {
+ 0.0,
+ 24000.0 / 1001.,
+ 24.0,
+ 25.0,
+ 30000.0 / 1001.,
+ 30.0,
+ 50.0,
+ 60000.0 / 1001.,
+ 60.0,
+
+ 1,
+ 5,
+ 10,
+ 12,
+ 15,
+ 0,
+ 0
};
+
/* defined but not used
static double ratio [16] = { 0., 1., 0.6735, 0.7031, 0.7615, 0.8055,
0.8437, 0.8935, 0.9157, 0.9815, 1.0255, 1.0695, 1.0950, 1.1575,
*/
#ifndef GST_DISABLE_GST_DEBUG
-static char picture_types [4][3] =
- { "I", "P", "B", "D" };
+static char picture_types[4][3] = { "I", "P", "B", "D" };
#endif
static int bitrate_index[2][3][16] =
-{ { {0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, },
- {0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, },
- {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, } },
- { {0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256, },
- {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, },
- {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, } },
+ { {{0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448,},
+ {0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384,},
+ {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320,}},
+{{0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256,},
+ {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160,},
+ {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160,}},
};
static long frequency[9] =
-{44100, 48000, 32000, 22050, 24000, 16000, 11025, 12000, 8000};
+ { 44100, 48000, 32000, 22050, 24000, 16000, 11025, 12000, 8000 };
+
+static double dfrequency[9] = { 44.1, 48, 32, 22.05, 24, 16, 11.025, 12, 8 };
-static double dfrequency[9] =
-{44.1, 48, 32, 22.05, 24, 16, 11.025, 12, 8};
+static unsigned int samples[4] = { 192, 384, 1152, 1152 };
-static unsigned int samples [4] = {192, 384, 1152, 1152};
/* deined but not used
static char mode [4][15] =
{ "stereo", "joint stereo", "dual channel", "single channel" };
static char emphasis [4][20] =
{ "none", "50/15 microseconds", "reserved", "CCITT J.17" };
*/
-static void mpeg1mux_buffer_update_video_info(Mpeg1MuxBuffer *mb);
-static void mpeg1mux_buffer_update_audio_info(Mpeg1MuxBuffer *mb);
+static void mpeg1mux_buffer_update_video_info (Mpeg1MuxBuffer * mb);
+static void mpeg1mux_buffer_update_audio_info (Mpeg1MuxBuffer * mb);
-Mpeg1MuxBuffer *mpeg1mux_buffer_new(guchar type, guchar id) {
- Mpeg1MuxBuffer *new = g_malloc(sizeof(Mpeg1MuxBuffer));
+Mpeg1MuxBuffer *
+mpeg1mux_buffer_new (guchar type, guchar id)
+{
+ Mpeg1MuxBuffer *new = g_malloc (sizeof (Mpeg1MuxBuffer));
new->buffer = NULL;
new->length = 0;
return new;
}
-void mpeg1mux_buffer_queue(Mpeg1MuxBuffer *mb, GstBuffer *buf) {
+void
+mpeg1mux_buffer_queue (Mpeg1MuxBuffer * mb, GstBuffer * buf)
+{
if (mb->buffer == NULL) {
- mb->buffer = g_malloc(GST_BUFFER_SIZE(buf));
- mb->length = GST_BUFFER_SIZE(buf);
- memcpy(mb->buffer, GST_BUFFER_DATA(buf), GST_BUFFER_SIZE(buf));
- }
- else {
- mb->buffer = g_realloc(mb->buffer, mb->length + GST_BUFFER_SIZE(buf));
- memcpy(mb->buffer+mb->length, GST_BUFFER_DATA(buf), GST_BUFFER_SIZE(buf));
- mb->length += GST_BUFFER_SIZE(buf);
+ mb->buffer = g_malloc (GST_BUFFER_SIZE (buf));
+ mb->length = GST_BUFFER_SIZE (buf);
+ memcpy (mb->buffer, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
+ } else {
+ mb->buffer = g_realloc (mb->buffer, mb->length + GST_BUFFER_SIZE (buf));
+ memcpy (mb->buffer + mb->length, GST_BUFFER_DATA (buf),
+ GST_BUFFER_SIZE (buf));
+ mb->length += GST_BUFFER_SIZE (buf);
}
GST_DEBUG ("queuing buffer %lu", mb->length);
if (mb->buffer_type == BUFFER_TYPE_VIDEO) {
- mpeg1mux_buffer_update_video_info(mb);
- }
- else {
- mpeg1mux_buffer_update_audio_info(mb);
+ mpeg1mux_buffer_update_video_info (mb);
+ } else {
+ mpeg1mux_buffer_update_audio_info (mb);
}
}
-gulong mpeg1mux_buffer_update_queued(Mpeg1MuxBuffer *mb, guint64 scr) {
+gulong
+mpeg1mux_buffer_update_queued (Mpeg1MuxBuffer * mb, guint64 scr)
+{
GList *queued_list;
Mpeg1MuxTimecode *tc;
gulong total_queued = 0;
-
+
GST_DEBUG ("queued in buffer on SCR=%" G_GUINT64_FORMAT, scr);
- queued_list = g_list_first(mb->queued_list);
+ queued_list = g_list_first (mb->queued_list);
while (queued_list) {
tc = (Mpeg1MuxTimecode *) queued_list->data;
if (tc->DTS < scr) {
/* this buffer should be sent out */
- mb->queued_list = g_list_remove(mb->queued_list, tc);
- queued_list = g_list_first(mb->queued_list);
- }
- else {
- GST_DEBUG ("queued in buffer %ld, %" G_GUINT64_FORMAT, tc->original_length, tc->DTS);
+ mb->queued_list = g_list_remove (mb->queued_list, tc);
+ queued_list = g_list_first (mb->queued_list);
+ } else {
+ GST_DEBUG ("queued in buffer %ld, %" G_GUINT64_FORMAT,
+ tc->original_length, tc->DTS);
total_queued += tc->original_length;
- queued_list = g_list_next(queued_list);
+ queued_list = g_list_next (queued_list);
}
}
GST_DEBUG ("queued in buffer %lu", total_queued);
return total_queued;
}
-void mpeg1mux_buffer_shrink(Mpeg1MuxBuffer *mb, gulong size) {
+void
+mpeg1mux_buffer_shrink (Mpeg1MuxBuffer * mb, gulong size)
+{
GList *timecode_list;
Mpeg1MuxTimecode *tc;
gulong consumed = 0;
GST_DEBUG ("shrinking buffer %lu", size);
- g_assert(mb->length >= size);
+ g_assert (mb->length >= size);
- memcpy(mb->buffer, mb->buffer+size, mb->length-size);
- mb->buffer = g_realloc(mb->buffer, mb->length-size);
+ memcpy (mb->buffer, mb->buffer + size, mb->length - size);
+ mb->buffer = g_realloc (mb->buffer, mb->length - size);
mb->length -= size;
mb->scan_pos -= size;
mb->current_start -= size;
- timecode_list = g_list_first(mb->timecode_list);
+ timecode_list = g_list_first (mb->timecode_list);
tc = (Mpeg1MuxTimecode *) timecode_list->data;
-
+
if (tc->length > size) {
tc->length -= size;
mb->new_frame = FALSE;
- }
- else {
+ } else {
consumed += tc->length;
while (size >= consumed) {
- GST_DEBUG ("removing timecode: %" G_GUINT64_FORMAT " %" G_GUINT64_FORMAT " %lu %lu", tc->DTS, tc->PTS, tc->length, consumed);
- mb->timecode_list = g_list_remove_link(mb->timecode_list, timecode_list);
- mb->queued_list = g_list_append(mb->queued_list, tc);
- timecode_list = g_list_first(mb->timecode_list);
+ GST_DEBUG ("removing timecode: %" G_GUINT64_FORMAT " %" G_GUINT64_FORMAT
+ " %lu %lu", tc->DTS, tc->PTS, tc->length, consumed);
+ mb->timecode_list = g_list_remove_link (mb->timecode_list, timecode_list);
+ mb->queued_list = g_list_append (mb->queued_list, tc);
+ timecode_list = g_list_first (mb->timecode_list);
tc = (Mpeg1MuxTimecode *) timecode_list->data;
consumed += tc->length;
- GST_DEBUG ("next timecode: %" G_GUINT64_FORMAT " %" G_GUINT64_FORMAT " %lu %lu", tc->DTS, tc->PTS, tc->length, consumed);
+ GST_DEBUG ("next timecode: %" G_GUINT64_FORMAT " %" G_GUINT64_FORMAT
+ " %lu %lu", tc->DTS, tc->PTS, tc->length, consumed);
}
mb->new_frame = TRUE;
- GST_DEBUG ("leftover frame size from %lu to %lu ", tc->length, consumed-size);
+ GST_DEBUG ("leftover frame size from %lu to %lu ", tc->length,
+ consumed - size);
tc->length = consumed - size;
}
mb->info.video.DTS = tc->DTS;
mb->info.video.PTS = tc->PTS;
mb->next_frame_time = tc->DTS;
- }
- else {
+ } else {
mb->info.audio.PTS = tc->PTS;
mb->next_frame_time = tc->PTS;
}
- GST_DEBUG ("next frame time timecode: %" G_GUINT64_FORMAT " %lu", mb->next_frame_time, tc->length);
+ GST_DEBUG ("next frame time timecode: %" G_GUINT64_FORMAT " %lu",
+ mb->next_frame_time, tc->length);
/* check buffer consistency */
- timecode_list = g_list_first(mb->timecode_list);
+ timecode_list = g_list_first (mb->timecode_list);
count = 0;
while (timecode_list) {
tc = (Mpeg1MuxTimecode *) timecode_list->data;
count += tc->length;
-
- timecode_list = g_list_next(timecode_list);
+
+ timecode_list = g_list_next (timecode_list);
}
- if (count != mb->current_start) g_print("********** error %lu != %lu\n", count, mb->current_start);
+ if (count != mb->current_start)
+ g_print ("********** error %lu != %lu\n", count, mb->current_start);
mb->base += size;
}
-static void mpeg1mux_buffer_update_video_info(Mpeg1MuxBuffer *mb) {
+static void
+mpeg1mux_buffer_update_video_info (Mpeg1MuxBuffer * mb)
+{
gboolean have_sync = FALSE;
guchar *data = mb->buffer;
gulong offset = mb->scan_pos;
guint sync_zeros = 0;
- gulong id=0;
+ gulong id = 0;
guint temporal_reference, temp;
gst_getbits_t gb;
-
+
GST_DEBUG ("mpeg1mux::update_video_info %lu %lu", mb->base, mb->scan_pos);
if (mb->base == 0 && mb->scan_pos == 0) {
- if ((SYNCWORD_START<<8)+*(mb->buffer+3) == SEQUENCE_HEADER) {
-
- gst_getbits_init(&gb, NULL, NULL);
- gst_getbits_newbuf(&gb, data+4, mb->length);
- mb->info.video.horizontal_size = gst_getbits12(&gb);
- mb->info.video.vertical_size = gst_getbits12(&gb);
- mb->info.video.aspect_ratio = gst_getbits4(&gb);
- mb->info.video.picture_rate = gst_getbits4(&gb);
- mb->info.video.bit_rate = gst_getbits18(&gb);
- if (gst_getbits1(&gb) != 1) {
- g_print("mpeg1mux::update_video_info: marker bit error\n");
+ if ((SYNCWORD_START << 8) + *(mb->buffer + 3) == SEQUENCE_HEADER) {
+
+ gst_getbits_init (&gb, NULL, NULL);
+ gst_getbits_newbuf (&gb, data + 4, mb->length);
+ mb->info.video.horizontal_size = gst_getbits12 (&gb);
+ mb->info.video.vertical_size = gst_getbits12 (&gb);
+ mb->info.video.aspect_ratio = gst_getbits4 (&gb);
+ mb->info.video.picture_rate = gst_getbits4 (&gb);
+ mb->info.video.bit_rate = gst_getbits18 (&gb);
+ if (gst_getbits1 (&gb) != 1) {
+ g_print ("mpeg1mux::update_video_info: marker bit error\n");
}
- mb->info.video.vbv_buffer_size = gst_getbits10(&gb);
- mb->info.video.CSPF = gst_getbits1(&gb);
-
- mb->info.video.secs_per_frame = 1. / picture_rates[mb->info.video.picture_rate];
- mb->info.video.decoding_order=0;
- mb->info.video.group_order=0;
- GST_DEBUG ("mpeg1mux::update_video_info: secs per frame %g", mb->info.video.secs_per_frame);
- }
- else {
- g_print("mpeg1mux::update_video_info: Invalid MPEG Video header\n");
+ mb->info.video.vbv_buffer_size = gst_getbits10 (&gb);
+ mb->info.video.CSPF = gst_getbits1 (&gb);
+
+ mb->info.video.secs_per_frame =
+ 1. / picture_rates[mb->info.video.picture_rate];
+ mb->info.video.decoding_order = 0;
+ mb->info.video.group_order = 0;
+ GST_DEBUG ("mpeg1mux::update_video_info: secs per frame %g",
+ mb->info.video.secs_per_frame);
+ } else {
+ g_print ("mpeg1mux::update_video_info: Invalid MPEG Video header\n");
}
}
- while (offset < mb->length-6) {
+ while (offset < mb->length - 6) {
if (!have_sync) {
- guchar byte = *(data+offset);
+ guchar byte = *(data + offset);
+
/*GST_DEBUG ("mpeg1mux::update_video_info: found #%d at %lu",byte,offset); */
offset++;
/* if it's zero, increment the zero count */
if (byte == 0) {
- sync_zeros++;
- /*GST_DEBUG ("mpeg1mux::update_video_info: found zero #%d at %lu",sync_zeros,offset-1); */
+ sync_zeros++;
+ /*GST_DEBUG ("mpeg1mux::update_video_info: found zero #%d at %lu",sync_zeros,offset-1); */
}
/* if it's a one and we have two previous zeros, we have sync */
else if ((byte == 1) && (sync_zeros >= 2)) {
- GST_DEBUG ("mpeg1mux::update_video_info: synced at %lu",offset-1);
- have_sync = TRUE;
- sync_zeros = 0;
+ GST_DEBUG ("mpeg1mux::update_video_info: synced at %lu", offset - 1);
+ have_sync = TRUE;
+ sync_zeros = 0;
}
/* if it's anything else, we've lost it completely */
- else sync_zeros = 0;
- /* then snag the chunk ID */
+ else
+ sync_zeros = 0;
+ /* then snag the chunk ID */
} else if (id == 0) {
- id = *(data+offset);
- GST_DEBUG ("mpeg1mux::update_video_info: got id 0x%02lX",id);
- id = (SYNCWORD_START<<8)+id;
+ id = *(data + offset);
+ GST_DEBUG ("mpeg1mux::update_video_info: got id 0x%02lX", id);
+ id = (SYNCWORD_START << 8) + id;
switch (id) {
case SEQUENCE_HEADER:
- GST_DEBUG ("mpeg1mux::update_video_info: sequence header");
+ GST_DEBUG ("mpeg1mux::update_video_info: sequence header");
break;
case GROUP_START:
- GST_DEBUG ("mpeg1mux::update_video_info: group start");
- mb->info.video.group_order=0;
+ GST_DEBUG ("mpeg1mux::update_video_info: group start");
+ mb->info.video.group_order = 0;
break;
case PICTURE_START:
/* skip the first access unit */
if (mb->info.video.decoding_order != 0) {
Mpeg1MuxTimecode *tc;
- GST_DEBUG ("mpeg1mux::update_video_info: PTS %" G_GUINT64_FORMAT ", DTS %" G_GUINT64_FORMAT ", length %lu", mb->info.video.current_PTS,
- mb->info.video.current_DTS, offset - mb->current_start-3);
- tc = (Mpeg1MuxTimecode *) g_malloc(sizeof(Mpeg1MuxTimecode));
- tc->length = offset - mb->current_start-3;
+ GST_DEBUG ("mpeg1mux::update_video_info: PTS %" G_GUINT64_FORMAT
+ ", DTS %" G_GUINT64_FORMAT ", length %lu",
+ mb->info.video.current_PTS, mb->info.video.current_DTS,
+ offset - mb->current_start - 3);
+
+ tc = (Mpeg1MuxTimecode *) g_malloc (sizeof (Mpeg1MuxTimecode));
+ tc->length = offset - mb->current_start - 3;
tc->original_length = tc->length;
tc->frame_type = mb->info.video.current_type;
tc->DTS = mb->info.video.current_DTS;
tc->PTS = mb->info.video.current_PTS;
- mb->timecode_list = g_list_append(mb->timecode_list, tc);
+ mb->timecode_list = g_list_append (mb->timecode_list, tc);
if (mb->info.video.decoding_order == 0) {
mb->next_frame_time = tc->DTS;
}
- mb->current_start = offset-3;
+ mb->current_start = offset - 3;
}
- temp= (*(data+offset+1)<<8)+*(data+offset+2);
+ temp = (*(data + offset + 1) << 8) + *(data + offset + 2);
temporal_reference = (temp & 0xffc0) >> 6;
mb->info.video.current_type = (temp & 0x0038) >> 3;
- GST_DEBUG ("mpeg1mux::update_video_info: picture start temporal_ref:%d type:%s Frame", temporal_reference,
- picture_types[mb->info.video.current_type-1]);
-
- mb->info.video.current_DTS = mb->info.video.decoding_order * mb->info.video.secs_per_frame * CLOCKS;
- mb->info.video.current_PTS = (temporal_reference - mb->info.video.group_order + 1 +
- mb->info.video.decoding_order) *mb->info.video.secs_per_frame*CLOCKS;
+ GST_DEBUG
+ ("mpeg1mux::update_video_info: picture start temporal_ref:%d type:%s Frame",
+ temporal_reference,
+ picture_types[mb->info.video.current_type - 1]);
+
+ mb->info.video.current_DTS =
+ mb->info.video.decoding_order * mb->info.video.secs_per_frame *
+ CLOCKS;
+ mb->info.video.current_PTS =
+ (temporal_reference - mb->info.video.group_order + 1 +
+ mb->info.video.decoding_order) * mb->info.video.secs_per_frame *
+ CLOCKS;
mb->info.video.decoding_order++;
mb->info.video.group_order++;
offset++;
break;
case SEQUENCE_END:
- GST_DEBUG ("mpeg1mux::update_video_info: sequence end");
+ GST_DEBUG ("mpeg1mux::update_video_info: sequence end");
break;
}
/* prepare for next sync */
mb->scan_pos = offset;
}
-static void mpeg1mux_buffer_update_audio_info(Mpeg1MuxBuffer *mb) {
+static void
+mpeg1mux_buffer_update_audio_info (Mpeg1MuxBuffer * mb)
+{
guchar *data = mb->buffer;
gulong offset = mb->scan_pos;
- guint32 id=0;
+ guint32 id = 0;
guint padding_bit;
gst_getbits_t gb;
guint startup_delay = 0;
- int layer_index,lsf,samplerate_index,padding;
+ int layer_index, lsf, samplerate_index, padding;
long bpf;
Mpeg1MuxTimecode *tc;
-
+
GST_DEBUG ("mpeg1mux::update_audio_info %lu %lu", mb->base, mb->scan_pos);
if (mb->base == 0 && mb->scan_pos == 0) {
- id = GUINT32_FROM_BE(*((guint32 *)(data)));
+ id = GUINT32_FROM_BE (*((guint32 *) (data)));
- printf("MPEG audio id = %08x\n", (unsigned int)id);
- if ((id & 0xfff00000) == AUDIO_SYNCWORD<<20) {
+ printf ("MPEG audio id = %08x\n", (unsigned int) id);
+ if ((id & 0xfff00000) == AUDIO_SYNCWORD << 20) {
/* mpegver = (header >> 19) & 0x3; don't need this for bpf */
layer_index = (id >> 17) & 0x3;
mb->info.audio.layer = 4 - layer_index;
lsf = (id & (1 << 20)) ? ((id & (1 << 19)) ? 0 : 1) : 1;
- mb->info.audio.bit_rate = bitrate_index[lsf][mb->info.audio.layer - 1][((id >> 12) & 0xf)];
+ mb->info.audio.bit_rate =
+ bitrate_index[lsf][mb->info.audio.layer - 1][((id >> 12) & 0xf)];
samplerate_index = (id >> 10) & 0x3;
padding = (id >> 9) & 0x1;
if (mb->info.audio.layer == 1) {
- bpf = mb->info.audio.bit_rate * 12000;
- bpf /= frequency[samplerate_index];
- bpf = ((bpf + padding) << 2);
+ bpf = mb->info.audio.bit_rate * 12000;
+ bpf /= frequency[samplerate_index];
+ bpf = ((bpf + padding) << 2);
} else {
- bpf = mb->info.audio.bit_rate * 144000;
- bpf /= frequency[samplerate_index];
- bpf += padding;
+ bpf = mb->info.audio.bit_rate * 144000;
+ bpf /= frequency[samplerate_index];
+ bpf += padding;
}
mb->info.audio.framesize = bpf;
- GST_DEBUG ("mpeg1mux::update_audio_info: samples per second %d", samplerate_index);
+ GST_DEBUG ("mpeg1mux::update_audio_info: samples per second %d",
+ samplerate_index);
- gst_getbits_init(&gb, NULL, NULL);
- gst_getbits_newbuf(&gb, data, mb->length);
+ gst_getbits_init (&gb, NULL, NULL);
+ gst_getbits_newbuf (&gb, data, mb->length);
- gst_flushbitsn(&gb, 12);
- if (gst_getbits1(&gb) != 1) {
- g_print("mpeg1mux::update_audio_info: marker bit error\n");
+ gst_flushbitsn (&gb, 12);
+ if (gst_getbits1 (&gb) != 1) {
+ g_print ("mpeg1mux::update_audio_info: marker bit error\n");
}
- gst_flushbitsn(&gb, 2);
- mb->info.audio.protection = gst_getbits1(&gb);
- gst_flushbitsn(&gb, 4);
- mb->info.audio.frequency = gst_getbits2(&gb);
- padding_bit = gst_getbits1(&gb);
- gst_flushbitsn(&gb, 1);
- mb->info.audio.mode = gst_getbits2(&gb);
- mb->info.audio.mode_extension = gst_getbits2(&gb);
- mb->info.audio.copyright = gst_getbits1(&gb);
- mb->info.audio.original_copy = gst_getbits1(&gb);
- mb->info.audio.emphasis = gst_getbits2(&gb);
+ gst_flushbitsn (&gb, 2);
+ mb->info.audio.protection = gst_getbits1 (&gb);
+ gst_flushbitsn (&gb, 4);
+ mb->info.audio.frequency = gst_getbits2 (&gb);
+ padding_bit = gst_getbits1 (&gb);
+ gst_flushbitsn (&gb, 1);
+ mb->info.audio.mode = gst_getbits2 (&gb);
+ mb->info.audio.mode_extension = gst_getbits2 (&gb);
+ mb->info.audio.copyright = gst_getbits1 (&gb);
+ mb->info.audio.original_copy = gst_getbits1 (&gb);
+ mb->info.audio.emphasis = gst_getbits2 (&gb);
GST_DEBUG ("mpeg1mux::update_audio_info: layer %d", mb->info.audio.layer);
- GST_DEBUG ("mpeg1mux::update_audio_info: bit_rate %d", mb->info.audio.bit_rate);
- GST_DEBUG ("mpeg1mux::update_audio_info: frequency %d", mb->info.audio.frequency);
+ GST_DEBUG ("mpeg1mux::update_audio_info: bit_rate %d",
+ mb->info.audio.bit_rate);
+ GST_DEBUG ("mpeg1mux::update_audio_info: frequency %d",
+ mb->info.audio.frequency);
- mb->info.audio.samples_per_second = (double)dfrequency [mb->info.audio.frequency];
+ mb->info.audio.samples_per_second =
+ (double) dfrequency[mb->info.audio.frequency];
- GST_DEBUG ("mpeg1mux::update_audio_info: samples per second %g", mb->info.audio.samples_per_second);
+ GST_DEBUG ("mpeg1mux::update_audio_info: samples per second %g",
+ mb->info.audio.samples_per_second);
- mb->info.audio.decoding_order=0;
+ mb->info.audio.decoding_order = 0;
- tc = (Mpeg1MuxTimecode *) g_malloc(sizeof(Mpeg1MuxTimecode));
+ tc = (Mpeg1MuxTimecode *) g_malloc (sizeof (Mpeg1MuxTimecode));
tc->length = mb->info.audio.framesize;
tc->original_length = tc->length;
tc->frame_type = FRAME_TYPE_AUDIO;
- mb->info.audio.current_PTS = mb->info.audio.decoding_order * samples [mb->info.audio.layer] /
- mb->info.audio.samples_per_second * 90. + startup_delay;
+ mb->info.audio.current_PTS =
+ mb->info.audio.decoding_order * samples[mb->info.audio.layer] /
+ mb->info.audio.samples_per_second * 90. + startup_delay;
- GST_DEBUG ("mpeg1mux::update_audio_info: PTS %" G_GUINT64_FORMAT ", length %u", mb->info.audio.current_PTS, mb->info.audio.framesize);
+ GST_DEBUG ("mpeg1mux::update_audio_info: PTS %" G_GUINT64_FORMAT
+ ", length %u", mb->info.audio.current_PTS, mb->info.audio.framesize);
tc->PTS = mb->info.audio.current_PTS;
tc->DTS = mb->info.audio.current_PTS;
- mb->timecode_list = g_list_append(mb->timecode_list, tc);
+ mb->timecode_list = g_list_append (mb->timecode_list, tc);
mb->next_frame_time = tc->PTS;
mb->info.audio.decoding_order++;
offset += tc->length;
- }
- else {
- g_print("mpeg1mux::update_audio_info: Invalid MPEG Video header\n");
+ } else {
+ g_print ("mpeg1mux::update_audio_info: Invalid MPEG Video header\n");
}
}
- while (offset < mb->length-4) {
- id = GUINT32_FROM_BE(*((guint32 *)(data+offset)));
+ while (offset < mb->length - 4) {
+ id = GUINT32_FROM_BE (*((guint32 *) (data + offset)));
/* mpegver = (header >> 19) & 0x3; don't need this for bpf */
layer_index = (id >> 17) & 0x3;
mb->info.audio.layer = 4 - layer_index;
lsf = (id & (1 << 20)) ? ((id & (1 << 19)) ? 0 : 1) : 1;
- mb->info.audio.bit_rate = bitrate_index[lsf][mb->info.audio.layer - 1][((id >> 12) & 0xf)];
+ mb->info.audio.bit_rate =
+ bitrate_index[lsf][mb->info.audio.layer - 1][((id >> 12) & 0xf)];
samplerate_index = (id >> 10) & 0x3;
padding = (id >> 9) & 0x1;
bpf /= frequency[samplerate_index];
bpf += padding;
}
- tc = (Mpeg1MuxTimecode *) g_malloc(sizeof(Mpeg1MuxTimecode));
+ tc = (Mpeg1MuxTimecode *) g_malloc (sizeof (Mpeg1MuxTimecode));
tc->length = bpf;
tc->original_length = tc->length;
tc->frame_type = FRAME_TYPE_AUDIO;
mb->current_start = offset + bpf;
- mb->info.audio.samples_per_second = (double)dfrequency [mb->info.audio.frequency];
+ mb->info.audio.samples_per_second =
+ (double) dfrequency[mb->info.audio.frequency];
- mb->info.audio.current_PTS = (mb->info.audio.decoding_order * samples [mb->info.audio.layer]) /
- mb->info.audio.samples_per_second * 90. ;
+ mb->info.audio.current_PTS =
+ (mb->info.audio.decoding_order * samples[mb->info.audio.layer]) /
+ mb->info.audio.samples_per_second * 90.;
tc->DTS = tc->PTS = mb->info.audio.current_PTS;
- GST_DEBUG ("mpeg1mux::update_audio_info: PTS %" G_GUINT64_FORMAT ", %" G_GUINT64_FORMAT " length %lu", mb->info.audio.current_PTS, tc->PTS, tc->length);
- mb->timecode_list = g_list_append(mb->timecode_list, tc);
+ GST_DEBUG ("mpeg1mux::update_audio_info: PTS %" G_GUINT64_FORMAT ", %"
+ G_GUINT64_FORMAT " length %lu", mb->info.audio.current_PTS, tc->PTS,
+ tc->length);
+ mb->timecode_list = g_list_append (mb->timecode_list, tc);
mb->info.audio.decoding_order++;
offset += tc->length;
#include <gst/gst.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define MPEG1MUX_BUFFER_QUEUED(mb) (g_list_length((mb)->timecode_list))
#define MPEG1MUX_BUFFER_SPACE(mb) ((mb)->length)
#define FRAME_TYPE_PFRAME 3
#define FRAME_TYPE_AUDIO 4
-typedef struct _Mpeg1MuxBuffer Mpeg1MuxBuffer;
-typedef struct _Mpeg1MuxTimecode Mpeg1MuxTimecode;
-
-typedef struct video_struc /* Informationen ueber Video Stream */
-{
- unsigned int stream_length ;
- unsigned int num_sequence ;
- unsigned int num_seq_end ;
- unsigned int num_pictures ;
- unsigned int num_groups ;
- unsigned int num_frames[4] ;
- unsigned int avg_frames[4] ;
-
- unsigned int horizontal_size;
- unsigned int vertical_size ;
- unsigned int aspect_ratio ;
- unsigned int picture_rate ;
- unsigned int bit_rate ;
- unsigned int comp_bit_rate ;
- unsigned int vbv_buffer_size;
- unsigned int CSPF ;
-
- guint64 PTS;
- guint64 DTS;
-
- guint64 current_PTS;
- guint64 current_DTS;
- guchar current_type;
-
- double secs_per_frame;
- gulong group_order, decoding_order;
-} Video_struc;
-
-typedef struct audio_struc /* Informationen ueber Audio Stream */
-{
- unsigned int stream_length ;
- unsigned int num_syncword ;
- unsigned int num_frames [2] ;
- unsigned int framesize ;
- unsigned int layer ;
- unsigned int protection ;
- unsigned int bit_rate ;
- unsigned int frequency ;
- unsigned int mode ;
- unsigned int mode_extension ;
- unsigned int copyright ;
- unsigned int original_copy ;
- unsigned int emphasis ;
-
- guint64 PTS;
-
- guint64 current_PTS;
-
- double samples_per_second;
- gulong decoding_order;
-} Audio_struc;
-
-struct _Mpeg1MuxTimecode {
- gulong length;
- gulong original_length;
- guchar frame_type;
- guint64 PTS;
- guint64 DTS;
-};
-
-struct _Mpeg1MuxBuffer {
- unsigned char *buffer;
- gulong length;
- gulong base;
- gulong scan_pos;
- gulong last_pos;
- gulong current_start;
- guchar buffer_type;
- guchar stream_id;
- gboolean new_frame;
- guint64 next_frame_time;
-
- union {
- Video_struc video;
- Audio_struc audio;
- } info;
-
- GList *timecode_list;
- GList *queued_list;
-};
-
-Mpeg1MuxBuffer *mpeg1mux_buffer_new(guchar type, guchar id);
-
-void mpeg1mux_buffer_queue(Mpeg1MuxBuffer *mb, GstBuffer *buf);
-void mpeg1mux_buffer_shrink(Mpeg1MuxBuffer *mb, gulong size);
-gulong mpeg1mux_buffer_update_queued(Mpeg1MuxBuffer *mb, guint64 scr);
+ typedef struct _Mpeg1MuxBuffer Mpeg1MuxBuffer;
+ typedef struct _Mpeg1MuxTimecode Mpeg1MuxTimecode;
+
+ typedef struct video_struc /* Informationen ueber Video Stream */
+ {
+ unsigned int stream_length;
+ unsigned int num_sequence;
+ unsigned int num_seq_end;
+ unsigned int num_pictures;
+ unsigned int num_groups;
+ unsigned int num_frames[4];
+ unsigned int avg_frames[4];
+
+ unsigned int horizontal_size;
+ unsigned int vertical_size;
+ unsigned int aspect_ratio;
+ unsigned int picture_rate;
+ unsigned int bit_rate;
+ unsigned int comp_bit_rate;
+ unsigned int vbv_buffer_size;
+ unsigned int CSPF;
+
+ guint64 PTS;
+ guint64 DTS;
+
+ guint64 current_PTS;
+ guint64 current_DTS;
+ guchar current_type;
+
+ double secs_per_frame;
+ gulong group_order, decoding_order;
+ } Video_struc;
+
+ typedef struct audio_struc /* Informationen ueber Audio Stream */
+ {
+ unsigned int stream_length;
+ unsigned int num_syncword;
+ unsigned int num_frames[2];
+ unsigned int framesize;
+ unsigned int layer;
+ unsigned int protection;
+ unsigned int bit_rate;
+ unsigned int frequency;
+ unsigned int mode;
+ unsigned int mode_extension;
+ unsigned int copyright;
+ unsigned int original_copy;
+ unsigned int emphasis;
+
+ guint64 PTS;
+
+ guint64 current_PTS;
+
+ double samples_per_second;
+ gulong decoding_order;
+ } Audio_struc;
+
+ struct _Mpeg1MuxTimecode
+ {
+ gulong length;
+ gulong original_length;
+ guchar frame_type;
+ guint64 PTS;
+ guint64 DTS;
+ };
+
+ struct _Mpeg1MuxBuffer
+ {
+ unsigned char *buffer;
+ gulong length;
+ gulong base;
+ gulong scan_pos;
+ gulong last_pos;
+ gulong current_start;
+ guchar buffer_type;
+ guchar stream_id;
+ gboolean new_frame;
+ guint64 next_frame_time;
+
+ union
+ {
+ Video_struc video;
+ Audio_struc audio;
+ } info;
+
+ GList *timecode_list;
+ GList *queued_list;
+ };
+
+ Mpeg1MuxBuffer *mpeg1mux_buffer_new (guchar type, guchar id);
+
+ void mpeg1mux_buffer_queue (Mpeg1MuxBuffer * mb, GstBuffer * buf);
+ void mpeg1mux_buffer_shrink (Mpeg1MuxBuffer * mb, gulong size);
+ gulong mpeg1mux_buffer_update_queued (Mpeg1MuxBuffer * mb, guint64 scr);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __BUFFER_H__ */
+#endif /* __BUFFER_H__ */
};
/* GstMPEG1SystemEncode signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
/* FILL ME */
};
-static GstStaticPadTemplate src_factory =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("video/mpeg, "
- "systemstream = (boolean) TRUE")
-);
+static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/mpeg, " "systemstream = (boolean) TRUE")
+ );
static GstStaticPadTemplate video_sink_factory =
-GST_STATIC_PAD_TEMPLATE (
- "video_%d",
- GST_PAD_SINK,
- GST_PAD_REQUEST,
- GST_STATIC_CAPS ("video/mpeg, "
- "mpegversion = (int) 1, "
- "systemstream = (boolean) FALSE")
-);
+GST_STATIC_PAD_TEMPLATE ("video_%d",
+ GST_PAD_SINK,
+ GST_PAD_REQUEST,
+ GST_STATIC_CAPS ("video/mpeg, "
+ "mpegversion = (int) 1, " "systemstream = (boolean) FALSE")
+ );
static GstStaticPadTemplate audio_sink_factory =
-GST_STATIC_PAD_TEMPLATE (
- "audio_%d",
- GST_PAD_SINK,
- GST_PAD_REQUEST,
- GST_STATIC_CAPS ("audio/mpeg, "
- "mpegversion = (int) 1, "
- "layer = (int) [ 1, 2 ] "
- )
-);
-
-static void gst_system_encode_class_init (GstMPEG1SystemEncodeClass *klass);
-static void gst_system_encode_base_init (GstMPEG1SystemEncodeClass *klass);
-static void gst_system_encode_init (GstMPEG1SystemEncode *system_encode);
-
-static GstPad* gst_system_encode_request_new_pad (GstElement *element, GstPadTemplate *templ,
- const gchar *unused);
-static void gst_system_encode_chain (GstPad *pad, GstData *_data);
-
-static void gst_system_encode_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_system_encode_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+GST_STATIC_PAD_TEMPLATE ("audio_%d",
+ GST_PAD_SINK,
+ GST_PAD_REQUEST,
+ GST_STATIC_CAPS ("audio/mpeg, "
+ "mpegversion = (int) 1, " "layer = (int) [ 1, 2 ] ")
+ );
+
+static void gst_system_encode_class_init (GstMPEG1SystemEncodeClass * klass);
+static void gst_system_encode_base_init (GstMPEG1SystemEncodeClass * klass);
+static void gst_system_encode_init (GstMPEG1SystemEncode * system_encode);
+
+static GstPad *gst_system_encode_request_new_pad (GstElement * element,
+ GstPadTemplate * templ, const gchar * unused);
+static void gst_system_encode_chain (GstPad * pad, GstData * _data);
+
+static void gst_system_encode_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_system_encode_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_system_encode_signals[LAST_SIGNAL] = { 0 }; */
GType
if (!system_encode_type) {
static const GTypeInfo system_encode_info = {
- sizeof(GstMPEG1SystemEncodeClass),
- (GBaseInitFunc)gst_system_encode_base_init,
+ sizeof (GstMPEG1SystemEncodeClass),
+ (GBaseInitFunc) gst_system_encode_base_init,
NULL,
- (GClassInitFunc)gst_system_encode_class_init,
+ (GClassInitFunc) gst_system_encode_class_init,
NULL,
NULL,
- sizeof(GstMPEG1SystemEncode),
+ sizeof (GstMPEG1SystemEncode),
0,
- (GInstanceInitFunc)gst_system_encode_init,
+ (GInstanceInitFunc) gst_system_encode_init,
NULL
};
- system_encode_type = g_type_register_static(GST_TYPE_ELEMENT, "GstMPEG1SystemEncode", &system_encode_info, 0);
+ system_encode_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstMPEG1SystemEncode",
+ &system_encode_info, 0);
}
return system_encode_type;
}
static void
-gst_system_encode_base_init (GstMPEG1SystemEncodeClass *klass)
+gst_system_encode_base_init (GstMPEG1SystemEncodeClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&src_factory));
+ gst_static_pad_template_get (&src_factory));
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&audio_sink_factory));
+ gst_static_pad_template_get (&audio_sink_factory));
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&video_sink_factory));
+ gst_static_pad_template_get (&video_sink_factory));
gst_element_class_set_details (element_class, &system_encode_details);
}
static void
-gst_system_encode_class_init (GstMPEG1SystemEncodeClass *klass)
+gst_system_encode_class_init (GstMPEG1SystemEncodeClass * 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);
gobject_class->set_property = gst_system_encode_set_property;
gobject_class->get_property = gst_system_encode_get_property;
}
static void
-gst_system_encode_init (GstMPEG1SystemEncode *system_encode)
+gst_system_encode_init (GstMPEG1SystemEncode * system_encode)
{
- system_encode->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&src_factory), "src");
+ system_encode->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get (&src_factory),
+ "src");
gst_element_add_pad (GST_ELEMENT (system_encode), system_encode->srcpad);
system_encode->video_buffer = mpeg1mux_buffer_new (BUFFER_TYPE_VIDEO, 0xE0);
system_encode->have_setup = FALSE;
system_encode->mta = NULL;
system_encode->packet_size = 2048;
- system_encode->lock = g_mutex_new();
+ system_encode->lock = g_mutex_new ();
system_encode->current_pack = system_encode->packets_per_pack = 3;
system_encode->video_delay_ms = 0;
system_encode->audio_delay_ms = 0;
}
-static GstPad*
-gst_system_encode_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar *unused)
+static GstPad *
+gst_system_encode_request_new_pad (GstElement * element, GstPadTemplate * templ,
+ const gchar * unused)
{
GstMPEG1SystemEncode *system_encode;
gchar *name = NULL;
name = g_strdup_printf ("audio_%02d", system_encode->num_audio_pads);
g_print ("%s\n", name);
newpad = gst_pad_new_from_template (templ, name);
- gst_pad_set_element_private (newpad, GINT_TO_POINTER (system_encode->num_audio_pads));
+ gst_pad_set_element_private (newpad,
+ GINT_TO_POINTER (system_encode->num_audio_pads));
system_encode->audio_pad[system_encode->num_audio_pads] = newpad;
system_encode->num_audio_pads++;
system_encode->which_streams |= STREAMS_AUDIO;
- }
- else if (templ == gst_static_pad_template_get (&video_sink_factory)) {
+ } else if (templ == gst_static_pad_template_get (&video_sink_factory)) {
name = g_strdup_printf ("video_%02d", system_encode->num_video_pads);
g_print ("%s\n", name);
newpad = gst_pad_new_from_template (templ, name);
- gst_pad_set_element_private (newpad, GINT_TO_POINTER (system_encode->num_video_pads));
+ gst_pad_set_element_private (newpad,
+ GINT_TO_POINTER (system_encode->num_video_pads));
system_encode->video_pad[system_encode->num_video_pads] = newpad;
system_encode->num_video_pads++;
system_encode->which_streams |= STREAMS_VIDEO;
- }
- else {
+ } else {
g_warning ("system_encode: this is not our template!\n");
return NULL;
}
}
/* return a list of all the highest prioripty streams */
-static GList*
-gst_system_encode_pick_streams (GList *mta, GstMPEG1SystemEncode *system_encode)
+static GList *
+gst_system_encode_pick_streams (GList * mta,
+ GstMPEG1SystemEncode * system_encode)
{
guint64 lowest = ~1;
- GST_DEBUG ("pick_streams: %" G_GINT64_FORMAT ", %" G_GINT64_FORMAT, system_encode->video_buffer->next_frame_time,
- system_encode->audio_buffer->next_frame_time);
+ GST_DEBUG ("pick_streams: %" G_GINT64_FORMAT ", %" G_GINT64_FORMAT,
+ system_encode->video_buffer->next_frame_time,
+ system_encode->audio_buffer->next_frame_time);
if (system_encode->which_streams & STREAMS_VIDEO) {
- if (system_encode->video_buffer->next_frame_time < lowest-system_encode->video_delay) {
+ if (system_encode->video_buffer->next_frame_time <
+ lowest - system_encode->video_delay) {
lowest = system_encode->video_buffer->next_frame_time;
}
}
if (system_encode->which_streams & STREAMS_AUDIO) {
- if (system_encode->audio_buffer->next_frame_time < lowest-system_encode->audio_delay) {
+ if (system_encode->audio_buffer->next_frame_time <
+ lowest - system_encode->audio_delay) {
lowest = system_encode->audio_buffer->next_frame_time;
}
}
if (system_encode->which_streams & STREAMS_VIDEO) {
if (system_encode->video_buffer->next_frame_time == lowest) {
- mta = g_list_append(mta, system_encode->video_buffer);
+ mta = g_list_append (mta, system_encode->video_buffer);
}
}
if (system_encode->which_streams & STREAMS_AUDIO) {
if (system_encode->audio_buffer->next_frame_time == lowest) {
- mta = g_list_append(mta, system_encode->audio_buffer);
+ mta = g_list_append (mta, system_encode->audio_buffer);
}
}
return mta;
}
static gboolean
-gst_system_encode_have_data (GstMPEG1SystemEncode *system_encode)
+gst_system_encode_have_data (GstMPEG1SystemEncode * system_encode)
{
if (system_encode->which_streams == (STREAMS_VIDEO | STREAMS_AUDIO)) {
- if (MPEG1MUX_BUFFER_QUEUED(system_encode->audio_buffer) > 2 &&
- MPEG1MUX_BUFFER_SPACE(system_encode->audio_buffer) > system_encode->packet_size*2 &&
- MPEG1MUX_BUFFER_QUEUED(system_encode->video_buffer) > 2 &&
- MPEG1MUX_BUFFER_SPACE(system_encode->video_buffer) > system_encode->packet_size*2) {
+ if (MPEG1MUX_BUFFER_QUEUED (system_encode->audio_buffer) > 2 &&
+ MPEG1MUX_BUFFER_SPACE (system_encode->audio_buffer) >
+ system_encode->packet_size * 2
+ && MPEG1MUX_BUFFER_QUEUED (system_encode->video_buffer) > 2
+ && MPEG1MUX_BUFFER_SPACE (system_encode->video_buffer) >
+ system_encode->packet_size * 2) {
return TRUE;
}
}
if (system_encode->which_streams == STREAMS_VIDEO) {
- if (MPEG1MUX_BUFFER_QUEUED(system_encode->video_buffer) > 2 &&
- MPEG1MUX_BUFFER_SPACE(system_encode->video_buffer) > system_encode->packet_size*2) {
+ if (MPEG1MUX_BUFFER_QUEUED (system_encode->video_buffer) > 2 &&
+ MPEG1MUX_BUFFER_SPACE (system_encode->video_buffer) >
+ system_encode->packet_size * 2) {
return TRUE;
}
}
if (system_encode->which_streams == STREAMS_VIDEO) {
- if (MPEG1MUX_BUFFER_QUEUED(system_encode->audio_buffer) > 2 &&
- MPEG1MUX_BUFFER_SPACE(system_encode->audio_buffer) > system_encode->packet_size*2) {
+ if (MPEG1MUX_BUFFER_QUEUED (system_encode->audio_buffer) > 2 &&
+ MPEG1MUX_BUFFER_SPACE (system_encode->audio_buffer) >
+ system_encode->packet_size * 2) {
return TRUE;
}
}
return FALSE;
}
-static GList*
-gst_system_encode_update_mta (GstMPEG1SystemEncode *system_encode, GList *mta, gulong size)
+static GList *
+gst_system_encode_update_mta (GstMPEG1SystemEncode * system_encode, GList * mta,
+ gulong size)
{
- GList *streams = g_list_first(mta);
- Mpeg1MuxBuffer *mb = (Mpeg1MuxBuffer *)streams->data;
+ GList *streams = g_list_first (mta);
+ Mpeg1MuxBuffer *mb = (Mpeg1MuxBuffer *) streams->data;
GST_DEBUG ("system_encode::multiplex: update mta");
- mpeg1mux_buffer_shrink(mb, size);
+ mpeg1mux_buffer_shrink (mb, size);
- mta = g_list_remove(mta, mb);
+ mta = g_list_remove (mta, mb);
return mta;
}
static void
-gst_system_setup_multiplex (GstMPEG1SystemEncode *system_encode)
+gst_system_setup_multiplex (GstMPEG1SystemEncode * system_encode)
{
Mpeg1MuxTimecode *video_tc, *audio_tc;
- system_encode->audio_buffer_size = 4*1024;
- system_encode->video_buffer_size = 46*1024;
+ system_encode->audio_buffer_size = 4 * 1024;
+ system_encode->video_buffer_size = 46 * 1024;
system_encode->bytes_output = 0;
- system_encode->min_packet_data = system_encode->packet_size - PACK_HEADER_SIZE - SYS_HEADER_SIZE -
- PACKET_HEADER_SIZE - AFTER_PACKET_LENGTH;
- system_encode->max_packet_data = system_encode->packet_size - PACKET_HEADER_SIZE - AFTER_PACKET_LENGTH;
+ system_encode->min_packet_data =
+ system_encode->packet_size - PACK_HEADER_SIZE - SYS_HEADER_SIZE -
+ PACKET_HEADER_SIZE - AFTER_PACKET_LENGTH;
+ system_encode->max_packet_data =
+ system_encode->packet_size - PACKET_HEADER_SIZE - AFTER_PACKET_LENGTH;
if (system_encode->which_streams & STREAMS_VIDEO) {
- system_encode->video_rate = system_encode->video_buffer->info.video.bit_rate * 50;
- }
- else system_encode->video_rate = 0;
+ system_encode->video_rate =
+ system_encode->video_buffer->info.video.bit_rate * 50;
+ } else
+ system_encode->video_rate = 0;
if (system_encode->which_streams & STREAMS_AUDIO)
- system_encode->audio_rate = system_encode->audio_buffer->info.audio.bit_rate * 128;
- else system_encode->audio_rate = 0;
-
- system_encode->data_rate = system_encode->video_rate + system_encode->audio_rate;
-
- system_encode->dmux_rate = ceil((double)(system_encode->data_rate) *
- ((double)(system_encode->packet_size)/(double)(system_encode->min_packet_data) +
- ((double)(system_encode->packet_size)/(double)(system_encode->max_packet_data) *
- (double)(system_encode->packets_per_pack-1.))) / (double)(system_encode->packets_per_pack) );
- system_encode->data_rate = ceil(system_encode->dmux_rate/50.)*50;
-
- GST_DEBUG ("system_encode::multiplex: data_rate %u, video_rate: %u, audio_rate: %u", system_encode->data_rate,
- system_encode->video_rate, system_encode->audio_rate);
-
- system_encode->video_delay = (double)system_encode->video_delay_ms*(double)(CLOCKS/1000);
- system_encode->audio_delay = (double)system_encode->audio_delay_ms*(double)(CLOCKS/1000);
-
- system_encode->mux_rate = ceil(system_encode->dmux_rate/50.);
- system_encode->dmux_rate= system_encode->mux_rate * 50.;
-
- video_tc = MPEG1MUX_BUFFER_FIRST_TIMECODE(system_encode->video_buffer);
- audio_tc = MPEG1MUX_BUFFER_FIRST_TIMECODE(system_encode->audio_buffer);
-
- GST_DEBUG ("system_encode::video tc %" G_GINT64_FORMAT ", audio tc %" G_GINT64_FORMAT ":", video_tc->DTS, audio_tc->DTS);
-
- system_encode->delay = ((double)system_encode->sectors_delay +
- ceil((double)video_tc->length/(double)system_encode->min_packet_data) +
- ceil((double)video_tc->length/(double)system_encode->min_packet_data )) *
- (double)system_encode->packet_size/system_encode->dmux_rate*(double)CLOCKS;
+ system_encode->audio_rate =
+ system_encode->audio_buffer->info.audio.bit_rate * 128;
+ else
+ system_encode->audio_rate = 0;
+
+ system_encode->data_rate =
+ system_encode->video_rate + system_encode->audio_rate;
+
+ system_encode->dmux_rate = ceil ((double) (system_encode->data_rate) *
+ ((double) (system_encode->packet_size) /
+ (double) (system_encode->min_packet_data) +
+ ((double) (system_encode->packet_size) /
+ (double) (system_encode->max_packet_data) *
+ (double) (system_encode->packets_per_pack -
+ 1.))) / (double) (system_encode->packets_per_pack));
+ system_encode->data_rate = ceil (system_encode->dmux_rate / 50.) * 50;
+
+ GST_DEBUG
+ ("system_encode::multiplex: data_rate %u, video_rate: %u, audio_rate: %u",
+ system_encode->data_rate, system_encode->video_rate,
+ system_encode->audio_rate);
+
+ system_encode->video_delay =
+ (double) system_encode->video_delay_ms * (double) (CLOCKS / 1000);
+ system_encode->audio_delay =
+ (double) system_encode->audio_delay_ms * (double) (CLOCKS / 1000);
+
+ system_encode->mux_rate = ceil (system_encode->dmux_rate / 50.);
+ system_encode->dmux_rate = system_encode->mux_rate * 50.;
+
+ video_tc = MPEG1MUX_BUFFER_FIRST_TIMECODE (system_encode->video_buffer);
+ audio_tc = MPEG1MUX_BUFFER_FIRST_TIMECODE (system_encode->audio_buffer);
+
+ GST_DEBUG ("system_encode::video tc %" G_GINT64_FORMAT ", audio tc %"
+ G_GINT64_FORMAT ":", video_tc->DTS, audio_tc->DTS);
+
+ system_encode->delay = ((double) system_encode->sectors_delay +
+ ceil ((double) video_tc->length /
+ (double) system_encode->min_packet_data) +
+ ceil ((double) video_tc->length /
+ (double) system_encode->min_packet_data)) *
+ (double) system_encode->packet_size / system_encode->dmux_rate *
+ (double) CLOCKS;
system_encode->audio_delay += system_encode->delay;
system_encode->video_delay += system_encode->delay;
system_encode->video_delay = 0;
system_encode->delay = 0;
- GST_DEBUG ("system_encode::multiplex: delay %g, mux_rate: %lu", system_encode->delay, system_encode->mux_rate);
+ GST_DEBUG ("system_encode::multiplex: delay %g, mux_rate: %lu",
+ system_encode->delay, system_encode->mux_rate);
}
static void
-gst_system_encode_multiplex(GstMPEG1SystemEncode *system_encode)
+gst_system_encode_multiplex (GstMPEG1SystemEncode * system_encode)
{
GList *streams;
- Mpeg1MuxBuffer *mb = (Mpeg1MuxBuffer *)streams->data;
+ Mpeg1MuxBuffer *mb = (Mpeg1MuxBuffer *) streams->data;
guchar timestamps;
guchar buffer_scale;
GstBuffer *outbuf;
- Pack_struc *pack;
- Sys_header_struc *sys_header;
+ Pack_struc *pack;
+ Sys_header_struc *sys_header;
Mpeg1MuxTimecode *tc;
gulong buffer_size, non_scaled_buffer_size, total_queued;
guint64 PTS, DTS;
- g_mutex_lock(system_encode->lock);
+ g_mutex_lock (system_encode->lock);
- while (gst_system_encode_have_data(system_encode)) {
+ while (gst_system_encode_have_data (system_encode)) {
GST_DEBUG ("system_encode::multiplex: multiplexing");
if (!system_encode->have_setup) {
- gst_system_setup_multiplex(system_encode);
+ gst_system_setup_multiplex (system_encode);
system_encode->have_setup = TRUE;
}
if (system_encode->mta == NULL) {
- system_encode->mta = gst_system_encode_pick_streams(system_encode->mta, system_encode);
+ system_encode->mta =
+ gst_system_encode_pick_streams (system_encode->mta, system_encode);
}
- if (system_encode->mta == NULL) break;
+ if (system_encode->mta == NULL)
+ break;
- system_encode->SCR = (guint64)(system_encode->bytes_output+LAST_SCR_BYTE_IN_PACK)*CLOCKS/system_encode->dmux_rate;
+ system_encode->SCR =
+ (guint64) (system_encode->bytes_output +
+ LAST_SCR_BYTE_IN_PACK) * CLOCKS / system_encode->dmux_rate;
- streams = g_list_first(system_encode->mta);
- mb = (Mpeg1MuxBuffer *)streams->data;
+ streams = g_list_first (system_encode->mta);
+ mb = (Mpeg1MuxBuffer *) streams->data;
if (system_encode->current_pack == system_encode->packets_per_pack) {
- create_pack(system_encode->pack, system_encode->SCR, system_encode->mux_rate);
- create_sys_header (system_encode->sys_header, system_encode->mux_rate, 1, 1, 1, 1, 1, 1,
- AUDIO_STR_0, 0, system_encode->audio_buffer_size/128,
- VIDEO_STR_0, 1, system_encode->video_buffer_size/1024, system_encode->which_streams );
+ create_pack (system_encode->pack, system_encode->SCR,
+ system_encode->mux_rate);
+ create_sys_header (system_encode->sys_header, system_encode->mux_rate, 1,
+ 1, 1, 1, 1, 1, AUDIO_STR_0, 0, system_encode->audio_buffer_size / 128,
+ VIDEO_STR_0, 1, system_encode->video_buffer_size / 1024,
+ system_encode->which_streams);
system_encode->current_pack = 0;
pack = system_encode->pack;
sys_header = system_encode->sys_header;
- }
- else {
+ } else {
system_encode->current_pack++;
pack = NULL;
sys_header = NULL;
}
- tc = MPEG1MUX_BUFFER_FIRST_TIMECODE(mb);
+ tc = MPEG1MUX_BUFFER_FIRST_TIMECODE (mb);
if (mb->new_frame) {
GST_DEBUG ("system_encode::multiplex: new frame");
- if (tc->frame_type == FRAME_TYPE_AUDIO || tc->frame_type == FRAME_TYPE_IFRAME || tc->frame_type == FRAME_TYPE_PFRAME) {
- timestamps = TIMESTAMPS_PTS;
- }
- else {
- timestamps = TIMESTAMPS_PTS_DTS;
+ if (tc->frame_type == FRAME_TYPE_AUDIO
+ || tc->frame_type == FRAME_TYPE_IFRAME
+ || tc->frame_type == FRAME_TYPE_PFRAME) {
+ timestamps = TIMESTAMPS_PTS;
+ } else {
+ timestamps = TIMESTAMPS_PTS_DTS;
}
- }
- else {
+ } else {
timestamps = TIMESTAMPS_NO;
}
if (tc->frame_type != FRAME_TYPE_AUDIO) {
- if (tc->PTS<system_encode->startup_delay)
+ if (tc->PTS < system_encode->startup_delay)
system_encode->startup_delay = tc->PTS;
}
if (tc->frame_type == FRAME_TYPE_AUDIO) {
buffer_scale = 0;
non_scaled_buffer_size = system_encode->audio_buffer_size;
- buffer_size = system_encode->audio_buffer_size/128;
+ buffer_size = system_encode->audio_buffer_size / 128;
PTS = tc->PTS + system_encode->audio_delay + system_encode->startup_delay;
DTS = tc->PTS + system_encode->audio_delay + system_encode->startup_delay;
- }
- else {
+ } else {
buffer_scale = 1;
non_scaled_buffer_size = system_encode->video_buffer_size;
- buffer_size = system_encode->video_buffer_size/1024;
+ buffer_size = system_encode->video_buffer_size / 1024;
PTS = tc->PTS + system_encode->video_delay;
DTS = tc->DTS + system_encode->video_delay;
}
- total_queued = mpeg1mux_buffer_update_queued(mb, system_encode->SCR);
+ total_queued = mpeg1mux_buffer_update_queued (mb, system_encode->SCR);
if (non_scaled_buffer_size - total_queued >= system_encode->packet_size) {
/* write the pack/packet here */
create_sector (system_encode->sector, pack, sys_header,
- system_encode->packet_size,
- MPEG1MUX_BUFFER_DATA(mb), mb->stream_id, buffer_scale,
- buffer_size, TRUE, PTS, DTS,
- timestamps, system_encode->which_streams);
- /* update mta */
- system_encode->mta = gst_system_encode_update_mta(system_encode, system_encode->mta,
- system_encode->sector->length_of_packet_data);
- }
- else {
+ system_encode->packet_size,
+ MPEG1MUX_BUFFER_DATA (mb), mb->stream_id, buffer_scale,
+ buffer_size, TRUE, PTS, DTS,
+ timestamps, system_encode->which_streams);
+ /* update mta */
+ system_encode->mta =
+ gst_system_encode_update_mta (system_encode, system_encode->mta,
+ system_encode->sector->length_of_packet_data);
+ } else {
/* write a padding packet */
create_sector (system_encode->sector, pack, sys_header,
- system_encode->packet_size, NULL, PADDING_STR, 0,
- 0, FALSE, 0, 0,
- TIMESTAMPS_NO, system_encode->which_streams);
+ system_encode->packet_size, NULL, PADDING_STR, 0,
+ 0, FALSE, 0, 0, TIMESTAMPS_NO, system_encode->which_streams);
}
- outbuf = gst_buffer_new();
- GST_BUFFER_DATA(outbuf) = g_malloc(system_encode->sector->length_of_sector);
- GST_BUFFER_SIZE(outbuf) = system_encode->sector->length_of_sector;
- memcpy(GST_BUFFER_DATA(outbuf),system_encode->sector->buf, system_encode->sector->length_of_sector);
- system_encode->bytes_output += GST_BUFFER_SIZE(outbuf);
- gst_pad_push(system_encode->srcpad,GST_DATA (outbuf));
+ outbuf = gst_buffer_new ();
+ GST_BUFFER_DATA (outbuf) =
+ g_malloc (system_encode->sector->length_of_sector);
+ GST_BUFFER_SIZE (outbuf) = system_encode->sector->length_of_sector;
+ memcpy (GST_BUFFER_DATA (outbuf), system_encode->sector->buf,
+ system_encode->sector->length_of_sector);
+ system_encode->bytes_output += GST_BUFFER_SIZE (outbuf);
+ gst_pad_push (system_encode->srcpad, GST_DATA (outbuf));
GST_DEBUG ("system_encode::multiplex: writing %02x", mb->stream_id);
}
- gst_info("system_encode::multiplex: data left in video buffer %lu\n", MPEG1MUX_BUFFER_SPACE(system_encode->video_buffer));
- gst_info("system_encode::multiplex: data left in audio buffer %lu\n", MPEG1MUX_BUFFER_SPACE(system_encode->audio_buffer));
+ gst_info ("system_encode::multiplex: data left in video buffer %lu\n",
+ MPEG1MUX_BUFFER_SPACE (system_encode->video_buffer));
+ gst_info ("system_encode::multiplex: data left in audio buffer %lu\n",
+ MPEG1MUX_BUFFER_SPACE (system_encode->audio_buffer));
- g_mutex_unlock(system_encode->lock);
+ g_mutex_unlock (system_encode->lock);
}
static void
-gst_system_encode_chain (GstPad *pad, GstData *_data)
+gst_system_encode_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstMPEG1SystemEncode *system_encode;
const gchar *padname;
gint channel;
- g_return_if_fail(pad != NULL);
- g_return_if_fail(GST_IS_PAD(pad));
- g_return_if_fail(buf != NULL);
+ g_return_if_fail (pad != NULL);
+ g_return_if_fail (GST_IS_PAD (pad));
+ g_return_if_fail (buf != NULL);
system_encode = GST_SYSTEM_ENCODE (GST_OBJECT_PARENT (pad));
- data = GST_BUFFER_DATA(buf);
- size = GST_BUFFER_SIZE(buf);
+ data = GST_BUFFER_DATA (buf);
+ size = GST_BUFFER_SIZE (buf);
- GST_DEBUG ("system_encode::chain: system_encode: have buffer of size %lu",size);
+ GST_DEBUG ("system_encode::chain: system_encode: have buffer of size %lu",
+ size);
padname = GST_OBJECT_NAME (pad);
- if (strncmp(padname, "audio_", 6) == 0) {
- channel = atoi(&padname[6]);
- GST_DEBUG ("gst_system_encode_chain: got audio buffer in from audio channel %02d", channel);
+ if (strncmp (padname, "audio_", 6) == 0) {
+ channel = atoi (&padname[6]);
+ GST_DEBUG
+ ("gst_system_encode_chain: got audio buffer in from audio channel %02d",
+ channel);
- mpeg1mux_buffer_queue(system_encode->audio_buffer, buf);
- }
- else if (strncmp(padname, "video_", 6) == 0) {
- channel = atoi(&padname[6]);
- GST_DEBUG ("gst_system_encode_chain: got video buffer in from video channel %02d", channel);
+ mpeg1mux_buffer_queue (system_encode->audio_buffer, buf);
+ } else if (strncmp (padname, "video_", 6) == 0) {
+ channel = atoi (&padname[6]);
+ GST_DEBUG
+ ("gst_system_encode_chain: got video buffer in from video channel %02d",
+ channel);
- mpeg1mux_buffer_queue(system_encode->video_buffer, buf);
+ mpeg1mux_buffer_queue (system_encode->video_buffer, buf);
+ } else {
+ g_assert_not_reached ();
}
- else {
- g_assert_not_reached ();
- }
- gst_system_encode_multiplex(system_encode);
+ gst_system_encode_multiplex (system_encode);
- gst_buffer_unref(buf);
+ gst_buffer_unref (buf);
}
static void
-gst_system_encode_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_system_encode_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstMPEG1SystemEncode *system_encode;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_SYSTEM_ENCODE(object));
- system_encode = GST_SYSTEM_ENCODE(object);
+ g_return_if_fail (GST_IS_SYSTEM_ENCODE (object));
+ system_encode = GST_SYSTEM_ENCODE (object);
switch (prop_id) {
default:
}
static void
-gst_system_encode_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_system_encode_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstMPEG1SystemEncode *src;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_SYSTEM_ENCODE(object));
- src = GST_SYSTEM_ENCODE(object);
+ g_return_if_fail (GST_IS_SYSTEM_ENCODE (object));
+ src = GST_SYSTEM_ENCODE (object);
switch (prop_id) {
default:
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
/* this filter needs the getbits functions */
if (!gst_library_load ("gstgetbits"))
return FALSE;
return gst_element_register (plugin, "system_encode",
- GST_RANK_NONE, GST_TYPE_SYSTEM_ENCODE);
+ GST_RANK_NONE, GST_TYPE_SYSTEM_ENCODE);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "system_encode",
- "MPEG-1 system stream encoder",
- plugin_init,
- VERSION,
- "GPL",
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "system_encode",
+ "MPEG-1 system stream encoder",
+ plugin_init, VERSION, "GPL", GST_PACKAGE, GST_ORIGIN)
#include "main.h"
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_SYSTEM_ENCODE \
#define GST_IS_SYSTEM_ENCODE_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SYSTEM_ENCODE))
-typedef struct _GstMPEG1SystemEncode GstMPEG1SystemEncode;
-typedef struct _GstMPEG1SystemEncodeClass GstMPEG1SystemEncodeClass;
+ typedef struct _GstMPEG1SystemEncode GstMPEG1SystemEncode;
+ typedef struct _GstMPEG1SystemEncodeClass GstMPEG1SystemEncodeClass;
-struct _GstMPEG1SystemEncode {
- GstElement element;
+ struct _GstMPEG1SystemEncode
+ {
+ GstElement element;
- GstPad *srcpad;
+ GstPad *srcpad;
- gboolean have_setup;
+ gboolean have_setup;
- GMutex *lock;
+ GMutex *lock;
- guint num_audio_pads;
- guint num_video_pads;
+ guint num_audio_pads;
+ guint num_video_pads;
- Mpeg1MuxBuffer *audio_buffer;
- Mpeg1MuxBuffer *video_buffer;
+ Mpeg1MuxBuffer *audio_buffer;
+ Mpeg1MuxBuffer *video_buffer;
- Pack_struc *pack;
- Sys_header_struc *sys_header;
- Sector_struc *sector;
+ Pack_struc *pack;
+ Sys_header_struc *sys_header;
+ Sector_struc *sector;
- guint data_rate, video_rate, audio_rate;
- gdouble delay, audio_delay, video_delay;
- gdouble clock_cycles;
- gulong sectors_delay, video_delay_ms, audio_delay_ms;
- gulong startup_delay;
- gulong audio_buffer_size;
- gulong video_buffer_size;
- gulong mux_rate, dmux_rate;
- guint64 SCR;
- gint which_streams;
+ guint data_rate, video_rate, audio_rate;
+ gdouble delay, audio_delay, video_delay;
+ gdouble clock_cycles;
+ gulong sectors_delay, video_delay_ms, audio_delay_ms;
+ gulong startup_delay;
+ gulong audio_buffer_size;
+ gulong video_buffer_size;
+ gulong mux_rate, dmux_rate;
+ guint64 SCR;
+ gint which_streams;
- gint current_pack;
- gulong min_packet_data;
- gulong max_packet_data;
- gint packets_per_pack;
- gulong packet_size;
- gulong bytes_output;
+ gint current_pack;
+ gulong min_packet_data;
+ gulong max_packet_data;
+ gint packets_per_pack;
+ gulong packet_size;
+ gulong bytes_output;
- GList *mta;
+ GList *mta;
- /* stream input pads */
- GstPad *private_1_pad[8]; /* up to 8 ac3 audio tracks <grumble> */
- GstPad *private_2_pad;
- GstPad *video_pad[16];
- GstPad *audio_pad[32];
-};
+ /* stream input pads */
+ GstPad *private_1_pad[8]; /* up to 8 ac3 audio tracks <grumble> */
+ GstPad *private_2_pad;
+ GstPad *video_pad[16];
+ GstPad *audio_pad[32];
+ };
-struct _GstMPEG1SystemEncodeClass {
- GstElementClass parent_class;
-};
+ struct _GstMPEG1SystemEncodeClass
+ {
+ GstElementClass parent_class;
+ };
-GType gst_mpeg1_system_encode_get_type(void);
+ GType gst_mpeg1_system_encode_get_type (void);
/* multplex.c */
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __SYSTEM_ENCODE_H__ */
+#endif /* __SYSTEM_ENCODE_H__ */
#define ISO11172_END 0x000001b9
#define PACKET_START 0x000001
-#define CLOCKS 90000.0 /* System Clock Hertz */
+#define CLOCKS 90000.0 /* System Clock Hertz */
-#define AFTER_PACKET_LENGTH 15 /* No of non-data-bytes */
- /* following the packet */
- /* length field */
-#define LAST_SCR_BYTE_IN_PACK 9 /* No of bytes in pack */
- /* preceding, and */
- /* including, the SCR */
+#define AFTER_PACKET_LENGTH 15 /* No of non-data-bytes */
+ /* following the packet */
+ /* length field */
+#define LAST_SCR_BYTE_IN_PACK 9 /* No of bytes in pack */
+ /* preceding, and */
+ /* including, the SCR */
/* The following values for sys_header_length & size are only valid for */
/* System streams consisting of two basic streams. When wrapping around */
/* the system layer on a single video or a single audio stream, those */
/* values get decreased by 3. */
-#define SYS_HEADER_LENGTH 12 /* length of Sys Header */
- /* after start code and */
- /* length field */
+#define SYS_HEADER_LENGTH 12 /* length of Sys Header */
+ /* after start code and */
+ /* length field */
-#define SYS_HEADER_SIZE 18 /* incl. start code and */
- /* length field */
+#define SYS_HEADER_SIZE 18 /* incl. start code and */
+ /* length field */
#define PACK_HEADER_SIZE 12
#define PACKET_HEADER_SIZE 6
-#define MAX_SECTOR_SIZE 0x20000 /* Max Sektor Groesse */
+#define MAX_SECTOR_SIZE 0x20000 /* Max Sektor Groesse */
#define STREAMS_VIDEO 1
#define STREAMS_AUDIO 2
#define STREAMS_BOTH 3
-#define AUDIO_STREAMS 0xb8 /* Marker Audio Streams */
-#define VIDEO_STREAMS 0xb9 /* Marker Video Streams */
-#define AUDIO_STR_0 0xc0 /* Marker Audio Stream0 */
-#define VIDEO_STR_0 0xe0 /* Marker Video Stream0 */
-#define PADDING_STR 0xbe /* Marker Padding Stream*/
+#define AUDIO_STREAMS 0xb8 /* Marker Audio Streams */
+#define VIDEO_STREAMS 0xb9 /* Marker Video Streams */
+#define AUDIO_STR_0 0xc0 /* Marker Audio Stream0 */
+#define VIDEO_STR_0 0xe0 /* Marker Video Stream0 */
+#define PADDING_STR 0xbe /* Marker Padding Stream */
#define ZERO_STUFFING_BYTE 0
#define STUFFING_BYTE 0xff
#define RESERVED_BYTE 0xff
-#define TIMESTAMPS_NO 0 /* Flag NO timestamps */
-#define TIMESTAMPS_PTS 1 /* Flag PTS timestamp */
-#define TIMESTAMPS_PTS_DTS 2 /* Flag BOTH timestamps */
+#define TIMESTAMPS_NO 0 /* Flag NO timestamps */
+#define TIMESTAMPS_PTS 1 /* Flag PTS timestamp */
+#define TIMESTAMPS_PTS_DTS 2 /* Flag BOTH timestamps */
-#define MARKER_SCR 2 /* Marker SCR */
-#define MARKER_JUST_PTS 2 /* Marker only PTS */
-#define MARKER_PTS 3 /* Marker PTS */
-#define MARKER_DTS 1 /* Marker DTS */
-#define MARKER_NO_TIMESTAMPS 0x0f /* Marker NO timestamps */
+#define MARKER_SCR 2 /* Marker SCR */
+#define MARKER_JUST_PTS 2 /* Marker only PTS */
+#define MARKER_PTS 3 /* Marker PTS */
+#define MARKER_DTS 1 /* Marker DTS */
+#define MARKER_NO_TIMESTAMPS 0x0f /* Marker NO timestamps */
-#define STATUS_AUDIO_END 0 /* Statusmessage A end */
-#define STATUS_VIDEO_END 1 /* Statusmessage V end */
-#define STATUS_AUDIO_TIME_OUT 2 /* Statusmessage A out */
-#define STATUS_VIDEO_TIME_OUT 3 /* Statusmessage V out */
+#define STATUS_AUDIO_END 0 /* Statusmessage A end */
+#define STATUS_VIDEO_END 1 /* Statusmessage V end */
+#define STATUS_AUDIO_TIME_OUT 2 /* Statusmessage A out */
+#define STATUS_VIDEO_TIME_OUT 3 /* Statusmessage V out */
/*************************************************************************
Typ- und Strukturdefinitionen
*************************************************************************/
-typedef struct sector_struc /* A sector, can contain pack, sys header */
- /* and packet. */
-{ unsigned char buf [MAX_SECTOR_SIZE] ;
- unsigned int length_of_sector ;
- unsigned int length_of_packet_data ;
- guint64 TS ;
+typedef struct sector_struc /* A sector, can contain pack, sys header */
+ /* and packet. */
+{
+ unsigned char buf[MAX_SECTOR_SIZE];
+ unsigned int length_of_sector;
+ unsigned int length_of_packet_data;
+ guint64 TS;
} Sector_struc;
-typedef struct pack_struc /* Pack Info */
-{ unsigned char buf [PACK_HEADER_SIZE];
- guint64 SCR;
+typedef struct pack_struc /* Pack Info */
+{
+ unsigned char buf[PACK_HEADER_SIZE];
+ guint64 SCR;
} Pack_struc;
-typedef struct sys_header_struc /* System Header Info */
-{ unsigned char buf [SYS_HEADER_SIZE];
+typedef struct sys_header_struc /* System Header Info */
+{
+ unsigned char buf[SYS_HEADER_SIZE];
} Sys_header_struc;
/*************************************************************************
*************************************************************************/
/* systems.c */
-void create_sector (Sector_struc *sector, Pack_struc *pack, Sys_header_struc *sys_header,
- unsigned int packet_size, unsigned char *inputbuffer, unsigned char type, unsigned char buffer_scale,
- unsigned int buffer_size, unsigned char buffers, guint64 PTS, guint64 DTS,
- unsigned char timestamps, unsigned int which_streams);
-
-void create_pack (Pack_struc *pack, guint64 SCR, unsigned int mux_rate);
-
-void create_sys_header (Sys_header_struc *sys_header, unsigned int rate_bound, unsigned char audio_bound,
- unsigned char fixed, unsigned char CSPS, unsigned char audio_lock, unsigned char video_lock,
- unsigned char video_bound, unsigned char stream1, unsigned char buffer1_scale, unsigned int buffer1_size,
- unsigned char stream2, unsigned char buffer2_scale, unsigned int buffer2_size, unsigned int which_streams);
+void create_sector (Sector_struc * sector, Pack_struc * pack,
+ Sys_header_struc * sys_header, unsigned int packet_size,
+ unsigned char *inputbuffer, unsigned char type, unsigned char buffer_scale,
+ unsigned int buffer_size, unsigned char buffers, guint64 PTS, guint64 DTS,
+ unsigned char timestamps, unsigned int which_streams);
+
+void create_pack (Pack_struc * pack, guint64 SCR, unsigned int mux_rate);
+
+void create_sys_header (Sys_header_struc * sys_header, unsigned int rate_bound,
+ unsigned char audio_bound, unsigned char fixed, unsigned char CSPS,
+ unsigned char audio_lock, unsigned char video_lock,
+ unsigned char video_bound, unsigned char stream1,
+ unsigned char buffer1_scale, unsigned int buffer1_size,
+ unsigned char stream2, unsigned char buffer2_scale,
+ unsigned int buffer2_size, unsigned int which_streams);
#endif
#include "main.h"
-static void buffer_timecode (timecode, marker, buffer)
-guint64 timecode;
-unsigned char marker;
-unsigned char **buffer;
+static void
+buffer_timecode (timecode, marker, buffer)
+ guint64 timecode;
+ unsigned char marker;
+ unsigned char **buffer;
{
unsigned char temp;
- temp = (marker << 4) | ((timecode>>29) & 0x38) |
- ((timecode >> 29) & 0x6) | 1;
- *((*buffer)++)=temp;
+ temp = (marker << 4) | ((timecode >> 29) & 0x38) |
+ ((timecode >> 29) & 0x6) | 1;
+ *((*buffer)++) = temp;
temp = (timecode & 0x3fc00000) >> 22;
- *((*buffer)++)=temp;
+ *((*buffer)++) = temp;
temp = ((timecode & 0x003f8000) >> 14) | 1;
- *((*buffer)++)=temp;
+ *((*buffer)++) = temp;
temp = (timecode & 0x7f80) >> 7;
- *((*buffer)++)=temp;
+ *((*buffer)++) = temp;
temp = ((timecode & 0x007f) << 1) | 1;
- *((*buffer)++)=temp;
+ *((*buffer)++) = temp;
}
/*************************************************************************
*************************************************************************/
-void create_sector (sector, pack, sys_header,
- packet_size, inputbuffer, type,
- buffer_scale, buffer_size, buffers,
- PTS, DTS, timestamps, which_streams )
+void
+create_sector (sector, pack, sys_header,
+ packet_size, inputbuffer, type,
+ buffer_scale, buffer_size, buffers, PTS, DTS, timestamps, which_streams)
-Sector_struc *sector;
-Pack_struc *pack;
-Sys_header_struc *sys_header;
-unsigned int packet_size;
-unsigned char *inputbuffer;
+ Sector_struc *sector;
+ Pack_struc *pack;
+ Sys_header_struc *sys_header;
+ unsigned int packet_size;
+ unsigned char *inputbuffer;
-unsigned char type;
-unsigned char buffer_scale;
-unsigned int buffer_size;
-unsigned char buffers;
-guint64 PTS;
-guint64 DTS;
-unsigned char timestamps;
-unsigned int which_streams;
+ unsigned char type;
+ unsigned char buffer_scale;
+ unsigned int buffer_size;
+ unsigned char buffers;
+ guint64 PTS;
+ guint64 DTS;
+ unsigned char timestamps;
+ unsigned int which_streams;
{
- int i,j,tmp;
- unsigned char *index;
- unsigned char *size_offset;
+ int i, j, tmp;
+ unsigned char *index;
+ unsigned char *size_offset;
- /* printf("creating sector\n"); */
+ /* printf("creating sector\n"); */
- index = sector->buf;
- sector->length_of_sector=0;
+ index = sector->buf;
+ sector->length_of_sector = 0;
/* Should we copy Pack Header information ? */
- if (pack != NULL)
- {
- i = sizeof(pack->buf);
- bcopy (pack->buf, index, i);
- index += i;
- sector->length_of_sector += i;
- }
+ if (pack != NULL) {
+ i = sizeof (pack->buf);
+ bcopy (pack->buf, index, i);
+ index += i;
+ sector->length_of_sector += i;
+ }
/* Should we copy System Header information ? */
- if (sys_header != NULL)
- {
- i = sizeof(sys_header->buf);
+ if (sys_header != NULL) {
+ i = sizeof (sys_header->buf);
- /* only one stream? 3 bytes less in sys header */
- if (which_streams != STREAMS_BOTH) i -= 3;
+ /* only one stream? 3 bytes less in sys header */
+ if (which_streams != STREAMS_BOTH)
+ i -= 3;
- bcopy (sys_header->buf, index, i);
- index += i;
- sector->length_of_sector += i;
- }
+ bcopy (sys_header->buf, index, i);
+ index += i;
+ sector->length_of_sector += i;
+ }
- /* write constant packet header data */
+ /* write constant packet header data */
- *(index++) = (unsigned char)(PACKET_START)>>16;
- *(index++) = (unsigned char)(PACKET_START & 0x00ffff)>>8;
- *(index++) = (unsigned char)(PACKET_START & 0x0000ff);
- *(index++) = type;
+ *(index++) = (unsigned char) (PACKET_START) >> 16;
+ *(index++) = (unsigned char) (PACKET_START & 0x00ffff) >> 8;
+ *(index++) = (unsigned char) (PACKET_START & 0x0000ff);
+ *(index++) = type;
- /* we remember this offset in case we will have to shrink this packet */
-
- size_offset = index;
- *(index++) = (unsigned char)((packet_size - PACKET_HEADER_SIZE)>>8);
- *(index++) = (unsigned char)((packet_size - PACKET_HEADER_SIZE)&0xff);
+ /* we remember this offset in case we will have to shrink this packet */
- *(index++) = STUFFING_BYTE;
- *(index++) = STUFFING_BYTE;
- *(index++) = STUFFING_BYTE;
+ size_offset = index;
+ *(index++) = (unsigned char) ((packet_size - PACKET_HEADER_SIZE) >> 8);
+ *(index++) = (unsigned char) ((packet_size - PACKET_HEADER_SIZE) & 0xff);
- i = 0;
+ *(index++) = STUFFING_BYTE;
+ *(index++) = STUFFING_BYTE;
+ *(index++) = STUFFING_BYTE;
- if (!buffers) i +=2;
- if (timestamps == TIMESTAMPS_NO) i+=9;
- else if (timestamps == TIMESTAMPS_PTS) i+=5;
+ i = 0;
- /* printf("%i stuffing %d\n", i, timestamps); */
-
- for (j=0; j<i; j++)
- *(index++) = STUFFING_BYTE;
+ if (!buffers)
+ i += 2;
+ if (timestamps == TIMESTAMPS_NO)
+ i += 9;
+ else if (timestamps == TIMESTAMPS_PTS)
+ i += 5;
- /* should we write buffer info ? */
+ /* printf("%i stuffing %d\n", i, timestamps); */
- if (buffers)
- {
- *(index++) = (unsigned char) (0x40 |
- (buffer_scale << 5) | (buffer_size >> 8));
- *(index++) = (unsigned char) (buffer_size & 0xff);
- }
+ for (j = 0; j < i; j++)
+ *(index++) = STUFFING_BYTE;
- /* should we write PTS, PTS & DTS or nothing at all ? */
-
- switch (timestamps)
- {
- case TIMESTAMPS_NO:
- *(index++) = MARKER_NO_TIMESTAMPS;
- break;
- case TIMESTAMPS_PTS:
- buffer_timecode (PTS, MARKER_JUST_PTS, &index);
- sector->TS = PTS;
- break;
- case TIMESTAMPS_PTS_DTS:
- buffer_timecode (PTS, MARKER_PTS, &index);
- buffer_timecode (DTS, MARKER_DTS, &index);
- sector->TS = DTS;
- break;
- }
+ /* should we write buffer info ? */
+
+ if (buffers) {
+ *(index++) = (unsigned char) (0x40 |
+ (buffer_scale << 5) | (buffer_size >> 8));
+ *(index++) = (unsigned char) (buffer_size & 0xff);
+ }
+
+ /* should we write PTS, PTS & DTS or nothing at all ? */
+
+ switch (timestamps) {
+ case TIMESTAMPS_NO:
+ *(index++) = MARKER_NO_TIMESTAMPS;
+ break;
+ case TIMESTAMPS_PTS:
+ buffer_timecode (PTS, MARKER_JUST_PTS, &index);
+ sector->TS = PTS;
+ break;
+ case TIMESTAMPS_PTS_DTS:
+ buffer_timecode (PTS, MARKER_PTS, &index);
+ buffer_timecode (DTS, MARKER_DTS, &index);
+ sector->TS = DTS;
+ break;
+ }
/* read in packet data */
-
- i = (packet_size - PACKET_HEADER_SIZE - AFTER_PACKET_LENGTH);
-
- if (type == PADDING_STR)
- {
- for (j=0; j<i; j++)
- *(index++)=(unsigned char) STUFFING_BYTE;
- tmp = i;
- }
- else
- {
- /*tmp = fread (index, sizeof (unsigned char), i, inputstream);*/
- memcpy(index, inputbuffer, i); tmp = i;
- index += tmp;
-
- /* if we did not get enough data bytes, shorten the Packet length */
-
- if (tmp != i)
- {
- packet_size -= (i-tmp);
- *(size_offset++) = (unsigned char)((packet_size - PACKET_HEADER_SIZE)>>8);
- *(size_offset++) = (unsigned char)((packet_size - PACKET_HEADER_SIZE)&0xff);
-
+
+ i = (packet_size - PACKET_HEADER_SIZE - AFTER_PACKET_LENGTH);
+
+ if (type == PADDING_STR) {
+ for (j = 0; j < i; j++)
+ *(index++) = (unsigned char) STUFFING_BYTE;
+ tmp = i;
+ } else {
+ /*tmp = fread (index, sizeof (unsigned char), i, inputstream); */
+ memcpy (index, inputbuffer, i);
+ tmp = i;
+ index += tmp;
+
+ /* if we did not get enough data bytes, shorten the Packet length */
+
+ if (tmp != i) {
+ packet_size -= (i - tmp);
+ *(size_offset++) =
+ (unsigned char) ((packet_size - PACKET_HEADER_SIZE) >> 8);
+ *(size_offset++) =
+ (unsigned char) ((packet_size - PACKET_HEADER_SIZE) & 0xff);
+
/* zero byte stuffing in the last Packet of a stream */
/* we don't need this any more, since we shortenend the packet */
/* for (j=tmp; j<i; j++) */
/* *(index++)=(unsigned char) ZERO_STUFFING_BYTE; */
- }
}
+ }
- /* write other struct data */
+ /* write other struct data */
+
+ sector->length_of_sector += packet_size;
+ sector->length_of_packet_data = tmp;
- sector->length_of_sector += packet_size;
- sector->length_of_packet_data = tmp;
-
}
/*************************************************************************
the sector buffer
*************************************************************************/
-void create_pack (pack, SCR, mux_rate)
+void
+create_pack (pack, SCR, mux_rate)
-Pack_struc *pack;
-unsigned int mux_rate;
-guint64 SCR;
+ Pack_struc *pack;
+ unsigned int mux_rate;
+ guint64 SCR;
{
- unsigned char *index;
-
- index = pack->buf;
-
- *(index++) = (unsigned char)((PACK_START)>>24);
- *(index++) = (unsigned char)((PACK_START & 0x00ff0000)>>16);
- *(index++) = (unsigned char)((PACK_START & 0x0000ff00)>>8);
- *(index++) = (unsigned char)(PACK_START & 0x000000ff);
- buffer_timecode (SCR, MARKER_SCR, &index);
- *(index++) = (unsigned char)(0x80 | (mux_rate >>15));
- *(index++) = (unsigned char)(0xff & (mux_rate >> 7));
- *(index++) = (unsigned char)(0x01 | ((mux_rate & 0x7f)<<1));
- pack->SCR = SCR;
+ unsigned char *index;
+
+ index = pack->buf;
+
+ *(index++) = (unsigned char) ((PACK_START) >> 24);
+ *(index++) = (unsigned char) ((PACK_START & 0x00ff0000) >> 16);
+ *(index++) = (unsigned char) ((PACK_START & 0x0000ff00) >> 8);
+ *(index++) = (unsigned char) (PACK_START & 0x000000ff);
+ buffer_timecode (SCR, MARKER_SCR, &index);
+ *(index++) = (unsigned char) (0x80 | (mux_rate >> 15));
+ *(index++) = (unsigned char) (0xff & (mux_rate >> 7));
+ *(index++) = (unsigned char) (0x01 | ((mux_rate & 0x7f) << 1));
+ pack->SCR = SCR;
}
the sector buffer
*************************************************************************/
-void create_sys_header (sys_header, rate_bound, audio_bound,
- fixed, CSPS, audio_lock, video_lock,
- video_bound,
- stream1, buffer1_scale, buffer1_size,
- stream2, buffer2_scale, buffer2_size,
- which_streams)
-
-Sys_header_struc *sys_header;
-unsigned int rate_bound;
-unsigned char audio_bound;
-unsigned char fixed;
-unsigned char CSPS;
-unsigned char audio_lock;
-unsigned char video_lock;
-unsigned char video_bound;
-
-unsigned char stream1;
-unsigned char buffer1_scale;
-unsigned int buffer1_size;
-unsigned char stream2;
-unsigned char buffer2_scale;
-unsigned int buffer2_size;
-unsigned int which_streams;
+void
+create_sys_header (sys_header, rate_bound, audio_bound,
+ fixed, CSPS, audio_lock, video_lock,
+ video_bound,
+ stream1, buffer1_scale, buffer1_size,
+ stream2, buffer2_scale, buffer2_size, which_streams)
+
+ Sys_header_struc *sys_header;
+ unsigned int rate_bound;
+ unsigned char audio_bound;
+ unsigned char fixed;
+ unsigned char CSPS;
+ unsigned char audio_lock;
+ unsigned char video_lock;
+ unsigned char video_bound;
+
+ unsigned char stream1;
+ unsigned char buffer1_scale;
+ unsigned int buffer1_size;
+ unsigned char stream2;
+ unsigned char buffer2_scale;
+ unsigned int buffer2_size;
+ unsigned int which_streams;
{
- unsigned char *index;
-
- index = sys_header->buf;
-
- /* if we are not using both streams, we should clear some
- options here */
-
- if (!(which_streams & STREAMS_AUDIO))
- audio_bound = 0;
- if (!(which_streams & STREAMS_VIDEO))
- video_bound = 0;
-
- *(index++) = (unsigned char)((SYS_HEADER_START)>>24);
- *(index++) = (unsigned char)((SYS_HEADER_START & 0x00ff0000)>>16);
- *(index++) = (unsigned char)((SYS_HEADER_START & 0x0000ff00)>>8);
- *(index++) = (unsigned char)(SYS_HEADER_START & 0x000000ff);
-
- if (which_streams == STREAMS_BOTH) {
- *(index++) = (unsigned char)(SYS_HEADER_LENGTH >> 8);
- *(index++) = (unsigned char)(SYS_HEADER_LENGTH & 0xff);
- } else {
- *(index++) = (unsigned char)((SYS_HEADER_LENGTH-3) >> 8);
- *(index++) = (unsigned char)((SYS_HEADER_LENGTH-3) & 0xff);
- }
-
- *(index++) = (unsigned char)(0x80 | (rate_bound >>15));
- *(index++) = (unsigned char)(0xff & (rate_bound >> 7));
- *(index++) = (unsigned char)(0x01 | ((rate_bound & 0x7f)<<1));
- *(index++) = (unsigned char)((audio_bound << 2)|(fixed << 1)|CSPS);
- *(index++) = (unsigned char)((audio_lock << 7)|
- (video_lock << 6)|0x20|video_bound);
-
- *(index++) = (unsigned char)RESERVED_BYTE;
-
- if (which_streams & STREAMS_AUDIO) {
- *(index++) = stream1;
- *(index++) = (unsigned char) (0xc0 |
- (buffer1_scale << 5) | (buffer1_size >> 8));
- *(index++) = (unsigned char) (buffer1_size & 0xff);
- }
-
- if (which_streams & STREAMS_VIDEO) {
- *(index++) = stream2;
- *(index++) = (unsigned char) (0xc0 |
- (buffer2_scale << 5) | (buffer2_size >> 8));
- *(index++) = (unsigned char) (buffer2_size & 0xff);
- }
+ unsigned char *index;
+
+ index = sys_header->buf;
+
+ /* if we are not using both streams, we should clear some
+ options here */
+
+ if (!(which_streams & STREAMS_AUDIO))
+ audio_bound = 0;
+ if (!(which_streams & STREAMS_VIDEO))
+ video_bound = 0;
+
+ *(index++) = (unsigned char) ((SYS_HEADER_START) >> 24);
+ *(index++) = (unsigned char) ((SYS_HEADER_START & 0x00ff0000) >> 16);
+ *(index++) = (unsigned char) ((SYS_HEADER_START & 0x0000ff00) >> 8);
+ *(index++) = (unsigned char) (SYS_HEADER_START & 0x000000ff);
+
+ if (which_streams == STREAMS_BOTH) {
+ *(index++) = (unsigned char) (SYS_HEADER_LENGTH >> 8);
+ *(index++) = (unsigned char) (SYS_HEADER_LENGTH & 0xff);
+ } else {
+ *(index++) = (unsigned char) ((SYS_HEADER_LENGTH - 3) >> 8);
+ *(index++) = (unsigned char) ((SYS_HEADER_LENGTH - 3) & 0xff);
+ }
+
+ *(index++) = (unsigned char) (0x80 | (rate_bound >> 15));
+ *(index++) = (unsigned char) (0xff & (rate_bound >> 7));
+ *(index++) = (unsigned char) (0x01 | ((rate_bound & 0x7f) << 1));
+ *(index++) = (unsigned char) ((audio_bound << 2) | (fixed << 1) | CSPS);
+ *(index++) = (unsigned char) ((audio_lock << 7) |
+ (video_lock << 6) | 0x20 | video_bound);
+
+ *(index++) = (unsigned char) RESERVED_BYTE;
+
+ if (which_streams & STREAMS_AUDIO) {
+ *(index++) = stream1;
+ *(index++) = (unsigned char) (0xc0 |
+ (buffer1_scale << 5) | (buffer1_size >> 8));
+ *(index++) = (unsigned char) (buffer1_size & 0xff);
+ }
+
+ if (which_streams & STREAMS_VIDEO) {
+ *(index++) = stream2;
+ *(index++) = (unsigned char) (0xc0 |
+ (buffer2_scale << 5) | (buffer2_size >> 8));
+ *(index++) = (unsigned char) (buffer2_size & 0xff);
+ }
}
#define SEQ_END_CODE 0x000001b7
/* elementfactory information */
-static GstElementDetails mpeg1videoparse_details = GST_ELEMENT_DETAILS (
- "MPEG 1 Video Parser",
- "Codec/Parser/Video",
- "Parses and frames MPEG 1 video streams, provides seek",
- "Wim Taymans <wim.taymans@chello.be>"
-);
-
-static GstStaticPadTemplate src_factory =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("video/mpeg, "
- "mpegversion = (int) 1, "
- "systemstream = (boolean) false, "
- "width = (int) [ 16, 4096 ], "
- "height = (int) [ 16, 4096 ], "
- "pixel_width = (int) [ 1, 255 ], "
- "pixel_height = (int) [ 1, 255 ], "
- "framerate = (double) [ 0, MAX ]"
- )
-);
-
-static GstStaticPadTemplate sink_factory =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("video/mpeg, "
- "mpegversion = (int) 1, "
- "systemstream = (boolean) false"
- )
-);
+static GstElementDetails mpeg1videoparse_details =
+GST_ELEMENT_DETAILS ("MPEG 1 Video Parser",
+ "Codec/Parser/Video",
+ "Parses and frames MPEG 1 video streams, provides seek",
+ "Wim Taymans <wim.taymans@chello.be>");
+
+static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/mpeg, "
+ "mpegversion = (int) 1, "
+ "systemstream = (boolean) false, "
+ "width = (int) [ 16, 4096 ], "
+ "height = (int) [ 16, 4096 ], "
+ "pixel_width = (int) [ 1, 255 ], "
+ "pixel_height = (int) [ 1, 255 ], " "framerate = (double) [ 0, MAX ]")
+ );
+
+static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/mpeg, "
+ "mpegversion = (int) 1, " "systemstream = (boolean) false")
+ );
/* Mp1VideoParse signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
/* FILL ME */
};
-static void gst_mp1videoparse_class_init (Mp1VideoParseClass *klass);
-static void gst_mp1videoparse_base_init (Mp1VideoParseClass *klass);
-static void gst_mp1videoparse_init (Mp1VideoParse *mp1videoparse);
+static void gst_mp1videoparse_class_init (Mp1VideoParseClass * klass);
+static void gst_mp1videoparse_base_init (Mp1VideoParseClass * klass);
+static void gst_mp1videoparse_init (Mp1VideoParse * mp1videoparse);
-static void gst_mp1videoparse_chain (GstPad *pad, GstData *_data);
-static void gst_mp1videoparse_real_chain (Mp1VideoParse *mp1videoparse, GstBuffer *buf, GstPad *outpad);
-static void gst_mp1videoparse_flush (Mp1VideoParse *mp1videoparse);
+static void gst_mp1videoparse_chain (GstPad * pad, GstData * _data);
+static void gst_mp1videoparse_real_chain (Mp1VideoParse * mp1videoparse,
+ GstBuffer * buf, GstPad * outpad);
+static void gst_mp1videoparse_flush (Mp1VideoParse * mp1videoparse);
static GstElementStateReturn
- gst_mp1videoparse_change_state (GstElement *element);
+gst_mp1videoparse_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_mp1videoparse_signals[LAST_SIGNAL] = { 0 }; */
GType
if (!mp1videoparse_type) {
static const GTypeInfo mp1videoparse_info = {
- sizeof(Mp1VideoParseClass),
- (GBaseInitFunc)gst_mp1videoparse_base_init,
+ sizeof (Mp1VideoParseClass),
+ (GBaseInitFunc) gst_mp1videoparse_base_init,
NULL,
- (GClassInitFunc)gst_mp1videoparse_class_init,
+ (GClassInitFunc) gst_mp1videoparse_class_init,
NULL,
NULL,
- sizeof(Mp1VideoParse),
+ sizeof (Mp1VideoParse),
0,
- (GInstanceInitFunc)gst_mp1videoparse_init,
+ (GInstanceInitFunc) gst_mp1videoparse_init,
};
- mp1videoparse_type = g_type_register_static(GST_TYPE_ELEMENT, "Mp1VideoParse", &mp1videoparse_info, 0);
+ mp1videoparse_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "Mp1VideoParse",
+ &mp1videoparse_info, 0);
}
return mp1videoparse_type;
}
static void
-gst_mp1videoparse_base_init (Mp1VideoParseClass *klass)
+gst_mp1videoparse_base_init (Mp1VideoParseClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&src_factory));
+ gst_static_pad_template_get (&src_factory));
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&sink_factory));
+ gst_static_pad_template_get (&sink_factory));
gst_element_class_set_details (element_class, &mpeg1videoparse_details);
}
static void
-gst_mp1videoparse_class_init (Mp1VideoParseClass *klass)
+gst_mp1videoparse_class_init (Mp1VideoParseClass * klass)
{
GstElementClass *gstelement_class;
- gstelement_class = (GstElementClass*)klass;
+ gstelement_class = (GstElementClass *) klass;
- parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
+ parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
gstelement_class->change_state = gst_mp1videoparse_change_state;
}
static void
-gst_mp1videoparse_init (Mp1VideoParse *mp1videoparse)
+gst_mp1videoparse_init (Mp1VideoParse * mp1videoparse)
{
- mp1videoparse->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&sink_factory), "sink");
- gst_element_add_pad(GST_ELEMENT(mp1videoparse),mp1videoparse->sinkpad);
- gst_pad_set_chain_function(mp1videoparse->sinkpad,gst_mp1videoparse_chain);
-
- mp1videoparse->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&src_factory), "src");
- gst_element_add_pad(GST_ELEMENT(mp1videoparse),mp1videoparse->srcpad);
+ mp1videoparse->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get (&sink_factory),
+ "sink");
+ gst_element_add_pad (GST_ELEMENT (mp1videoparse), mp1videoparse->sinkpad);
+ gst_pad_set_chain_function (mp1videoparse->sinkpad, gst_mp1videoparse_chain);
+
+ mp1videoparse->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get (&src_factory),
+ "src");
+ gst_element_add_pad (GST_ELEMENT (mp1videoparse), mp1videoparse->srcpad);
gst_pad_use_explicit_caps (mp1videoparse->srcpad);
mp1videoparse->partialbuf = NULL;
}
static void
-mp1videoparse_parse_seq (Mp1VideoParse *mp1videoparse, GstBuffer *buf)
+mp1videoparse_parse_seq (Mp1VideoParse * mp1videoparse, GstBuffer * buf)
{
gint width, height, asr_idx, fps_idx;
gfloat asr_table[] = { 0., 1.,
- 0.6735, 0.7031, 0.7615, 0.8055, 0.8437,
- 0.8935, 0.9157, 0.9815, 1.0255, 1.0695,
- 1.0950, 1.1575, 1.2015 };
- gfloat fps_table[] = { 0., 24./1.001, 24., 25.,
- 30./1.001, 30.,
- 50., 60./1.001, 60. };
+ 0.6735, 0.7031, 0.7615, 0.8055, 0.8437,
+ 0.8935, 0.9157, 0.9815, 1.0255, 1.0695,
+ 1.0950, 1.1575, 1.2015
+ };
+ gfloat fps_table[] = { 0., 24. / 1.001, 24., 25.,
+ 30. / 1.001, 30.,
+ 50., 60. / 1.001, 60.
+ };
guint32 n = GUINT32_FROM_BE (*(guint32 *) GST_BUFFER_DATA (buf));
- width = (n & 0xfff00000) >> 20;
- height = (n & 0x000fff00) >> 8;
- asr_idx = (n & 0x000000f0) >> 4;
- fps_idx = (n & 0x0000000f) >> 0;
+ width = (n & 0xfff00000) >> 20;
+ height = (n & 0x000fff00) >> 8;
+ asr_idx = (n & 0x000000f0) >> 4;
+ fps_idx = (n & 0x0000000f) >> 0;
if (fps_idx >= 9 || fps_idx <= 0)
- fps_idx = 3; /* well, we need a default */
+ fps_idx = 3; /* well, we need a default */
if (asr_idx >= 15 || asr_idx <= 0)
- asr_idx = 1; /* no aspect ratio */
+ asr_idx = 1; /* no aspect ratio */
- if (asr_table[asr_idx] != mp1videoparse->asr ||
- fps_table[fps_idx] != mp1videoparse->fps ||
- width != mp1videoparse->width ||
- height != mp1videoparse->height) {
+ if (asr_table[asr_idx] != mp1videoparse->asr ||
+ fps_table[fps_idx] != mp1videoparse->fps ||
+ width != mp1videoparse->width || height != mp1videoparse->height) {
GstCaps *caps;
gint p_w, p_h;
- mp1videoparse->asr = asr_table[asr_idx];
- mp1videoparse->fps = fps_table[fps_idx];
- mp1videoparse->width = width;
+ mp1videoparse->asr = asr_table[asr_idx];
+ mp1videoparse->fps = fps_table[fps_idx];
+ mp1videoparse->width = width;
mp1videoparse->height = height;
p_w = (asr_table[asr_idx] < 1.0) ? (100 / asr_table[asr_idx]) : 1;
caps = gst_caps_new_simple ("video/mpeg",
"systemstream", G_TYPE_BOOLEAN, FALSE,
- "mpegversion", G_TYPE_INT, 1,
- "width", G_TYPE_INT, width,
- "height", G_TYPE_INT, height,
- "framerate", G_TYPE_DOUBLE, fps_table[fps_idx],
- "pixel_width", G_TYPE_INT, p_w,
- "pixel_height", G_TYPE_INT, p_h, NULL);
+ "mpegversion", G_TYPE_INT, 1,
+ "width", G_TYPE_INT, width,
+ "height", G_TYPE_INT, height,
+ "framerate", G_TYPE_DOUBLE, fps_table[fps_idx],
+ "pixel_width", G_TYPE_INT, p_w, "pixel_height", G_TYPE_INT, p_h, NULL);
GST_DEBUG ("New mpeg1videoparse caps: " GST_PTR_FORMAT, caps);
}
static gboolean
-mp1videoparse_valid_sync (Mp1VideoParse *mp1videoparse, guint32 head, GstBuffer *buf)
+mp1videoparse_valid_sync (Mp1VideoParse * mp1videoparse, guint32 head,
+ GstBuffer * buf)
{
switch (head) {
- case SEQ_START_CODE: {
+ case SEQ_START_CODE:{
GstBuffer *subbuf = gst_buffer_create_sub (buf, 4,
- GST_BUFFER_SIZE (buf) - 4);
- mp1videoparse_parse_seq(mp1videoparse, subbuf);
+ GST_BUFFER_SIZE (buf) - 4);
+
+ mp1videoparse_parse_seq (mp1videoparse, subbuf);
gst_buffer_unref (subbuf);
return TRUE;
}
case EXT_START_CODE:
return TRUE;
default:
- if (head >= SLICE_MIN_START_CODE &&
- head <= SLICE_MAX_START_CODE)
- return TRUE;
+ if (head >= SLICE_MIN_START_CODE && head <= SLICE_MAX_START_CODE)
+ return TRUE;
}
return FALSE;
}
static gint
-mp1videoparse_find_next_gop (Mp1VideoParse *mp1videoparse, GstBuffer *buf)
+mp1videoparse_find_next_gop (Mp1VideoParse * mp1videoparse, GstBuffer * buf)
{
- guchar *data = GST_BUFFER_DATA(buf);
- gulong size = GST_BUFFER_SIZE(buf);
+ guchar *data = GST_BUFFER_DATA (buf);
+ gulong size = GST_BUFFER_SIZE (buf);
gulong offset = 0;
gint sync_zeros = 0;
gboolean have_sync = FALSE;
while (offset < size) {
- guchar byte = *(data+offset);
+ guchar byte = *(data + offset);
+
offset++;
if (byte == 0) {
sync_zeros++;
- }
- else if (byte == 1 && sync_zeros >=2 ) {
+ } else if (byte == 1 && sync_zeros >= 2) {
sync_zeros = 0;
have_sync = TRUE;
- }
- else if (have_sync) {
+ } else if (have_sync) {
if (byte == (SEQ_START_CODE & 0xff) || byte == (GOP_START_CODE & 0xff)) {
- return offset - 4;
+ return offset - 4;
} else {
- sync_zeros = 0;
+ sync_zeros = 0;
have_sync = FALSE;
}
- }
- else {
+ } else {
sync_zeros = 0;
}
}
}
static guint64
-gst_mp1videoparse_time_code (guchar *gop,
- gfloat fps)
+gst_mp1videoparse_time_code (guchar * gop, gfloat fps)
{
- guint32 data = GUINT32_FROM_BE (* (guint32 *) gop);
+ guint32 data = GUINT32_FROM_BE (*(guint32 *) gop);
- return ((((data & 0xfc000000) >> 26) * 3600 * GST_SECOND) + /* hours */
- (((data & 0x03f00000) >> 20) * 60 * GST_SECOND) + /* minutes */
- (((data & 0x0007e000) >> 13) * GST_SECOND) + /* seconds */
- (((data & 0x00001f80) >> 7) * GST_SECOND / fps)); /* frames */
+ return ((((data & 0xfc000000) >> 26) * 3600 * GST_SECOND) + /* hours */
+ (((data & 0x03f00000) >> 20) * 60 * GST_SECOND) + /* minutes */
+ (((data & 0x0007e000) >> 13) * GST_SECOND) + /* seconds */
+ (((data & 0x00001f80) >> 7) * GST_SECOND / fps)); /* frames */
}
static void
-gst_mp1videoparse_flush (Mp1VideoParse *mp1videoparse)
+gst_mp1videoparse_flush (Mp1VideoParse * mp1videoparse)
{
GST_DEBUG ("mp1videoparse: flushing");
if (mp1videoparse->partialbuf) {
- gst_buffer_unref(mp1videoparse->partialbuf);
- mp1videoparse->partialbuf= NULL;
+ gst_buffer_unref (mp1videoparse->partialbuf);
+ mp1videoparse->partialbuf = NULL;
}
mp1videoparse->need_resync = TRUE;
mp1videoparse->in_flush = TRUE;
}
static void
-gst_mp1videoparse_chain (GstPad *pad,GstData *_data)
+gst_mp1videoparse_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
Mp1VideoParse *mp1videoparse;
mp1videoparse = GST_MP1VIDEOPARSE (GST_OBJECT_PARENT (pad));
- gst_mp1videoparse_real_chain(mp1videoparse, buf, mp1videoparse->srcpad);
+ gst_mp1videoparse_real_chain (mp1videoparse, buf, mp1videoparse->srcpad);
}
static void
-gst_mp1videoparse_real_chain (Mp1VideoParse *mp1videoparse, GstBuffer *buf, GstPad *outpad)
+gst_mp1videoparse_real_chain (Mp1VideoParse * mp1videoparse, GstBuffer * buf,
+ GstPad * outpad)
{
guchar *data;
gulong size, offset = 0;
guint64 time_stamp;
GstBuffer *temp;
- time_stamp = GST_BUFFER_TIMESTAMP(buf);
+ time_stamp = GST_BUFFER_TIMESTAMP (buf);
if (GST_IS_EVENT (buf)) {
GstEvent *event = GST_EVENT (buf);
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_FLUSH:
case GST_EVENT_DISCONTINUOUS:
- gst_mp1videoparse_flush(mp1videoparse);
- break;
+ gst_mp1videoparse_flush (mp1videoparse);
+ break;
case GST_EVENT_EOS:
- gst_mp1videoparse_flush(mp1videoparse);
- gst_event_ref(event);
- gst_pad_push(outpad, GST_DATA (event));
- gst_element_set_eos (GST_ELEMENT (mp1videoparse));
- break;
+ gst_mp1videoparse_flush (mp1videoparse);
+ gst_event_ref (event);
+ gst_pad_push (outpad, GST_DATA (event));
+ gst_element_set_eos (GST_ELEMENT (mp1videoparse));
+ break;
default:
- GST_DEBUG ("Unhandled event type %d",
- GST_EVENT_TYPE (event));
- break;
+ GST_DEBUG ("Unhandled event type %d", GST_EVENT_TYPE (event));
+ break;
}
-
+
gst_event_unref (event);
return;
}
-
+
if (mp1videoparse->partialbuf) {
GstBuffer *merge;
- offset = GST_BUFFER_SIZE(mp1videoparse->partialbuf);
- merge = gst_buffer_merge(mp1videoparse->partialbuf, buf);
+ offset = GST_BUFFER_SIZE (mp1videoparse->partialbuf);
+ merge = gst_buffer_merge (mp1videoparse->partialbuf, buf);
- gst_buffer_unref(mp1videoparse->partialbuf);
- gst_buffer_unref(buf);
+ gst_buffer_unref (mp1videoparse->partialbuf);
+ gst_buffer_unref (buf);
mp1videoparse->partialbuf = merge;
- }
- else {
+ } else {
mp1videoparse->partialbuf = buf;
offset = 0;
}
- data = GST_BUFFER_DATA(mp1videoparse->partialbuf);
- size = GST_BUFFER_SIZE(mp1videoparse->partialbuf);
+ data = GST_BUFFER_DATA (mp1videoparse->partialbuf);
+ size = GST_BUFFER_SIZE (mp1videoparse->partialbuf);
- GST_DEBUG ("mp1videoparse: received buffer of %ld bytes %" G_GINT64_FORMAT,size, GST_BUFFER_TIMESTAMP(buf));
+ GST_DEBUG ("mp1videoparse: received buffer of %ld bytes %" G_GINT64_FORMAT,
+ size, GST_BUFFER_TIMESTAMP (buf));
do {
- data = GST_BUFFER_DATA(mp1videoparse->partialbuf);
- size = GST_BUFFER_SIZE(mp1videoparse->partialbuf);
+ data = GST_BUFFER_DATA (mp1videoparse->partialbuf);
+ size = GST_BUFFER_SIZE (mp1videoparse->partialbuf);
- head = GUINT32_FROM_BE(*((guint32 *)data));
+ head = GUINT32_FROM_BE (*((guint32 *) data));
- GST_DEBUG ("mp1videoparse: head is %08x", (unsigned int)head);
+ GST_DEBUG ("mp1videoparse: head is %08x", (unsigned int) head);
- if (!mp1videoparse_valid_sync(mp1videoparse, head,
- mp1videoparse->partialbuf) ||
- mp1videoparse->need_resync) {
- sync_pos = mp1videoparse_find_next_gop(mp1videoparse, mp1videoparse->partialbuf);
+ if (!mp1videoparse_valid_sync (mp1videoparse, head,
+ mp1videoparse->partialbuf) || mp1videoparse->need_resync) {
+ sync_pos =
+ mp1videoparse_find_next_gop (mp1videoparse,
+ mp1videoparse->partialbuf);
if (sync_pos >= 0) {
- mp1videoparse->need_resync = FALSE;
- GST_DEBUG ("mp1videoparse: found new gop at %d", sync_pos);
-
- if (sync_pos != 0) {
- temp = gst_buffer_create_sub(mp1videoparse->partialbuf, sync_pos, size-sync_pos);
- g_assert(temp != NULL);
- gst_buffer_unref(mp1videoparse->partialbuf);
+ mp1videoparse->need_resync = FALSE;
+ GST_DEBUG ("mp1videoparse: found new gop at %d", sync_pos);
+
+ if (sync_pos != 0) {
+ temp =
+ gst_buffer_create_sub (mp1videoparse->partialbuf, sync_pos,
+ size - sync_pos);
+ g_assert (temp != NULL);
+ gst_buffer_unref (mp1videoparse->partialbuf);
mp1videoparse->partialbuf = temp;
- data = GST_BUFFER_DATA(mp1videoparse->partialbuf);
- size = GST_BUFFER_SIZE(mp1videoparse->partialbuf);
+ data = GST_BUFFER_DATA (mp1videoparse->partialbuf);
+ size = GST_BUFFER_SIZE (mp1videoparse->partialbuf);
offset = 0;
- }
-
- head = GUINT32_FROM_BE(*((guint32 *)data));
- /* re-call this function so that if we hadn't already, we can
- * now read the sequence header and parse video properties,
- * set caps, stream data, be happy, bla, bla, bla... */
- if (!mp1videoparse_valid_sync (mp1videoparse, head,
- mp1videoparse->partialbuf))
- g_error ("Found sync but no valid sync point at pos 0x0");
- }
- else {
- GST_DEBUG ("mp1videoparse: could not sync");
- gst_buffer_unref(mp1videoparse->partialbuf);
- mp1videoparse->partialbuf = NULL;
- return;
+ }
+
+ head = GUINT32_FROM_BE (*((guint32 *) data));
+ /* re-call this function so that if we hadn't already, we can
+ * now read the sequence header and parse video properties,
+ * set caps, stream data, be happy, bla, bla, bla... */
+ if (!mp1videoparse_valid_sync (mp1videoparse, head,
+ mp1videoparse->partialbuf))
+ g_error ("Found sync but no valid sync point at pos 0x0");
+ } else {
+ GST_DEBUG ("mp1videoparse: could not sync");
+ gst_buffer_unref (mp1videoparse->partialbuf);
+ mp1videoparse->partialbuf = NULL;
+ return;
}
}
if (mp1videoparse->picture_in_buffer == 1 &&
- time_stamp != GST_CLOCK_TIME_NONE) {
+ time_stamp != GST_CLOCK_TIME_NONE) {
mp1videoparse->last_pts = time_stamp;
}
GST_DEBUG ("mp1videoparse: searching sync");
- while (offset < size-1) {
+ while (offset < size - 1) {
sync_byte = *(data + offset);
if (sync_byte == 0) {
- sync_state++;
- }
- else if ((sync_byte == 1) && (sync_state >=2)) {
- GST_DEBUG ("mp1videoparse: code 0x000001%02x",data[offset+1]);
- if (data[offset+1] == (PICTURE_START_CODE & 0xff)) {
+ sync_state++;
+ } else if ((sync_byte == 1) && (sync_state >= 2)) {
+ GST_DEBUG ("mp1videoparse: code 0x000001%02x", data[offset + 1]);
+ if (data[offset + 1] == (PICTURE_START_CODE & 0xff)) {
mp1videoparse->picture_in_buffer++;
if (mp1videoparse->picture_in_buffer == 1) {
if (time_stamp != GST_CLOCK_TIME_NONE) {
- mp1videoparse->last_pts = time_stamp;
+ mp1videoparse->last_pts = time_stamp;
}
sync_state = 0;
+ } else if (mp1videoparse->picture_in_buffer == 2) {
+ have_sync = TRUE;
+ break;
+ } else {
+ GST_DEBUG ("mp1videoparse: %d in buffer",
+ mp1videoparse->picture_in_buffer);
+ g_assert_not_reached ();
}
- else if (mp1videoparse->picture_in_buffer == 2) {
- have_sync = TRUE;
- break;
- }
- else {
- GST_DEBUG ("mp1videoparse: %d in buffer", mp1videoparse->picture_in_buffer);
- g_assert_not_reached();
- }
- }
- /* A new sequence (or GOP) is a valid sync too. Note that the
- * sequence header should be put in the next buffer, not here. */
- else if (data[offset+1] == (SEQ_START_CODE & 0xFF) ||
- data[offset+1] == (GOP_START_CODE & 0xFF)) {
- if (mp1videoparse->picture_in_buffer == 0 &&
- data[offset+1] == (GOP_START_CODE & 0xFF)) {
+ }
+ /* A new sequence (or GOP) is a valid sync too. Note that the
+ * sequence header should be put in the next buffer, not here. */
+ else if (data[offset + 1] == (SEQ_START_CODE & 0xFF) ||
+ data[offset + 1] == (GOP_START_CODE & 0xFF)) {
+ if (mp1videoparse->picture_in_buffer == 0 &&
+ data[offset + 1] == (GOP_START_CODE & 0xFF)) {
mp1videoparse->last_pts = gst_mp1videoparse_time_code (&data[2],
- mp1videoparse->fps);
- }
- else if (mp1videoparse->picture_in_buffer == 1) {
+ mp1videoparse->fps);
+ } else if (mp1videoparse->picture_in_buffer == 1) {
have_sync = TRUE;
break;
} else {
g_assert (mp1videoparse->picture_in_buffer == 0);
}
- }
- /* end-of-sequence is a valid sync point and should be included
- * in the current picture, not the next. */
- else if (data[offset+1] == (SEQ_END_CODE & 0xFF)) {
- if (mp1videoparse->picture_in_buffer == 1) {
- offset += 4;
+ }
+ /* end-of-sequence is a valid sync point and should be included
+ * in the current picture, not the next. */
+ else if (data[offset + 1] == (SEQ_END_CODE & 0xFF)) {
+ if (mp1videoparse->picture_in_buffer == 1) {
+ offset += 4;
have_sync = TRUE;
break;
} else {
g_assert (mp1videoparse->picture_in_buffer == 0);
}
- }
- else sync_state = 0;
+ } else
+ sync_state = 0;
}
/* something else... */
- else sync_state = 0;
+ else
+ sync_state = 0;
/* go down the buffer */
offset++;
}
if (have_sync) {
offset -= 2;
- GST_DEBUG ("mp1videoparse: synced at %ld code 0x000001%02x",offset,data[offset+3]);
+ GST_DEBUG ("mp1videoparse: synced at %ld code 0x000001%02x", offset,
+ data[offset + 3]);
- outbuf = gst_buffer_create_sub(mp1videoparse->partialbuf, 0, offset+4);
- g_assert(outbuf != NULL);
- GST_BUFFER_TIMESTAMP(outbuf) = mp1videoparse->last_pts;
- GST_BUFFER_DURATION(outbuf) = GST_SECOND / mp1videoparse->fps;
+ outbuf = gst_buffer_create_sub (mp1videoparse->partialbuf, 0, offset + 4);
+ g_assert (outbuf != NULL);
+ GST_BUFFER_TIMESTAMP (outbuf) = mp1videoparse->last_pts;
+ GST_BUFFER_DURATION (outbuf) = GST_SECOND / mp1videoparse->fps;
mp1videoparse->last_pts += GST_BUFFER_DURATION (outbuf);
if (mp1videoparse->in_flush) {
- /* FIXME, send a flush event here */
- mp1videoparse->in_flush = FALSE;
+ /* FIXME, send a flush event here */
+ mp1videoparse->in_flush = FALSE;
}
if (GST_PAD_CAPS (outpad) != NULL) {
- GST_DEBUG ("mp1videoparse: pushing %d bytes %" G_GUINT64_FORMAT, GST_BUFFER_SIZE(outbuf), GST_BUFFER_TIMESTAMP(outbuf));
- gst_pad_push(outpad, GST_DATA (outbuf));
- GST_DEBUG ("mp1videoparse: pushing done");
+ GST_DEBUG ("mp1videoparse: pushing %d bytes %" G_GUINT64_FORMAT,
+ GST_BUFFER_SIZE (outbuf), GST_BUFFER_TIMESTAMP (outbuf));
+ gst_pad_push (outpad, GST_DATA (outbuf));
+ GST_DEBUG ("mp1videoparse: pushing done");
} else {
- GST_DEBUG ("No capsnego yet, delaying buffer push");
- gst_buffer_unref (outbuf);
+ GST_DEBUG ("No capsnego yet, delaying buffer push");
+ gst_buffer_unref (outbuf);
}
mp1videoparse->picture_in_buffer = 0;
- temp = gst_buffer_create_sub(mp1videoparse->partialbuf, offset, size-offset);
- gst_buffer_unref(mp1videoparse->partialbuf);
+ temp =
+ gst_buffer_create_sub (mp1videoparse->partialbuf, offset,
+ size - offset);
+ gst_buffer_unref (mp1videoparse->partialbuf);
mp1videoparse->partialbuf = temp;
offset = 0;
- }
- else {
+ } else {
if (time_stamp != GST_CLOCK_TIME_NONE) {
- mp1videoparse->last_pts = time_stamp;
+ mp1videoparse->last_pts = time_stamp;
break;
}
}
} while (1);
}
-static GstElementStateReturn
-gst_mp1videoparse_change_state (GstElement *element)
+static GstElementStateReturn
+gst_mp1videoparse_change_state (GstElement * element)
{
Mp1VideoParse *mp1videoparse;
- g_return_val_if_fail(GST_IS_MP1VIDEOPARSE(element),GST_STATE_FAILURE);
- mp1videoparse = GST_MP1VIDEOPARSE(element);
+ g_return_val_if_fail (GST_IS_MP1VIDEOPARSE (element), GST_STATE_FAILURE);
+
+ mp1videoparse = GST_MP1VIDEOPARSE (element);
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_PAUSED_TO_READY:
- gst_mp1videoparse_flush(mp1videoparse);
+ gst_mp1videoparse_flush (mp1videoparse);
mp1videoparse->width = mp1videoparse->height = -1;
- mp1videoparse->fps = mp1videoparse->asr = 0.;
+ mp1videoparse->fps = mp1videoparse->asr = 0.;
break;
default:
break;
}
- if (GST_ELEMENT_CLASS(parent_class)->change_state)
- return GST_ELEMENT_CLASS(parent_class)->change_state(element);
+ if (GST_ELEMENT_CLASS (parent_class)->change_state)
+ return GST_ELEMENT_CLASS (parent_class)->change_state (element);
return GST_STATE_SUCCESS;
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
return gst_element_register (plugin, "mpeg1videoparse",
- GST_RANK_NONE, GST_TYPE_MP1VIDEOPARSE);
+ GST_RANK_NONE, GST_TYPE_MP1VIDEOPARSE);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "mpeg1videoparse",
- "MPEG-1 video parser",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "mpeg1videoparse",
+ "MPEG-1 video parser",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_MP1VIDEOPARSE \
#define GST_IS_MP1VIDEOPARSE_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MP1VIDEOPARSE))
-typedef struct _Mp1VideoParse Mp1VideoParse;
-typedef struct _Mp1VideoParseClass Mp1VideoParseClass;
+ typedef struct _Mp1VideoParse Mp1VideoParse;
+ typedef struct _Mp1VideoParseClass Mp1VideoParseClass;
-struct _Mp1VideoParse {
- GstElement element;
+ struct _Mp1VideoParse
+ {
+ GstElement element;
- GstPad *sinkpad,*srcpad;
+ GstPad *sinkpad, *srcpad;
- GstBuffer *partialbuf; /* previous buffer (if carryover) */
- gulong next_buffer_offset;
- gboolean need_resync;
- gboolean in_flush;
- guint64 last_pts;
- gint picture_in_buffer;
+ GstBuffer *partialbuf; /* previous buffer (if carryover) */
+ gulong next_buffer_offset;
+ gboolean need_resync;
+ gboolean in_flush;
+ guint64 last_pts;
+ gint picture_in_buffer;
- gint width, height;
- gfloat fps, asr;
-};
+ gint width, height;
+ gfloat fps, asr;
+ };
-struct _Mp1VideoParseClass {
- GstElementClass parent_class;
-};
+ struct _Mp1VideoParseClass
+ {
+ GstElementClass parent_class;
+ };
-GType gst_mp1videoparse_get_type(void);
+ GType gst_mp1videoparse_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __MP1VIDEOPARSE_H__ */
+#endif /* __MP1VIDEOPARSE_H__ */
#endif
#include <gstmpeg2subt.h>
-static void gst_mpeg2subt_class_init (GstMpeg2SubtClass *klass);
-static void gst_mpeg2subt_base_init (GstMpeg2SubtClass *klass);
-static void gst_mpeg2subt_init (GstMpeg2Subt *mpeg2subt);
+static void gst_mpeg2subt_class_init (GstMpeg2SubtClass * klass);
+static void gst_mpeg2subt_base_init (GstMpeg2SubtClass * klass);
+static void gst_mpeg2subt_init (GstMpeg2Subt * mpeg2subt);
-static void gst_mpeg2subt_chain_video (GstPad *pad,GstData *_data);
-static void gst_mpeg2subt_chain_subtitle (GstPad *pad,GstData *_data);
+static void gst_mpeg2subt_chain_video (GstPad * pad, GstData * _data);
+static void gst_mpeg2subt_chain_subtitle (GstPad * pad, GstData * _data);
-static void gst_mpeg2subt_merge_title (GstMpeg2Subt *mpeg2subt, GstBuffer *buf);
+static void gst_mpeg2subt_merge_title (GstMpeg2Subt * mpeg2subt,
+ GstBuffer * buf);
-static void gst_mpeg2subt_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void gst_mpeg2subt_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+static void gst_mpeg2subt_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_mpeg2subt_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
/* elementfactory information */
static GstElementDetails mpeg2subt_details = {
};
/* GstMpeg2Subt signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_SKIP,
/* FILL ME */
static GstElementClass *parent_class = NULL;
+
/*static guint gst_mpeg2subt_signals[LAST_SIGNAL] = { 0 };*/
GType
if (!mpeg2subt_type) {
static const GTypeInfo mpeg2subt_info = {
- sizeof(GstMpeg2SubtClass),
- (GBaseInitFunc)gst_mpeg2subt_base_init,
+ sizeof (GstMpeg2SubtClass),
+ (GBaseInitFunc) gst_mpeg2subt_base_init,
NULL,
- (GClassInitFunc)gst_mpeg2subt_class_init,
+ (GClassInitFunc) gst_mpeg2subt_class_init,
NULL,
NULL,
- sizeof(GstMpeg2Subt),
+ sizeof (GstMpeg2Subt),
0,
- (GInstanceInitFunc)gst_mpeg2subt_init,
+ (GInstanceInitFunc) gst_mpeg2subt_init,
};
- mpeg2subt_type = g_type_register_static(GST_TYPE_ELEMENT, "GstMpeg2Subt", &mpeg2subt_info, 0);
+ mpeg2subt_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstMpeg2Subt",
+ &mpeg2subt_info, 0);
}
return mpeg2subt_type;
}
static void
-gst_mpeg2subt_base_init (GstMpeg2SubtClass *klass)
+gst_mpeg2subt_base_init (GstMpeg2SubtClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
}
static void
-gst_mpeg2subt_class_init (GstMpeg2SubtClass *klass)
+gst_mpeg2subt_class_init (GstMpeg2SubtClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- gobject_class = (GObjectClass*)klass;
- gstelement_class = (GstElementClass*)klass;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_SKIP,
- g_param_spec_int("skip","skip","skip",
- G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SKIP, g_param_spec_int ("skip", "skip", "skip", G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */
- parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
+ parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
gobject_class->set_property = gst_mpeg2subt_set_property;
gobject_class->get_property = gst_mpeg2subt_get_property;
}
static void
-gst_mpeg2subt_init (GstMpeg2Subt *mpeg2subt)
+gst_mpeg2subt_init (GstMpeg2Subt * mpeg2subt)
{
- mpeg2subt->videopad = gst_pad_new("video",GST_PAD_SINK);
- gst_element_add_pad(GST_ELEMENT(mpeg2subt),mpeg2subt->videopad);
- gst_pad_set_chain_function(mpeg2subt->videopad,gst_mpeg2subt_chain_video);
+ mpeg2subt->videopad = gst_pad_new ("video", GST_PAD_SINK);
+ gst_element_add_pad (GST_ELEMENT (mpeg2subt), mpeg2subt->videopad);
+ gst_pad_set_chain_function (mpeg2subt->videopad, gst_mpeg2subt_chain_video);
- mpeg2subt->subtitlepad = gst_pad_new("subtitle",GST_PAD_SINK);
- gst_element_add_pad(GST_ELEMENT(mpeg2subt),mpeg2subt->subtitlepad);
- gst_pad_set_chain_function(mpeg2subt->subtitlepad,gst_mpeg2subt_chain_subtitle);
+ mpeg2subt->subtitlepad = gst_pad_new ("subtitle", GST_PAD_SINK);
+ gst_element_add_pad (GST_ELEMENT (mpeg2subt), mpeg2subt->subtitlepad);
+ gst_pad_set_chain_function (mpeg2subt->subtitlepad,
+ gst_mpeg2subt_chain_subtitle);
- mpeg2subt->srcpad = gst_pad_new("src",GST_PAD_SRC);
- gst_element_add_pad(GST_ELEMENT(mpeg2subt),mpeg2subt->srcpad);
+ mpeg2subt->srcpad = gst_pad_new ("src", GST_PAD_SRC);
+ gst_element_add_pad (GST_ELEMENT (mpeg2subt), mpeg2subt->srcpad);
mpeg2subt->partialbuf = NULL;
mpeg2subt->have_title = FALSE;
}
static void
-gst_mpeg2subt_chain_video (GstPad *pad, GstData *_data)
+gst_mpeg2subt_chain_video (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstMpeg2Subt *mpeg2subt;
guchar *data;
glong size;
- g_return_if_fail(pad != NULL);
- g_return_if_fail(GST_IS_PAD(pad));
- g_return_if_fail(buf != NULL);
+ g_return_if_fail (pad != NULL);
+ g_return_if_fail (GST_IS_PAD (pad));
+ g_return_if_fail (buf != NULL);
mpeg2subt = GST_MPEG2SUBT (GST_OBJECT_PARENT (pad));
- data = GST_BUFFER_DATA(buf);
- size = GST_BUFFER_SIZE(buf);
+ data = GST_BUFFER_DATA (buf);
+ size = GST_BUFFER_SIZE (buf);
if (mpeg2subt->have_title && mpeg2subt->duration != 0) {
- gst_mpeg2subt_merge_title(mpeg2subt, buf);
+ gst_mpeg2subt_merge_title (mpeg2subt, buf);
mpeg2subt->duration--;
}
- gst_pad_push(mpeg2subt->srcpad, GST_DATA (buf));
+ gst_pad_push (mpeg2subt->srcpad, GST_DATA (buf));
}
static void
-gst_mpeg2subt_parse_header (GstMpeg2Subt *mpeg2subt)
+gst_mpeg2subt_parse_header (GstMpeg2Subt * mpeg2subt)
{
- guchar *buffer = GST_BUFFER_DATA(mpeg2subt->partialbuf);
+ guchar *buffer = GST_BUFFER_DATA (mpeg2subt->partialbuf);
guchar dummy;
guint i;
i = mpeg2subt->data_size + 4;
- while (i < mpeg2subt->packet_size)
- {
- dummy = buffer [i];
- switch (dummy)
- {
- case 0x01: /* null packet ? */
- i++;
- break;
- case 0x02: /* 02 ff (ff) is the end of the packet */
- i = mpeg2subt->packet_size;
- break;
- case 0x03: /* palette */
- mpeg2subt->color[0] = yuv_color[buffer [i+1] >> 4];
- mpeg2subt->color[1] = yuv_color[buffer [i+1] & 0xf];
- mpeg2subt->color[2] = yuv_color[buffer [i+2] >> 4];
- mpeg2subt->color[3] = yuv_color[buffer [i+2] & 0xf];
- mpeg2subt->color[4] = yuv_color[0xf];
- GST_DEBUG ("mpeg2subt: colors %d %d %d %d", mpeg2subt->color[0],mpeg2subt->color[1],mpeg2subt->color[2],mpeg2subt->color[3]);
- i += 3;
- break;
- case 0x04: /* transparency palette */
- mpeg2subt->trans[3] = buffer [i+1] >> 4;
- mpeg2subt->trans[2] = buffer [i+1] & 0xf;
- mpeg2subt->trans[1] = buffer [i+2] >> 4;
- mpeg2subt->trans[0] = buffer [i+2] & 0xf;
- GST_DEBUG ("mpeg2subt: transparency %d %d %d %d", mpeg2subt->trans[0],mpeg2subt->trans[1],mpeg2subt->trans[2],mpeg2subt->trans[3]);
+ while (i < mpeg2subt->packet_size) {
+ dummy = buffer[i];
+ switch (dummy) {
+ case 0x01: /* null packet ? */
+ i++;
+ break;
+ case 0x02: /* 02 ff (ff) is the end of the packet */
+ i = mpeg2subt->packet_size;
+ break;
+ case 0x03: /* palette */
+ mpeg2subt->color[0] = yuv_color[buffer[i + 1] >> 4];
+ mpeg2subt->color[1] = yuv_color[buffer[i + 1] & 0xf];
+ mpeg2subt->color[2] = yuv_color[buffer[i + 2] >> 4];
+ mpeg2subt->color[3] = yuv_color[buffer[i + 2] & 0xf];
+ mpeg2subt->color[4] = yuv_color[0xf];
+ GST_DEBUG ("mpeg2subt: colors %d %d %d %d", mpeg2subt->color[0],
+ mpeg2subt->color[1], mpeg2subt->color[2], mpeg2subt->color[3]);
i += 3;
break;
- case 0x05: /* image coordinates */
- mpeg2subt->width = 1 + ( ((buffer[i+2] & 0x0f) << 8) + buffer[i+3] )
- - ( (((unsigned int)buffer[i+1]) << 4) + (buffer[i+2] >> 4) );
- mpeg2subt->height = 1 + ( ((buffer[i+5] & 0x0f) << 8) + buffer[i+6] )
- - ( (((unsigned int)buffer[i+4]) << 4) + (buffer[i+5] >> 4) );
- i += 7;
+ case 0x04: /* transparency palette */
+ mpeg2subt->trans[3] = buffer[i + 1] >> 4;
+ mpeg2subt->trans[2] = buffer[i + 1] & 0xf;
+ mpeg2subt->trans[1] = buffer[i + 2] >> 4;
+ mpeg2subt->trans[0] = buffer[i + 2] & 0xf;
+ GST_DEBUG ("mpeg2subt: transparency %d %d %d %d", mpeg2subt->trans[0],
+ mpeg2subt->trans[1], mpeg2subt->trans[2], mpeg2subt->trans[3]);
+ i += 3;
break;
- case 0x06: /* image 1 / image 2 offsets */
- mpeg2subt->offset[0] = (((unsigned int)buffer[i+1]) << 8) + buffer[i+2];
- mpeg2subt->offset[1] = (((unsigned int)buffer[i+3]) << 8) + buffer[i+4];
+ case 0x05: /* image coordinates */
+ mpeg2subt->width = 1 + (((buffer[i + 2] & 0x0f) << 8) + buffer[i + 3])
+ - ((((unsigned int) buffer[i + 1]) << 4) + (buffer[i + 2] >> 4));
+ mpeg2subt->height = 1 + (((buffer[i + 5] & 0x0f) << 8) + buffer[i + 6])
+ - ((((unsigned int) buffer[i + 4]) << 4) + (buffer[i + 5] >> 4));
+ i += 7;
+ break;
+ case 0x06: /* image 1 / image 2 offsets */
+ mpeg2subt->offset[0] =
+ (((unsigned int) buffer[i + 1]) << 8) + buffer[i + 2];
+ mpeg2subt->offset[1] =
+ (((unsigned int) buffer[i + 3]) << 8) + buffer[i + 4];
i += 5;
break;
- case 0xff: /* "ff xx yy zz uu" with 'zz uu' == start of control packet
- * xx and yy are the end time in 90th/sec
- */
- mpeg2subt->duration = (((buffer[i+1] << 8) + buffer[i+2]) * 25)/90;
+ case 0xff: /* "ff xx yy zz uu" with 'zz uu' == start of control packet
+ * xx and yy are the end time in 90th/sec
+ */
+ mpeg2subt->duration =
+ (((buffer[i + 1] << 8) + buffer[i + 2]) * 25) / 90;
GST_DEBUG ("duration %d", mpeg2subt->duration);
- if ( (buffer[i+3] != buffer[mpeg2subt->data_size+2])
- || (buffer[i+4] != buffer[mpeg2subt->data_size+3]) )
- {
- g_print("mpeg2subt: invalid control header (%.2x%.2x != %.2x%.2x) !\n",
- buffer[i+3], buffer[i+4], buffer[mpeg2subt->data_size+2], buffer[mpeg2subt->data_size+3] );
+ if ((buffer[i + 3] != buffer[mpeg2subt->data_size + 2])
+ || (buffer[i + 4] != buffer[mpeg2subt->data_size + 3])) {
+ g_print
+ ("mpeg2subt: invalid control header (%.2x%.2x != %.2x%.2x) !\n",
+ buffer[i + 3], buffer[i + 4], buffer[mpeg2subt->data_size + 2],
+ buffer[mpeg2subt->data_size + 3]);
/* FIXME */
/* exit(1); */
}
i += 5;
break;
default:
- g_print("mpeg2subt: invalid sequence in control header (%.2x) !\n", dummy);
+ g_print ("mpeg2subt: invalid sequence in control header (%.2x) !\n",
+ dummy);
break;
}
}
}
static int
-get_nibble (guchar *buffer, gint *offset, gint id, gint *aligned)
+get_nibble (guchar * buffer, gint * offset, gint id, gint * aligned)
{
static int next;
- if (*aligned)
- {
+ if (*aligned) {
next = buffer[offset[id]];
offset[id]++;
*aligned = 0;
return next >> 4;
- }
- else
- {
+ } else {
*aligned = 1;
return next & 0xf;
}
}
static void
-gst_mpeg2subt_merge_title (GstMpeg2Subt *mpeg2subt, GstBuffer *buf)
+gst_mpeg2subt_merge_title (GstMpeg2Subt * mpeg2subt, GstBuffer * buf)
{
- gint x=0, y=0;
+ gint x = 0, y = 0;
gint width = mpeg2subt->width;
gint height = mpeg2subt->height;
- guchar *buffer = GST_BUFFER_DATA(mpeg2subt->partialbuf);
- guchar *target = GST_BUFFER_DATA(buf);
- gint id=0, aligned=1;
+ guchar *buffer = GST_BUFFER_DATA (mpeg2subt->partialbuf);
+ guchar *target = GST_BUFFER_DATA (buf);
+ gint id = 0, aligned = 1;
gint offset[2];
offset[0] = mpeg2subt->offset[0];
GST_DEBUG ("mpeg2subt: merging subtitle");
- while ((offset[1] < mpeg2subt->data_size + 2) && (y < height))
- {
+ while ((offset[1] < mpeg2subt->data_size + 2) && (y < height)) {
gint code;
gint length, colorid;
- code = get_nibble();
- if (code >= 0x4) /* 4 .. f */
- {
-found_code:
+ code = get_nibble ();
+ if (code >= 0x4) { /* 4 .. f */
+ found_code:
length = code >> 2;
colorid = code & 3;
while (length--)
- if (x++ < width) {
+ if (x++ < width) {
if (mpeg2subt->trans[colorid] != 0x0) {
- *target++ = mpeg2subt->color[colorid];
- }
- else target++;
+ *target++ = mpeg2subt->color[colorid];
+ } else
+ target++;
}
- if (x >= width)
- {
- if (!aligned)
- get_nibble ();
- goto next_line;
+ if (x >= width) {
+ if (!aligned)
+ get_nibble ();
+ goto next_line;
}
continue;
}
- code = (code << 4) + get_nibble();
- if (code >= 0x10) /* 1x .. 3x */
+ code = (code << 4) + get_nibble ();
+ if (code >= 0x10) /* 1x .. 3x */
goto found_code;
- code = (code << 4) + get_nibble();
- if (code >= 0x40) /* 04x .. 0fx */
+ code = (code << 4) + get_nibble ();
+ if (code >= 0x40) /* 04x .. 0fx */
goto found_code;
- code = (code << 4) + get_nibble();
- if (code >= 0x100) /* 01xx .. 03xx */
+ code = (code << 4) + get_nibble ();
+ if (code >= 0x100) /* 01xx .. 03xx */
goto found_code;
/* 00xx - should only happen for 00 00 */
if (!aligned)
- code = (code << 4) + get_nibble(); /* 0 0x xx */
+ code = (code << 4) + get_nibble (); /* 0 0x xx */
- if (code)
- {
- g_print("mpeg2subt: got unknown code 00%x (offset %x side %x, x=%d, y=%d)\n", code, mpeg2subt->offset[id], id, x, y);
+ if (code) {
+ g_print
+ ("mpeg2subt: got unknown code 00%x (offset %x side %x, x=%d, y=%d)\n",
+ code, mpeg2subt->offset[id], id, x, y);
goto next_line;
}
-next_line:
+ next_line:
/* aligned 00 00 */
if (y < height) {
- target+=(width-x);
+ target += (width - x);
x = 0;
y++;
id = 1 - id;
}
static void
-gst_mpeg2subt_chain_subtitle (GstPad *pad, GstData *_data)
+gst_mpeg2subt_chain_subtitle (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstMpeg2Subt *mpeg2subt;
guchar *data;
glong size = 0;
- g_return_if_fail(pad != NULL);
- g_return_if_fail(GST_IS_PAD(pad));
- g_return_if_fail(buf != NULL);
+ g_return_if_fail (pad != NULL);
+ g_return_if_fail (GST_IS_PAD (pad));
+ g_return_if_fail (buf != NULL);
/* g_return_if_fail(GST_IS_BUFFER(buf)); */
mpeg2subt = GST_MPEG2SUBT (GST_OBJECT_PARENT (pad));
if (mpeg2subt->have_title) {
- gst_buffer_unref(mpeg2subt->partialbuf);
+ gst_buffer_unref (mpeg2subt->partialbuf);
mpeg2subt->partialbuf = NULL;
mpeg2subt->have_title = FALSE;
}
- GST_DEBUG ("presentation time %" G_GUINT64_FORMAT, GST_BUFFER_TIMESTAMP(buf));
+ GST_DEBUG ("presentation time %" G_GUINT64_FORMAT,
+ GST_BUFFER_TIMESTAMP (buf));
/* deal with partial frame from previous buffer */
if (mpeg2subt->partialbuf) {
GstBuffer *merge;
- merge = gst_buffer_merge(mpeg2subt->partialbuf, buf);
+
+ merge = gst_buffer_merge (mpeg2subt->partialbuf, buf);
gst_buffer_unref (mpeg2subt->partialbuf);
- gst_buffer_unref(buf);
+ gst_buffer_unref (buf);
mpeg2subt->partialbuf = merge;
- }
- else {
+ } else {
mpeg2subt->partialbuf = buf;
}
- data = GST_BUFFER_DATA(mpeg2subt->partialbuf);
- size = GST_BUFFER_SIZE(mpeg2subt->partialbuf);
+ data = GST_BUFFER_DATA (mpeg2subt->partialbuf);
+ size = GST_BUFFER_SIZE (mpeg2subt->partialbuf);
- mpeg2subt->packet_size = GUINT16_FROM_BE(*(guint16 *)data);
+ mpeg2subt->packet_size = GUINT16_FROM_BE (*(guint16 *) data);
if (mpeg2subt->packet_size == size) {
- GST_DEBUG ("mpeg2subt: subtitle packet size %d, current size %ld", mpeg2subt->packet_size, size);
+ GST_DEBUG ("mpeg2subt: subtitle packet size %d, current size %ld",
+ mpeg2subt->packet_size, size);
- mpeg2subt->data_size = GUINT16_FROM_BE(*(guint16 *)(data+2));
+ mpeg2subt->data_size = GUINT16_FROM_BE (*(guint16 *) (data + 2));
- gst_mpeg2subt_parse_header(mpeg2subt);
+ gst_mpeg2subt_parse_header (mpeg2subt);
mpeg2subt->have_title = TRUE;
}
}
static void
-gst_mpeg2subt_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_mpeg2subt_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstMpeg2Subt *src;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_MPEG2SUBT(object));
- src = GST_MPEG2SUBT(object);
+ g_return_if_fail (GST_IS_MPEG2SUBT (object));
+ src = GST_MPEG2SUBT (object);
switch (prop_id) {
default:
}
static void
-gst_mpeg2subt_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_mpeg2subt_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstMpeg2Subt *src;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_MPEG2SUBT(object));
- src = GST_MPEG2SUBT(object);
+ g_return_if_fail (GST_IS_MPEG2SUBT (object));
+ src = GST_MPEG2SUBT (object);
switch (prop_id) {
default:
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- return gst_element_register(plugin, "mpeg2subt",
- GST_RANK_NONE, GST_TYPE_MPEG2SUBT);
+ return gst_element_register (plugin, "mpeg2subt",
+ GST_RANK_NONE, GST_TYPE_MPEG2SUBT);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "mpeg2sub",
- "MPEG-2 video subtitle parser",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "mpeg2sub",
+ "MPEG-2 video subtitle parser",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_MPEG2SUBT \
#define GST_IS_MPEG2SUBT_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MPEG2SUBT))
-typedef struct _GstMpeg2Subt GstMpeg2Subt;
-typedef struct _GstMpeg2SubtClass GstMpeg2SubtClass;
+ typedef struct _GstMpeg2Subt GstMpeg2Subt;
+ typedef struct _GstMpeg2SubtClass GstMpeg2SubtClass;
-struct _GstMpeg2Subt {
- GstElement element;
+ struct _GstMpeg2Subt
+ {
+ GstElement element;
- GstPad *videopad,*subtitlepad,*srcpad;
+ GstPad *videopad, *subtitlepad, *srcpad;
- GstBuffer *partialbuf; /* previous buffer (if carryover) */
+ GstBuffer *partialbuf; /* previous buffer (if carryover) */
- gboolean have_title;
+ gboolean have_title;
- guint16 packet_size;
- guint16 data_size;
+ guint16 packet_size;
+ guint16 data_size;
- gint offset[2];
- guchar color[5];
- guchar trans[4];
+ gint offset[2];
+ guchar color[5];
+ guchar trans[4];
- guint duration;
+ guint duration;
- gint width, height;
+ gint width, height;
-};
+ };
-struct _GstMpeg2SubtClass {
- GstElementClass parent_class;
-};
+ struct _GstMpeg2SubtClass
+ {
+ GstElementClass parent_class;
+ };
-GType gst_mpeg2subt_get_type(void);
+ GType gst_mpeg2subt_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_MPEG2SUBT_H__ */
+#endif /* __GST_MPEG2SUBT_H__ */
"Erik Walthinsen <omega@cse.ogi.edu>"
};
-static GstStaticPadTemplate mp3_src_template =
-GST_STATIC_PAD_TEMPLATE (
- "src",
+static GstStaticPadTemplate mp3_src_template = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/mpeg, "
- "mpegversion = (int) 1, "
- "layer = (int) [ 1, 3 ], "
- "rate = (int) [ 8000, 48000], "
- "channels = (int) [ 1, 2 ]")
-);
-
-static GstStaticPadTemplate mp3_sink_template =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
+ "mpegversion = (int) 1, "
+ "layer = (int) [ 1, 3 ], "
+ "rate = (int) [ 8000, 48000], " "channels = (int) [ 1, 2 ]")
+ );
+
+static GstStaticPadTemplate mp3_sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/mpeg, "
- "mpegversion = (int) 1"
- )
-);
+ GST_STATIC_CAPS ("audio/mpeg, " "mpegversion = (int) 1")
+ );
/* GstMPEGAudioParse signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_SKIP,
ARG_BIT_RATE,
};
-static void gst_mp3parse_class_init (GstMPEGAudioParseClass *klass);
-static void gst_mp3parse_base_init (GstMPEGAudioParseClass *klass);
-static void gst_mp3parse_init (GstMPEGAudioParse *mp3parse);
+static void gst_mp3parse_class_init (GstMPEGAudioParseClass * klass);
+static void gst_mp3parse_base_init (GstMPEGAudioParseClass * klass);
+static void gst_mp3parse_init (GstMPEGAudioParse * mp3parse);
-static void gst_mp3parse_chain (GstPad *pad,GstData *_data);
-static long bpf_from_header (GstMPEGAudioParse *parse, unsigned long header);
-static int head_check (unsigned long head);
+static void gst_mp3parse_chain (GstPad * pad, GstData * _data);
+static long bpf_from_header (GstMPEGAudioParse * parse, unsigned long header);
+static int head_check (unsigned long head);
-static void gst_mp3parse_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void gst_mp3parse_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
-static GstElementStateReturn
- gst_mp3parse_change_state (GstElement *element);
+static void gst_mp3parse_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_mp3parse_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+static GstElementStateReturn gst_mp3parse_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_mp3parse_signals[LAST_SIGNAL] = { 0 }; */
GType
-gst_mp3parse_get_type(void) {
+gst_mp3parse_get_type (void)
+{
static GType mp3parse_type = 0;
if (!mp3parse_type) {
static const GTypeInfo mp3parse_info = {
- sizeof(GstMPEGAudioParseClass),
- (GBaseInitFunc)gst_mp3parse_base_init,
+ sizeof (GstMPEGAudioParseClass),
+ (GBaseInitFunc) gst_mp3parse_base_init,
NULL,
- (GClassInitFunc)gst_mp3parse_class_init,
+ (GClassInitFunc) gst_mp3parse_class_init,
NULL,
NULL,
- sizeof(GstMPEGAudioParse),
+ sizeof (GstMPEGAudioParse),
0,
- (GInstanceInitFunc)gst_mp3parse_init,
+ (GInstanceInitFunc) gst_mp3parse_init,
};
mp3parse_type = g_type_register_static (GST_TYPE_ELEMENT,
- "GstMPEGAudioParse",
- &mp3parse_info, 0);
+ "GstMPEGAudioParse", &mp3parse_info, 0);
}
return mp3parse_type;
}
static guint mp3types_bitrates[2][3][16] =
-{ { {0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, },
- {0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, },
- {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, } },
- { {0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256, },
- {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, },
- {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, } },
+ { {{0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448,},
+ {0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384,},
+ {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320,}},
+{{0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256,},
+ {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160,},
+ {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160,}},
};
-static guint mp3types_freqs[3][3] =
-{ {44100, 48000, 32000},
- {22050, 24000, 16000},
- {11025, 12000, 8000}};
+static guint mp3types_freqs[3][3] = { {44100, 48000, 32000},
+{22050, 24000, 16000},
+{11025, 12000, 8000}
+};
static inline guint
-mp3_type_frame_length_from_header (guint32 header, guint *put_layer,
- guint *put_channels, guint *put_bitrate,
- guint *put_samplerate)
+mp3_type_frame_length_from_header (guint32 header, guint * put_layer,
+ guint * put_channels, guint * put_bitrate, guint * put_samplerate)
{
guint length;
gulong mode, samplerate, bitrate, layer, channels, padding;
GST_DEBUG ("Calculated mp3 frame length of %u bytes", length);
GST_DEBUG ("samplerate = %lu, bitrate = %lu, layer = %lu, channels = %lu",
- samplerate, bitrate, layer, channels);
+ samplerate, bitrate, layer, channels);
if (put_layer)
*put_layer = layer;
#define GST_MP3_TYPEFIND_MIN_DATA (1440 * (GST_MP3_TYPEFIND_MIN_HEADERS + 1) - 1 + 3)
static GstCaps *
-mp3_caps_create (guint layer, guint channels,
- guint bitrate, guint samplerate)
+mp3_caps_create (guint layer, guint channels, guint bitrate, guint samplerate)
{
GstCaps *new;
new = gst_caps_new_simple ("audio/mpeg",
"mpegversion", G_TYPE_INT, 1,
- "layer", G_TYPE_INT, layer,
- "rate", G_TYPE_INT, samplerate,
- "channels", G_TYPE_INT, channels, NULL);
+ "layer", G_TYPE_INT, layer,
+ "rate", G_TYPE_INT, samplerate, "channels", G_TYPE_INT, channels, NULL);
return new;
}
static void
-gst_mp3parse_base_init (GstMPEGAudioParseClass *klass)
+gst_mp3parse_base_init (GstMPEGAudioParseClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
}
static void
-gst_mp3parse_class_init (GstMPEGAudioParseClass *klass)
+gst_mp3parse_class_init (GstMPEGAudioParseClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- gobject_class = (GObjectClass*)klass;
- gstelement_class = (GstElementClass*)klass;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_SKIP,
- g_param_spec_int("skip","skip","skip",
- G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_BIT_RATE,
- g_param_spec_int("bitrate","Bitrate","Bit Rate",
- G_MININT,G_MAXINT,0,G_PARAM_READABLE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SKIP, g_param_spec_int ("skip", "skip", "skip", G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BIT_RATE, g_param_spec_int ("bitrate", "Bitrate", "Bit Rate", G_MININT, G_MAXINT, 0, G_PARAM_READABLE)); /* CHECKME */
- parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
+ parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
gobject_class->set_property = gst_mp3parse_set_property;
gobject_class->get_property = gst_mp3parse_get_property;
}
static void
-gst_mp3parse_init (GstMPEGAudioParse *mp3parse)
+gst_mp3parse_init (GstMPEGAudioParse * mp3parse)
{
- mp3parse->sinkpad = gst_pad_new_from_template(
- gst_static_pad_template_get (&mp3_sink_template), "sink");
- gst_element_add_pad(GST_ELEMENT(mp3parse),mp3parse->sinkpad);
-
- gst_pad_set_chain_function(mp3parse->sinkpad,gst_mp3parse_chain);
- gst_element_set_loop_function (GST_ELEMENT(mp3parse),NULL);
-
- mp3parse->srcpad = gst_pad_new_from_template(
- gst_static_pad_template_get (&mp3_src_template), "src");
- gst_element_add_pad(GST_ELEMENT(mp3parse),mp3parse->srcpad);
+ mp3parse->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&mp3_sink_template), "sink");
+ gst_element_add_pad (GST_ELEMENT (mp3parse), mp3parse->sinkpad);
+
+ gst_pad_set_chain_function (mp3parse->sinkpad, gst_mp3parse_chain);
+ gst_element_set_loop_function (GST_ELEMENT (mp3parse), NULL);
+
+ mp3parse->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&mp3_src_template), "src");
+ gst_element_add_pad (GST_ELEMENT (mp3parse), mp3parse->srcpad);
gst_pad_use_explicit_caps (mp3parse->srcpad);
/*gst_pad_set_type_id(mp3parse->srcpad, mp3frametype); */
}
static void
-gst_mp3parse_chain (GstPad *pad, GstData *_data)
+gst_mp3parse_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstMPEGAudioParse *mp3parse;
guchar *data;
- glong size,offset = 0;
+ glong size, offset = 0;
guint32 header;
int bpf;
GstBuffer *outbuf;
guint64 last_ts;
- g_return_if_fail(pad != NULL);
- g_return_if_fail(GST_IS_PAD(pad));
- g_return_if_fail(buf != NULL);
+ g_return_if_fail (pad != NULL);
+ g_return_if_fail (GST_IS_PAD (pad));
+ g_return_if_fail (buf != NULL);
/* g_return_if_fail(GST_IS_BUFFER(buf)); */
mp3parse = GST_MP3PARSE (gst_pad_get_parent (pad));
- GST_DEBUG ("mp3parse: received buffer of %d bytes",GST_BUFFER_SIZE(buf));
+ GST_DEBUG ("mp3parse: received buffer of %d bytes", GST_BUFFER_SIZE (buf));
- last_ts = GST_BUFFER_TIMESTAMP(buf);
+ last_ts = GST_BUFFER_TIMESTAMP (buf);
/* FIXME, do flush */
/*
- if (mp3parse->partialbuf) {
- gst_buffer_unref(mp3parse->partialbuf);
- mp3parse->partialbuf = NULL;
- }
- mp3parse->in_flush = TRUE;
- */
+ if (mp3parse->partialbuf) {
+ gst_buffer_unref(mp3parse->partialbuf);
+ mp3parse->partialbuf = NULL;
+ }
+ mp3parse->in_flush = TRUE;
+ */
/* if we have something left from the previous frame */
if (mp3parse->partialbuf) {
GstBuffer *newbuf;
- newbuf = gst_buffer_merge(mp3parse->partialbuf, buf);
+ newbuf = gst_buffer_merge (mp3parse->partialbuf, buf);
/* and the one we received.. */
- gst_buffer_unref(buf);
- gst_buffer_unref(mp3parse->partialbuf);
+ gst_buffer_unref (buf);
+ gst_buffer_unref (mp3parse->partialbuf);
mp3parse->partialbuf = newbuf;
- }
- else {
+ } else {
mp3parse->partialbuf = buf;
}
- size = GST_BUFFER_SIZE(mp3parse->partialbuf);
- data = GST_BUFFER_DATA(mp3parse->partialbuf);
+ size = GST_BUFFER_SIZE (mp3parse->partialbuf);
+ data = GST_BUFFER_DATA (mp3parse->partialbuf);
/* while we still have bytes left -4 for the header */
- while (offset < size-4) {
+ while (offset < size - 4) {
int skipped = 0;
- GST_DEBUG ("mp3parse: offset %ld, size %ld ",offset, size);
+ GST_DEBUG ("mp3parse: offset %ld, size %ld ", offset, size);
/* search for a possible start byte */
- for (;((data[offset] != 0xff) && (offset < size));offset++) skipped++;
+ for (; ((data[offset] != 0xff) && (offset < size)); offset++)
+ skipped++;
if (skipped && !mp3parse->in_flush) {
- GST_DEBUG ("mp3parse: **** now at %ld skipped %d bytes",offset,skipped);
+ GST_DEBUG ("mp3parse: **** now at %ld skipped %d bytes", offset, skipped);
}
/* construct the header word */
- header = GUINT32_FROM_BE(*((guint32 *)(data+offset)));
+ header = GUINT32_FROM_BE (*((guint32 *) (data + offset)));
/* if it's a valid header, go ahead and send off the frame */
- if (head_check(header)) {
+ if (head_check (header)) {
/* calculate the bpf of the frame */
- bpf = bpf_from_header(mp3parse, header);
+ bpf = bpf_from_header (mp3parse, header);
/********************************************************************************
* robust seek support
* from previous frames. In this case, seeking may be more complicated because
* the frames are not independently coded.
********************************************************************************/
- if ( mp3parse->in_flush ) {
- guint32 header2;
+ if (mp3parse->in_flush) {
+ guint32 header2;
- if ((size-offset)<(bpf+4)) { if (mp3parse->in_flush) break; } /* wait until we have the the entire current frame as well as the next frame header */
-
- header2 = GUINT32_FROM_BE(*((guint32 *)(data+offset+bpf)));
- GST_DEBUG ("mp3parse: header=%08X, header2=%08X, bpf=%d", (unsigned int)header, (unsigned int)header2, bpf );
+ if ((size - offset) < (bpf + 4)) {
+ if (mp3parse->in_flush)
+ break;
+ }
+ /* wait until we have the the entire current frame as well as the next frame header */
+ header2 = GUINT32_FROM_BE (*((guint32 *) (data + offset + bpf)));
+ GST_DEBUG ("mp3parse: header=%08X, header2=%08X, bpf=%d",
+ (unsigned int) header, (unsigned int) header2, bpf);
/* mask the bits which are allowed to differ between frames */
#define HDRMASK ~((0xF << 12) /* bitrate */ | \
(0x1 << 9) /* padding */ | \
- (0x3 << 4)) /*mode extension*/
-
- if ( (header2&HDRMASK) != (header&HDRMASK) ) { /* require 2 matching headers in a row */
- GST_DEBUG ("mp3parse: next header doesn't match (header=%08X, header2=%08X, bpf=%d)", (unsigned int)header, (unsigned int)header2, bpf );
- offset++; /* This frame is invalid. Start looking for a valid frame at the next position in the stream */
- continue;
- }
+ (0x3 << 4)) /*mode extension */
+
+ if ((header2 & HDRMASK) != (header & HDRMASK)) { /* require 2 matching headers in a row */
+ GST_DEBUG
+ ("mp3parse: next header doesn't match (header=%08X, header2=%08X, bpf=%d)",
+ (unsigned int) header, (unsigned int) header2, bpf);
+ offset++; /* This frame is invalid. Start looking for a valid frame at the next position in the stream */
+ continue;
+ }
}
/* if we don't have the whole frame... */
if ((size - offset) < bpf) {
- GST_DEBUG ("mp3parse: partial buffer needed %ld < %d ",(size-offset), bpf);
+ GST_DEBUG ("mp3parse: partial buffer needed %ld < %d ", (size - offset),
+ bpf);
break;
} else {
- guint bitrate, layer, rate, channels;
-
- if (!mp3_type_frame_length_from_header (header, &layer,
- &channels,
- &bitrate, &rate)) {
- g_error("Header failed internal error");
- }
- if (channels != mp3parse->channels ||
- rate != mp3parse->rate ||
- layer != mp3parse->layer ||
- bitrate != mp3parse->bit_rate) {
- GstCaps *caps = mp3_caps_create (layer, channels, bitrate, rate);
-
- gst_pad_set_explicit_caps(mp3parse->srcpad, caps);
-
- mp3parse->channels = channels;
- mp3parse->layer = layer;
- mp3parse->rate = rate;
- mp3parse->bit_rate = bitrate;
- }
-
- outbuf = gst_buffer_create_sub(mp3parse->partialbuf,offset,bpf);
-
- offset += bpf;
+ guint bitrate, layer, rate, channels;
+
+ if (!mp3_type_frame_length_from_header (header, &layer,
+ &channels, &bitrate, &rate)) {
+ g_error ("Header failed internal error");
+ }
+ if (channels != mp3parse->channels ||
+ rate != mp3parse->rate ||
+ layer != mp3parse->layer || bitrate != mp3parse->bit_rate) {
+ GstCaps *caps = mp3_caps_create (layer, channels, bitrate, rate);
+
+ gst_pad_set_explicit_caps (mp3parse->srcpad, caps);
+
+ mp3parse->channels = channels;
+ mp3parse->layer = layer;
+ mp3parse->rate = rate;
+ mp3parse->bit_rate = bitrate;
+ }
+
+ outbuf = gst_buffer_create_sub (mp3parse->partialbuf, offset, bpf);
+
+ offset += bpf;
if (mp3parse->skip == 0) {
- GST_DEBUG ("mp3parse: pushing buffer of %d bytes",GST_BUFFER_SIZE(outbuf));
+ GST_DEBUG ("mp3parse: pushing buffer of %d bytes",
+ GST_BUFFER_SIZE (outbuf));
if (mp3parse->in_flush) {
/* FIXME do some sort of flush event */
mp3parse->in_flush = FALSE;
}
- GST_BUFFER_TIMESTAMP(outbuf) = last_ts;
- GST_BUFFER_DURATION(outbuf) = 8 * (GST_SECOND/1000) * GST_BUFFER_SIZE(outbuf) / mp3parse->bit_rate;
-
- if (GST_PAD_CAPS (mp3parse->srcpad) != NULL) {
- gst_pad_push(mp3parse->srcpad,GST_DATA (outbuf));
- } else {
- GST_DEBUG ("No capsnego yet, delaying buffer push");
- gst_buffer_unref (outbuf);
- }
- }
- else {
- GST_DEBUG ("mp3parse: skipping buffer of %d bytes",GST_BUFFER_SIZE(outbuf));
- gst_buffer_unref(outbuf);
+ GST_BUFFER_TIMESTAMP (outbuf) = last_ts;
+ GST_BUFFER_DURATION (outbuf) =
+ 8 * (GST_SECOND / 1000) * GST_BUFFER_SIZE (outbuf) /
+ mp3parse->bit_rate;
+
+ if (GST_PAD_CAPS (mp3parse->srcpad) != NULL) {
+ gst_pad_push (mp3parse->srcpad, GST_DATA (outbuf));
+ } else {
+ GST_DEBUG ("No capsnego yet, delaying buffer push");
+ gst_buffer_unref (outbuf);
+ }
+ } else {
+ GST_DEBUG ("mp3parse: skipping buffer of %d bytes",
+ GST_BUFFER_SIZE (outbuf));
+ gst_buffer_unref (outbuf);
mp3parse->skip--;
}
}
} else {
offset++;
- if (!mp3parse->in_flush) GST_DEBUG ("mp3parse: *** wrong header, skipping byte (FIXME?)");
+ if (!mp3parse->in_flush)
+ GST_DEBUG ("mp3parse: *** wrong header, skipping byte (FIXME?)");
}
}
/* if we have processed this block and there are still */
/* bytes left not in a partial block, copy them over. */
- if (size-offset > 0) {
+ if (size - offset > 0) {
glong remainder = (size - offset);
- GST_DEBUG ("mp3parse: partial buffer needed %ld for trailing bytes",remainder);
- outbuf = gst_buffer_create_sub(mp3parse->partialbuf,offset,remainder);
- gst_buffer_unref(mp3parse->partialbuf);
+ GST_DEBUG ("mp3parse: partial buffer needed %ld for trailing bytes",
+ remainder);
+
+ outbuf = gst_buffer_create_sub (mp3parse->partialbuf, offset, remainder);
+ gst_buffer_unref (mp3parse->partialbuf);
mp3parse->partialbuf = outbuf;
- }
- else {
- gst_buffer_unref(mp3parse->partialbuf);
+ } else {
+ gst_buffer_unref (mp3parse->partialbuf);
mp3parse->partialbuf = NULL;
}
}
static long
-bpf_from_header (GstMPEGAudioParse *parse, unsigned long header)
+bpf_from_header (GstMPEGAudioParse * parse, unsigned long header)
{
guint bitrate, layer, rate, channels, length;
if (!(length = mp3_type_frame_length_from_header (header, &layer,
- &channels,
- &bitrate, &rate))) {
+ &channels, &bitrate, &rate))) {
return 0;
}
static gboolean
head_check (unsigned long head)
{
- GST_DEBUG ("checking mp3 header 0x%08lx",head);
+ GST_DEBUG ("checking mp3 header 0x%08lx", head);
/* if it's not a valid sync */
if ((head & 0xffe00000) != 0xffe00000) {
- GST_DEBUG ("invalid sync");return FALSE; }
+ GST_DEBUG ("invalid sync");
+ return FALSE;
+ }
/* if it's an invalid MPEG version */
if (((head >> 19) & 3) == 0x1) {
- GST_DEBUG ("invalid MPEG version");return FALSE; }
+ GST_DEBUG ("invalid MPEG version");
+ return FALSE;
+ }
/* if it's an invalid layer */
if (!((head >> 17) & 3)) {
- GST_DEBUG ("invalid layer");return FALSE; }
+ GST_DEBUG ("invalid layer");
+ return FALSE;
+ }
/* if it's an invalid bitrate */
if (((head >> 12) & 0xf) == 0x0) {
- GST_DEBUG ("invalid bitrate");return FALSE; }
+ GST_DEBUG ("invalid bitrate");
+ return FALSE;
+ }
if (((head >> 12) & 0xf) == 0xf) {
- GST_DEBUG ("invalid bitrate");return FALSE; }
+ GST_DEBUG ("invalid bitrate");
+ return FALSE;
+ }
/* if it's an invalid samplerate */
if (((head >> 10) & 0x3) == 0x3) {
- GST_DEBUG ("invalid samplerate");return FALSE; }
- if ((head & 0xffff0000) == 0xfffe0000) {
- GST_DEBUG ("invalid sync");return FALSE; }
+ GST_DEBUG ("invalid samplerate");
+ return FALSE;
+ }
+ if ((head & 0xffff0000) == 0xfffe0000) {
+ GST_DEBUG ("invalid sync");
+ return FALSE;
+ }
if (head & 0x00000002) {
- GST_DEBUG ("invalid emphasis");return FALSE; }
+ GST_DEBUG ("invalid emphasis");
+ return FALSE;
+ }
return TRUE;
}
static void
-gst_mp3parse_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_mp3parse_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstMPEGAudioParse *src;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_MP3PARSE(object));
- src = GST_MP3PARSE(object);
+ g_return_if_fail (GST_IS_MP3PARSE (object));
+ src = GST_MP3PARSE (object);
switch (prop_id) {
case ARG_SKIP:
}
static void
-gst_mp3parse_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_mp3parse_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstMPEGAudioParse *src;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_MP3PARSE(object));
- src = GST_MP3PARSE(object);
+ g_return_if_fail (GST_IS_MP3PARSE (object));
+ src = GST_MP3PARSE (object);
switch (prop_id) {
case ARG_SKIP:
}
}
-static GstElementStateReturn
-gst_mp3parse_change_state (GstElement *element)
+static GstElementStateReturn
+gst_mp3parse_change_state (GstElement * element)
{
GstMPEGAudioParse *src;
- g_return_val_if_fail(GST_IS_MP3PARSE(element), GST_STATE_FAILURE);
- src = GST_MP3PARSE(element);
+ g_return_val_if_fail (GST_IS_MP3PARSE (element), GST_STATE_FAILURE);
+ src = GST_MP3PARSE (element);
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_PAUSED_TO_READY:
- src->channels = -1; src->rate = -1; src->layer = -1;
+ src->channels = -1;
+ src->rate = -1;
+ src->layer = -1;
break;
default:
break;
}
- if (GST_ELEMENT_CLASS(parent_class)->change_state)
- return GST_ELEMENT_CLASS(parent_class)->change_state(element);
+ if (GST_ELEMENT_CLASS (parent_class)->change_state)
+ return GST_ELEMENT_CLASS (parent_class)->change_state (element);
return GST_STATE_SUCCESS;
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
return gst_element_register (plugin, "mp3parse",
- GST_RANK_NONE, GST_TYPE_MP3PARSE);
+ GST_RANK_NONE, GST_TYPE_MP3PARSE);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "mpegaudioparse",
- "MPEG-1 layer 1/2/3 audio parser",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "mpegaudioparse",
+ "MPEG-1 layer 1/2/3 audio parser",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_MP3PARSE \
#define GST_IS_MP3PARSE_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MP3PARSE))
-typedef struct _GstMPEGAudioParse GstMPEGAudioParse;
-typedef struct _GstMPEGAudioParseClass GstMPEGAudioParseClass;
+ typedef struct _GstMPEGAudioParse GstMPEGAudioParse;
+ typedef struct _GstMPEGAudioParseClass GstMPEGAudioParseClass;
-struct _GstMPEGAudioParse {
- GstElement element;
+ struct _GstMPEGAudioParse
+ {
+ GstElement element;
- GstPad *sinkpad,*srcpad;
+ GstPad *sinkpad, *srcpad;
- GstBuffer *partialbuf; /* previous buffer (if carryover) */
- guint skip; /* number of frames to skip */
- guint bit_rate;
- gint channels, rate, layer;
- gboolean in_flush;
-};
+ GstBuffer *partialbuf; /* previous buffer (if carryover) */
+ guint skip; /* number of frames to skip */
+ guint bit_rate;
+ gint channels, rate, layer;
+ gboolean in_flush;
+ };
-struct _GstMPEGAudioParseClass {
- GstElementClass parent_class;
-};
+ struct _GstMPEGAudioParseClass
+ {
+ GstElementClass parent_class;
+ };
-GType gst_mp3parse_get_type(void);
+ GType gst_mp3parse_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __MP3PARSE_H__ */
+#endif /* __MP3PARSE_H__ */
};
static GstStaticPadTemplate overlay_src_factory =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV("I420"))
-);
+GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420"))
+ );
static GstStaticPadTemplate overlay_sink1_factory =
-GST_STATIC_PAD_TEMPLATE (
- "sink1",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV("I420"))
-);
+GST_STATIC_PAD_TEMPLATE ("sink1",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420"))
+ );
static GstStaticPadTemplate overlay_sink2_factory =
-GST_STATIC_PAD_TEMPLATE (
- "sink2",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV("I420"))
-);
+GST_STATIC_PAD_TEMPLATE ("sink2",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420"))
+ );
static GstStaticPadTemplate overlay_sink3_factory =
-GST_STATIC_PAD_TEMPLATE (
- "sink3",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV("I420"))
-);
+GST_STATIC_PAD_TEMPLATE ("sink3",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420"))
+ );
/* OVERLAY signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
};
-static void gst_overlay_class_init (GstOverlayClass *klass);
-static void gst_overlay_base_init (GstOverlayClass *klass);
-static void gst_overlay_init (GstOverlay *overlay);
+static void gst_overlay_class_init (GstOverlayClass * klass);
+static void gst_overlay_base_init (GstOverlayClass * klass);
+static void gst_overlay_init (GstOverlay * overlay);
-static void gst_overlay_loop (GstElement *element);
+static void gst_overlay_loop (GstElement * element);
-static void gst_overlay_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_overlay_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static void gst_overlay_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_overlay_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_overlay_signals[LAST_SIGNAL] = { 0 }; */
static GType
if (!overlay_type) {
static const GTypeInfo overlay_info = {
- sizeof(GstOverlayClass),
- (GBaseInitFunc)gst_overlay_base_init,
+ sizeof (GstOverlayClass),
+ (GBaseInitFunc) gst_overlay_base_init,
NULL,
- (GClassInitFunc)gst_overlay_class_init,
+ (GClassInitFunc) gst_overlay_class_init,
NULL,
NULL,
- sizeof(GstOverlay),
+ sizeof (GstOverlay),
0,
- (GInstanceInitFunc)gst_overlay_init,
+ (GInstanceInitFunc) gst_overlay_init,
};
- overlay_type = g_type_register_static(GST_TYPE_ELEMENT, "GstOverlay", &overlay_info, 0);
+ overlay_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstOverlay", &overlay_info,
+ 0);
}
return overlay_type;
}
static void
-gst_overlay_base_init (GstOverlayClass *klass)
+gst_overlay_base_init (GstOverlayClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&overlay_sink1_factory));
+ gst_static_pad_template_get (&overlay_sink1_factory));
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&overlay_sink2_factory));
+ gst_static_pad_template_get (&overlay_sink2_factory));
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&overlay_sink3_factory));
+ gst_static_pad_template_get (&overlay_sink3_factory));
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&overlay_src_factory));
+ gst_static_pad_template_get (&overlay_src_factory));
gst_element_class_set_details (element_class, &overlay_details);
}
static void
-gst_overlay_class_init (GstOverlayClass *klass)
+gst_overlay_class_init (GstOverlayClass * 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);
gobject_class->set_property = gst_overlay_set_property;
gobject_class->get_property = gst_overlay_get_property;
}
#if 0
-static GstCaps *gst_overlay_getcaps(GstPad *pad)
+static GstCaps *
+gst_overlay_getcaps (GstPad * pad)
{
GstCaps *caps;
GstOverlay *overlay;
overlay = GST_OVERLAY (gst_pad_get_parent (pad));
- if(overlay->width && overlay->height){
- caps = GST_STATIC_CAPS (
- "overlay_sink2",
- "video/raw",
- "format", GST_TYPE_FOURCC (GST_MAKE_FOURCC ('I','4','2','0')),
- "width", G_TYPE_INT (overlay->width),
- "height", G_TYPE_INT (overlay->height)
- );
- }else{
- caps = GST_STATIC_CAPS (
- "overlay_sink2",
- "video/raw",
- "format", GST_TYPE_FOURCC (GST_MAKE_FOURCC ('I','4','2','0')),
- "width", G_TYPE_INT_RANGE (0, 4096),
- "height", G_TYPE_INT_RANGE (0, 4096)
- );
+ if (overlay->width && overlay->height) {
+ caps = GST_STATIC_CAPS ("overlay_sink2",
+ "video/raw",
+ "format", GST_TYPE_FOURCC (GST_MAKE_FOURCC ('I', '4', '2', '0')),
+ "width", G_TYPE_INT (overlay->width),
+ "height", G_TYPE_INT (overlay->height)
+ );
+ } else {
+ caps = GST_STATIC_CAPS ("overlay_sink2",
+ "video/raw",
+ "format", GST_TYPE_FOURCC (GST_MAKE_FOURCC ('I', '4', '2', '0')),
+ "width", G_TYPE_INT_RANGE (0, 4096),
+ "height", G_TYPE_INT_RANGE (0, 4096)
+ );
}
return caps;
#endif
static gboolean
-gst_overlay_sinkconnect (GstPad *pad, const GstCaps *caps)
+gst_overlay_sinkconnect (GstPad * pad, const GstCaps * caps)
{
GstOverlay *overlay;
GstStructure *structure;
structure = gst_caps_get_structure (caps, 0);
- gst_structure_get_int (structure, "width", &overlay->width);
- gst_structure_get_int (structure, "height", &overlay->height);
- gst_structure_get_double (structure, "framerate", &overlay->framerate);
+ gst_structure_get_int (structure, "width", &overlay->width);
+ gst_structure_get_int (structure, "height", &overlay->height);
+ gst_structure_get_double (structure, "framerate", &overlay->framerate);
/* forward to the next plugin */
- return gst_pad_try_set_caps(overlay->srcpad, caps);
+ return gst_pad_try_set_caps (overlay->srcpad, caps);
}
-static void
-gst_overlay_init (GstOverlay *overlay)
+static void
+gst_overlay_init (GstOverlay * overlay)
{
- overlay->sinkpad1 = gst_pad_new_from_template (
- gst_static_pad_template_get (&overlay_sink1_factory), "sink1");
+ overlay->sinkpad1 =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&overlay_sink1_factory), "sink1");
gst_pad_set_link_function (overlay->sinkpad1, gst_overlay_sinkconnect);
gst_element_add_pad (GST_ELEMENT (overlay), overlay->sinkpad1);
- overlay->sinkpad2 = gst_pad_new_from_template (
- gst_static_pad_template_get (&overlay_sink2_factory), "sink2");
+ overlay->sinkpad2 =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&overlay_sink2_factory), "sink2");
gst_pad_set_link_function (overlay->sinkpad2, gst_overlay_sinkconnect);
gst_element_add_pad (GST_ELEMENT (overlay), overlay->sinkpad2);
- overlay->sinkpad3 = gst_pad_new_from_template (
- gst_static_pad_template_get (&overlay_sink3_factory), "sink3");
+ overlay->sinkpad3 =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&overlay_sink3_factory), "sink3");
gst_pad_set_link_function (overlay->sinkpad3, gst_overlay_sinkconnect);
gst_element_add_pad (GST_ELEMENT (overlay), overlay->sinkpad3);
- overlay->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&overlay_src_factory), "src");
+ overlay->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&overlay_src_factory), "src");
gst_element_add_pad (GST_ELEMENT (overlay), overlay->srcpad);
gst_element_set_loop_function (GST_ELEMENT (overlay), gst_overlay_loop);
}
static void
-gst_overlay_blend_i420 (guint8 *out, guint8 *in1, guint8 *in2, guint8 *in3,
- gint width, gint height)
+gst_overlay_blend_i420 (guint8 * out, guint8 * in1, guint8 * in2, guint8 * in3,
+ gint width, gint height)
{
int mask;
int i, j;
- guint8 *in1u, *in1v, *in2u, *in2v, *outu, *outv;
+ guint8 *in1u, *in1v, *in2u, *in2v, *outu, *outv;
int lumsize;
int chromsize;
- int width2 = width/2;
- int height2 = height/2;
+ int width2 = width / 2;
+ int height2 = height / 2;
lumsize = width * height;
chromsize = width2 * height2;
- in1u = in1 + lumsize; in1v = in1u + chromsize;
- in2u = in2 + lumsize; in2v = in2u + chromsize;
- outu = out + lumsize; outv = outu + chromsize;
-
+ in1u = in1 + lumsize;
+ in1v = in1u + chromsize;
+ in2u = in2 + lumsize;
+ in2v = in2u + chromsize;
+ outu = out + lumsize;
+ outv = outu + chromsize;
+
for (i = 0; i < height; i++) {
for (j = 0; j < width; j++) {
- mask = in3[i*width + j];
- out[i*width+j] = ((in1[i*width+j] * mask) +
- (in2[i*width+j] * (255 - mask))) >> 8;
+ mask = in3[i * width + j];
+ out[i * width + j] = ((in1[i * width + j] * mask) +
+ (in2[i * width + j] * (255 - mask))) >> 8;
}
}
- for (i = 0; i < height/2; i++) {
- for (j = 0; j < width/2; j++) {
- mask = (in3[(i*2)*width + (j*2)] + in3[(i*2 + 1)*width + (j*2)] +
- in3[(i*2)*width + (j*2 + 1)] + in3[(i*2 + 1)*width + (j*2 + 1)]) / 4;
- outu[i*width2 + j] = ((in1u[i*width2+j] * mask) +
- (in2u[i*width2 + j] * (255 - mask))) >> 8;
- outv[i*width2 + j] = ((in1v[i*width2+j] * mask) +
- (in2v[i*width2 + j] * (255 - mask))) >> 8;
+ for (i = 0; i < height / 2; i++) {
+ for (j = 0; j < width / 2; j++) {
+ mask =
+ (in3[(i * 2) * width + (j * 2)] + in3[(i * 2 + 1) * width + (j * 2)] +
+ in3[(i * 2) * width + (j * 2 + 1)] + in3[(i * 2 + 1) * width +
+ (j * 2 + 1)]) / 4;
+ outu[i * width2 + j] =
+ ((in1u[i * width2 + j] * mask) + (in2u[i * width2 + j] * (255 -
+ mask))) >> 8;
+ outv[i * width2 + j] =
+ ((in1v[i * width2 + j] * mask) + (in2v[i * width2 + j] * (255 -
+ mask))) >> 8;
}
}
}
static void
-gst_overlay_loop (GstElement *element)
+gst_overlay_loop (GstElement * element)
{
GstOverlay *overlay;
GstBuffer *out;
return;
}
- g_return_if_fail(in1 != NULL);
- g_return_if_fail(in2 != NULL);
- g_return_if_fail(in3 != NULL);
+ g_return_if_fail (in1 != NULL);
+ g_return_if_fail (in2 != NULL);
+ g_return_if_fail (in3 != NULL);
- size = (overlay->width * overlay->height * 3)/2;
- g_return_if_fail(GST_BUFFER_SIZE(in1) != size);
- g_return_if_fail(GST_BUFFER_SIZE(in2) != size);
- g_return_if_fail(GST_BUFFER_SIZE(in3) != size);
+ size = (overlay->width * overlay->height * 3) / 2;
+ g_return_if_fail (GST_BUFFER_SIZE (in1) != size);
+ g_return_if_fail (GST_BUFFER_SIZE (in2) != size);
+ g_return_if_fail (GST_BUFFER_SIZE (in3) != size);
out = gst_buffer_new_and_alloc (size);
gst_overlay_blend_i420 (GST_BUFFER_DATA (out),
- GST_BUFFER_DATA (in1),
- GST_BUFFER_DATA (in2),
- GST_BUFFER_DATA (in3),
- overlay->width, overlay->height);
+ GST_BUFFER_DATA (in1),
+ GST_BUFFER_DATA (in2),
+ GST_BUFFER_DATA (in3), overlay->width, overlay->height);
GST_BUFFER_TIMESTAMP (out) = GST_BUFFER_TIMESTAMP (in1);
GST_BUFFER_DURATION (out) = GST_BUFFER_DURATION (in1);
}
static void
-gst_overlay_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
+gst_overlay_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstOverlay *overlay;
- overlay = GST_OVERLAY(object);
+ overlay = GST_OVERLAY (object);
switch (prop_id) {
default:
}
static void
-gst_overlay_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
+gst_overlay_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
GstOverlay *overlay;
- overlay = GST_OVERLAY(object);
+ overlay = GST_OVERLAY (object);
switch (prop_id) {
default:
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
return gst_element_register (plugin, "overlay",
- GST_RANK_NONE, GST_TYPE_OVERLAY);
+ GST_RANK_NONE, GST_TYPE_OVERLAY);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "overlay",
- "Overlay multiple video streams",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "overlay",
+ "Overlay multiple video streams",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
typedef struct _GstOverlay GstOverlay;
typedef struct _GstOverlayClass GstOverlayClass;
-struct _GstOverlay {
- GstElement element;
+struct _GstOverlay
+{
+ GstElement element;
- GstPad *srcpad;
- GstPad *sinkpad1;
- GstPad *sinkpad2;
- GstPad *sinkpad3;
+ GstPad *srcpad;
+ GstPad *sinkpad1;
+ GstPad *sinkpad2;
+ GstPad *sinkpad3;
- gint format;
- gint width;
- gint height;
+ gint format;
+ gint width;
+ gint height;
- gint duration;
- gint position;
+ gint duration;
+ gint position;
- gint type;
- gint fps;
- gint border;
- gint depth;
+ gint type;
+ gint fps;
+ gint border;
+ gint depth;
- gdouble framerate;
+ gdouble framerate;
};
-struct _GstOverlayClass {
+struct _GstOverlayClass
+{
GstElementClass parent_class;
};
"Passthrough",
"Filter/Effect/Audio",
"Transparent filter for audio/raw (boilerplate for effects)",
- "Thomas <thomas@apestaart.org>, "\
- "Andy Wingo <apwingo@eos.ncsu.edu>"
+ "Thomas <thomas@apestaart.org>, " "Andy Wingo <apwingo@eos.ncsu.edu>"
};
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
/* static guint gst_filter_signals[LAST_SIGNAL] = { 0 }; */
-enum {
+enum
+{
ARG_0,
ARG_SILENT
};
static GstStaticPadTemplate passthrough_sink_template =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
+ GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- GST_AUDIO_INT_PAD_TEMPLATE_CAPS "; "
- GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS
- )
-);
+ GST_STATIC_CAPS (GST_AUDIO_INT_PAD_TEMPLATE_CAPS "; "
+ GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS)
+ );
static GstStaticPadTemplate passthrough_src_template =
-GST_STATIC_PAD_TEMPLATE (
- "src",
+ GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- GST_AUDIO_INT_PAD_TEMPLATE_CAPS "; "
- GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS
- )
-);
+ GST_STATIC_CAPS (GST_AUDIO_INT_PAD_TEMPLATE_CAPS "; "
+ GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS)
+ );
-static void passthrough_class_init (GstPassthroughClass *klass);
-static void passthrough_base_init (GstPassthroughClass *klass);
-static void passthrough_init (GstPassthrough *filter);
+static void passthrough_class_init (GstPassthroughClass * klass);
+static void passthrough_base_init (GstPassthroughClass * klass);
+static void passthrough_init (GstPassthrough * filter);
-static void passthrough_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void passthrough_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+static void passthrough_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void passthrough_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static GstPadLinkReturn passthrough_connect_sink (GstPad *pad, const GstCaps *caps);
+static GstPadLinkReturn passthrough_connect_sink (GstPad * pad,
+ const GstCaps * caps);
-static void passthrough_chain (GstPad *pad, GstData *_data);
-static void inline passthrough_fast_float_chain (gfloat* data, guint numsamples);
-static void inline passthrough_fast_16bit_chain (gint16* data, guint numsamples);
-static void inline passthrough_fast_8bit_chain (gint8* data, guint numsamples);
+static void passthrough_chain (GstPad * pad, GstData * _data);
+static void inline passthrough_fast_float_chain (gfloat * data,
+ guint numsamples);
+static void inline passthrough_fast_16bit_chain (gint16 * data,
+ guint numsamples);
+static void inline passthrough_fast_8bit_chain (gint8 * data, guint numsamples);
static GstElementClass *parent_class = NULL;
static GstPadLinkReturn
-passthrough_connect_sink (GstPad *pad, const GstCaps *caps)
+passthrough_connect_sink (GstPad * pad, const GstCaps * caps)
{
const gchar *mimetype;
GstPassthrough *filter;
GstStructure *structure;
-
- g_return_val_if_fail (pad != NULL, GST_PAD_LINK_DELAYED);
+
+ g_return_val_if_fail (pad != NULL, GST_PAD_LINK_DELAYED);
g_return_val_if_fail (caps != NULL, GST_PAD_LINK_DELAYED);
filter = GST_PASSTHROUGH (gst_pad_get_parent (pad));
structure = gst_caps_get_structure (caps, 0);
mimetype = gst_structure_get_name (structure);
- gst_structure_get_int (structure, "rate", &filter->rate);
- gst_structure_get_int (structure, "channels", &filter->channels);
- gst_structure_get_int (structure, "width", &filter->width);
- gst_structure_get_int (structure, "endianness", &filter->endianness);
+ gst_structure_get_int (structure, "rate", &filter->rate);
+ gst_structure_get_int (structure, "channels", &filter->channels);
+ gst_structure_get_int (structure, "width", &filter->width);
+ gst_structure_get_int (structure, "endianness", &filter->endianness);
if (strcmp (mimetype, "audio/x-raw-int") == 0) {
filter->format = GST_PASSTHROUGH_FORMAT_INT;
- gst_structure_get_int (structure, "depth", &filter->depth);
- gst_structure_get_boolean (structure, "signed", &filter->is_signed);
+ gst_structure_get_int (structure, "depth", &filter->depth);
+ gst_structure_get_boolean (structure, "signed", &filter->is_signed);
- if (! filter->silent) {
- g_print ("Passthrough : channels %d, rate %d\n", filter->channels, filter->rate);
- g_print ("Passthrough : format int, bit width %d, endianness %d, signed %s\n",
- filter->width, filter->endianness, filter->is_signed ? "yes" : "no");
+ if (!filter->silent) {
+ g_print ("Passthrough : channels %d, rate %d\n", filter->channels,
+ filter->rate);
+ g_print
+ ("Passthrough : format int, bit width %d, endianness %d, signed %s\n",
+ filter->width, filter->endianness, filter->is_signed ? "yes" : "no");
}
} else if (strcmp (mimetype, "audio/x-raw-float") == 0) {
filter->format = GST_PASSTHROUGH_FORMAT_FLOAT;
- if (! filter->silent) {
- g_print ("Passthrough : channels %d, rate %d\n", filter->channels, filter->rate);
+ if (!filter->silent) {
+ g_print ("Passthrough : channels %d, rate %d\n", filter->channels,
+ filter->rate);
g_print ("Passthrough : format float, width %d\n", filter->width);
}
}
0,
(GInstanceInitFunc) passthrough_init,
};
- passthrough_type = g_type_register_static (GST_TYPE_ELEMENT, "GstPassthrough", &passthrough_info, 0);
+ passthrough_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstPassthrough",
+ &passthrough_info, 0);
}
return passthrough_type;
}
static void
-passthrough_base_init (GstPassthroughClass *klass)
+passthrough_base_init (GstPassthroughClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
}
static void
-passthrough_class_init (GstPassthroughClass *klass)
+passthrough_class_init (GstPassthroughClass * 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);
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_SILENT,
- g_param_spec_boolean("silent","silent","silent",
- TRUE, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT, g_param_spec_boolean ("silent", "silent", "silent", TRUE, G_PARAM_READWRITE)); /* CHECKME */
gobject_class->set_property = passthrough_set_property;
gobject_class->get_property = passthrough_get_property;
}
static void
-passthrough_init (GstPassthrough *filter)
+passthrough_init (GstPassthrough * filter)
{
- filter->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&passthrough_src_template), "src");
+ filter->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&passthrough_src_template), "src");
gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
- filter->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&passthrough_sink_template), "sink");
+ filter->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&passthrough_sink_template), "sink");
gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
- gst_pad_set_link_function (filter->sinkpad, passthrough_connect_sink);
- gst_pad_set_chain_function (filter->sinkpad, passthrough_chain);
+ gst_pad_set_link_function (filter->sinkpad, passthrough_connect_sink);
+ gst_pad_set_chain_function (filter->sinkpad, passthrough_chain);
filter->silent = FALSE;
}
static void
-passthrough_chain (GstPad *pad, GstData *_data)
+passthrough_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstPassthrough *filter;
gint16 *int_data;
gfloat *float_data;
-
+
g_return_if_fail (pad != NULL);
g_return_if_fail (GST_IS_PAD (pad));
g_return_if_fail (buf != NULL);
-
+
filter = GST_PASSTHROUGH (gst_pad_get_parent (pad));
g_return_if_fail (filter != NULL);
g_return_if_fail (GST_IS_PASSTHROUGH (filter));
switch (filter->format) {
- case GST_PASSTHROUGH_FORMAT_INT:
- int_data = (gint16 *) GST_BUFFER_DATA (buf);
+ case GST_PASSTHROUGH_FORMAT_INT:
+ int_data = (gint16 *) GST_BUFFER_DATA (buf);
+
+ switch (filter->width) {
+ case 16:
+ passthrough_fast_16bit_chain (int_data, GST_BUFFER_SIZE (buf) / 2);
+ break;
+ case 8:
+ passthrough_fast_8bit_chain ((gint8 *) int_data,
+ GST_BUFFER_SIZE (buf));
+ break;
+ }
- switch (filter->width) {
- case 16:
- passthrough_fast_16bit_chain (int_data, GST_BUFFER_SIZE (buf) / 2);
break;
- case 8:
- passthrough_fast_8bit_chain ((gint8*) int_data, GST_BUFFER_SIZE (buf));
- break;
- }
+ case GST_PASSTHROUGH_FORMAT_FLOAT:
+ float_data = (gfloat *) GST_BUFFER_DATA (buf);
- break;
- case GST_PASSTHROUGH_FORMAT_FLOAT:
- float_data = (gfloat *) GST_BUFFER_DATA (buf);
-
- passthrough_fast_float_chain (float_data, GST_BUFFER_SIZE (buf) / sizeof (gfloat));
-
- break;
+ passthrough_fast_float_chain (float_data,
+ GST_BUFFER_SIZE (buf) / sizeof (gfloat));
+
+ break;
}
-
+
gst_pad_push (filter->srcpad, GST_DATA (buf));
}
static void inline
-passthrough_fast_float_chain(gfloat* data, guint num_samples)
+passthrough_fast_float_chain (gfloat * data, guint num_samples)
#include "filter.func"
-
-static void inline
-passthrough_fast_16bit_chain(gint16* data, guint num_samples)
+ static void inline
+ passthrough_fast_16bit_chain (gint16 * data, guint num_samples)
#include "filter.func"
-
-static void inline
-passthrough_fast_8bit_chain(gint8* data, guint num_samples)
+ static void inline
+ passthrough_fast_8bit_chain (gint8 * data, guint num_samples)
#include "filter.func"
-
-static void
-passthrough_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+ static void
+ passthrough_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstPassthrough *filter;
g_return_if_fail (GST_IS_PASSTHROUGH (object));
filter = GST_PASSTHROUGH (object);
- switch (prop_id)
- {
+ switch (prop_id) {
case ARG_SILENT:
filter->silent = g_value_get_boolean (value);
break;
}
static void
-passthrough_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+passthrough_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstPassthrough *filter;
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
return gst_element_register (plugin, "passthrough",
- GST_RANK_NONE, GST_TYPE_PASSTHROUGH);
+ GST_RANK_NONE, GST_TYPE_PASSTHROUGH);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "passthrough",
- "Transparent filter for audio/raw (boilerplate for effects)",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "passthrough",
+ "Transparent filter for audio/raw (boilerplate for effects)",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_TYPE_PASSTHROUGH \
(gst_passthrough_get_type())
#define GST_PASSTHROUGH(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_PASSTHROUGH))
#define GST_IS_PASSTHROUGH_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_PASSTHROUGH))
-
typedef struct _GstPassthrough GstPassthrough;
typedef struct _GstPassthroughClass GstPassthroughClass;
-typedef enum _GstPassthroughFormat GstPassthroughFormat;
+typedef enum _GstPassthroughFormat GstPassthroughFormat;
-enum _GstPassthroughFormat {
+enum _GstPassthroughFormat
+{
GST_PASSTHROUGH_FORMAT_INT,
GST_PASSTHROUGH_FORMAT_FLOAT
};
-struct _GstPassthrough {
+struct _GstPassthrough
+{
GstElement element;
GstPad *sinkpad, *srcpad;
gboolean is_signed;
};
-struct _GstPassthroughClass {
+struct _GstPassthroughClass
+{
GstElementClass parent_class;
};
-GType gst_passthrough_get_type(void);
+GType gst_passthrough_get_type (void);
G_END_DECLS
-
#endif /* __GST_PASSTHROUGH_H__ */
guint32 *beats;
void
-played (GstElement *pod, gpointer data)
+played (GstElement * pod, gpointer data)
{
gint i;
- g_print("Played beat at %02u, beats are ",
- (guint) (gst_clock_get_time(element_clock) / GST_SECOND *
- (GTK_ADJUSTMENT(speed_adj))->value) % NUM_BEATS);
+ g_print ("Played beat at %02u, beats are ",
+ (guint) (gst_clock_get_time (element_clock) / GST_SECOND *
+ (GTK_ADJUSTMENT (speed_adj))->value) % NUM_BEATS);
- for (i = 0; i <= NUM_BEATS / 32; i++) g_print ("%08x ", beats[i]);
+ for (i = 0; i <= NUM_BEATS / 32; i++)
+ g_print ("%08x ", beats[i]);
- g_print("\n");
+ g_print ("\n");
}
void
-play (GtkButton *button, gpointer data)
+play (GtkButton * button, gpointer data)
{
- g_signal_emit_by_name(G_OBJECT(pod), "play", NULL, NULL);
+ g_signal_emit_by_name (G_OBJECT (pod), "play", NULL, NULL);
}
void
-clear (GtkButton *button, gpointer data)
+clear (GtkButton * button, gpointer data)
{
- g_signal_emit_by_name(G_OBJECT(pod), "clear", NULL, NULL);
+ g_signal_emit_by_name (G_OBJECT (pod), "clear", NULL, NULL);
}
void
-reset (GtkButton *button, gpointer data)
+reset (GtkButton * button, gpointer data)
{
guint i;
- g_signal_emit_by_name(G_OBJECT(pod), "reset", NULL, NULL);
+
+ g_signal_emit_by_name (G_OBJECT (pod), "reset", NULL, NULL);
for (i = 0; i < NUM_BEATS; i++)
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(beat_button[i]), 0);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (beat_button[i]), 0);
}
void
-beat (GtkToggleButton *button, gpointer data)
+beat (GtkToggleButton * button, gpointer data)
{
- guint b = GPOINTER_TO_UINT(data);
+ guint b = GPOINTER_TO_UINT (data);
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)))
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
beats[b / 32] |= 1 << (b % 32);
else
- beats[b / 32] &= ~ (1 << (b % 32));
+ beats[b / 32] &= ~(1 << (b % 32));
}
void
-speed (GtkAdjustment *adjustment, gpointer data)
+speed (GtkAdjustment * adjustment, gpointer data)
{
- /*g_signal_stop_emission_by_name(G_OBJECT(pod), "deep-notify");*/
- g_object_set(G_OBJECT(pod), "tick-rate", TICK_RATE(adjustment->value), NULL);
- /*gst_clock_set_speed(element_clock, adjustment->value);*/
+ /*g_signal_stop_emission_by_name(G_OBJECT(pod), "deep-notify"); */
+ g_object_set (G_OBJECT (pod), "tick-rate", TICK_RATE (adjustment->value),
+ NULL);
+ /*gst_clock_set_speed(element_clock, adjustment->value); */
}
void
-setup_pipeline (gchar *filename)
+setup_pipeline (gchar * filename)
{
- src = gst_element_factory_make("filesrc", "source");
- dec = gst_element_factory_make("vorbisfile", "decoder");
- pod = gst_element_factory_make("playondemand", "sequencer");
- sink = gst_element_factory_make("alsasink", "sink");
+ src = gst_element_factory_make ("filesrc", "source");
+ dec = gst_element_factory_make ("vorbisfile", "decoder");
+ pod = gst_element_factory_make ("playondemand", "sequencer");
+ sink = gst_element_factory_make ("alsasink", "sink");
- g_object_set(G_OBJECT (src), "location", filename, NULL);
- g_object_set(G_OBJECT (sink), "period-count", 64, "period-size", 512, NULL);
- g_object_set(G_OBJECT (pod), "total-ticks", NUM_BEATS,
- "tick-rate", 1.0e-6, "max-plays", NUM_BEATS * 2, NULL);
+ g_object_set (G_OBJECT (src), "location", filename, NULL);
+ g_object_set (G_OBJECT (sink), "period-count", 64, "period-size", 512, NULL);
+ g_object_set (G_OBJECT (pod), "total-ticks", NUM_BEATS,
+ "tick-rate", 1.0e-6, "max-plays", NUM_BEATS * 2, NULL);
- g_object_get(G_OBJECT (pod), "ticks", &beats, NULL);
+ g_object_get (G_OBJECT (pod), "ticks", &beats, NULL);
- pipeline = gst_pipeline_new("app");
+ pipeline = gst_pipeline_new ("app");
- gst_bin_add_many(GST_BIN (pipeline), src, dec, pod, sink, NULL);
- gst_element_link_many(src, dec, pod, sink, NULL);
+ gst_bin_add_many (GST_BIN (pipeline), src, dec, pod, sink, NULL);
+ gst_element_link_many (src, dec, pod, sink, NULL);
- element_clock = gst_element_get_clock(GST_ELEMENT (sink));
- gst_element_set_clock(GST_ELEMENT (pod), element_clock);
+ element_clock = gst_element_get_clock (GST_ELEMENT (sink));
+ gst_element_set_clock (GST_ELEMENT (pod), element_clock);
}
void
{
guint i;
- beat_button = g_new(GtkWidget *, NUM_BEATS);
+ beat_button = g_new (GtkWidget *, NUM_BEATS);
/* initialize gui elements ... */
- window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_container_set_border_width(GTK_CONTAINER(window), 12);
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_container_set_border_width (GTK_CONTAINER (window), 12);
- vbox = gtk_vbox_new(TRUE, 0);
- gtk_box_set_spacing(GTK_BOX(vbox), 12);
+ vbox = gtk_vbox_new (TRUE, 0);
+ gtk_box_set_spacing (GTK_BOX (vbox), 12);
- beat_box = gtk_hbox_new(TRUE, 0);
- button_box = gtk_hbox_new(TRUE, 0);
+ beat_box = gtk_hbox_new (TRUE, 0);
+ button_box = gtk_hbox_new (TRUE, 0);
- play_button = gtk_button_new_with_label("Play");
- clear_button = gtk_button_new_with_label("Reset Sound");
- reset_button = gtk_button_new_with_label("Reset All");
- quit_button = gtk_button_new_with_label("Quit");
+ play_button = gtk_button_new_with_label ("Play");
+ clear_button = gtk_button_new_with_label ("Reset Sound");
+ reset_button = gtk_button_new_with_label ("Reset All");
+ quit_button = gtk_button_new_with_label ("Quit");
for (i = 0; i < NUM_BEATS; i++)
- beat_button[i] = gtk_toggle_button_new_with_label(g_strdup_printf("%2d", i+1));
+ beat_button[i] =
+ gtk_toggle_button_new_with_label (g_strdup_printf ("%2d", i + 1));
- speed_adj = gtk_adjustment_new(1, 0.0, 10.0, 0.1, 1.0, 0.0);
- speed_scale = gtk_hscale_new(GTK_ADJUSTMENT(speed_adj));
- gtk_scale_set_digits(GTK_SCALE(speed_scale), 4);
- gtk_range_set_update_policy(GTK_RANGE(speed_scale), GTK_UPDATE_DISCONTINUOUS);
+ speed_adj = gtk_adjustment_new (1, 0.0, 10.0, 0.1, 1.0, 0.0);
+ speed_scale = gtk_hscale_new (GTK_ADJUSTMENT (speed_adj));
+ gtk_scale_set_digits (GTK_SCALE (speed_scale), 4);
+ gtk_range_set_update_policy (GTK_RANGE (speed_scale),
+ GTK_UPDATE_DISCONTINUOUS);
/* do the packing stuff ... */
- gtk_window_set_default_size(GTK_WINDOW(window), 96, 96);
- gtk_container_add(GTK_CONTAINER(window), vbox);
+ gtk_window_set_default_size (GTK_WINDOW (window), 96, 96);
+ gtk_container_add (GTK_CONTAINER (window), vbox);
- gtk_box_pack_start(GTK_BOX(button_box), play_button, TRUE, TRUE, 2);
- gtk_box_pack_start(GTK_BOX(button_box), clear_button, TRUE, TRUE, 2);
- gtk_box_pack_start(GTK_BOX(button_box), reset_button, TRUE, TRUE, 2);
- gtk_box_pack_start(GTK_BOX(button_box), quit_button, TRUE, TRUE, 2);
+ gtk_box_pack_start (GTK_BOX (button_box), play_button, TRUE, TRUE, 2);
+ gtk_box_pack_start (GTK_BOX (button_box), clear_button, TRUE, TRUE, 2);
+ gtk_box_pack_start (GTK_BOX (button_box), reset_button, TRUE, TRUE, 2);
+ gtk_box_pack_start (GTK_BOX (button_box), quit_button, TRUE, TRUE, 2);
for (i = 0; i < NUM_BEATS; i++)
- gtk_box_pack_start(GTK_BOX(beat_box), beat_button[i], TRUE, TRUE, 2);
+ gtk_box_pack_start (GTK_BOX (beat_box), beat_button[i], TRUE, TRUE, 2);
- gtk_box_pack_start(GTK_BOX(vbox), button_box, TRUE, FALSE, 2);
- gtk_box_pack_start(GTK_BOX(vbox), beat_box, TRUE, FALSE, 2);
- gtk_box_pack_start(GTK_BOX(vbox), speed_scale, TRUE, FALSE, 2);
+ gtk_box_pack_start (GTK_BOX (vbox), button_box, TRUE, FALSE, 2);
+ gtk_box_pack_start (GTK_BOX (vbox), beat_box, TRUE, FALSE, 2);
+ gtk_box_pack_start (GTK_BOX (vbox), speed_scale, TRUE, FALSE, 2);
/* connect things ... */
- g_signal_connect(G_OBJECT(play_button), "clicked", G_CALLBACK(play), NULL);
- g_signal_connect(G_OBJECT(clear_button), "clicked", G_CALLBACK(clear), NULL);
- g_signal_connect(G_OBJECT(reset_button), "clicked", G_CALLBACK(reset), NULL);
- g_signal_connect(G_OBJECT(quit_button), "clicked", gtk_main_quit, NULL);
- g_signal_connect(G_OBJECT(pod), "played", G_CALLBACK(played), NULL);
- g_signal_connect(G_OBJECT(speed_adj), "value_changed", G_CALLBACK(speed), NULL);
+ g_signal_connect (G_OBJECT (play_button), "clicked", G_CALLBACK (play), NULL);
+ g_signal_connect (G_OBJECT (clear_button), "clicked", G_CALLBACK (clear),
+ NULL);
+ g_signal_connect (G_OBJECT (reset_button), "clicked", G_CALLBACK (reset),
+ NULL);
+ g_signal_connect (G_OBJECT (quit_button), "clicked", gtk_main_quit, NULL);
+ g_signal_connect (G_OBJECT (pod), "played", G_CALLBACK (played), NULL);
+ g_signal_connect (G_OBJECT (speed_adj), "value_changed", G_CALLBACK (speed),
+ NULL);
for (i = 0; i < NUM_BEATS; i++)
- g_signal_connect(G_OBJECT(beat_button[i]), "toggled", G_CALLBACK(beat), GUINT_TO_POINTER(i));
+ g_signal_connect (G_OBJECT (beat_button[i]), "toggled", G_CALLBACK (beat),
+ GUINT_TO_POINTER (i));
/* show the gui. */
- gtk_widget_show_all(window);
+ gtk_widget_show_all (window);
- gtk_idle_add((GtkFunction)gst_bin_iterate, pipeline);
+ gtk_idle_add ((GtkFunction) gst_bin_iterate, pipeline);
}
int
-main(int argc, char **argv)
+main (int argc, char **argv)
{
gst_init (&argc, &argv);
gtk_init (&argc, &argv);
- if (argc!=2) {
- g_print("usage: %s <mp3-filename>\n", argv[0]);
- exit(-1);
+ if (argc != 2) {
+ g_print ("usage: %s <mp3-filename>\n", argv[0]);
+ exit (-1);
}
- setup_pipeline(argv[1]);
- gst_element_set_state(pipeline, GST_STATE_PLAYING);
- setup_gui();
- gtk_main();
- g_free(beat_button);
+ setup_pipeline (argv[1]);
+ gst_element_set_state (pipeline, GST_STATE_PLAYING);
+ setup_gui ();
+ gtk_main ();
+ g_free (beat_button);
return 0;
}
* way beyond what a real computer can actually keep track of, but hey ... */
/* some default values */
-#define GST_POD_MAX_PLAYS 100 /* maximum simultaneous plays */
-#define GST_POD_BUFFER_TIME 5.0 /* buffer length in seconds */
-#define GST_POD_TICK_RATE 1e-6 /* ticks per second */
+#define GST_POD_MAX_PLAYS 100 /* maximum simultaneous plays */
+#define GST_POD_BUFFER_TIME 5.0 /* buffer length in seconds */
+#define GST_POD_TICK_RATE 1e-6 /* ticks per second */
/* buffer pool fallback values ... use if no buffer pool is available */
#define GST_POD_BUFPOOL_SIZE 4096
static GstStaticPadTemplate play_on_demand_sink_template =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
+ GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- GST_AUDIO_INT_PAD_TEMPLATE_CAPS "; "
- GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS
- )
-);
+ GST_STATIC_CAPS (GST_AUDIO_INT_PAD_TEMPLATE_CAPS "; "
+ GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS)
+ );
static GstStaticPadTemplate play_on_demand_src_template =
-GST_STATIC_PAD_TEMPLATE (
- "src",
+ GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- GST_AUDIO_INT_PAD_TEMPLATE_CAPS "; "
- GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS
- )
-);
+ GST_STATIC_CAPS (GST_AUDIO_INT_PAD_TEMPLATE_CAPS "; "
+ GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS)
+ );
/* GObject functionality */
-static void play_on_demand_class_init (GstPlayOnDemandClass *klass);
-static void play_on_demand_base_init (GstPlayOnDemandClass *klass);
-static void play_on_demand_init (GstPlayOnDemand *filter);
-static void play_on_demand_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void play_on_demand_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
-static void play_on_demand_dispose (GObject *object);
+static void play_on_demand_class_init (GstPlayOnDemandClass * klass);
+static void play_on_demand_base_init (GstPlayOnDemandClass * klass);
+static void play_on_demand_init (GstPlayOnDemand * filter);
+static void play_on_demand_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void play_on_demand_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+static void play_on_demand_dispose (GObject * object);
/* GStreamer functionality */
-static GstPadLinkReturn play_on_demand_pad_link (GstPad *pad, const GstCaps *caps);
-static void play_on_demand_loop (GstElement *elem);
-static void play_on_demand_set_clock (GstElement *elem, GstClock *clock);
+static GstPadLinkReturn play_on_demand_pad_link (GstPad * pad,
+ const GstCaps * caps);
+static void play_on_demand_loop (GstElement * elem);
+static void play_on_demand_set_clock (GstElement * elem, GstClock * clock);
/* signal handlers */
-static void play_on_demand_play_handler (GstElement *elem);
-static void play_on_demand_clear_handler (GstElement *elem);
-static void play_on_demand_reset_handler (GstElement *elem);
+static void play_on_demand_play_handler (GstElement * elem);
+static void play_on_demand_clear_handler (GstElement * elem);
+static void play_on_demand_reset_handler (GstElement * elem);
/* utility functions */
-static void play_on_demand_add_play_pointer (GstPlayOnDemand *filter, guint pos);
-static void play_on_demand_resize_buffer (GstPlayOnDemand *filter);
+static void play_on_demand_add_play_pointer (GstPlayOnDemand * filter,
+ guint pos);
+static void play_on_demand_resize_buffer (GstPlayOnDemand * filter);
GType
gst_play_on_demand_get_type (void)
{
static GType play_on_demand_type = 0;
- if (! play_on_demand_type) {
+ if (!play_on_demand_type) {
static const GTypeInfo play_on_demand_info = {
- sizeof(GstPlayOnDemandClass),
+ sizeof (GstPlayOnDemandClass),
(GBaseInitFunc) play_on_demand_base_init,
NULL,
(GClassInitFunc) play_on_demand_class_init,
NULL,
NULL,
- sizeof(GstPlayOnDemand),
+ sizeof (GstPlayOnDemand),
0,
(GInstanceInitFunc) play_on_demand_init,
};
- play_on_demand_type = g_type_register_static(GST_TYPE_ELEMENT,
- "GstPlayOnDemand",
- &play_on_demand_info, 0);
+ play_on_demand_type = g_type_register_static (GST_TYPE_ELEMENT,
+ "GstPlayOnDemand", &play_on_demand_info, 0);
}
return play_on_demand_type;
}
/* signals and properties */
-enum {
+enum
+{
/* add signals here */
PLAYED_SIGNAL,
STOPPED_SIGNAL,
LAST_SIGNAL
};
-enum {
+enum
+{
PROP_0,
PROP_MUTE,
PROP_BUFFER_TIME,
static GstElementClass *parent_class = NULL;
static void
-play_on_demand_base_init (GstPlayOnDemandClass *klass)
+play_on_demand_base_init (GstPlayOnDemandClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
- gst_element_class_add_pad_template(element_class,
- gst_static_pad_template_get(&play_on_demand_src_template));
- gst_element_class_add_pad_template(element_class,
- gst_static_pad_template_get(&play_on_demand_sink_template));
- gst_element_class_set_details(element_class, &play_on_demand_details);
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&play_on_demand_src_template));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&play_on_demand_sink_template));
+ gst_element_class_set_details (element_class, &play_on_demand_details);
}
static void
-play_on_demand_class_init (GstPlayOnDemandClass *klass)
+play_on_demand_class_init (GstPlayOnDemandClass * klass)
{
- GObjectClass *gobject_class;
+ GObjectClass *gobject_class;
GstElementClass *gstelement_class;
- gobject_class = (GObjectClass *) klass;
+ gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
gst_pod_filter_signals[PLAYED_SIGNAL] =
- g_signal_new("played", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GstPlayOnDemandClass, played),
- NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("played", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstPlayOnDemandClass, played),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
gst_pod_filter_signals[STOPPED_SIGNAL] =
- g_signal_new("stopped", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GstPlayOnDemandClass, stopped),
- NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("stopped", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstPlayOnDemandClass, stopped),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
gst_pod_filter_signals[PLAY_SIGNAL] =
- g_signal_new("play", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GstPlayOnDemandClass, play),
- NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("play", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstPlayOnDemandClass, play),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
gst_pod_filter_signals[CLEAR_SIGNAL] =
- g_signal_new("clear", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GstPlayOnDemandClass, clear),
- NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("clear", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstPlayOnDemandClass, clear),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
gst_pod_filter_signals[RESET_SIGNAL] =
- g_signal_new("reset", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GstPlayOnDemandClass, reset),
- NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("reset", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstPlayOnDemandClass, reset),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
- klass->play = play_on_demand_play_handler;
+ klass->play = play_on_demand_play_handler;
klass->clear = play_on_demand_clear_handler;
klass->reset = play_on_demand_reset_handler;
- parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
+ parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
gobject_class->set_property = play_on_demand_set_property;
gobject_class->get_property = play_on_demand_get_property;
- gobject_class->dispose = play_on_demand_dispose;
+ gobject_class->dispose = play_on_demand_dispose;
gstelement_class->set_clock = play_on_demand_set_clock;
- g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_MUTE,
- g_param_spec_boolean("mute", "Silence output", "Do not output any sound",
- FALSE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
- g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_BUFFER_TIME,
- g_param_spec_float("buffer-time", "Buffer length in seconds", "Number of seconds of audio the buffer holds",
- 0.0, G_MAXFLOAT, GST_POD_BUFFER_TIME, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
- g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_MAX_PLAYS,
- g_param_spec_uint("max-plays", "Maximum simultaneous playbacks", "Maximum allowed number of simultaneous plays from the buffer",
- 1, G_MAXUINT, GST_POD_MAX_PLAYS, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
- g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_TICK_RATE,
- g_param_spec_float("tick-rate", "Tick rate (ticks/second)", "The rate of musical ticks, the smallest time unit in a song",
- 0, G_MAXFLOAT, GST_POD_TICK_RATE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
- g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_TOTAL_TICKS,
- g_param_spec_uint("total-ticks", "Total number of ticks", "Total number of ticks in the tick array",
- 1, G_MAXUINT, 1, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
- g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_TICKS,
- g_param_spec_pointer("ticks", "Ticks to play sample on", "An array of ticks (musical times) at which to play the sample",
- G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_MUTE,
+ g_param_spec_boolean ("mute", "Silence output", "Do not output any sound",
+ FALSE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_BUFFER_TIME,
+ g_param_spec_float ("buffer-time", "Buffer length in seconds",
+ "Number of seconds of audio the buffer holds", 0.0, G_MAXFLOAT,
+ GST_POD_BUFFER_TIME, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_MAX_PLAYS,
+ g_param_spec_uint ("max-plays", "Maximum simultaneous playbacks",
+ "Maximum allowed number of simultaneous plays from the buffer", 1,
+ G_MAXUINT, GST_POD_MAX_PLAYS, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_TICK_RATE,
+ g_param_spec_float ("tick-rate", "Tick rate (ticks/second)",
+ "The rate of musical ticks, the smallest time unit in a song", 0,
+ G_MAXFLOAT, GST_POD_TICK_RATE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_TOTAL_TICKS,
+ g_param_spec_uint ("total-ticks", "Total number of ticks",
+ "Total number of ticks in the tick array", 1, G_MAXUINT, 1,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_TICKS,
+ g_param_spec_pointer ("ticks", "Ticks to play sample on",
+ "An array of ticks (musical times) at which to play the sample",
+ G_PARAM_READWRITE));
}
static void
-play_on_demand_init (GstPlayOnDemand *filter)
+play_on_demand_init (GstPlayOnDemand * filter)
{
- filter->srcpad = gst_pad_new_from_template(
- gst_static_pad_template_get(&play_on_demand_src_template), "src");
- filter->sinkpad = gst_pad_new_from_template(
- gst_static_pad_template_get(&play_on_demand_sink_template), "sink");
+ filter->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&play_on_demand_src_template), "src");
+ filter->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&play_on_demand_sink_template), "sink");
- gst_pad_set_link_function(filter->sinkpad, play_on_demand_pad_link);
+ gst_pad_set_link_function (filter->sinkpad, play_on_demand_pad_link);
- gst_element_add_pad(GST_ELEMENT(filter), filter->sinkpad);
- gst_element_add_pad(GST_ELEMENT(filter), filter->srcpad);
+ gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
+ gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
- gst_element_set_loop_function(GST_ELEMENT(filter), play_on_demand_loop);
+ gst_element_set_loop_function (GST_ELEMENT (filter), play_on_demand_loop);
filter->clock = NULL;
filter->rate = 0;
- filter->ticks = g_new(guint32, filter->total_ticks / 32 + 1);
- filter->plays = g_new(guint, filter->max_plays);
+ filter->ticks = g_new (guint32, filter->total_ticks / 32 + 1);
+ filter->plays = g_new (guint, filter->max_plays);
- play_on_demand_resize_buffer(filter);
- play_on_demand_reset_handler(GST_ELEMENT(filter));
+ play_on_demand_resize_buffer (filter);
+ play_on_demand_reset_handler (GST_ELEMENT (filter));
}
static void
-play_on_demand_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
+play_on_demand_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstPlayOnDemand *filter;
- register guint i;
- guint new_size, min_size, *new_plays;
- guint *new_ticks;
+ register guint i;
+ guint new_size, min_size, *new_plays;
+ guint *new_ticks;
- g_return_if_fail(GST_IS_PLAYONDEMAND(object));
- filter = GST_PLAYONDEMAND(object);
+ g_return_if_fail (GST_IS_PLAYONDEMAND (object));
+ filter = GST_PLAYONDEMAND (object);
switch (prop_id) {
- case PROP_MUTE:
- filter->mute = g_value_get_boolean(value);
- break;
- case PROP_BUFFER_TIME:
- filter->buffer_time = g_value_get_float(value);
- play_on_demand_resize_buffer(filter);
-
- /* clear out now-invalid play pointers */
- for (i = 0; i < filter->max_plays; i++) filter->plays[i] = G_MAXUINT;
-
- break;
- case PROP_MAX_PLAYS:
- new_size = g_value_get_uint(value);
- min_size = (new_size < filter->max_plays) ? new_size : filter->max_plays;
-
- new_plays = g_new(guint, new_size);
- for (i = 0; i < min_size; i++) new_plays[i] = filter->plays[i];
- for (i = min_size; i < new_size; i++) new_plays[i] = G_MAXUINT;
-
- g_free(filter->plays);
- filter->plays = new_plays;
- filter->max_plays = new_size;
-
- break;
- case PROP_TICK_RATE:
- filter->tick_rate = g_value_get_float(value);
- break;
- case PROP_TOTAL_TICKS:
- new_size = g_value_get_uint(value);
- min_size = (new_size < filter->total_ticks) ? new_size : filter->total_ticks;
-
- new_ticks = g_new(guint32, new_size / 32 + 1);
- for (i = 0; i <= min_size / 32; i++) new_ticks[i] = filter->ticks[i];
- for (i = min_size / 32 + 1; i <= new_size / 32; i++) new_ticks[i] = 0;
-
- g_free(filter->ticks);
- filter->ticks = new_ticks;
- filter->total_ticks = new_size;
-
- break;
- case PROP_TICKS:
- new_ticks = (guint *) g_value_get_pointer(value);
- if (new_ticks) {
- g_free(filter->ticks);
+ case PROP_MUTE:
+ filter->mute = g_value_get_boolean (value);
+ break;
+ case PROP_BUFFER_TIME:
+ filter->buffer_time = g_value_get_float (value);
+ play_on_demand_resize_buffer (filter);
+
+ /* clear out now-invalid play pointers */
+ for (i = 0; i < filter->max_plays; i++)
+ filter->plays[i] = G_MAXUINT;
+
+ break;
+ case PROP_MAX_PLAYS:
+ new_size = g_value_get_uint (value);
+ min_size = (new_size < filter->max_plays) ? new_size : filter->max_plays;
+
+ new_plays = g_new (guint, new_size);
+ for (i = 0; i < min_size; i++)
+ new_plays[i] = filter->plays[i];
+ for (i = min_size; i < new_size; i++)
+ new_plays[i] = G_MAXUINT;
+
+ g_free (filter->plays);
+ filter->plays = new_plays;
+ filter->max_plays = new_size;
+
+ break;
+ case PROP_TICK_RATE:
+ filter->tick_rate = g_value_get_float (value);
+ break;
+ case PROP_TOTAL_TICKS:
+ new_size = g_value_get_uint (value);
+ min_size =
+ (new_size < filter->total_ticks) ? new_size : filter->total_ticks;
+
+ new_ticks = g_new (guint32, new_size / 32 + 1);
+ for (i = 0; i <= min_size / 32; i++)
+ new_ticks[i] = filter->ticks[i];
+ for (i = min_size / 32 + 1; i <= new_size / 32; i++)
+ new_ticks[i] = 0;
+
+ g_free (filter->ticks);
filter->ticks = new_ticks;
- }
- break;
- default:
- break;
+ filter->total_ticks = new_size;
+
+ break;
+ case PROP_TICKS:
+ new_ticks = (guint *) g_value_get_pointer (value);
+ if (new_ticks) {
+ g_free (filter->ticks);
+ filter->ticks = new_ticks;
+ }
+ break;
+ default:
+ break;
}
}
static void
-play_on_demand_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
+play_on_demand_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
GstPlayOnDemand *filter;
- g_return_if_fail(GST_IS_PLAYONDEMAND(object));
- filter = GST_PLAYONDEMAND(object);
+ g_return_if_fail (GST_IS_PLAYONDEMAND (object));
+ filter = GST_PLAYONDEMAND (object);
switch (prop_id) {
- case PROP_MUTE:
- g_value_set_boolean(value, filter->mute);
- break;
- case PROP_BUFFER_TIME:
- g_value_set_float(value, filter->buffer_time);
- break;
- case PROP_MAX_PLAYS:
- g_value_set_uint(value, filter->max_plays);
- break;
- case PROP_TICK_RATE:
- g_value_set_float(value, filter->tick_rate);
- break;
- case PROP_TOTAL_TICKS:
- g_value_set_uint(value, filter->total_ticks);
- break;
- case PROP_TICKS:
- g_value_set_pointer(value, (gpointer) filter->ticks);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
- break;
+ case PROP_MUTE:
+ g_value_set_boolean (value, filter->mute);
+ break;
+ case PROP_BUFFER_TIME:
+ g_value_set_float (value, filter->buffer_time);
+ break;
+ case PROP_MAX_PLAYS:
+ g_value_set_uint (value, filter->max_plays);
+ break;
+ case PROP_TICK_RATE:
+ g_value_set_float (value, filter->tick_rate);
+ break;
+ case PROP_TOTAL_TICKS:
+ g_value_set_uint (value, filter->total_ticks);
+ break;
+ case PROP_TICKS:
+ g_value_set_pointer (value, (gpointer) filter->ticks);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
static void
-play_on_demand_dispose (GObject *object)
+play_on_demand_dispose (GObject * object)
{
GstPlayOnDemand *filter = GST_PLAYONDEMAND (object);
}
static GstPadLinkReturn
-play_on_demand_pad_link (GstPad *pad, const GstCaps *caps)
+play_on_demand_pad_link (GstPad * pad, const GstCaps * caps)
{
const gchar *mimetype;
GstPlayOnDemand *filter;
GstStructure *structure;
- g_return_val_if_fail(caps != NULL, GST_PAD_LINK_DELAYED);
- g_return_val_if_fail(pad != NULL, GST_PAD_LINK_DELAYED);
+ g_return_val_if_fail (caps != NULL, GST_PAD_LINK_DELAYED);
+ g_return_val_if_fail (pad != NULL, GST_PAD_LINK_DELAYED);
- filter = GST_PLAYONDEMAND(GST_PAD_PARENT(pad));
+ filter = GST_PLAYONDEMAND (GST_PAD_PARENT (pad));
structure = gst_caps_get_structure (caps, 0);
gst_structure_get_int (structure, "rate", &filter->rate);
gst_structure_get_int (structure, "channels", &filter->channels);
- if (strcmp(mimetype, "audio/x-raw-int") == 0) {
+ if (strcmp (mimetype, "audio/x-raw-int") == 0) {
filter->format = GST_PLAYONDEMAND_FORMAT_INT;
- gst_structure_get_int (structure, "width", &filter->width);
- } else if (strcmp(mimetype, "audio/x-raw-float") == 0) {
+ gst_structure_get_int (structure, "width", &filter->width);
+ } else if (strcmp (mimetype, "audio/x-raw-float") == 0) {
filter->format = GST_PLAYONDEMAND_FORMAT_FLOAT;
}
- play_on_demand_resize_buffer(filter);
+ play_on_demand_resize_buffer (filter);
return gst_pad_try_set_caps (filter->srcpad, caps);
}
inline static void
-play_on_demand_add_play_pointer (GstPlayOnDemand *filter, guint pos)
+play_on_demand_add_play_pointer (GstPlayOnDemand * filter, guint pos)
{
register guint i;
if (filter->rate && ((filter->buffer_time * filter->rate) > pos)) {
for (i = 0; i < filter->max_plays; i++) {
if (filter->plays[i] == G_MAXUINT) {
- filter->plays[i] = pos;
- /* emit a signal to indicate a sample being played */
- g_signal_emit(filter, gst_pod_filter_signals[PLAYED_SIGNAL], 0);
- break;
+ filter->plays[i] = pos;
+ /* emit a signal to indicate a sample being played */
+ g_signal_emit (filter, gst_pod_filter_signals[PLAYED_SIGNAL], 0);
+ break;
}
}
}
}
static void
-play_on_demand_loop (GstElement *elem)
+play_on_demand_loop (GstElement * elem)
{
- GstPlayOnDemand *filter = GST_PLAYONDEMAND(elem);
- guint num_in, num_out, num_filter;
- GstData *in = NULL;
- GstBuffer *out = NULL;
- static guint last_tick = 0;
+ GstPlayOnDemand *filter = GST_PLAYONDEMAND (elem);
+ guint num_in, num_out, num_filter;
+ GstData *in = NULL;
+ GstBuffer *out = NULL;
+ static guint last_tick = 0;
- g_return_if_fail(filter != NULL);
- g_return_if_fail(GST_IS_PLAYONDEMAND(filter));
+ g_return_if_fail (filter != NULL);
+ g_return_if_fail (GST_IS_PLAYONDEMAND (filter));
- in = (in == NULL && ! filter->eos) ? gst_pad_pull(filter->sinkpad) : NULL;
+ in = (in == NULL && !filter->eos) ? gst_pad_pull (filter->sinkpad) : NULL;
if (filter->format == GST_PLAYONDEMAND_FORMAT_INT) {
if (filter->width == 16) {
gint16 min = 0xffff;
gint16 max = 0x7fff;
gint16 zero = 0;
+
#define _TYPE_ gint16
#include "filter.func"
#undef _TYPE_
gint8 min = 0xff;
gint8 max = 0x7f;
gint8 zero = 0;
+
#define _TYPE_ gint8
#include "filter.func"
#undef _TYPE_
gfloat min = -1.0;
gfloat max = 1.0;
gfloat zero = 0.0;
+
#define _TYPE_ gfloat
#include "filter.func"
#undef _TYPE_
}
static void
-play_on_demand_set_clock (GstElement *elem, GstClock *clock)
+play_on_demand_set_clock (GstElement * elem, GstClock * clock)
{
GstPlayOnDemand *filter;
- g_return_if_fail(elem != NULL);
- g_return_if_fail(GST_IS_PLAYONDEMAND(elem));
- filter = GST_PLAYONDEMAND(elem);
+ g_return_if_fail (elem != NULL);
+ g_return_if_fail (GST_IS_PLAYONDEMAND (elem));
+ filter = GST_PLAYONDEMAND (elem);
filter->clock = clock;
}
static void
-play_on_demand_play_handler (GstElement *elem)
+play_on_demand_play_handler (GstElement * elem)
{
GstPlayOnDemand *filter;
- g_return_if_fail(elem != NULL);
- g_return_if_fail(GST_IS_PLAYONDEMAND(elem));
- filter = GST_PLAYONDEMAND(elem);
+ g_return_if_fail (elem != NULL);
+ g_return_if_fail (GST_IS_PLAYONDEMAND (elem));
+ filter = GST_PLAYONDEMAND (elem);
- play_on_demand_add_play_pointer(filter, 0);
+ play_on_demand_add_play_pointer (filter, 0);
}
static void
-play_on_demand_clear_handler (GstElement *elem)
+play_on_demand_clear_handler (GstElement * elem)
{
GstPlayOnDemand *filter;
register guint i;
- g_return_if_fail(elem != NULL);
- g_return_if_fail(GST_IS_PLAYONDEMAND(elem));
- filter = GST_PLAYONDEMAND(elem);
+ g_return_if_fail (elem != NULL);
+ g_return_if_fail (GST_IS_PLAYONDEMAND (elem));
+ filter = GST_PLAYONDEMAND (elem);
filter->write = 0;
filter->eos = FALSE;
- for (i = 0; i < filter->max_plays; i++) filter->plays[i] = G_MAXUINT;
- for (i = 0; i < filter->buffer_bytes; i++) filter->buffer[i] = (gchar) 0;
+ for (i = 0; i < filter->max_plays; i++)
+ filter->plays[i] = G_MAXUINT;
+ for (i = 0; i < filter->buffer_bytes; i++)
+ filter->buffer[i] = (gchar) 0;
}
static void
-play_on_demand_reset_handler (GstElement *elem)
+play_on_demand_reset_handler (GstElement * elem)
{
GstPlayOnDemand *filter;
register guint i;
play_on_demand_clear_handler (elem);
- g_return_if_fail(elem != NULL);
- g_return_if_fail(GST_IS_PLAYONDEMAND(elem));
- filter = GST_PLAYONDEMAND(elem);
+ g_return_if_fail (elem != NULL);
+ g_return_if_fail (GST_IS_PLAYONDEMAND (elem));
+ filter = GST_PLAYONDEMAND (elem);
- for (i = 0; i <= filter->total_ticks / 32; i++) filter->ticks[i] = 0;
+ for (i = 0; i <= filter->total_ticks / 32; i++)
+ filter->ticks[i] = 0;
}
static void
-play_on_demand_resize_buffer (GstPlayOnDemand *filter)
+play_on_demand_resize_buffer (GstPlayOnDemand * filter)
{
- register guint i;
- guint new_size, min_size;
- gchar *new_buffer;
+ register guint i;
+ guint new_size, min_size;
+ gchar *new_buffer;
/* use a default sample rate of 44100, 1 channel, 1 byte per sample if caps
haven't been set yet */
- new_size = (guint) filter->buffer_time;
+ new_size = (guint) filter->buffer_time;
new_size *= (filter->rate) ? filter->rate : 44100;
new_size *= (filter->channels) ? filter->channels : 1;
if (filter->format && filter->format == GST_PLAYONDEMAND_FORMAT_FLOAT)
- new_size *= sizeof(gfloat);
+ new_size *= sizeof (gfloat);
else
new_size *= (filter->width) ? filter->width / 8 : 1;
- min_size = (new_size < filter->buffer_bytes) ? new_size : filter->buffer_bytes;
+ min_size =
+ (new_size < filter->buffer_bytes) ? new_size : filter->buffer_bytes;
- new_buffer = g_new(gchar, new_size);
- for (i = 0; i < min_size; i++) new_buffer[i] = filter->buffer[i];
- for (i = min_size; i < new_size; i++) new_buffer[i] = (gchar) 0;
+ new_buffer = g_new (gchar, new_size);
+ for (i = 0; i < min_size; i++)
+ new_buffer[i] = filter->buffer[i];
+ for (i = min_size; i < new_size; i++)
+ new_buffer[i] = (gchar) 0;
- g_free(filter->buffer);
+ g_free (filter->buffer);
filter->buffer = new_buffer;
filter->buffer_bytes = new_size;
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- return gst_element_register(plugin, "playondemand",
- GST_RANK_NONE,
- GST_TYPE_PLAYONDEMAND);
+ return gst_element_register (plugin, "playondemand",
+ GST_RANK_NONE, GST_TYPE_PLAYONDEMAND);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "playondemand",
- "Plays a stream at specific times, or when it receives a signal",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "playondemand",
+ "Plays a stream at specific times, or when it receives a signal",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_TYPE_PLAYONDEMAND \
(gst_play_on_demand_get_type())
#define GST_PLAYONDEMAND(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_PLAYONDEMAND))
#define GST_IS_PLAYONDEMAND_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_PLAYONDEMAND))
+typedef struct _GstPlayOnDemand GstPlayOnDemand;
+typedef struct _GstPlayOnDemandClass GstPlayOnDemandClass;
+typedef enum _GstPlayOnDemandFormat GstPlayOnDemandFormat;
-typedef struct _GstPlayOnDemand GstPlayOnDemand;
-typedef struct _GstPlayOnDemandClass GstPlayOnDemandClass;
-typedef enum _GstPlayOnDemandFormat GstPlayOnDemandFormat;
-
-enum _GstPlayOnDemandFormat {
+enum _GstPlayOnDemandFormat
+{
GST_PLAYONDEMAND_FORMAT_INT,
GST_PLAYONDEMAND_FORMAT_FLOAT
};
-struct _GstPlayOnDemand {
+struct _GstPlayOnDemand
+{
GstElement element;
- GstPad *sinkpad, *srcpad;
+ GstPad *sinkpad, *srcpad;
GstClock *clock;
/* filter properties */
- gboolean mute;
- gfloat buffer_time;
- guint max_plays;
- gfloat tick_rate;
- guint total_ticks;
- guint32 *ticks;
+ gboolean mute;
+ gfloat buffer_time;
+ guint max_plays;
+ gfloat tick_rate;
+ guint total_ticks;
+ guint32 *ticks;
/* internal buffer info */
- gchar *buffer;
- guint buffer_bytes;
- gboolean eos;
+ gchar *buffer;
+ guint buffer_bytes;
+ gboolean eos;
/* play pointers == internal buffer offsets for producing output sound */
- guint *plays;
- guint write;
+ guint *plays;
+ guint write;
/* audio format info (used to calculate buffer_samples) */
GstPlayOnDemandFormat format;
- guint rate;
- guint channels;
- guint width;
+ guint rate;
+ guint channels;
+ guint width;
};
-struct _GstPlayOnDemandClass {
+struct _GstPlayOnDemandClass
+{
GstElementClass parent_class;
- void (*play) (GstElement *elem);
- void (*clear) (GstElement *elem);
- void (*reset) (GstElement *elem);
- void (*played) (GstElement *elem);
- void (*stopped) (GstElement *elem);
+ void (*play) (GstElement * elem);
+ void (*clear) (GstElement * elem);
+ void (*reset) (GstElement * elem);
+ void (*played) (GstElement * elem);
+ void (*stopped) (GstElement * elem);
};
-GType gst_play_on_demand_get_type(void);
+GType gst_play_on_demand_get_type (void);
G_END_DECLS
-
#endif /* __GST_PLAYONDEMAND_H__ */
typedef struct _QtNode QtNode;
typedef struct _QtNodeType QtNodeType;
typedef struct _QtDemuxSample QtDemuxSample;
+
//typedef struct _QtDemuxStream QtDemuxStream;
-struct _QtNode {
+struct _QtNode
+{
guint32 type;
gpointer data;
int len;
};
-struct _QtNodeType {
+struct _QtNodeType
+{
guint32 fourcc;
char *name;
int flags;
- void (*dump)(GstQTDemux *qtdemux, void *buffer, int depth);
+ void (*dump) (GstQTDemux * qtdemux, void *buffer, int depth);
};
-struct _QtDemuxSample {
+struct _QtDemuxSample
+{
int sample_index;
int chunk;
int size;
guint64 duration;
};
-struct _QtDemuxStream {
+struct _QtDemuxStream
+{
guint32 subtype;
GstCaps *caps;
GstPad *pad;
int width;
int height;
float fps;
-
+
double rate;
int n_channels;
guint bytes_per_frame;
guint samples_per_packet;
};
-enum QtDemuxState {
+enum QtDemuxState
+{
QTDEMUX_STATE_NULL,
QTDEMUX_STATE_HEADER,
QTDEMUX_STATE_HEADER_SEEKING,
QTDEMUX_STATE_EOS,
};
-static GNode *qtdemux_tree_get_child_by_type(GNode *node, guint32 fourcc);
-static GNode *qtdemux_tree_get_sibling_by_type(GNode *node, guint32 fourcc);
+static GNode *qtdemux_tree_get_child_by_type (GNode * node, guint32 fourcc);
+static GNode *qtdemux_tree_get_sibling_by_type (GNode * node, guint32 fourcc);
-static GstElementDetails
-gst_qtdemux_details =
-{
+static GstElementDetails gst_qtdemux_details = {
"QuickTime Demuxer",
"Codec/Demuxer",
"Demultiplex a QuickTime file into audio and video streams",
"David Schleef <ds@schleef.org>"
};
-enum {
+enum
+{
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0
};
static GstStaticPadTemplate gst_qtdemux_sink_template =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_SOMETIMES,
- GST_STATIC_CAPS ("video/quicktime")
-);
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_SOMETIMES,
+ GST_STATIC_CAPS ("video/quicktime")
+ );
static GstStaticPadTemplate gst_qtdemux_videosrc_template =
-GST_STATIC_PAD_TEMPLATE (
- "audio_%02d",
- GST_PAD_SRC,
- GST_PAD_SOMETIMES,
- GST_STATIC_CAPS_ANY
-);
+GST_STATIC_PAD_TEMPLATE ("audio_%02d",
+ GST_PAD_SRC,
+ GST_PAD_SOMETIMES,
+ GST_STATIC_CAPS_ANY);
static GstStaticPadTemplate gst_qtdemux_audiosrc_template =
-GST_STATIC_PAD_TEMPLATE (
- "video_%02d",
- GST_PAD_SRC,
- GST_PAD_SOMETIMES,
- GST_STATIC_CAPS_ANY
-);
+GST_STATIC_PAD_TEMPLATE ("video_%02d",
+ GST_PAD_SRC,
+ GST_PAD_SOMETIMES,
+ GST_STATIC_CAPS_ANY);
static GstElementClass *parent_class = NULL;
-static void gst_qtdemux_class_init (GstQTDemuxClass *klass);
-static void gst_qtdemux_base_init (GstQTDemuxClass *klass);
-static void gst_qtdemux_init (GstQTDemux *quicktime_demux);
-static GstElementStateReturn gst_qtdemux_change_state(GstElement *element);
-static void gst_qtdemux_loop_header (GstElement *element);
-static gboolean gst_qtdemux_handle_sink_event (GstQTDemux *qtdemux);
-
-static void qtdemux_parse_moov(GstQTDemux *qtdemux, void *buffer, int length);
-static void qtdemux_parse(GstQTDemux *qtdemux, GNode *node, void *buffer, int length);
-static QtNodeType *qtdemux_type_get(guint32 fourcc);
-static void qtdemux_node_dump(GstQTDemux *qtdemux, GNode *node);
-static void qtdemux_parse_tree(GstQTDemux *qtdemux);
-static GstCaps *qtdemux_video_caps(GstQTDemux *qtdemux, guint32 fourcc, const guint8 *stsd_data);
-static GstCaps *qtdemux_audio_caps(GstQTDemux *qtdemux, guint32 fourcc, const guint8 *data);
-
-static GType gst_qtdemux_get_type (void)
+static void gst_qtdemux_class_init (GstQTDemuxClass * klass);
+static void gst_qtdemux_base_init (GstQTDemuxClass * klass);
+static void gst_qtdemux_init (GstQTDemux * quicktime_demux);
+static GstElementStateReturn gst_qtdemux_change_state (GstElement * element);
+static void gst_qtdemux_loop_header (GstElement * element);
+static gboolean gst_qtdemux_handle_sink_event (GstQTDemux * qtdemux);
+
+static void qtdemux_parse_moov (GstQTDemux * qtdemux, void *buffer, int length);
+static void qtdemux_parse (GstQTDemux * qtdemux, GNode * node, void *buffer,
+ int length);
+static QtNodeType *qtdemux_type_get (guint32 fourcc);
+static void qtdemux_node_dump (GstQTDemux * qtdemux, GNode * node);
+static void qtdemux_parse_tree (GstQTDemux * qtdemux);
+static GstCaps *qtdemux_video_caps (GstQTDemux * qtdemux, guint32 fourcc,
+ const guint8 * stsd_data);
+static GstCaps *qtdemux_audio_caps (GstQTDemux * qtdemux, guint32 fourcc,
+ const guint8 * data);
+
+static GType
+gst_qtdemux_get_type (void)
{
static GType qtdemux_type = 0;
if (!qtdemux_type) {
static const GTypeInfo qtdemux_info = {
- sizeof(GstQTDemuxClass),
- (GBaseInitFunc)gst_qtdemux_base_init, NULL,
- (GClassInitFunc)gst_qtdemux_class_init,
- NULL, NULL, sizeof(GstQTDemux), 0,
- (GInstanceInitFunc)gst_qtdemux_init,
+ sizeof (GstQTDemuxClass),
+ (GBaseInitFunc) gst_qtdemux_base_init, NULL,
+ (GClassInitFunc) gst_qtdemux_class_init,
+ NULL, NULL, sizeof (GstQTDemux), 0,
+ (GInstanceInitFunc) gst_qtdemux_init,
};
- qtdemux_type = g_type_register_static (GST_TYPE_ELEMENT, "GstQTDemux", &qtdemux_info, 0);
+ qtdemux_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstQTDemux", &qtdemux_info,
+ 0);
}
return qtdemux_type;
}
-static void gst_qtdemux_base_init (GstQTDemuxClass *klass)
+static void
+gst_qtdemux_base_init (GstQTDemuxClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
}
-static void gst_qtdemux_class_init (GstQTDemuxClass *klass)
+static void
+gst_qtdemux_class_init (GstQTDemuxClass * 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);
gstelement_class->change_state = gst_qtdemux_change_state;
}
-static void
-gst_qtdemux_init (GstQTDemux *qtdemux)
+static void
+gst_qtdemux_init (GstQTDemux * qtdemux)
{
- qtdemux->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&gst_qtdemux_sink_template), "sink");
+ qtdemux->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_qtdemux_sink_template), "sink");
gst_element_set_loop_function (GST_ELEMENT (qtdemux),
gst_qtdemux_loop_header);
gst_element_add_pad (GST_ELEMENT (qtdemux), qtdemux->sinkpad);
}
static const GstFormat *
-gst_qtdemux_get_src_formats (GstPad *pad)
+gst_qtdemux_get_src_formats (GstPad * pad)
{
static const GstFormat src_a_formats[] = {
GST_FORMAT_TIME,
GST_FORMAT_DEFAULT,
0
};
- QtDemuxStream *stream = gst_pad_get_element_private(pad);
+ QtDemuxStream *stream = gst_pad_get_element_private (pad);
- return (stream->subtype == GST_MAKE_FOURCC('v','i','d','e')) ?
- src_v_formats : src_a_formats;
+ return (stream->subtype == GST_MAKE_FOURCC ('v', 'i', 'd', 'e')) ?
+ src_v_formats : src_a_formats;
}
static gboolean
-gst_qtdemux_src_convert (GstPad *pad, GstFormat src_format, gint64 src_value,
- GstFormat *dest_format, gint64 *dest_value)
+gst_qtdemux_src_convert (GstPad * pad, GstFormat src_format, gint64 src_value,
+ GstFormat * dest_format, gint64 * dest_value)
{
gboolean res = TRUE;
- QtDemuxStream *stream = gst_pad_get_element_private(pad);
+ QtDemuxStream *stream = gst_pad_get_element_private (pad);
- if (stream->subtype == GST_MAKE_FOURCC('v','i','d','e') &&
+ if (stream->subtype == GST_MAKE_FOURCC ('v', 'i', 'd', 'e') &&
(src_format == GST_FORMAT_BYTES || *dest_format == GST_FORMAT_BYTES))
return FALSE;
switch (src_format) {
case GST_FORMAT_TIME:
switch (*dest_format) {
- case GST_FORMAT_BYTES:
- *dest_value = src_value * 1; /* FIXME */
- break;
- case GST_FORMAT_DEFAULT:
- *dest_value = src_value * 1; /* FIXME */
- break;
- default:
- res = FALSE;
- break;
+ case GST_FORMAT_BYTES:
+ *dest_value = src_value * 1; /* FIXME */
+ break;
+ case GST_FORMAT_DEFAULT:
+ *dest_value = src_value * 1; /* FIXME */
+ break;
+ default:
+ res = FALSE;
+ break;
}
break;
case GST_FORMAT_BYTES:
switch (*dest_format) {
- case GST_FORMAT_TIME:
- *dest_value = src_value * 1; /* FIXME */
- break;
- default:
- res = FALSE;
- break;
+ case GST_FORMAT_TIME:
+ *dest_value = src_value * 1; /* FIXME */
+ break;
+ default:
+ res = FALSE;
+ break;
}
break;
case GST_FORMAT_DEFAULT:
switch (*dest_format) {
- case GST_FORMAT_TIME:
- *dest_value = src_value * 1; /* FIXME */
- break;
- default:
- res = FALSE;
- break;
+ case GST_FORMAT_TIME:
+ *dest_value = src_value * 1; /* FIXME */
+ break;
+ default:
+ res = FALSE;
+ break;
}
break;
default:
}
static const GstQueryType *
-gst_qtdemux_get_src_query_types (GstPad *pad)
+gst_qtdemux_get_src_query_types (GstPad * pad)
{
static const GstQueryType src_types[] = {
GST_QUERY_TOTAL,
}
static const GstEventMask *
-gst_qtdemux_get_event_mask (GstPad *pad)
+gst_qtdemux_get_event_mask (GstPad * pad)
{
static const GstEventMask masks[] = {
- { GST_EVENT_SEEK, GST_SEEK_METHOD_SET | GST_SEEK_FLAG_KEY_UNIT },
- { 0, }
+ {GST_EVENT_SEEK, GST_SEEK_METHOD_SET | GST_SEEK_FLAG_KEY_UNIT},
+ {0,}
};
return masks;
}
static gboolean
-gst_qtdemux_handle_src_query (GstPad *pad, GstQueryType type,
- GstFormat *format, gint64 *value)
+gst_qtdemux_handle_src_query (GstPad * pad, GstQueryType type,
+ GstFormat * format, gint64 * value)
{
gboolean res = TRUE;
+
//QtDemuxStream *stream = gst_pad_get_element_private(pad);
switch (type) {
case GST_QUERY_TOTAL:
switch (*format) {
- case GST_FORMAT_TIME:
- *value = 0; /* FIXME */
- break;
- case GST_FORMAT_BYTES:
- *value = 0; /* FIXME */
- break;
- case GST_FORMAT_DEFAULT:
- *value = 0; /* FIXME */
- break;
- default:
- res = FALSE;
- break;
+ case GST_FORMAT_TIME:
+ *value = 0; /* FIXME */
+ break;
+ case GST_FORMAT_BYTES:
+ *value = 0; /* FIXME */
+ break;
+ case GST_FORMAT_DEFAULT:
+ *value = 0; /* FIXME */
+ break;
+ default:
+ res = FALSE;
+ break;
}
break;
case GST_QUERY_POSITION:
switch (*format) {
- case GST_FORMAT_TIME:
- *value = 0; /* FIXME */
- break;
- case GST_FORMAT_BYTES:
- *value = 0; /* FIXME */
- break;
- case GST_FORMAT_DEFAULT:
- *value = 0; /* FIXME */
- break;
- default:
- res = FALSE;
- break;
+ case GST_FORMAT_TIME:
+ *value = 0; /* FIXME */
+ break;
+ case GST_FORMAT_BYTES:
+ *value = 0; /* FIXME */
+ break;
+ case GST_FORMAT_DEFAULT:
+ *value = 0; /* FIXME */
+ break;
+ default:
+ res = FALSE;
+ break;
}
break;
default:
}
static gboolean
-gst_qtdemux_handle_src_event (GstPad *pad, GstEvent *event)
+gst_qtdemux_handle_src_event (GstPad * pad, GstEvent * event)
{
gboolean res = TRUE;
+
//QtDemuxStream *stream = gst_pad_get_element_private(pad);
switch (GST_EVENT_TYPE (event)) {
GST_DEBUG ("seek format %d", GST_EVENT_SEEK_FORMAT (event));
switch (GST_EVENT_SEEK_FORMAT (event)) {
- case GST_FORMAT_BYTES:
- case GST_FORMAT_DEFAULT:
- case GST_FORMAT_TIME:
- {
- gint64 desired_offset = GST_EVENT_SEEK_OFFSET (event);
-
- GST_DEBUG ("seeking to %" G_GINT64_FORMAT, desired_offset);
-
- res = FALSE;
- }
- default:
- res = FALSE;
- break;
+ case GST_FORMAT_BYTES:
+ case GST_FORMAT_DEFAULT:
+ case GST_FORMAT_TIME:
+ {
+ gint64 desired_offset = GST_EVENT_SEEK_OFFSET (event);
+
+ GST_DEBUG ("seeking to %" G_GINT64_FORMAT, desired_offset);
+
+ res = FALSE;
+ }
+ default:
+ res = FALSE;
+ break;
}
default:
res = FALSE;
GST_DEBUG_CATEGORY (qtdemux_debug);
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
GST_DEBUG_CATEGORY_INIT (qtdemux_debug, "qtdemux", 0, "qtdemux plugin");
return FALSE;
return gst_element_register (plugin, "qtdemux",
- GST_RANK_PRIMARY, GST_TYPE_QTDEMUX);
+ GST_RANK_PRIMARY, GST_TYPE_QTDEMUX);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "qtdemux",
- "Quicktime stream demuxer",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN
-)
-
-static gboolean gst_qtdemux_handle_sink_event (GstQTDemux *qtdemux)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "qtdemux",
+ "Quicktime stream demuxer",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
+
+ static gboolean gst_qtdemux_handle_sink_event (GstQTDemux * qtdemux)
{
guint32 remaining;
GstEvent *event;
GstEventType type;
- gst_bytestream_get_status(qtdemux->bs, &remaining, &event);
+ gst_bytestream_get_status (qtdemux->bs, &remaining, &event);
- type = event ? GST_EVENT_TYPE(event) : GST_EVENT_UNKNOWN;
+ type = event ? GST_EVENT_TYPE (event) : GST_EVENT_UNKNOWN;
GST_DEBUG ("qtdemux: event %p %d", event, type);
- switch(type){
+ switch (type) {
case GST_EVENT_EOS:
- gst_bytestream_flush(qtdemux->bs, remaining);
- gst_pad_event_default(qtdemux->sinkpad, event);
+ gst_bytestream_flush (qtdemux->bs, remaining);
+ gst_pad_event_default (qtdemux->sinkpad, event);
return FALSE;
case GST_EVENT_FLUSH:
//g_warning("flush event");
//gst_bytestream_flush_fast(qtdemux->bs, remaining);
break;
default:
- g_warning("unhandled event %d",type);
+ g_warning ("unhandled event %d", type);
break;
}
- gst_event_unref(event);
+ gst_event_unref (event);
return TRUE;
}
-static GstElementStateReturn gst_qtdemux_change_state(GstElement *element)
+static GstElementStateReturn
+gst_qtdemux_change_state (GstElement * element)
{
- GstQTDemux *qtdemux = GST_QTDEMUX(element);
+ GstQTDemux *qtdemux = GST_QTDEMUX (element);
- switch(GST_STATE_TRANSITION(element)){
+ switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY:
break;
case GST_STATE_READY_TO_PAUSED:
- qtdemux->bs = gst_bytestream_new(qtdemux->sinkpad);
+ qtdemux->bs = gst_bytestream_new (qtdemux->sinkpad);
qtdemux->state = QTDEMUX_STATE_HEADER;
/* FIXME */
break;
case GST_STATE_PLAYING_TO_PAUSED:
break;
case GST_STATE_PAUSED_TO_READY:
- gst_bytestream_destroy(qtdemux->bs);
+ gst_bytestream_destroy (qtdemux->bs);
break;
case GST_STATE_READY_TO_NULL:
break;
break;
}
- return GST_ELEMENT_CLASS(parent_class)->change_state(element);
+ return GST_ELEMENT_CLASS (parent_class)->change_state (element);
}
-static void gst_qtdemux_loop_header (GstElement *element)
+static void
+gst_qtdemux_loop_header (GstElement * element)
{
- GstQTDemux *qtdemux = GST_QTDEMUX(element);
+ GstQTDemux *qtdemux = GST_QTDEMUX (element);
guint8 *data;
guint32 length;
guint32 fourcc;
/* FIXME _tell gets the offset wrong */
//cur_offset = gst_bytestream_tell(qtdemux->bs);
-
+
cur_offset = qtdemux->offset;
- GST_DEBUG ("loop at position %d",cur_offset);
-
- switch(qtdemux->state){
- case QTDEMUX_STATE_HEADER:
- {
- do{
- ret = gst_bytestream_peek_bytes(qtdemux->bs, &data, 16);
- if(ret<16){
- if(!gst_qtdemux_handle_sink_event(qtdemux)){
- return;
+ GST_DEBUG ("loop at position %d", cur_offset);
+
+ switch (qtdemux->state) {
+ case QTDEMUX_STATE_HEADER:
+ {
+ do {
+ ret = gst_bytestream_peek_bytes (qtdemux->bs, &data, 16);
+ if (ret < 16) {
+ if (!gst_qtdemux_handle_sink_event (qtdemux)) {
+ return;
+ }
+ } else {
+ break;
}
- }else{
- break;
+ } while (1);
+
+ length = GUINT32_FROM_BE (*(guint32 *) data);
+ GST_DEBUG ("length %08x", length);
+ fourcc = GUINT32_FROM_LE (*(guint32 *) (data + 4));
+ GST_DEBUG ("fourcc " GST_FOURCC_FORMAT, GST_FOURCC_ARGS (fourcc));
+
+ if (length == 0) {
+ length = gst_bytestream_length (qtdemux->bs) - cur_offset;
}
- }while(1);
+ if (length == 1) {
+ guint32 length1, length2;
- length = GUINT32_FROM_BE(*(guint32 *)data);
- GST_DEBUG ("length %08x",length);
- fourcc = GUINT32_FROM_LE(*(guint32 *)(data+4));
- GST_DEBUG ("fourcc " GST_FOURCC_FORMAT, GST_FOURCC_ARGS(fourcc));
+ length1 = GUINT32_FROM_BE (*(guint32 *) (data + 8));
+ GST_DEBUG ("length1 %08x", length1);
+ length2 = GUINT32_FROM_BE (*(guint32 *) (data + 12));
+ GST_DEBUG ("length2 %08x", length2);
- if(length==0){
- length = gst_bytestream_length(qtdemux->bs) - cur_offset;
- }
- if(length==1){
- guint32 length1, length2;
-
- length1 = GUINT32_FROM_BE(*(guint32 *)(data+8));
- GST_DEBUG ("length1 %08x",length1);
- length2 = GUINT32_FROM_BE(*(guint32 *)(data+12));
- GST_DEBUG ("length2 %08x",length2);
-
- length=length2;
- }
-
- switch(fourcc){
- case GST_MAKE_FOURCC('m','d','a','t'):
- case GST_MAKE_FOURCC('f','r','e','e'):
- case GST_MAKE_FOURCC('w','i','d','e'):
- case GST_MAKE_FOURCC('P','I','C','T'):
- case GST_MAKE_FOURCC('p','n','o','t'):
- break;
- case GST_MAKE_FOURCC('m','o','o','v'):
- {
- GstBuffer *moov;
-
- do{
- ret = gst_bytestream_read(qtdemux->bs, &moov, length);
- if(ret < length){
- GST_DEBUG ("read failed (%d < %d)",ret,length);
- if(!gst_qtdemux_handle_sink_event(qtdemux)){
- return;
+ length = length2;
+ }
+
+ switch (fourcc) {
+ case GST_MAKE_FOURCC ('m', 'd', 'a', 't'):
+ case GST_MAKE_FOURCC ('f', 'r', 'e', 'e'):
+ case GST_MAKE_FOURCC ('w', 'i', 'd', 'e'):
+ case GST_MAKE_FOURCC ('P', 'I', 'C', 'T'):
+ case GST_MAKE_FOURCC ('p', 'n', 'o', 't'):
+ break;
+ case GST_MAKE_FOURCC ('m', 'o', 'o', 'v'):
+ {
+ GstBuffer *moov;
+
+ do {
+ ret = gst_bytestream_read (qtdemux->bs, &moov, length);
+ if (ret < length) {
+ GST_DEBUG ("read failed (%d < %d)", ret, length);
+ if (!gst_qtdemux_handle_sink_event (qtdemux)) {
+ return;
+ }
+ } else {
+ break;
}
- }else{
- break;
+ } while (1);
+
+ qtdemux_parse_moov (qtdemux, GST_BUFFER_DATA (moov), length);
+ if (1)
+ qtdemux_node_dump (qtdemux, qtdemux->moov_node);
+ qtdemux_parse_tree (qtdemux);
+ qtdemux->state = QTDEMUX_STATE_MOVIE;
+ break;
+ }
+ default:
+ {
+ GST_LOG ("unknown %08x '" GST_FOURCC_FORMAT "' at %d\n",
+ fourcc, GST_FOURCC_ARGS (fourcc), cur_offset);
+ break;
+ }
+ }
+ ret = gst_bytestream_seek (qtdemux->bs, cur_offset + length,
+ GST_SEEK_METHOD_SET);
+ qtdemux->offset = cur_offset + length;
+ GST_DEBUG ("seek returned %d\n", ret);
+ break;
+ }
+ case QTDEMUX_STATE_SEEKING_EOS:
+ {
+ guint8 *data;
+
+ do {
+ ret = gst_bytestream_peek_bytes (qtdemux->bs, &data, 1);
+ if (ret < 1) {
+ if (!gst_qtdemux_handle_sink_event (qtdemux)) {
+ return;
}
- }while(1);
+ } else {
+ break;
+ }
+ } while (TRUE);
+ gst_element_set_eos (element);
- qtdemux_parse_moov(qtdemux, GST_BUFFER_DATA(moov), length);
- if(1)qtdemux_node_dump(qtdemux, qtdemux->moov_node);
- qtdemux_parse_tree(qtdemux);
- qtdemux->state = QTDEMUX_STATE_MOVIE;
- break;
- }
- default:
- {
- GST_LOG("unknown %08x '" GST_FOURCC_FORMAT "' at %d\n",
- fourcc, GST_FOURCC_ARGS(fourcc), cur_offset);
- break;
- }
+ qtdemux->state = QTDEMUX_STATE_EOS;
+ return;
}
- ret = gst_bytestream_seek(qtdemux->bs, cur_offset + length,
- GST_SEEK_METHOD_SET);
- qtdemux->offset = cur_offset + length;
- GST_DEBUG ("seek returned %d\n",ret);
- break;
- }
- case QTDEMUX_STATE_SEEKING_EOS:
- {
- guint8 *data;
-
- do{
- ret = gst_bytestream_peek_bytes(qtdemux->bs, &data, 1);
- if(ret<1){
- if(!gst_qtdemux_handle_sink_event(qtdemux)){
- return;
- }
- }else{
- break;
+ case QTDEMUX_STATE_EOS:
+ g_warning ("spinning in EOS\n");
+ return;
+ case QTDEMUX_STATE_MOVIE:
+ {
+ QtDemuxStream *stream;
+ guint64 min_time;
+ int index = -1;
+ int i;
+
+ min_time = G_MAXUINT64;
+ for (i = 0; i < qtdemux->n_streams; i++) {
+ stream = qtdemux->streams[i];
+
+ if (stream->sample_index < stream->n_samples &&
+ stream->samples[stream->sample_index].timestamp < min_time) {
+ min_time = stream->samples[stream->sample_index].timestamp;
+ index = i;
+ }
}
- }while(TRUE);
- gst_element_set_eos(element);
- qtdemux->state = QTDEMUX_STATE_EOS;
- return;
- }
- case QTDEMUX_STATE_EOS:
- g_warning("spinning in EOS\n");
- return;
- case QTDEMUX_STATE_MOVIE:
- {
- QtDemuxStream *stream;
- guint64 min_time;
- int index = -1;
- int i;
-
- min_time = G_MAXUINT64;
- for(i=0;i<qtdemux->n_streams;i++){
- stream = qtdemux->streams[i];
-
- if(stream->sample_index < stream->n_samples &&
- stream->samples[stream->sample_index].timestamp < min_time){
- min_time = stream->samples[stream->sample_index].timestamp;
- index = i;
- }
- }
+ if (index == -1) {
+ for (i = 0; i < qtdemux->n_streams; i++) {
+ gst_pad_push (qtdemux->streams[i]->pad,
+ GST_DATA (gst_event_new (GST_EVENT_EOS)));
+ }
+ ret = gst_bytestream_seek (qtdemux->bs, 0, GST_SEEK_METHOD_END);
+ GST_DEBUG ("seek returned %d", ret);
- if(index==-1){
- for(i=0;i<qtdemux->n_streams;i++){
- gst_pad_push(qtdemux->streams[i]->pad,
- GST_DATA(gst_event_new (GST_EVENT_EOS)));
+ qtdemux->state = QTDEMUX_STATE_SEEKING_EOS;
+ return;
}
- ret = gst_bytestream_seek(qtdemux->bs, 0, GST_SEEK_METHOD_END);
- GST_DEBUG ("seek returned %d",ret);
-
- qtdemux->state = QTDEMUX_STATE_SEEKING_EOS;
- return;
- }
- stream = qtdemux->streams[index];
+ stream = qtdemux->streams[index];
- offset = stream->samples[stream->sample_index].offset;
- size = stream->samples[stream->sample_index].size;
+ offset = stream->samples[stream->sample_index].offset;
+ size = stream->samples[stream->sample_index].size;
- GST_INFO ("pushing from stream %d, sample_index=%d offset=%d size=%d timestamp=%lld",
- index, stream->sample_index, offset, size,
- stream->samples[stream->sample_index].timestamp);
+ GST_INFO
+ ("pushing from stream %d, sample_index=%d offset=%d size=%d timestamp=%lld",
+ index, stream->sample_index, offset, size,
+ stream->samples[stream->sample_index].timestamp);
- cur_offset = gst_bytestream_tell(qtdemux->bs);
- if(offset != cur_offset){
- GST_DEBUG ("seeking to offset %d",offset);
- GST_LOG ("seeking to offset %d\n",offset);
- ret = gst_bytestream_seek(qtdemux->bs, offset, GST_SEEK_METHOD_SET);
- GST_DEBUG ("seek returned %d",ret);
- return;
- }
+ cur_offset = gst_bytestream_tell (qtdemux->bs);
+ if (offset != cur_offset) {
+ GST_DEBUG ("seeking to offset %d", offset);
+ GST_LOG ("seeking to offset %d\n", offset);
+ ret = gst_bytestream_seek (qtdemux->bs, offset, GST_SEEK_METHOD_SET);
+ GST_DEBUG ("seek returned %d", ret);
+ return;
+ }
- GST_DEBUG ("reading %d bytes\n",size);
- buf = NULL;
- do{
- ret = gst_bytestream_read(qtdemux->bs, &buf, size);
- if(ret < size){
- GST_DEBUG ("read failed (%d < %d)",ret,size);
- if(!gst_qtdemux_handle_sink_event(qtdemux)){
- return;
+ GST_DEBUG ("reading %d bytes\n", size);
+ buf = NULL;
+ do {
+ ret = gst_bytestream_read (qtdemux->bs, &buf, size);
+ if (ret < size) {
+ GST_DEBUG ("read failed (%d < %d)", ret, size);
+ if (!gst_qtdemux_handle_sink_event (qtdemux)) {
+ return;
+ }
+ } else {
+ break;
+ }
+ } while (TRUE);
+
+ if (buf) {
+ /* hum... */
+ if (stream->subtype == GST_MAKE_FOURCC ('v', 'i', 'd', 'e')) {
+ float fps =
+ 1. * GST_SECOND / stream->samples[stream->sample_index].duration;
+ if (fps != stream->fps) {
+ gst_caps_set_simple (stream->caps, "framerate", G_TYPE_DOUBLE, fps,
+ NULL);
+ stream->fps = fps;
+ gst_pad_set_explicit_caps (stream->pad, stream->caps);
+ }
}
- }else{
- break;
- }
- }while(TRUE);
-
- if(buf){
- /* hum... */
- if(stream->subtype == GST_MAKE_FOURCC('v','i','d','e')){
- float fps = 1. * GST_SECOND / stream->samples[stream->sample_index].duration;
- if (fps != stream->fps) {
- gst_caps_set_simple (stream->caps, "framerate", G_TYPE_DOUBLE, fps,
- NULL);
- stream->fps = fps;
- gst_pad_set_explicit_caps(stream->pad, stream->caps);
- }
- }
- GST_BUFFER_TIMESTAMP(buf) = stream->samples[stream->sample_index].timestamp;
- GST_BUFFER_DURATION(buf) = stream->samples[stream->sample_index].duration;
- gst_pad_push(stream->pad, GST_DATA (buf));
+ GST_BUFFER_TIMESTAMP (buf) =
+ stream->samples[stream->sample_index].timestamp;
+ GST_BUFFER_DURATION (buf) =
+ stream->samples[stream->sample_index].duration;
+ gst_pad_push (stream->pad, GST_DATA (buf));
- GST_DEBUG ("pushing buffer on %" GST_PTR_FORMAT, stream->pad);
+ GST_DEBUG ("pushing buffer on %" GST_PTR_FORMAT, stream->pad);
+ }
+ stream->sample_index++;
+ break;
}
- stream->sample_index++;
- break;
- }
- default:
- /* unreached */
- g_assert(0);
+ default:
+ /* unreached */
+ g_assert (0);
}
}
-void gst_qtdemux_add_stream(GstQTDemux *qtdemux, QtDemuxStream *stream)
+void
+gst_qtdemux_add_stream (GstQTDemux * qtdemux, QtDemuxStream * stream)
{
- if(stream->subtype == GST_MAKE_FOURCC('v','i','d','e')){
+ if (stream->subtype == GST_MAKE_FOURCC ('v', 'i', 'd', 'e')) {
gchar *name = g_strdup_printf ("video_%02d", qtdemux->n_video_streams);
- stream->pad = gst_pad_new_from_template (
- gst_static_pad_template_get(&gst_qtdemux_videosrc_template), name);
+
+ stream->pad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_qtdemux_videosrc_template), name);
g_free (name);
stream->fps = 1. * GST_SECOND / stream->samples[0].duration;
- if(stream->caps){
- gst_caps_set_simple(stream->caps,
+ if (stream->caps) {
+ gst_caps_set_simple (stream->caps,
"width", G_TYPE_INT, stream->width,
"height", G_TYPE_INT, stream->height,
"framerate", G_TYPE_DOUBLE, stream->fps, NULL);
}
qtdemux->n_video_streams++;
- }else{
+ } else {
gchar *name = g_strdup_printf ("audio_%02d", qtdemux->n_audio_streams);
- stream->pad = gst_pad_new_from_template (
- gst_static_pad_template_get(&gst_qtdemux_audiosrc_template), name);
+
+ stream->pad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_qtdemux_audiosrc_template), name);
g_free (name);
- if(stream->caps){
- gst_caps_set_simple(stream->caps,
- "rate", G_TYPE_INT, (int)stream->rate,
+ if (stream->caps) {
+ gst_caps_set_simple (stream->caps,
+ "rate", G_TYPE_INT, (int) stream->rate,
"channels", G_TYPE_INT, stream->n_channels, NULL);
}
qtdemux->n_audio_streams++;
gst_pad_use_explicit_caps (stream->pad);
- GST_PAD_ELEMENT_PRIVATE(stream->pad) = stream;
+ GST_PAD_ELEMENT_PRIVATE (stream->pad) = stream;
qtdemux->streams[qtdemux->n_streams] = stream;
qtdemux->n_streams++;
GST_DEBUG ("n_streams is now %d", qtdemux->n_streams);
gst_pad_set_event_mask_function (stream->pad, gst_qtdemux_get_event_mask);
gst_pad_set_event_function (stream->pad, gst_qtdemux_handle_src_event);
- gst_pad_set_query_type_function (stream->pad, gst_qtdemux_get_src_query_types);
+ gst_pad_set_query_type_function (stream->pad,
+ gst_qtdemux_get_src_query_types);
gst_pad_set_query_function (stream->pad, gst_qtdemux_handle_src_query);
gst_pad_set_formats_function (stream->pad, gst_qtdemux_get_src_formats);
gst_pad_set_convert_function (stream->pad, gst_qtdemux_src_convert);
- gst_pad_set_explicit_caps(stream->pad, stream->caps);
+ gst_pad_set_explicit_caps (stream->pad, stream->caps);
GST_DEBUG ("adding pad %p to qtdemux %p", stream->pad, qtdemux);
- gst_element_add_pad(GST_ELEMENT (qtdemux), stream->pad);
+ gst_element_add_pad (GST_ELEMENT (qtdemux), stream->pad);
}
#define FOURCC_cmvd GST_MAKE_FOURCC('c','m','v','d')
-static void qtdemux_dump_mvhd(GstQTDemux *qtdemux, void *buffer, int depth);
-static void qtdemux_dump_tkhd(GstQTDemux *qtdemux, void *buffer, int depth);
-static void qtdemux_dump_elst(GstQTDemux *qtdemux, void *buffer, int depth);
-static void qtdemux_dump_mdhd(GstQTDemux *qtdemux, void *buffer, int depth);
-static void qtdemux_dump_hdlr(GstQTDemux *qtdemux, void *buffer, int depth);
-static void qtdemux_dump_vmhd(GstQTDemux *qtdemux, void *buffer, int depth);
-static void qtdemux_dump_dref(GstQTDemux *qtdemux, void *buffer, int depth);
-static void qtdemux_dump_stsd(GstQTDemux *qtdemux, void *buffer, int depth);
-static void qtdemux_dump_stts(GstQTDemux *qtdemux, void *buffer, int depth);
-static void qtdemux_dump_stss(GstQTDemux *qtdemux, void *buffer, int depth);
-static void qtdemux_dump_stsc(GstQTDemux *qtdemux, void *buffer, int depth);
-static void qtdemux_dump_stsz(GstQTDemux *qtdemux, void *buffer, int depth);
-static void qtdemux_dump_stco(GstQTDemux *qtdemux, void *buffer, int depth);
-static void qtdemux_dump_co64(GstQTDemux *qtdemux, void *buffer, int depth);
-static void qtdemux_dump_dcom(GstQTDemux *qtdemux, void *buffer, int depth);
-static void qtdemux_dump_cmvd(GstQTDemux *qtdemux, void *buffer, int depth);
+static void qtdemux_dump_mvhd (GstQTDemux * qtdemux, void *buffer, int depth);
+static void qtdemux_dump_tkhd (GstQTDemux * qtdemux, void *buffer, int depth);
+static void qtdemux_dump_elst (GstQTDemux * qtdemux, void *buffer, int depth);
+static void qtdemux_dump_mdhd (GstQTDemux * qtdemux, void *buffer, int depth);
+static void qtdemux_dump_hdlr (GstQTDemux * qtdemux, void *buffer, int depth);
+static void qtdemux_dump_vmhd (GstQTDemux * qtdemux, void *buffer, int depth);
+static void qtdemux_dump_dref (GstQTDemux * qtdemux, void *buffer, int depth);
+static void qtdemux_dump_stsd (GstQTDemux * qtdemux, void *buffer, int depth);
+static void qtdemux_dump_stts (GstQTDemux * qtdemux, void *buffer, int depth);
+static void qtdemux_dump_stss (GstQTDemux * qtdemux, void *buffer, int depth);
+static void qtdemux_dump_stsc (GstQTDemux * qtdemux, void *buffer, int depth);
+static void qtdemux_dump_stsz (GstQTDemux * qtdemux, void *buffer, int depth);
+static void qtdemux_dump_stco (GstQTDemux * qtdemux, void *buffer, int depth);
+static void qtdemux_dump_co64 (GstQTDemux * qtdemux, void *buffer, int depth);
+static void qtdemux_dump_dcom (GstQTDemux * qtdemux, void *buffer, int depth);
+static void qtdemux_dump_cmvd (GstQTDemux * qtdemux, void *buffer, int depth);
QtNodeType qt_node_types[] = {
- { FOURCC_moov, "movie", QT_CONTAINER, },
- { FOURCC_mvhd, "movie header", 0,
- qtdemux_dump_mvhd },
- { FOURCC_clip, "clipping", QT_CONTAINER, },
- { FOURCC_trak, "track", QT_CONTAINER, },
- { FOURCC_udta, "user data", 0, }, /* special container */
- { FOURCC_ctab, "color table", 0, },
- { FOURCC_tkhd, "track header", 0,
- qtdemux_dump_tkhd },
- { FOURCC_crgn, "clipping region", 0, },
- { FOURCC_matt, "track matte", QT_CONTAINER, },
- { FOURCC_kmat, "compressed matte", 0, },
- { FOURCC_edts, "edit", QT_CONTAINER, },
- { FOURCC_elst, "edit list", 0,
- qtdemux_dump_elst },
- { FOURCC_load, "track load settings", 0, },
- { FOURCC_tref, "track reference", QT_CONTAINER, },
- { FOURCC_imap, "track input map", QT_CONTAINER, },
- { FOURCC___in, "track input", 0, }, /* special container */
- { FOURCC___ty, "input type", 0, },
- { FOURCC_mdia, "media", QT_CONTAINER },
- { FOURCC_mdhd, "media header", 0,
- qtdemux_dump_mdhd },
- { FOURCC_hdlr, "handler reference", 0,
- qtdemux_dump_hdlr },
- { FOURCC_minf, "media information", QT_CONTAINER },
- { FOURCC_vmhd, "video media information", 0,
- qtdemux_dump_vmhd },
- { FOURCC_smhd, "sound media information", 0 },
- { FOURCC_gmhd, "base media information header", 0 },
- { FOURCC_gmin, "base media info", 0 },
- { FOURCC_dinf, "data information", QT_CONTAINER },
- { FOURCC_dref, "data reference", 0,
- qtdemux_dump_dref },
- { FOURCC_stbl, "sample table", QT_CONTAINER },
- { FOURCC_stsd, "sample description", 0,
- qtdemux_dump_stsd },
- { FOURCC_stts, "time-to-sample", 0,
- qtdemux_dump_stts },
- { FOURCC_stss, "sync sample", 0,
- qtdemux_dump_stss },
- { FOURCC_stsc, "sample-to-chunk", 0,
- qtdemux_dump_stsc },
- { FOURCC_stsz, "sample size", 0,
- qtdemux_dump_stsz },
- { FOURCC_stco, "chunk offset", 0,
- qtdemux_dump_stco },
- { FOURCC_co64, "64-bit chunk offset", 0,
- qtdemux_dump_co64 },
- { FOURCC_vide, "video media", 0 },
- { FOURCC_cmov, "compressed movie", QT_CONTAINER },
- { FOURCC_dcom, "compressed data", 0,
- qtdemux_dump_dcom },
- { FOURCC_cmvd, "compressed movie data", 0,
- qtdemux_dump_cmvd },
- { 0, "unknown", 0 },
+ {FOURCC_moov, "movie", QT_CONTAINER,},
+ {FOURCC_mvhd, "movie header", 0,
+ qtdemux_dump_mvhd},
+ {FOURCC_clip, "clipping", QT_CONTAINER,},
+ {FOURCC_trak, "track", QT_CONTAINER,},
+ {FOURCC_udta, "user data", 0,}, /* special container */
+ {FOURCC_ctab, "color table", 0,},
+ {FOURCC_tkhd, "track header", 0,
+ qtdemux_dump_tkhd},
+ {FOURCC_crgn, "clipping region", 0,},
+ {FOURCC_matt, "track matte", QT_CONTAINER,},
+ {FOURCC_kmat, "compressed matte", 0,},
+ {FOURCC_edts, "edit", QT_CONTAINER,},
+ {FOURCC_elst, "edit list", 0,
+ qtdemux_dump_elst},
+ {FOURCC_load, "track load settings", 0,},
+ {FOURCC_tref, "track reference", QT_CONTAINER,},
+ {FOURCC_imap, "track input map", QT_CONTAINER,},
+ {FOURCC___in, "track input", 0,}, /* special container */
+ {FOURCC___ty, "input type", 0,},
+ {FOURCC_mdia, "media", QT_CONTAINER},
+ {FOURCC_mdhd, "media header", 0,
+ qtdemux_dump_mdhd},
+ {FOURCC_hdlr, "handler reference", 0,
+ qtdemux_dump_hdlr},
+ {FOURCC_minf, "media information", QT_CONTAINER},
+ {FOURCC_vmhd, "video media information", 0,
+ qtdemux_dump_vmhd},
+ {FOURCC_smhd, "sound media information", 0},
+ {FOURCC_gmhd, "base media information header", 0},
+ {FOURCC_gmin, "base media info", 0},
+ {FOURCC_dinf, "data information", QT_CONTAINER},
+ {FOURCC_dref, "data reference", 0,
+ qtdemux_dump_dref},
+ {FOURCC_stbl, "sample table", QT_CONTAINER},
+ {FOURCC_stsd, "sample description", 0,
+ qtdemux_dump_stsd},
+ {FOURCC_stts, "time-to-sample", 0,
+ qtdemux_dump_stts},
+ {FOURCC_stss, "sync sample", 0,
+ qtdemux_dump_stss},
+ {FOURCC_stsc, "sample-to-chunk", 0,
+ qtdemux_dump_stsc},
+ {FOURCC_stsz, "sample size", 0,
+ qtdemux_dump_stsz},
+ {FOURCC_stco, "chunk offset", 0,
+ qtdemux_dump_stco},
+ {FOURCC_co64, "64-bit chunk offset", 0,
+ qtdemux_dump_co64},
+ {FOURCC_vide, "video media", 0},
+ {FOURCC_cmov, "compressed movie", QT_CONTAINER},
+ {FOURCC_dcom, "compressed data", 0,
+ qtdemux_dump_dcom},
+ {FOURCC_cmvd, "compressed movie data", 0,
+ qtdemux_dump_cmvd},
+ {0, "unknown", 0},
};
-static int n_qt_node_types = sizeof(qt_node_types)/sizeof(qt_node_types[0]);
+static int n_qt_node_types = sizeof (qt_node_types) / sizeof (qt_node_types[0]);
-static void *qtdemux_zalloc(void *opaque, unsigned int items, unsigned int size)
+static void *
+qtdemux_zalloc (void *opaque, unsigned int items, unsigned int size)
{
- return g_malloc(items*size);
+ return g_malloc (items * size);
}
-static void qtdemux_zfree(void *opaque, void *addr)
+static void
+qtdemux_zfree (void *opaque, void *addr)
{
- g_free(addr);
+ g_free (addr);
}
-static void *qtdemux_inflate(void *z_buffer, int z_length, int length)
+static void *
+qtdemux_inflate (void *z_buffer, int z_length, int length)
{
void *buffer;
z_stream *z;
int ret;
- z = g_new0(z_stream, 1);
+ z = g_new0 (z_stream, 1);
z->zalloc = qtdemux_zalloc;
z->zfree = qtdemux_zfree;
z->opaque = NULL;
z->next_in = z_buffer;
z->avail_in = z_length;
- buffer = g_malloc(length);
- ret = inflateInit(z);
- while(z->avail_in > 0){
- if(z->avail_out == 0){
+ buffer = g_malloc (length);
+ ret = inflateInit (z);
+ while (z->avail_in > 0) {
+ if (z->avail_out == 0) {
length += 1024;
- buffer = realloc(buffer, length);
+ buffer = realloc (buffer, length);
z->next_out = buffer + z->total_out;
z->avail_out = 1024;
}
- ret = inflate(z,Z_SYNC_FLUSH);
- if(ret != Z_OK)break;
+ ret = inflate (z, Z_SYNC_FLUSH);
+ if (ret != Z_OK)
+ break;
}
- if(ret != Z_STREAM_END){
- g_warning("inflate() returned %d\n",ret);
+ if (ret != Z_STREAM_END) {
+ g_warning ("inflate() returned %d\n", ret);
}
- g_free(z);
+ g_free (z);
return buffer;
}
-static void qtdemux_parse_moov(GstQTDemux *qtdemux, void *buffer, int length)
+static void
+qtdemux_parse_moov (GstQTDemux * qtdemux, void *buffer, int length)
{
GNode *cmov;
- qtdemux->moov_node = g_node_new(buffer);
+ qtdemux->moov_node = g_node_new (buffer);
- qtdemux_parse(qtdemux, qtdemux->moov_node, buffer, length);
+ qtdemux_parse (qtdemux, qtdemux->moov_node, buffer, length);
- cmov = qtdemux_tree_get_child_by_type(qtdemux->moov_node, FOURCC_cmov);
- if(cmov){
+ cmov = qtdemux_tree_get_child_by_type (qtdemux->moov_node, FOURCC_cmov);
+ if (cmov) {
GNode *dcom;
GNode *cmvd;
- dcom = qtdemux_tree_get_child_by_type(cmov, FOURCC_dcom);
- cmvd = qtdemux_tree_get_child_by_type(cmov, FOURCC_cmvd);
+ dcom = qtdemux_tree_get_child_by_type (cmov, FOURCC_dcom);
+ cmvd = qtdemux_tree_get_child_by_type (cmov, FOURCC_cmvd);
- if(QTDEMUX_FOURCC_GET(dcom->data+8) == GST_MAKE_FOURCC('z','l','i','b')){
+ if (QTDEMUX_FOURCC_GET (dcom->data + 8) == GST_MAKE_FOURCC ('z', 'l', 'i',
+ 'b')) {
int uncompressed_length;
int compressed_length;
void *buf;
-
- uncompressed_length = QTDEMUX_GUINT32_GET(cmvd->data+8);
- compressed_length = QTDEMUX_GUINT32_GET(cmvd->data+4) - 12;
- GST_LOG("length = %d\n",uncompressed_length);
- buf = qtdemux_inflate(cmvd->data + 12, compressed_length,
+ uncompressed_length = QTDEMUX_GUINT32_GET (cmvd->data + 8);
+ compressed_length = QTDEMUX_GUINT32_GET (cmvd->data + 4) - 12;
+ GST_LOG ("length = %d\n", uncompressed_length);
+
+ buf = qtdemux_inflate (cmvd->data + 12, compressed_length,
uncompressed_length);
qtdemux->moov_node_compressed = qtdemux->moov_node;
- qtdemux->moov_node = g_node_new(buf);
+ qtdemux->moov_node = g_node_new (buf);
- qtdemux_parse(qtdemux, qtdemux->moov_node, buf, uncompressed_length);
- }else{
- GST_LOG("unknown header compression type\n");
+ qtdemux_parse (qtdemux, qtdemux->moov_node, buf, uncompressed_length);
+ } else {
+ GST_LOG ("unknown header compression type\n");
}
}
}
-static void qtdemux_parse(GstQTDemux *qtdemux, GNode *node, void *buffer, int length)
+static void
+qtdemux_parse (GstQTDemux * qtdemux, GNode * node, void *buffer, int length)
{
guint32 fourcc;
guint32 node_length;
QtNodeType *type;
void *end;
- GST_LOG("qtdemux_parse %p %d\n",buffer, length);
+ GST_LOG ("qtdemux_parse %p %d\n", buffer, length);
- node_length = QTDEMUX_GUINT32_GET(buffer);
- fourcc = QTDEMUX_FOURCC_GET(buffer+4);
+ node_length = QTDEMUX_GUINT32_GET (buffer);
+ fourcc = QTDEMUX_FOURCC_GET (buffer + 4);
- type = qtdemux_type_get(fourcc);
-
- GST_LOG("parsing '" GST_FOURCC_FORMAT "', length=%d\n",
- GST_FOURCC_ARGS(fourcc), node_length);
+ type = qtdemux_type_get (fourcc);
- if(type->flags & QT_CONTAINER){
+ GST_LOG ("parsing '" GST_FOURCC_FORMAT "', length=%d\n",
+ GST_FOURCC_ARGS (fourcc), node_length);
+
+ if (type->flags & QT_CONTAINER) {
void *buf;
guint32 len;
buf = buffer + 8;
end = buffer + length;
- while(buf < end){
+ while (buf < end) {
GNode *child;
- if(buf + 8 >= end){
+ if (buf + 8 >= end) {
/* FIXME: get annoyed */
- GST_LOG("buffer overrun\n");
+ GST_LOG ("buffer overrun\n");
}
- len = QTDEMUX_GUINT32_GET(buf);
+ len = QTDEMUX_GUINT32_GET (buf);
- child = g_node_new(buf);
- g_node_append(node, child);
- qtdemux_parse(qtdemux, child, buf, len);
+ child = g_node_new (buf);
+ g_node_append (node, child);
+ qtdemux_parse (qtdemux, child, buf, len);
buf += len;
}
- }else{
+ } else {
#if 0
- if(fourcc == FOURCC_cmvd){
+ if (fourcc == FOURCC_cmvd) {
int uncompressed_length;
void *buf;
-
- uncompressed_length = QTDEMUX_GUINT32_GET(buffer+8);
- GST_LOG("length = %d\n",uncompressed_length);
- buf = qtdemux_inflate(buffer + 12, node_length-12, uncompressed_length);
+ uncompressed_length = QTDEMUX_GUINT32_GET (buffer + 8);
+ GST_LOG ("length = %d\n", uncompressed_length);
+
+ buf =
+ qtdemux_inflate (buffer + 12, node_length - 12, uncompressed_length);
end = buf + uncompressed_length;
- while(buf < end){
- GNode *child;
+ while (buf < end) {
+ GNode *child;
guint32 len;
- if(buf + 8 >= end){
+ if (buf + 8 >= end) {
/* FIXME: get annoyed */
- GST_LOG("buffer overrun\n");
- }
- len = QTDEMUX_GUINT32_GET(buf);
+ GST_LOG ("buffer overrun\n");
+ }
+ len = QTDEMUX_GUINT32_GET (buf);
- child = g_node_new(buf);
- g_node_append(node, child);
- qtdemux_parse(qtdemux, child, buf, len);
+ child = g_node_new (buf);
+ g_node_append (node, child);
+ qtdemux_parse (qtdemux, child, buf, len);
- buf += len;
+ buf += len;
}
}
#endif
}
}
-static QtNodeType *qtdemux_type_get(guint32 fourcc)
+static QtNodeType *
+qtdemux_type_get (guint32 fourcc)
{
int i;
- for(i=0;i<n_qt_node_types;i++){
- if(qt_node_types[i].fourcc == fourcc)
- return qt_node_types+i;
+ for (i = 0; i < n_qt_node_types; i++) {
+ if (qt_node_types[i].fourcc == fourcc)
+ return qt_node_types + i;
}
- return qt_node_types+n_qt_node_types-1;
+ return qt_node_types + n_qt_node_types - 1;
}
-static gboolean qtdemux_node_dump_foreach(GNode *node, gpointer data)
+static gboolean
+qtdemux_node_dump_foreach (GNode * node, gpointer data)
{
void *buffer = node->data;
guint32 node_length;
QtNodeType *type;
int depth;
- node_length = GUINT32_FROM_BE(*(guint32 *)buffer);
- fourcc = GUINT32_FROM_LE(*(guint32 *)(buffer+4));
+ node_length = GUINT32_FROM_BE (*(guint32 *) buffer);
+ fourcc = GUINT32_FROM_LE (*(guint32 *) (buffer + 4));
- type = qtdemux_type_get(fourcc);
+ type = qtdemux_type_get (fourcc);
- depth = (g_node_depth(node)-1)*2;
- GST_LOG("%*s'" GST_FOURCC_FORMAT "', [%d], %s\n",
- depth, "",
- GST_FOURCC_ARGS(fourcc),
- node_length,
- type->name);
+ depth = (g_node_depth (node) - 1) * 2;
+ GST_LOG ("%*s'" GST_FOURCC_FORMAT "', [%d], %s\n",
+ depth, "", GST_FOURCC_ARGS (fourcc), node_length, type->name);
- if(type->dump)type->dump(data, buffer, depth);
+ if (type->dump)
+ type->dump (data, buffer, depth);
return FALSE;
}
-static void qtdemux_node_dump(GstQTDemux *qtdemux, GNode *node)
+static void
+qtdemux_node_dump (GstQTDemux * qtdemux, GNode * node)
{
- g_node_traverse(qtdemux->moov_node, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
+ g_node_traverse (qtdemux->moov_node, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
qtdemux_node_dump_foreach, qtdemux);
}
-static void qtdemux_dump_mvhd(GstQTDemux *qtdemux, void *buffer, int depth)
+static void
+qtdemux_dump_mvhd (GstQTDemux * qtdemux, void *buffer, int depth)
{
- GST_LOG("%*s version/flags: %08x\n", depth, "", QTDEMUX_GUINT32_GET(buffer+8));
- GST_LOG("%*s creation time: %u\n", depth, "", QTDEMUX_GUINT32_GET(buffer+12));
- GST_LOG("%*s modify time: %u\n", depth, "", QTDEMUX_GUINT32_GET(buffer+16));
- GST_LOG("%*s time scale: 1/%u sec\n", depth, "", QTDEMUX_GUINT32_GET(buffer+20));
- GST_LOG("%*s duration: %u\n", depth, "", QTDEMUX_GUINT32_GET(buffer+24));
- GST_LOG("%*s pref. rate: %g\n", depth, "", QTDEMUX_FP32_GET(buffer+28));
- GST_LOG("%*s pref. volume: %g\n", depth, "", QTDEMUX_FP16_GET(buffer+32));
- GST_LOG("%*s preview time: %u\n", depth, "", QTDEMUX_GUINT32_GET(buffer+80));
- GST_LOG("%*s preview dur.: %u\n", depth, "", QTDEMUX_GUINT32_GET(buffer+84));
- GST_LOG("%*s poster time: %u\n", depth, "", QTDEMUX_GUINT32_GET(buffer+88));
- GST_LOG("%*s select time: %u\n", depth, "", QTDEMUX_GUINT32_GET(buffer+92));
- GST_LOG("%*s select dur.: %u\n", depth, "", QTDEMUX_GUINT32_GET(buffer+96));
- GST_LOG("%*s current time: %u\n", depth, "", QTDEMUX_GUINT32_GET(buffer+100));
- GST_LOG("%*s next track ID: %d\n", depth, "", QTDEMUX_GUINT32_GET(buffer+104));
+ GST_LOG ("%*s version/flags: %08x\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 8));
+ GST_LOG ("%*s creation time: %u\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 12));
+ GST_LOG ("%*s modify time: %u\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 16));
+ GST_LOG ("%*s time scale: 1/%u sec\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 20));
+ GST_LOG ("%*s duration: %u\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 24));
+ GST_LOG ("%*s pref. rate: %g\n", depth, "",
+ QTDEMUX_FP32_GET (buffer + 28));
+ GST_LOG ("%*s pref. volume: %g\n", depth, "",
+ QTDEMUX_FP16_GET (buffer + 32));
+ GST_LOG ("%*s preview time: %u\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 80));
+ GST_LOG ("%*s preview dur.: %u\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 84));
+ GST_LOG ("%*s poster time: %u\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 88));
+ GST_LOG ("%*s select time: %u\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 92));
+ GST_LOG ("%*s select dur.: %u\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 96));
+ GST_LOG ("%*s current time: %u\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 100));
+ GST_LOG ("%*s next track ID: %d\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 104));
}
-static void qtdemux_dump_tkhd(GstQTDemux *qtdemux, void *buffer, int depth)
+static void
+qtdemux_dump_tkhd (GstQTDemux * qtdemux, void *buffer, int depth)
{
- GST_LOG("%*s version/flags: %08x\n", depth, "", QTDEMUX_GUINT32_GET(buffer+8));
- GST_LOG("%*s creation time: %u\n", depth, "", QTDEMUX_GUINT32_GET(buffer+12));
- GST_LOG("%*s modify time: %u\n", depth, "", QTDEMUX_GUINT32_GET(buffer+16));
- GST_LOG("%*s track ID: %u\n", depth, "", QTDEMUX_GUINT32_GET(buffer+20));
- GST_LOG("%*s duration: %u\n", depth, "", QTDEMUX_GUINT32_GET(buffer+28));
- GST_LOG("%*s layer: %u\n", depth, "", QTDEMUX_GUINT16_GET(buffer+36));
- GST_LOG("%*s alt group: %u\n", depth, "", QTDEMUX_GUINT16_GET(buffer+38));
- GST_LOG("%*s volume: %g\n", depth, "", QTDEMUX_FP16_GET(buffer+44));
- GST_LOG("%*s track width: %g\n", depth, "", QTDEMUX_FP32_GET(buffer+84));
- GST_LOG("%*s track height: %g\n", depth, "", QTDEMUX_FP32_GET(buffer+88));
+ GST_LOG ("%*s version/flags: %08x\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 8));
+ GST_LOG ("%*s creation time: %u\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 12));
+ GST_LOG ("%*s modify time: %u\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 16));
+ GST_LOG ("%*s track ID: %u\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 20));
+ GST_LOG ("%*s duration: %u\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 28));
+ GST_LOG ("%*s layer: %u\n", depth, "",
+ QTDEMUX_GUINT16_GET (buffer + 36));
+ GST_LOG ("%*s alt group: %u\n", depth, "",
+ QTDEMUX_GUINT16_GET (buffer + 38));
+ GST_LOG ("%*s volume: %g\n", depth, "",
+ QTDEMUX_FP16_GET (buffer + 44));
+ GST_LOG ("%*s track width: %g\n", depth, "",
+ QTDEMUX_FP32_GET (buffer + 84));
+ GST_LOG ("%*s track height: %g\n", depth, "",
+ QTDEMUX_FP32_GET (buffer + 88));
}
-static void qtdemux_dump_elst(GstQTDemux *qtdemux, void *buffer, int depth)
+static void
+qtdemux_dump_elst (GstQTDemux * qtdemux, void *buffer, int depth)
{
int i;
int n;
- GST_LOG("%*s version/flags: %08x\n", depth, "", QTDEMUX_GUINT32_GET(buffer+8));
- GST_LOG("%*s n entries: %u\n", depth, "", QTDEMUX_GUINT32_GET(buffer+12));
- n = QTDEMUX_GUINT32_GET(buffer+12);
- for(i=0;i<n;i++){
- GST_LOG("%*s track dur: %u\n", depth, "", QTDEMUX_GUINT32_GET(buffer+16+i*12));
- GST_LOG("%*s media time: %u\n", depth, "", QTDEMUX_GUINT32_GET(buffer+20+i*12));
- GST_LOG("%*s media rate: %g\n", depth, "", QTDEMUX_FP32_GET(buffer+24+i*12));
+ GST_LOG ("%*s version/flags: %08x\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 8));
+ GST_LOG ("%*s n entries: %u\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 12));
+ n = QTDEMUX_GUINT32_GET (buffer + 12);
+ for (i = 0; i < n; i++) {
+ GST_LOG ("%*s track dur: %u\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 16 + i * 12));
+ GST_LOG ("%*s media time: %u\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 20 + i * 12));
+ GST_LOG ("%*s media rate: %g\n", depth, "",
+ QTDEMUX_FP32_GET (buffer + 24 + i * 12));
}
}
-static void qtdemux_dump_mdhd(GstQTDemux *qtdemux, void *buffer, int depth)
+static void
+qtdemux_dump_mdhd (GstQTDemux * qtdemux, void *buffer, int depth)
{
- GST_LOG("%*s version/flags: %08x\n", depth, "", QTDEMUX_GUINT32_GET(buffer+8));
- GST_LOG("%*s creation time: %u\n", depth, "", QTDEMUX_GUINT32_GET(buffer+12));
- GST_LOG("%*s modify time: %u\n", depth, "", QTDEMUX_GUINT32_GET(buffer+16));
- GST_LOG("%*s time scale: 1/%u sec\n", depth, "", QTDEMUX_GUINT32_GET(buffer+20));
- GST_LOG("%*s duration: %u\n", depth, "", QTDEMUX_GUINT32_GET(buffer+24));
- GST_LOG("%*s language: %u\n", depth, "", QTDEMUX_GUINT16_GET(buffer+28));
- GST_LOG("%*s quality: %u\n", depth, "", QTDEMUX_GUINT16_GET(buffer+30));
+ GST_LOG ("%*s version/flags: %08x\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 8));
+ GST_LOG ("%*s creation time: %u\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 12));
+ GST_LOG ("%*s modify time: %u\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 16));
+ GST_LOG ("%*s time scale: 1/%u sec\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 20));
+ GST_LOG ("%*s duration: %u\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 24));
+ GST_LOG ("%*s language: %u\n", depth, "",
+ QTDEMUX_GUINT16_GET (buffer + 28));
+ GST_LOG ("%*s quality: %u\n", depth, "",
+ QTDEMUX_GUINT16_GET (buffer + 30));
}
-static void qtdemux_dump_hdlr(GstQTDemux *qtdemux, void *buffer, int depth)
+static void
+qtdemux_dump_hdlr (GstQTDemux * qtdemux, void *buffer, int depth)
{
- GST_LOG("%*s version/flags: %08x\n", depth, "", QTDEMUX_GUINT32_GET(buffer+8));
- GST_LOG("%*s type: " GST_FOURCC_FORMAT "\n", depth, "",
- GST_FOURCC_ARGS(QTDEMUX_FOURCC_GET(buffer+12)));
- GST_LOG("%*s subtype: " GST_FOURCC_FORMAT "\n", depth, "",
- GST_FOURCC_ARGS(QTDEMUX_FOURCC_GET(buffer+16)));
- GST_LOG("%*s manufacturer: " GST_FOURCC_FORMAT "\n", depth, "",
- GST_FOURCC_ARGS(QTDEMUX_FOURCC_GET(buffer+20)));
- GST_LOG("%*s flags: %08x\n", depth, "", QTDEMUX_GUINT32_GET(buffer+24));
- GST_LOG("%*s flags mask: %08x\n", depth, "", QTDEMUX_GUINT32_GET(buffer+28));
- GST_LOG("%*s name: %*s\n", depth, "",
- QTDEMUX_GUINT8_GET(buffer+32), (char *)(buffer+33));
+ GST_LOG ("%*s version/flags: %08x\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 8));
+ GST_LOG ("%*s type: " GST_FOURCC_FORMAT "\n", depth, "",
+ GST_FOURCC_ARGS (QTDEMUX_FOURCC_GET (buffer + 12)));
+ GST_LOG ("%*s subtype: " GST_FOURCC_FORMAT "\n", depth, "",
+ GST_FOURCC_ARGS (QTDEMUX_FOURCC_GET (buffer + 16)));
+ GST_LOG ("%*s manufacturer: " GST_FOURCC_FORMAT "\n", depth, "",
+ GST_FOURCC_ARGS (QTDEMUX_FOURCC_GET (buffer + 20)));
+ GST_LOG ("%*s flags: %08x\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 24));
+ GST_LOG ("%*s flags mask: %08x\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 28));
+ GST_LOG ("%*s name: %*s\n", depth, "",
+ QTDEMUX_GUINT8_GET (buffer + 32), (char *) (buffer + 33));
}
-static void qtdemux_dump_vmhd(GstQTDemux *qtdemux, void *buffer, int depth)
+static void
+qtdemux_dump_vmhd (GstQTDemux * qtdemux, void *buffer, int depth)
{
- GST_LOG("%*s version/flags: %08x\n", depth, "", QTDEMUX_GUINT32_GET(buffer+8));
- GST_LOG("%*s mode/color: %08x\n", depth, "", QTDEMUX_GUINT32_GET(buffer+16));
+ GST_LOG ("%*s version/flags: %08x\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 8));
+ GST_LOG ("%*s mode/color: %08x\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 16));
}
-static void qtdemux_dump_dref(GstQTDemux *qtdemux, void *buffer, int depth)
+static void
+qtdemux_dump_dref (GstQTDemux * qtdemux, void *buffer, int depth)
{
int n;
int i;
int offset;
- GST_LOG("%*s version/flags: %08x\n", depth, "", QTDEMUX_GUINT32_GET(buffer+8));
- GST_LOG("%*s n entries: %u\n", depth, "", QTDEMUX_GUINT32_GET(buffer+12));
- n = QTDEMUX_GUINT32_GET(buffer+12);
+ GST_LOG ("%*s version/flags: %08x\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 8));
+ GST_LOG ("%*s n entries: %u\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 12));
+ n = QTDEMUX_GUINT32_GET (buffer + 12);
offset = 16;
- for(i=0;i<n;i++){
- GST_LOG("%*s size: %u\n", depth, "", QTDEMUX_GUINT32_GET(buffer+offset));
- GST_LOG("%*s type: " GST_FOURCC_FORMAT "\n", depth, "",
- GST_FOURCC_ARGS(QTDEMUX_FOURCC_GET(buffer+offset+4)));
- offset += QTDEMUX_GUINT32_GET(buffer+offset);
+ for (i = 0; i < n; i++) {
+ GST_LOG ("%*s size: %u\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + offset));
+ GST_LOG ("%*s type: " GST_FOURCC_FORMAT "\n", depth, "",
+ GST_FOURCC_ARGS (QTDEMUX_FOURCC_GET (buffer + offset + 4)));
+ offset += QTDEMUX_GUINT32_GET (buffer + offset);
}
}
-static void qtdemux_dump_stsd(GstQTDemux *qtdemux, void *buffer, int depth)
+static void
+qtdemux_dump_stsd (GstQTDemux * qtdemux, void *buffer, int depth)
{
int i;
int n;
int offset;
- GST_LOG("%*s version/flags: %08x\n", depth, "", QTDEMUX_GUINT32_GET(buffer+8));
- GST_LOG("%*s n entries: %d\n", depth, "", QTDEMUX_GUINT32_GET(buffer+12));
- n = QTDEMUX_GUINT32_GET(buffer+12);
+ GST_LOG ("%*s version/flags: %08x\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 8));
+ GST_LOG ("%*s n entries: %d\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 12));
+ n = QTDEMUX_GUINT32_GET (buffer + 12);
offset = 16;
- for(i=0;i<n;i++){
- GST_LOG("%*s size: %u\n", depth, "", QTDEMUX_GUINT32_GET(buffer+offset));
- GST_LOG("%*s type: " GST_FOURCC_FORMAT "\n", depth, "",
- GST_FOURCC_ARGS(QTDEMUX_FOURCC_GET(buffer+offset+4)));
- GST_LOG("%*s data reference:%d\n", depth, "", QTDEMUX_GUINT16_GET(buffer+offset+14));
-
- GST_LOG("%*s version/rev.: %08x\n", depth, "", QTDEMUX_GUINT32_GET(buffer+offset+16));
- GST_LOG("%*s vendor: " GST_FOURCC_FORMAT "\n", depth, "",
- GST_FOURCC_ARGS(QTDEMUX_FOURCC_GET(buffer+offset+20)));
- GST_LOG("%*s temporal qual: %u\n", depth, "", QTDEMUX_GUINT32_GET(buffer+offset+24));
- GST_LOG("%*s spatial qual: %u\n", depth, "", QTDEMUX_GUINT32_GET(buffer+offset+28));
- GST_LOG("%*s width: %u\n", depth, "", QTDEMUX_GUINT16_GET(buffer+offset+32));
- GST_LOG("%*s height: %u\n", depth, "", QTDEMUX_GUINT16_GET(buffer+offset+34));
- GST_LOG("%*s horiz. resol: %g\n", depth, "", QTDEMUX_FP32_GET(buffer+offset+36));
- GST_LOG("%*s vert. resol.: %g\n", depth, "", QTDEMUX_FP32_GET(buffer+offset+40));
- GST_LOG("%*s data size: %u\n", depth, "", QTDEMUX_GUINT32_GET(buffer+offset+44));
- GST_LOG("%*s frame count: %u\n", depth, "", QTDEMUX_GUINT16_GET(buffer+offset+48));
- GST_LOG("%*s compressor: %*s\n", depth, "",
- QTDEMUX_GUINT8_GET(buffer+offset+49), (char *)(buffer+offset+51));
- GST_LOG("%*s depth: %u\n", depth, "", QTDEMUX_GUINT16_GET(buffer+offset+82));
- GST_LOG("%*s color table ID:%u\n", depth, "", QTDEMUX_GUINT16_GET(buffer+offset+84));
-
- offset += QTDEMUX_GUINT32_GET(buffer+offset);
+ for (i = 0; i < n; i++) {
+ GST_LOG ("%*s size: %u\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + offset));
+ GST_LOG ("%*s type: " GST_FOURCC_FORMAT "\n", depth, "",
+ GST_FOURCC_ARGS (QTDEMUX_FOURCC_GET (buffer + offset + 4)));
+ GST_LOG ("%*s data reference:%d\n", depth, "",
+ QTDEMUX_GUINT16_GET (buffer + offset + 14));
+
+ GST_LOG ("%*s version/rev.: %08x\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + offset + 16));
+ GST_LOG ("%*s vendor: " GST_FOURCC_FORMAT "\n", depth, "",
+ GST_FOURCC_ARGS (QTDEMUX_FOURCC_GET (buffer + offset + 20)));
+ GST_LOG ("%*s temporal qual: %u\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + offset + 24));
+ GST_LOG ("%*s spatial qual: %u\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + offset + 28));
+ GST_LOG ("%*s width: %u\n", depth, "",
+ QTDEMUX_GUINT16_GET (buffer + offset + 32));
+ GST_LOG ("%*s height: %u\n", depth, "",
+ QTDEMUX_GUINT16_GET (buffer + offset + 34));
+ GST_LOG ("%*s horiz. resol: %g\n", depth, "",
+ QTDEMUX_FP32_GET (buffer + offset + 36));
+ GST_LOG ("%*s vert. resol.: %g\n", depth, "",
+ QTDEMUX_FP32_GET (buffer + offset + 40));
+ GST_LOG ("%*s data size: %u\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + offset + 44));
+ GST_LOG ("%*s frame count: %u\n", depth, "",
+ QTDEMUX_GUINT16_GET (buffer + offset + 48));
+ GST_LOG ("%*s compressor: %*s\n", depth, "",
+ QTDEMUX_GUINT8_GET (buffer + offset + 49),
+ (char *) (buffer + offset + 51));
+ GST_LOG ("%*s depth: %u\n", depth, "",
+ QTDEMUX_GUINT16_GET (buffer + offset + 82));
+ GST_LOG ("%*s color table ID:%u\n", depth, "",
+ QTDEMUX_GUINT16_GET (buffer + offset + 84));
+
+ offset += QTDEMUX_GUINT32_GET (buffer + offset);
}
}
-static void qtdemux_dump_stts(GstQTDemux *qtdemux, void *buffer, int depth)
+static void
+qtdemux_dump_stts (GstQTDemux * qtdemux, void *buffer, int depth)
{
int i;
int n;
int offset;
- GST_LOG("%*s version/flags: %08x\n", depth, "", QTDEMUX_GUINT32_GET(buffer+8));
- GST_LOG("%*s n entries: %d\n", depth, "", QTDEMUX_GUINT32_GET(buffer+12));
- n = QTDEMUX_GUINT32_GET(buffer+12);
+ GST_LOG ("%*s version/flags: %08x\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 8));
+ GST_LOG ("%*s n entries: %d\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 12));
+ n = QTDEMUX_GUINT32_GET (buffer + 12);
offset = 16;
- for(i=0;i<n;i++){
- GST_LOG("%*s count: %u\n", depth, "", QTDEMUX_GUINT32_GET(buffer+offset));
- GST_LOG("%*s duration: %u\n", depth, "", QTDEMUX_GUINT32_GET(buffer+offset + 4));
+ for (i = 0; i < n; i++) {
+ GST_LOG ("%*s count: %u\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + offset));
+ GST_LOG ("%*s duration: %u\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + offset + 4));
offset += 8;
}
}
-static void qtdemux_dump_stss(GstQTDemux *qtdemux, void *buffer, int depth)
+static void
+qtdemux_dump_stss (GstQTDemux * qtdemux, void *buffer, int depth)
{
int i;
int n;
int offset;
- GST_LOG("%*s version/flags: %08x\n", depth, "", QTDEMUX_GUINT32_GET(buffer+8));
- GST_LOG("%*s n entries: %d\n", depth, "", QTDEMUX_GUINT32_GET(buffer+12));
- n = QTDEMUX_GUINT32_GET(buffer+12);
+ GST_LOG ("%*s version/flags: %08x\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 8));
+ GST_LOG ("%*s n entries: %d\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 12));
+ n = QTDEMUX_GUINT32_GET (buffer + 12);
offset = 16;
- for(i=0;i<n;i++){
- GST_LOG("%*s sample: %u\n", depth, "", QTDEMUX_GUINT32_GET(buffer+offset));
+ for (i = 0; i < n; i++) {
+ GST_LOG ("%*s sample: %u\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + offset));
offset += 4;
}
}
-static void qtdemux_dump_stsc(GstQTDemux *qtdemux, void *buffer, int depth)
+static void
+qtdemux_dump_stsc (GstQTDemux * qtdemux, void *buffer, int depth)
{
int i;
int n;
int offset;
- GST_LOG("%*s version/flags: %08x\n", depth, "", QTDEMUX_GUINT32_GET(buffer+8));
- GST_LOG("%*s n entries: %d\n", depth, "", QTDEMUX_GUINT32_GET(buffer+12));
- n = QTDEMUX_GUINT32_GET(buffer+12);
+ GST_LOG ("%*s version/flags: %08x\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 8));
+ GST_LOG ("%*s n entries: %d\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 12));
+ n = QTDEMUX_GUINT32_GET (buffer + 12);
offset = 16;
- for(i=0;i<n;i++){
- GST_LOG("%*s first chunk: %u\n", depth, "", QTDEMUX_GUINT32_GET(buffer+offset));
- GST_LOG("%*s sample per ch: %u\n", depth, "", QTDEMUX_GUINT32_GET(buffer+offset+4));
- GST_LOG("%*s sample desc id:%08x\n", depth, "", QTDEMUX_GUINT32_GET(buffer+offset+8));
+ for (i = 0; i < n; i++) {
+ GST_LOG ("%*s first chunk: %u\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + offset));
+ GST_LOG ("%*s sample per ch: %u\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + offset + 4));
+ GST_LOG ("%*s sample desc id:%08x\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + offset + 8));
offset += 12;
}
}
-static void qtdemux_dump_stsz(GstQTDemux *qtdemux, void *buffer, int depth)
+static void
+qtdemux_dump_stsz (GstQTDemux * qtdemux, void *buffer, int depth)
{
int i;
int n;
int offset;
int sample_size;
- GST_LOG("%*s version/flags: %08x\n", depth, "", QTDEMUX_GUINT32_GET(buffer+8));
- GST_LOG("%*s sample size: %d\n", depth, "", QTDEMUX_GUINT32_GET(buffer+12));
- sample_size = QTDEMUX_GUINT32_GET(buffer+12);
- if(sample_size == 0){
- GST_LOG("%*s n entries: %d\n", depth, "", QTDEMUX_GUINT32_GET(buffer+16));
- n = QTDEMUX_GUINT32_GET(buffer+16);
+ GST_LOG ("%*s version/flags: %08x\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 8));
+ GST_LOG ("%*s sample size: %d\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 12));
+ sample_size = QTDEMUX_GUINT32_GET (buffer + 12);
+ if (sample_size == 0) {
+ GST_LOG ("%*s n entries: %d\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 16));
+ n = QTDEMUX_GUINT32_GET (buffer + 16);
offset = 20;
- for(i=0;i<n;i++){
- GST_LOG("%*s sample size: %u\n", depth, "", QTDEMUX_GUINT32_GET(buffer+offset));
+ for (i = 0; i < n; i++) {
+ GST_LOG ("%*s sample size: %u\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + offset));
offset += 4;
}
}
}
-static void qtdemux_dump_stco(GstQTDemux *qtdemux, void *buffer, int depth)
+static void
+qtdemux_dump_stco (GstQTDemux * qtdemux, void *buffer, int depth)
{
int i;
int n;
int offset;
- GST_LOG("%*s version/flags: %08x\n", depth, "", QTDEMUX_GUINT32_GET(buffer+8));
- GST_LOG("%*s n entries: %d\n", depth, "", QTDEMUX_GUINT32_GET(buffer+12));
- n = QTDEMUX_GUINT32_GET(buffer+12);
+ GST_LOG ("%*s version/flags: %08x\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 8));
+ GST_LOG ("%*s n entries: %d\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 12));
+ n = QTDEMUX_GUINT32_GET (buffer + 12);
offset = 16;
- for(i=0;i<n;i++){
- GST_LOG("%*s chunk offset: %u\n", depth, "", QTDEMUX_GUINT32_GET(buffer+offset));
+ for (i = 0; i < n; i++) {
+ GST_LOG ("%*s chunk offset: %u\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + offset));
offset += 4;
}
}
-static void qtdemux_dump_co64(GstQTDemux *qtdemux, void *buffer, int depth)
+static void
+qtdemux_dump_co64 (GstQTDemux * qtdemux, void *buffer, int depth)
{
int i;
int n;
int offset;
- GST_LOG("%*s version/flags: %08x\n", depth, "", QTDEMUX_GUINT32_GET(buffer+8));
- GST_LOG("%*s n entries: %d\n", depth, "", QTDEMUX_GUINT32_GET(buffer+12));
- n = QTDEMUX_GUINT32_GET(buffer+12);
+ GST_LOG ("%*s version/flags: %08x\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 8));
+ GST_LOG ("%*s n entries: %d\n", depth, "",
+ QTDEMUX_GUINT32_GET (buffer + 12));
+ n = QTDEMUX_GUINT32_GET (buffer + 12);
offset = 16;
- for(i=0;i<n;i++){
- GST_LOG("%*s chunk offset: %" G_GUINT64_FORMAT "\n", depth, "", QTDEMUX_GUINT64_GET(buffer+offset));
+ for (i = 0; i < n; i++) {
+ GST_LOG ("%*s chunk offset: %" G_GUINT64_FORMAT "\n", depth, "",
+ QTDEMUX_GUINT64_GET (buffer + offset));
offset += 8;
}
}
-static void qtdemux_dump_dcom(GstQTDemux *qtdemux, void *buffer, int depth)
+static void
+qtdemux_dump_dcom (GstQTDemux * qtdemux, void *buffer, int depth)
{
- GST_LOG("%*s compression type: " GST_FOURCC_FORMAT "\n", depth, "",
- GST_FOURCC_ARGS(QTDEMUX_FOURCC_GET(buffer+8)));
+ GST_LOG ("%*s compression type: " GST_FOURCC_FORMAT "\n", depth, "",
+ GST_FOURCC_ARGS (QTDEMUX_FOURCC_GET (buffer + 8)));
}
-static void qtdemux_dump_cmvd(GstQTDemux *qtdemux, void *buffer, int depth)
+static void
+qtdemux_dump_cmvd (GstQTDemux * qtdemux, void *buffer, int depth)
{
- GST_LOG("%*s length: %d\n", depth, "", QTDEMUX_GUINT32_GET(buffer+8));
+ GST_LOG ("%*s length: %d\n", depth, "", QTDEMUX_GUINT32_GET (buffer + 8));
}
-static GNode *qtdemux_tree_get_child_by_type(GNode *node, guint32 fourcc)
+static GNode *
+qtdemux_tree_get_child_by_type (GNode * node, guint32 fourcc)
{
GNode *child;
void *buffer;
guint32 child_fourcc;
- for(child = g_node_first_child(node); child; child = g_node_next_sibling(child)){
+ for (child = g_node_first_child (node); child;
+ child = g_node_next_sibling (child)) {
buffer = child->data;
- child_fourcc = GUINT32_FROM_LE(*(guint32 *)(buffer+4));
+ child_fourcc = GUINT32_FROM_LE (*(guint32 *) (buffer + 4));
- if(child_fourcc == fourcc){
+ if (child_fourcc == fourcc) {
return child;
}
}
return NULL;
}
-static GNode *qtdemux_tree_get_sibling_by_type(GNode *node, guint32 fourcc)
+static GNode *
+qtdemux_tree_get_sibling_by_type (GNode * node, guint32 fourcc)
{
GNode *child;
void *buffer;
guint32 child_fourcc;
- for(child = g_node_next_sibling(node); child; child = g_node_next_sibling(child)){
+ for (child = g_node_next_sibling (node); child;
+ child = g_node_next_sibling (child)) {
buffer = child->data;
- child_fourcc = GUINT32_FROM_LE(*(guint32 *)(buffer+4));
+ child_fourcc = GUINT32_FROM_LE (*(guint32 *) (buffer + 4));
- if(child_fourcc == fourcc){
+ if (child_fourcc == fourcc) {
return child;
}
}
return NULL;
}
-static void qtdemux_parse_trak(GstQTDemux *qtdemux, GNode *trak);
+static void qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak);
-static void qtdemux_parse_tree(GstQTDemux *qtdemux)
+static void
+qtdemux_parse_tree (GstQTDemux * qtdemux)
{
GNode *mvhd;
GNode *trak;
- mvhd = qtdemux_tree_get_child_by_type(qtdemux->moov_node, FOURCC_mvhd);
- if(mvhd==NULL){
- GST_LOG("No mvhd node found.\n");
+ mvhd = qtdemux_tree_get_child_by_type (qtdemux->moov_node, FOURCC_mvhd);
+ if (mvhd == NULL) {
+ GST_LOG ("No mvhd node found.\n");
return;
}
- qtdemux->timescale = QTDEMUX_GUINT32_GET(mvhd->data + 20);
- qtdemux->duration = QTDEMUX_GUINT32_GET(mvhd->data + 24);
+ qtdemux->timescale = QTDEMUX_GUINT32_GET (mvhd->data + 20);
+ qtdemux->duration = QTDEMUX_GUINT32_GET (mvhd->data + 24);
- GST_INFO("timescale: %d\n", qtdemux->timescale);
- GST_INFO("duration: %d\n", qtdemux->duration);
+ GST_INFO ("timescale: %d\n", qtdemux->timescale);
+ GST_INFO ("duration: %d\n", qtdemux->duration);
- trak = qtdemux_tree_get_child_by_type(qtdemux->moov_node, FOURCC_trak);
- qtdemux_parse_trak(qtdemux, trak);
+ trak = qtdemux_tree_get_child_by_type (qtdemux->moov_node, FOURCC_trak);
+ qtdemux_parse_trak (qtdemux, trak);
/* trak = qtdemux_tree_get_sibling_by_type(trak, FOURCC_trak);
if(trak)qtdemux_parse_trak(qtdemux, trak);*/
- while ((trak = qtdemux_tree_get_sibling_by_type(trak, FOURCC_trak)) != NULL)
- qtdemux_parse_trak(qtdemux, trak);
+ while ((trak = qtdemux_tree_get_sibling_by_type (trak, FOURCC_trak)) != NULL)
+ qtdemux_parse_trak (qtdemux, trak);
}
-static void qtdemux_parse_trak(GstQTDemux *qtdemux, GNode *trak)
+static void
+qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
{
int offset;
GNode *tkhd;
QtDemuxSample *samples;
int n_samples_per_chunk;
int index;
- int i,j,k;
+ int i, j, k;
QtDemuxStream *stream;
int n_sample_times;
guint64 timestamp;
int sample_size;
int sample_index;
- stream = g_new0(QtDemuxStream,1);
+ stream = g_new0 (QtDemuxStream, 1);
- tkhd = qtdemux_tree_get_child_by_type(trak, FOURCC_tkhd);
- g_assert(tkhd);
+ tkhd = qtdemux_tree_get_child_by_type (trak, FOURCC_tkhd);
+ g_assert (tkhd);
/* track duration? */
- mdia = qtdemux_tree_get_child_by_type(trak, FOURCC_mdia);
- g_assert(mdia);
+ mdia = qtdemux_tree_get_child_by_type (trak, FOURCC_mdia);
+ g_assert (mdia);
- mdhd = qtdemux_tree_get_child_by_type(mdia, FOURCC_mdhd);
- g_assert(mdhd);
+ mdhd = qtdemux_tree_get_child_by_type (mdia, FOURCC_mdhd);
+ g_assert (mdhd);
- stream->timescale = QTDEMUX_GUINT32_GET(mdhd->data+20);
- GST_INFO("track timescale: %d", stream->timescale);
-
- hdlr = qtdemux_tree_get_child_by_type(mdia, FOURCC_hdlr);
- g_assert(hdlr);
-
- GST_LOG("track type: " GST_FOURCC_FORMAT "\n",
- GST_FOURCC_ARGS(QTDEMUX_FOURCC_GET(hdlr->data+12)));
- GST_LOG("track subtype: " GST_FOURCC_FORMAT "\n",
- GST_FOURCC_ARGS(QTDEMUX_FOURCC_GET(hdlr->data+16)));
+ stream->timescale = QTDEMUX_GUINT32_GET (mdhd->data + 20);
+ GST_INFO ("track timescale: %d", stream->timescale);
+
+ hdlr = qtdemux_tree_get_child_by_type (mdia, FOURCC_hdlr);
+ g_assert (hdlr);
- stream->subtype = QTDEMUX_FOURCC_GET(hdlr->data+16);
+ GST_LOG ("track type: " GST_FOURCC_FORMAT "\n",
+ GST_FOURCC_ARGS (QTDEMUX_FOURCC_GET (hdlr->data + 12)));
+ GST_LOG ("track subtype: " GST_FOURCC_FORMAT "\n",
+ GST_FOURCC_ARGS (QTDEMUX_FOURCC_GET (hdlr->data + 16)));
- minf = qtdemux_tree_get_child_by_type(mdia, FOURCC_minf);
- g_assert(minf);
+ stream->subtype = QTDEMUX_FOURCC_GET (hdlr->data + 16);
- stbl = qtdemux_tree_get_child_by_type(minf, FOURCC_stbl);
- g_assert(stbl);
+ minf = qtdemux_tree_get_child_by_type (mdia, FOURCC_minf);
+ g_assert (minf);
- stsd = qtdemux_tree_get_child_by_type(stbl, FOURCC_stsd);
- g_assert(stsd);
+ stbl = qtdemux_tree_get_child_by_type (minf, FOURCC_stbl);
+ g_assert (stbl);
- if(stream->subtype == FOURCC_vide){
+ stsd = qtdemux_tree_get_child_by_type (stbl, FOURCC_stsd);
+ g_assert (stsd);
+
+ if (stream->subtype == FOURCC_vide) {
offset = 16;
- GST_LOG("st type: " GST_FOURCC_FORMAT "\n",
- GST_FOURCC_ARGS(QTDEMUX_FOURCC_GET(stsd->data+offset+4)));
-
- stream->width = QTDEMUX_GUINT16_GET(stsd->data+offset+32);
- stream->height = QTDEMUX_GUINT16_GET(stsd->data+offset+34);
- stream->fps = 0.; /* this is filled in later */
-
- GST_LOG("frame count: %u\n", QTDEMUX_GUINT16_GET(stsd->data+offset+48));
-
- stream->caps = qtdemux_video_caps(qtdemux,
- QTDEMUX_FOURCC_GET(stsd->data+offset+4), stsd->data);
- GST_INFO("type " GST_FOURCC_FORMAT " caps %" GST_PTR_FORMAT "\n",
- GST_FOURCC_ARGS (QTDEMUX_FOURCC_GET(stsd->data+offset+4)),
- stream->caps);
- }else if(stream->subtype == FOURCC_soun){
+ GST_LOG ("st type: " GST_FOURCC_FORMAT "\n",
+ GST_FOURCC_ARGS (QTDEMUX_FOURCC_GET (stsd->data + offset + 4)));
+
+ stream->width = QTDEMUX_GUINT16_GET (stsd->data + offset + 32);
+ stream->height = QTDEMUX_GUINT16_GET (stsd->data + offset + 34);
+ stream->fps = 0.; /* this is filled in later */
+
+ GST_LOG ("frame count: %u\n",
+ QTDEMUX_GUINT16_GET (stsd->data + offset + 48));
+
+ stream->caps = qtdemux_video_caps (qtdemux,
+ QTDEMUX_FOURCC_GET (stsd->data + offset + 4), stsd->data);
+ GST_INFO ("type " GST_FOURCC_FORMAT " caps %" GST_PTR_FORMAT "\n",
+ GST_FOURCC_ARGS (QTDEMUX_FOURCC_GET (stsd->data + offset + 4)),
+ stream->caps);
+ } else if (stream->subtype == FOURCC_soun) {
int version, samplesize;
- GST_LOG("st type: " GST_FOURCC_FORMAT "\n",
- GST_FOURCC_ARGS(QTDEMUX_FOURCC_GET(stsd->data+16+4)));
+ GST_LOG ("st type: " GST_FOURCC_FORMAT "\n",
+ GST_FOURCC_ARGS (QTDEMUX_FOURCC_GET (stsd->data + 16 + 4)));
offset = 32;
- GST_LOG("version/rev: %08x\n", QTDEMUX_GUINT32_GET(stsd->data+offset));
- version = QTDEMUX_GUINT32_GET(stsd->data+offset);
- GST_LOG("vendor: %08x\n", QTDEMUX_GUINT32_GET(stsd->data+offset + 4));
- GST_LOG("n_channels: %d\n", QTDEMUX_GUINT16_GET(stsd->data+offset + 8));
- stream->n_channels = QTDEMUX_GUINT16_GET(stsd->data+offset + 8);
- GST_LOG("sample_size: %d\n", QTDEMUX_GUINT16_GET(stsd->data+offset + 10));
- samplesize = QTDEMUX_GUINT16_GET(stsd->data+offset + 10);
- GST_LOG("compression_id: %d\n", QTDEMUX_GUINT16_GET(stsd->data+offset + 12));
- GST_LOG("packet size: %d\n", QTDEMUX_GUINT16_GET(stsd->data+offset + 14));
- GST_LOG("sample rate: %g\n", QTDEMUX_FP32_GET(stsd->data+offset + 16));
- stream->rate = QTDEMUX_FP32_GET(stsd->data+offset + 16);
+ GST_LOG ("version/rev: %08x\n",
+ QTDEMUX_GUINT32_GET (stsd->data + offset));
+ version = QTDEMUX_GUINT32_GET (stsd->data + offset);
+ GST_LOG ("vendor: %08x\n",
+ QTDEMUX_GUINT32_GET (stsd->data + offset + 4));
+ GST_LOG ("n_channels: %d\n",
+ QTDEMUX_GUINT16_GET (stsd->data + offset + 8));
+ stream->n_channels = QTDEMUX_GUINT16_GET (stsd->data + offset + 8);
+ GST_LOG ("sample_size: %d\n",
+ QTDEMUX_GUINT16_GET (stsd->data + offset + 10));
+ samplesize = QTDEMUX_GUINT16_GET (stsd->data + offset + 10);
+ GST_LOG ("compression_id: %d\n",
+ QTDEMUX_GUINT16_GET (stsd->data + offset + 12));
+ GST_LOG ("packet size: %d\n",
+ QTDEMUX_GUINT16_GET (stsd->data + offset + 14));
+ GST_LOG ("sample rate: %g\n",
+ QTDEMUX_FP32_GET (stsd->data + offset + 16));
+ stream->rate = QTDEMUX_FP32_GET (stsd->data + offset + 16);
offset = 52;
- if(version == 0x00010000){
- GST_LOG("samples/packet: %d\n", QTDEMUX_GUINT32_GET(stsd->data+offset));
- stream->samples_per_packet = QTDEMUX_GUINT32_GET(stsd->data+offset);
- GST_LOG("bytes/packet: %d\n", QTDEMUX_GUINT32_GET(stsd->data+offset + 4));
- GST_LOG("bytes/frame: %d\n", QTDEMUX_GUINT32_GET(stsd->data+offset + 8));
- stream->bytes_per_frame = QTDEMUX_GUINT32_GET(stsd->data+offset + 8);
- GST_LOG("bytes/sample: %d\n", QTDEMUX_GUINT32_GET(stsd->data+offset + 12));
+ if (version == 0x00010000) {
+ GST_LOG ("samples/packet: %d\n",
+ QTDEMUX_GUINT32_GET (stsd->data + offset));
+ stream->samples_per_packet = QTDEMUX_GUINT32_GET (stsd->data + offset);
+ GST_LOG ("bytes/packet: %d\n",
+ QTDEMUX_GUINT32_GET (stsd->data + offset + 4));
+ GST_LOG ("bytes/frame: %d\n",
+ QTDEMUX_GUINT32_GET (stsd->data + offset + 8));
+ stream->bytes_per_frame = QTDEMUX_GUINT32_GET (stsd->data + offset + 8);
+ GST_LOG ("bytes/sample: %d\n",
+ QTDEMUX_GUINT32_GET (stsd->data + offset + 12));
offset = 68;
} else {
stream->bytes_per_frame = stream->n_channels * samplesize / 8;
stream->samples_per_packet = 1;
}
- stream->caps = qtdemux_audio_caps(qtdemux,
- QTDEMUX_FOURCC_GET(stsd->data+16+4), (QTDEMUX_GUINT32_GET(stsd->data) > offset) ? stsd->data + offset : NULL);
- GST_INFO("type " GST_FOURCC_FORMAT " caps %" GST_PTR_FORMAT "\n",
- GST_FOURCC_ARGS(QTDEMUX_FOURCC_GET(stsd->data+16+4)), stream->caps);
- }else{
- GST_LOG("unknown subtype\n");
+ stream->caps = qtdemux_audio_caps (qtdemux,
+ QTDEMUX_FOURCC_GET (stsd->data + 16 + 4),
+ (QTDEMUX_GUINT32_GET (stsd->data) >
+ offset) ? stsd->data + offset : NULL);
+ GST_INFO ("type " GST_FOURCC_FORMAT " caps %" GST_PTR_FORMAT "\n",
+ GST_FOURCC_ARGS (QTDEMUX_FOURCC_GET (stsd->data + 16 + 4)),
+ stream->caps);
+ } else {
+ GST_LOG ("unknown subtype\n");
return;
}
/* sample to chunk */
- stsc = qtdemux_tree_get_child_by_type(stbl, FOURCC_stsc);
- g_assert(stsc);
+ stsc = qtdemux_tree_get_child_by_type (stbl, FOURCC_stsc);
+ g_assert (stsc);
/* sample size */
- stsz = qtdemux_tree_get_child_by_type(stbl, FOURCC_stsz);
- g_assert(stsz);
+ stsz = qtdemux_tree_get_child_by_type (stbl, FOURCC_stsz);
+ g_assert (stsz);
/* chunk offsets */
- stco = qtdemux_tree_get_child_by_type(stbl, FOURCC_stco);
- co64 = qtdemux_tree_get_child_by_type(stbl, FOURCC_co64);
- g_assert(stco || co64);
+ stco = qtdemux_tree_get_child_by_type (stbl, FOURCC_stco);
+ co64 = qtdemux_tree_get_child_by_type (stbl, FOURCC_co64);
+ g_assert (stco || co64);
/* sample time */
- stts = qtdemux_tree_get_child_by_type(stbl, FOURCC_stts);
- g_assert(stts);
+ stts = qtdemux_tree_get_child_by_type (stbl, FOURCC_stts);
+ g_assert (stts);
- sample_size = QTDEMUX_GUINT32_GET(stsz->data+12);
- if(sample_size == 0){
- n_samples = QTDEMUX_GUINT32_GET(stsz->data+16);
+ sample_size = QTDEMUX_GUINT32_GET (stsz->data + 12);
+ if (sample_size == 0) {
+ n_samples = QTDEMUX_GUINT32_GET (stsz->data + 16);
stream->n_samples = n_samples;
- samples = g_malloc(sizeof(QtDemuxSample)*n_samples);
+ samples = g_malloc (sizeof (QtDemuxSample) * n_samples);
stream->samples = samples;
- for(i=0;i<n_samples;i++){
- samples[i].size = QTDEMUX_GUINT32_GET(stsz->data + i*4 + 20);
+ for (i = 0; i < n_samples; i++) {
+ samples[i].size = QTDEMUX_GUINT32_GET (stsz->data + i * 4 + 20);
}
- n_samples_per_chunk = QTDEMUX_GUINT32_GET(stsc->data+12);
+ n_samples_per_chunk = QTDEMUX_GUINT32_GET (stsc->data + 12);
index = 0;
offset = 16;
- for(i=0;i<n_samples_per_chunk;i++){
+ for (i = 0; i < n_samples_per_chunk; i++) {
int first_chunk, last_chunk;
int samples_per_chunk;
-
- first_chunk = QTDEMUX_GUINT32_GET(stsc->data + 16 + i*12 + 0) - 1;
- if(i==n_samples_per_chunk-1){
- last_chunk = INT_MAX;
- }else{
- last_chunk = QTDEMUX_GUINT32_GET(stsc->data +16 + i*12 + 12) - 1;
+
+ first_chunk = QTDEMUX_GUINT32_GET (stsc->data + 16 + i * 12 + 0) - 1;
+ if (i == n_samples_per_chunk - 1) {
+ last_chunk = INT_MAX;
+ } else {
+ last_chunk = QTDEMUX_GUINT32_GET (stsc->data + 16 + i * 12 + 12) - 1;
}
- samples_per_chunk = QTDEMUX_GUINT32_GET(stsc->data + 16 + i*12 + 4);
-
- for(j=first_chunk;j<last_chunk;j++){
- int chunk_offset;
- if(stco){
- chunk_offset = QTDEMUX_GUINT32_GET(stco->data + 16 + j*4);
- }else{
- chunk_offset = QTDEMUX_GUINT64_GET(co64->data + 16 + j*8);
- }
- for(k=0;k<samples_per_chunk;k++){
+ samples_per_chunk = QTDEMUX_GUINT32_GET (stsc->data + 16 + i * 12 + 4);
+
+ for (j = first_chunk; j < last_chunk; j++) {
+ int chunk_offset;
+
+ if (stco) {
+ chunk_offset = QTDEMUX_GUINT32_GET (stco->data + 16 + j * 4);
+ } else {
+ chunk_offset = QTDEMUX_GUINT64_GET (co64->data + 16 + j * 8);
+ }
+ for (k = 0; k < samples_per_chunk; k++) {
samples[index].chunk = j;
samples[index].offset = chunk_offset;
chunk_offset += samples[index].size;
index++;
- if(index>=n_samples)goto done;
- }
+ if (index >= n_samples)
+ goto done;
+ }
}
}
-done:
-
- n_sample_times = QTDEMUX_GUINT32_GET(stts->data + 12);
+ done:
+
+ n_sample_times = QTDEMUX_GUINT32_GET (stts->data + 12);
timestamp = 0;
index = 0;
- for(i=0;i<n_sample_times;i++){
+ for (i = 0; i < n_sample_times; i++) {
int n;
int duration;
guint64 time;
-
- n = QTDEMUX_GUINT32_GET(stts->data + 16 + 8*i);
- duration = QTDEMUX_GUINT32_GET(stts->data + 16 + 8*i + 4);
- time = (GST_SECOND * duration)/stream->timescale;
- for(j=0;j<n;j++){
- //GST_INFO("moo %lld", timestamp);
- samples[index].timestamp = timestamp;
- samples[index].duration = time;
- timestamp += time;
- index++;
+
+ n = QTDEMUX_GUINT32_GET (stts->data + 16 + 8 * i);
+ duration = QTDEMUX_GUINT32_GET (stts->data + 16 + 8 * i + 4);
+ time = (GST_SECOND * duration) / stream->timescale;
+ for (j = 0; j < n; j++) {
+ //GST_INFO("moo %lld", timestamp);
+ samples[index].timestamp = timestamp;
+ samples[index].duration = time;
+ timestamp += time;
+ index++;
}
}
- }else{
+ } else {
int sample_width;
guint64 timestamp = 0;
- GST_LOG("treating chunks as samples\n");
+ GST_LOG ("treating chunks as samples\n");
/* treat chunks as samples */
- if(stco){
- n_samples = QTDEMUX_GUINT32_GET(stco->data+12);
- }else{
- n_samples = QTDEMUX_GUINT32_GET(co64->data+12);
+ if (stco) {
+ n_samples = QTDEMUX_GUINT32_GET (stco->data + 12);
+ } else {
+ n_samples = QTDEMUX_GUINT32_GET (co64->data + 12);
}
stream->n_samples = n_samples;
- samples = g_malloc(sizeof(QtDemuxSample)*n_samples);
+ samples = g_malloc (sizeof (QtDemuxSample) * n_samples);
stream->samples = samples;
- sample_width = QTDEMUX_GUINT16_GET(stsd->data+offset + 10) / 8;
+ sample_width = QTDEMUX_GUINT16_GET (stsd->data + offset + 10) / 8;
- n_samples_per_chunk = QTDEMUX_GUINT32_GET(stsc->data+12);
+ n_samples_per_chunk = QTDEMUX_GUINT32_GET (stsc->data + 12);
offset = 16;
sample_index = 0;
- for(i=0;i<n_samples_per_chunk;i++){
+ for (i = 0; i < n_samples_per_chunk; i++) {
int first_chunk, last_chunk;
int samples_per_chunk;
-
- first_chunk = QTDEMUX_GUINT32_GET(stsc->data + 16 + i*12 + 0) - 1;
- if(i==n_samples-1){
- last_chunk = INT_MAX;
- }else{
- last_chunk = QTDEMUX_GUINT32_GET(stsc->data +16 + i*12 + 12) - 1;
+
+ first_chunk = QTDEMUX_GUINT32_GET (stsc->data + 16 + i * 12 + 0) - 1;
+ if (i == n_samples - 1) {
+ last_chunk = INT_MAX;
+ } else {
+ last_chunk = QTDEMUX_GUINT32_GET (stsc->data + 16 + i * 12 + 12) - 1;
}
- samples_per_chunk = QTDEMUX_GUINT32_GET(stsc->data + 16 + i*12 + 4);
-
- for(j=first_chunk;j<last_chunk;j++){
- int chunk_offset;
- if(j>=n_samples)goto done2;
- if(stco){
- chunk_offset = QTDEMUX_GUINT32_GET(stco->data + 16 + j*4);
- }else{
- chunk_offset = QTDEMUX_GUINT64_GET(co64->data + 16 + j*8);
- }
+ samples_per_chunk = QTDEMUX_GUINT32_GET (stsc->data + 16 + i * 12 + 4);
+
+ for (j = first_chunk; j < last_chunk; j++) {
+ int chunk_offset;
+
+ if (j >= n_samples)
+ goto done2;
+ if (stco) {
+ chunk_offset = QTDEMUX_GUINT32_GET (stco->data + 16 + j * 4);
+ } else {
+ chunk_offset = QTDEMUX_GUINT64_GET (co64->data + 16 + j * 8);
+ }
samples[j].chunk = j;
samples[j].offset = chunk_offset;
- samples[j].size = samples_per_chunk * stream->bytes_per_frame / stream->samples_per_packet;
- samples[j].duration = samples_per_chunk * GST_SECOND / (stream->rate/2);
+ samples[j].size =
+ samples_per_chunk * stream->bytes_per_frame /
+ stream->samples_per_packet;
+ samples[j].duration =
+ samples_per_chunk * GST_SECOND / (stream->rate / 2);
samples[j].timestamp = timestamp;
timestamp += (samples_per_chunk * GST_SECOND) / stream->rate;
#if 0
- GST_INFO("moo samples_per_chunk=%d rate=%d dur=%lld %lld",
- (int)samples_per_chunk,
- (int)stream->rate,
- (long long)((samples_per_chunk * GST_SECOND) / stream->rate),
- (long long)timestamp);
+ GST_INFO ("moo samples_per_chunk=%d rate=%d dur=%lld %lld",
+ (int) samples_per_chunk,
+ (int) stream->rate,
+ (long long) ((samples_per_chunk * GST_SECOND) / stream->rate),
+ (long long) timestamp);
#endif
samples[j].sample_index = sample_index;
sample_index += samples_per_chunk;
}
done2:
#if 0
- for(i=0;i<n_samples;i++){
- GST_LOG("%d: %d %d %d %d %" G_GUINT64_FORMAT "\n",i,
- samples[i].sample_index,samples[i].chunk,
+ for (i = 0; i < n_samples; i++) {
+ GST_LOG ("%d: %d %d %d %d %" G_GUINT64_FORMAT "\n", i,
+ samples[i].sample_index, samples[i].chunk,
samples[i].offset, samples[i].size, samples[i].timestamp);
- if(i>10)break;
+ if (i > 10)
+ break;
}
#endif
- gst_qtdemux_add_stream(qtdemux,stream);
+ gst_qtdemux_add_stream (qtdemux, stream);
}
-static GstCaps *qtdemux_video_caps(GstQTDemux *qtdemux, guint32 fourcc, const guint8 *stsd_data)
+static GstCaps *
+qtdemux_video_caps (GstQTDemux * qtdemux, guint32 fourcc,
+ const guint8 * stsd_data)
{
- switch(fourcc){
- case GST_MAKE_FOURCC('j','p','e','g'):
+ switch (fourcc) {
+ case GST_MAKE_FOURCC ('j', 'p', 'e', 'g'):
/* JPEG */
return gst_caps_from_string ("image/jpeg");
- case GST_MAKE_FOURCC('m','j','p','a'):
+ case GST_MAKE_FOURCC ('m', 'j', 'p', 'a'):
/* Motion-JPEG (format A) */
return gst_caps_from_string ("image/jpeg");
- case GST_MAKE_FOURCC('m','j','p','b'):
+ case GST_MAKE_FOURCC ('m', 'j', 'p', 'b'):
/* Motion-JPEG (format B) */
return gst_caps_from_string ("image/jpeg");
- case GST_MAKE_FOURCC('S','V','Q','3'):
+ case GST_MAKE_FOURCC ('S', 'V', 'Q', '3'):
if (stsd_data != NULL) {
- gst_getbits_t gb;
+ gst_getbits_t gb;
gint halfpel_flag;
gint thirdpel_flag;
gint unknown_svq3_flag;
gint low_delay;
gint size;
- size = QTDEMUX_GUINT32_GET(stsd_data + 16);
+ size = QTDEMUX_GUINT32_GET (stsd_data + 16);
+
+ gst_getbits_init (&gb, NULL, NULL);
+ gst_getbits_newbuf (&gb, (unsigned char *) stsd_data + 98 + 16 + 4,
+ (size - 102 + 16));
+
+ /* Infos ripped from ffmpeg see libavcodec/svq3.c */
- gst_getbits_init (&gb, NULL, NULL);
- gst_getbits_newbuf (&gb, (unsigned char *)stsd_data + 98 + 16 + 4 , (size - 102 + 16));
-
- /* Infos ripped from ffmpeg see libavcodec/svq3.c */
-
/* 'frame size code' and optional 'width, height' */
- if (gst_getbitsn (&gb, 3) == 7) {
- gst_getbitsn (&gb, 12);
- gst_getbitsn (&gb, 12);
+ if (gst_getbitsn (&gb, 3) == 7) {
+ gst_getbitsn (&gb, 12);
+ gst_getbitsn (&gb, 12);
}
halfpel_flag = gst_get1bit (&gb);
- thirdpel_flag = gst_get1bit (&gb);
+ thirdpel_flag = gst_get1bit (&gb);
- /* unknown fields */
- gst_get1bit (&gb);
- gst_get1bit (&gb);
- gst_get1bit (&gb);
- gst_get1bit (&gb);
+ /* unknown fields */
+ gst_get1bit (&gb);
+ gst_get1bit (&gb);
+ gst_get1bit (&gb);
+ gst_get1bit (&gb);
- low_delay = gst_get1bit (&gb);
+ low_delay = gst_get1bit (&gb);
- /* unknown field */
- gst_get1bit (&gb);
+ /* unknown field */
+ gst_get1bit (&gb);
while (gst_get1bit (&gb)) {
- gst_getbitsn (&gb, 8);
- }
-
- unknown_svq3_flag = gst_get1bit (&gb);
-
- return gst_caps_new_simple ("video/x-svq",
- "svqversion", G_TYPE_INT, 3,
- "halfpel_flag", G_TYPE_INT, halfpel_flag,
- "thirdpel_flag", G_TYPE_INT, thirdpel_flag,
- "low_delay", G_TYPE_INT, low_delay,
- "unknown_svq3_flag", G_TYPE_INT, unknown_svq3_flag,
- NULL);
+ gst_getbitsn (&gb, 8);
+ }
+
+ unknown_svq3_flag = gst_get1bit (&gb);
+
+ return gst_caps_new_simple ("video/x-svq",
+ "svqversion", G_TYPE_INT, 3,
+ "halfpel_flag", G_TYPE_INT, halfpel_flag,
+ "thirdpel_flag", G_TYPE_INT, thirdpel_flag,
+ "low_delay", G_TYPE_INT, low_delay,
+ "unknown_svq3_flag", G_TYPE_INT, unknown_svq3_flag, NULL);
}
- return gst_caps_from_string ("video/x-svq, "
- "svqversion = (int) 3");
- case GST_MAKE_FOURCC('s','v','q','i'):
- case GST_MAKE_FOURCC('S','V','Q','1'):
- return gst_caps_from_string ("video/x-svq, "
- "svqversion = (int) 1");
- case GST_MAKE_FOURCC('r','a','w',' '):
+ return gst_caps_from_string ("video/x-svq, " "svqversion = (int) 3");
+ case GST_MAKE_FOURCC ('s', 'v', 'q', 'i'):
+ case GST_MAKE_FOURCC ('S', 'V', 'Q', '1'):
+ return gst_caps_from_string ("video/x-svq, " "svqversion = (int) 1");
+ case GST_MAKE_FOURCC ('r', 'a', 'w', ' '):
/* uncompressed RGB */
return gst_caps_from_string ("video/x-raw-rgb, "
"endianness = (int) BIG_ENDIAN");
- /*"bpp", GST_PROPS_INT(x),
- "depth", GST_PROPS_INT(x),
- "red_mask", GST_PROPS_INT(x),
- "green_mask", GST_PROPS_INT(x),
- "blue_mask", GST_PROPS_INT(x), FIXME! */
- case GST_MAKE_FOURCC('Y','u','v','2'):
+ /*"bpp", GST_PROPS_INT(x),
+ "depth", GST_PROPS_INT(x),
+ "red_mask", GST_PROPS_INT(x),
+ "green_mask", GST_PROPS_INT(x),
+ "blue_mask", GST_PROPS_INT(x), FIXME! */
+ case GST_MAKE_FOURCC ('Y', 'u', 'v', '2'):
/* uncompressed YUV2 */
return gst_caps_from_string ("video/x-raw-yuv, "
"format = (fourcc) YUY2");
- case GST_MAKE_FOURCC('m','p','e','g'):
+ case GST_MAKE_FOURCC ('m', 'p', 'e', 'g'):
/* MPEG */
return gst_caps_from_string ("video/mpeg, "
- "systemstream = (boolean) false, "
- "mpegversion = (int) 1");
- case GST_MAKE_FOURCC('g','i','f',' '):
+ "systemstream = (boolean) false, " "mpegversion = (int) 1");
+ case GST_MAKE_FOURCC ('g', 'i', 'f', ' '):
return gst_caps_from_string ("image/gif");
- case GST_MAKE_FOURCC('h','2','6','3'):
+ case GST_MAKE_FOURCC ('h', '2', '6', '3'):
/* H.263 */
/* ffmpeg uses the height/width props, don't know why */
return gst_caps_from_string ("video/x-h263");
- case GST_MAKE_FOURCC('m','p','4','v'):
+ case GST_MAKE_FOURCC ('m', 'p', '4', 'v'):
/* MPEG-4 */
return gst_caps_from_string ("video/mpeg, "
- "mpegversion = (int) 4, "
- "systemstream = (boolean) false");
- case GST_MAKE_FOURCC('3','I','V','1'):
+ "mpegversion = (int) 4, " "systemstream = (boolean) false");
+ case GST_MAKE_FOURCC ('3', 'I', 'V', '1'):
return gst_caps_from_string ("video/x-3ivx");
- case GST_MAKE_FOURCC('c','v','i','d'):
+ case GST_MAKE_FOURCC ('c', 'v', 'i', 'd'):
/* Cinepak */
return gst_caps_from_string ("video/x-cinepak");
- case GST_MAKE_FOURCC('r','p','z','a'):
- case GST_MAKE_FOURCC('r','l','e',' '):
+ case GST_MAKE_FOURCC ('r', 'p', 'z', 'a'):
+ case GST_MAKE_FOURCC ('r', 'l', 'e', ' '):
/* Run-length encoding */
- case GST_MAKE_FOURCC('s','m','c',' '):
- case GST_MAKE_FOURCC('k','p','c','d'):
+ case GST_MAKE_FOURCC ('s', 'm', 'c', ' '):
+ case GST_MAKE_FOURCC ('k', 'p', 'c', 'd'):
default:
g_critical ("Don't know how to convert fourcc '" GST_FOURCC_FORMAT
- "' to caps\n", GST_FOURCC_ARGS(fourcc));
+ "' to caps\n", GST_FOURCC_ARGS (fourcc));
return NULL;
}
}
-static GstCaps *qtdemux_audio_caps(GstQTDemux *qtdemux, guint32 fourcc, const guint8 *data)
+static GstCaps *
+qtdemux_audio_caps (GstQTDemux * qtdemux, guint32 fourcc, const guint8 * data)
{
- switch(fourcc){
- case GST_MAKE_FOURCC('N','O','N','E'):
- return NULL; /*gst_caps_from_string ("audio/raw");*/
- case GST_MAKE_FOURCC('r','a','w',' '):
+ switch (fourcc) {
+ case GST_MAKE_FOURCC ('N', 'O', 'N', 'E'):
+ return NULL; /*gst_caps_from_string ("audio/raw"); */
+ case GST_MAKE_FOURCC ('r', 'a', 'w', ' '):
/* FIXME */
return gst_caps_from_string ("audio/x-raw-int, "
- "width = (int) 8, "
- "depth = (int) 8, "
- "signed = (boolean) true");
- case GST_MAKE_FOURCC('t','w','o','s'):
+ "width = (int) 8, " "depth = (int) 8, " "signed = (boolean) true");
+ case GST_MAKE_FOURCC ('t', 'w', 'o', 's'):
/* FIXME */
return gst_caps_from_string ("audio/x-raw-int, "
"width = (int) 16, "
"depth = (int) 16, "
- "endianness = (int) G_BIG_ENDIAN, "
- "signed = (boolean) true");
- case GST_MAKE_FOURCC('s','o','w','t'):
+ "endianness = (int) G_BIG_ENDIAN, " "signed = (boolean) true");
+ case GST_MAKE_FOURCC ('s', 'o', 'w', 't'):
/* FIXME */
return gst_caps_from_string ("audio/x-raw-int, "
"width = (int) 16, "
"depth = (int) 16, "
- "endianness = (int) G_LITTLE_ENDIAN, "
- "signed = (boolean) true");
- case GST_MAKE_FOURCC('f','l','6','4'):
+ "endianness = (int) G_LITTLE_ENDIAN, " "signed = (boolean) true");
+ case GST_MAKE_FOURCC ('f', 'l', '6', '4'):
return gst_caps_from_string ("audio/x-raw-float, "
- "width = (int) 64, "
- "endianness = (int) G_BIG_ENDIAN");
- case GST_MAKE_FOURCC('f','l','3','2'):
+ "width = (int) 64, " "endianness = (int) G_BIG_ENDIAN");
+ case GST_MAKE_FOURCC ('f', 'l', '3', '2'):
return gst_caps_from_string ("audio/x-raw-float, "
- "width = (int) 32, "
- "endianness = (int) G_BIG_ENDIAN");
- case GST_MAKE_FOURCC('i','n','2','4'):
+ "width = (int) 32, " "endianness = (int) G_BIG_ENDIAN");
+ case GST_MAKE_FOURCC ('i', 'n', '2', '4'):
/* FIXME */
return gst_caps_from_string ("audio/x-raw-int, "
"width = (int) 24, "
"depth = (int) 32, "
- "endianness = (int) G_BIG_ENDIAN, "
- "signed = (boolean) true");
- case GST_MAKE_FOURCC('i','n','3','2'):
+ "endianness = (int) G_BIG_ENDIAN, " "signed = (boolean) true");
+ case GST_MAKE_FOURCC ('i', 'n', '3', '2'):
/* FIXME */
return gst_caps_from_string ("audio/x-raw-int, "
"width = (int) 32, "
"depth = (int) 32, "
- "endianness = (int) G_BIG_ENDIAN, "
- "signed = (boolean) true");
- case GST_MAKE_FOURCC('u','l','a','w'):
+ "endianness = (int) G_BIG_ENDIAN, " "signed = (boolean) true");
+ case GST_MAKE_FOURCC ('u', 'l', 'a', 'w'):
/* FIXME */
return gst_caps_from_string ("audio/x-mulaw");
- case GST_MAKE_FOURCC('a','l','a','w'):
+ case GST_MAKE_FOURCC ('a', 'l', 'a', 'w'):
/* FIXME */
return gst_caps_from_string ("audio/x-alaw");
case 0x6d730002:
case 0x6d730055:
/* MPEG layer 3, CBR only (pre QT4.1) */
case 0x5500736d:
- case GST_MAKE_FOURCC('.','m','p','3'):
+ case GST_MAKE_FOURCC ('.', 'm', 'p', '3'):
/* MPEG layer 3, CBR & VBR (QT4.1 and later) */
return gst_caps_from_string ("audio/mpeg, "
- "layer = (int) 3, "
- "mpegversion = (int) 1");
- case GST_MAKE_FOURCC('M','A','C','3'):
+ "layer = (int) 3, " "mpegversion = (int) 1");
+ case GST_MAKE_FOURCC ('M', 'A', 'C', '3'):
/* MACE 3:1 */
- return gst_caps_from_string ("audio/x-mace, "
- "maceversion = (int) 3");
- case GST_MAKE_FOURCC('M','A','C','6'):
+ return gst_caps_from_string ("audio/x-mace, " "maceversion = (int) 3");
+ case GST_MAKE_FOURCC ('M', 'A', 'C', '6'):
/* MACE 6:1 */
- return gst_caps_from_string ("audio/x-mace, "
- "maceversion = (int) 6");
- case GST_MAKE_FOURCC('O','g','g','V'):
+ return gst_caps_from_string ("audio/x-mace, " "maceversion = (int) 6");
+ case GST_MAKE_FOURCC ('O', 'g', 'g', 'V'):
/* Ogg Vorbis */
return gst_caps_from_string ("application/ogg");
- case GST_MAKE_FOURCC('d','v','c','a'):
+ case GST_MAKE_FOURCC ('d', 'v', 'c', 'a'):
/* DV audio */
return gst_caps_from_string ("audio/x-dv");
- case GST_MAKE_FOURCC('m','p','4','a'):
+ case GST_MAKE_FOURCC ('m', 'p', '4', 'a'):
/* MPEG-4 AAC */
- return gst_caps_from_string ("audio/mpeg, "
- "mpegversion = (int) 4");
- case GST_MAKE_FOURCC('Q','D','M','2'):
+ return gst_caps_from_string ("audio/mpeg, " "mpegversion = (int) 4");
+ case GST_MAKE_FOURCC ('Q', 'D', 'M', '2'):
/* FIXME: QDesign music version 2 (no constant) */
if (QTDEMUX_GUINT32_GET (data) <= 100) {
- gst_util_dump_mem ((guint8*)data, 100);
+ gst_util_dump_mem ((guint8 *) data, 100);
return gst_caps_new_simple ("audio/x-qdm2",
- "framesize", G_TYPE_INT, QTDEMUX_GUINT32_GET (data + 52),
- "bitrate", G_TYPE_INT, QTDEMUX_GUINT32_GET (data + 40),
- "blocksize", G_TYPE_INT, QTDEMUX_GUINT32_GET (data + 44),
- NULL);
+ "framesize", G_TYPE_INT, QTDEMUX_GUINT32_GET (data + 52),
+ "bitrate", G_TYPE_INT, QTDEMUX_GUINT32_GET (data + 40),
+ "blocksize", G_TYPE_INT, QTDEMUX_GUINT32_GET (data + 44), NULL);
}
- case GST_MAKE_FOURCC('q','t','v','r'):
+ case GST_MAKE_FOURCC ('q', 't', 'v', 'r'):
/* ? */
- case GST_MAKE_FOURCC('Q','D','M','C'):
+ case GST_MAKE_FOURCC ('Q', 'D', 'M', 'C'):
/* QDesign music */
- case GST_MAKE_FOURCC('i','m','a','4'):
+ case GST_MAKE_FOURCC ('i', 'm', 'a', '4'):
/* IMA 4:1 */
- case GST_MAKE_FOURCC('Q','c','l','p'):
+ case GST_MAKE_FOURCC ('Q', 'c', 'l', 'p'):
/* QUALCOMM PureVoice */
- case GST_MAKE_FOURCC('a','g','s','m'):
+ case GST_MAKE_FOURCC ('a', 'g', 's', 'm'):
/* ? */
default:
g_critical ("Don't know how to convert fourcc '" GST_FOURCC_FORMAT
- "' to caps\n", GST_FOURCC_ARGS(fourcc));
+ "' to caps\n", GST_FOURCC_ARGS (fourcc));
return NULL;
}
}
-
#include <gst/getbits/getbits.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_QTDEMUX \
#define GST_QTDEMUX_MAX_STREAMS 8
-typedef struct _GstQTDemux GstQTDemux;
-typedef struct _GstQTDemuxClass GstQTDemuxClass;
-typedef struct _QtDemuxStream QtDemuxStream;
+ typedef struct _GstQTDemux GstQTDemux;
+ typedef struct _GstQTDemuxClass GstQTDemuxClass;
+ typedef struct _QtDemuxStream QtDemuxStream;
-struct _GstQTDemux {
- GstElement element;
+ struct _GstQTDemux
+ {
+ GstElement element;
- /* pads */
- GstPad *sinkpad;
+ /* pads */
+ GstPad *sinkpad;
- QtDemuxStream *streams[GST_QTDEMUX_MAX_STREAMS];
- int n_streams;
- int n_video_streams;
- int n_audio_streams;
+ QtDemuxStream *streams[GST_QTDEMUX_MAX_STREAMS];
+ int n_streams;
+ int n_video_streams;
+ int n_audio_streams;
- GstByteStream *bs;
+ GstByteStream *bs;
- GNode *moov_node;
- GNode *moov_node_compressed;
+ GNode *moov_node;
+ GNode *moov_node_compressed;
- guint32 timescale;
- guint32 duration;
+ guint32 timescale;
+ guint32 duration;
- int state;
+ int state;
- int offset;
+ int offset;
- /* track stuff */
+ /* track stuff */
-};
+ };
-struct _GstQTDemuxClass {
- GstElementClass parent_class;
-};
+ struct _GstQTDemuxClass
+ {
+ GstElementClass parent_class;
+ };
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_QTDEMUX_H__ */
+#endif /* __GST_QTDEMUX_H__ */
#include "mmx.h"
#endif
-static const unsigned char RTjpeg_ZZ[64]={
-0,
-8, 1,
-2, 9, 16,
-24, 17, 10, 3,
-4, 11, 18, 25, 32,
-40, 33, 26, 19, 12, 5,
-6, 13, 20, 27, 34, 41, 48,
-56, 49, 42, 35, 28, 21, 14, 7,
-15, 22, 29, 36, 43, 50, 57,
-58, 51, 44, 37, 30, 23,
-31, 38, 45, 52, 59,
-60, 53, 46, 39,
-47, 54, 61,
-62, 55,
-63 };
-
-static const __u64 RTjpeg_aan_tab[64]={
-4294967296ULL, 5957222912ULL, 5611718144ULL, 5050464768ULL, 4294967296ULL, 3374581504ULL, 2324432128ULL, 1184891264ULL,
-5957222912ULL, 8263040512ULL, 7783580160ULL, 7005009920ULL, 5957222912ULL, 4680582144ULL, 3224107520ULL, 1643641088ULL,
-5611718144ULL, 7783580160ULL, 7331904512ULL, 6598688768ULL, 5611718144ULL, 4408998912ULL, 3036936960ULL, 1548224000ULL,
-5050464768ULL, 7005009920ULL, 6598688768ULL, 5938608128ULL, 5050464768ULL, 3968072960ULL, 2733115392ULL, 1393296000ULL,
-4294967296ULL, 5957222912ULL, 5611718144ULL, 5050464768ULL, 4294967296ULL, 3374581504ULL, 2324432128ULL, 1184891264ULL,
-3374581504ULL, 4680582144ULL, 4408998912ULL, 3968072960ULL, 3374581504ULL, 2651326208ULL, 1826357504ULL, 931136000ULL,
-2324432128ULL, 3224107520ULL, 3036936960ULL, 2733115392ULL, 2324432128ULL, 1826357504ULL, 1258030336ULL, 641204288ULL,
-1184891264ULL, 1643641088ULL, 1548224000ULL, 1393296000ULL, 1184891264ULL, 931136000ULL, 641204288ULL, 326894240ULL,
+static const unsigned char RTjpeg_ZZ[64] = {
+ 0,
+ 8, 1,
+ 2, 9, 16,
+ 24, 17, 10, 3,
+ 4, 11, 18, 25, 32,
+ 40, 33, 26, 19, 12, 5,
+ 6, 13, 20, 27, 34, 41, 48,
+ 56, 49, 42, 35, 28, 21, 14, 7,
+ 15, 22, 29, 36, 43, 50, 57,
+ 58, 51, 44, 37, 30, 23,
+ 31, 38, 45, 52, 59,
+ 60, 53, 46, 39,
+ 47, 54, 61,
+ 62, 55,
+ 63
+};
+
+static const __u64 RTjpeg_aan_tab[64] = {
+ 4294967296ULL, 5957222912ULL, 5611718144ULL, 5050464768ULL, 4294967296ULL,
+ 3374581504ULL, 2324432128ULL, 1184891264ULL,
+ 5957222912ULL, 8263040512ULL, 7783580160ULL, 7005009920ULL, 5957222912ULL,
+ 4680582144ULL, 3224107520ULL, 1643641088ULL,
+ 5611718144ULL, 7783580160ULL, 7331904512ULL, 6598688768ULL, 5611718144ULL,
+ 4408998912ULL, 3036936960ULL, 1548224000ULL,
+ 5050464768ULL, 7005009920ULL, 6598688768ULL, 5938608128ULL, 5050464768ULL,
+ 3968072960ULL, 2733115392ULL, 1393296000ULL,
+ 4294967296ULL, 5957222912ULL, 5611718144ULL, 5050464768ULL, 4294967296ULL,
+ 3374581504ULL, 2324432128ULL, 1184891264ULL,
+ 3374581504ULL, 4680582144ULL, 4408998912ULL, 3968072960ULL, 3374581504ULL,
+ 2651326208ULL, 1826357504ULL, 931136000ULL,
+ 2324432128ULL, 3224107520ULL, 3036936960ULL, 2733115392ULL, 2324432128ULL,
+ 1826357504ULL, 1258030336ULL, 641204288ULL,
+ 1184891264ULL, 1643641088ULL, 1548224000ULL, 1393296000ULL, 1184891264ULL,
+ 931136000ULL, 641204288ULL, 326894240ULL,
};
#ifndef HAVE_LIBMMX
-static __s32 RTjpeg_ws[64+31];
+static __s32 RTjpeg_ws[64 + 31];
#endif
-__u8 RTjpeg_alldata[2*64+4*64+4*64+4*64+4*64+32];
+__u8 RTjpeg_alldata[2 * 64 + 4 * 64 + 4 * 64 + 4 * 64 + 4 * 64 + 32];
__s16 *RTjpeg_block;
__s32 *RTjpeg_lqt;
int RTjpeg_Ywidth, RTjpeg_Cwidth;
int RTjpeg_Ysize, RTjpeg_Csize;
-__s16 *RTjpeg_old=NULL;
+__s16 *RTjpeg_old = NULL;
#ifdef HAVE_LIBMMX
mmx_t RTjpeg_lmask;
__u16 RTjpeg_lmask;
__u16 RTjpeg_cmask;
#endif
-int RTjpeg_mtest=0;
+int RTjpeg_mtest = 0;
static const unsigned char RTjpeg_lum_quant_tbl[64] = {
- 16, 11, 10, 16, 24, 40, 51, 61,
- 12, 12, 14, 19, 26, 58, 60, 55,
- 14, 13, 16, 24, 40, 57, 69, 56,
- 14, 17, 22, 29, 51, 87, 80, 62,
- 18, 22, 37, 56, 68, 109, 103, 77,
- 24, 35, 55, 64, 81, 104, 113, 92,
- 49, 64, 78, 87, 103, 121, 120, 101,
- 72, 92, 95, 98, 112, 100, 103, 99
- };
+ 16, 11, 10, 16, 24, 40, 51, 61,
+ 12, 12, 14, 19, 26, 58, 60, 55,
+ 14, 13, 16, 24, 40, 57, 69, 56,
+ 14, 17, 22, 29, 51, 87, 80, 62,
+ 18, 22, 37, 56, 68, 109, 103, 77,
+ 24, 35, 55, 64, 81, 104, 113, 92,
+ 49, 64, 78, 87, 103, 121, 120, 101,
+ 72, 92, 95, 98, 112, 100, 103, 99
+};
static const unsigned char RTjpeg_chrom_quant_tbl[64] = {
- 17, 18, 24, 47, 99, 99, 99, 99,
- 18, 21, 26, 66, 99, 99, 99, 99,
- 24, 26, 56, 99, 99, 99, 99, 99,
- 47, 66, 99, 99, 99, 99, 99, 99,
- 99, 99, 99, 99, 99, 99, 99, 99,
- 99, 99, 99, 99, 99, 99, 99, 99,
- 99, 99, 99, 99, 99, 99, 99, 99,
- 99, 99, 99, 99, 99, 99, 99, 99
- };
-
-int RTjpeg_b2s(__s16 *data, __s8 *strm, __u8 bt8)
+ 17, 18, 24, 47, 99, 99, 99, 99,
+ 18, 21, 26, 66, 99, 99, 99, 99,
+ 24, 26, 56, 99, 99, 99, 99, 99,
+ 47, 66, 99, 99, 99, 99, 99, 99,
+ 99, 99, 99, 99, 99, 99, 99, 99,
+ 99, 99, 99, 99, 99, 99, 99, 99,
+ 99, 99, 99, 99, 99, 99, 99, 99,
+ 99, 99, 99, 99, 99, 99, 99, 99
+};
+
+int
+RTjpeg_b2s (__s16 * data, __s8 * strm, __u8 bt8)
{
- register int ci, co=1, tmp;
- register __s16 ZZvalue;
-
- strm[0]=(__u8)(data[RTjpeg_ZZ[0]]>254) ? 254:((data[RTjpeg_ZZ[0]]<0)?0:data[RTjpeg_ZZ[0]]);
-
- for(ci=1; ci<=bt8; ci++)
- {
- ZZvalue = data[RTjpeg_ZZ[ci]];
-
- if(ZZvalue>0)
- {
- strm[co++]=(__s8)(ZZvalue>127)?127:ZZvalue;
- }
- else
- {
- strm[co++]=(__s8)(ZZvalue<-128)?-128:ZZvalue;
- }
- }
-
- for(; ci<64; ci++)
- {
- ZZvalue = data[RTjpeg_ZZ[ci]];
-
- if(ZZvalue>0)
- {
- strm[co++]=(__s8)(ZZvalue>63)?63:ZZvalue;
- }
- else if(ZZvalue<0)
- {
- strm[co++]=(__s8)(ZZvalue<-64)?-64:ZZvalue;
- }
- else /* compress zeros */
- {
- tmp=ci;
- do
- {
- ci++;
- }
- while((ci<64)&&(data[RTjpeg_ZZ[ci]]==0));
+ register int ci, co = 1, tmp;
+ register __s16 ZZvalue;
+
+ strm[0] =
+ (__u8) (data[RTjpeg_ZZ[0]] > 254) ? 254 : ((data[RTjpeg_ZZ[0]] <
+ 0) ? 0 : data[RTjpeg_ZZ[0]]);
+
+ for (ci = 1; ci <= bt8; ci++) {
+ ZZvalue = data[RTjpeg_ZZ[ci]];
+
+ if (ZZvalue > 0) {
+ strm[co++] = (__s8) (ZZvalue > 127) ? 127 : ZZvalue;
+ } else {
+ strm[co++] = (__s8) (ZZvalue < -128) ? -128 : ZZvalue;
+ }
+ }
+
+ for (; ci < 64; ci++) {
+ ZZvalue = data[RTjpeg_ZZ[ci]];
+
+ if (ZZvalue > 0) {
+ strm[co++] = (__s8) (ZZvalue > 63) ? 63 : ZZvalue;
+ } else if (ZZvalue < 0) {
+ strm[co++] = (__s8) (ZZvalue < -64) ? -64 : ZZvalue;
+ } else { /* compress zeros */
- strm[co++]=(__s8)(63+(ci-tmp));
- ci--;
+ tmp = ci;
+ do {
+ ci++;
+ }
+ while ((ci < 64) && (data[RTjpeg_ZZ[ci]] == 0));
+
+ strm[co++] = (__s8) (63 + (ci - tmp));
+ ci--;
+ }
}
- }
- return (int)co;
+ return (int) co;
}
-int RTjpeg_s2b(__s16 *data, __s8 *strm, __u8 bt8, __u32 *qtbl)
+int
+RTjpeg_s2b (__s16 * data, __s8 * strm, __u8 bt8, __u32 * qtbl)
{
- int ci=1, co=1, tmp;
- register int i;
-
- i=RTjpeg_ZZ[0];
- data[i]=((__u8)strm[0])*qtbl[i];
-
- for(co=1; co<=bt8; co++)
- {
- i=RTjpeg_ZZ[co];
- data[i]=strm[ci++]*qtbl[i];
- }
-
- for(; co<64; co++)
- {
- if(strm[ci]>63)
- {
- tmp=co+strm[ci]-63;
- for(; co<tmp; co++)data[RTjpeg_ZZ[co]]=0;
- co--;
- } else
- {
- i=RTjpeg_ZZ[co];
- data[i]=strm[ci]*qtbl[i];
+ int ci = 1, co = 1, tmp;
+ register int i;
+
+ i = RTjpeg_ZZ[0];
+ data[i] = ((__u8) strm[0]) * qtbl[i];
+
+ for (co = 1; co <= bt8; co++) {
+ i = RTjpeg_ZZ[co];
+ data[i] = strm[ci++] * qtbl[i];
+ }
+
+ for (; co < 64; co++) {
+ if (strm[ci] > 63) {
+ tmp = co + strm[ci] - 63;
+ for (; co < tmp; co++)
+ data[RTjpeg_ZZ[co]] = 0;
+ co--;
+ } else {
+ i = RTjpeg_ZZ[co];
+ data[i] = strm[ci] * qtbl[i];
+ }
+ ci++;
}
- ci++;
- }
- return (int)ci;
+ return (int) ci;
}
#if defined(HAVE_LIBMMX)
-void RTjpeg_quant_init(void)
+void
+RTjpeg_quant_init (void)
{
- int i;
- __s16 *qtbl;
-
- qtbl=(__s16 *)RTjpeg_lqt;
- for(i=0; i<64; i++)qtbl[i]=(__s16)RTjpeg_lqt[i];
-
- qtbl=(__s16 *)RTjpeg_cqt;
- for(i=0; i<64; i++)qtbl[i]=(__s16)RTjpeg_cqt[i];
+ int i;
+ __s16 *qtbl;
+
+ qtbl = (__s16 *) RTjpeg_lqt;
+ for (i = 0; i < 64; i++)
+ qtbl[i] = (__s16) RTjpeg_lqt[i];
+
+ qtbl = (__s16 *) RTjpeg_cqt;
+ for (i = 0; i < 64; i++)
+ qtbl[i] = (__s16) RTjpeg_cqt[i];
}
-static mmx_t RTjpeg_ones=(mmx_t)(long long)0x0001000100010001LL;
-static mmx_t RTjpeg_half=(mmx_t)(long long)0x7fff7fff7fff7fffLL;
+static mmx_t RTjpeg_ones = (mmx_t) (long long) 0x0001000100010001LL;
+static mmx_t RTjpeg_half = (mmx_t) (long long) 0x7fff7fff7fff7fffLL;
-void RTjpeg_quant(__s16 *block, __s32 *qtbl)
+void
+RTjpeg_quant (__s16 * block, __s32 * qtbl)
{
- int i;
- mmx_t *bl, *ql;
-
- ql=(mmx_t *)qtbl;
- bl=(mmx_t *)block;
-
- movq_m2r(RTjpeg_ones, mm6);
- movq_m2r(RTjpeg_half, mm7);
-
- for(i=16; i; i--)
- {
- movq_m2r(*(ql++), mm0); /* quant vals (4) */
- movq_m2r(*bl, mm2); /* block vals (4) */
- movq_r2r(mm0, mm1);
- movq_r2r(mm2, mm3);
-
- punpcklwd_r2r(mm6, mm0); /* 1 qb 1 qa */
- punpckhwd_r2r(mm6, mm1); /* 1 qd 1 qc */
-
- punpcklwd_r2r(mm7, mm2); /* 32767 bb 32767 ba */
- punpckhwd_r2r(mm7, mm3); /* 32767 bd 32767 bc */
-
- pmaddwd_r2r(mm2, mm0); /* 32767+bb*qb 32767+ba*qa */
- pmaddwd_r2r(mm3, mm1); /* 32767+bd*qd 32767+bc*qc */
-
- psrad_i2r(16, mm0);
- psrad_i2r(16, mm1);
-
- packssdw_r2r(mm1, mm0);
-
- movq_r2m(mm0, *(bl++));
-
- }
+ int i;
+ mmx_t *bl, *ql;
+
+ ql = (mmx_t *) qtbl;
+ bl = (mmx_t *) block;
+
+ movq_m2r (RTjpeg_ones, mm6);
+ movq_m2r (RTjpeg_half, mm7);
+
+ for (i = 16; i; i--) {
+ movq_m2r (*(ql++), mm0); /* quant vals (4) */
+ movq_m2r (*bl, mm2); /* block vals (4) */
+ movq_r2r (mm0, mm1);
+ movq_r2r (mm2, mm3);
+
+ punpcklwd_r2r (mm6, mm0); /* 1 qb 1 qa */
+ punpckhwd_r2r (mm6, mm1); /* 1 qd 1 qc */
+
+ punpcklwd_r2r (mm7, mm2); /* 32767 bb 32767 ba */
+ punpckhwd_r2r (mm7, mm3); /* 32767 bd 32767 bc */
+
+ pmaddwd_r2r (mm2, mm0); /* 32767+bb*qb 32767+ba*qa */
+ pmaddwd_r2r (mm3, mm1); /* 32767+bd*qd 32767+bc*qc */
+
+ psrad_i2r (16, mm0);
+ psrad_i2r (16, mm1);
+
+ packssdw_r2r (mm1, mm0);
+
+ movq_r2m (mm0, *(bl++));
+
+ }
}
#else
-void RTjpeg_quant_init(void)
+void
+RTjpeg_quant_init (void)
{
}
-void RTjpeg_quant(__s16 *block, __s32 *qtbl)
+void
+RTjpeg_quant (__s16 * block, __s32 * qtbl)
{
- int i;
-
- for(i=0; i<64; i++)
- block[i]=(__s16)((block[i]*qtbl[i]+32767)>>16);
+ int i;
+
+ for (i = 0; i < 64; i++)
+ block[i] = (__s16) ((block[i] * qtbl[i] + 32767) >> 16);
}
#endif
* Perform the forward DCT on one block of samples.
*/
#ifdef HAVE_LIBMMX
-static mmx_t RTjpeg_C4 =(mmx_t)(long long)0x2D412D412D412D41LL;
-static mmx_t RTjpeg_C6 =(mmx_t)(long long)0x187E187E187E187ELL;
-static mmx_t RTjpeg_C2mC6=(mmx_t)(long long)0x22A322A322A322A3LL;
-static mmx_t RTjpeg_C2pC6=(mmx_t)(long long)0x539F539F539F539FLL;
-static mmx_t RTjpeg_zero =(mmx_t)(long long)0x0000000000000000LL;
+static mmx_t RTjpeg_C4 = (mmx_t) (long long) 0x2D412D412D412D41LL;
+static mmx_t RTjpeg_C6 = (mmx_t) (long long) 0x187E187E187E187ELL;
+static mmx_t RTjpeg_C2mC6 = (mmx_t) (long long) 0x22A322A322A322A3LL;
+static mmx_t RTjpeg_C2pC6 = (mmx_t) (long long) 0x539F539F539F539FLL;
+static mmx_t RTjpeg_zero = (mmx_t) (long long) 0x0000000000000000LL;
#else
-#define FIX_0_382683433 ((__s32) 98) /* FIX(0.382683433) */
-#define FIX_0_541196100 ((__s32) 139) /* FIX(0.541196100) */
-#define FIX_0_707106781 ((__s32) 181) /* FIX(0.707106781) */
-#define FIX_1_306562965 ((__s32) 334) /* FIX(1.306562965) */
+#define FIX_0_382683433 ((__s32) 98) /* FIX(0.382683433) */
+#define FIX_0_541196100 ((__s32) 139) /* FIX(0.541196100) */
+#define FIX_0_707106781 ((__s32) 181) /* FIX(0.707106781) */
+#define FIX_1_306562965 ((__s32) 334) /* FIX(1.306562965) */
#define DESCALE10(x) (__s16)( ((x)+128) >> 8)
#define DESCALE20(x) (__s16)(((x)+32768) >> 16)
#define D_MULTIPLY(var,const) ((__s32) ((var) * (const)))
#endif
-void RTjpeg_dct_init(void)
+void
+RTjpeg_dct_init (void)
{
- int i;
-
- for(i=0; i<64; i++)
- {
- RTjpeg_lqt[i]=(((__u64)RTjpeg_lqt[i]<<32)/RTjpeg_aan_tab[i]);
- RTjpeg_cqt[i]=(((__u64)RTjpeg_cqt[i]<<32)/RTjpeg_aan_tab[i]);
- }
+ int i;
+
+ for (i = 0; i < 64; i++) {
+ RTjpeg_lqt[i] = (((__u64) RTjpeg_lqt[i] << 32) / RTjpeg_aan_tab[i]);
+ RTjpeg_cqt[i] = (((__u64) RTjpeg_cqt[i] << 32) / RTjpeg_aan_tab[i]);
+ }
}
-void RTjpeg_dctY(__u8 *idata, __s16 *odata, int rskip)
+void
+RTjpeg_dctY (__u8 * idata, __s16 * odata, int rskip)
{
#ifndef HAVE_LIBMMX
__s32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
tmp5 = idataptr[2] - idataptr[5];
tmp3 = idataptr[3] + idataptr[4];
tmp4 = idataptr[3] - idataptr[4];
-
+
tmp10 = (tmp0 + tmp3); /* phase 2 */
tmp13 = tmp0 - tmp3;
tmp11 = (tmp1 + tmp2);
tmp12 = tmp1 - tmp2;
-
- wsptr[0] = (tmp10 + tmp11)<<8; /* phase 3 */
- wsptr[4] = (tmp10 - tmp11)<<8;
-
- z1 = D_MULTIPLY(tmp12 + tmp13, FIX_0_707106781); /* c4 */
- wsptr[2] = (tmp13<<8) + z1; /* phase 5 */
- wsptr[6] = (tmp13<<8) - z1;
-
+
+ wsptr[0] = (tmp10 + tmp11) << 8; /* phase 3 */
+ wsptr[4] = (tmp10 - tmp11) << 8;
+
+ z1 = D_MULTIPLY (tmp12 + tmp13, FIX_0_707106781); /* c4 */
+ wsptr[2] = (tmp13 << 8) + z1; /* phase 5 */
+ wsptr[6] = (tmp13 << 8) - z1;
+
tmp10 = tmp4 + tmp5; /* phase 2 */
tmp11 = tmp5 + tmp6;
tmp12 = tmp6 + tmp7;
- z5 = D_MULTIPLY(tmp10 - tmp12, FIX_0_382683433); /* c6 */
- z2 = D_MULTIPLY(tmp10, FIX_0_541196100) + z5; /* c2-c6 */
- z4 = D_MULTIPLY(tmp12, FIX_1_306562965) + z5; /* c2+c6 */
- z3 = D_MULTIPLY(tmp11, FIX_0_707106781); /* c4 */
+ z5 = D_MULTIPLY (tmp10 - tmp12, FIX_0_382683433); /* c6 */
+ z2 = D_MULTIPLY (tmp10, FIX_0_541196100) + z5; /* c2-c6 */
+ z4 = D_MULTIPLY (tmp12, FIX_1_306562965) + z5; /* c2+c6 */
+ z3 = D_MULTIPLY (tmp11, FIX_0_707106781); /* c4 */
- z11 = (tmp7<<8) + z3; /* phase 5 */
- z13 = (tmp7<<8) - z3;
+ z11 = (tmp7 << 8) + z3; /* phase 5 */
+ z13 = (tmp7 << 8) - z3;
wsptr[5] = z13 + z2; /* phase 6 */
wsptr[3] = z13 - z2;
wsptr[1] = z11 + z4;
wsptr[7] = z11 - z4;
- idataptr += rskip<<3; /* advance pointer to next row */
+ idataptr += rskip << 3; /* advance pointer to next row */
wsptr += 8;
}
wsptr = RTjpeg_ws;
- odataptr=odata;
+ odataptr = odata;
for (ctr = 7; ctr >= 0; ctr--) {
tmp0 = wsptr[0] + wsptr[56];
tmp7 = wsptr[0] - wsptr[56];
tmp5 = wsptr[16] - wsptr[40];
tmp3 = wsptr[24] + wsptr[32];
tmp4 = wsptr[24] - wsptr[32];
-
+
tmp10 = tmp0 + tmp3; /* phase 2 */
tmp13 = tmp0 - tmp3;
tmp11 = tmp1 + tmp2;
tmp12 = tmp1 - tmp2;
-
- odataptr[0] = DESCALE10(tmp10 + tmp11); /* phase 3 */
- odataptr[32] = DESCALE10(tmp10 - tmp11);
-
- z1 = D_MULTIPLY(tmp12 + tmp13, FIX_0_707106781); /* c4 */
- odataptr[16] = DESCALE20((tmp13<<8) + z1); /* phase 5 */
- odataptr[48] = DESCALE20((tmp13<<8) - z1);
+
+ odataptr[0] = DESCALE10 (tmp10 + tmp11); /* phase 3 */
+ odataptr[32] = DESCALE10 (tmp10 - tmp11);
+
+ z1 = D_MULTIPLY (tmp12 + tmp13, FIX_0_707106781); /* c4 */
+ odataptr[16] = DESCALE20 ((tmp13 << 8) + z1); /* phase 5 */
+ odataptr[48] = DESCALE20 ((tmp13 << 8) - z1);
tmp10 = tmp4 + tmp5; /* phase 2 */
tmp11 = tmp5 + tmp6;
tmp12 = tmp6 + tmp7;
- z5 = D_MULTIPLY(tmp10 - tmp12, FIX_0_382683433); /* c6 */
- z2 = D_MULTIPLY(tmp10, FIX_0_541196100) + z5; /* c2-c6 */
- z4 = D_MULTIPLY(tmp12, FIX_1_306562965) + z5; /* c2+c6 */
- z3 = D_MULTIPLY(tmp11, FIX_0_707106781); /* c4 */
+ z5 = D_MULTIPLY (tmp10 - tmp12, FIX_0_382683433); /* c6 */
+ z2 = D_MULTIPLY (tmp10, FIX_0_541196100) + z5; /* c2-c6 */
+ z4 = D_MULTIPLY (tmp12, FIX_1_306562965) + z5; /* c2+c6 */
+ z3 = D_MULTIPLY (tmp11, FIX_0_707106781); /* c4 */
- z11 = (tmp7<<8) + z3; /* phase 5 */
- z13 = (tmp7<<8) - z3;
+ z11 = (tmp7 << 8) + z3; /* phase 5 */
+ z13 = (tmp7 << 8) - z3;
- odataptr[40] = DESCALE20(z13 + z2); /* phase 6 */
- odataptr[24] = DESCALE20(z13 - z2);
- odataptr[8] = DESCALE20(z11 + z4);
- odataptr[56] = DESCALE20(z11 - z4);
+ odataptr[40] = DESCALE20 (z13 + z2); /* phase 6 */
+ odataptr[24] = DESCALE20 (z13 - z2);
+ odataptr[8] = DESCALE20 (z11 + z4);
+ odataptr[56] = DESCALE20 (z11 - z4);
odataptr++; /* advance pointer to next column */
wsptr++;
}
#else
mmx_t tmp6, tmp7;
- register mmx_t *dataptr = (mmx_t *)odata;
- mmx_t *idata2 = (mmx_t *)idata;
+ register mmx_t *dataptr = (mmx_t *) odata;
+ mmx_t *idata2 = (mmx_t *) idata;
+
+ /* first copy the input 8 bit to the destination 16 bits */
+
+ movq_m2r (RTjpeg_zero, mm2);
+
- /* first copy the input 8 bit to the destination 16 bits */
+ movq_m2r (*idata2, mm0);
+ movq_r2r (mm0, mm1);
- movq_m2r(RTjpeg_zero, mm2);
+ punpcklbw_r2r (mm2, mm0);
+ movq_r2m (mm0, *(dataptr));
+ punpckhbw_r2r (mm2, mm1);
+ movq_r2m (mm1, *(dataptr + 1));
- movq_m2r(*idata2, mm0);
- movq_r2r(mm0, mm1);
+ idata2 += rskip;
- punpcklbw_r2r(mm2, mm0);
- movq_r2m(mm0, *(dataptr));
+ movq_m2r (*idata2, mm0);
+ movq_r2r (mm0, mm1);
- punpckhbw_r2r(mm2, mm1);
- movq_r2m(mm1, *(dataptr+1));
-
- idata2 += rskip;
+ punpcklbw_r2r (mm2, mm0);
+ movq_r2m (mm0, *(dataptr + 2));
- movq_m2r(*idata2, mm0);
- movq_r2r(mm0, mm1);
+ punpckhbw_r2r (mm2, mm1);
+ movq_r2m (mm1, *(dataptr + 3));
- punpcklbw_r2r(mm2, mm0);
- movq_r2m(mm0, *(dataptr+2));
+ idata2 += rskip;
- punpckhbw_r2r(mm2, mm1);
- movq_r2m(mm1, *(dataptr+3));
-
- idata2 += rskip;
+ movq_m2r (*idata2, mm0);
+ movq_r2r (mm0, mm1);
- movq_m2r(*idata2, mm0);
- movq_r2r(mm0, mm1);
+ punpcklbw_r2r (mm2, mm0);
+ movq_r2m (mm0, *(dataptr + 4));
- punpcklbw_r2r(mm2, mm0);
- movq_r2m(mm0, *(dataptr+4));
+ punpckhbw_r2r (mm2, mm1);
+ movq_r2m (mm1, *(dataptr + 5));
- punpckhbw_r2r(mm2, mm1);
- movq_r2m(mm1, *(dataptr+5));
-
- idata2 += rskip;
+ idata2 += rskip;
- movq_m2r(*idata2, mm0);
- movq_r2r(mm0, mm1);
+ movq_m2r (*idata2, mm0);
+ movq_r2r (mm0, mm1);
- punpcklbw_r2r(mm2, mm0);
- movq_r2m(mm0, *(dataptr+6));
+ punpcklbw_r2r (mm2, mm0);
+ movq_r2m (mm0, *(dataptr + 6));
- punpckhbw_r2r(mm2, mm1);
- movq_r2m(mm1, *(dataptr+7));
-
- idata2 += rskip;
+ punpckhbw_r2r (mm2, mm1);
+ movq_r2m (mm1, *(dataptr + 7));
- movq_m2r(*idata2, mm0);
- movq_r2r(mm0, mm1);
+ idata2 += rskip;
- punpcklbw_r2r(mm2, mm0);
- movq_r2m(mm0, *(dataptr+8));
+ movq_m2r (*idata2, mm0);
+ movq_r2r (mm0, mm1);
- punpckhbw_r2r(mm2, mm1);
- movq_r2m(mm1, *(dataptr+9));
-
- idata2 += rskip;
+ punpcklbw_r2r (mm2, mm0);
+ movq_r2m (mm0, *(dataptr + 8));
- movq_m2r(*idata2, mm0);
- movq_r2r(mm0, mm1);
+ punpckhbw_r2r (mm2, mm1);
+ movq_r2m (mm1, *(dataptr + 9));
- punpcklbw_r2r(mm2, mm0);
- movq_r2m(mm0, *(dataptr+10));
+ idata2 += rskip;
- punpckhbw_r2r(mm2, mm1);
- movq_r2m(mm1, *(dataptr+11));
-
- idata2 += rskip;
+ movq_m2r (*idata2, mm0);
+ movq_r2r (mm0, mm1);
- movq_m2r(*idata2, mm0);
- movq_r2r(mm0, mm1);
+ punpcklbw_r2r (mm2, mm0);
+ movq_r2m (mm0, *(dataptr + 10));
- punpcklbw_r2r(mm2, mm0);
- movq_r2m(mm0, *(dataptr+12));
+ punpckhbw_r2r (mm2, mm1);
+ movq_r2m (mm1, *(dataptr + 11));
- punpckhbw_r2r(mm2, mm1);
- movq_r2m(mm1, *(dataptr+13));
-
- idata2 += rskip;
+ idata2 += rskip;
- movq_m2r(*idata2, mm0);
- movq_r2r(mm0, mm1);
+ movq_m2r (*idata2, mm0);
+ movq_r2r (mm0, mm1);
- punpcklbw_r2r(mm2, mm0);
- movq_r2m(mm0, *(dataptr+14));
+ punpcklbw_r2r (mm2, mm0);
+ movq_r2m (mm0, *(dataptr + 12));
- punpckhbw_r2r(mm2, mm1);
- movq_r2m(mm1, *(dataptr+15));
+ punpckhbw_r2r (mm2, mm1);
+ movq_r2m (mm1, *(dataptr + 13));
+
+ idata2 += rskip;
+
+ movq_m2r (*idata2, mm0);
+ movq_r2r (mm0, mm1);
+
+ punpcklbw_r2r (mm2, mm0);
+ movq_r2m (mm0, *(dataptr + 14));
+
+ punpckhbw_r2r (mm2, mm1);
+ movq_r2m (mm1, *(dataptr + 15));
/* Start Transpose to do calculations on rows */
- movq_m2r(*(dataptr+9), mm7); /* m03:m02|m01:m00 - first line (line 4)and copy into m5 */
+ movq_m2r (*(dataptr + 9), mm7); /* m03:m02|m01:m00 - first line (line 4)and copy into m5 */
- movq_m2r(*(dataptr+13), mm6); /* m23:m22|m21:m20 - third line (line 6)and copy into m2 */
- movq_r2r(mm7, mm5);
+ movq_m2r (*(dataptr + 13), mm6); /* m23:m22|m21:m20 - third line (line 6)and copy into m2 */
+ movq_r2r (mm7, mm5);
- punpcklwd_m2r(*(dataptr+11), mm7); /* m11:m01|m10:m00 - interleave first and second lines */
- movq_r2r(mm6, mm2);
+ punpcklwd_m2r (*(dataptr + 11), mm7); /* m11:m01|m10:m00 - interleave first and second lines */
+ movq_r2r (mm6, mm2);
- punpcklwd_m2r(*(dataptr+15), mm6); /* m31:m21|m30:m20 - interleave third and fourth lines */
- movq_r2r(mm7, mm1);
+ punpcklwd_m2r (*(dataptr + 15), mm6); /* m31:m21|m30:m20 - interleave third and fourth lines */
+ movq_r2r (mm7, mm1);
- movq_m2r(*(dataptr+11), mm3); /* m13:m13|m11:m10 - second line */
- punpckldq_r2r(mm6, mm7); /* m30:m20|m10:m00 - interleave to produce result 1 */
+ movq_m2r (*(dataptr + 11), mm3); /* m13:m13|m11:m10 - second line */
+ punpckldq_r2r (mm6, mm7); /* m30:m20|m10:m00 - interleave to produce result 1 */
- movq_m2r(*(dataptr+15), mm0); /* m13:m13|m11:m10 - fourth line */
- punpckhdq_r2r(mm6, mm1); /* m31:m21|m11:m01 - interleave to produce result 2 */
+ movq_m2r (*(dataptr + 15), mm0); /* m13:m13|m11:m10 - fourth line */
+ punpckhdq_r2r (mm6, mm1); /* m31:m21|m11:m01 - interleave to produce result 2 */
- movq_r2m(mm7,*(dataptr+9)); /* write result 1 */
- punpckhwd_r2r(mm3, mm5); /* m13:m03|m12:m02 - interleave first and second lines */
-
- movq_r2m(mm1,*(dataptr+11)); /* write result 2 */
- punpckhwd_r2r(mm0, mm2); /* m33:m23|m32:m22 - interleave third and fourth lines */
+ movq_r2m (mm7, *(dataptr + 9)); /* write result 1 */
+ punpckhwd_r2r (mm3, mm5); /* m13:m03|m12:m02 - interleave first and second lines */
- movq_r2r(mm5, mm1);
- punpckldq_r2r(mm2, mm5); /* m32:m22|m12:m02 - interleave to produce result 3 */
+ movq_r2m (mm1, *(dataptr + 11)); /* write result 2 */
+ punpckhwd_r2r (mm0, mm2); /* m33:m23|m32:m22 - interleave third and fourth lines */
- movq_m2r(*(dataptr+1), mm0); /* m03:m02|m01:m00 - first line, 4x4 */
- punpckhdq_r2r(mm2, mm1); /* m33:m23|m13:m03 - interleave to produce result 4 */
+ movq_r2r (mm5, mm1);
+ punpckldq_r2r (mm2, mm5); /* m32:m22|m12:m02 - interleave to produce result 3 */
- movq_r2m(mm5,*(dataptr+13)); /* write result 3 */
+ movq_m2r (*(dataptr + 1), mm0); /* m03:m02|m01:m00 - first line, 4x4 */
+ punpckhdq_r2r (mm2, mm1); /* m33:m23|m13:m03 - interleave to produce result 4 */
- /* last 4x4 done */
+ movq_r2m (mm5, *(dataptr + 13)); /* write result 3 */
- movq_r2m(mm1, *(dataptr+15)); /* write result 4, last 4x4 */
+ /* last 4x4 done */
- movq_m2r(*(dataptr+5), mm2); /* m23:m22|m21:m20 - third line */
- movq_r2r(mm0, mm6);
+ movq_r2m (mm1, *(dataptr + 15)); /* write result 4, last 4x4 */
- punpcklwd_m2r(*(dataptr+3), mm0); /* m11:m01|m10:m00 - interleave first and second lines */
- movq_r2r(mm2, mm7);
+ movq_m2r (*(dataptr + 5), mm2); /* m23:m22|m21:m20 - third line */
+ movq_r2r (mm0, mm6);
- punpcklwd_m2r(*(dataptr+7), mm2); /* m31:m21|m30:m20 - interleave third and fourth lines */
- movq_r2r(mm0, mm4);
+ punpcklwd_m2r (*(dataptr + 3), mm0); /* m11:m01|m10:m00 - interleave first and second lines */
+ movq_r2r (mm2, mm7);
-
- movq_m2r(*(dataptr+8), mm1); /* n03:n02|n01:n00 - first line */
- punpckldq_r2r(mm2, mm0); /* m30:m20|m10:m00 - interleave to produce first result */
+ punpcklwd_m2r (*(dataptr + 7), mm2); /* m31:m21|m30:m20 - interleave third and fourth lines */
+ movq_r2r (mm0, mm4);
- movq_m2r(*(dataptr+12), mm3); /* n23:n22|n21:n20 - third line */
- punpckhdq_r2r(mm2, mm4); /* m31:m21|m11:m01 - interleave to produce second result */
- punpckhwd_m2r(*(dataptr+3), mm6); /* m13:m03|m12:m02 - interleave first and second lines */
- movq_r2r(mm1, mm2); /* copy first line */
+ movq_m2r (*(dataptr + 8), mm1); /* n03:n02|n01:n00 - first line */
+ punpckldq_r2r (mm2, mm0); /* m30:m20|m10:m00 - interleave to produce first result */
- punpckhwd_m2r(*(dataptr+7), mm7); /* m33:m23|m32:m22 - interleave third and fourth lines */
- movq_r2r(mm6, mm5); /* copy first intermediate result */
+ movq_m2r (*(dataptr + 12), mm3); /* n23:n22|n21:n20 - third line */
+ punpckhdq_r2r (mm2, mm4); /* m31:m21|m11:m01 - interleave to produce second result */
- movq_r2m(mm0, *(dataptr+8)); /* write result 1 */
- punpckhdq_r2r(mm7, mm5); /* m33:m23|m13:m03 - produce third result */
+ punpckhwd_m2r (*(dataptr + 3), mm6); /* m13:m03|m12:m02 - interleave first and second lines */
+ movq_r2r (mm1, mm2); /* copy first line */
- punpcklwd_m2r(*(dataptr+10), mm1); /* n11:n01|n10:n00 - interleave first and second lines */
- movq_r2r(mm3, mm0); /* copy third line */
+ punpckhwd_m2r (*(dataptr + 7), mm7); /* m33:m23|m32:m22 - interleave third and fourth lines */
+ movq_r2r (mm6, mm5); /* copy first intermediate result */
- punpckhwd_m2r(*(dataptr+10), mm2); /* n13:n03|n12:n02 - interleave first and second lines */
+ movq_r2m (mm0, *(dataptr + 8)); /* write result 1 */
+ punpckhdq_r2r (mm7, mm5); /* m33:m23|m13:m03 - produce third result */
- movq_r2m(mm4, *(dataptr+10)); /* write result 2 out */
- punpckldq_r2r(mm7, mm6); /* m32:m22|m12:m02 - produce fourth result */
+ punpcklwd_m2r (*(dataptr + 10), mm1); /* n11:n01|n10:n00 - interleave first and second lines */
+ movq_r2r (mm3, mm0); /* copy third line */
- punpcklwd_m2r(*(dataptr+14), mm3); /* n31:n21|n30:n20 - interleave third and fourth lines */
- movq_r2r(mm1, mm4);
+ punpckhwd_m2r (*(dataptr + 10), mm2); /* n13:n03|n12:n02 - interleave first and second lines */
- movq_r2m(mm6, *(dataptr+12)); /* write result 3 out */
- punpckldq_r2r(mm3, mm1); /* n30:n20|n10:n00 - produce first result */
+ movq_r2m (mm4, *(dataptr + 10)); /* write result 2 out */
+ punpckldq_r2r (mm7, mm6); /* m32:m22|m12:m02 - produce fourth result */
- punpckhwd_m2r(*(dataptr+14), mm0); /* n33:n23|n32:n22 - interleave third and fourth lines */
- movq_r2r(mm2, mm6);
+ punpcklwd_m2r (*(dataptr + 14), mm3); /* n31:n21|n30:n20 - interleave third and fourth lines */
+ movq_r2r (mm1, mm4);
- movq_r2m(mm5, *(dataptr+14)); /* write result 4 out */
- punpckhdq_r2r(mm3, mm4); /* n31:n21|n11:n01- produce second result */
+ movq_r2m (mm6, *(dataptr + 12)); /* write result 3 out */
+ punpckldq_r2r (mm3, mm1); /* n30:n20|n10:n00 - produce first result */
- movq_r2m(mm1, *(dataptr+1)); /* write result 5 out - (first result for other 4 x 4 block) */
- punpckldq_r2r(mm0, mm2); /* n32:n22|n12:n02- produce third result */
+ punpckhwd_m2r (*(dataptr + 14), mm0); /* n33:n23|n32:n22 - interleave third and fourth lines */
+ movq_r2r (mm2, mm6);
- movq_r2m(mm4, *(dataptr+3)); /* write result 6 out */
- punpckhdq_r2r(mm0, mm6); /* n33:n23|n13:n03 - produce fourth result */
+ movq_r2m (mm5, *(dataptr + 14)); /* write result 4 out */
+ punpckhdq_r2r (mm3, mm4); /* n31:n21|n11:n01- produce second result */
- movq_r2m(mm2, *(dataptr+5)); /* write result 7 out*/
+ movq_r2m (mm1, *(dataptr + 1)); /* write result 5 out - (first result for other 4 x 4 block) */
+ punpckldq_r2r (mm0, mm2); /* n32:n22|n12:n02- produce third result */
- movq_m2r(*dataptr, mm0); /* m03:m02|m01:m00 - first line, first 4x4 */
+ movq_r2m (mm4, *(dataptr + 3)); /* write result 6 out */
+ punpckhdq_r2r (mm0, mm6); /* n33:n23|n13:n03 - produce fourth result */
- movq_r2m(mm6, *(dataptr+7)); /* write result 8 out */
+ movq_r2m (mm2, *(dataptr + 5)); /* write result 7 out */
+
+ movq_m2r (*dataptr, mm0); /* m03:m02|m01:m00 - first line, first 4x4 */
+
+ movq_r2m (mm6, *(dataptr + 7)); /* write result 8 out */
/* Do first 4x4 quadrant, which is used in the beginning of the DCT: */
- movq_m2r(*(dataptr+4), mm7); /* m23:m22|m21:m20 - third line */
- movq_r2r(mm0, mm2);
+ movq_m2r (*(dataptr + 4), mm7); /* m23:m22|m21:m20 - third line */
+ movq_r2r (mm0, mm2);
- punpcklwd_m2r(*(dataptr+2), mm0); /* m11:m01|m10:m00 - interleave first and second lines */
- movq_r2r(mm7, mm4);
+ punpcklwd_m2r (*(dataptr + 2), mm0); /* m11:m01|m10:m00 - interleave first and second lines */
+ movq_r2r (mm7, mm4);
- punpcklwd_m2r(*(dataptr+6), mm7); /* m31:m21|m30:m20 - interleave third and fourth lines */
- movq_r2r(mm0, mm1);
+ punpcklwd_m2r (*(dataptr + 6), mm7); /* m31:m21|m30:m20 - interleave third and fourth lines */
+ movq_r2r (mm0, mm1);
- movq_m2r(*(dataptr+2), mm6); /* m13:m12|m11:m10 - second line */
- punpckldq_r2r(mm7, mm0); /* m30:m20|m10:m00 - interleave to produce result 1 */
+ movq_m2r (*(dataptr + 2), mm6); /* m13:m12|m11:m10 - second line */
+ punpckldq_r2r (mm7, mm0); /* m30:m20|m10:m00 - interleave to produce result 1 */
- movq_m2r(*(dataptr+6), mm5); /* m33:m32|m31:m30 - fourth line */
- punpckhdq_r2r(mm7, mm1); /* m31:m21|m11:m01 - interleave to produce result 2 */
+ movq_m2r (*(dataptr + 6), mm5); /* m33:m32|m31:m30 - fourth line */
+ punpckhdq_r2r (mm7, mm1); /* m31:m21|m11:m01 - interleave to produce result 2 */
- movq_r2r(mm0, mm7); /* write result 1 */
- punpckhwd_r2r(mm6, mm2); /* m13:m03|m12:m02 - interleave first and second lines */
+ movq_r2r (mm0, mm7); /* write result 1 */
+ punpckhwd_r2r (mm6, mm2); /* m13:m03|m12:m02 - interleave first and second lines */
- psubw_m2r(*(dataptr+14), mm7); /* tmp07=x0-x7: Stage 1 */
- movq_r2r(mm1, mm6); /* write result 2 */
+ psubw_m2r (*(dataptr + 14), mm7); /* tmp07=x0-x7: Stage 1 */
+ movq_r2r (mm1, mm6); /* write result 2 */
- paddw_m2r(*(dataptr+14), mm0); /* tmp00=x0+x7: Stage 1 */
- punpckhwd_r2r(mm5, mm4); /* m33:m23|m32:m22 - interleave third and fourth lines */
+ paddw_m2r (*(dataptr + 14), mm0); /* tmp00=x0+x7: Stage 1 */
+ punpckhwd_r2r (mm5, mm4); /* m33:m23|m32:m22 - interleave third and fourth lines */
- paddw_m2r(*(dataptr+12), mm1); /* tmp01=x1+x6: Stage 1 */
- movq_r2r(mm2, mm3); /* copy first intermediate result */
+ paddw_m2r (*(dataptr + 12), mm1); /* tmp01=x1+x6: Stage 1 */
+ movq_r2r (mm2, mm3); /* copy first intermediate result */
- psubw_m2r(*(dataptr+12), mm6); /* tmp06=x1-x6: Stage 1 */
- punpckldq_r2r(mm4, mm2); /* m32:m22|m12:m02 - interleave to produce result 3 */
+ psubw_m2r (*(dataptr + 12), mm6); /* tmp06=x1-x6: Stage 1 */
+ punpckldq_r2r (mm4, mm2); /* m32:m22|m12:m02 - interleave to produce result 3 */
- movq_r2m(mm7, tmp7);
- movq_r2r(mm2, mm5); /* write result 3 */
+ movq_r2m (mm7, tmp7);
+ movq_r2r (mm2, mm5); /* write result 3 */
- movq_r2m(mm6, tmp6);
- punpckhdq_r2r(mm4, mm3); /* m33:m23|m13:m03 - interleave to produce result 4 */
+ movq_r2m (mm6, tmp6);
+ punpckhdq_r2r (mm4, mm3); /* m33:m23|m13:m03 - interleave to produce result 4 */
- paddw_m2r(*(dataptr+10), mm2); /* tmp02=x2+5: Stage 1 */
- movq_r2r(mm3, mm4); /* write result 4 */
+ paddw_m2r (*(dataptr + 10), mm2); /* tmp02=x2+5: Stage 1 */
+ movq_r2r (mm3, mm4); /* write result 4 */
/************************************************************************************************
End of Transpose
************************************************************************************************/
- paddw_m2r(*(dataptr+8), mm3); /* tmp03=x3+x4: stage 1 */
- movq_r2r(mm0, mm7);
+ paddw_m2r (*(dataptr + 8), mm3); /* tmp03=x3+x4: stage 1 */
+ movq_r2r (mm0, mm7);
- psubw_m2r(*(dataptr+8), mm4); /* tmp04=x3-x4: stage 1 */
- movq_r2r(mm1, mm6);
+ psubw_m2r (*(dataptr + 8), mm4); /* tmp04=x3-x4: stage 1 */
+ movq_r2r (mm1, mm6);
- paddw_r2r(mm3, mm0); /* tmp10 = tmp00 + tmp03: even 2 */
- psubw_r2r(mm3, mm7); /* tmp13 = tmp00 - tmp03: even 2 */
+ paddw_r2r (mm3, mm0); /* tmp10 = tmp00 + tmp03: even 2 */
+ psubw_r2r (mm3, mm7); /* tmp13 = tmp00 - tmp03: even 2 */
- psubw_r2r(mm2, mm6); /* tmp12 = tmp01 - tmp02: even 2 */
- paddw_r2r(mm2, mm1); /* tmp11 = tmp01 + tmp02: even 2 */
+ psubw_r2r (mm2, mm6); /* tmp12 = tmp01 - tmp02: even 2 */
+ paddw_r2r (mm2, mm1); /* tmp11 = tmp01 + tmp02: even 2 */
- psubw_m2r(*(dataptr+10), mm5); /* tmp05=x2-x5: stage 1 */
- paddw_r2r(mm7, mm6); /* tmp12 + tmp13 */
+ psubw_m2r (*(dataptr + 10), mm5); /* tmp05=x2-x5: stage 1 */
+ paddw_r2r (mm7, mm6); /* tmp12 + tmp13 */
- /* stage 3 */
+ /* stage 3 */
- movq_m2r(tmp6, mm2);
- movq_r2r(mm0, mm3);
+ movq_m2r (tmp6, mm2);
+ movq_r2r (mm0, mm3);
- psllw_i2r(2, mm6); /* m8 * 2^2 */
- paddw_r2r(mm1, mm0);
+ psllw_i2r (2, mm6); /* m8 * 2^2 */
+ paddw_r2r (mm1, mm0);
- pmulhw_m2r(RTjpeg_C4, mm6); /* z1 */
- psubw_r2r(mm1, mm3);
+ pmulhw_m2r (RTjpeg_C4, mm6); /* z1 */
+ psubw_r2r (mm1, mm3);
- movq_r2m(mm0, *dataptr);
- movq_r2r(mm7, mm0);
-
- /* Odd part */
- movq_r2m(mm3, *(dataptr+8));
- paddw_r2r(mm5, mm4); /* tmp10 */
+ movq_r2m (mm0, *dataptr);
+ movq_r2r (mm7, mm0);
- movq_m2r(tmp7, mm3);
- paddw_r2r(mm6, mm0); /* tmp32 */
+ /* Odd part */
+ movq_r2m (mm3, *(dataptr + 8));
+ paddw_r2r (mm5, mm4); /* tmp10 */
- paddw_r2r(mm2, mm5); /* tmp11 */
- psubw_r2r(mm6, mm7); /* tmp33 */
+ movq_m2r (tmp7, mm3);
+ paddw_r2r (mm6, mm0); /* tmp32 */
- movq_r2m(mm0, *(dataptr+4));
- paddw_r2r(mm3, mm2); /* tmp12 */
+ paddw_r2r (mm2, mm5); /* tmp11 */
+ psubw_r2r (mm6, mm7); /* tmp33 */
- /* stage 4 */
+ movq_r2m (mm0, *(dataptr + 4));
+ paddw_r2r (mm3, mm2); /* tmp12 */
- movq_r2m(mm7, *(dataptr+12));
- movq_r2r(mm4, mm1); /* copy of tmp10 */
+ /* stage 4 */
- psubw_r2r(mm2, mm1); /* tmp10 - tmp12 */
- psllw_i2r(2, mm4); /* m8 * 2^2 */
+ movq_r2m (mm7, *(dataptr + 12));
+ movq_r2r (mm4, mm1); /* copy of tmp10 */
- movq_m2r(RTjpeg_C2mC6, mm0);
- psllw_i2r(2, mm1);
+ psubw_r2r (mm2, mm1); /* tmp10 - tmp12 */
+ psllw_i2r (2, mm4); /* m8 * 2^2 */
- pmulhw_m2r(RTjpeg_C6, mm1); /* z5 */
- psllw_i2r(2, mm2);
+ movq_m2r (RTjpeg_C2mC6, mm0);
+ psllw_i2r (2, mm1);
- pmulhw_r2r(mm0, mm4); /* z5 */
+ pmulhw_m2r (RTjpeg_C6, mm1); /* z5 */
+ psllw_i2r (2, mm2);
- /* stage 5 */
+ pmulhw_r2r (mm0, mm4); /* z5 */
- pmulhw_m2r(RTjpeg_C2pC6, mm2);
- psllw_i2r(2, mm5);
+ /* stage 5 */
- pmulhw_m2r(RTjpeg_C4, mm5); /* z3 */
- movq_r2r(mm3, mm0); /* copy tmp7 */
+ pmulhw_m2r (RTjpeg_C2pC6, mm2);
+ psllw_i2r (2, mm5);
- movq_m2r(*(dataptr+1), mm7);
- paddw_r2r(mm1, mm4); /* z2 */
+ pmulhw_m2r (RTjpeg_C4, mm5); /* z3 */
+ movq_r2r (mm3, mm0); /* copy tmp7 */
- paddw_r2r(mm1, mm2); /* z4 */
+ movq_m2r (*(dataptr + 1), mm7);
+ paddw_r2r (mm1, mm4); /* z2 */
- paddw_r2r(mm5, mm0); /* z11 */
- psubw_r2r(mm5, mm3); /* z13 */
+ paddw_r2r (mm1, mm2); /* z4 */
- /* stage 6 */
+ paddw_r2r (mm5, mm0); /* z11 */
+ psubw_r2r (mm5, mm3); /* z13 */
- movq_r2r(mm3, mm5); /* copy z13 */
- psubw_r2r(mm4, mm3); /* y3=z13 - z2 */
+ /* stage 6 */
- paddw_r2r(mm4, mm5); /* y5=z13 + z2 */
- movq_r2r(mm0, mm6); /* copy z11 */
+ movq_r2r (mm3, mm5); /* copy z13 */
+ psubw_r2r (mm4, mm3); /* y3=z13 - z2 */
- movq_r2m(mm3, *(dataptr+6)); /*save y3 */
- psubw_r2r(mm2, mm0); /* y7=z11 - z4 */
+ paddw_r2r (mm4, mm5); /* y5=z13 + z2 */
+ movq_r2r (mm0, mm6); /* copy z11 */
- movq_r2m(mm5, *(dataptr+10)); /*save y5 */
- paddw_r2r(mm2, mm6); /* y1=z11 + z4 */
+ movq_r2m (mm3, *(dataptr + 6)); /*save y3 */
+ psubw_r2r (mm2, mm0); /* y7=z11 - z4 */
- movq_r2m(mm0, *(dataptr+14)); /*save y7 */
+ movq_r2m (mm5, *(dataptr + 10)); /*save y5 */
+ paddw_r2r (mm2, mm6); /* y1=z11 + z4 */
+
+ movq_r2m (mm0, *(dataptr + 14)); /*save y7 */
/************************************************
* End of 1st 4 rows
************************************************/
- movq_m2r(*(dataptr+3), mm1); /* load x1: stage 1 */
- movq_r2r(mm7, mm0); /* copy x0 */
+ movq_m2r (*(dataptr + 3), mm1); /* load x1: stage 1 */
+ movq_r2r (mm7, mm0); /* copy x0 */
+
+ movq_r2m (mm6, *(dataptr + 2)); /*save y1 */
- movq_r2m(mm6, *(dataptr+2)); /*save y1 */
+ movq_m2r (*(dataptr + 5), mm2); /* load x2: stage 1 */
+ movq_r2r (mm1, mm6); /* copy x1 */
- movq_m2r(*(dataptr+5), mm2); /* load x2: stage 1 */
- movq_r2r(mm1, mm6); /* copy x1 */
+ paddw_m2r (*(dataptr + 15), mm0); /* tmp00 = x0 + x7 */
- paddw_m2r(*(dataptr+15), mm0); /* tmp00 = x0 + x7 */
+ movq_m2r (*(dataptr + 7), mm3); /* load x3 : stage 1 */
+ movq_r2r (mm2, mm5); /* copy x2 */
- movq_m2r(*(dataptr+7), mm3); /* load x3 : stage 1 */
- movq_r2r(mm2, mm5); /* copy x2 */
+ psubw_m2r (*(dataptr + 15), mm7); /* tmp07 = x0 - x7 */
+ movq_r2r (mm3, mm4); /* copy x3 */
- psubw_m2r(*(dataptr+15), mm7); /* tmp07 = x0 - x7 */
- movq_r2r(mm3, mm4); /* copy x3 */
+ paddw_m2r (*(dataptr + 13), mm1); /* tmp01 = x1 + x6 */
- paddw_m2r(*(dataptr+13), mm1); /* tmp01 = x1 + x6 */
+ movq_r2m (mm7, tmp7); /* save tmp07 */
+ movq_r2r (mm0, mm7); /* copy tmp00 */
- movq_r2m(mm7, tmp7); /* save tmp07 */
- movq_r2r(mm0, mm7); /* copy tmp00 */
+ psubw_m2r (*(dataptr + 13), mm6); /* tmp06 = x1 - x6 */
- psubw_m2r(*(dataptr+13), mm6); /* tmp06 = x1 - x6 */
+ /* stage 2, Even Part */
- /* stage 2, Even Part */
+ paddw_m2r (*(dataptr + 9), mm3); /* tmp03 = x3 + x4 */
- paddw_m2r(*(dataptr+9), mm3); /* tmp03 = x3 + x4 */
+ movq_r2m (mm6, tmp6); /* save tmp07 */
+ movq_r2r (mm1, mm6); /* copy tmp01 */
- movq_r2m(mm6, tmp6); /* save tmp07 */
- movq_r2r(mm1, mm6); /* copy tmp01 */
+ paddw_m2r (*(dataptr + 11), mm2); /* tmp02 = x2 + x5 */
+ paddw_r2r (mm3, mm0); /* tmp10 = tmp00 + tmp03 */
- paddw_m2r(*(dataptr+11), mm2); /* tmp02 = x2 + x5 */
- paddw_r2r(mm3, mm0); /* tmp10 = tmp00 + tmp03 */
+ psubw_r2r (mm3, mm7); /* tmp13 = tmp00 - tmp03 */
- psubw_r2r(mm3, mm7); /* tmp13 = tmp00 - tmp03 */
+ psubw_m2r (*(dataptr + 9), mm4); /* tmp04 = x3 - x4 */
+ psubw_r2r (mm2, mm6); /* tmp12 = tmp01 - tmp02 */
- psubw_m2r(*(dataptr+9), mm4); /* tmp04 = x3 - x4 */
- psubw_r2r(mm2, mm6); /* tmp12 = tmp01 - tmp02 */
+ paddw_r2r (mm2, mm1); /* tmp11 = tmp01 + tmp02 */
- paddw_r2r(mm2, mm1); /* tmp11 = tmp01 + tmp02 */
+ psubw_m2r (*(dataptr + 11), mm5); /* tmp05 = x2 - x5 */
+ paddw_r2r (mm7, mm6); /* tmp12 + tmp13 */
- psubw_m2r(*(dataptr+11), mm5); /* tmp05 = x2 - x5 */
- paddw_r2r(mm7, mm6); /* tmp12 + tmp13 */
+ /* stage 3, Even and stage 4 & 5 even */
- /* stage 3, Even and stage 4 & 5 even */
+ movq_m2r (tmp6, mm2); /* load tmp6 */
+ movq_r2r (mm0, mm3); /* copy tmp10 */
- movq_m2r(tmp6, mm2); /* load tmp6 */
- movq_r2r(mm0, mm3); /* copy tmp10 */
+ psllw_i2r (2, mm6); /* shift z1 */
+ paddw_r2r (mm1, mm0); /* y0=tmp10 + tmp11 */
- psllw_i2r(2, mm6); /* shift z1 */
- paddw_r2r(mm1, mm0); /* y0=tmp10 + tmp11 */
+ pmulhw_m2r (RTjpeg_C4, mm6); /* z1 */
+ psubw_r2r (mm1, mm3); /* y4=tmp10 - tmp11 */
- pmulhw_m2r(RTjpeg_C4, mm6); /* z1 */
- psubw_r2r(mm1, mm3); /* y4=tmp10 - tmp11 */
+ movq_r2m (mm0, *(dataptr + 1)); /*save y0 */
+ movq_r2r (mm7, mm0); /* copy tmp13 */
- movq_r2m(mm0, *(dataptr+1)); /*save y0 */
- movq_r2r(mm7, mm0); /* copy tmp13 */
-
- /* odd part */
+ /* odd part */
- movq_r2m(mm3, *(dataptr+9)); /*save y4 */
- paddw_r2r(mm5, mm4); /* tmp10 = tmp4 + tmp5 */
+ movq_r2m (mm3, *(dataptr + 9)); /*save y4 */
+ paddw_r2r (mm5, mm4); /* tmp10 = tmp4 + tmp5 */
- movq_m2r(tmp7, mm3); /* load tmp7 */
- paddw_r2r(mm6, mm0); /* tmp32 = tmp13 + z1 */
+ movq_m2r (tmp7, mm3); /* load tmp7 */
+ paddw_r2r (mm6, mm0); /* tmp32 = tmp13 + z1 */
- paddw_r2r(mm2, mm5); /* tmp11 = tmp5 + tmp6 */
- psubw_r2r(mm6, mm7); /* tmp33 = tmp13 - z1 */
+ paddw_r2r (mm2, mm5); /* tmp11 = tmp5 + tmp6 */
+ psubw_r2r (mm6, mm7); /* tmp33 = tmp13 - z1 */
- movq_r2m(mm0, *(dataptr+5)); /*save y2 */
- paddw_r2r(mm3, mm2); /* tmp12 = tmp6 + tmp7 */
+ movq_r2m (mm0, *(dataptr + 5)); /*save y2 */
+ paddw_r2r (mm3, mm2); /* tmp12 = tmp6 + tmp7 */
- /* stage 4 */
+ /* stage 4 */
- movq_r2m(mm7, *(dataptr+13)); /*save y6 */
- movq_r2r(mm4, mm1); /* copy tmp10 */
+ movq_r2m (mm7, *(dataptr + 13)); /*save y6 */
+ movq_r2r (mm4, mm1); /* copy tmp10 */
- psubw_r2r(mm2, mm1); /* tmp10 - tmp12 */
- psllw_i2r(2, mm4); /* shift tmp10 */
+ psubw_r2r (mm2, mm1); /* tmp10 - tmp12 */
+ psllw_i2r (2, mm4); /* shift tmp10 */
- movq_m2r(RTjpeg_C2mC6, mm0); /* load C2mC6 */
- psllw_i2r(2, mm1); /* shift (tmp10-tmp12) */
+ movq_m2r (RTjpeg_C2mC6, mm0); /* load C2mC6 */
+ psllw_i2r (2, mm1); /* shift (tmp10-tmp12) */
- pmulhw_m2r(RTjpeg_C6, mm1); /* z5 */
- psllw_i2r(2, mm5); /* prepare for multiply */
+ pmulhw_m2r (RTjpeg_C6, mm1); /* z5 */
+ psllw_i2r (2, mm5); /* prepare for multiply */
- pmulhw_r2r(mm0, mm4); /* multiply by converted real */
+ pmulhw_r2r (mm0, mm4); /* multiply by converted real */
- /* stage 5 */
+ /* stage 5 */
- pmulhw_m2r(RTjpeg_C4, mm5); /* z3 */
- psllw_i2r(2, mm2); /* prepare for multiply */
+ pmulhw_m2r (RTjpeg_C4, mm5); /* z3 */
+ psllw_i2r (2, mm2); /* prepare for multiply */
- pmulhw_m2r(RTjpeg_C2pC6, mm2); /* multiply */
- movq_r2r(mm3, mm0); /* copy tmp7 */
+ pmulhw_m2r (RTjpeg_C2pC6, mm2); /* multiply */
+ movq_r2r (mm3, mm0); /* copy tmp7 */
- movq_m2r(*(dataptr+9), mm7); /* m03:m02|m01:m00 - first line (line 4)and copy into mm7 */
- paddw_r2r(mm1, mm4); /* z2 */
+ movq_m2r (*(dataptr + 9), mm7); /* m03:m02|m01:m00 - first line (line 4)and copy into mm7 */
+ paddw_r2r (mm1, mm4); /* z2 */
- paddw_r2r(mm5, mm0); /* z11 */
- psubw_r2r(mm5, mm3); /* z13 */
+ paddw_r2r (mm5, mm0); /* z11 */
+ psubw_r2r (mm5, mm3); /* z13 */
- /* stage 6 */
+ /* stage 6 */
- movq_r2r(mm3, mm5); /* copy z13 */
- paddw_r2r(mm1, mm2); /* z4 */
+ movq_r2r (mm3, mm5); /* copy z13 */
+ paddw_r2r (mm1, mm2); /* z4 */
- movq_r2r(mm0, mm6); /* copy z11 */
- psubw_r2r(mm4, mm5); /* y3 */
+ movq_r2r (mm0, mm6); /* copy z11 */
+ psubw_r2r (mm4, mm5); /* y3 */
- paddw_r2r(mm2, mm6); /* y1 */
- paddw_r2r(mm4, mm3); /* y5 */
+ paddw_r2r (mm2, mm6); /* y1 */
+ paddw_r2r (mm4, mm3); /* y5 */
- movq_r2m(mm5, *(dataptr+7)); /*save y3 */
+ movq_r2m (mm5, *(dataptr + 7)); /*save y3 */
+
+ movq_r2m (mm6, *(dataptr + 3)); /*save y1 */
+ psubw_r2r (mm2, mm0); /* y7 */
- movq_r2m(mm6, *(dataptr+3)); /*save y1 */
- psubw_r2r(mm2, mm0); /* y7 */
-
/************************************************************************************************
Start of Transpose
************************************************************************************************/
- movq_m2r(*(dataptr+13), mm6); /* m23:m22|m21:m20 - third line (line 6)and copy into m2 */
- movq_r2r(mm7, mm5); /* copy first line */
+ movq_m2r (*(dataptr + 13), mm6); /* m23:m22|m21:m20 - third line (line 6)and copy into m2 */
+ movq_r2r (mm7, mm5); /* copy first line */
- punpcklwd_r2r(mm3, mm7); /* m11:m01|m10:m00 - interleave first and second lines */
- movq_r2r(mm6, mm2); /* copy third line */
+ punpcklwd_r2r (mm3, mm7); /* m11:m01|m10:m00 - interleave first and second lines */
+ movq_r2r (mm6, mm2); /* copy third line */
- punpcklwd_r2r(mm0, mm6); /* m31:m21|m30:m20 - interleave third and fourth lines */
- movq_r2r(mm7, mm1); /* copy first intermediate result */
+ punpcklwd_r2r (mm0, mm6); /* m31:m21|m30:m20 - interleave third and fourth lines */
+ movq_r2r (mm7, mm1); /* copy first intermediate result */
- punpckldq_r2r(mm6, mm7); /* m30:m20|m10:m00 - interleave to produce result 1 */
+ punpckldq_r2r (mm6, mm7); /* m30:m20|m10:m00 - interleave to produce result 1 */
- punpckhdq_r2r(mm6, mm1); /* m31:m21|m11:m01 - interleave to produce result 2 */
+ punpckhdq_r2r (mm6, mm1); /* m31:m21|m11:m01 - interleave to produce result 2 */
- movq_r2m(mm7, *(dataptr+9)); /* write result 1 */
- punpckhwd_r2r(mm3, mm5); /* m13:m03|m12:m02 - interleave first and second lines */
+ movq_r2m (mm7, *(dataptr + 9)); /* write result 1 */
+ punpckhwd_r2r (mm3, mm5); /* m13:m03|m12:m02 - interleave first and second lines */
- movq_r2m(mm1, *(dataptr+11)); /* write result 2 */
- punpckhwd_r2r(mm0, mm2); /* m33:m23|m32:m22 - interleave third and fourth lines */
+ movq_r2m (mm1, *(dataptr + 11)); /* write result 2 */
+ punpckhwd_r2r (mm0, mm2); /* m33:m23|m32:m22 - interleave third and fourth lines */
- movq_r2r(mm5, mm1); /* copy first intermediate result */
- punpckldq_r2r(mm2, mm5); /* m32:m22|m12:m02 - interleave to produce result 3 */
+ movq_r2r (mm5, mm1); /* copy first intermediate result */
+ punpckldq_r2r (mm2, mm5); /* m32:m22|m12:m02 - interleave to produce result 3 */
- movq_m2r(*(dataptr+1), mm0); /* m03:m02|m01:m00 - first line, 4x4 */
- punpckhdq_r2r(mm2, mm1); /* m33:m23|m13:m03 - interleave to produce result 4 */
+ movq_m2r (*(dataptr + 1), mm0); /* m03:m02|m01:m00 - first line, 4x4 */
+ punpckhdq_r2r (mm2, mm1); /* m33:m23|m13:m03 - interleave to produce result 4 */
- movq_r2m(mm5, *(dataptr+13)); /* write result 3 */
+ movq_r2m (mm5, *(dataptr + 13)); /* write result 3 */
/****** last 4x4 done */
- movq_r2m(mm1, *(dataptr+15)); /* write result 4, last 4x4 */
+ movq_r2m (mm1, *(dataptr + 15)); /* write result 4, last 4x4 */
+
+ movq_m2r (*(dataptr + 5), mm2); /* m23:m22|m21:m20 - third line */
+ movq_r2r (mm0, mm6); /* copy first line */
- movq_m2r(*(dataptr+5), mm2); /* m23:m22|m21:m20 - third line */
- movq_r2r(mm0, mm6); /* copy first line */
+ punpcklwd_m2r (*(dataptr + 3), mm0); /* m11:m01|m10:m00 - interleave first and second lines */
+ movq_r2r (mm2, mm7); /* copy third line */
- punpcklwd_m2r(*(dataptr+3), mm0); /* m11:m01|m10:m00 - interleave first and second lines */
- movq_r2r(mm2, mm7); /* copy third line */
+ punpcklwd_m2r (*(dataptr + 7), mm2); /* m31:m21|m30:m20 - interleave third and fourth lines */
+ movq_r2r (mm0, mm4); /* copy first intermediate result */
- punpcklwd_m2r(*(dataptr+7), mm2); /* m31:m21|m30:m20 - interleave third and fourth lines */
- movq_r2r(mm0, mm4); /* copy first intermediate result */
-
- movq_m2r(*(dataptr+8), mm1); /* n03:n02|n01:n00 - first line */
- punpckldq_r2r(mm2, mm0); /* m30:m20|m10:m00 - interleave to produce first result */
+ movq_m2r (*(dataptr + 8), mm1); /* n03:n02|n01:n00 - first line */
+ punpckldq_r2r (mm2, mm0); /* m30:m20|m10:m00 - interleave to produce first result */
- movq_m2r(*(dataptr+12), mm3); /* n23:n22|n21:n20 - third line */
- punpckhdq_r2r(mm2, mm4); /* m31:m21|m11:m01 - interleave to produce second result */
+ movq_m2r (*(dataptr + 12), mm3); /* n23:n22|n21:n20 - third line */
+ punpckhdq_r2r (mm2, mm4); /* m31:m21|m11:m01 - interleave to produce second result */
- punpckhwd_m2r(*(dataptr+3), mm6); /* m13:m03|m12:m02 - interleave first and second lines */
- movq_r2r(mm1, mm2); /* copy first line */
+ punpckhwd_m2r (*(dataptr + 3), mm6); /* m13:m03|m12:m02 - interleave first and second lines */
+ movq_r2r (mm1, mm2); /* copy first line */
- punpckhwd_m2r(*(dataptr+7), mm7); /* m33:m23|m32:m22 - interleave third and fourth lines */
- movq_r2r(mm6, mm5); /* copy first intermediate result */
+ punpckhwd_m2r (*(dataptr + 7), mm7); /* m33:m23|m32:m22 - interleave third and fourth lines */
+ movq_r2r (mm6, mm5); /* copy first intermediate result */
- movq_r2m(mm0, *(dataptr+8)); /* write result 1 */
- punpckhdq_r2r(mm7, mm5); /* m33:m23|m13:m03 - produce third result */
+ movq_r2m (mm0, *(dataptr + 8)); /* write result 1 */
+ punpckhdq_r2r (mm7, mm5); /* m33:m23|m13:m03 - produce third result */
- punpcklwd_m2r(*(dataptr+10), mm1); /* n11:n01|n10:n00 - interleave first and second lines */
- movq_r2r(mm3, mm0); /* copy third line */
+ punpcklwd_m2r (*(dataptr + 10), mm1); /* n11:n01|n10:n00 - interleave first and second lines */
+ movq_r2r (mm3, mm0); /* copy third line */
- punpckhwd_m2r(*(dataptr+10), mm2); /* n13:n03|n12:n02 - interleave first and second lines */
+ punpckhwd_m2r (*(dataptr + 10), mm2); /* n13:n03|n12:n02 - interleave first and second lines */
- movq_r2m(mm4, *(dataptr+10)); /* write result 2 out */
- punpckldq_r2r(mm7, mm6); /* m32:m22|m12:m02 - produce fourth result */
+ movq_r2m (mm4, *(dataptr + 10)); /* write result 2 out */
+ punpckldq_r2r (mm7, mm6); /* m32:m22|m12:m02 - produce fourth result */
- punpcklwd_m2r(*(dataptr+14), mm3); /* n33:n23|n32:n22 - interleave third and fourth lines */
- movq_r2r(mm1, mm4); /* copy second intermediate result */
+ punpcklwd_m2r (*(dataptr + 14), mm3); /* n33:n23|n32:n22 - interleave third and fourth lines */
+ movq_r2r (mm1, mm4); /* copy second intermediate result */
- movq_r2m(mm6, *(dataptr+12)); /* write result 3 out */
- punpckldq_r2r(mm3, mm1); /* */
+ movq_r2m (mm6, *(dataptr + 12)); /* write result 3 out */
+ punpckldq_r2r (mm3, mm1); /* */
- punpckhwd_m2r(*(dataptr+14), mm0); /* n33:n23|n32:n22 - interleave third and fourth lines */
- movq_r2r(mm2, mm6); /* copy second intermediate result */
+ punpckhwd_m2r (*(dataptr + 14), mm0); /* n33:n23|n32:n22 - interleave third and fourth lines */
+ movq_r2r (mm2, mm6); /* copy second intermediate result */
- movq_r2m(mm5, *(dataptr+14)); /* write result 4 out */
- punpckhdq_r2r(mm3, mm4); /* n31:n21|n11:n01- produce second result */
+ movq_r2m (mm5, *(dataptr + 14)); /* write result 4 out */
+ punpckhdq_r2r (mm3, mm4); /* n31:n21|n11:n01- produce second result */
- movq_r2m(mm1, *(dataptr+1)); /* write result 5 out - (first result for other 4 x 4 block) */
- punpckldq_r2r(mm0, mm2); /* n32:n22|n12:n02- produce third result */
+ movq_r2m (mm1, *(dataptr + 1)); /* write result 5 out - (first result for other 4 x 4 block) */
+ punpckldq_r2r (mm0, mm2); /* n32:n22|n12:n02- produce third result */
- movq_r2m(mm4, *(dataptr+3)); /* write result 6 out */
- punpckhdq_r2r(mm0, mm6); /* n33:n23|n13:n03 - produce fourth result */
+ movq_r2m (mm4, *(dataptr + 3)); /* write result 6 out */
+ punpckhdq_r2r (mm0, mm6); /* n33:n23|n13:n03 - produce fourth result */
- movq_r2m(mm2, *(dataptr+5)); /* write result 7 out */
+ movq_r2m (mm2, *(dataptr + 5)); /* write result 7 out */
- movq_m2r(*dataptr, mm0); /* m03:m02|m01:m00 - first line, first 4x4 */
+ movq_m2r (*dataptr, mm0); /* m03:m02|m01:m00 - first line, first 4x4 */
- movq_r2m(mm6, *(dataptr+7)); /* write result 8 out */
+ movq_r2m (mm6, *(dataptr + 7)); /* write result 8 out */
/* Do first 4x4 quadrant, which is used in the beginning of the DCT: */
- movq_m2r(*(dataptr+4), mm7); /* m23:m22|m21:m20 - third line */
- movq_r2r(mm0, mm2); /* copy first line */
+ movq_m2r (*(dataptr + 4), mm7); /* m23:m22|m21:m20 - third line */
+ movq_r2r (mm0, mm2); /* copy first line */
+
+ punpcklwd_m2r (*(dataptr + 2), mm0); /* m11:m01|m10:m00 - interleave first and second lines */
+ movq_r2r (mm7, mm4); /* copy third line */
- punpcklwd_m2r(*(dataptr+2), mm0); /* m11:m01|m10:m00 - interleave first and second lines */
- movq_r2r(mm7, mm4); /* copy third line */
-
- punpcklwd_m2r(*(dataptr+6), mm7); /* m31:m21|m30:m20 - interleave third and fourth lines */
- movq_r2r(mm0, mm1); /* copy first intermediate result */
+ punpcklwd_m2r (*(dataptr + 6), mm7); /* m31:m21|m30:m20 - interleave third and fourth lines */
+ movq_r2r (mm0, mm1); /* copy first intermediate result */
- movq_m2r(*(dataptr+2), mm6); /* m13:m12|m11:m10 - second line */
- punpckldq_r2r(mm7, mm0); /* m30:m20|m10:m00 - interleave to produce result 1 */
+ movq_m2r (*(dataptr + 2), mm6); /* m13:m12|m11:m10 - second line */
+ punpckldq_r2r (mm7, mm0); /* m30:m20|m10:m00 - interleave to produce result 1 */
- movq_m2r(*(dataptr+6), mm5); /* m33:m32|m31:m30 - fourth line */
- punpckhdq_r2r(mm7, mm1); /* m31:m21|m11:m01 - interleave to produce result 2 */
+ movq_m2r (*(dataptr + 6), mm5); /* m33:m32|m31:m30 - fourth line */
+ punpckhdq_r2r (mm7, mm1); /* m31:m21|m11:m01 - interleave to produce result 2 */
- movq_r2r(mm0, mm7); /* write result 1 */
- punpckhwd_r2r(mm6, mm2); /* m13:m03|m12:m02 - interleave first and second lines */
+ movq_r2r (mm0, mm7); /* write result 1 */
+ punpckhwd_r2r (mm6, mm2); /* m13:m03|m12:m02 - interleave first and second lines */
- psubw_m2r(*(dataptr+14), mm7); /* tmp07=x0-x7: Stage 1 */
- movq_r2r(mm1, mm6); /* write result 2 */
+ psubw_m2r (*(dataptr + 14), mm7); /* tmp07=x0-x7: Stage 1 */
+ movq_r2r (mm1, mm6); /* write result 2 */
- paddw_m2r(*(dataptr+14), mm0); /* tmp00=x0+x7: Stage 1 */
- punpckhwd_r2r(mm5, mm4); /* m33:m23|m32:m22 - interleave third and fourth lines */
+ paddw_m2r (*(dataptr + 14), mm0); /* tmp00=x0+x7: Stage 1 */
+ punpckhwd_r2r (mm5, mm4); /* m33:m23|m32:m22 - interleave third and fourth lines */
- paddw_m2r(*(dataptr+12), mm1); /* tmp01=x1+x6: Stage 1 */
- movq_r2r(mm2, mm3); /* copy first intermediate result */
+ paddw_m2r (*(dataptr + 12), mm1); /* tmp01=x1+x6: Stage 1 */
+ movq_r2r (mm2, mm3); /* copy first intermediate result */
- psubw_m2r(*(dataptr+12), mm6); /* tmp06=x1-x6: Stage 1 */
- punpckldq_r2r(mm4, mm2); /* m32:m22|m12:m02 - interleave to produce result 3 */
+ psubw_m2r (*(dataptr + 12), mm6); /* tmp06=x1-x6: Stage 1 */
+ punpckldq_r2r (mm4, mm2); /* m32:m22|m12:m02 - interleave to produce result 3 */
- movq_r2m(mm7, tmp7); /* save tmp07 */
- movq_r2r(mm2, mm5); /* write result 3 */
+ movq_r2m (mm7, tmp7); /* save tmp07 */
+ movq_r2r (mm2, mm5); /* write result 3 */
- movq_r2m(mm6, tmp6); /* save tmp06 */
+ movq_r2m (mm6, tmp6); /* save tmp06 */
- punpckhdq_r2r(mm4, mm3); /* m33:m23|m13:m03 - interleave to produce result 4 */
+ punpckhdq_r2r (mm4, mm3); /* m33:m23|m13:m03 - interleave to produce result 4 */
- paddw_m2r(*(dataptr+10), mm2); /* tmp02=x2+x5: stage 1 */
- movq_r2r(mm3, mm4); /* write result 4 */
+ paddw_m2r (*(dataptr + 10), mm2); /* tmp02=x2+x5: stage 1 */
+ movq_r2r (mm3, mm4); /* write result 4 */
/************************************************************************************************
End of Transpose 2
************************************************************************************************/
- paddw_m2r(*(dataptr+8), mm3); /* tmp03=x3+x4: stage 1 */
- movq_r2r(mm0, mm7);
+ paddw_m2r (*(dataptr + 8), mm3); /* tmp03=x3+x4: stage 1 */
+ movq_r2r (mm0, mm7);
- psubw_m2r(*(dataptr+8), mm4); /* tmp04=x3-x4: stage 1 */
- movq_r2r(mm1, mm6);
+ psubw_m2r (*(dataptr + 8), mm4); /* tmp04=x3-x4: stage 1 */
+ movq_r2r (mm1, mm6);
- paddw_r2r(mm3, mm0); /* tmp10 = tmp00 + tmp03: even 2 */
- psubw_r2r(mm3, mm7); /* tmp13 = tmp00 - tmp03: even 2 */
+ paddw_r2r (mm3, mm0); /* tmp10 = tmp00 + tmp03: even 2 */
+ psubw_r2r (mm3, mm7); /* tmp13 = tmp00 - tmp03: even 2 */
- psubw_r2r(mm2, mm6); /* tmp12 = tmp01 - tmp02: even 2 */
- paddw_r2r(mm2, mm1); /* tmp11 = tmp01 + tmp02: even 2 */
+ psubw_r2r (mm2, mm6); /* tmp12 = tmp01 - tmp02: even 2 */
+ paddw_r2r (mm2, mm1); /* tmp11 = tmp01 + tmp02: even 2 */
- psubw_m2r(*(dataptr+10), mm5); /* tmp05=x2-x5: stage 1 */
- paddw_r2r(mm7, mm6); /* tmp12 + tmp13 */
+ psubw_m2r (*(dataptr + 10), mm5); /* tmp05=x2-x5: stage 1 */
+ paddw_r2r (mm7, mm6); /* tmp12 + tmp13 */
- /* stage 3 */
+ /* stage 3 */
- movq_m2r(tmp6, mm2);
- movq_r2r(mm0, mm3);
+ movq_m2r (tmp6, mm2);
+ movq_r2r (mm0, mm3);
- psllw_i2r(2, mm6); /* m8 * 2^2 */
- paddw_r2r(mm1, mm0);
+ psllw_i2r (2, mm6); /* m8 * 2^2 */
+ paddw_r2r (mm1, mm0);
- pmulhw_m2r(RTjpeg_C4, mm6); /* z1 */
- psubw_r2r(mm1, mm3);
+ pmulhw_m2r (RTjpeg_C4, mm6); /* z1 */
+ psubw_r2r (mm1, mm3);
- movq_r2m(mm0, *dataptr);
- movq_r2r(mm7, mm0);
-
- /* Odd part */
- movq_r2m(mm3, *(dataptr+8));
- paddw_r2r(mm5, mm4); /* tmp10 */
+ movq_r2m (mm0, *dataptr);
+ movq_r2r (mm7, mm0);
- movq_m2r(tmp7, mm3);
- paddw_r2r(mm6, mm0); /* tmp32 */
+ /* Odd part */
+ movq_r2m (mm3, *(dataptr + 8));
+ paddw_r2r (mm5, mm4); /* tmp10 */
- paddw_r2r(mm2, mm5); /* tmp11 */
- psubw_r2r(mm6, mm7); /* tmp33 */
+ movq_m2r (tmp7, mm3);
+ paddw_r2r (mm6, mm0); /* tmp32 */
- movq_r2m(mm0, *(dataptr+4));
- paddw_r2r(mm3, mm2); /* tmp12 */
+ paddw_r2r (mm2, mm5); /* tmp11 */
+ psubw_r2r (mm6, mm7); /* tmp33 */
- /* stage 4 */
- movq_r2m(mm7, *(dataptr+12));
- movq_r2r(mm4, mm1); /* copy of tmp10 */
+ movq_r2m (mm0, *(dataptr + 4));
+ paddw_r2r (mm3, mm2); /* tmp12 */
- psubw_r2r(mm2, mm1); /* tmp10 - tmp12 */
- psllw_i2r(2, mm4); /* m8 * 2^2 */
+ /* stage 4 */
+ movq_r2m (mm7, *(dataptr + 12));
+ movq_r2r (mm4, mm1); /* copy of tmp10 */
- movq_m2r(RTjpeg_C2mC6, mm0);
- psllw_i2r(2, mm1);
+ psubw_r2r (mm2, mm1); /* tmp10 - tmp12 */
+ psllw_i2r (2, mm4); /* m8 * 2^2 */
- pmulhw_m2r(RTjpeg_C6, mm1); /* z5 */
- psllw_i2r(2, mm2);
+ movq_m2r (RTjpeg_C2mC6, mm0);
+ psllw_i2r (2, mm1);
- pmulhw_r2r(mm0, mm4); /* z5 */
+ pmulhw_m2r (RTjpeg_C6, mm1); /* z5 */
+ psllw_i2r (2, mm2);
- /* stage 5 */
+ pmulhw_r2r (mm0, mm4); /* z5 */
- pmulhw_m2r(RTjpeg_C2pC6, mm2);
- psllw_i2r(2, mm5);
+ /* stage 5 */
- pmulhw_m2r(RTjpeg_C4, mm5); /* z3 */
- movq_r2r(mm3, mm0); /* copy tmp7 */
+ pmulhw_m2r (RTjpeg_C2pC6, mm2);
+ psllw_i2r (2, mm5);
- movq_m2r(*(dataptr+1), mm7);
- paddw_r2r(mm1, mm4); /* z2 */
+ pmulhw_m2r (RTjpeg_C4, mm5); /* z3 */
+ movq_r2r (mm3, mm0); /* copy tmp7 */
- paddw_r2r(mm1, mm2); /* z4 */
+ movq_m2r (*(dataptr + 1), mm7);
+ paddw_r2r (mm1, mm4); /* z2 */
- paddw_r2r(mm5, mm0); /* z11 */
- psubw_r2r(mm5, mm3); /* z13 */
+ paddw_r2r (mm1, mm2); /* z4 */
- /* stage 6 */
+ paddw_r2r (mm5, mm0); /* z11 */
+ psubw_r2r (mm5, mm3); /* z13 */
- movq_r2r(mm3, mm5); /* copy z13 */
- psubw_r2r(mm4, mm3); /* y3=z13 - z2 */
+ /* stage 6 */
- paddw_r2r(mm4, mm5); /* y5=z13 + z2 */
- movq_r2r(mm0, mm6); /* copy z11 */
+ movq_r2r (mm3, mm5); /* copy z13 */
+ psubw_r2r (mm4, mm3); /* y3=z13 - z2 */
- movq_r2m(mm3, *(dataptr+6)); /*save y3 */
- psubw_r2r(mm2, mm0); /* y7=z11 - z4 */
+ paddw_r2r (mm4, mm5); /* y5=z13 + z2 */
+ movq_r2r (mm0, mm6); /* copy z11 */
- movq_r2m(mm5, *(dataptr+10)); /*save y5 */
- paddw_r2r(mm2, mm6); /* y1=z11 + z4 */
+ movq_r2m (mm3, *(dataptr + 6)); /*save y3 */
+ psubw_r2r (mm2, mm0); /* y7=z11 - z4 */
- movq_r2m(mm0, *(dataptr+14)); /*save y7 */
+ movq_r2m (mm5, *(dataptr + 10)); /*save y5 */
+ paddw_r2r (mm2, mm6); /* y1=z11 + z4 */
+
+ movq_r2m (mm0, *(dataptr + 14)); /*save y7 */
/************************************************
* End of 1st 4 rows
************************************************/
- movq_m2r(*(dataptr+3), mm1); /* load x1 : stage 1 */
- movq_r2r(mm7, mm0); /* copy x0 */
+ movq_m2r (*(dataptr + 3), mm1); /* load x1 : stage 1 */
+ movq_r2r (mm7, mm0); /* copy x0 */
+
+ movq_r2m (mm6, *(dataptr + 2)); /*save y1 */
- movq_r2m(mm6, *(dataptr+2)); /*save y1 */
+ movq_m2r (*(dataptr + 5), mm2); /* load x2 : stage 1 */
+ movq_r2r (mm1, mm6); /* copy x1 */
- movq_m2r(*(dataptr+5), mm2); /* load x2 : stage 1 */
- movq_r2r(mm1, mm6); /* copy x1 */
+ paddw_m2r (*(dataptr + 15), mm0); /* tmp00 = x0 + x7 */
- paddw_m2r(*(dataptr+15), mm0); /* tmp00 = x0 + x7 */
+ movq_m2r (*(dataptr + 7), mm3); /* load x3 : stage 1 */
+ movq_r2r (mm2, mm5); /* copy x2 */
- movq_m2r(*(dataptr+7), mm3); /* load x3 : stage 1 */
- movq_r2r(mm2, mm5); /* copy x2 */
+ psubw_m2r (*(dataptr + 15), mm7); /* tmp07 = x0 - x7 */
+ movq_r2r (mm3, mm4); /* copy x3 */
- psubw_m2r(*(dataptr+15), mm7); /* tmp07 = x0 - x7 */
- movq_r2r(mm3, mm4); /* copy x3 */
+ paddw_m2r (*(dataptr + 13), mm1); /* tmp01 = x1 + x6 */
- paddw_m2r(*(dataptr+13), mm1); /* tmp01 = x1 + x6 */
+ movq_r2m (mm7, tmp7); /* save tmp07 */
+ movq_r2r (mm0, mm7); /* copy tmp00 */
- movq_r2m(mm7, tmp7); /* save tmp07 */
- movq_r2r(mm0, mm7); /* copy tmp00 */
+ psubw_m2r (*(dataptr + 13), mm6); /* tmp06 = x1 - x6 */
- psubw_m2r(*(dataptr+13), mm6); /* tmp06 = x1 - x6 */
+ /* stage 2, Even Part */
- /* stage 2, Even Part */
+ paddw_m2r (*(dataptr + 9), mm3); /* tmp03 = x3 + x4 */
- paddw_m2r(*(dataptr+9), mm3); /* tmp03 = x3 + x4 */
+ movq_r2m (mm6, tmp6); /* save tmp07 */
+ movq_r2r (mm1, mm6); /* copy tmp01 */
- movq_r2m(mm6, tmp6); /* save tmp07 */
- movq_r2r(mm1, mm6); /* copy tmp01 */
+ paddw_m2r (*(dataptr + 11), mm2); /* tmp02 = x2 + x5 */
+ paddw_r2r (mm3, mm0); /* tmp10 = tmp00 + tmp03 */
- paddw_m2r(*(dataptr+11), mm2); /* tmp02 = x2 + x5 */
- paddw_r2r(mm3, mm0); /* tmp10 = tmp00 + tmp03 */
+ psubw_r2r (mm3, mm7); /* tmp13 = tmp00 - tmp03 */
- psubw_r2r(mm3, mm7); /* tmp13 = tmp00 - tmp03 */
+ psubw_m2r (*(dataptr + 9), mm4); /* tmp04 = x3 - x4 */
+ psubw_r2r (mm2, mm6); /* tmp12 = tmp01 - tmp02 */
- psubw_m2r(*(dataptr+9), mm4); /* tmp04 = x3 - x4 */
- psubw_r2r(mm2, mm6); /* tmp12 = tmp01 - tmp02 */
+ paddw_r2r (mm2, mm1); /* tmp11 = tmp01 + tmp02 */
- paddw_r2r(mm2, mm1); /* tmp11 = tmp01 + tmp02 */
+ psubw_m2r (*(dataptr + 11), mm5); /* tmp05 = x2 - x5 */
+ paddw_r2r (mm7, mm6); /* tmp12 + tmp13 */
- psubw_m2r(*(dataptr+11), mm5); /* tmp05 = x2 - x5 */
- paddw_r2r(mm7, mm6); /* tmp12 + tmp13 */
+ /* stage 3, Even and stage 4 & 5 even */
- /* stage 3, Even and stage 4 & 5 even */
+ movq_m2r (tmp6, mm2); /* load tmp6 */
+ movq_r2r (mm0, mm3); /* copy tmp10 */
- movq_m2r(tmp6, mm2); /* load tmp6 */
- movq_r2r(mm0, mm3); /* copy tmp10 */
+ psllw_i2r (2, mm6); /* shift z1 */
+ paddw_r2r (mm1, mm0); /* y0=tmp10 + tmp11 */
- psllw_i2r(2, mm6); /* shift z1 */
- paddw_r2r(mm1, mm0); /* y0=tmp10 + tmp11 */
+ pmulhw_m2r (RTjpeg_C4, mm6); /* z1 */
+ psubw_r2r (mm1, mm3); /* y4=tmp10 - tmp11 */
- pmulhw_m2r(RTjpeg_C4, mm6); /* z1 */
- psubw_r2r(mm1, mm3); /* y4=tmp10 - tmp11 */
+ movq_r2m (mm0, *(dataptr + 1)); /*save y0 */
+ movq_r2r (mm7, mm0); /* copy tmp13 */
- movq_r2m(mm0, *(dataptr+1)); /*save y0 */
- movq_r2r(mm7, mm0); /* copy tmp13 */
-
- /* odd part */
+ /* odd part */
- movq_r2m(mm3, *(dataptr+9)); /*save y4 */
- paddw_r2r(mm5, mm4); /* tmp10 = tmp4 + tmp5 */
+ movq_r2m (mm3, *(dataptr + 9)); /*save y4 */
+ paddw_r2r (mm5, mm4); /* tmp10 = tmp4 + tmp5 */
- movq_m2r(tmp7, mm3); /* load tmp7 */
- paddw_r2r(mm6, mm0); /* tmp32 = tmp13 + z1 */
+ movq_m2r (tmp7, mm3); /* load tmp7 */
+ paddw_r2r (mm6, mm0); /* tmp32 = tmp13 + z1 */
- paddw_r2r(mm2, mm5); /* tmp11 = tmp5 + tmp6 */
- psubw_r2r(mm6, mm7); /* tmp33 = tmp13 - z1 */
+ paddw_r2r (mm2, mm5); /* tmp11 = tmp5 + tmp6 */
+ psubw_r2r (mm6, mm7); /* tmp33 = tmp13 - z1 */
- movq_r2m(mm0, *(dataptr+5)); /*save y2 */
- paddw_r2r(mm3, mm2); /* tmp12 = tmp6 + tmp7 */
+ movq_r2m (mm0, *(dataptr + 5)); /*save y2 */
+ paddw_r2r (mm3, mm2); /* tmp12 = tmp6 + tmp7 */
- /* stage 4 */
+ /* stage 4 */
- movq_r2m(mm7, *(dataptr+13)); /*save y6 */
- movq_r2r(mm4, mm1); /* copy tmp10 */
+ movq_r2m (mm7, *(dataptr + 13)); /*save y6 */
+ movq_r2r (mm4, mm1); /* copy tmp10 */
- psubw_r2r(mm2, mm1); /* tmp10 - tmp12 */
- psllw_i2r(2, mm4); /* shift tmp10 */
+ psubw_r2r (mm2, mm1); /* tmp10 - tmp12 */
+ psllw_i2r (2, mm4); /* shift tmp10 */
- movq_m2r(RTjpeg_C2mC6, mm0); /* load C2mC6 */
- psllw_i2r(2, mm1); /* shift (tmp10-tmp12) */
+ movq_m2r (RTjpeg_C2mC6, mm0); /* load C2mC6 */
+ psllw_i2r (2, mm1); /* shift (tmp10-tmp12) */
- pmulhw_m2r(RTjpeg_C6, mm1); /* z5 */
- psllw_i2r(2, mm5); /* prepare for multiply */
+ pmulhw_m2r (RTjpeg_C6, mm1); /* z5 */
+ psllw_i2r (2, mm5); /* prepare for multiply */
- pmulhw_r2r(mm0, mm4); /* multiply by converted real */
+ pmulhw_r2r (mm0, mm4); /* multiply by converted real */
- /* stage 5 */
+ /* stage 5 */
- pmulhw_m2r(RTjpeg_C4, mm5); /* z3 */
- psllw_i2r(2, mm2); /* prepare for multiply */
+ pmulhw_m2r (RTjpeg_C4, mm5); /* z3 */
+ psllw_i2r (2, mm2); /* prepare for multiply */
- pmulhw_m2r(RTjpeg_C2pC6, mm2); /* multiply */
- movq_r2r(mm3, mm0); /* copy tmp7 */
+ pmulhw_m2r (RTjpeg_C2pC6, mm2); /* multiply */
+ movq_r2r (mm3, mm0); /* copy tmp7 */
- movq_m2r(*(dataptr+9), mm7); /* m03:m02|m01:m00 - first line (line 4)and copy into mm7 */
- paddw_r2r(mm1, mm4); /* z2 */
+ movq_m2r (*(dataptr + 9), mm7); /* m03:m02|m01:m00 - first line (line 4)and copy into mm7 */
+ paddw_r2r (mm1, mm4); /* z2 */
- paddw_r2r(mm5, mm0); /* z11 */
- psubw_r2r(mm5, mm3); /* z13 */
+ paddw_r2r (mm5, mm0); /* z11 */
+ psubw_r2r (mm5, mm3); /* z13 */
- /* stage 6 */
+ /* stage 6 */
- movq_r2r(mm3, mm5); /* copy z13 */
- paddw_r2r(mm1, mm2); /* z4 */
+ movq_r2r (mm3, mm5); /* copy z13 */
+ paddw_r2r (mm1, mm2); /* z4 */
- movq_r2r(mm0, mm6); /* copy z11 */
- psubw_r2r(mm4, mm5); /* y3 */
+ movq_r2r (mm0, mm6); /* copy z11 */
+ psubw_r2r (mm4, mm5); /* y3 */
- paddw_r2r(mm2, mm6); /* y1 */
- paddw_r2r(mm4, mm3); /* y5 */
+ paddw_r2r (mm2, mm6); /* y1 */
+ paddw_r2r (mm4, mm3); /* y5 */
- movq_r2m(mm5, *(dataptr+7)); /*save y3 */
- psubw_r2r(mm2, mm0); /* yè=z11 - z4 */
+ movq_r2m (mm5, *(dataptr + 7)); /*save y3 */
+ psubw_r2r (mm2, mm0); /* yè=z11 - z4 */
- movq_r2m(mm3, *(dataptr+11)); /*save y5 */
+ movq_r2m (mm3, *(dataptr + 11)); /*save y5 */
- movq_r2m(mm6, *(dataptr+3)); /*save y1 */
+ movq_r2m (mm6, *(dataptr + 3)); /*save y1 */
+
+ movq_r2m (mm0, *(dataptr + 15)); /*save y7 */
- movq_r2m(mm0, *(dataptr+15)); /*save y7 */
-
#endif
}
-#define FIX_1_082392200 ((__s32) 277) /* FIX(1.082392200) */
-#define FIX_1_414213562 ((__s32) 362) /* FIX(1.414213562) */
-#define FIX_1_847759065 ((__s32) 473) /* FIX(1.847759065) */
-#define FIX_2_613125930 ((__s32) 669) /* FIX(2.613125930) */
+#define FIX_1_082392200 ((__s32) 277) /* FIX(1.082392200) */
+#define FIX_1_414213562 ((__s32) 362) /* FIX(1.414213562) */
+#define FIX_1_847759065 ((__s32) 473) /* FIX(1.847759065) */
+#define FIX_2_613125930 ((__s32) 669) /* FIX(2.613125930) */
#define DESCALE(x) (__s16)( ((x)+4) >> 3)
#define RL(x) ((x)>235) ? 235 : (((x)<16) ? 16 : (x))
#define MULTIPLY(var,const) (((__s32) ((var) * (const)) + 128)>>8)
-void RTjpeg_idct_init(void)
+void
+RTjpeg_idct_init (void)
{
- int i;
-
- for(i=0; i<64; i++)
- {
- RTjpeg_liqt[i]=((__u64)RTjpeg_liqt[i]*RTjpeg_aan_tab[i])>>32;
- RTjpeg_ciqt[i]=((__u64)RTjpeg_ciqt[i]*RTjpeg_aan_tab[i])>>32;
- }
+ int i;
+
+ for (i = 0; i < 64; i++) {
+ RTjpeg_liqt[i] = ((__u64) RTjpeg_liqt[i] * RTjpeg_aan_tab[i]) >> 32;
+ RTjpeg_ciqt[i] = ((__u64) RTjpeg_ciqt[i] * RTjpeg_aan_tab[i]) >> 32;
+ }
}
-void RTjpeg_idct(__u8 *odata, __s16 *data, int rskip)
+void
+RTjpeg_idct (__u8 * odata, __s16 * data, int rskip)
{
#ifdef HAVE_LIBMMX
-static mmx_t fix_141 = (mmx_t)(long long)0x5a825a825a825a82LL;
-static mmx_t fix_184n261 = (mmx_t)(long long)0xcf04cf04cf04cf04LL;
-static mmx_t fix_184 = (mmx_t)(long long)0x7641764176417641LL;
-static mmx_t fix_n184 = (mmx_t)(long long)0x896f896f896f896fLL;
-static mmx_t fix_108n184 = (mmx_t)(long long)0xcf04cf04cf04cf04LL;
+ static mmx_t fix_141 = (mmx_t) (long long) 0x5a825a825a825a82LL;
+ static mmx_t fix_184n261 = (mmx_t) (long long) 0xcf04cf04cf04cf04LL;
+ static mmx_t fix_184 = (mmx_t) (long long) 0x7641764176417641LL;
+ static mmx_t fix_n184 = (mmx_t) (long long) 0x896f896f896f896fLL;
+ static mmx_t fix_108n184 = (mmx_t) (long long) 0xcf04cf04cf04cf04LL;
mmx_t workspace[64];
mmx_t *wsptr = workspace;
- register mmx_t *dataptr = (mmx_t *)odata;
- mmx_t *idata = (mmx_t *)data;
+ register mmx_t *dataptr = (mmx_t *) odata;
+ mmx_t *idata = (mmx_t *) data;
- rskip = rskip>>3;
+ rskip = rskip >> 3;
/*
* Perform inverse DCT on one block of coefficients.
*/
- /* Odd part */
+ /* Odd part */
+
+ movq_m2r (*(idata + 10), mm1); /* load idata[DCTSIZE*5] */
- movq_m2r(*(idata+10), mm1); /* load idata[DCTSIZE*5] */
+ movq_m2r (*(idata + 6), mm0); /* load idata[DCTSIZE*3] */
- movq_m2r(*(idata+6), mm0); /* load idata[DCTSIZE*3] */
+ movq_m2r (*(idata + 2), mm3); /* load idata[DCTSIZE*1] */
- movq_m2r(*(idata+2), mm3); /* load idata[DCTSIZE*1] */
+ movq_r2r (mm1, mm2); /* copy tmp6 : phase 6 */
+ */movq_m2r (*(idata + 14), mm4); /* load idata[DCTSIZE*7] */
- movq_r2r(mm1, mm2); /* copy tmp6 : phase 6 */ */
+ paddw_r2r (mm0, mm1); /* z13 = tmp6 + tmp5; */
- movq_m2r(*(idata+14), mm4); /* load idata[DCTSIZE*7] */
+ psubw_r2r (mm0, mm2); /* z10 = tmp6 - tmp5 */
- paddw_r2r(mm0, mm1); /* z13 = tmp6 + tmp5; */
+ psllw_i2r (2, mm2); /* shift z10 */
+ movq_r2r (mm2, mm0); /* copy z10 */
- psubw_r2r(mm0, mm2); /* z10 = tmp6 - tmp5 */
+ pmulhw_m2r (fix_184n261, mm2); /* MULTIPLY( z12, FIX_1_847759065); : 2*c2 */
+ movq_r2r (mm3, mm5); /* copy tmp4 */
- psllw_i2r(2, mm2); /* shift z10 */
- movq_r2r(mm2, mm0); /* copy z10 */
+ pmulhw_m2r (fix_n184, mm0); /* MULTIPLY(z10, -FIX_1_847759065); : 2*c2 */
+ paddw_r2r (mm4, mm3); /* z11 = tmp4 + tmp7; */
- pmulhw_m2r(fix_184n261, mm2); /* MULTIPLY( z12, FIX_1_847759065); : 2*c2 */
- movq_r2r(mm3, mm5); /* copy tmp4 */
+ movq_r2r (mm3, mm6); /* copy z11 : phase 5 */
+ psubw_r2r (mm4, mm5); /* z12 = tmp4 - tmp7; */
- pmulhw_m2r(fix_n184, mm0); /* MULTIPLY(z10, -FIX_1_847759065); : 2*c2 */
- paddw_r2r(mm4, mm3); /* z11 = tmp4 + tmp7; */
+ psubw_r2r (mm1, mm6); /* z11-z13 */
+ psllw_i2r (2, mm5); /* shift z12 */
- movq_r2r(mm3, mm6); /* copy z11 : phase 5 */
- psubw_r2r(mm4, mm5); /* z12 = tmp4 - tmp7; */
+ movq_m2r (*(idata + 12), mm4); /* load idata[DCTSIZE*6], even part */
+ movq_r2r (mm5, mm7); /* copy z12 */
- psubw_r2r(mm1, mm6); /* z11-z13 */
- psllw_i2r(2, mm5); /* shift z12 */
+ pmulhw_m2r (fix_108n184, mm5); /* MULT(z12, (FIX_1_08-FIX_1_84)) //- z5; 2*(c2-c6): even part */
+ paddw_r2r (mm1, mm3); /* tmp7 = z11 + z13; */
- movq_m2r(*(idata+12), mm4); /* load idata[DCTSIZE*6], even part */
- movq_r2r(mm5, mm7); /* copy z12 */
+ /*ok */
- pmulhw_m2r(fix_108n184, mm5); /* MULT(z12, (FIX_1_08-FIX_1_84)) //- z5; 2*(c2-c6): even part */
- paddw_r2r(mm1, mm3); /* tmp7 = z11 + z13; */
+ /* Even part */
+ pmulhw_m2r (fix_184, mm7); /* MULTIPLY(z10,(FIX_1_847759065 - FIX_2_613125930)) //+ z5; -2*(c2+c6) */
+ psllw_i2r (2, mm6);
- /*ok */
+ movq_m2r (*(idata + 4), mm1); /* load idata[DCTSIZE*2] */
- /* Even part */
- pmulhw_m2r(fix_184, mm7); /* MULTIPLY(z10,(FIX_1_847759065 - FIX_2_613125930)) //+ z5; -2*(c2+c6) */
- psllw_i2r(2, mm6);
+ paddw_r2r (mm5, mm0); /* tmp10 */
- movq_m2r(*(idata+4), mm1); /* load idata[DCTSIZE*2] */
+ paddw_r2r (mm7, mm2); /* tmp12 */
- paddw_r2r(mm5, mm0); /* tmp10 */
+ pmulhw_m2r (fix_141, mm6); /* tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); 2*c4 */
+ psubw_r2r (mm3, mm2); /* tmp6 = tmp12 - tmp7 */
- paddw_r2r(mm7, mm2); /* tmp12 */
+ movq_r2r (mm1, mm5); /* copy tmp1 */
+ paddw_r2r (mm4, mm1); /* tmp13= tmp1 + tmp3; phases 5-3 */
- pmulhw_m2r(fix_141, mm6); /* tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); 2*c4 */
- psubw_r2r(mm3, mm2); /* tmp6 = tmp12 - tmp7 */
+ psubw_r2r (mm4, mm5); /* tmp1-tmp3 */
+ psubw_r2r (mm2, mm6); /* tmp5 = tmp11 - tmp6; */
- movq_r2r(mm1, mm5); /* copy tmp1 */
- paddw_r2r(mm4, mm1); /* tmp13= tmp1 + tmp3; phases 5-3 */
+ movq_r2m (mm1, *(wsptr)); /* save tmp13 in workspace */
+ psllw_i2r (2, mm5); /* shift tmp1-tmp3 */
- psubw_r2r(mm4, mm5); /* tmp1-tmp3 */
- psubw_r2r(mm2, mm6); /* tmp5 = tmp11 - tmp6; */
+ movq_m2r (*(idata), mm7); /* load idata[DCTSIZE*0] */
- movq_r2m(mm1, *(wsptr)); /* save tmp13 in workspace */
- psllw_i2r(2, mm5); /* shift tmp1-tmp3 */
-
- movq_m2r(*(idata), mm7); /* load idata[DCTSIZE*0] */
+ pmulhw_m2r (fix_141, mm5); /* MULTIPLY(tmp1 - tmp3, FIX_1_414213562) */
+ paddw_r2r (mm6, mm0); /* tmp4 = tmp10 + tmp5; */
- pmulhw_m2r(fix_141, mm5); /* MULTIPLY(tmp1 - tmp3, FIX_1_414213562) */
- paddw_r2r(mm6, mm0); /* tmp4 = tmp10 + tmp5; */
+ movq_m2r (*(idata + 8), mm4); /* load idata[DCTSIZE*4] */
- movq_m2r(*(idata+8), mm4); /* load idata[DCTSIZE*4] */
-
- psubw_r2r(mm1, mm5); /* tmp12 = MULTIPLY(tmp1 - tmp3, FIX_1_414213562) - tmp13; 2*c4 */
+ psubw_r2r (mm1, mm5); /* tmp12 = MULTIPLY(tmp1 - tmp3, FIX_1_414213562) - tmp13; 2*c4 */
- movq_r2m(mm0, *(wsptr+4)); /* save tmp4 in workspace */
- movq_r2r(mm7, mm1); /* copy tmp0 : phase 3 */
+ movq_r2m (mm0, *(wsptr + 4)); /* save tmp4 in workspace */
+ movq_r2r (mm7, mm1); /* copy tmp0 : phase 3 */
- movq_r2m(mm5, *(wsptr+2)); /* save tmp12 in workspace */
- psubw_r2r(mm4, mm1); /* tmp11 = tmp0 - tmp2; */
+ movq_r2m (mm5, *(wsptr + 2)); /* save tmp12 in workspace */
+ psubw_r2r (mm4, mm1); /* tmp11 = tmp0 - tmp2; */
- paddw_r2r(mm4, mm7); /* tmp10 = tmp0 + tmp2; */
- movq_r2r(mm1, mm5); /* copy tmp11 */
-
- paddw_m2r(*(wsptr+2), mm1); /* tmp1 = tmp11 + tmp12; */
- movq_r2r(mm7, mm4); /* copy tmp10 : phase 2 */
+ paddw_r2r (mm4, mm7); /* tmp10 = tmp0 + tmp2; */
+ movq_r2r (mm1, mm5); /* copy tmp11 */
- paddw_m2r(*(wsptr), mm7); /* tmp0 = tmp10 + tmp13; */
+ paddw_m2r (*(wsptr + 2), mm1); /* tmp1 = tmp11 + tmp12; */
+ movq_r2r (mm7, mm4); /* copy tmp10 : phase 2 */
- psubw_m2r(*(wsptr), mm4); /* tmp3 = tmp10 - tmp13; */
- movq_r2r(mm7, mm0); /* copy tmp0 */
+ paddw_m2r (*(wsptr), mm7); /* tmp0 = tmp10 + tmp13; */
- psubw_m2r(*(wsptr+2), mm5); /* tmp2 = tmp11 - tmp12; */
- paddw_r2r(mm3, mm7); /* wsptr[DCTSIZE*0] = (int) (tmp0 + tmp7); */
-
- psubw_r2r(mm3, mm0); /* wsptr[DCTSIZE*7] = (int) (tmp0 - tmp7); */
+ psubw_m2r (*(wsptr), mm4); /* tmp3 = tmp10 - tmp13; */
+ movq_r2r (mm7, mm0); /* copy tmp0 */
- movq_r2m(mm7, *(wsptr)); /* wsptr[DCTSIZE*0] */
- movq_r2r(mm1, mm3); /* copy tmp1 */
+ psubw_m2r (*(wsptr + 2), mm5); /* tmp2 = tmp11 - tmp12; */
+ paddw_r2r (mm3, mm7); /* wsptr[DCTSIZE*0] = (int) (tmp0 + tmp7); */
- movq_r2m(mm0, *(wsptr+14)); /* wsptr[DCTSIZE*7] */
- paddw_r2r(mm2, mm1); /* wsptr[DCTSIZE*1] = (int) (tmp1 + tmp6); */
+ psubw_r2r (mm3, mm0); /* wsptr[DCTSIZE*7] = (int) (tmp0 - tmp7); */
- psubw_r2r(mm2, mm3); /* wsptr[DCTSIZE*6] = (int) (tmp1 - tmp6); */
+ movq_r2m (mm7, *(wsptr)); /* wsptr[DCTSIZE*0] */
+ movq_r2r (mm1, mm3); /* copy tmp1 */
- movq_r2m(mm1, *(wsptr+2)); /* wsptr[DCTSIZE*1] */
- movq_r2r(mm4, mm1); /* copy tmp3 */
+ movq_r2m (mm0, *(wsptr + 14)); /* wsptr[DCTSIZE*7] */
+ paddw_r2r (mm2, mm1); /* wsptr[DCTSIZE*1] = (int) (tmp1 + tmp6); */
- movq_r2m(mm3, *(wsptr+12)); /* wsptr[DCTSIZE*6] */
+ psubw_r2r (mm2, mm3); /* wsptr[DCTSIZE*6] = (int) (tmp1 - tmp6); */
- paddw_m2r(*(wsptr+4), mm4); /* wsptr[DCTSIZE*4] = (int) (tmp3 + tmp4); */
+ movq_r2m (mm1, *(wsptr + 2)); /* wsptr[DCTSIZE*1] */
+ movq_r2r (mm4, mm1); /* copy tmp3 */
- psubw_m2r(*(wsptr+4), mm1); /* wsptr[DCTSIZE*3] = (int) (tmp3 - tmp4); */
+ movq_r2m (mm3, *(wsptr + 12)); /* wsptr[DCTSIZE*6] */
- movq_r2m(mm4, *(wsptr+8));
- movq_r2r(mm5, mm7); /* copy tmp2 */
+ paddw_m2r (*(wsptr + 4), mm4); /* wsptr[DCTSIZE*4] = (int) (tmp3 + tmp4); */
- paddw_r2r(mm6, mm5); /* wsptr[DCTSIZE*2] = (int) (tmp2 + tmp5) */
+ psubw_m2r (*(wsptr + 4), mm1); /* wsptr[DCTSIZE*3] = (int) (tmp3 - tmp4); */
- movq_r2m(mm1, *(wsptr+6));
- psubw_r2r(mm6, mm7); /* wsptr[DCTSIZE*5] = (int) (tmp2 - tmp5); */
+ movq_r2m (mm4, *(wsptr + 8));
+ movq_r2r (mm5, mm7); /* copy tmp2 */
- movq_r2m(mm5, *(wsptr+4));
+ paddw_r2r (mm6, mm5); /* wsptr[DCTSIZE*2] = (int) (tmp2 + tmp5) */
- movq_r2m(mm7, *(wsptr+10));
+ movq_r2m (mm1, *(wsptr + 6));
+ psubw_r2r (mm6, mm7); /* wsptr[DCTSIZE*5] = (int) (tmp2 - tmp5); */
- /*ok */
+ movq_r2m (mm5, *(wsptr + 4));
+
+ movq_r2m (mm7, *(wsptr + 10));
+
+ /*ok */
/*****************************************************************/
- idata++;
- wsptr++;
+ idata++;
+ wsptr++;
/*****************************************************************/
- movq_m2r(*(idata+10), mm1); /* load idata[DCTSIZE*5] */
+ movq_m2r (*(idata + 10), mm1); /* load idata[DCTSIZE*5] */
+
+ movq_m2r (*(idata + 6), mm0); /* load idata[DCTSIZE*3] */
+
+ movq_m2r (*(idata + 2), mm3); /* load idata[DCTSIZE*1] */
+ movq_r2r (mm1, mm2); /* copy tmp6 : phase 6 */
+ */movq_m2r (*(idata + 14), mm4); /* load idata[DCTSIZE*7] */
+ paddw_r2r (mm0, mm1); /* z13 = tmp6 + tmp5; */
- movq_m2r(*(idata+6), mm0); /* load idata[DCTSIZE*3] */
+ psubw_r2r (mm0, mm2); /* z10 = tmp6 - tmp5 */
- movq_m2r(*(idata+2), mm3); /* load idata[DCTSIZE*1] */
- movq_r2r(mm1, mm2); /* copy tmp6 : phase 6 */ */
+ psllw_i2r (2, mm2); /* shift z10 */
+ movq_r2r (mm2, mm0); /* copy z10 */
- movq_m2r(*(idata+14), mm4); /* load idata[DCTSIZE*7] */
- paddw_r2r(mm0, mm1); /* z13 = tmp6 + tmp5; */
+ pmulhw_m2r (fix_184n261, mm2); /* MULTIPLY( z12, FIX_1_847759065); : 2*c2 */
+ movq_r2r (mm3, mm5); /* copy tmp4 */
- psubw_r2r(mm0, mm2); /* z10 = tmp6 - tmp5 */
+ pmulhw_m2r (fix_n184, mm0); /* MULTIPLY(z10, -FIX_1_847759065); : 2*c2 */
+ paddw_r2r (mm4, mm3); /* z11 = tmp4 + tmp7; */
- psllw_i2r(2, mm2); /* shift z10 */
- movq_r2r(mm2, mm0); /* copy z10 */
+ movq_r2r (mm3, mm6); /* copy z11 : phase 5 */
+ psubw_r2r (mm4, mm5); /* z12 = tmp4 - tmp7; */
- pmulhw_m2r(fix_184n261, mm2); /* MULTIPLY( z12, FIX_1_847759065); : 2*c2 */
- movq_r2r(mm3, mm5); /* copy tmp4 */
+ psubw_r2r (mm1, mm6); /* z11-z13 */
+ psllw_i2r (2, mm5); /* shift z12 */
- pmulhw_m2r(fix_n184, mm0); /* MULTIPLY(z10, -FIX_1_847759065); : 2*c2 */
- paddw_r2r(mm4, mm3); /* z11 = tmp4 + tmp7; */
+ movq_m2r (*(idata + 12), mm4); /* load idata[DCTSIZE*6], even part */
+ movq_r2r (mm5, mm7); /* copy z12 */
- movq_r2r(mm3, mm6); /* copy z11 : phase 5 */
- psubw_r2r(mm4, mm5); /* z12 = tmp4 - tmp7; */
+ pmulhw_m2r (fix_108n184, mm5); /* MULT(z12, (FIX_1_08-FIX_1_84)) //- z5; 2*(c2-c6) even part */
+ paddw_r2r (mm1, mm3); /* tmp7 = z11 + z13; */
- psubw_r2r(mm1, mm6); /* z11-z13 */
- psllw_i2r(2, mm5); /* shift z12 */
+ /*ok */
- movq_m2r(*(idata+12), mm4); /* load idata[DCTSIZE*6], even part */
- movq_r2r(mm5, mm7); /* copy z12 */
+ /* Even part */
+ pmulhw_m2r (fix_184, mm7); /* MULTIPLY(z10,(FIX_1_847759065 - FIX_2_613125930)) //+ z5; -2*(c2+c6) */
+ psllw_i2r (2, mm6);
- pmulhw_m2r(fix_108n184, mm5); /* MULT(z12, (FIX_1_08-FIX_1_84)) //- z5; 2*(c2-c6) even part */
- paddw_r2r(mm1, mm3); /* tmp7 = z11 + z13; */
+ movq_m2r (*(idata + 4), mm1); /* load idata[DCTSIZE*2] */
- /*ok */
+ paddw_r2r (mm5, mm0); /* tmp10 */
- /* Even part */
- pmulhw_m2r(fix_184, mm7); /* MULTIPLY(z10,(FIX_1_847759065 - FIX_2_613125930)) //+ z5; -2*(c2+c6) */
- psllw_i2r(2, mm6);
+ paddw_r2r (mm7, mm2); /* tmp12 */
- movq_m2r(*(idata+4), mm1); /* load idata[DCTSIZE*2] */
+ pmulhw_m2r (fix_141, mm6); /* tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); 2*c4 */
+ psubw_r2r (mm3, mm2); /* tmp6 = tmp12 - tmp7 */
- paddw_r2r(mm5, mm0); /* tmp10 */
+ movq_r2r (mm1, mm5); /* copy tmp1 */
+ paddw_r2r (mm4, mm1); /* tmp13= tmp1 + tmp3; phases 5-3 */
- paddw_r2r(mm7, mm2); /* tmp12 */
+ psubw_r2r (mm4, mm5); /* tmp1-tmp3 */
+ psubw_r2r (mm2, mm6); /* tmp5 = tmp11 - tmp6; */
- pmulhw_m2r(fix_141, mm6); /* tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); 2*c4 */
- psubw_r2r(mm3, mm2); /* tmp6 = tmp12 - tmp7 */
+ movq_r2m (mm1, *(wsptr)); /* save tmp13 in workspace */
+ psllw_i2r (2, mm5); /* shift tmp1-tmp3 */
- movq_r2r(mm1, mm5); /* copy tmp1 */
- paddw_r2r(mm4, mm1); /* tmp13= tmp1 + tmp3; phases 5-3 */
+ movq_m2r (*(idata), mm7); /* load idata[DCTSIZE*0] */
+ paddw_r2r (mm6, mm0); /* tmp4 = tmp10 + tmp5; */
- psubw_r2r(mm4, mm5); /* tmp1-tmp3 */
- psubw_r2r(mm2, mm6); /* tmp5 = tmp11 - tmp6; */
+ pmulhw_m2r (fix_141, mm5); /* MULTIPLY(tmp1 - tmp3, FIX_1_414213562) */
- movq_r2m(mm1, *(wsptr)); /* save tmp13 in workspace */
- psllw_i2r(2, mm5); /* shift tmp1-tmp3 */
-
- movq_m2r(*(idata), mm7); /* load idata[DCTSIZE*0] */
- paddw_r2r(mm6, mm0); /* tmp4 = tmp10 + tmp5; */
+ movq_m2r (*(idata + 8), mm4); /* load idata[DCTSIZE*4] */
- pmulhw_m2r(fix_141, mm5); /* MULTIPLY(tmp1 - tmp3, FIX_1_414213562) */
+ psubw_r2r (mm1, mm5); /* tmp12 = MULTIPLY(tmp1 - tmp3, FIX_1_414213562) - tmp13; 2*c4 */
- movq_m2r(*(idata+8), mm4); /* load idata[DCTSIZE*4] */
-
- psubw_r2r(mm1, mm5); /* tmp12 = MULTIPLY(tmp1 - tmp3, FIX_1_414213562) - tmp13; 2*c4 */
+ movq_r2m (mm0, *(wsptr + 4)); /* save tmp4 in workspace */
+ movq_r2r (mm7, mm1); /* copy tmp0: phase 3 */
- movq_r2m(mm0, *(wsptr+4)); /* save tmp4 in workspace */
- movq_r2r(mm7, mm1); /* copy tmp0: phase 3 */
+ movq_r2m (mm5, *(wsptr + 2)); /* save tmp12 in workspace */
+ psubw_r2r (mm4, mm1); /* tmp11 = tmp0 - tmp2; */
- movq_r2m(mm5, *(wsptr+2)); /* save tmp12 in workspace */
- psubw_r2r(mm4, mm1); /* tmp11 = tmp0 - tmp2; */
+ paddw_r2r (mm4, mm7); /* tmp10 = tmp0 + tmp2; */
+ movq_r2r (mm1, mm5); /* copy tmp11 */
- paddw_r2r(mm4, mm7); /* tmp10 = tmp0 + tmp2; */
- movq_r2r(mm1, mm5); /* copy tmp11 */
-
- paddw_m2r(*(wsptr+2), mm1); /* tmp1 = tmp11 + tmp12; */
- movq_r2r(mm7, mm4); /* copy tmp10: phase 2 */
+ paddw_m2r (*(wsptr + 2), mm1); /* tmp1 = tmp11 + tmp12; */
+ movq_r2r (mm7, mm4); /* copy tmp10: phase 2 */
- paddw_m2r(*(wsptr), mm7); /* tmp0 = tmp10 + tmp13; */
+ paddw_m2r (*(wsptr), mm7); /* tmp0 = tmp10 + tmp13; */
- psubw_m2r(*(wsptr), mm4); /* tmp3 = tmp10 - tmp13; */
- movq_r2r(mm7, mm0); /* copy tmp0 */
+ psubw_m2r (*(wsptr), mm4); /* tmp3 = tmp10 - tmp13; */
+ movq_r2r (mm7, mm0); /* copy tmp0 */
- psubw_m2r(*(wsptr+2), mm5); /* tmp2 = tmp11 - tmp12; */
- paddw_r2r(mm3, mm7); /* wsptr[DCTSIZE*0] = (int) (tmp0 + tmp7); */
-
- psubw_r2r(mm3, mm0); /* wsptr[DCTSIZE*7] = (int) (tmp0 - tmp7); */
+ psubw_m2r (*(wsptr + 2), mm5); /* tmp2 = tmp11 - tmp12; */
+ paddw_r2r (mm3, mm7); /* wsptr[DCTSIZE*0] = (int) (tmp0 + tmp7); */
- movq_r2m(mm7, *(wsptr)); /* wsptr[DCTSIZE*0] */
- movq_r2r(mm1, mm3); /* copy tmp1 */
+ psubw_r2r (mm3, mm0); /* wsptr[DCTSIZE*7] = (int) (tmp0 - tmp7); */
- movq_r2m(mm0, *(wsptr+14)); /* wsptr[DCTSIZE*7] */
- paddw_r2r(mm2, mm1); /* wsptr[DCTSIZE*1] = (int) (tmp1 + tmp6); */
+ movq_r2m (mm7, *(wsptr)); /* wsptr[DCTSIZE*0] */
+ movq_r2r (mm1, mm3); /* copy tmp1 */
- psubw_r2r(mm2, mm3); /* wsptr[DCTSIZE*6] = (int) (tmp1 - tmp6); */
+ movq_r2m (mm0, *(wsptr + 14)); /* wsptr[DCTSIZE*7] */
+ paddw_r2r (mm2, mm1); /* wsptr[DCTSIZE*1] = (int) (tmp1 + tmp6); */
- movq_r2m(mm1, *(wsptr+2)); /* wsptr[DCTSIZE*1] */
- movq_r2r(mm4, mm1); /* copy tmp3 */
+ psubw_r2r (mm2, mm3); /* wsptr[DCTSIZE*6] = (int) (tmp1 - tmp6); */
- movq_r2m(mm3, *(wsptr+12)); /* wsptr[DCTSIZE*6] */
+ movq_r2m (mm1, *(wsptr + 2)); /* wsptr[DCTSIZE*1] */
+ movq_r2r (mm4, mm1); /* copy tmp3 */
- paddw_m2r(*(wsptr+4), mm4); /* wsptr[DCTSIZE*4] = (int) (tmp3 + tmp4); */
+ movq_r2m (mm3, *(wsptr + 12)); /* wsptr[DCTSIZE*6] */
- psubw_m2r(*(wsptr+4), mm1); /* wsptr[DCTSIZE*3] = (int) (tmp3 - tmp4); */
+ paddw_m2r (*(wsptr + 4), mm4); /* wsptr[DCTSIZE*4] = (int) (tmp3 + tmp4); */
- movq_r2m(mm4, *(wsptr+8));
- movq_r2r(mm5, mm7); /* copy tmp2 */
+ psubw_m2r (*(wsptr + 4), mm1); /* wsptr[DCTSIZE*3] = (int) (tmp3 - tmp4); */
- paddw_r2r(mm6, mm5); /* wsptr[DCTSIZE*2] = (int) (tmp2 + tmp5) */
+ movq_r2m (mm4, *(wsptr + 8));
+ movq_r2r (mm5, mm7); /* copy tmp2 */
- movq_r2m(mm1, *(wsptr+6));
- psubw_r2r(mm6, mm7); /* wsptr[DCTSIZE*5] = (int) (tmp2 - tmp5); */
+ paddw_r2r (mm6, mm5); /* wsptr[DCTSIZE*2] = (int) (tmp2 + tmp5) */
- movq_r2m(mm5, *(wsptr+4));
+ movq_r2m (mm1, *(wsptr + 6));
+ psubw_r2r (mm6, mm7); /* wsptr[DCTSIZE*5] = (int) (tmp2 - tmp5); */
- movq_r2m(mm7, *(wsptr+10));
+ movq_r2m (mm5, *(wsptr + 4));
+
+ movq_r2m (mm7, *(wsptr + 10));
/*****************************************************************/
/* and also undo the PASS1_BITS scaling. */
/*****************************************************************/
- /* Even part */
+ /* Even part */
- wsptr--;
+ wsptr--;
/* tmp10 = ((DCTELEM) wsptr[0] + (DCTELEM) wsptr[4]); */
/* tmp13 = ((DCTELEM) wsptr[2] + (DCTELEM) wsptr[6]); */
/* tmp11 = ((DCTELEM) wsptr[0] - (DCTELEM) wsptr[4]); */
/* tmp14 = ((DCTELEM) wsptr[2] - (DCTELEM) wsptr[6]); */
- movq_m2r(*(wsptr), mm0); /* wsptr[0,0],[0,1],[0,2],[0,3] */
+ movq_m2r (*(wsptr), mm0); /* wsptr[0,0],[0,1],[0,2],[0,3] */
+
+ movq_m2r (*(wsptr + 1), mm1); /* wsptr[0,4],[0,5],[0,6],[0,7] */
+ movq_r2r (mm0, mm2);
+
+ movq_m2r (*(wsptr + 2), mm3); /* wsptr[1,0],[1,1],[1,2],[1,3] */
+ paddw_r2r (mm1, mm0); /* wsptr[0,tmp10],[xxx],[0,tmp13],[xxx] */
+
+ movq_m2r (*(wsptr + 3), mm4); /* wsptr[1,4],[1,5],[1,6],[1,7] */
+ psubw_r2r (mm1, mm2); /* wsptr[0,tmp11],[xxx],[0,tmp14],[xxx] */
- movq_m2r(*(wsptr+1), mm1); /* wsptr[0,4],[0,5],[0,6],[0,7] */
- movq_r2r(mm0, mm2);
-
- movq_m2r(*(wsptr+2), mm3); /* wsptr[1,0],[1,1],[1,2],[1,3] */
- paddw_r2r(mm1, mm0); /* wsptr[0,tmp10],[xxx],[0,tmp13],[xxx] */
+ movq_r2r (mm0, mm6);
+ movq_r2r (mm3, mm5);
- movq_m2r(*(wsptr+3), mm4); /* wsptr[1,4],[1,5],[1,6],[1,7] */
- psubw_r2r(mm1, mm2); /* wsptr[0,tmp11],[xxx],[0,tmp14],[xxx] */
+ paddw_r2r (mm4, mm3); /* wsptr[1,tmp10],[xxx],[1,tmp13],[xxx] */
+ movq_r2r (mm2, mm1);
- movq_r2r(mm0, mm6);
- movq_r2r(mm3, mm5);
-
- paddw_r2r(mm4, mm3); /* wsptr[1,tmp10],[xxx],[1,tmp13],[xxx] */
- movq_r2r(mm2, mm1);
+ psubw_r2r (mm4, mm5); /* wsptr[1,tmp11],[xxx],[1,tmp14],[xxx] */
+ punpcklwd_r2r (mm3, mm0); /* wsptr[0,tmp10],[1,tmp10],[xxx],[xxx] */
- psubw_r2r(mm4, mm5); /* wsptr[1,tmp11],[xxx],[1,tmp14],[xxx] */
- punpcklwd_r2r(mm3, mm0); /* wsptr[0,tmp10],[1,tmp10],[xxx],[xxx] */
+ movq_m2r (*(wsptr + 7), mm7); /* wsptr[3,4],[3,5],[3,6],[3,7] */
+ punpckhwd_r2r (mm3, mm6); /* wsptr[0,tmp13],[1,tmp13],[xxx],[xxx] */
- movq_m2r(*(wsptr+7), mm7); /* wsptr[3,4],[3,5],[3,6],[3,7] */
- punpckhwd_r2r(mm3, mm6); /* wsptr[0,tmp13],[1,tmp13],[xxx],[xxx] */
+ movq_m2r (*(wsptr + 4), mm3); /* wsptr[2,0],[2,1],[2,2],[2,3] */
+ punpckldq_r2r (mm6, mm0); /* wsptr[0,tmp10],[1,tmp10],[0,tmp13],[1,tmp13] */
- movq_m2r(*(wsptr+4), mm3); /* wsptr[2,0],[2,1],[2,2],[2,3] */
- punpckldq_r2r(mm6, mm0); /* wsptr[0,tmp10],[1,tmp10],[0,tmp13],[1,tmp13] */
+ punpcklwd_r2r (mm5, mm1); /* wsptr[0,tmp11],[1,tmp11],[xxx],[xxx] */
+ movq_r2r (mm3, mm4);
- punpcklwd_r2r(mm5, mm1); /* wsptr[0,tmp11],[1,tmp11],[xxx],[xxx] */
- movq_r2r(mm3, mm4);
+ movq_m2r (*(wsptr + 6), mm6); /* wsptr[3,0],[3,1],[3,2],[3,3] */
+ punpckhwd_r2r (mm5, mm2); /* wsptr[0,tmp14],[1,tmp14],[xxx],[xxx] */
- movq_m2r(*(wsptr+6), mm6); /* wsptr[3,0],[3,1],[3,2],[3,3] */
- punpckhwd_r2r(mm5, mm2); /* wsptr[0,tmp14],[1,tmp14],[xxx],[xxx] */
+ movq_m2r (*(wsptr + 5), mm5); /* wsptr[2,4],[2,5],[2,6],[2,7] */
+ punpckldq_r2r (mm2, mm1); /* wsptr[0,tmp11],[1,tmp11],[0,tmp14],[1,tmp14] */
- movq_m2r(*(wsptr+5), mm5); /* wsptr[2,4],[2,5],[2,6],[2,7] */
- punpckldq_r2r(mm2, mm1); /* wsptr[0,tmp11],[1,tmp11],[0,tmp14],[1,tmp14] */
-
- paddw_r2r(mm5, mm3); /* wsptr[2,tmp10],[xxx],[2,tmp13],[xxx] */
- movq_r2r(mm6, mm2);
+ paddw_r2r (mm5, mm3); /* wsptr[2,tmp10],[xxx],[2,tmp13],[xxx] */
+ movq_r2r (mm6, mm2);
- psubw_r2r(mm5, mm4); /* wsptr[2,tmp11],[xxx],[2,tmp14],[xxx] */
- paddw_r2r(mm7, mm6); /* wsptr[3,tmp10],[xxx],[3,tmp13],[xxx] */
+ psubw_r2r (mm5, mm4); /* wsptr[2,tmp11],[xxx],[2,tmp14],[xxx] */
+ paddw_r2r (mm7, mm6); /* wsptr[3,tmp10],[xxx],[3,tmp13],[xxx] */
- movq_r2r(mm3, mm5);
- punpcklwd_r2r(mm6, mm3); /* wsptr[2,tmp10],[3,tmp10],[xxx],[xxx] */
-
- psubw_r2r(mm7, mm2); /* wsptr[3,tmp11],[xxx],[3,tmp14],[xxx] */
- punpckhwd_r2r(mm6, mm5); /* wsptr[2,tmp13],[3,tmp13],[xxx],[xxx] */
+ movq_r2r (mm3, mm5);
+ punpcklwd_r2r (mm6, mm3); /* wsptr[2,tmp10],[3,tmp10],[xxx],[xxx] */
- movq_r2r(mm4, mm7);
- punpckldq_r2r(mm5, mm3); /* wsptr[2,tmp10],[3,tmp10],[2,tmp13],[3,tmp13] */
-
- punpcklwd_r2r(mm2, mm4); /* wsptr[2,tmp11],[3,tmp11],[xxx],[xxx] */
+ psubw_r2r (mm7, mm2); /* wsptr[3,tmp11],[xxx],[3,tmp14],[xxx] */
+ punpckhwd_r2r (mm6, mm5); /* wsptr[2,tmp13],[3,tmp13],[xxx],[xxx] */
- punpckhwd_r2r(mm2, mm7); /* wsptr[2,tmp14],[3,tmp14],[xxx],[xxx] */
+ movq_r2r (mm4, mm7);
+ punpckldq_r2r (mm5, mm3); /* wsptr[2,tmp10],[3,tmp10],[2,tmp13],[3,tmp13] */
- punpckldq_r2r(mm7, mm4); /* wsptr[2,tmp11],[3,tmp11],[2,tmp14],[3,tmp14] */
- movq_r2r(mm1, mm6);
+ punpcklwd_r2r (mm2, mm4); /* wsptr[2,tmp11],[3,tmp11],[xxx],[xxx] */
- /*ok */
+ punpckhwd_r2r (mm2, mm7); /* wsptr[2,tmp14],[3,tmp14],[xxx],[xxx] */
+
+ punpckldq_r2r (mm7, mm4); /* wsptr[2,tmp11],[3,tmp11],[2,tmp14],[3,tmp14] */
+ movq_r2r (mm1, mm6);
+
+ /*ok */
/* mm0 = ;wsptr[0,tmp10],[1,tmp10],[0,tmp13],[1,tmp13] */
/* mm1 = ;wsptr[0,tmp11],[1,tmp11],[0,tmp14],[1,tmp14] */
- movq_r2r(mm0, mm2);
- punpckhdq_r2r(mm4, mm6); /* wsptr[0,tmp14],[1,tmp14],[2,tmp14],[3,tmp14] */
+ movq_r2r (mm0, mm2);
+ punpckhdq_r2r (mm4, mm6); /* wsptr[0,tmp14],[1,tmp14],[2,tmp14],[3,tmp14] */
- punpckldq_r2r(mm4, mm1); /* wsptr[0,tmp11],[1,tmp11],[2,tmp11],[3,tmp11] */
- psllw_i2r(2, mm6);
+ punpckldq_r2r (mm4, mm1); /* wsptr[0,tmp11],[1,tmp11],[2,tmp11],[3,tmp11] */
+ psllw_i2r (2, mm6);
- pmulhw_m2r(fix_141, mm6);
- punpckldq_r2r(mm3, mm0); /* wsptr[0,tmp10],[1,tmp10],[2,tmp10],[3,tmp10] */
+ pmulhw_m2r (fix_141, mm6);
+ punpckldq_r2r (mm3, mm0); /* wsptr[0,tmp10],[1,tmp10],[2,tmp10],[3,tmp10] */
- punpckhdq_r2r(mm3, mm2); /* wsptr[0,tmp13],[1,tmp13],[2,tmp13],[3,tmp13] */
- movq_r2r(mm0, mm7);
+ punpckhdq_r2r (mm3, mm2); /* wsptr[0,tmp13],[1,tmp13],[2,tmp13],[3,tmp13] */
+ movq_r2r (mm0, mm7);
/* tmp0 = tmp10 + tmp13; */
/* tmp3 = tmp10 - tmp13; */
- paddw_r2r(mm2, mm0); /* [0,tmp0],[1,tmp0],[2,tmp0],[3,tmp0] */
- psubw_r2r(mm2, mm7); /* [0,tmp3],[1,tmp3],[2,tmp3],[3,tmp3] */
+ paddw_r2r (mm2, mm0); /* [0,tmp0],[1,tmp0],[2,tmp0],[3,tmp0] */
+ psubw_r2r (mm2, mm7); /* [0,tmp3],[1,tmp3],[2,tmp3],[3,tmp3] */
/* tmp12 = MULTIPLY(tmp14, FIX_1_414213562) - tmp13; */
- psubw_r2r(mm2, mm6); /* wsptr[0,tmp12],[1,tmp12],[2,tmp12],[3,tmp12] */
+ psubw_r2r (mm2, mm6); /* wsptr[0,tmp12],[1,tmp12],[2,tmp12],[3,tmp12] */
/* tmp1 = tmp11 + tmp12; */
/* tmp2 = tmp11 - tmp12; */
- movq_r2r(mm1, mm5);
+ movq_r2r (mm1, mm5);
- /*OK */
+ /*OK */
- /* Odd part */
+ /* Odd part */
/* z13 = (DCTELEM) wsptr[5] + (DCTELEM) wsptr[3]; */
/* z10 = (DCTELEM) wsptr[5] - (DCTELEM) wsptr[3]; */
/* z11 = (DCTELEM) wsptr[1] + (DCTELEM) wsptr[7]; */
/* z12 = (DCTELEM) wsptr[1] - (DCTELEM) wsptr[7]; */
- movq_m2r(*(wsptr), mm3); /* wsptr[0,0],[0,1],[0,2],[0,3] */
- paddw_r2r(mm6, mm1); /* [0,tmp1],[1,tmp1],[2,tmp1],[3,tmp1] */
+ movq_m2r (*(wsptr), mm3); /* wsptr[0,0],[0,1],[0,2],[0,3] */
+ paddw_r2r (mm6, mm1); /* [0,tmp1],[1,tmp1],[2,tmp1],[3,tmp1] */
- movq_m2r(*(wsptr+1), mm4); /* wsptr[0,4],[0,5],[0,6],[0,7] */
- psubw_r2r(mm6, mm5); /* [0,tmp2],[1,tmp2],[2,tmp2],[3,tmp2] */
+ movq_m2r (*(wsptr + 1), mm4); /* wsptr[0,4],[0,5],[0,6],[0,7] */
+ psubw_r2r (mm6, mm5); /* [0,tmp2],[1,tmp2],[2,tmp2],[3,tmp2] */
- movq_r2r(mm3, mm6);
- punpckldq_r2r(mm4, mm3); /* wsptr[0,0],[0,1],[0,4],[0,5] */
+ movq_r2r (mm3, mm6);
+ punpckldq_r2r (mm4, mm3); /* wsptr[0,0],[0,1],[0,4],[0,5] */
- punpckhdq_r2r(mm6, mm4); /* wsptr[0,6],[0,7],[0,2],[0,3] */
- movq_r2r(mm3, mm2);
+ punpckhdq_r2r (mm6, mm4); /* wsptr[0,6],[0,7],[0,2],[0,3] */
+ movq_r2r (mm3, mm2);
/*Save tmp0 and tmp1 in wsptr */
- movq_r2m(mm0, *(wsptr)); /* save tmp0 */
- paddw_r2r(mm4, mm2); /* wsptr[xxx],[0,z11],[xxx],[0,z13] */
+ movq_r2m (mm0, *(wsptr)); /* save tmp0 */
+ paddw_r2r (mm4, mm2); /* wsptr[xxx],[0,z11],[xxx],[0,z13] */
+
-
/*Continue with z10 --- z13 */
- movq_m2r(*(wsptr+2), mm6); /* wsptr[1,0],[1,1],[1,2],[1,3] */
- psubw_r2r(mm4, mm3); /* wsptr[xxx],[0,z12],[xxx],[0,z10] */
+ movq_m2r (*(wsptr + 2), mm6); /* wsptr[1,0],[1,1],[1,2],[1,3] */
+ psubw_r2r (mm4, mm3); /* wsptr[xxx],[0,z12],[xxx],[0,z10] */
- movq_m2r(*(wsptr+3), mm0); /* wsptr[1,4],[1,5],[1,6],[1,7] */
- movq_r2r(mm6, mm4);
+ movq_m2r (*(wsptr + 3), mm0); /* wsptr[1,4],[1,5],[1,6],[1,7] */
+ movq_r2r (mm6, mm4);
- movq_r2m(mm1, *(wsptr+1)); /* save tmp1 */
- punpckldq_r2r(mm0, mm6); /* wsptr[1,0],[1,1],[1,4],[1,5] */
+ movq_r2m (mm1, *(wsptr + 1)); /* save tmp1 */
+ punpckldq_r2r (mm0, mm6); /* wsptr[1,0],[1,1],[1,4],[1,5] */
+
+ punpckhdq_r2r (mm4, mm0); /* wsptr[1,6],[1,7],[1,2],[1,3] */
+ movq_r2r (mm6, mm1);
- punpckhdq_r2r(mm4, mm0); /* wsptr[1,6],[1,7],[1,2],[1,3] */
- movq_r2r(mm6, mm1);
-
/*Save tmp2 and tmp3 in wsptr */
- paddw_r2r(mm0, mm6); /* wsptr[xxx],[1,z11],[xxx],[1,z13] */
- movq_r2r(mm2, mm4);
-
+ paddw_r2r (mm0, mm6); /* wsptr[xxx],[1,z11],[xxx],[1,z13] */
+ movq_r2r (mm2, mm4);
+
/*Continue with z10 --- z13 */
- movq_r2m(mm5, *(wsptr+2)); /* save tmp2 */
- punpcklwd_r2r(mm6, mm2); /* wsptr[xxx],[xxx],[0,z11],[1,z11] */
+ movq_r2m (mm5, *(wsptr + 2)); /* save tmp2 */
+ punpcklwd_r2r (mm6, mm2); /* wsptr[xxx],[xxx],[0,z11],[1,z11] */
- psubw_r2r(mm0, mm1); /* wsptr[xxx],[1,z12],[xxx],[1,z10] */
- punpckhwd_r2r(mm6, mm4); /* wsptr[xxx],[xxx],[0,z13],[1,z13] */
+ psubw_r2r (mm0, mm1); /* wsptr[xxx],[1,z12],[xxx],[1,z10] */
+ punpckhwd_r2r (mm6, mm4); /* wsptr[xxx],[xxx],[0,z13],[1,z13] */
- movq_r2r(mm3, mm0);
- punpcklwd_r2r(mm1, mm3); /* wsptr[xxx],[xxx],[0,z12],[1,z12] */
+ movq_r2r (mm3, mm0);
+ punpcklwd_r2r (mm1, mm3); /* wsptr[xxx],[xxx],[0,z12],[1,z12] */
- movq_r2m(mm7, *(wsptr+3)); /* save tmp3 */
- punpckhwd_r2r(mm1, mm0); /* wsptr[xxx],[xxx],[0,z10],[1,z10] */
+ movq_r2m (mm7, *(wsptr + 3)); /* save tmp3 */
+ punpckhwd_r2r (mm1, mm0); /* wsptr[xxx],[xxx],[0,z10],[1,z10] */
- movq_m2r(*(wsptr+4), mm6); /* wsptr[2,0],[2,1],[2,2],[2,3] */
- punpckhdq_r2r(mm2, mm0); /* wsptr[0,z10],[1,z10],[0,z11],[1,z11] */
+ movq_m2r (*(wsptr + 4), mm6); /* wsptr[2,0],[2,1],[2,2],[2,3] */
+ punpckhdq_r2r (mm2, mm0); /* wsptr[0,z10],[1,z10],[0,z11],[1,z11] */
- movq_m2r(*(wsptr+5), mm7); /* wsptr[2,4],[2,5],[2,6],[2,7] */
- punpckhdq_r2r(mm4, mm3); /* wsptr[0,z12],[1,z12],[0,z13],[1,z13] */
+ movq_m2r (*(wsptr + 5), mm7); /* wsptr[2,4],[2,5],[2,6],[2,7] */
+ punpckhdq_r2r (mm4, mm3); /* wsptr[0,z12],[1,z12],[0,z13],[1,z13] */
- movq_m2r(*(wsptr+6), mm1); /* wsptr[3,0],[3,1],[3,2],[3,3] */
- movq_r2r(mm6, mm4);
+ movq_m2r (*(wsptr + 6), mm1); /* wsptr[3,0],[3,1],[3,2],[3,3] */
+ movq_r2r (mm6, mm4);
- punpckldq_r2r(mm7, mm6); /* wsptr[2,0],[2,1],[2,4],[2,5] */
- movq_r2r(mm1, mm5);
+ punpckldq_r2r (mm7, mm6); /* wsptr[2,0],[2,1],[2,4],[2,5] */
+ movq_r2r (mm1, mm5);
- punpckhdq_r2r(mm4, mm7); /* wsptr[2,6],[2,7],[2,2],[2,3] */
- movq_r2r(mm6, mm2);
-
- movq_m2r(*(wsptr+7), mm4); /* wsptr[3,4],[3,5],[3,6],[3,7] */
- paddw_r2r(mm7, mm6); /* wsptr[xxx],[2,z11],[xxx],[2,z13] */
+ punpckhdq_r2r (mm4, mm7); /* wsptr[2,6],[2,7],[2,2],[2,3] */
+ movq_r2r (mm6, mm2);
- psubw_r2r(mm7, mm2); /* wsptr[xxx],[2,z12],[xxx],[2,z10] */
- punpckldq_r2r(mm4, mm1); /* wsptr[3,0],[3,1],[3,4],[3,5] */
+ movq_m2r (*(wsptr + 7), mm4); /* wsptr[3,4],[3,5],[3,6],[3,7] */
+ paddw_r2r (mm7, mm6); /* wsptr[xxx],[2,z11],[xxx],[2,z13] */
- punpckhdq_r2r(mm5, mm4); /* wsptr[3,6],[3,7],[3,2],[3,3] */
- movq_r2r(mm1, mm7);
+ psubw_r2r (mm7, mm2); /* wsptr[xxx],[2,z12],[xxx],[2,z10] */
+ punpckldq_r2r (mm4, mm1); /* wsptr[3,0],[3,1],[3,4],[3,5] */
- paddw_r2r(mm4, mm1); /* wsptr[xxx],[3,z11],[xxx],[3,z13] */
- psubw_r2r(mm4, mm7); /* wsptr[xxx],[3,z12],[xxx],[3,z10] */
+ punpckhdq_r2r (mm5, mm4); /* wsptr[3,6],[3,7],[3,2],[3,3] */
+ movq_r2r (mm1, mm7);
- movq_r2r(mm6, mm5);
- punpcklwd_r2r(mm1, mm6); /* wsptr[xxx],[xxx],[2,z11],[3,z11] */
+ paddw_r2r (mm4, mm1); /* wsptr[xxx],[3,z11],[xxx],[3,z13] */
+ psubw_r2r (mm4, mm7); /* wsptr[xxx],[3,z12],[xxx],[3,z10] */
- punpckhwd_r2r(mm1, mm5); /* wsptr[xxx],[xxx],[2,z13],[3,z13] */
- movq_r2r(mm2, mm4);
+ movq_r2r (mm6, mm5);
+ punpcklwd_r2r (mm1, mm6); /* wsptr[xxx],[xxx],[2,z11],[3,z11] */
- punpcklwd_r2r(mm7, mm2); /* wsptr[xxx],[xxx],[2,z12],[3,z12] */
+ punpckhwd_r2r (mm1, mm5); /* wsptr[xxx],[xxx],[2,z13],[3,z13] */
+ movq_r2r (mm2, mm4);
- punpckhwd_r2r(mm7, mm4); /* wsptr[xxx],[xxx],[2,z10],[3,z10] */
+ punpcklwd_r2r (mm7, mm2); /* wsptr[xxx],[xxx],[2,z12],[3,z12] */
- punpckhdq_r2r(mm6, mm4); /*/ wsptr[2,z10],[3,z10],[2,z11],[3,z11] */
+ punpckhwd_r2r (mm7, mm4); /* wsptr[xxx],[xxx],[2,z10],[3,z10] */
- punpckhdq_r2r(mm5, mm2); /* wsptr[2,z12],[3,z12],[2,z13],[3,z13] */
- movq_r2r(mm0, mm5);
+ punpckhdq_r2r (mm6, mm4); /*/ wsptr[2,z10],[3,z10],[2,z11],[3,z11] */
- punpckldq_r2r(mm4, mm0); /* wsptr[0,z10],[1,z10],[2,z10],[3,z10] */
+ punpckhdq_r2r (mm5, mm2); /* wsptr[2,z12],[3,z12],[2,z13],[3,z13] */
+ movq_r2r (mm0, mm5);
- punpckhdq_r2r(mm4, mm5); /* wsptr[0,z11],[1,z11],[2,z11],[3,z11] */
- movq_r2r(mm3, mm4);
+ punpckldq_r2r (mm4, mm0); /* wsptr[0,z10],[1,z10],[2,z10],[3,z10] */
- punpckhdq_r2r(mm2, mm4); /* wsptr[0,z13],[1,z13],[2,z13],[3,z13] */
- movq_r2r(mm5, mm1);
+ punpckhdq_r2r (mm4, mm5); /* wsptr[0,z11],[1,z11],[2,z11],[3,z11] */
+ movq_r2r (mm3, mm4);
- punpckldq_r2r(mm2, mm3); /* wsptr[0,z12],[1,z12],[2,z12],[3,z12] */
+ punpckhdq_r2r (mm2, mm4); /* wsptr[0,z13],[1,z13],[2,z13],[3,z13] */
+ movq_r2r (mm5, mm1);
+
+ punpckldq_r2r (mm2, mm3); /* wsptr[0,z12],[1,z12],[2,z12],[3,z12] */
/* tmp7 = z11 + z13; : phase 5 */
/* tmp8 = z11 - z13; : phase 5 */
- psubw_r2r(mm4, mm1); /* tmp8 */
+ psubw_r2r (mm4, mm1); /* tmp8 */
- paddw_r2r(mm4, mm5); /* tmp7 */
+ paddw_r2r (mm4, mm5); /* tmp7 */
/* tmp21 = MULTIPLY(tmp8, FIX_1_414213562); 2*c4 */
- psllw_i2r(2, mm1);
+ psllw_i2r (2, mm1);
- psllw_i2r(2, mm0);
+ psllw_i2r (2, mm0);
- pmulhw_m2r(fix_141, mm1); /* tmp21 */
+ pmulhw_m2r (fix_141, mm1); /* tmp21 */
/* tmp20 = MULTIPLY(z12, (FIX_1_082392200- FIX_1_847759065)) 2*(c2-c6) */
/* + MULTIPLY(z10, - FIX_1_847759065); : 2*c2 */
- psllw_i2r(2, mm3);
- movq_r2r(mm0, mm7);
+ psllw_i2r (2, mm3);
+ movq_r2r (mm0, mm7);
- pmulhw_m2r(fix_n184, mm7);
- movq_r2r(mm3, mm6);
+ pmulhw_m2r (fix_n184, mm7);
+ movq_r2r (mm3, mm6);
- movq_m2r(*(wsptr), mm2); /* tmp0,final1 */
+ movq_m2r (*(wsptr), mm2); /* tmp0,final1 */
- pmulhw_m2r(fix_108n184, mm6);
+ pmulhw_m2r (fix_108n184, mm6);
/* tmp22 = MULTIPLY(z10,(FIX_1_847759065 - FIX_2_613125930)) : -2*(c2+c6) */
/* + MULTIPLY(z12, FIX_1_847759065); 2*c2 */
- movq_r2r(mm2, mm4); /* final1 */
-
- pmulhw_m2r(fix_184n261, mm0);
- paddw_r2r(mm5, mm2); /* tmp0+tmp7,final1 */
+ movq_r2r (mm2, mm4); /* final1 */
+
+ pmulhw_m2r (fix_184n261, mm0);
+ paddw_r2r (mm5, mm2); /* tmp0+tmp7,final1 */
- pmulhw_m2r(fix_184, mm3);
- psubw_r2r(mm5, mm4); /* tmp0-tmp7,final1 */
+ pmulhw_m2r (fix_184, mm3);
+ psubw_r2r (mm5, mm4); /* tmp0-tmp7,final1 */
/* tmp6 = tmp22 - tmp7; phase 2 */
- psraw_i2r(3, mm2); /* outptr[0,0],[1,0],[2,0],[3,0],final1 */
+ psraw_i2r (3, mm2); /* outptr[0,0],[1,0],[2,0],[3,0],final1 */
- paddw_r2r(mm6, mm7); /* tmp20 */
- psraw_i2r(3, mm4); /* outptr[0,7],[1,7],[2,7],[3,7],final1 */
+ paddw_r2r (mm6, mm7); /* tmp20 */
+ psraw_i2r (3, mm4); /* outptr[0,7],[1,7],[2,7],[3,7],final1 */
- paddw_r2r(mm0, mm3); /* tmp22 */
+ paddw_r2r (mm0, mm3); /* tmp22 */
/* tmp5 = tmp21 - tmp6; */
- psubw_r2r(mm5, mm3); /* tmp6 */
+ psubw_r2r (mm5, mm3); /* tmp6 */
/* tmp4 = tmp20 + tmp5; */
- movq_m2r(*(wsptr+1), mm0); /* tmp1,final2 */
- psubw_r2r(mm3, mm1); /* tmp5 */
+ movq_m2r (*(wsptr + 1), mm0); /* tmp1,final2 */
+ psubw_r2r (mm3, mm1); /* tmp5 */
- movq_r2r(mm0, mm6); /* final2 */
- paddw_r2r(mm3, mm0); /* tmp1+tmp6,final2 */
+ movq_r2r (mm0, mm6); /* final2 */
+ paddw_r2r (mm3, mm0); /* tmp1+tmp6,final2 */
- /* Final output stage: scale down by a factor of 8 and range-limit */
+ /* Final output stage: scale down by a factor of 8 and range-limit */
/* outptr[0] = range_limit[IDESCALE(tmp0 + tmp7, PASS1_BITS+3) */
/* & RANGE_MASK]; */
/* outptr[6] = range_limit[IDESCALE(tmp1 - tmp6, PASS1_BITS+3) */
/* & RANGE_MASK]; final2 */
- psubw_r2r(mm3, mm6); /* tmp1-tmp6,final2 */
- psraw_i2r(3, mm0); /* outptr[0,1],[1,1],[2,1],[3,1] */
+ psubw_r2r (mm3, mm6); /* tmp1-tmp6,final2 */
+ psraw_i2r (3, mm0); /* outptr[0,1],[1,1],[2,1],[3,1] */
+
+ psraw_i2r (3, mm6); /* outptr[0,6],[1,6],[2,6],[3,6] */
+
+ packuswb_r2r (mm4, mm0); /* out[0,1],[1,1],[2,1],[3,1],[0,7],[1,7],[2,7],[3,7] */
- psraw_i2r(3, mm6); /* outptr[0,6],[1,6],[2,6],[3,6] */
-
- packuswb_r2r(mm4, mm0); /* out[0,1],[1,1],[2,1],[3,1],[0,7],[1,7],[2,7],[3,7] */
-
- movq_m2r(*(wsptr+2), mm5); /* tmp2,final3 */
- packuswb_r2r(mm6, mm2); /* out[0,0],[1,0],[2,0],[3,0],[0,6],[1,6],[2,6],[3,6] */
+ movq_m2r (*(wsptr + 2), mm5); /* tmp2,final3 */
+ packuswb_r2r (mm6, mm2); /* out[0,0],[1,0],[2,0],[3,0],[0,6],[1,6],[2,6],[3,6] */
/* outptr[2] = range_limit[IDESCALE(tmp2 + tmp5, PASS1_BITS+3) */
/* & RANGE_MASK]; */
/* outptr[5] = range_limit[IDESCALE(tmp2 - tmp5, PASS1_BITS+3) */
/* & RANGE_MASK]; final3 */
- paddw_r2r(mm1, mm7); /* tmp4 */
- movq_r2r(mm5, mm3);
+ paddw_r2r (mm1, mm7); /* tmp4 */
+ movq_r2r (mm5, mm3);
- paddw_r2r(mm1, mm5); /* tmp2+tmp5 */
- psubw_r2r(mm1, mm3); /* tmp2-tmp5 */
+ paddw_r2r (mm1, mm5); /* tmp2+tmp5 */
+ psubw_r2r (mm1, mm3); /* tmp2-tmp5 */
- psraw_i2r(3, mm5); /* outptr[0,2],[1,2],[2,2],[3,2] */
+ psraw_i2r (3, mm5); /* outptr[0,2],[1,2],[2,2],[3,2] */
- movq_m2r(*(wsptr+3), mm4); /* tmp3,final4 */
- psraw_i2r(3, mm3); /* outptr[0,5],[1,5],[2,5],[3,5] */
+ movq_m2r (*(wsptr + 3), mm4); /* tmp3,final4 */
+ psraw_i2r (3, mm3); /* outptr[0,5],[1,5],[2,5],[3,5] */
/* & RANGE_MASK]; */
/* outptr[3] = range_limit[IDESCALE(tmp3 - tmp4, PASS1_BITS+3) */
/* & RANGE_MASK]; final4 */
- movq_r2r(mm4, mm6);
- paddw_r2r(mm7, mm4); /* tmp3+tmp4 */
+ movq_r2r (mm4, mm6);
+ paddw_r2r (mm7, mm4); /* tmp3+tmp4 */
- psubw_r2r(mm7, mm6); /* tmp3-tmp4 */
- psraw_i2r(3, mm4); /* outptr[0,4],[1,4],[2,4],[3,4] */
+ psubw_r2r (mm7, mm6); /* tmp3-tmp4 */
+ psraw_i2r (3, mm4); /* outptr[0,4],[1,4],[2,4],[3,4] */
- /* mov ecx, [dataptr] */
+ /* mov ecx, [dataptr] */
- psraw_i2r(3, mm6); /* outptr[0,3],[1,3],[2,3],[3,3] */
+ psraw_i2r (3, mm6); /* outptr[0,3],[1,3],[2,3],[3,3] */
- packuswb_r2r(mm4, mm5); /* out[0,2],[1,2],[2,2],[3,2],[0,4],[1,4],[2,4],[3,4] */
+ packuswb_r2r (mm4, mm5); /* out[0,2],[1,2],[2,2],[3,2],[0,4],[1,4],[2,4],[3,4] */
- packuswb_r2r(mm3, mm6); /* out[0,3],[1,3],[2,3],[3,3],[0,5],[1,5],[2,5],[3,5] */
- movq_r2r(mm2, mm4);
+ packuswb_r2r (mm3, mm6); /* out[0,3],[1,3],[2,3],[3,3],[0,5],[1,5],[2,5],[3,5] */
+ movq_r2r (mm2, mm4);
- movq_r2r(mm5, mm7);
- punpcklbw_r2r(mm0, mm2); /* out[0,0],[0,1],[1,0],[1,1],[2,0],[2,1],[3,0],[3,1] */
+ movq_r2r (mm5, mm7);
+ punpcklbw_r2r (mm0, mm2); /* out[0,0],[0,1],[1,0],[1,1],[2,0],[2,1],[3,0],[3,1] */
- punpckhbw_r2r(mm0, mm4); /* out[0,6],[0,7],[1,6],[1,7],[2,6],[2,7],[3,6],[3,7] */
- movq_r2r(mm2, mm1);
+ punpckhbw_r2r (mm0, mm4); /* out[0,6],[0,7],[1,6],[1,7],[2,6],[2,7],[3,6],[3,7] */
+ movq_r2r (mm2, mm1);
- punpcklbw_r2r(mm6, mm5); /* out[0,2],[0,3],[1,2],[1,3],[2,2],[2,3],[3,2],[3,3] */
+ punpcklbw_r2r (mm6, mm5); /* out[0,2],[0,3],[1,2],[1,3],[2,2],[2,3],[3,2],[3,3] */
- /* add dataptr, 4 */
+ /* add dataptr, 4 */
- punpckhbw_r2r(mm6, mm7); /* out[0,4],[0,5],[1,4],[1,5],[2,4],[2,5],[3,4],[3,5] */
+ punpckhbw_r2r (mm6, mm7); /* out[0,4],[0,5],[1,4],[1,5],[2,4],[2,5],[3,4],[3,5] */
- punpcklwd_r2r(mm5, mm2); /* out[0,0],[0,1],[0,2],[0,3],[1,0],[1,1],[1,2],[1,3] */
-
- /* add ecx, output_col */
+ punpcklwd_r2r (mm5, mm2); /* out[0,0],[0,1],[0,2],[0,3],[1,0],[1,1],[1,2],[1,3] */
- movq_r2r(mm7, mm6);
- punpckhwd_r2r(mm5, mm1); /* out[2,0],[2,1],[2,2],[2,3],[3,0],[3,1],[3,2],[3,3] */
+ /* add ecx, output_col */
- movq_r2r(mm2, mm0);
- punpcklwd_r2r(mm4, mm6); /* out[0,4],[0,5],[0,6],[0,7],[1,4],[1,5],[1,6],[1,7] */
+ movq_r2r (mm7, mm6);
+ punpckhwd_r2r (mm5, mm1); /* out[2,0],[2,1],[2,2],[2,3],[3,0],[3,1],[3,2],[3,3] */
- /* mov idata, [dataptr] */
-
- punpckldq_r2r(mm6, mm2); /* out[0,0],[0,1],[0,2],[0,3],[0,4],[0,5],[0,6],[0,7] */
+ movq_r2r (mm2, mm0);
+ punpcklwd_r2r (mm4, mm6); /* out[0,4],[0,5],[0,6],[0,7],[1,4],[1,5],[1,6],[1,7] */
- /* add dataptr, 4 */
-
- movq_r2r(mm1, mm3);
+ /* mov idata, [dataptr] */
- /* add idata, output_col */
-
- punpckhwd_r2r(mm4, mm7); /* out[2,4],[2,5],[2,6],[2,7],[3,4],[3,5],[3,6],[3,7] */
-
- movq_r2m(mm2, *(dataptr));
-
- punpckhdq_r2r(mm6, mm0); /* out[1,0],[1,1],[1,2],[1,3],[1,4],[1,5],[1,6],[1,7] */
+ punpckldq_r2r (mm6, mm2); /* out[0,0],[0,1],[0,2],[0,3],[0,4],[0,5],[0,6],[0,7] */
- dataptr += rskip;
- movq_r2m(mm0, *(dataptr));
+ /* add dataptr, 4 */
- punpckldq_r2r(mm7, mm1); /* out[2,0],[2,1],[2,2],[2,3],[2,4],[2,5],[2,6],[2,7] */
- punpckhdq_r2r(mm7, mm3); /* out[3,0],[3,1],[3,2],[3,3],[3,4],[3,5],[3,6],[3,7] */
-
- dataptr += rskip;
- movq_r2m(mm1, *(dataptr));
+ movq_r2r (mm1, mm3);
- dataptr += rskip;
- movq_r2m(mm3, *(dataptr));
+ /* add idata, output_col */
+
+ punpckhwd_r2r (mm4, mm7); /* out[2,4],[2,5],[2,6],[2,7],[3,4],[3,5],[3,6],[3,7] */
+
+ movq_r2m (mm2, *(dataptr));
+
+ punpckhdq_r2r (mm6, mm0); /* out[1,0],[1,1],[1,2],[1,3],[1,4],[1,5],[1,6],[1,7] */
+
+ dataptr += rskip;
+ movq_r2m (mm0, *(dataptr));
+
+ punpckldq_r2r (mm7, mm1); /* out[2,0],[2,1],[2,2],[2,3],[2,4],[2,5],[2,6],[2,7] */
+ punpckhdq_r2r (mm7, mm3); /* out[3,0],[3,1],[3,2],[3,3],[3,4],[3,5],[3,6],[3,7] */
+
+ dataptr += rskip;
+ movq_r2m (mm1, *(dataptr));
+
+ dataptr += rskip;
+ movq_r2m (mm3, *(dataptr));
/*******************************************************************/
- wsptr += 8;
+ wsptr += 8;
/*******************************************************************/
/* tmp13 = ((DCTELEM) wsptr[2] + (DCTELEM) wsptr[6]); */
/* tmp11 = ((DCTELEM) wsptr[0] - (DCTELEM) wsptr[4]); */
/* tmp14 = ((DCTELEM) wsptr[2] - (DCTELEM) wsptr[6]); */
- movq_m2r(*(wsptr), mm0); /* wsptr[0,0],[0,1],[0,2],[0,3] */
+ movq_m2r (*(wsptr), mm0); /* wsptr[0,0],[0,1],[0,2],[0,3] */
+
+ movq_m2r (*(wsptr + 1), mm1); /* wsptr[0,4],[0,5],[0,6],[0,7] */
+ movq_r2r (mm0, mm2);
- movq_m2r(*(wsptr+1), mm1); /* wsptr[0,4],[0,5],[0,6],[0,7] */
- movq_r2r(mm0, mm2);
-
- movq_m2r(*(wsptr+2), mm3); /* wsptr[1,0],[1,1],[1,2],[1,3] */
- paddw_r2r(mm1, mm0); /* wsptr[0,tmp10],[xxx],[0,tmp13],[xxx] */
+ movq_m2r (*(wsptr + 2), mm3); /* wsptr[1,0],[1,1],[1,2],[1,3] */
+ paddw_r2r (mm1, mm0); /* wsptr[0,tmp10],[xxx],[0,tmp13],[xxx] */
- movq_m2r(*(wsptr+3), mm4); /* wsptr[1,4],[1,5],[1,6],[1,7] */
- psubw_r2r(mm1, mm2); /* wsptr[0,tmp11],[xxx],[0,tmp14],[xxx] */
+ movq_m2r (*(wsptr + 3), mm4); /* wsptr[1,4],[1,5],[1,6],[1,7] */
+ psubw_r2r (mm1, mm2); /* wsptr[0,tmp11],[xxx],[0,tmp14],[xxx] */
- movq_r2r(mm0, mm6);
- movq_r2r(mm3, mm5);
-
- paddw_r2r(mm4, mm3); /* wsptr[1,tmp10],[xxx],[1,tmp13],[xxx] */
- movq_r2r(mm2, mm1);
+ movq_r2r (mm0, mm6);
+ movq_r2r (mm3, mm5);
- psubw_r2r(mm4, mm5); /* wsptr[1,tmp11],[xxx],[1,tmp14],[xxx] */
- punpcklwd_r2r(mm3, mm0); /* wsptr[0,tmp10],[1,tmp10],[xxx],[xxx] */
+ paddw_r2r (mm4, mm3); /* wsptr[1,tmp10],[xxx],[1,tmp13],[xxx] */
+ movq_r2r (mm2, mm1);
- movq_m2r(*(wsptr+7), mm7); /* wsptr[3,4],[3,5],[3,6],[3,7] */
- punpckhwd_r2r(mm3, mm6); /* wsptr[0,tmp13],[1,tmp13],[xxx],[xxx] */
+ psubw_r2r (mm4, mm5); /* wsptr[1,tmp11],[xxx],[1,tmp14],[xxx] */
+ punpcklwd_r2r (mm3, mm0); /* wsptr[0,tmp10],[1,tmp10],[xxx],[xxx] */
- movq_m2r(*(wsptr+4), mm3); /* wsptr[2,0],[2,1],[2,2],[2,3] */
- punpckldq_r2r(mm6, mm0); /* wsptr[0,tmp10],[1,tmp10],[0,tmp13],[1,tmp13] */
+ movq_m2r (*(wsptr + 7), mm7); /* wsptr[3,4],[3,5],[3,6],[3,7] */
+ punpckhwd_r2r (mm3, mm6); /* wsptr[0,tmp13],[1,tmp13],[xxx],[xxx] */
- punpcklwd_r2r(mm5, mm1); /* wsptr[0,tmp11],[1,tmp11],[xxx],[xxx] */
- movq_r2r(mm3, mm4);
+ movq_m2r (*(wsptr + 4), mm3); /* wsptr[2,0],[2,1],[2,2],[2,3] */
+ punpckldq_r2r (mm6, mm0); /* wsptr[0,tmp10],[1,tmp10],[0,tmp13],[1,tmp13] */
- movq_m2r(*(wsptr+6), mm6); /* wsptr[3,0],[3,1],[3,2],[3,3] */
- punpckhwd_r2r(mm5, mm2); /* wsptr[0,tmp14],[1,tmp14],[xxx],[xxx] */
+ punpcklwd_r2r (mm5, mm1); /* wsptr[0,tmp11],[1,tmp11],[xxx],[xxx] */
+ movq_r2r (mm3, mm4);
- movq_m2r(*(wsptr+5), mm5); /* wsptr[2,4],[2,5],[2,6],[2,7] */
- punpckldq_r2r(mm2, mm1); /* wsptr[0,tmp11],[1,tmp11],[0,tmp14],[1,tmp14] */
+ movq_m2r (*(wsptr + 6), mm6); /* wsptr[3,0],[3,1],[3,2],[3,3] */
+ punpckhwd_r2r (mm5, mm2); /* wsptr[0,tmp14],[1,tmp14],[xxx],[xxx] */
- paddw_r2r(mm5, mm3); /* wsptr[2,tmp10],[xxx],[2,tmp13],[xxx] */
- movq_r2r(mm6, mm2);
+ movq_m2r (*(wsptr + 5), mm5); /* wsptr[2,4],[2,5],[2,6],[2,7] */
+ punpckldq_r2r (mm2, mm1); /* wsptr[0,tmp11],[1,tmp11],[0,tmp14],[1,tmp14] */
- psubw_r2r(mm5, mm4); /* wsptr[2,tmp11],[xxx],[2,tmp14],[xxx] */
- paddw_r2r(mm7, mm6); /* wsptr[3,tmp10],[xxx],[3,tmp13],[xxx] */
+ paddw_r2r (mm5, mm3); /* wsptr[2,tmp10],[xxx],[2,tmp13],[xxx] */
+ movq_r2r (mm6, mm2);
- movq_r2r(mm3, mm5);
- punpcklwd_r2r(mm6, mm3); /* wsptr[2,tmp10],[3,tmp10],[xxx],[xxx] */
-
- psubw_r2r(mm7, mm2); /* wsptr[3,tmp11],[xxx],[3,tmp14],[xxx] */
- punpckhwd_r2r(mm6, mm5); /* wsptr[2,tmp13],[3,tmp13],[xxx],[xxx] */
+ psubw_r2r (mm5, mm4); /* wsptr[2,tmp11],[xxx],[2,tmp14],[xxx] */
+ paddw_r2r (mm7, mm6); /* wsptr[3,tmp10],[xxx],[3,tmp13],[xxx] */
- movq_r2r(mm4, mm7);
- punpckldq_r2r(mm5, mm3); /* wsptr[2,tmp10],[3,tmp10],[2,tmp13],[3,tmp13] */
+ movq_r2r (mm3, mm5);
+ punpcklwd_r2r (mm6, mm3); /* wsptr[2,tmp10],[3,tmp10],[xxx],[xxx] */
- punpcklwd_r2r(mm2, mm4); /* wsptr[2,tmp11],[3,tmp11],[xxx],[xxx] */
+ psubw_r2r (mm7, mm2); /* wsptr[3,tmp11],[xxx],[3,tmp14],[xxx] */
+ punpckhwd_r2r (mm6, mm5); /* wsptr[2,tmp13],[3,tmp13],[xxx],[xxx] */
- punpckhwd_r2r(mm2, mm7); /* wsptr[2,tmp14],[3,tmp14],[xxx],[xxx] */
+ movq_r2r (mm4, mm7);
+ punpckldq_r2r (mm5, mm3); /* wsptr[2,tmp10],[3,tmp10],[2,tmp13],[3,tmp13] */
- punpckldq_r2r(mm7, mm4); /* wsptr[2,tmp11],[3,tmp11],[2,tmp14],[3,tmp14] */
- movq_r2r(mm1, mm6);
+ punpcklwd_r2r (mm2, mm4); /* wsptr[2,tmp11],[3,tmp11],[xxx],[xxx] */
- /*OK */
+ punpckhwd_r2r (mm2, mm7); /* wsptr[2,tmp14],[3,tmp14],[xxx],[xxx] */
+
+ punpckldq_r2r (mm7, mm4); /* wsptr[2,tmp11],[3,tmp11],[2,tmp14],[3,tmp14] */
+ movq_r2r (mm1, mm6);
+
+ /*OK */
/* mm0 = ;wsptr[0,tmp10],[1,tmp10],[0,tmp13],[1,tmp13] */
/* mm1 = ;wsptr[0,tmp11],[1,tmp11],[0,tmp14],[1,tmp14] */
- movq_r2r(mm0, mm2);
- punpckhdq_r2r(mm4, mm6); /* wsptr[0,tmp14],[1,tmp14],[2,tmp14],[3,tmp14] */
+ movq_r2r (mm0, mm2);
+ punpckhdq_r2r (mm4, mm6); /* wsptr[0,tmp14],[1,tmp14],[2,tmp14],[3,tmp14] */
- punpckldq_r2r(mm4, mm1); /* wsptr[0,tmp11],[1,tmp11],[2,tmp11],[3,tmp11] */
- psllw_i2r(2, mm6);
+ punpckldq_r2r (mm4, mm1); /* wsptr[0,tmp11],[1,tmp11],[2,tmp11],[3,tmp11] */
+ psllw_i2r (2, mm6);
- pmulhw_m2r(fix_141, mm6);
- punpckldq_r2r(mm3, mm0); /* wsptr[0,tmp10],[1,tmp10],[2,tmp10],[3,tmp10] */
+ pmulhw_m2r (fix_141, mm6);
+ punpckldq_r2r (mm3, mm0); /* wsptr[0,tmp10],[1,tmp10],[2,tmp10],[3,tmp10] */
- punpckhdq_r2r(mm3, mm2); /* wsptr[0,tmp13],[1,tmp13],[2,tmp13],[3,tmp13] */
- movq_r2r(mm0, mm7);
+ punpckhdq_r2r (mm3, mm2); /* wsptr[0,tmp13],[1,tmp13],[2,tmp13],[3,tmp13] */
+ movq_r2r (mm0, mm7);
/* tmp0 = tmp10 + tmp13; */
/* tmp3 = tmp10 - tmp13; */
- paddw_r2r(mm2, mm0); /* [0,tmp0],[1,tmp0],[2,tmp0],[3,tmp0] */
- psubw_r2r(mm2, mm7); /* [0,tmp3],[1,tmp3],[2,tmp3],[3,tmp3] */
+ paddw_r2r (mm2, mm0); /* [0,tmp0],[1,tmp0],[2,tmp0],[3,tmp0] */
+ psubw_r2r (mm2, mm7); /* [0,tmp3],[1,tmp3],[2,tmp3],[3,tmp3] */
/* tmp12 = MULTIPLY(tmp14, FIX_1_414213562) - tmp13; */
- psubw_r2r(mm2, mm6); /* wsptr[0,tmp12],[1,tmp12],[2,tmp12],[3,tmp12] */
+ psubw_r2r (mm2, mm6); /* wsptr[0,tmp12],[1,tmp12],[2,tmp12],[3,tmp12] */
/* tmp1 = tmp11 + tmp12; */
/* tmp2 = tmp11 - tmp12; */
- movq_r2r(mm1, mm5);
+ movq_r2r (mm1, mm5);
- /*OK */
+ /*OK */
- /* Odd part */
+ /* Odd part */
/* z13 = (DCTELEM) wsptr[5] + (DCTELEM) wsptr[3]; */
/* z10 = (DCTELEM) wsptr[5] - (DCTELEM) wsptr[3]; */
/* z11 = (DCTELEM) wsptr[1] + (DCTELEM) wsptr[7]; */
/* z12 = (DCTELEM) wsptr[1] - (DCTELEM) wsptr[7]; */
- movq_m2r(*(wsptr), mm3); /* wsptr[0,0],[0,1],[0,2],[0,3] */
- paddw_r2r(mm6, mm1); /* [0,tmp1],[1,tmp1],[2,tmp1],[3,tmp1] */
+ movq_m2r (*(wsptr), mm3); /* wsptr[0,0],[0,1],[0,2],[0,3] */
+ paddw_r2r (mm6, mm1); /* [0,tmp1],[1,tmp1],[2,tmp1],[3,tmp1] */
- movq_m2r(*(wsptr+1), mm4); /* wsptr[0,4],[0,5],[0,6],[0,7] */
- psubw_r2r(mm6, mm5); /* [0,tmp2],[1,tmp2],[2,tmp2],[3,tmp2] */
+ movq_m2r (*(wsptr + 1), mm4); /* wsptr[0,4],[0,5],[0,6],[0,7] */
+ psubw_r2r (mm6, mm5); /* [0,tmp2],[1,tmp2],[2,tmp2],[3,tmp2] */
- movq_r2r(mm3, mm6);
- punpckldq_r2r(mm4, mm3); /* wsptr[0,0],[0,1],[0,4],[0,5] */
+ movq_r2r (mm3, mm6);
+ punpckldq_r2r (mm4, mm3); /* wsptr[0,0],[0,1],[0,4],[0,5] */
- punpckhdq_r2r(mm6, mm4); /* wsptr[0,6],[0,7],[0,2],[0,3] */
- movq_r2r(mm3, mm2);
+ punpckhdq_r2r (mm6, mm4); /* wsptr[0,6],[0,7],[0,2],[0,3] */
+ movq_r2r (mm3, mm2);
/*Save tmp0 and tmp1 in wsptr */
- movq_r2m(mm0, *(wsptr)); /* save tmp0 */
- paddw_r2r(mm4, mm2); /* wsptr[xxx],[0,z11],[xxx],[0,z13] */
+ movq_r2m (mm0, *(wsptr)); /* save tmp0 */
+ paddw_r2r (mm4, mm2); /* wsptr[xxx],[0,z11],[xxx],[0,z13] */
+
-
/*Continue with z10 --- z13 */
- movq_m2r(*(wsptr+2), mm6); /* wsptr[1,0],[1,1],[1,2],[1,3] */
- psubw_r2r(mm4, mm3); /* wsptr[xxx],[0,z12],[xxx],[0,z10] */
+ movq_m2r (*(wsptr + 2), mm6); /* wsptr[1,0],[1,1],[1,2],[1,3] */
+ psubw_r2r (mm4, mm3); /* wsptr[xxx],[0,z12],[xxx],[0,z10] */
- movq_m2r(*(wsptr+3), mm0); /* wsptr[1,4],[1,5],[1,6],[1,7] */
- movq_r2r(mm6, mm4);
+ movq_m2r (*(wsptr + 3), mm0); /* wsptr[1,4],[1,5],[1,6],[1,7] */
+ movq_r2r (mm6, mm4);
- movq_r2m(mm1, *(wsptr+1)); /* save tmp1 */
- punpckldq_r2r(mm0, mm6); /* wsptr[1,0],[1,1],[1,4],[1,5] */
+ movq_r2m (mm1, *(wsptr + 1)); /* save tmp1 */
+ punpckldq_r2r (mm0, mm6); /* wsptr[1,0],[1,1],[1,4],[1,5] */
+
+ punpckhdq_r2r (mm4, mm0); /* wsptr[1,6],[1,7],[1,2],[1,3] */
+ movq_r2r (mm6, mm1);
- punpckhdq_r2r(mm4, mm0); /* wsptr[1,6],[1,7],[1,2],[1,3] */
- movq_r2r(mm6, mm1);
-
/*Save tmp2 and tmp3 in wsptr */
- paddw_r2r(mm0, mm6); /* wsptr[xxx],[1,z11],[xxx],[1,z13] */
- movq_r2r(mm2, mm4);
-
+ paddw_r2r (mm0, mm6); /* wsptr[xxx],[1,z11],[xxx],[1,z13] */
+ movq_r2r (mm2, mm4);
+
/*Continue with z10 --- z13 */
- movq_r2m(mm5, *(wsptr+2)); /* save tmp2 */
- punpcklwd_r2r(mm6, mm2); /* wsptr[xxx],[xxx],[0,z11],[1,z11] */
+ movq_r2m (mm5, *(wsptr + 2)); /* save tmp2 */
+ punpcklwd_r2r (mm6, mm2); /* wsptr[xxx],[xxx],[0,z11],[1,z11] */
- psubw_r2r(mm0, mm1); /* wsptr[xxx],[1,z12],[xxx],[1,z10] */
- punpckhwd_r2r(mm6, mm4); /* wsptr[xxx],[xxx],[0,z13],[1,z13] */
+ psubw_r2r (mm0, mm1); /* wsptr[xxx],[1,z12],[xxx],[1,z10] */
+ punpckhwd_r2r (mm6, mm4); /* wsptr[xxx],[xxx],[0,z13],[1,z13] */
- movq_r2r(mm3, mm0);
- punpcklwd_r2r(mm1, mm3); /* wsptr[xxx],[xxx],[0,z12],[1,z12] */
+ movq_r2r (mm3, mm0);
+ punpcklwd_r2r (mm1, mm3); /* wsptr[xxx],[xxx],[0,z12],[1,z12] */
- movq_r2m(mm7, *(wsptr+3)); /* save tmp3 */
- punpckhwd_r2r(mm1, mm0); /* wsptr[xxx],[xxx],[0,z10],[1,z10] */
+ movq_r2m (mm7, *(wsptr + 3)); /* save tmp3 */
+ punpckhwd_r2r (mm1, mm0); /* wsptr[xxx],[xxx],[0,z10],[1,z10] */
- movq_m2r(*(wsptr+4), mm6); /* wsptr[2,0],[2,1],[2,2],[2,3] */
- punpckhdq_r2r(mm2, mm0); /* wsptr[0,z10],[1,z10],[0,z11],[1,z11] */
+ movq_m2r (*(wsptr + 4), mm6); /* wsptr[2,0],[2,1],[2,2],[2,3] */
+ punpckhdq_r2r (mm2, mm0); /* wsptr[0,z10],[1,z10],[0,z11],[1,z11] */
- movq_m2r(*(wsptr+5), mm7); /* wsptr[2,4],[2,5],[2,6],[2,7] */
- punpckhdq_r2r(mm4, mm3); /* wsptr[0,z12],[1,z12],[0,z13],[1,z13] */
+ movq_m2r (*(wsptr + 5), mm7); /* wsptr[2,4],[2,5],[2,6],[2,7] */
+ punpckhdq_r2r (mm4, mm3); /* wsptr[0,z12],[1,z12],[0,z13],[1,z13] */
- movq_m2r(*(wsptr+6), mm1); /* wsptr[3,0],[3,1],[3,2],[3,3] */
- movq_r2r(mm6, mm4);
+ movq_m2r (*(wsptr + 6), mm1); /* wsptr[3,0],[3,1],[3,2],[3,3] */
+ movq_r2r (mm6, mm4);
- punpckldq_r2r(mm7, mm6); /* wsptr[2,0],[2,1],[2,4],[2,5] */
- movq_r2r(mm1, mm5);
+ punpckldq_r2r (mm7, mm6); /* wsptr[2,0],[2,1],[2,4],[2,5] */
+ movq_r2r (mm1, mm5);
- punpckhdq_r2r(mm4, mm7); /* wsptr[2,6],[2,7],[2,2],[2,3] */
- movq_r2r(mm6, mm2);
-
- movq_m2r(*(wsptr+7), mm4); /* wsptr[3,4],[3,5],[3,6],[3,7] */
- paddw_r2r(mm7, mm6); /* wsptr[xxx],[2,z11],[xxx],[2,z13] */
+ punpckhdq_r2r (mm4, mm7); /* wsptr[2,6],[2,7],[2,2],[2,3] */
+ movq_r2r (mm6, mm2);
- psubw_r2r(mm7, mm2); /* wsptr[xxx],[2,z12],[xxx],[2,z10] */
- punpckldq_r2r(mm4, mm1); /* wsptr[3,0],[3,1],[3,4],[3,5] */
+ movq_m2r (*(wsptr + 7), mm4); /* wsptr[3,4],[3,5],[3,6],[3,7] */
+ paddw_r2r (mm7, mm6); /* wsptr[xxx],[2,z11],[xxx],[2,z13] */
- punpckhdq_r2r(mm5, mm4); /* wsptr[3,6],[3,7],[3,2],[3,3] */
- movq_r2r(mm1, mm7);
+ psubw_r2r (mm7, mm2); /* wsptr[xxx],[2,z12],[xxx],[2,z10] */
+ punpckldq_r2r (mm4, mm1); /* wsptr[3,0],[3,1],[3,4],[3,5] */
- paddw_r2r(mm4, mm1); /* wsptr[xxx],[3,z11],[xxx],[3,z13] */
- psubw_r2r(mm4, mm7); /* wsptr[xxx],[3,z12],[xxx],[3,z10] */
+ punpckhdq_r2r (mm5, mm4); /* wsptr[3,6],[3,7],[3,2],[3,3] */
+ movq_r2r (mm1, mm7);
- movq_r2r(mm6, mm5);
- punpcklwd_r2r(mm1, mm6); /* wsptr[xxx],[xxx],[2,z11],[3,z11] */
+ paddw_r2r (mm4, mm1); /* wsptr[xxx],[3,z11],[xxx],[3,z13] */
+ psubw_r2r (mm4, mm7); /* wsptr[xxx],[3,z12],[xxx],[3,z10] */
- punpckhwd_r2r(mm1, mm5); /* wsptr[xxx],[xxx],[2,z13],[3,z13] */
- movq_r2r(mm2, mm4);
+ movq_r2r (mm6, mm5);
+ punpcklwd_r2r (mm1, mm6); /* wsptr[xxx],[xxx],[2,z11],[3,z11] */
- punpcklwd_r2r(mm7, mm2); /* wsptr[xxx],[xxx],[2,z12],[3,z12] */
+ punpckhwd_r2r (mm1, mm5); /* wsptr[xxx],[xxx],[2,z13],[3,z13] */
+ movq_r2r (mm2, mm4);
- punpckhwd_r2r(mm7, mm4); /* wsptr[xxx],[xxx],[2,z10],[3,z10] */
+ punpcklwd_r2r (mm7, mm2); /* wsptr[xxx],[xxx],[2,z12],[3,z12] */
- punpckhdq_r2r(mm6, mm4); /* wsptr[2,z10],[3,z10],[2,z11],[3,z11] */
+ punpckhwd_r2r (mm7, mm4); /* wsptr[xxx],[xxx],[2,z10],[3,z10] */
- punpckhdq_r2r(mm5, mm2); /* wsptr[2,z12],[3,z12],[2,z13],[3,z13] */
- movq_r2r(mm0, mm5);
+ punpckhdq_r2r (mm6, mm4); /* wsptr[2,z10],[3,z10],[2,z11],[3,z11] */
- punpckldq_r2r(mm4, mm0); /* wsptr[0,z10],[1,z10],[2,z10],[3,z10] */
+ punpckhdq_r2r (mm5, mm2); /* wsptr[2,z12],[3,z12],[2,z13],[3,z13] */
+ movq_r2r (mm0, mm5);
- punpckhdq_r2r(mm4, mm5); /* wsptr[0,z11],[1,z11],[2,z11],[3,z11] */
- movq_r2r(mm3, mm4);
+ punpckldq_r2r (mm4, mm0); /* wsptr[0,z10],[1,z10],[2,z10],[3,z10] */
- punpckhdq_r2r(mm2, mm4); /* wsptr[0,z13],[1,z13],[2,z13],[3,z13] */
- movq_r2r(mm5, mm1);
+ punpckhdq_r2r (mm4, mm5); /* wsptr[0,z11],[1,z11],[2,z11],[3,z11] */
+ movq_r2r (mm3, mm4);
- punpckldq_r2r(mm2, mm3); /* wsptr[0,z12],[1,z12],[2,z12],[3,z12] */
+ punpckhdq_r2r (mm2, mm4); /* wsptr[0,z13],[1,z13],[2,z13],[3,z13] */
+ movq_r2r (mm5, mm1);
+
+ punpckldq_r2r (mm2, mm3); /* wsptr[0,z12],[1,z12],[2,z12],[3,z12] */
/* tmp7 = z11 + z13; : phase 5 */
/* tmp8 = z11 - z13; : phase 5 */
- psubw_r2r(mm4, mm1); /* tmp8 */
+ psubw_r2r (mm4, mm1); /* tmp8 */
- paddw_r2r(mm4, mm5); /* tmp7 */
+ paddw_r2r (mm4, mm5); /* tmp7 */
/* tmp21 = MULTIPLY(tmp8, FIX_1_414213562); 2*c4 */
- psllw_i2r(2, mm1);
+ psllw_i2r (2, mm1);
- psllw_i2r(2, mm0);
+ psllw_i2r (2, mm0);
- pmulhw_m2r(fix_141, mm1); /* tmp21 */
+ pmulhw_m2r (fix_141, mm1); /* tmp21 */
/* tmp20 = MULTIPLY(z12, (FIX_1_082392200- FIX_1_847759065)) : 2*(c2-c6) */
/* + MULTIPLY(z10, - FIX_1_847759065); : 2*c2 */
- psllw_i2r(2, mm3);
- movq_r2r(mm0, mm7);
+ psllw_i2r (2, mm3);
+ movq_r2r (mm0, mm7);
- pmulhw_m2r(fix_n184, mm7);
- movq_r2r(mm3, mm6);
+ pmulhw_m2r (fix_n184, mm7);
+ movq_r2r (mm3, mm6);
- movq_m2r(*(wsptr), mm2); /* tmp0,final1 */
+ movq_m2r (*(wsptr), mm2); /* tmp0,final1 */
- pmulhw_m2r(fix_108n184, mm6);
+ pmulhw_m2r (fix_108n184, mm6);
/* tmp22 = MULTIPLY(z10,(FIX_1_847759065 - FIX_2_613125930)) : -2*(c2+c6) */
/* + MULTIPLY(z12, FIX_1_847759065); : 2*c2 */
- movq_r2r(mm2, mm4); /* final1 */
-
- pmulhw_m2r(fix_184n261, mm0);
- paddw_r2r(mm5, mm2); /* tmp0+tmp7,final1 */
+ movq_r2r (mm2, mm4); /* final1 */
+
+ pmulhw_m2r (fix_184n261, mm0);
+ paddw_r2r (mm5, mm2); /* tmp0+tmp7,final1 */
- pmulhw_m2r(fix_184, mm3);
- psubw_r2r(mm5, mm4); /* tmp0-tmp7,final1 */
+ pmulhw_m2r (fix_184, mm3);
+ psubw_r2r (mm5, mm4); /* tmp0-tmp7,final1 */
/* tmp6 = tmp22 - tmp7; phase 2 */
- psraw_i2r(3, mm2); /* outptr[0,0],[1,0],[2,0],[3,0],final1 */
+ psraw_i2r (3, mm2); /* outptr[0,0],[1,0],[2,0],[3,0],final1 */
- paddw_r2r(mm6, mm7); /* tmp20 */
- psraw_i2r(3, mm4); /* outptr[0,7],[1,7],[2,7],[3,7],final1 */
+ paddw_r2r (mm6, mm7); /* tmp20 */
+ psraw_i2r (3, mm4); /* outptr[0,7],[1,7],[2,7],[3,7],final1 */
- paddw_r2r(mm0, mm3); /* tmp22 */
+ paddw_r2r (mm0, mm3); /* tmp22 */
/* tmp5 = tmp21 - tmp6; */
- psubw_r2r(mm5, mm3); /* tmp6 */
+ psubw_r2r (mm5, mm3); /* tmp6 */
/* tmp4 = tmp20 + tmp5; */
- movq_m2r(*(wsptr+1), mm0); /* tmp1,final2 */
- psubw_r2r(mm3, mm1); /* tmp5 */
+ movq_m2r (*(wsptr + 1), mm0); /* tmp1,final2 */
+ psubw_r2r (mm3, mm1); /* tmp5 */
- movq_r2r(mm0, mm6); /* final2 */
- paddw_r2r(mm3, mm0); /* tmp1+tmp6,final2 */
+ movq_r2r (mm0, mm6); /* final2 */
+ paddw_r2r (mm3, mm0); /* tmp1+tmp6,final2 */
- /* Final output stage: scale down by a factor of 8 and range-limit */
+ /* Final output stage: scale down by a factor of 8 and range-limit */
/* outptr[0] = range_limit[IDESCALE(tmp0 + tmp7, PASS1_BITS+3) */
/* & RANGE_MASK]; */
/* & RANGE_MASK]; */
/* outptr[6] = range_limit[IDESCALE(tmp1 - tmp6, PASS1_BITS+3) */
/* & RANGE_MASK]; final2 */
- psubw_r2r(mm3, mm6); /* tmp1-tmp6,final2 */
- psraw_i2r(3, mm0); /* outptr[0,1],[1,1],[2,1],[3,1] */
+ psubw_r2r (mm3, mm6); /* tmp1-tmp6,final2 */
+ psraw_i2r (3, mm0); /* outptr[0,1],[1,1],[2,1],[3,1] */
+
+ psraw_i2r (3, mm6); /* outptr[0,6],[1,6],[2,6],[3,6] */
+
+ packuswb_r2r (mm4, mm0); /* out[0,1],[1,1],[2,1],[3,1],[0,7],[1,7],[2,7],[3,7] */
- psraw_i2r(3, mm6); /* outptr[0,6],[1,6],[2,6],[3,6] */
-
- packuswb_r2r(mm4, mm0); /* out[0,1],[1,1],[2,1],[3,1],[0,7],[1,7],[2,7],[3,7] */
-
- movq_m2r(*(wsptr+2), mm5); /* tmp2,final3 */
- packuswb_r2r(mm6, mm2); /* out[0,0],[1,0],[2,0],[3,0],[0,6],[1,6],[2,6],[3,6] */
+ movq_m2r (*(wsptr + 2), mm5); /* tmp2,final3 */
+ packuswb_r2r (mm6, mm2); /* out[0,0],[1,0],[2,0],[3,0],[0,6],[1,6],[2,6],[3,6] */
/* outptr[2] = range_limit[IDESCALE(tmp2 + tmp5, PASS1_BITS+3) */
/* & RANGE_MASK]; */
/* outptr[5] = range_limit[IDESCALE(tmp2 - tmp5, PASS1_BITS+3) */
/* & RANGE_MASK]; final3 */
- paddw_r2r(mm1, mm7); /* tmp4 */
- movq_r2r(mm5, mm3);
+ paddw_r2r (mm1, mm7); /* tmp4 */
+ movq_r2r (mm5, mm3);
- paddw_r2r(mm1, mm5); /* tmp2+tmp5 */
- psubw_r2r(mm1, mm3); /* tmp2-tmp5 */
+ paddw_r2r (mm1, mm5); /* tmp2+tmp5 */
+ psubw_r2r (mm1, mm3); /* tmp2-tmp5 */
- psraw_i2r(3, mm5); /* outptr[0,2],[1,2],[2,2],[3,2] */
+ psraw_i2r (3, mm5); /* outptr[0,2],[1,2],[2,2],[3,2] */
- movq_m2r(*(wsptr+3), mm4); /* tmp3,final4 */
- psraw_i2r(3, mm3); /* outptr[0,5],[1,5],[2,5],[3,5] */
+ movq_m2r (*(wsptr + 3), mm4); /* tmp3,final4 */
+ psraw_i2r (3, mm3); /* outptr[0,5],[1,5],[2,5],[3,5] */
/* & RANGE_MASK]; */
/* outptr[3] = range_limit[IDESCALE(tmp3 - tmp4, PASS1_BITS+3) */
/* & RANGE_MASK]; final4 */
- movq_r2r(mm4, mm6);
- paddw_r2r(mm7, mm4); /* tmp3+tmp4 */
+ movq_r2r (mm4, mm6);
+ paddw_r2r (mm7, mm4); /* tmp3+tmp4 */
- psubw_r2r(mm7, mm6); /* tmp3-tmp4 */
- psraw_i2r(3, mm4); /* outptr[0,4],[1,4],[2,4],[3,4] */
+ psubw_r2r (mm7, mm6); /* tmp3-tmp4 */
+ psraw_i2r (3, mm4); /* outptr[0,4],[1,4],[2,4],[3,4] */
- psraw_i2r(3, mm6); /* outptr[0,3],[1,3],[2,3],[3,3] */
+ psraw_i2r (3, mm6); /* outptr[0,3],[1,3],[2,3],[3,3] */
- /*
- movq_r2m(mm4, *dummy);
- fprintf(stderr, "3-4 %016llx\n", dummy);
- movq_r2m(mm4, *dummy);
- fprintf(stderr, "3+4 %016llx\n", dummy);
- */
-
+ /*
+ movq_r2m(mm4, *dummy);
+ fprintf(stderr, "3-4 %016llx\n", dummy);
+ movq_r2m(mm4, *dummy);
+ fprintf(stderr, "3+4 %016llx\n", dummy);
+ */
- packuswb_r2r(mm4, mm5); /* out[0,2],[1,2],[2,2],[3,2],[0,4],[1,4],[2,4],[3,4] */
- packuswb_r2r(mm3, mm6); /* out[0,3],[1,3],[2,3],[3,3],[0,5],[1,5],[2,5],[3,5] */
- movq_r2r(mm2, mm4);
+ packuswb_r2r (mm4, mm5); /* out[0,2],[1,2],[2,2],[3,2],[0,4],[1,4],[2,4],[3,4] */
- movq_r2r(mm5, mm7);
- punpcklbw_r2r(mm0, mm2); /* out[0,0],[0,1],[1,0],[1,1],[2,0],[2,1],[3,0],[3,1] */
+ packuswb_r2r (mm3, mm6); /* out[0,3],[1,3],[2,3],[3,3],[0,5],[1,5],[2,5],[3,5] */
+ movq_r2r (mm2, mm4);
- punpckhbw_r2r(mm0, mm4); /* out[0,6],[0,7],[1,6],[1,7],[2,6],[2,7],[3,6],[3,7] */
- movq_r2r(mm2, mm1);
+ movq_r2r (mm5, mm7);
+ punpcklbw_r2r (mm0, mm2); /* out[0,0],[0,1],[1,0],[1,1],[2,0],[2,1],[3,0],[3,1] */
- punpcklbw_r2r(mm6, mm5); /* out[0,2],[0,3],[1,2],[1,3],[2,2],[2,3],[3,2],[3,3] */
-
- punpckhbw_r2r(mm6, mm7); /* out[0,4],[0,5],[1,4],[1,5],[2,4],[2,5],[3,4],[3,5] */
+ punpckhbw_r2r (mm0, mm4); /* out[0,6],[0,7],[1,6],[1,7],[2,6],[2,7],[3,6],[3,7] */
+ movq_r2r (mm2, mm1);
- punpcklwd_r2r(mm5, mm2); /* out[0,0],[0,1],[0,2],[0,3],[1,0],[1,1],[1,2],[1,3] */
-
- movq_r2r(mm7, mm6);
- punpckhwd_r2r(mm5, mm1); /* out[2,0],[2,1],[2,2],[2,3],[3,0],[3,1],[3,2],[3,3] */
+ punpcklbw_r2r (mm6, mm5); /* out[0,2],[0,3],[1,2],[1,3],[2,2],[2,3],[3,2],[3,3] */
- movq_r2r(mm2, mm0);
- punpcklwd_r2r(mm4, mm6); /* out[0,4],[0,5],[0,6],[0,7],[1,4],[1,5],[1,6],[1,7] */
+ punpckhbw_r2r (mm6, mm7); /* out[0,4],[0,5],[1,4],[1,5],[2,4],[2,5],[3,4],[3,5] */
- punpckldq_r2r(mm6, mm2); /* out[0,0],[0,1],[0,2],[0,3],[0,4],[0,5],[0,6],[0,7] */
+ punpcklwd_r2r (mm5, mm2); /* out[0,0],[0,1],[0,2],[0,3],[1,0],[1,1],[1,2],[1,3] */
- movq_r2r(mm1, mm3);
+ movq_r2r (mm7, mm6);
+ punpckhwd_r2r (mm5, mm1); /* out[2,0],[2,1],[2,2],[2,3],[3,0],[3,1],[3,2],[3,3] */
- punpckhwd_r2r(mm4, mm7); /* out[2,4],[2,5],[2,6],[2,7],[3,4],[3,5],[3,6],[3,7] */
-
- dataptr += rskip;
- movq_r2m(mm2, *(dataptr));
+ movq_r2r (mm2, mm0);
+ punpcklwd_r2r (mm4, mm6); /* out[0,4],[0,5],[0,6],[0,7],[1,4],[1,5],[1,6],[1,7] */
- punpckhdq_r2r(mm6, mm0); /* out[1,0],[1,1],[1,2],[1,3],[1,4],[1,5],[1,6],[1,7] */
+ punpckldq_r2r (mm6, mm2); /* out[0,0],[0,1],[0,2],[0,3],[0,4],[0,5],[0,6],[0,7] */
- dataptr += rskip;
- movq_r2m(mm0, *(dataptr));
+ movq_r2r (mm1, mm3);
- punpckldq_r2r(mm7, mm1); /* out[2,0],[2,1],[2,2],[2,3],[2,4],[2,5],[2,6],[2,7] */
-
- punpckhdq_r2r(mm7, mm3); /* out[3,0],[3,1],[3,2],[3,3],[3,4],[3,5],[3,6],[3,7] */
+ punpckhwd_r2r (mm4, mm7); /* out[2,4],[2,5],[2,6],[2,7],[3,4],[3,5],[3,6],[3,7] */
- dataptr += rskip;
- movq_r2m(mm1, *(dataptr));
+ dataptr += rskip;
+ movq_r2m (mm2, *(dataptr));
- dataptr += rskip;
- movq_r2m(mm3, *(dataptr));
+ punpckhdq_r2r (mm6, mm0); /* out[1,0],[1,1],[1,2],[1,3],[1,4],[1,5],[1,6],[1,7] */
+
+ dataptr += rskip;
+ movq_r2m (mm0, *(dataptr));
+
+ punpckldq_r2r (mm7, mm1); /* out[2,0],[2,1],[2,2],[2,3],[2,4],[2,5],[2,6],[2,7] */
+
+ punpckhdq_r2r (mm7, mm3); /* out[3,0],[3,1],[3,2],[3,3],[3,4],[3,5],[3,6],[3,7] */
+
+ dataptr += rskip;
+ movq_r2m (mm1, *(dataptr));
+
+ dataptr += rskip;
+ movq_r2m (mm3, *(dataptr));
#else
__s32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
inptr = data;
wsptr = workspace;
for (ctr = 8; ctr > 0; ctr--) {
-
+
if ((inptr[8] | inptr[16] | inptr[24] |
- inptr[32] | inptr[40] | inptr[48] | inptr[56]) == 0) {
+ inptr[32] | inptr[40] | inptr[48] | inptr[56]) == 0) {
dcval = inptr[0];
wsptr[0] = dcval;
wsptr[8] = dcval;
wsptr[40] = dcval;
wsptr[48] = dcval;
wsptr[56] = dcval;
-
- inptr++;
+
+ inptr++;
wsptr++;
continue;
- }
-
+ }
+
tmp0 = inptr[0];
tmp1 = inptr[16];
tmp2 = inptr[32];
tmp11 = tmp0 - tmp2;
tmp13 = tmp1 + tmp3;
- tmp12 = MULTIPLY(tmp1 - tmp3, FIX_1_414213562) - tmp13;
+ tmp12 = MULTIPLY (tmp1 - tmp3, FIX_1_414213562) - tmp13;
tmp0 = tmp10 + tmp13;
tmp3 = tmp10 - tmp13;
tmp1 = tmp11 + tmp12;
tmp2 = tmp11 - tmp12;
-
+
tmp4 = inptr[8];
tmp5 = inptr[24];
tmp6 = inptr[40];
z12 = tmp4 - tmp7;
tmp7 = z11 + z13;
- tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562);
+ tmp11 = MULTIPLY (z11 - z13, FIX_1_414213562);
- z5 = MULTIPLY(z10 + z12, FIX_1_847759065);
- tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5;
- tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5;
+ z5 = MULTIPLY (z10 + z12, FIX_1_847759065);
+ tmp10 = MULTIPLY (z12, FIX_1_082392200) - z5;
+ tmp12 = MULTIPLY (z10, -FIX_2_613125930) + z5;
tmp6 = tmp12 - tmp7;
tmp5 = tmp11 - tmp6;
wsptr = workspace;
for (ctr = 0; ctr < 8; ctr++) {
- outptr = &(odata[ctr*rskip]);
+ outptr = &(odata[ctr * rskip]);
tmp10 = wsptr[0] + wsptr[4];
tmp11 = wsptr[0] - wsptr[4];
tmp13 = wsptr[2] + wsptr[6];
- tmp12 = MULTIPLY(wsptr[2] - wsptr[6], FIX_1_414213562) - tmp13;
+ tmp12 = MULTIPLY (wsptr[2] - wsptr[6], FIX_1_414213562) - tmp13;
tmp0 = tmp10 + tmp13;
tmp3 = tmp10 - tmp13;
z12 = wsptr[1] - wsptr[7];
tmp7 = z11 + z13;
- tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562);
+ tmp11 = MULTIPLY (z11 - z13, FIX_1_414213562);
- z5 = MULTIPLY(z10 + z12, FIX_1_847759065);
- tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5;
- tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5;
+ z5 = MULTIPLY (z10 + z12, FIX_1_847759065);
+ tmp10 = MULTIPLY (z12, FIX_1_082392200) - z5;
+ tmp12 = MULTIPLY (z10, -FIX_2_613125930) + z5;
tmp6 = tmp12 - tmp7;
tmp5 = tmp11 - tmp6;
tmp4 = tmp10 + tmp5;
- outptr[0] = RL(DESCALE(tmp0 + tmp7));
- outptr[7] = RL(DESCALE(tmp0 - tmp7));
- outptr[1] = RL(DESCALE(tmp1 + tmp6));
- outptr[6] = RL(DESCALE(tmp1 - tmp6));
- outptr[2] = RL(DESCALE(tmp2 + tmp5));
- outptr[5] = RL(DESCALE(tmp2 - tmp5));
- outptr[4] = RL(DESCALE(tmp3 + tmp4));
- outptr[3] = RL(DESCALE(tmp3 - tmp4));
+ outptr[0] = RL (DESCALE (tmp0 + tmp7));
+ outptr[7] = RL (DESCALE (tmp0 - tmp7));
+ outptr[1] = RL (DESCALE (tmp1 + tmp6));
+ outptr[6] = RL (DESCALE (tmp1 - tmp6));
+ outptr[2] = RL (DESCALE (tmp2 + tmp5));
+ outptr[5] = RL (DESCALE (tmp2 - tmp5));
+ outptr[4] = RL (DESCALE (tmp3 + tmp4));
+ outptr[3] = RL (DESCALE (tmp3 - tmp4));
wsptr += 8;
}
#endif
}
+
/*
Main Routines
*/
-void RTjpeg_init_data(void)
+void
+RTjpeg_init_data (void)
{
- unsigned long dptr;
-
- dptr=(unsigned long)&(RTjpeg_alldata[0]);
- dptr+=32;
- dptr=dptr>>5;
- dptr=dptr<<5; /* cache align data */
-
- RTjpeg_block=(__s16 *)dptr;
- dptr+=sizeof(__s16)*64;
- RTjpeg_lqt=(__s32 *)dptr;
- dptr+=sizeof(__s32)*64;
- RTjpeg_cqt=(__s32 *)dptr;
- dptr+=sizeof(__s32)*64;
- RTjpeg_liqt=(__u32 *)dptr;
- dptr+=sizeof(__u32)*64;
- RTjpeg_ciqt=(__u32 *)dptr;
+ unsigned long dptr;
+
+ dptr = (unsigned long) &(RTjpeg_alldata[0]);
+ dptr += 32;
+ dptr = dptr >> 5;
+ dptr = dptr << 5; /* cache align data */
+
+ RTjpeg_block = (__s16 *) dptr;
+ dptr += sizeof (__s16) * 64;
+ RTjpeg_lqt = (__s32 *) dptr;
+ dptr += sizeof (__s32) * 64;
+ RTjpeg_cqt = (__s32 *) dptr;
+ dptr += sizeof (__s32) * 64;
+ RTjpeg_liqt = (__u32 *) dptr;
+ dptr += sizeof (__u32) * 64;
+ RTjpeg_ciqt = (__u32 *) dptr;
}
/*
Q -> quality factor (192=best, 32=worst)
*/
-void RTjpeg_init_Q(__u8 Q)
+void
+RTjpeg_init_Q (__u8 Q)
{
- int i;
- __u64 qual;
-
- qual=(__u64)Q<<(32-7); /* 32 bit FP, 255=2, 0=0 */
-
- for(i=0; i<64; i++)
- {
- RTjpeg_lqt[i]=(__s32)((qual/((__u64)RTjpeg_lum_quant_tbl[i]<<16))>>3);
- if(RTjpeg_lqt[i]==0)RTjpeg_lqt[i]=1;
- RTjpeg_cqt[i]=(__s32)((qual/((__u64)RTjpeg_chrom_quant_tbl[i]<<16))>>3);
- if(RTjpeg_cqt[i]==0)RTjpeg_cqt[i]=1;
- RTjpeg_liqt[i]=(1<<16)/(RTjpeg_lqt[i]<<3);
- RTjpeg_ciqt[i]=(1<<16)/(RTjpeg_cqt[i]<<3);
- RTjpeg_lqt[i]=((1<<16)/RTjpeg_liqt[i])>>3;
- RTjpeg_cqt[i]=((1<<16)/RTjpeg_ciqt[i])>>3;
- }
-
- RTjpeg_lb8=0;
- while(RTjpeg_liqt[RTjpeg_ZZ[++RTjpeg_lb8]]<=8);
- RTjpeg_lb8--;
- RTjpeg_cb8=0;
- while(RTjpeg_ciqt[RTjpeg_ZZ[++RTjpeg_cb8]]<=8);
- RTjpeg_cb8--;
-
- RTjpeg_dct_init();
- RTjpeg_idct_init();
- RTjpeg_quant_init();
+ int i;
+ __u64 qual;
+
+ qual = (__u64) Q << (32 - 7); /* 32 bit FP, 255=2, 0=0 */
+
+ for (i = 0; i < 64; i++) {
+ RTjpeg_lqt[i] =
+ (__s32) ((qual / ((__u64) RTjpeg_lum_quant_tbl[i] << 16)) >> 3);
+ if (RTjpeg_lqt[i] == 0)
+ RTjpeg_lqt[i] = 1;
+ RTjpeg_cqt[i] =
+ (__s32) ((qual / ((__u64) RTjpeg_chrom_quant_tbl[i] << 16)) >> 3);
+ if (RTjpeg_cqt[i] == 0)
+ RTjpeg_cqt[i] = 1;
+ RTjpeg_liqt[i] = (1 << 16) / (RTjpeg_lqt[i] << 3);
+ RTjpeg_ciqt[i] = (1 << 16) / (RTjpeg_cqt[i] << 3);
+ RTjpeg_lqt[i] = ((1 << 16) / RTjpeg_liqt[i]) >> 3;
+ RTjpeg_cqt[i] = ((1 << 16) / RTjpeg_ciqt[i]) >> 3;
+ }
+
+ RTjpeg_lb8 = 0;
+ while (RTjpeg_liqt[RTjpeg_ZZ[++RTjpeg_lb8]] <= 8);
+ RTjpeg_lb8--;
+ RTjpeg_cb8 = 0;
+ while (RTjpeg_ciqt[RTjpeg_ZZ[++RTjpeg_cb8]] <= 8);
+ RTjpeg_cb8--;
+
+ RTjpeg_dct_init ();
+ RTjpeg_idct_init ();
+ RTjpeg_quant_init ();
}
/*
*/
-void RTjpeg_init_compress(__u32 *buf, int width, int height, __u8 Q)
+void
+RTjpeg_init_compress (__u32 * buf, int width, int height, __u8 Q)
{
- int i;
- __u64 qual;
-
- RTjpeg_init_data();
-
- RTjpeg_width=width;
- RTjpeg_height=height;
- RTjpeg_Ywidth = RTjpeg_width>>3;
- RTjpeg_Ysize=width * height;
- RTjpeg_Cwidth = RTjpeg_width>>4;
- RTjpeg_Csize= (width>>1) * height;
-
- qual=(__u64)Q<<(32-7); /* 32 bit FP, 255=2, 0=0 */
-
- for(i=0; i<64; i++)
- {
- RTjpeg_lqt[i]=(__s32)((qual/((__u64)RTjpeg_lum_quant_tbl[i]<<16))>>3);
- if(RTjpeg_lqt[i]==0)RTjpeg_lqt[i]=1;
- RTjpeg_cqt[i]=(__s32)((qual/((__u64)RTjpeg_chrom_quant_tbl[i]<<16))>>3);
- if(RTjpeg_cqt[i]==0)RTjpeg_cqt[i]=1;
- RTjpeg_liqt[i]=(1<<16)/(RTjpeg_lqt[i]<<3);
- RTjpeg_ciqt[i]=(1<<16)/(RTjpeg_cqt[i]<<3);
- RTjpeg_lqt[i]=((1<<16)/RTjpeg_liqt[i])>>3;
- RTjpeg_cqt[i]=((1<<16)/RTjpeg_ciqt[i])>>3;
- }
-
- RTjpeg_lb8=0;
- while(RTjpeg_liqt[RTjpeg_ZZ[++RTjpeg_lb8]]<=8);
- RTjpeg_lb8--;
- RTjpeg_cb8=0;
- while(RTjpeg_ciqt[RTjpeg_ZZ[++RTjpeg_cb8]]<=8);
- RTjpeg_cb8--;
-
- RTjpeg_dct_init();
- RTjpeg_quant_init();
-
- for(i=0; i<64; i++)
- buf[i]=RTjpeg_liqt[i];
- for(i=0; i<64; i++)
- buf[64+i]=RTjpeg_ciqt[i];
+ int i;
+ __u64 qual;
+
+ RTjpeg_init_data ();
+
+ RTjpeg_width = width;
+ RTjpeg_height = height;
+ RTjpeg_Ywidth = RTjpeg_width >> 3;
+ RTjpeg_Ysize = width * height;
+ RTjpeg_Cwidth = RTjpeg_width >> 4;
+ RTjpeg_Csize = (width >> 1) * height;
+
+ qual = (__u64) Q << (32 - 7); /* 32 bit FP, 255=2, 0=0 */
+
+ for (i = 0; i < 64; i++) {
+ RTjpeg_lqt[i] =
+ (__s32) ((qual / ((__u64) RTjpeg_lum_quant_tbl[i] << 16)) >> 3);
+ if (RTjpeg_lqt[i] == 0)
+ RTjpeg_lqt[i] = 1;
+ RTjpeg_cqt[i] =
+ (__s32) ((qual / ((__u64) RTjpeg_chrom_quant_tbl[i] << 16)) >> 3);
+ if (RTjpeg_cqt[i] == 0)
+ RTjpeg_cqt[i] = 1;
+ RTjpeg_liqt[i] = (1 << 16) / (RTjpeg_lqt[i] << 3);
+ RTjpeg_ciqt[i] = (1 << 16) / (RTjpeg_cqt[i] << 3);
+ RTjpeg_lqt[i] = ((1 << 16) / RTjpeg_liqt[i]) >> 3;
+ RTjpeg_cqt[i] = ((1 << 16) / RTjpeg_ciqt[i]) >> 3;
+ }
+
+ RTjpeg_lb8 = 0;
+ while (RTjpeg_liqt[RTjpeg_ZZ[++RTjpeg_lb8]] <= 8);
+ RTjpeg_lb8--;
+ RTjpeg_cb8 = 0;
+ while (RTjpeg_ciqt[RTjpeg_ZZ[++RTjpeg_cb8]] <= 8);
+ RTjpeg_cb8--;
+
+ RTjpeg_dct_init ();
+ RTjpeg_quant_init ();
+
+ for (i = 0; i < 64; i++)
+ buf[i] = RTjpeg_liqt[i];
+ for (i = 0; i < 64; i++)
+ buf[64 + i] = RTjpeg_ciqt[i];
}
-void RTjpeg_init_decompress(__u32 *buf, int width, int height)
+void
+RTjpeg_init_decompress (__u32 * buf, int width, int height)
{
- int i;
-
- RTjpeg_init_data();
-
- RTjpeg_width=width;
- RTjpeg_height=height;
- RTjpeg_Ywidth = RTjpeg_width>>3;
- RTjpeg_Ysize=width * height;
- RTjpeg_Cwidth = RTjpeg_width>>4;
- RTjpeg_Csize= (width>>1) * height;
-
- for(i=0; i<64; i++)
- {
- RTjpeg_liqt[i]=buf[i];
- RTjpeg_ciqt[i]=buf[i+64];
- }
-
- RTjpeg_lb8=0;
- while(RTjpeg_liqt[RTjpeg_ZZ[++RTjpeg_lb8]]<=8);
- RTjpeg_lb8--;
- RTjpeg_cb8=0;
- while(RTjpeg_ciqt[RTjpeg_ZZ[++RTjpeg_cb8]]<=8);
- RTjpeg_cb8--;
-
- RTjpeg_idct_init();
+ int i;
+
+ RTjpeg_init_data ();
+
+ RTjpeg_width = width;
+ RTjpeg_height = height;
+ RTjpeg_Ywidth = RTjpeg_width >> 3;
+ RTjpeg_Ysize = width * height;
+ RTjpeg_Cwidth = RTjpeg_width >> 4;
+ RTjpeg_Csize = (width >> 1) * height;
+
+ for (i = 0; i < 64; i++) {
+ RTjpeg_liqt[i] = buf[i];
+ RTjpeg_ciqt[i] = buf[i + 64];
+ }
+
+ RTjpeg_lb8 = 0;
+ while (RTjpeg_liqt[RTjpeg_ZZ[++RTjpeg_lb8]] <= 8);
+ RTjpeg_lb8--;
+ RTjpeg_cb8 = 0;
+ while (RTjpeg_ciqt[RTjpeg_ZZ[++RTjpeg_cb8]] <= 8);
+ RTjpeg_cb8--;
+
+ RTjpeg_idct_init ();
/* RTjpeg_color_init(); */
}
-int RTjpeg_compressYUV420(__s8 *sp, unsigned char *bp)
+int
+RTjpeg_compressYUV420 (__s8 * sp, unsigned char *bp)
{
- __s8 * sb;
- register __s8 * bp1 = bp + (RTjpeg_width<<3);
- register __s8 * bp2 = bp + RTjpeg_Ysize;
- register __s8 * bp3 = bp2 + (RTjpeg_Csize>>1);
- register int i, j, k;
+ __s8 *sb;
+ register __s8 *bp1 = bp + (RTjpeg_width << 3);
+ register __s8 *bp2 = bp + RTjpeg_Ysize;
+ register __s8 *bp3 = bp2 + (RTjpeg_Csize >> 1);
+ register int i, j, k;
#ifdef HAVE_LIBMMX
- emms();
+ emms ();
#endif
- sb=sp;
+ sb = sp;
/* Y */
- for(i=RTjpeg_height>>1; i; i-=8)
- {
- for(j=0, k=0; j<RTjpeg_width; j+=16, k+=8)
- {
- RTjpeg_dctY(bp+j, RTjpeg_block, RTjpeg_Ywidth);
- RTjpeg_quant(RTjpeg_block, RTjpeg_lqt);
- sp+=RTjpeg_b2s(RTjpeg_block, sp, RTjpeg_lb8);
-
- RTjpeg_dctY(bp+j+8, RTjpeg_block, RTjpeg_Ywidth);
- RTjpeg_quant(RTjpeg_block, RTjpeg_lqt);
- sp+=RTjpeg_b2s(RTjpeg_block, sp, RTjpeg_lb8);
-
- RTjpeg_dctY(bp1+j, RTjpeg_block, RTjpeg_Ywidth);
- RTjpeg_quant(RTjpeg_block, RTjpeg_lqt);
- sp+=RTjpeg_b2s(RTjpeg_block, sp, RTjpeg_lb8);
-
- RTjpeg_dctY(bp1+j+8, RTjpeg_block, RTjpeg_Ywidth);
- RTjpeg_quant(RTjpeg_block, RTjpeg_lqt);
- sp+=RTjpeg_b2s(RTjpeg_block, sp, RTjpeg_lb8);
-
- RTjpeg_dctY(bp2+k, RTjpeg_block, RTjpeg_Cwidth);
- RTjpeg_quant(RTjpeg_block, RTjpeg_cqt);
- sp+=RTjpeg_b2s(RTjpeg_block, sp, RTjpeg_cb8);
-
- RTjpeg_dctY(bp3+k, RTjpeg_block, RTjpeg_Cwidth);
- RTjpeg_quant(RTjpeg_block, RTjpeg_cqt);
- sp+=RTjpeg_b2s(RTjpeg_block, sp, RTjpeg_cb8);
+ for (i = RTjpeg_height >> 1; i; i -= 8) {
+ for (j = 0, k = 0; j < RTjpeg_width; j += 16, k += 8) {
+ RTjpeg_dctY (bp + j, RTjpeg_block, RTjpeg_Ywidth);
+ RTjpeg_quant (RTjpeg_block, RTjpeg_lqt);
+ sp += RTjpeg_b2s (RTjpeg_block, sp, RTjpeg_lb8);
+
+ RTjpeg_dctY (bp + j + 8, RTjpeg_block, RTjpeg_Ywidth);
+ RTjpeg_quant (RTjpeg_block, RTjpeg_lqt);
+ sp += RTjpeg_b2s (RTjpeg_block, sp, RTjpeg_lb8);
+
+ RTjpeg_dctY (bp1 + j, RTjpeg_block, RTjpeg_Ywidth);
+ RTjpeg_quant (RTjpeg_block, RTjpeg_lqt);
+ sp += RTjpeg_b2s (RTjpeg_block, sp, RTjpeg_lb8);
+
+ RTjpeg_dctY (bp1 + j + 8, RTjpeg_block, RTjpeg_Ywidth);
+ RTjpeg_quant (RTjpeg_block, RTjpeg_lqt);
+ sp += RTjpeg_b2s (RTjpeg_block, sp, RTjpeg_lb8);
+
+ RTjpeg_dctY (bp2 + k, RTjpeg_block, RTjpeg_Cwidth);
+ RTjpeg_quant (RTjpeg_block, RTjpeg_cqt);
+ sp += RTjpeg_b2s (RTjpeg_block, sp, RTjpeg_cb8);
+
+ RTjpeg_dctY (bp3 + k, RTjpeg_block, RTjpeg_Cwidth);
+ RTjpeg_quant (RTjpeg_block, RTjpeg_cqt);
+ sp += RTjpeg_b2s (RTjpeg_block, sp, RTjpeg_cb8);
+
+ }
+ bp += RTjpeg_width << 4;
+ bp1 += RTjpeg_width << 4;
+ bp2 += RTjpeg_width << 2;
+ bp3 += RTjpeg_width << 2;
}
- bp+=RTjpeg_width<<4;
- bp1+=RTjpeg_width<<4;
- bp2+=RTjpeg_width<<2;
- bp3+=RTjpeg_width<<2;
-
- }
#ifdef HAVE_LIBMMX
- emms();
+ emms ();
#endif
- return (sp-sb);
+ return (sp - sb);
}
-int RTjpeg_compressYUV422(__s8 *sp, unsigned char *bp)
+int
+RTjpeg_compressYUV422 (__s8 * sp, unsigned char *bp)
{
- __s8 * sb;
- register __s8 * bp2 = bp + RTjpeg_Ysize;
- register __s8 * bp3 = bp2 + RTjpeg_Csize;
- register int i, j, k;
+ __s8 *sb;
+ register __s8 *bp2 = bp + RTjpeg_Ysize;
+ register __s8 *bp3 = bp2 + RTjpeg_Csize;
+ register int i, j, k;
#ifdef HAVE_LIBMMX
- emms();
+ emms ();
#endif
- sb=sp;
+ sb = sp;
/* Y */
- for(i=RTjpeg_height; i; i-=8)
- {
- for(j=0, k=0; j<RTjpeg_width; j+=16, k+=8)
- {
- RTjpeg_dctY(bp+j, RTjpeg_block, RTjpeg_Ywidth);
- RTjpeg_quant(RTjpeg_block, RTjpeg_lqt);
- sp+=RTjpeg_b2s(RTjpeg_block, sp, RTjpeg_lb8);
-
- RTjpeg_dctY(bp+j+8, RTjpeg_block, RTjpeg_Ywidth);
- RTjpeg_quant(RTjpeg_block, RTjpeg_lqt);
- sp+=RTjpeg_b2s(RTjpeg_block, sp, RTjpeg_lb8);
-
- RTjpeg_dctY(bp2+k, RTjpeg_block, RTjpeg_Cwidth);
- RTjpeg_quant(RTjpeg_block, RTjpeg_cqt);
- sp+=RTjpeg_b2s(RTjpeg_block, sp, RTjpeg_cb8);
-
- RTjpeg_dctY(bp3+k, RTjpeg_block, RTjpeg_Cwidth);
- RTjpeg_quant(RTjpeg_block, RTjpeg_cqt);
- sp+=RTjpeg_b2s(RTjpeg_block, sp, RTjpeg_cb8);
+ for (i = RTjpeg_height; i; i -= 8) {
+ for (j = 0, k = 0; j < RTjpeg_width; j += 16, k += 8) {
+ RTjpeg_dctY (bp + j, RTjpeg_block, RTjpeg_Ywidth);
+ RTjpeg_quant (RTjpeg_block, RTjpeg_lqt);
+ sp += RTjpeg_b2s (RTjpeg_block, sp, RTjpeg_lb8);
+
+ RTjpeg_dctY (bp + j + 8, RTjpeg_block, RTjpeg_Ywidth);
+ RTjpeg_quant (RTjpeg_block, RTjpeg_lqt);
+ sp += RTjpeg_b2s (RTjpeg_block, sp, RTjpeg_lb8);
+
+ RTjpeg_dctY (bp2 + k, RTjpeg_block, RTjpeg_Cwidth);
+ RTjpeg_quant (RTjpeg_block, RTjpeg_cqt);
+ sp += RTjpeg_b2s (RTjpeg_block, sp, RTjpeg_cb8);
+
+ RTjpeg_dctY (bp3 + k, RTjpeg_block, RTjpeg_Cwidth);
+ RTjpeg_quant (RTjpeg_block, RTjpeg_cqt);
+ sp += RTjpeg_b2s (RTjpeg_block, sp, RTjpeg_cb8);
+
+ }
+ bp += RTjpeg_width << 3;
+ bp2 += RTjpeg_width << 2;
+ bp3 += RTjpeg_width << 2;
}
- bp+=RTjpeg_width<<3;
- bp2+=RTjpeg_width<<2;
- bp3+=RTjpeg_width<<2;
-
- }
#ifdef HAVE_LIBMMX
- emms();
+ emms ();
#endif
- return (sp-sb);
+ return (sp - sb);
}
-int RTjpeg_compress8(__s8 *sp, unsigned char *bp)
+int
+RTjpeg_compress8 (__s8 * sp, unsigned char *bp)
{
- __s8 * sb;
- int i, j;
+ __s8 *sb;
+ int i, j;
#ifdef HAVE_LIBMMX
- emms();
+ emms ();
#endif
-
- sb=sp;
+
+ sb = sp;
/* Y */
- for(i=0; i<RTjpeg_height; i+=8)
- {
- for(j=0; j<RTjpeg_width; j+=8)
- {
- RTjpeg_dctY(bp+j, RTjpeg_block, RTjpeg_width);
- RTjpeg_quant(RTjpeg_block, RTjpeg_lqt);
- sp+=RTjpeg_b2s(RTjpeg_block, sp, RTjpeg_lb8);
+ for (i = 0; i < RTjpeg_height; i += 8) {
+ for (j = 0; j < RTjpeg_width; j += 8) {
+ RTjpeg_dctY (bp + j, RTjpeg_block, RTjpeg_width);
+ RTjpeg_quant (RTjpeg_block, RTjpeg_lqt);
+ sp += RTjpeg_b2s (RTjpeg_block, sp, RTjpeg_lb8);
+ }
+ bp += RTjpeg_width;
}
- bp+=RTjpeg_width;
- }
#ifdef HAVE_LIBMMX
- emms();
+ emms ();
#endif
- return (sp-sb);
+ return (sp - sb);
}
-void RTjpeg_decompressYUV422(__s8 *sp, __u8 *bp)
+void
+RTjpeg_decompressYUV422 (__s8 * sp, __u8 * bp)
{
- register __s8 * bp2 = bp + RTjpeg_Ysize;
- register __s8 * bp3 = bp2 + (RTjpeg_Csize);
- int i, j,k;
+ register __s8 *bp2 = bp + RTjpeg_Ysize;
+ register __s8 *bp3 = bp2 + (RTjpeg_Csize);
+ int i, j, k;
#ifdef HAVE_LIBMMX
- emms();
+ emms ();
#endif
/* Y */
- for(i=RTjpeg_height; i; i-=8)
- {
- for(k=0, j=0; j<RTjpeg_width; j+=16, k+=8) {
- if(*sp==-1)sp++;
- else
- {
- sp+=RTjpeg_s2b(RTjpeg_block, sp, RTjpeg_lb8, RTjpeg_liqt);
- RTjpeg_idct(bp+j, RTjpeg_block, RTjpeg_width);
- }
- if(*sp==-1)sp++;
- else
- {
- sp+=RTjpeg_s2b(RTjpeg_block, sp, RTjpeg_lb8, RTjpeg_liqt);
- RTjpeg_idct(bp+j+8, RTjpeg_block, RTjpeg_width);
- }
- if(*sp==-1)sp++;
- else
- {
- sp+=RTjpeg_s2b(RTjpeg_block, sp, RTjpeg_cb8, RTjpeg_ciqt);
- RTjpeg_idct(bp2+k, RTjpeg_block, RTjpeg_width>>1);
- }
- if(*sp==-1)sp++;
- else
- {
- sp+=RTjpeg_s2b(RTjpeg_block, sp, RTjpeg_cb8, RTjpeg_ciqt);
- RTjpeg_idct(bp3+k, RTjpeg_block, RTjpeg_width>>1);
- }
+ for (i = RTjpeg_height; i; i -= 8) {
+ for (k = 0, j = 0; j < RTjpeg_width; j += 16, k += 8) {
+ if (*sp == -1)
+ sp++;
+ else {
+ sp += RTjpeg_s2b (RTjpeg_block, sp, RTjpeg_lb8, RTjpeg_liqt);
+ RTjpeg_idct (bp + j, RTjpeg_block, RTjpeg_width);
+ }
+ if (*sp == -1)
+ sp++;
+ else {
+ sp += RTjpeg_s2b (RTjpeg_block, sp, RTjpeg_lb8, RTjpeg_liqt);
+ RTjpeg_idct (bp + j + 8, RTjpeg_block, RTjpeg_width);
+ }
+ if (*sp == -1)
+ sp++;
+ else {
+ sp += RTjpeg_s2b (RTjpeg_block, sp, RTjpeg_cb8, RTjpeg_ciqt);
+ RTjpeg_idct (bp2 + k, RTjpeg_block, RTjpeg_width >> 1);
+ }
+ if (*sp == -1)
+ sp++;
+ else {
+ sp += RTjpeg_s2b (RTjpeg_block, sp, RTjpeg_cb8, RTjpeg_ciqt);
+ RTjpeg_idct (bp3 + k, RTjpeg_block, RTjpeg_width >> 1);
+ }
+ }
+ bp += RTjpeg_width << 3;
+ bp2 += RTjpeg_width << 2;
+ bp3 += RTjpeg_width << 2;
}
- bp+=RTjpeg_width<<3;
- bp2+=RTjpeg_width<<2;
- bp3+=RTjpeg_width<<2;
- }
#ifdef HAVE_LIBMMX
- emms();
+ emms ();
#endif
}
-void RTjpeg_decompressYUV420(__s8 *sp, __u8 *bp)
+void
+RTjpeg_decompressYUV420 (__s8 * sp, __u8 * bp)
{
- register __s8 * bp1 = bp + (RTjpeg_width<<3);
- register __s8 * bp2 = bp + RTjpeg_Ysize;
- register __s8 * bp3 = bp2 + (RTjpeg_Csize>>1);
- int i, j,k;
+ register __s8 *bp1 = bp + (RTjpeg_width << 3);
+ register __s8 *bp2 = bp + RTjpeg_Ysize;
+ register __s8 *bp3 = bp2 + (RTjpeg_Csize >> 1);
+ int i, j, k;
#ifdef HAVE_LIBMMX
- emms();
+ emms ();
#endif
/* Y */
- for(i=RTjpeg_height>>1; i; i-=8)
- {
- for(k=0, j=0; j<RTjpeg_width; j+=16, k+=8) {
- if(*sp==-1)sp++;
- else
- {
- sp+=RTjpeg_s2b(RTjpeg_block, sp, RTjpeg_lb8, RTjpeg_liqt);
- RTjpeg_idct(bp+j, RTjpeg_block, RTjpeg_width);
- }
- if(*sp==-1)sp++;
- else
- {
- sp+=RTjpeg_s2b(RTjpeg_block, sp, RTjpeg_lb8, RTjpeg_liqt);
- RTjpeg_idct(bp+j+8, RTjpeg_block, RTjpeg_width);
- }
- if(*sp==-1)sp++;
- else
- {
- sp+=RTjpeg_s2b(RTjpeg_block, sp, RTjpeg_lb8, RTjpeg_liqt);
- RTjpeg_idct(bp1+j, RTjpeg_block, RTjpeg_width);
- }
- if(*sp==-1)sp++;
- else
- {
- sp+=RTjpeg_s2b(RTjpeg_block, sp, RTjpeg_lb8, RTjpeg_liqt);
- RTjpeg_idct(bp1+j+8, RTjpeg_block, RTjpeg_width);
- }
- if(*sp==-1)sp++;
- else
- {
- sp+=RTjpeg_s2b(RTjpeg_block, sp, RTjpeg_cb8, RTjpeg_ciqt);
- RTjpeg_idct(bp2+k, RTjpeg_block, RTjpeg_width>>1);
- }
- if(*sp==-1)sp++;
- else
- {
- sp+=RTjpeg_s2b(RTjpeg_block, sp, RTjpeg_cb8, RTjpeg_ciqt);
- RTjpeg_idct(bp3+k, RTjpeg_block, RTjpeg_width>>1);
- }
+ for (i = RTjpeg_height >> 1; i; i -= 8) {
+ for (k = 0, j = 0; j < RTjpeg_width; j += 16, k += 8) {
+ if (*sp == -1)
+ sp++;
+ else {
+ sp += RTjpeg_s2b (RTjpeg_block, sp, RTjpeg_lb8, RTjpeg_liqt);
+ RTjpeg_idct (bp + j, RTjpeg_block, RTjpeg_width);
+ }
+ if (*sp == -1)
+ sp++;
+ else {
+ sp += RTjpeg_s2b (RTjpeg_block, sp, RTjpeg_lb8, RTjpeg_liqt);
+ RTjpeg_idct (bp + j + 8, RTjpeg_block, RTjpeg_width);
+ }
+ if (*sp == -1)
+ sp++;
+ else {
+ sp += RTjpeg_s2b (RTjpeg_block, sp, RTjpeg_lb8, RTjpeg_liqt);
+ RTjpeg_idct (bp1 + j, RTjpeg_block, RTjpeg_width);
+ }
+ if (*sp == -1)
+ sp++;
+ else {
+ sp += RTjpeg_s2b (RTjpeg_block, sp, RTjpeg_lb8, RTjpeg_liqt);
+ RTjpeg_idct (bp1 + j + 8, RTjpeg_block, RTjpeg_width);
+ }
+ if (*sp == -1)
+ sp++;
+ else {
+ sp += RTjpeg_s2b (RTjpeg_block, sp, RTjpeg_cb8, RTjpeg_ciqt);
+ RTjpeg_idct (bp2 + k, RTjpeg_block, RTjpeg_width >> 1);
+ }
+ if (*sp == -1)
+ sp++;
+ else {
+ sp += RTjpeg_s2b (RTjpeg_block, sp, RTjpeg_cb8, RTjpeg_ciqt);
+ RTjpeg_idct (bp3 + k, RTjpeg_block, RTjpeg_width >> 1);
+ }
+ }
+ bp += RTjpeg_width << 4;
+ bp1 += RTjpeg_width << 4;
+ bp2 += RTjpeg_width << 2;
+ bp3 += RTjpeg_width << 2;
}
- bp+=RTjpeg_width<<4;
- bp1+=RTjpeg_width<<4;
- bp2+=RTjpeg_width<<2;
- bp3+=RTjpeg_width<<2;
- }
#ifdef HAVE_LIBMMX
- emms();
+ emms ();
#endif
}
-void RTjpeg_decompress8(__s8 *sp, __u8 *bp)
+void
+RTjpeg_decompress8 (__s8 * sp, __u8 * bp)
{
- int i, j;
+ int i, j;
#ifdef HAVE_LIBMMX
- emms();
+ emms ();
#endif
/* Y */
- for(i=0; i<RTjpeg_height; i+=8)
- {
- for(j=0; j<RTjpeg_width; j+=8)
- if(*sp==-1)sp++;
- else
- {
- sp+=RTjpeg_s2b(RTjpeg_block, sp, RTjpeg_lb8, RTjpeg_liqt);
- RTjpeg_idct(bp+j, RTjpeg_block, RTjpeg_width);
- }
- bp+=RTjpeg_width<<3;
- }
+ for (i = 0; i < RTjpeg_height; i += 8) {
+ for (j = 0; j < RTjpeg_width; j += 8)
+ if (*sp == -1)
+ sp++;
+ else {
+ sp += RTjpeg_s2b (RTjpeg_block, sp, RTjpeg_lb8, RTjpeg_liqt);
+ RTjpeg_idct (bp + j, RTjpeg_block, RTjpeg_width);
+ }
+ bp += RTjpeg_width << 3;
+ }
}
/*
*/
-void RTjpeg_init_mcompress(void)
+void
+RTjpeg_init_mcompress (void)
{
- unsigned long tmp;
-
- if(!RTjpeg_old)
- {
- RTjpeg_old=malloc((4*RTjpeg_width*RTjpeg_height)+32);
- tmp=(unsigned long)RTjpeg_old;
- tmp+=32;
- tmp=tmp>>5;
- RTjpeg_old=(__s16 *)(tmp<<5);
- }
- if (!RTjpeg_old)
- {
- fprintf(stderr, "RTjpeg: Could not allocate memory\n");
- exit(-1);
- }
- memset (RTjpeg_old, 0, ((4*RTjpeg_width*RTjpeg_height)));
+ unsigned long tmp;
+
+ if (!RTjpeg_old) {
+ RTjpeg_old = malloc ((4 * RTjpeg_width * RTjpeg_height) + 32);
+ tmp = (unsigned long) RTjpeg_old;
+ tmp += 32;
+ tmp = tmp >> 5;
+ RTjpeg_old = (__s16 *) (tmp << 5);
+ }
+ if (!RTjpeg_old) {
+ fprintf (stderr, "RTjpeg: Could not allocate memory\n");
+ exit (-1);
+ }
+ memset (RTjpeg_old, 0, ((4 * RTjpeg_width * RTjpeg_height)));
}
#ifdef HAVE_LIBMMX
-int RTjpeg_bcomp(__s16 *old, mmx_t *mask)
+int
+RTjpeg_bcomp (__s16 * old, mmx_t * mask)
{
- int i;
- mmx_t *mold=(mmx_t *)old;
- mmx_t *mblock=(mmx_t *)RTjpeg_block;
- mmx_t result;
- static mmx_t neg=(mmx_t)(unsigned long long)0xffffffffffffffffULL;
-
- movq_m2r(*mask, mm7);
- movq_m2r(neg, mm6);
- pxor_r2r(mm5, mm5);
-
- for(i=0; i<8; i++)
- {
- movq_m2r(*(mblock++), mm0);
- movq_m2r(*(mblock++), mm2);
- movq_m2r(*(mold++), mm1);
- movq_m2r(*(mold++), mm3);
- psubsw_r2r(mm1, mm0);
- psubsw_r2r(mm3, mm2);
- movq_r2r(mm0, mm1);
- movq_r2r(mm2, mm3);
- pcmpgtw_r2r(mm7, mm0);
- pcmpgtw_r2r(mm7, mm2);
- pxor_r2r(mm6, mm1);
- pxor_r2r(mm6, mm3);
- pcmpgtw_r2r(mm7, mm1);
- pcmpgtw_r2r(mm7, mm3);
- por_r2r(mm0, mm5);
- por_r2r(mm2, mm5);
- por_r2r(mm1, mm5);
- por_r2r(mm3, mm5);
- }
- movq_r2m(mm5, result);
-
- if(result.q)
- {
- if(!RTjpeg_mtest)
- for(i=0; i<16; i++)((__u64 *)old)[i]=((__u64 *)RTjpeg_block)[i];
- return 0;
- }
+ int i;
+ mmx_t *mold = (mmx_t *) old;
+ mmx_t *mblock = (mmx_t *) RTjpeg_block;
+ mmx_t result;
+ static mmx_t neg = (mmx_t) (unsigned long long) 0xffffffffffffffffULL;
+
+ movq_m2r (*mask, mm7);
+ movq_m2r (neg, mm6);
+ pxor_r2r (mm5, mm5);
+
+ for (i = 0; i < 8; i++) {
+ movq_m2r (*(mblock++), mm0);
+ movq_m2r (*(mblock++), mm2);
+ movq_m2r (*(mold++), mm1);
+ movq_m2r (*(mold++), mm3);
+ psubsw_r2r (mm1, mm0);
+ psubsw_r2r (mm3, mm2);
+ movq_r2r (mm0, mm1);
+ movq_r2r (mm2, mm3);
+ pcmpgtw_r2r (mm7, mm0);
+ pcmpgtw_r2r (mm7, mm2);
+ pxor_r2r (mm6, mm1);
+ pxor_r2r (mm6, mm3);
+ pcmpgtw_r2r (mm7, mm1);
+ pcmpgtw_r2r (mm7, mm3);
+ por_r2r (mm0, mm5);
+ por_r2r (mm2, mm5);
+ por_r2r (mm1, mm5);
+ por_r2r (mm3, mm5);
+ }
+ movq_r2m (mm5, result);
+
+ if (result.q) {
+ if (!RTjpeg_mtest)
+ for (i = 0; i < 16; i++)
+ ((__u64 *) old)[i] = ((__u64 *) RTjpeg_block)[i];
+ return 0;
+ }
/* printf("."); */
- return 1;
+ return 1;
}
#else
-int RTjpeg_bcomp(__s16 *old, __u16 *mask)
+int
+RTjpeg_bcomp (__s16 * old, __u16 * mask)
{
- int i;
-
- for(i=0; i<64; i++)
- if(abs(old[i]-RTjpeg_block[i])>*mask)
- {
- if(!RTjpeg_mtest)
- for(i=0; i<16; i++)((__u64 *)old)[i]=((__u64 *)RTjpeg_block)[i];
- return 0;
- }
- return 1;
+ int i;
+
+ for (i = 0; i < 64; i++)
+ if (abs (old[i] - RTjpeg_block[i]) > *mask) {
+ if (!RTjpeg_mtest)
+ for (i = 0; i < 16; i++)
+ ((__u64 *) old)[i] = ((__u64 *) RTjpeg_block)[i];
+ return 0;
+ }
+ return 1;
}
#endif
-void RTjpeg_set_test(int i)
+void
+RTjpeg_set_test (int i)
{
- RTjpeg_mtest=i;
+ RTjpeg_mtest = i;
}
-int RTjpeg_mcompress(__s8 *sp, unsigned char *bp, __u16 lmask, __u16 cmask)
+int
+RTjpeg_mcompress (__s8 * sp, unsigned char *bp, __u16 lmask, __u16 cmask)
{
- __s8 * sb;
- __s16 *block;
- register __s8 * bp2;
- register __s8 * bp3;
- register int i, j, k;
+ __s8 *sb;
+ __s16 *block;
+ register __s8 *bp2;
+ register __s8 *bp3;
+ register int i, j, k;
#ifdef HAVE_LIBMMX
- emms();
- RTjpeg_lmask=(mmx_t)(((__u64)lmask<<48)|((__u64)lmask<<32)|((__u64)lmask<<16)|lmask);
- RTjpeg_cmask=(mmx_t)(((__u64)cmask<<48)|((__u64)cmask<<32)|((__u64)cmask<<16)|cmask);
+ emms ();
+ RTjpeg_lmask =
+ (mmx_t) (((__u64) lmask << 48) | ((__u64) lmask << 32) | ((__u64) lmask <<
+ 16) | lmask);
+ RTjpeg_cmask =
+ (mmx_t) (((__u64) cmask << 48) | ((__u64) cmask << 32) | ((__u64) cmask <<
+ 16) | cmask);
#else
- RTjpeg_lmask=lmask;
- RTjpeg_cmask=cmask;
+ RTjpeg_lmask = lmask;
+ RTjpeg_cmask = cmask;
#endif
-
- bp = bp - RTjpeg_width*0;
- bp2 = bp + RTjpeg_Ysize-RTjpeg_width*0;
- bp3 = bp2 + RTjpeg_Csize;
- sb=sp;
- block=RTjpeg_old;
-/* Y */
- for(i=RTjpeg_height; i; i-=8)
- {
- for(j=0, k=0; j<RTjpeg_width; j+=16, k+=8)
- {
- RTjpeg_dctY(bp+j, RTjpeg_block, RTjpeg_Ywidth);
- RTjpeg_quant(RTjpeg_block, RTjpeg_lqt);
- if(RTjpeg_bcomp(block, &RTjpeg_lmask))
- {
- *((__u8 *)sp++)=255;
- }
- else sp+=RTjpeg_b2s(RTjpeg_block, sp, RTjpeg_lb8);
- block+=64;
-
- RTjpeg_dctY(bp+j+8, RTjpeg_block, RTjpeg_Ywidth);
- RTjpeg_quant(RTjpeg_block, RTjpeg_lqt);
- if(RTjpeg_bcomp(block, &RTjpeg_lmask))
- {
- *((__u8 *)sp++)=255;
- }
- else sp+=RTjpeg_b2s(RTjpeg_block, sp, RTjpeg_lb8);
- block+=64;
-
- RTjpeg_dctY(bp2+k, RTjpeg_block, RTjpeg_Cwidth);
- RTjpeg_quant(RTjpeg_block, RTjpeg_cqt);
- if(RTjpeg_bcomp(block, &RTjpeg_cmask))
- {
- *((__u8 *)sp++)=255;
- }
- else sp+=RTjpeg_b2s(RTjpeg_block, sp, RTjpeg_cb8);
- block+=64;
-
- RTjpeg_dctY(bp3+k, RTjpeg_block, RTjpeg_Cwidth);
- RTjpeg_quant(RTjpeg_block, RTjpeg_cqt);
- if(RTjpeg_bcomp(block, &RTjpeg_cmask))
- {
- *((__u8 *)sp++)=255;
- }
- else sp+=RTjpeg_b2s(RTjpeg_block, sp, RTjpeg_cb8);
- block+=64;
+ bp = bp - RTjpeg_width * 0;
+ bp2 = bp + RTjpeg_Ysize - RTjpeg_width * 0;
+ bp3 = bp2 + RTjpeg_Csize;
+ sb = sp;
+ block = RTjpeg_old;
+/* Y */
+ for (i = RTjpeg_height; i; i -= 8) {
+ for (j = 0, k = 0; j < RTjpeg_width; j += 16, k += 8) {
+ RTjpeg_dctY (bp + j, RTjpeg_block, RTjpeg_Ywidth);
+ RTjpeg_quant (RTjpeg_block, RTjpeg_lqt);
+ if (RTjpeg_bcomp (block, &RTjpeg_lmask)) {
+ *((__u8 *) sp++) = 255;
+ } else
+ sp += RTjpeg_b2s (RTjpeg_block, sp, RTjpeg_lb8);
+ block += 64;
+
+ RTjpeg_dctY (bp + j + 8, RTjpeg_block, RTjpeg_Ywidth);
+ RTjpeg_quant (RTjpeg_block, RTjpeg_lqt);
+ if (RTjpeg_bcomp (block, &RTjpeg_lmask)) {
+ *((__u8 *) sp++) = 255;
+ } else
+ sp += RTjpeg_b2s (RTjpeg_block, sp, RTjpeg_lb8);
+ block += 64;
+
+ RTjpeg_dctY (bp2 + k, RTjpeg_block, RTjpeg_Cwidth);
+ RTjpeg_quant (RTjpeg_block, RTjpeg_cqt);
+ if (RTjpeg_bcomp (block, &RTjpeg_cmask)) {
+ *((__u8 *) sp++) = 255;
+ } else
+ sp += RTjpeg_b2s (RTjpeg_block, sp, RTjpeg_cb8);
+ block += 64;
+
+ RTjpeg_dctY (bp3 + k, RTjpeg_block, RTjpeg_Cwidth);
+ RTjpeg_quant (RTjpeg_block, RTjpeg_cqt);
+ if (RTjpeg_bcomp (block, &RTjpeg_cmask)) {
+ *((__u8 *) sp++) = 255;
+ } else
+ sp += RTjpeg_b2s (RTjpeg_block, sp, RTjpeg_cb8);
+ block += 64;
+
+ }
+ bp += RTjpeg_width << 3;
+ bp2 += RTjpeg_width << 2;
+ bp3 += RTjpeg_width << 2;
}
- bp+=RTjpeg_width<<3;
- bp2+=RTjpeg_width<<2;
- bp3+=RTjpeg_width<<2;
- }
- /*printf ("%d\n", block - RTjpeg_old); */
+ /*printf ("%d\n", block - RTjpeg_old); */
#ifdef HAVE_LIBMMX
- emms();
+ emms ();
#endif
- return (sp-sb);
+ return (sp - sb);
}
-int RTjpeg_mcompress8(__s8 *sp, unsigned char *bp, __u16 lmask)
+int
+RTjpeg_mcompress8 (__s8 * sp, unsigned char *bp, __u16 lmask)
{
- __s8 * sb;
- __s16 *block;
- int i, j;
+ __s8 *sb;
+ __s16 *block;
+ int i, j;
#ifdef HAVE_LIBMMX
- emms();
- RTjpeg_lmask=(mmx_t)(((__u64)lmask<<48)|((__u64)lmask<<32)|((__u64)lmask<<16)|lmask);
+ emms ();
+ RTjpeg_lmask =
+ (mmx_t) (((__u64) lmask << 48) | ((__u64) lmask << 32) | ((__u64) lmask <<
+ 16) | lmask);
#else
- RTjpeg_lmask=lmask;
+ RTjpeg_lmask = lmask;
#endif
-
- sb=sp;
- block=RTjpeg_old;
+
+ sb = sp;
+ block = RTjpeg_old;
/* Y */
- for(i=0; i<RTjpeg_height; i+=8)
- {
- for(j=0; j<RTjpeg_width; j+=8)
- {
- RTjpeg_dctY(bp+j, RTjpeg_block, RTjpeg_width);
- RTjpeg_quant(RTjpeg_block, RTjpeg_lqt);
- if(RTjpeg_bcomp(block, &RTjpeg_lmask))
- {
- *((__u8 *)sp++)=255;
+ for (i = 0; i < RTjpeg_height; i += 8) {
+ for (j = 0; j < RTjpeg_width; j += 8) {
+ RTjpeg_dctY (bp + j, RTjpeg_block, RTjpeg_width);
+ RTjpeg_quant (RTjpeg_block, RTjpeg_lqt);
+ if (RTjpeg_bcomp (block, &RTjpeg_lmask)) {
+ *((__u8 *) sp++) = 255;
/* printf("* %d ", sp[-1]); */
- } else sp+=RTjpeg_b2s(RTjpeg_block, sp, RTjpeg_lb8);
- block+=64;
+ } else
+ sp += RTjpeg_b2s (RTjpeg_block, sp, RTjpeg_lb8);
+ block += 64;
+ }
+ bp += RTjpeg_width << 3;
}
- bp+=RTjpeg_width<<3;
- }
#ifdef HAVE_LIBMMX
- emms();
+ emms ();
#endif
- return (sp-sb);
+ return (sp - sb);
}
-void RTjpeg_color_init(void)
+void
+RTjpeg_color_init (void)
{
-}
+}
#define KcrR 76284
#define KcrG 53281
#define KcbB 132252
#define Ky 76284
-void RTjpeg_yuv422rgb(__u8 *buf, __u8 *rgb)
+void
+RTjpeg_yuv422rgb (__u8 * buf, __u8 * rgb)
{
- int tmp;
- int i, j;
- __s32 y, crR, crG, cbG, cbB;
- __u8 *bufcr, *bufcb, *bufy, *bufoute;
- int yskip;
-
- yskip=RTjpeg_width;
-
- bufcb=&buf[RTjpeg_width*RTjpeg_height];
- bufcr=&buf[RTjpeg_width*RTjpeg_height+(RTjpeg_width*RTjpeg_height)/2];
- bufy=&buf[0];
- bufoute=rgb;
-
- for(i=0; i<(RTjpeg_height); i++)
- {
- for(j=0; j<RTjpeg_width; j+=2)
- {
- crR=(*bufcr-128)*KcrR;
- crG=(*(bufcr++)-128)*KcrG;
- cbG=(*bufcb-128)*KcbG;
- cbB=(*(bufcb++)-128)*KcbB;
-
- y=(bufy[j]-16)*Ky;
-
- tmp=(y+crR)>>16;
- *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp);
- tmp=(y-crG-cbG)>>16;
- *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp);
- tmp=(y+cbB)>>16;
- *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp);
-
- y=(bufy[j+1]-16)*Ky;
-
- tmp=(y+crR)>>16;
- *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp);
- tmp=(y-crG-cbG)>>16;
- *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp);
- tmp=(y+cbB)>>16;
- *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp);
-
+ int tmp;
+ int i, j;
+ __s32 y, crR, crG, cbG, cbB;
+ __u8 *bufcr, *bufcb, *bufy, *bufoute;
+ int yskip;
+
+ yskip = RTjpeg_width;
+
+ bufcb = &buf[RTjpeg_width * RTjpeg_height];
+ bufcr =
+ &buf[RTjpeg_width * RTjpeg_height + (RTjpeg_width * RTjpeg_height) / 2];
+ bufy = &buf[0];
+ bufoute = rgb;
+
+ for (i = 0; i < (RTjpeg_height); i++) {
+ for (j = 0; j < RTjpeg_width; j += 2) {
+ crR = (*bufcr - 128) * KcrR;
+ crG = (*(bufcr++) - 128) * KcrG;
+ cbG = (*bufcb - 128) * KcbG;
+ cbB = (*(bufcb++) - 128) * KcbB;
+
+ y = (bufy[j] - 16) * Ky;
+
+ tmp = (y + crR) >> 16;
+ *(bufoute++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ tmp = (y - crG - cbG) >> 16;
+ *(bufoute++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ tmp = (y + cbB) >> 16;
+ *(bufoute++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+
+ y = (bufy[j + 1] - 16) * Ky;
+
+ tmp = (y + crR) >> 16;
+ *(bufoute++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ tmp = (y - crG - cbG) >> 16;
+ *(bufoute++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ tmp = (y + cbB) >> 16;
+ *(bufoute++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+
+ }
+ bufy += yskip;
}
- bufy+=yskip;
- }
}
-void RTjpeg_yuv420rgb(__u8 *buf, __u8 *rgb)
+void
+RTjpeg_yuv420rgb (__u8 * buf, __u8 * rgb)
{
- int tmp;
- int i, j;
- __s32 y, crR, crG, cbG, cbB;
- __u8 *bufcr, *bufcb, *bufy, *bufoute, *bufouto;
- int oskip, yskip;
-
- oskip=RTjpeg_width*3;
- yskip=RTjpeg_width;
-
- bufcb=&buf[RTjpeg_width*RTjpeg_height];
- bufcr=&buf[RTjpeg_width*RTjpeg_height+(RTjpeg_width*RTjpeg_height)/4];
- bufy=&buf[0];
- bufoute=rgb;
- bufouto=rgb+oskip;
-
- for(i=0; i<(RTjpeg_height>>1); i++)
- {
- for(j=0; j<RTjpeg_width; j+=2)
- {
- crR=(*bufcr-128)*KcrR;
- crG=(*(bufcr++)-128)*KcrG;
- cbG=(*bufcb-128)*KcbG;
- cbB=(*(bufcb++)-128)*KcbB;
-
- y=(bufy[j]-16)*Ky;
-
- tmp=(y+crR)>>16;
- *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp);
- tmp=(y-crG-cbG)>>16;
- *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp);
- tmp=(y+cbB)>>16;
- *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp);
-
- y=(bufy[j+1]-16)*Ky;
-
- tmp=(y+crR)>>16;
- *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp);
- tmp=(y-crG-cbG)>>16;
- *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp);
- tmp=(y+cbB)>>16;
- *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp);
-
- y=(bufy[j+yskip]-16)*Ky;
-
- tmp=(y+crR)>>16;
- *(bufouto++)=(tmp>255)?255:((tmp<0)?0:tmp);
- tmp=(y-crG-cbG)>>16;
- *(bufouto++)=(tmp>255)?255:((tmp<0)?0:tmp);
- tmp=(y+cbB)>>16;
- *(bufouto++)=(tmp>255)?255:((tmp<0)?0:tmp);
-
- y=(bufy[j+1+yskip]-16)*Ky;
-
- tmp=(y+crR)>>16;
- *(bufouto++)=(tmp>255)?255:((tmp<0)?0:tmp);
- tmp=(y-crG-cbG)>>16;
- *(bufouto++)=(tmp>255)?255:((tmp<0)?0:tmp);
- tmp=(y+cbB)>>16;
- *(bufouto++)=(tmp>255)?255:((tmp<0)?0:tmp);
-
+ int tmp;
+ int i, j;
+ __s32 y, crR, crG, cbG, cbB;
+ __u8 *bufcr, *bufcb, *bufy, *bufoute, *bufouto;
+ int oskip, yskip;
+
+ oskip = RTjpeg_width * 3;
+ yskip = RTjpeg_width;
+
+ bufcb = &buf[RTjpeg_width * RTjpeg_height];
+ bufcr =
+ &buf[RTjpeg_width * RTjpeg_height + (RTjpeg_width * RTjpeg_height) / 4];
+ bufy = &buf[0];
+ bufoute = rgb;
+ bufouto = rgb + oskip;
+
+ for (i = 0; i < (RTjpeg_height >> 1); i++) {
+ for (j = 0; j < RTjpeg_width; j += 2) {
+ crR = (*bufcr - 128) * KcrR;
+ crG = (*(bufcr++) - 128) * KcrG;
+ cbG = (*bufcb - 128) * KcbG;
+ cbB = (*(bufcb++) - 128) * KcbB;
+
+ y = (bufy[j] - 16) * Ky;
+
+ tmp = (y + crR) >> 16;
+ *(bufoute++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ tmp = (y - crG - cbG) >> 16;
+ *(bufoute++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ tmp = (y + cbB) >> 16;
+ *(bufoute++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+
+ y = (bufy[j + 1] - 16) * Ky;
+
+ tmp = (y + crR) >> 16;
+ *(bufoute++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ tmp = (y - crG - cbG) >> 16;
+ *(bufoute++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ tmp = (y + cbB) >> 16;
+ *(bufoute++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+
+ y = (bufy[j + yskip] - 16) * Ky;
+
+ tmp = (y + crR) >> 16;
+ *(bufouto++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ tmp = (y - crG - cbG) >> 16;
+ *(bufouto++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ tmp = (y + cbB) >> 16;
+ *(bufouto++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+
+ y = (bufy[j + 1 + yskip] - 16) * Ky;
+
+ tmp = (y + crR) >> 16;
+ *(bufouto++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ tmp = (y - crG - cbG) >> 16;
+ *(bufouto++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ tmp = (y + cbB) >> 16;
+ *(bufouto++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+
+ }
+ bufoute += oskip;
+ bufouto += oskip;
+ bufy += yskip << 1;
}
- bufoute+=oskip;
- bufouto+=oskip;
- bufy+=yskip<<1;
- }
}
-void RTjpeg_yuvrgb32(__u8 *buf, __u8 *rgb)
+void
+RTjpeg_yuvrgb32 (__u8 * buf, __u8 * rgb)
{
- int tmp;
- int i, j;
- __s32 y, crR, crG, cbG, cbB;
- __u8 *bufcr, *bufcb, *bufy, *bufoute, *bufouto;
- int oskip, yskip;
-
- oskip=RTjpeg_width*4;
- yskip=RTjpeg_width;
-
- bufcb=&buf[RTjpeg_width*RTjpeg_height];
- bufcr=&buf[RTjpeg_width*RTjpeg_height+(RTjpeg_width*RTjpeg_height)/2];
- bufy=&buf[0];
- bufoute=rgb;
- bufouto=rgb+oskip;
-
- for(i=0; i<(RTjpeg_height>>1); i++)
- {
- for(j=0; j<RTjpeg_width; j+=2)
- {
- crR=(*bufcr-128)*KcrR;
- crG=(*(bufcr++)-128)*KcrG;
- cbG=(*bufcb-128)*KcbG;
- cbB=(*(bufcb++)-128)*KcbB;
-
- y=(bufy[j]-16)*Ky;
-
- tmp=(y+cbB)>>16;
- *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp);
- tmp=(y-crG-cbG)>>16;
- *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp);
- tmp=(y+crR)>>16;
- *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp);
- bufoute++;
-
- y=(bufy[j+1]-16)*Ky;
-
- tmp=(y+cbB)>>16;
- *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp);
- tmp=(y-crG-cbG)>>16;
- *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp);
- tmp=(y+crR)>>16;
- *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp);
- bufoute++;
-
- y=(bufy[j+yskip]-16)*Ky;
-
- tmp=(y+cbB)>>16;
- *(bufouto++)=(tmp>255)?255:((tmp<0)?0:tmp);
- tmp=(y-crG-cbG)>>16;
- *(bufouto++)=(tmp>255)?255:((tmp<0)?0:tmp);
- tmp=(y+crR)>>16;
- *(bufouto++)=(tmp>255)?255:((tmp<0)?0:tmp);
- bufouto++;
-
- y=(bufy[j+1+yskip]-16)*Ky;
-
- tmp=(y+cbB)>>16;
- *(bufouto++)=(tmp>255)?255:((tmp<0)?0:tmp);
- tmp=(y-crG-cbG)>>16;
- *(bufouto++)=(tmp>255)?255:((tmp<0)?0:tmp);
- tmp=(y+crR)>>16;
- *(bufouto++)=(tmp>255)?255:((tmp<0)?0:tmp);
- bufouto++;
-
+ int tmp;
+ int i, j;
+ __s32 y, crR, crG, cbG, cbB;
+ __u8 *bufcr, *bufcb, *bufy, *bufoute, *bufouto;
+ int oskip, yskip;
+
+ oskip = RTjpeg_width * 4;
+ yskip = RTjpeg_width;
+
+ bufcb = &buf[RTjpeg_width * RTjpeg_height];
+ bufcr =
+ &buf[RTjpeg_width * RTjpeg_height + (RTjpeg_width * RTjpeg_height) / 2];
+ bufy = &buf[0];
+ bufoute = rgb;
+ bufouto = rgb + oskip;
+
+ for (i = 0; i < (RTjpeg_height >> 1); i++) {
+ for (j = 0; j < RTjpeg_width; j += 2) {
+ crR = (*bufcr - 128) * KcrR;
+ crG = (*(bufcr++) - 128) * KcrG;
+ cbG = (*bufcb - 128) * KcbG;
+ cbB = (*(bufcb++) - 128) * KcbB;
+
+ y = (bufy[j] - 16) * Ky;
+
+ tmp = (y + cbB) >> 16;
+ *(bufoute++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ tmp = (y - crG - cbG) >> 16;
+ *(bufoute++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ tmp = (y + crR) >> 16;
+ *(bufoute++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ bufoute++;
+
+ y = (bufy[j + 1] - 16) * Ky;
+
+ tmp = (y + cbB) >> 16;
+ *(bufoute++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ tmp = (y - crG - cbG) >> 16;
+ *(bufoute++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ tmp = (y + crR) >> 16;
+ *(bufoute++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ bufoute++;
+
+ y = (bufy[j + yskip] - 16) * Ky;
+
+ tmp = (y + cbB) >> 16;
+ *(bufouto++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ tmp = (y - crG - cbG) >> 16;
+ *(bufouto++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ tmp = (y + crR) >> 16;
+ *(bufouto++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ bufouto++;
+
+ y = (bufy[j + 1 + yskip] - 16) * Ky;
+
+ tmp = (y + cbB) >> 16;
+ *(bufouto++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ tmp = (y - crG - cbG) >> 16;
+ *(bufouto++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ tmp = (y + crR) >> 16;
+ *(bufouto++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ bufouto++;
+
+ }
+ bufoute += oskip;
+ bufouto += oskip;
+ bufy += yskip << 1;
}
- bufoute+=oskip;
- bufouto+=oskip;
- bufy+=yskip<<1;
- }
}
-void RTjpeg_yuvrgb24(__u8 *buf, __u8 *rgb)
+void
+RTjpeg_yuvrgb24 (__u8 * buf, __u8 * rgb)
{
- int tmp;
- int i, j;
- __s32 y, crR, crG, cbG, cbB;
- __u8 *bufcr, *bufcb, *bufy, *bufoute, *bufouto;
- int oskip, yskip;
-
- oskip=RTjpeg_width*3;
- yskip=RTjpeg_width;
-
- bufcb=&buf[RTjpeg_width*RTjpeg_height];
- bufcr=&buf[RTjpeg_width*RTjpeg_height+(RTjpeg_width*RTjpeg_height)/4];
- bufy=&buf[0];
- bufoute=rgb;
- bufouto=rgb+oskip;
-
- for(i=0; i<(RTjpeg_height>>1); i++)
- {
- for(j=0; j<RTjpeg_width; j+=2)
- {
- crR=(*bufcr-128)*KcrR;
- crG=(*(bufcr++)-128)*KcrG;
- cbG=(*bufcb-128)*KcbG;
- cbB=(*(bufcb++)-128)*KcbB;
-
- y=(bufy[j]-16)*Ky;
-
- tmp=(y+cbB)>>16;
- *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp);
- tmp=(y-crG-cbG)>>16;
- *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp);
- tmp=(y+crR)>>16;
- *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp);
-
- y=(bufy[j+1]-16)*Ky;
-
- tmp=(y+cbB)>>16;
- *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp);
- tmp=(y-crG-cbG)>>16;
- *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp);
- tmp=(y+crR)>>16;
- *(bufoute++)=(tmp>255)?255:((tmp<0)?0:tmp);
-
- y=(bufy[j+yskip]-16)*Ky;
-
- tmp=(y+cbB)>>16;
- *(bufouto++)=(tmp>255)?255:((tmp<0)?0:tmp);
- tmp=(y-crG-cbG)>>16;
- *(bufouto++)=(tmp>255)?255:((tmp<0)?0:tmp);
- tmp=(y+crR)>>16;
- *(bufouto++)=(tmp>255)?255:((tmp<0)?0:tmp);
-
- y=(bufy[j+1+yskip]-16)*Ky;
-
- tmp=(y+cbB)>>16;
- *(bufouto++)=(tmp>255)?255:((tmp<0)?0:tmp);
- tmp=(y-crG-cbG)>>16;
- *(bufouto++)=(tmp>255)?255:((tmp<0)?0:tmp);
- tmp=(y+crR)>>16;
- *(bufouto++)=(tmp>255)?255:((tmp<0)?0:tmp);
-
+ int tmp;
+ int i, j;
+ __s32 y, crR, crG, cbG, cbB;
+ __u8 *bufcr, *bufcb, *bufy, *bufoute, *bufouto;
+ int oskip, yskip;
+
+ oskip = RTjpeg_width * 3;
+ yskip = RTjpeg_width;
+
+ bufcb = &buf[RTjpeg_width * RTjpeg_height];
+ bufcr =
+ &buf[RTjpeg_width * RTjpeg_height + (RTjpeg_width * RTjpeg_height) / 4];
+ bufy = &buf[0];
+ bufoute = rgb;
+ bufouto = rgb + oskip;
+
+ for (i = 0; i < (RTjpeg_height >> 1); i++) {
+ for (j = 0; j < RTjpeg_width; j += 2) {
+ crR = (*bufcr - 128) * KcrR;
+ crG = (*(bufcr++) - 128) * KcrG;
+ cbG = (*bufcb - 128) * KcbG;
+ cbB = (*(bufcb++) - 128) * KcbB;
+
+ y = (bufy[j] - 16) * Ky;
+
+ tmp = (y + cbB) >> 16;
+ *(bufoute++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ tmp = (y - crG - cbG) >> 16;
+ *(bufoute++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ tmp = (y + crR) >> 16;
+ *(bufoute++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+
+ y = (bufy[j + 1] - 16) * Ky;
+
+ tmp = (y + cbB) >> 16;
+ *(bufoute++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ tmp = (y - crG - cbG) >> 16;
+ *(bufoute++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ tmp = (y + crR) >> 16;
+ *(bufoute++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+
+ y = (bufy[j + yskip] - 16) * Ky;
+
+ tmp = (y + cbB) >> 16;
+ *(bufouto++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ tmp = (y - crG - cbG) >> 16;
+ *(bufouto++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ tmp = (y + crR) >> 16;
+ *(bufouto++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+
+ y = (bufy[j + 1 + yskip] - 16) * Ky;
+
+ tmp = (y + cbB) >> 16;
+ *(bufouto++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ tmp = (y - crG - cbG) >> 16;
+ *(bufouto++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ tmp = (y + crR) >> 16;
+ *(bufouto++) = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+
+ }
+ bufoute += oskip;
+ bufouto += oskip;
+ bufy += yskip << 1;
}
- bufoute+=oskip;
- bufouto+=oskip;
- bufy+=yskip<<1;
- }
}
-void RTjpeg_yuvrgb16(__u8 *buf, __u8 *rgb)
+void
+RTjpeg_yuvrgb16 (__u8 * buf, __u8 * rgb)
{
- int tmp;
- int i, j;
- __s32 y, crR, crG, cbG, cbB;
- __u8 *bufcr, *bufcb, *bufy, *bufoute, *bufouto;
- int oskip, yskip;
- unsigned char r, g, b;
-
- oskip=RTjpeg_width*2;
- yskip=RTjpeg_width;
-
- bufcb=&buf[RTjpeg_width*RTjpeg_height];
- bufcr=&buf[RTjpeg_width*RTjpeg_height+(RTjpeg_width*RTjpeg_height)/4];
- bufy=&buf[0];
- bufoute=rgb;
- bufouto=rgb+oskip;
-
- for(i=0; i<(RTjpeg_height>>1); i++)
- {
- for(j=0; j<RTjpeg_width; j+=2)
- {
- crR=(*bufcr-128)*KcrR;
- crG=(*(bufcr++)-128)*KcrG;
- cbG=(*bufcb-128)*KcbG;
- cbB=(*(bufcb++)-128)*KcbB;
-
- y=(bufy[j]-16)*Ky;
-
- tmp=(y+cbB)>>16;
- b=(tmp>255)?255:((tmp<0)?0:tmp);
- tmp=(y-crG-cbG)>>16;
- g=(tmp>255)?255:((tmp<0)?0:tmp);
- tmp=(y+crR)>>16;
- r=(tmp>255)?255:((tmp<0)?0:tmp);
- tmp=(int)((int)b >> 3);
- tmp|=(int)(((int)g >> 2) << 5);
- tmp|=(int)(((int)r >> 3) << 11);
- *(bufoute++)=tmp&0xff;
- *(bufoute++)=tmp>>8;
-
-
- y=(bufy[j+1]-16)*Ky;
-
- tmp=(y+cbB)>>16;
- b=(tmp>255)?255:((tmp<0)?0:tmp);
- tmp=(y-crG-cbG)>>16;
- g=(tmp>255)?255:((tmp<0)?0:tmp);
- tmp=(y+crR)>>16;
- r=(tmp>255)?255:((tmp<0)?0:tmp);
- tmp=(int)((int)b >> 3);
- tmp|=(int)(((int)g >> 2) << 5);
- tmp|=(int)(((int)r >> 3) << 11);
- *(bufoute++)=tmp&0xff;
- *(bufoute++)=tmp>>8;
-
- y=(bufy[j+yskip]-16)*Ky;
-
- tmp=(y+cbB)>>16;
- b=(tmp>255)?255:((tmp<0)?0:tmp);
- tmp=(y-crG-cbG)>>16;
- g=(tmp>255)?255:((tmp<0)?0:tmp);
- tmp=(y+crR)>>16;
- r=(tmp>255)?255:((tmp<0)?0:tmp);
- tmp=(int)((int)b >> 3);
- tmp|=(int)(((int)g >> 2) << 5);
- tmp|=(int)(((int)r >> 3) << 11);
- *(bufouto++)=tmp&0xff;
- *(bufouto++)=tmp>>8;
-
- y=(bufy[j+1+yskip]-16)*Ky;
-
- tmp=(y+cbB)>>16;
- b=(tmp>255)?255:((tmp<0)?0:tmp);
- tmp=(y-crG-cbG)>>16;
- g=(tmp>255)?255:((tmp<0)?0:tmp);
- tmp=(y+crR)>>16;
- r=(tmp>255)?255:((tmp<0)?0:tmp);
- tmp=(int)((int)b >> 3);
- tmp|=(int)(((int)g >> 2) << 5);
- tmp|=(int)(((int)r >> 3) << 11);
- *(bufouto++)=tmp&0xff;
- *(bufouto++)=tmp>>8;
-
+ int tmp;
+ int i, j;
+ __s32 y, crR, crG, cbG, cbB;
+ __u8 *bufcr, *bufcb, *bufy, *bufoute, *bufouto;
+ int oskip, yskip;
+ unsigned char r, g, b;
+
+ oskip = RTjpeg_width * 2;
+ yskip = RTjpeg_width;
+
+ bufcb = &buf[RTjpeg_width * RTjpeg_height];
+ bufcr =
+ &buf[RTjpeg_width * RTjpeg_height + (RTjpeg_width * RTjpeg_height) / 4];
+ bufy = &buf[0];
+ bufoute = rgb;
+ bufouto = rgb + oskip;
+
+ for (i = 0; i < (RTjpeg_height >> 1); i++) {
+ for (j = 0; j < RTjpeg_width; j += 2) {
+ crR = (*bufcr - 128) * KcrR;
+ crG = (*(bufcr++) - 128) * KcrG;
+ cbG = (*bufcb - 128) * KcbG;
+ cbB = (*(bufcb++) - 128) * KcbB;
+
+ y = (bufy[j] - 16) * Ky;
+
+ tmp = (y + cbB) >> 16;
+ b = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ tmp = (y - crG - cbG) >> 16;
+ g = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ tmp = (y + crR) >> 16;
+ r = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ tmp = (int) ((int) b >> 3);
+ tmp |= (int) (((int) g >> 2) << 5);
+ tmp |= (int) (((int) r >> 3) << 11);
+ *(bufoute++) = tmp & 0xff;
+ *(bufoute++) = tmp >> 8;
+
+
+ y = (bufy[j + 1] - 16) * Ky;
+
+ tmp = (y + cbB) >> 16;
+ b = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ tmp = (y - crG - cbG) >> 16;
+ g = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ tmp = (y + crR) >> 16;
+ r = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ tmp = (int) ((int) b >> 3);
+ tmp |= (int) (((int) g >> 2) << 5);
+ tmp |= (int) (((int) r >> 3) << 11);
+ *(bufoute++) = tmp & 0xff;
+ *(bufoute++) = tmp >> 8;
+
+ y = (bufy[j + yskip] - 16) * Ky;
+
+ tmp = (y + cbB) >> 16;
+ b = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ tmp = (y - crG - cbG) >> 16;
+ g = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ tmp = (y + crR) >> 16;
+ r = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ tmp = (int) ((int) b >> 3);
+ tmp |= (int) (((int) g >> 2) << 5);
+ tmp |= (int) (((int) r >> 3) << 11);
+ *(bufouto++) = tmp & 0xff;
+ *(bufouto++) = tmp >> 8;
+
+ y = (bufy[j + 1 + yskip] - 16) * Ky;
+
+ tmp = (y + cbB) >> 16;
+ b = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ tmp = (y - crG - cbG) >> 16;
+ g = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ tmp = (y + crR) >> 16;
+ r = (tmp > 255) ? 255 : ((tmp < 0) ? 0 : tmp);
+ tmp = (int) ((int) b >> 3);
+ tmp |= (int) (((int) g >> 2) << 5);
+ tmp |= (int) (((int) r >> 3) << 11);
+ *(bufouto++) = tmp & 0xff;
+ *(bufouto++) = tmp >> 8;
+
+ }
+ bufoute += oskip;
+ bufouto += oskip;
+ bufy += yskip << 1;
}
- bufoute+=oskip;
- bufouto+=oskip;
- bufy+=yskip<<1;
- }
}
-void RTjpeg_yuvrgb8(__u8 *buf, __u8 *rgb)
+void
+RTjpeg_yuvrgb8 (__u8 * buf, __u8 * rgb)
{
- bcopy(buf, rgb, RTjpeg_width*RTjpeg_height);
+ bcopy (buf, rgb, RTjpeg_width * RTjpeg_height);
}
-void RTjpeg_double32(__u32 *buf)
+void
+RTjpeg_double32 (__u32 * buf)
{
- int i, j;
-
- __u32 *iptr, *optr1, *optr2;
-
- iptr=buf+(RTjpeg_width*RTjpeg_height)-1;
- optr1=buf+(RTjpeg_width*RTjpeg_height*4)-1;
- optr2=optr1-(2*RTjpeg_width);
-
- for(i=0; i<RTjpeg_height; i++)
- {
- for(j=0; j<RTjpeg_width; j++)
- {
- *(optr1--)=*iptr;
- *(optr1--)=*iptr;
- *(optr2--)=*iptr;
- *(optr2--)=*(iptr--);
+ int i, j;
+
+ __u32 *iptr, *optr1, *optr2;
+
+ iptr = buf + (RTjpeg_width * RTjpeg_height) - 1;
+ optr1 = buf + (RTjpeg_width * RTjpeg_height * 4) - 1;
+ optr2 = optr1 - (2 * RTjpeg_width);
+
+ for (i = 0; i < RTjpeg_height; i++) {
+ for (j = 0; j < RTjpeg_width; j++) {
+ *(optr1--) = *iptr;
+ *(optr1--) = *iptr;
+ *(optr2--) = *iptr;
+ *(optr2--) = *(iptr--);
+ }
+ optr2 = optr2 - 2 * RTjpeg_width;
+ optr1 = optr1 - 2 * RTjpeg_width;
}
- optr2=optr2-2*RTjpeg_width;
- optr1=optr1-2*RTjpeg_width;
- }
}
-void RTjpeg_double24(__u8 *buf)
+void
+RTjpeg_double24 (__u8 * buf)
{
}
-void RTjpeg_double16(__u16 *buf)
+void
+RTjpeg_double16 (__u16 * buf)
{
- int i, j;
-
- __u16 *iptr, *optr1, *optr2;
-
- iptr=buf+(RTjpeg_width*RTjpeg_height)-1;
- optr1=buf+(RTjpeg_width*RTjpeg_height*4)-1;
- optr2=optr1-(2*RTjpeg_width);
-
- for(i=0; i<RTjpeg_height; i++)
- {
- for(j=0; j<RTjpeg_width; j++)
- {
- *(optr1--)=*iptr;
- *(optr1--)=*iptr;
- *(optr2--)=*iptr;
- *(optr2--)=*(iptr--);
+ int i, j;
+
+ __u16 *iptr, *optr1, *optr2;
+
+ iptr = buf + (RTjpeg_width * RTjpeg_height) - 1;
+ optr1 = buf + (RTjpeg_width * RTjpeg_height * 4) - 1;
+ optr2 = optr1 - (2 * RTjpeg_width);
+
+ for (i = 0; i < RTjpeg_height; i++) {
+ for (j = 0; j < RTjpeg_width; j++) {
+ *(optr1--) = *iptr;
+ *(optr1--) = *iptr;
+ *(optr2--) = *iptr;
+ *(optr2--) = *(iptr--);
+ }
+ optr2 = optr2 - 2 * RTjpeg_width;
+ optr1 = optr1 - 2 * RTjpeg_width;
}
- optr2=optr2-2*RTjpeg_width;
- optr1=optr1-2*RTjpeg_width;
- }
}
-void RTjpeg_double8(__u8 *buf)
+void
+RTjpeg_double8 (__u8 * buf)
{
- int i, j;
-
- __u8 *iptr, *optr1, *optr2;
-
- iptr=buf+(RTjpeg_width*RTjpeg_height)-1;
- optr1=buf+(RTjpeg_width*RTjpeg_height*4)-1;
- optr2=optr1-(2*RTjpeg_width);
-
- for(i=0; i<RTjpeg_height; i++)
- {
- for(j=0; j<RTjpeg_width; j++)
- {
- *(optr1--)=*iptr;
- *(optr1--)=*iptr;
- *(optr2--)=*iptr;
- *(optr2--)=*(iptr--);
+ int i, j;
+
+ __u8 *iptr, *optr1, *optr2;
+
+ iptr = buf + (RTjpeg_width * RTjpeg_height) - 1;
+ optr1 = buf + (RTjpeg_width * RTjpeg_height * 4) - 1;
+ optr2 = optr1 - (2 * RTjpeg_width);
+
+ for (i = 0; i < RTjpeg_height; i++) {
+ for (j = 0; j < RTjpeg_width; j++) {
+ *(optr1--) = *iptr;
+ *(optr1--) = *iptr;
+ *(optr2--) = *iptr;
+ *(optr2--) = *(iptr--);
+ }
+ optr2 = optr2 - 2 * RTjpeg_width;
+ optr1 = optr1 - 2 * RTjpeg_width;
}
- optr2=optr2-2*RTjpeg_width;
- optr1=optr1-2*RTjpeg_width;
- }
}
-
#include <inttypes.h>
-typedef uint8_t __u8;
+typedef uint8_t __u8;
typedef uint32_t __u32;
-typedef int8_t __s8;
+typedef int8_t __s8;
typedef uint16_t __u16;
-extern void RTjpeg_init_Q(__u8 Q);
-extern void RTjpeg_init_compress(long unsigned int *buf, int width, int height, __u8 Q);
-extern void RTjpeg_init_decompress(long unsigned int *buf, int width, int height);
-extern int RTjpeg_compressYUV420(__s8 *sp, unsigned char *bp);
-extern int RTjpeg_compressYUV422(__s8 *sp, unsigned char *bp);
-extern void RTjpeg_decompressYUV420(__s8 *sp, __u8 *bp);
-extern void RTjpeg_decompressYUV422(__s8 *sp, __u8 *bp);
-extern int RTjpeg_compress8(__s8 *sp, unsigned char *bp);
-extern void RTjpeg_decompress8(__s8 *sp, __u8 *bp);
-
-extern void RTjpeg_init_mcompress(void);
-extern int RTjpeg_mcompress(__s8 *sp, unsigned char *bp, __u16 lmask, __u16 cmask);
-extern int RTjpeg_mcompress8(__s8 *sp, unsigned char *bp, __u16 lmask);
-extern void RTjpeg_set_test(int i);
-
-extern void RTjpeg_yuv420rgb(__u8 *buf, __u8 *rgb);
-extern void RTjpeg_yuv422rgb(__u8 *buf, __u8 *rgb);
-extern void RTjpeg_yuvrgb8(__u8 *buf, __u8 *rgb);
-extern void RTjpeg_yuvrgb16(__u8 *buf, __u8 *rgb);
-extern void RTjpeg_yuvrgb24(__u8 *buf, __u8 *rgb);
-extern void RTjpeg_yuvrgb32(__u8 *buf, __u8 *rgb);
-
+extern void RTjpeg_init_Q (__u8 Q);
+extern void RTjpeg_init_compress (long unsigned int *buf, int width, int height,
+ __u8 Q);
+extern void RTjpeg_init_decompress (long unsigned int *buf, int width,
+ int height);
+extern int RTjpeg_compressYUV420 (__s8 * sp, unsigned char *bp);
+extern int RTjpeg_compressYUV422 (__s8 * sp, unsigned char *bp);
+extern void RTjpeg_decompressYUV420 (__s8 * sp, __u8 * bp);
+extern void RTjpeg_decompressYUV422 (__s8 * sp, __u8 * bp);
+extern int RTjpeg_compress8 (__s8 * sp, unsigned char *bp);
+extern void RTjpeg_decompress8 (__s8 * sp, __u8 * bp);
+
+extern void RTjpeg_init_mcompress (void);
+extern int RTjpeg_mcompress (__s8 * sp, unsigned char *bp, __u16 lmask,
+ __u16 cmask);
+extern int RTjpeg_mcompress8 (__s8 * sp, unsigned char *bp, __u16 lmask);
+extern void RTjpeg_set_test (int i);
+
+extern void RTjpeg_yuv420rgb (__u8 * buf, __u8 * rgb);
+extern void RTjpeg_yuv422rgb (__u8 * buf, __u8 * rgb);
+extern void RTjpeg_yuvrgb8 (__u8 * buf, __u8 * rgb);
+extern void RTjpeg_yuvrgb16 (__u8 * buf, __u8 * rgb);
+extern void RTjpeg_yuvrgb24 (__u8 * buf, __u8 * rgb);
+extern void RTjpeg_yuvrgb32 (__u8 * buf, __u8 * rgb);
#include <gstrtjpegdec.h>
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
if (!gst_element_register (plugin, "rtjpegenc",
- GST_RANK_NONE, GST_TYPE_RTJPEGENC) ||
+ GST_RANK_NONE, GST_TYPE_RTJPEGENC) ||
!gst_element_register (plugin, "rtjpegdec",
- GST_RANK_NONE, GST_TYPE_RTJPEGDEC))
+ GST_RANK_NONE, GST_TYPE_RTJPEGDEC))
return FALSE;
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "rtjpeg",
- "Justin Schoeman's RTjpeg codec",
- plugin_init,
- VERSION,
- "GPL",
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "rtjpeg",
+ "Justin Schoeman's RTjpeg codec",
+ plugin_init, VERSION, "GPL", GST_PACKAGE, GST_ORIGIN)
};
/* GstRTJpegDec signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_QUALITY,
};
-static void gst_rtjpegdec_class_init (GstRTJpegDecClass *klass);
-static void gst_rtjpegdec_base_init (GstRTJpegDecClass *klass);
-static void gst_rtjpegdec_init (GstRTJpegDec *rtjpegdec);
+static void gst_rtjpegdec_class_init (GstRTJpegDecClass * klass);
+static void gst_rtjpegdec_base_init (GstRTJpegDecClass * klass);
+static void gst_rtjpegdec_init (GstRTJpegDec * rtjpegdec);
-static void gst_rtjpegdec_chain (GstPad *pad, GstData *_data);
+static void gst_rtjpegdec_chain (GstPad * pad, GstData * _data);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_rtjpegdec_signals[LAST_SIGNAL] = { 0 }; */
GType
if (!rtjpegdec_type) {
static const GTypeInfo rtjpegdec_info = {
- sizeof(GstRTJpegDecClass),
- (GBaseInitFunc)gst_rtjpegdec_base_init,
+ sizeof (GstRTJpegDecClass),
+ (GBaseInitFunc) gst_rtjpegdec_base_init,
NULL,
- (GClassInitFunc)gst_rtjpegdec_class_init,
+ (GClassInitFunc) gst_rtjpegdec_class_init,
NULL,
NULL,
- sizeof(GstRTJpegDec),
+ sizeof (GstRTJpegDec),
0,
- (GInstanceInitFunc)gst_rtjpegdec_init,
+ (GInstanceInitFunc) gst_rtjpegdec_init,
};
- rtjpegdec_type = g_type_register_static(GST_TYPE_ELEMENT, "GstRTJpegDec", &rtjpegdec_info, 0);
+ rtjpegdec_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstRTJpegDec",
+ &rtjpegdec_info, 0);
}
return rtjpegdec_type;
}
static void
-gst_rtjpegdec_base_init (GstRTJpegDecClass *klass)
+gst_rtjpegdec_base_init (GstRTJpegDecClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
}
static void
-gst_rtjpegdec_class_init (GstRTJpegDecClass *klass)
+gst_rtjpegdec_class_init (GstRTJpegDecClass * klass)
{
GstElementClass *gstelement_class;
- gstelement_class = (GstElementClass*)klass;
+ gstelement_class = (GstElementClass *) klass;
- parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
+ parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
}
static void
-gst_rtjpegdec_init (GstRTJpegDec *rtjpegdec)
+gst_rtjpegdec_init (GstRTJpegDec * rtjpegdec)
{
- rtjpegdec->sinkpad = gst_pad_new("sink",GST_PAD_SINK);
- gst_element_add_pad(GST_ELEMENT(rtjpegdec),rtjpegdec->sinkpad);
- gst_pad_set_chain_function(rtjpegdec->sinkpad,gst_rtjpegdec_chain);
- rtjpegdec->srcpad = gst_pad_new("src",GST_PAD_SRC);
- gst_element_add_pad(GST_ELEMENT(rtjpegdec),rtjpegdec->srcpad);
+ rtjpegdec->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
+ gst_element_add_pad (GST_ELEMENT (rtjpegdec), rtjpegdec->sinkpad);
+ gst_pad_set_chain_function (rtjpegdec->sinkpad, gst_rtjpegdec_chain);
+ rtjpegdec->srcpad = gst_pad_new ("src", GST_PAD_SRC);
+ gst_element_add_pad (GST_ELEMENT (rtjpegdec), rtjpegdec->srcpad);
}
static void
-gst_rtjpegdec_chain (GstPad *pad, GstData *_data)
+gst_rtjpegdec_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstRTJpegDec *rtjpegdec;
g_return_if_fail (buf != NULL);
rtjpegdec = GST_RTJPEGDEC (GST_OBJECT_PARENT (pad));
- data = GST_BUFFER_DATA(buf);
- size = GST_BUFFER_SIZE(buf);
+ data = GST_BUFFER_DATA (buf);
+ size = GST_BUFFER_SIZE (buf);
- gst_info("would be encoding frame here\n");
+ gst_info ("would be encoding frame here\n");
- gst_pad_push(rtjpegdec->srcpad,GST_DATA (buf));
+ gst_pad_push (rtjpegdec->srcpad, GST_DATA (buf));
}
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_RTJPEGDEC \
#define GST_IS_RTJPEGDEC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RTJPEGDEC)))
-typedef struct _GstRTJpegDec GstRTJpegDec;
-typedef struct _GstRTJpegDecClass GstRTJpegDecClass;
+ typedef struct _GstRTJpegDec GstRTJpegDec;
+ typedef struct _GstRTJpegDecClass GstRTJpegDecClass;
-struct _GstRTJpegDec {
- GstElement element;
+ struct _GstRTJpegDec
+ {
+ GstElement element;
- GstPad *sinkpad,*srcpad;
+ GstPad *sinkpad, *srcpad;
- gint width,height;
- gint quality;
- gint quant[128];
+ gint width, height;
+ gint quality;
+ gint quant[128];
-};
+ };
-struct _GstRTJpegDecClass {
- GstElementClass parent_class;
-};
+ struct _GstRTJpegDecClass
+ {
+ GstElementClass parent_class;
+ };
-GType gst_rtjpegdec_get_type(void);
+ GType gst_rtjpegdec_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __RTJPEGDEC_H__ */
+#endif /* __RTJPEGDEC_H__ */
};
/* GstRTJpegEnc signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_QUALITY,
};
-static void gst_rtjpegenc_class_init (GstRTJpegEncClass *klass);
-static void gst_rtjpegenc_base_init (GstRTJpegEncClass *klass);
-static void gst_rtjpegenc_init (GstRTJpegEnc *rtjpegenc);
+static void gst_rtjpegenc_class_init (GstRTJpegEncClass * klass);
+static void gst_rtjpegenc_base_init (GstRTJpegEncClass * klass);
+static void gst_rtjpegenc_init (GstRTJpegEnc * rtjpegenc);
-static void gst_rtjpegenc_chain (GstPad *pad, GstData *_data);
+static void gst_rtjpegenc_chain (GstPad * pad, GstData * _data);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_rtjpegenc_signals[LAST_SIGNAL] = { 0 }; */
GType
if (!rtjpegenc_type) {
static const GTypeInfo rtjpegenc_info = {
- sizeof(GstRTJpegEncClass),
- (GBaseInitFunc)gst_rtjpegenc_base_init,
+ sizeof (GstRTJpegEncClass),
+ (GBaseInitFunc) gst_rtjpegenc_base_init,
NULL,
- (GClassInitFunc)gst_rtjpegenc_class_init,
+ (GClassInitFunc) gst_rtjpegenc_class_init,
NULL,
NULL,
- sizeof(GstRTJpegEnc),
+ sizeof (GstRTJpegEnc),
0,
- (GInstanceInitFunc)gst_rtjpegenc_init,
+ (GInstanceInitFunc) gst_rtjpegenc_init,
};
- rtjpegenc_type = g_type_register_static(GST_TYPE_ELEMENT, "GstRTJpegEnc", &rtjpegenc_info, 0);
+ rtjpegenc_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstRTJpegEnc",
+ &rtjpegenc_info, 0);
}
return rtjpegenc_type;
}
static void
-gst_rtjpegenc_base_init (GstRTJpegEncClass *klass)
+gst_rtjpegenc_base_init (GstRTJpegEncClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
}
static void
-gst_rtjpegenc_class_init (GstRTJpegEncClass *klass)
+gst_rtjpegenc_class_init (GstRTJpegEncClass * klass)
{
GstElementClass *gstelement_class;
- gstelement_class = (GstElementClass*)klass;
+ gstelement_class = (GstElementClass *) klass;
- parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
+ parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
}
static void
-gst_rtjpegenc_init (GstRTJpegEnc *rtjpegenc)
+gst_rtjpegenc_init (GstRTJpegEnc * rtjpegenc)
{
- rtjpegenc->sinkpad = gst_pad_new("sink",GST_PAD_SINK);
- gst_element_add_pad(GST_ELEMENT(rtjpegenc),rtjpegenc->sinkpad);
- gst_pad_set_chain_function(rtjpegenc->sinkpad,gst_rtjpegenc_chain);
- rtjpegenc->srcpad = gst_pad_new("src",GST_PAD_SRC);
- gst_element_add_pad(GST_ELEMENT(rtjpegenc),rtjpegenc->srcpad);
+ rtjpegenc->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
+ gst_element_add_pad (GST_ELEMENT (rtjpegenc), rtjpegenc->sinkpad);
+ gst_pad_set_chain_function (rtjpegenc->sinkpad, gst_rtjpegenc_chain);
+ rtjpegenc->srcpad = gst_pad_new ("src", GST_PAD_SRC);
+ gst_element_add_pad (GST_ELEMENT (rtjpegenc), rtjpegenc->srcpad);
}
static void
-gst_rtjpegenc_chain (GstPad *pad, GstData *_data)
+gst_rtjpegenc_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstRTJpegEnc *rtjpegenc;
guchar *data;
gulong size;
- g_return_if_fail(pad != NULL);
- g_return_if_fail(GST_IS_PAD(pad));
- g_return_if_fail(buf != NULL);
+ g_return_if_fail (pad != NULL);
+ g_return_if_fail (GST_IS_PAD (pad));
+ g_return_if_fail (buf != NULL);
rtjpegenc = GST_RTJPEGENC (GST_OBJECT_PARENT (pad));
- data = GST_BUFFER_DATA(buf);
- size = GST_BUFFER_SIZE(buf);
+ data = GST_BUFFER_DATA (buf);
+ size = GST_BUFFER_SIZE (buf);
- gst_info("would be encoding frame here\n");
+ gst_info ("would be encoding frame here\n");
- gst_pad_push(rtjpegenc->srcpad,GST_DATA (buf));
+ gst_pad_push (rtjpegenc->srcpad, GST_DATA (buf));
}
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_RTJPEGENC \
#define GST_IS_RTJPEGENC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RTJPEGENC))
-typedef struct _GstRTJpegEnc GstRTJpegEnc;
-typedef struct _GstRTJpegEncClass GstRTJpegEncClass;
+ typedef struct _GstRTJpegEnc GstRTJpegEnc;
+ typedef struct _GstRTJpegEncClass GstRTJpegEncClass;
-struct _GstRTJpegEnc {
- GstElement element;
+ struct _GstRTJpegEnc
+ {
+ GstElement element;
- GstPad *sinkpad,*srcpad;
+ GstPad *sinkpad, *srcpad;
- gint width,height;
- gint quality;
- gint quant[128];
-};
+ gint width, height;
+ gint quality;
+ gint quant[128];
+ };
-struct _GstRTJpegEncClass {
- GstElementClass parent_class;
-};
+ struct _GstRTJpegEncClass
+ {
+ GstElementClass parent_class;
+ };
-GType gst_rtjpegenc_get_type(void);
+ GType gst_rtjpegenc_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __RTJPEGENC_H__ */
+#endif /* __RTJPEGENC_H__ */
/* Smooth signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_ACTIVE,
ARG_TOLERANCE,
};
static GstStaticPadTemplate gst_smooth_src_template =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- GST_VIDEO_CAPS_YUV("I420")
- )
-);
+GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420")
+ )
+ );
static GstStaticPadTemplate gst_smooth_sink_template =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- GST_VIDEO_CAPS_YUV("I420")
- )
-);
-
-static void gst_smooth_class_init (GstSmoothClass *klass);
-static void gst_smooth_base_init (GstSmoothClass *klass);
-static void gst_smooth_init (GstSmooth *smooth);
-
-static void gst_smooth_chain (GstPad *pad, GstData *_data);
-static void smooth_filter (unsigned char* dest, unsigned char* src,
- int width, int height, int tolerance, int filtersize);
-
-static void gst_smooth_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void gst_smooth_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420")
+ )
+ );
+
+static void gst_smooth_class_init (GstSmoothClass * klass);
+static void gst_smooth_base_init (GstSmoothClass * klass);
+static void gst_smooth_init (GstSmooth * smooth);
+
+static void gst_smooth_chain (GstPad * pad, GstData * _data);
+static void smooth_filter (unsigned char *dest, unsigned char *src,
+ int width, int height, int tolerance, int filtersize);
+
+static void gst_smooth_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_smooth_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_smooth_signals[LAST_SIGNAL] = { 0 }; */
GType
if (!smooth_type) {
static const GTypeInfo smooth_info = {
- sizeof(GstSmoothClass),
- (GBaseInitFunc)gst_smooth_base_init,
+ sizeof (GstSmoothClass),
+ (GBaseInitFunc) gst_smooth_base_init,
NULL,
- (GClassInitFunc)gst_smooth_class_init,
+ (GClassInitFunc) gst_smooth_class_init,
NULL,
NULL,
- sizeof(GstSmooth),
+ sizeof (GstSmooth),
0,
- (GInstanceInitFunc)gst_smooth_init,
+ (GInstanceInitFunc) gst_smooth_init,
};
- smooth_type = g_type_register_static(GST_TYPE_ELEMENT, "GstSmooth", &smooth_info, 0);
+ smooth_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstSmooth", &smooth_info, 0);
}
return smooth_type;
}
static void
-gst_smooth_base_init (GstSmoothClass *klass)
+gst_smooth_base_init (GstSmoothClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
}
static void
-gst_smooth_class_init (GstSmoothClass *klass)
+gst_smooth_class_init (GstSmoothClass * 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);
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_ACTIVE,
- g_param_spec_boolean("active","active","active",
- TRUE,G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_TOLERANCE,
- g_param_spec_int("tolerance","tolerance","tolerance",
- G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_FILTERSIZE,
- g_param_spec_int("filtersize","filtersize","filtersize",
- G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ACTIVE, g_param_spec_boolean ("active", "active", "active", TRUE, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TOLERANCE, g_param_spec_int ("tolerance", "tolerance", "tolerance", G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FILTERSIZE, g_param_spec_int ("filtersize", "filtersize", "filtersize", G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */
gobject_class->set_property = gst_smooth_set_property;
gobject_class->get_property = gst_smooth_get_property;
}
static GstPadLinkReturn
-gst_smooth_link (GstPad *pad, const GstCaps *caps)
+gst_smooth_link (GstPad * pad, const GstCaps * caps)
{
GstSmooth *filter;
GstStructure *structure;
ret = gst_structure_get_int (structure, "width", &filter->width);
ret &= gst_structure_get_int (structure, "height", &filter->height);
- if (!ret) return GST_PAD_LINK_REFUSED;
+ if (!ret)
+ return GST_PAD_LINK_REFUSED;
return gst_pad_try_set_caps (filter->srcpad, caps);
}
static void
-gst_smooth_init (GstSmooth *smooth)
+gst_smooth_init (GstSmooth * smooth)
{
- smooth->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&gst_smooth_sink_template), "sink");
+ smooth->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_smooth_sink_template), "sink");
gst_pad_set_link_function (smooth->sinkpad, gst_smooth_link);
gst_pad_set_chain_function (smooth->sinkpad, gst_smooth_chain);
gst_element_add_pad (GST_ELEMENT (smooth), smooth->sinkpad);
- smooth->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&gst_smooth_sink_template), "src");
+ smooth->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_smooth_sink_template), "src");
gst_pad_set_link_function (smooth->srcpad, gst_smooth_link);
gst_element_add_pad (GST_ELEMENT (smooth), smooth->srcpad);
}
static void
-smooth_filter (unsigned char* dest, unsigned char* src, int width, int height, int tolerance, int filtersize)
+smooth_filter (unsigned char *dest, unsigned char *src, int width, int height,
+ int tolerance, int filtersize)
{
int refval, aktval, upperval, lowerval, numvalues, sum;
int x, y, fx, fy, fy1, fy2, fx1, fx2;
unsigned char *srcp = src;
fy1 = 0;
- fy2 = MIN(filtersize+1, height) * width;
+ fy2 = MIN (filtersize + 1, height) * width;
- for(y = 0; y < height; y++)
- {
- if (y>(filtersize+1)) fy1 += width;
- if (y<height-(filtersize+1)) fy2 += width;
+ for (y = 0; y < height; y++) {
+ if (y > (filtersize + 1))
+ fy1 += width;
+ if (y < height - (filtersize + 1))
+ fy2 += width;
- for(x = 0; x < width; x++)
- {
- refval = *src;
- upperval = refval + tolerance;
- lowerval = refval - tolerance;
+ for (x = 0; x < width; x++) {
+ refval = *src;
+ upperval = refval + tolerance;
+ lowerval = refval - tolerance;
numvalues = 1;
- sum = refval;
-
- fx1 = MAX(x-filtersize, 0) + fy1;
- fx2 = MIN(x+filtersize+1, width) + fy1;
-
- for (fy = fy1; fy<fy2; fy+=width)
- {
- for (fx = fx1; fx<fx2; fx++)
- {
- aktval = srcp[fx];
- if ((lowerval-aktval)*(upperval-aktval)<0)
- {
- numvalues ++;
- sum += aktval;
- }
- } /*for fx */
- fx1 += width;
- fx2 += width;
- } /*for fy */
+ sum = refval;
+
+ fx1 = MAX (x - filtersize, 0) + fy1;
+ fx2 = MIN (x + filtersize + 1, width) + fy1;
+
+ for (fy = fy1; fy < fy2; fy += width) {
+ for (fx = fx1; fx < fx2; fx++) {
+ aktval = srcp[fx];
+ if ((lowerval - aktval) * (upperval - aktval) < 0) {
+ numvalues++;
+ sum += aktval;
+ }
+ } /*for fx */
+ fx1 += width;
+ fx2 += width;
+ } /*for fy */
src++;
- *dest++ = sum/numvalues;
+ *dest++ = sum / numvalues;
}
}
}
static void
-gst_smooth_chain (GstPad *pad, GstData *_data)
+gst_smooth_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstSmooth *smooth;
smooth = GST_SMOOTH (GST_OBJECT_PARENT (pad));
if (!smooth->active) {
- gst_pad_push(smooth->srcpad,GST_DATA (buf));
+ gst_pad_push (smooth->srcpad, GST_DATA (buf));
return;
}
GST_DEBUG ("smooth: have buffer of %d", GST_BUFFER_SIZE (buf));
- outbuf = gst_buffer_new();
+ outbuf = gst_buffer_new ();
GST_BUFFER_DATA (outbuf) = g_malloc (GST_BUFFER_SIZE (buf));
GST_BUFFER_SIZE (outbuf) = GST_BUFFER_SIZE (buf);
- lumsize = smooth->width*smooth->height;
- chromsize = lumsize/4;
+ lumsize = smooth->width * smooth->height;
+ chromsize = lumsize / 4;
- smooth_filter (GST_BUFFER_DATA (outbuf), data, smooth->width, smooth->height,
- smooth->tolerance, smooth->filtersize);
+ smooth_filter (GST_BUFFER_DATA (outbuf), data, smooth->width, smooth->height,
+ smooth->tolerance, smooth->filtersize);
if (!smooth->lum_only) {
- smooth_filter (GST_BUFFER_DATA (outbuf)+lumsize, data+lumsize, smooth->width/2, smooth->height/2,
- smooth->tolerance, smooth->filtersize/2);
- smooth_filter (GST_BUFFER_DATA (outbuf)+lumsize+chromsize, data+lumsize+chromsize, smooth->width/2,
- smooth->height/2, smooth->tolerance, smooth->filtersize/2);
- }
- else {
- memcpy (GST_BUFFER_DATA (outbuf)+lumsize, data+lumsize, chromsize*2);
+ smooth_filter (GST_BUFFER_DATA (outbuf) + lumsize, data + lumsize,
+ smooth->width / 2, smooth->height / 2, smooth->tolerance,
+ smooth->filtersize / 2);
+ smooth_filter (GST_BUFFER_DATA (outbuf) + lumsize + chromsize,
+ data + lumsize + chromsize, smooth->width / 2, smooth->height / 2,
+ smooth->tolerance, smooth->filtersize / 2);
+ } else {
+ memcpy (GST_BUFFER_DATA (outbuf) + lumsize, data + lumsize, chromsize * 2);
}
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
}
static void
-gst_smooth_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_smooth_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstSmooth *smooth;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_SMOOTH(object));
- smooth = GST_SMOOTH(object);
+ g_return_if_fail (GST_IS_SMOOTH (object));
+ smooth = GST_SMOOTH (object);
switch (prop_id) {
case ARG_ACTIVE:
}
static void
-gst_smooth_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_smooth_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstSmooth *smooth;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_SMOOTH(object));
- smooth = GST_SMOOTH(object);
+ g_return_if_fail (GST_IS_SMOOTH (object));
+ smooth = GST_SMOOTH (object);
switch (prop_id) {
case ARG_ACTIVE:
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- return gst_element_register(plugin, "smooth",
- GST_RANK_NONE, GST_TYPE_SMOOTH);
+ return gst_element_register (plugin, "smooth",
+ GST_RANK_NONE, GST_TYPE_SMOOTH);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "smooth",
- "Apply a smooth filter to an image",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "smooth",
+ "Apply a smooth filter to an image",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
#include <gst/gst.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_SMOOTH \
#define GST_IS_SMOOTH_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SMOOTH))
-typedef struct _GstSmooth GstSmooth;
-typedef struct _GstSmoothClass GstSmoothClass;
+ typedef struct _GstSmooth GstSmooth;
+ typedef struct _GstSmoothClass GstSmoothClass;
-struct _GstSmooth {
- GstElement element;
+ struct _GstSmooth
+ {
+ GstElement element;
- int format;
- int width;
- int height;
+ int format;
+ int width;
+ int height;
- gboolean active;
- int tolerance;
- int filtersize;
- gboolean lum_only;
+ gboolean active;
+ int tolerance;
+ int filtersize;
+ gboolean lum_only;
- GstPad *sinkpad,*srcpad;
-};
+ GstPad *sinkpad, *srcpad;
+ };
-struct _GstSmoothClass {
- GstElementClass parent_class;
-};
+ struct _GstSmoothClass
+ {
+ GstElementClass parent_class;
+ };
-GType gst_smooth_get_type(void);
+ GType gst_smooth_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_SMOOTH_H__ */
+#endif /* __GST_SMOOTH_H__ */
extern gboolean _gst_plugin_spew;
-gboolean idle_func(gpointer data);
+gboolean idle_func (gpointer data);
GtkWidget *drawingarea;
-int main(int argc,char *argv[]) {
+int
+main (int argc, char *argv[])
+{
GstElement *bin;
GstElementFactory *srcfactory;
GstElement *src;
GtkWidget *wave_widget;
GtkWidget *appwindow;
- gst_init(&argc,&argv);
- gst_plugin_load("libsmoothwave.so");
- gtk_init(&argc,&argv);
+ gst_init (&argc, &argv);
+ gst_plugin_load ("libsmoothwave.so");
+ gtk_init (&argc, &argv);
- bin = gst_pipeline_new("bin");
+ bin = gst_pipeline_new ("bin");
- srcfactory = gst_element_factory_find("sinesrc");
- g_return_val_if_fail(srcfactory != NULL, -1);
- wavefactory = gst_element_factory_find("smoothwave");
- g_return_val_if_fail(wavefactory != NULL, -1);
+ srcfactory = gst_element_factory_find ("sinesrc");
+ g_return_val_if_fail (srcfactory != NULL, -1);
+ wavefactory = gst_element_factory_find ("smoothwave");
+ g_return_val_if_fail (wavefactory != NULL, -1);
- src = gst_element_factory_create(srcfactory,"src");
+ src = gst_element_factory_create (srcfactory, "src");
//g_object_set(G_OBJECT(src),"bytes_per_read",(gulong)2048,NULL);
- wave = gst_element_factory_create(wavefactory,"wave");
- g_object_set(G_OBJECT(wave),"width",256,"height",100,NULL);
+ wave = gst_element_factory_create (wavefactory, "wave");
+ g_object_set (G_OBJECT (wave), "width", 256, "height", 100, NULL);
- gst_bin_add(GST_BIN(bin),GST_ELEMENT(src));
- gst_bin_add(GST_BIN(bin),GST_ELEMENT(wave));
+ gst_bin_add (GST_BIN (bin), GST_ELEMENT (src));
+ gst_bin_add (GST_BIN (bin), GST_ELEMENT (wave));
- gst_pad_link(gst_element_get_pad(src,"src"),
- gst_element_get_pad(wave,"sink"));
+ gst_pad_link (gst_element_get_pad (src, "src"),
+ gst_element_get_pad (wave, "sink"));
- appwindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- g_object_get(G_OBJECT(wave),"widget",&wave_widget,NULL);
- gtk_container_add(GTK_CONTAINER(appwindow), wave_widget);
- gtk_widget_show_all(appwindow);
+ appwindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ g_object_get (G_OBJECT (wave), "widget", &wave_widget, NULL);
+ gtk_container_add (GTK_CONTAINER (appwindow), wave_widget);
+ gtk_widget_show_all (appwindow);
- gst_element_set_state(GST_ELEMENT(bin),GST_STATE_READY);
- gst_element_set_state(GST_ELEMENT(bin),GST_STATE_PLAYING);
+ gst_element_set_state (GST_ELEMENT (bin), GST_STATE_READY);
+ gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING);
- g_idle_add(idle_func,bin);
+ g_idle_add (idle_func, bin);
- gtk_main();
+ gtk_main ();
return 0;
}
-gboolean idle_func(gpointer data)
+gboolean
+idle_func (gpointer data)
{
- gst_bin_iterate(GST_BIN(data));
+ gst_bin_iterate (GST_BIN (data));
return TRUE;
}
#include "gstsmoothwave.h"
-static GstElementDetails gst_smoothwave_details = GST_ELEMENT_DETAILS (
- "Smooth waveform",
- "Visualization",
- "Fading grayscale waveform display",
- "Erik Walthinsen <omega@cse.ogi.edu>"
-);
+static GstElementDetails gst_smoothwave_details =
+GST_ELEMENT_DETAILS ("Smooth waveform",
+ "Visualization",
+ "Fading grayscale waveform display",
+ "Erik Walthinsen <omega@cse.ogi.edu>");
/* SmoothWave signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_WIDTH,
ARG_HEIGHT,
ARG_WIDGET,
};
-static void gst_smoothwave_base_init (gpointer g_class);
-static void gst_smoothwave_class_init (GstSmoothWaveClass *klass);
-static void gst_smoothwave_init (GstSmoothWave *smoothwave);
+static void gst_smoothwave_base_init (gpointer g_class);
+static void gst_smoothwave_class_init (GstSmoothWaveClass * klass);
+static void gst_smoothwave_init (GstSmoothWave * smoothwave);
-static void gst_smoothwave_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void gst_smoothwave_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+static void gst_smoothwave_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_smoothwave_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static void gst_smoothwave_chain (GstPad *pad, GstData *_data);
+static void gst_smoothwave_chain (GstPad * pad, GstData * _data);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_smoothwave_signals[LAST_SIGNAL] = { 0 }; */
if (!smoothwave_type) {
static const GTypeInfo smoothwave_info = {
- sizeof(GstSmoothWaveClass),
+ sizeof (GstSmoothWaveClass),
gst_smoothwave_base_init,
NULL,
- (GClassInitFunc)gst_smoothwave_class_init,
+ (GClassInitFunc) gst_smoothwave_class_init,
NULL,
NULL,
- sizeof(GstSmoothWave),
+ sizeof (GstSmoothWave),
0,
- (GInstanceInitFunc)gst_smoothwave_init,
+ (GInstanceInitFunc) gst_smoothwave_init,
};
- smoothwave_type = g_type_register_static(GST_TYPE_ELEMENT, "GstSmoothWave", &smoothwave_info, 0);
+ smoothwave_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstSmoothWave",
+ &smoothwave_info, 0);
}
return smoothwave_type;
}
}
static void
-gst_smoothwave_class_init (GstSmoothWaveClass *klass)
+gst_smoothwave_class_init (GstSmoothWaveClass * 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);
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_WIDTH,
- g_param_spec_int("width","width","width",
- G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_HEIGHT,
- g_param_spec_int("height","height","height",
- G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_WIDGET,
- g_param_spec_object("widget","widget","widget",
- GTK_TYPE_WIDGET,G_PARAM_READABLE)); /* CHECKME! */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_WIDTH, g_param_spec_int ("width", "width", "width", G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_HEIGHT, g_param_spec_int ("height", "height", "height", G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_WIDGET, g_param_spec_object ("widget", "widget", "widget", GTK_TYPE_WIDGET, G_PARAM_READABLE)); /* CHECKME! */
gobject_class->set_property = gst_smoothwave_set_property;
gobject_class->get_property = gst_smoothwave_get_property;
}
static void
-gst_smoothwave_init (GstSmoothWave *smoothwave)
+gst_smoothwave_init (GstSmoothWave * smoothwave)
{
int i;
guint32 palette[256];
- smoothwave->sinkpad = gst_pad_new("sink",GST_PAD_SINK);
- gst_element_add_pad(GST_ELEMENT(smoothwave),smoothwave->sinkpad);
- gst_pad_set_chain_function(smoothwave->sinkpad,gst_smoothwave_chain);
- smoothwave->srcpad = gst_pad_new("src",GST_PAD_SRC);
- gst_element_add_pad(GST_ELEMENT(smoothwave),smoothwave->srcpad);
+ smoothwave->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
+ gst_element_add_pad (GST_ELEMENT (smoothwave), smoothwave->sinkpad);
+ gst_pad_set_chain_function (smoothwave->sinkpad, gst_smoothwave_chain);
+ smoothwave->srcpad = gst_pad_new ("src", GST_PAD_SRC);
+ gst_element_add_pad (GST_ELEMENT (smoothwave), smoothwave->srcpad);
/* smoothwave->meta = NULL; */
smoothwave->width = 512;
smoothwave->height = 256;
- gdk_rgb_init();
+ gdk_rgb_init ();
/* gtk_widget_set_default_colormap (gdk_rgb_get_cmap()); */
/* gtk_widget_set_default_visual (gdk_rgb_get_visual()); */
/* GST_DEBUG ("creating palette"); */
- for (i=0;i<256;i++)
+ for (i = 0; i < 256; i++)
palette[i] = (i << 16) || (i << 8);
/* GST_DEBUG ("creating cmap"); */
- smoothwave->cmap = gdk_rgb_cmap_new(palette,256);
+ smoothwave->cmap = gdk_rgb_cmap_new (palette, 256);
/* GST_DEBUG ("created cmap"); */
/* gtk_widget_set_default_colormap (smoothwave->cmap); */
- smoothwave->image = gtk_drawing_area_new();
- gtk_drawing_area_size(GTK_DRAWING_AREA(smoothwave->image),
- smoothwave->width,smoothwave->height);
- gtk_widget_show(smoothwave->image);
+ smoothwave->image = gtk_drawing_area_new ();
+ gtk_drawing_area_size (GTK_DRAWING_AREA (smoothwave->image),
+ smoothwave->width, smoothwave->height);
+ gtk_widget_show (smoothwave->image);
- smoothwave->imagebuffer = g_malloc(smoothwave->width*smoothwave->height);
- memset(smoothwave->imagebuffer,0,smoothwave->width*smoothwave->height);
+ smoothwave->imagebuffer = g_malloc (smoothwave->width * smoothwave->height);
+ memset (smoothwave->imagebuffer, 0, smoothwave->width * smoothwave->height);
}
static void
-gst_smoothwave_chain (GstPad *pad, GstData *_data)
+gst_smoothwave_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstSmoothWave *smoothwave;
gint16 *samples;
- gint samplecount,i;
+ gint samplecount, i;
register guint32 *ptr;
gint qheight;
- g_return_if_fail(pad != NULL);
- g_return_if_fail(GST_IS_PAD(pad));
- g_return_if_fail(buf != NULL);
+ g_return_if_fail (pad != NULL);
+ g_return_if_fail (GST_IS_PAD (pad));
+ g_return_if_fail (buf != NULL);
/* g_return_if_fail(GST_IS_BUFFER(buf)); */
- smoothwave = GST_SMOOTHWAVE(GST_OBJECT_PARENT (pad));
+ smoothwave = GST_SMOOTHWAVE (GST_OBJECT_PARENT (pad));
/* first deal with audio metadata */
#if 0
/* FIXME: need to unref the old metadata so it goes away */
}
/* we just make a copy of the pointer */
- smoothwave->meta = (MetaAudioRaw *)(buf->meta);
+ smoothwave->meta = (MetaAudioRaw *) (buf->meta);
/* FIXME: now we have to ref the metadata so it doesn't go away */
}
#endif
/* g_return_if_fail(smoothwave->meta != NULL); */
- samples = (gint16 *)GST_BUFFER_DATA(buf);
+ samples = (gint16 *) GST_BUFFER_DATA (buf);
/* samplecount = buf->datasize / (smoothwave->meta->channels * sizeof(gint16)); */
- samplecount = GST_BUFFER_SIZE(buf) / (2 * sizeof(gint16));
+ samplecount = GST_BUFFER_SIZE (buf) / (2 * sizeof (gint16));
- qheight = smoothwave->height/4;
+ qheight = smoothwave->height / 4;
/* GST_DEBUG ("traversing %d",smoothwave->width); */
- for (i=0;i<MAX(smoothwave->width,samplecount);i++) {
- gint16 y1 = (gint32)(samples[i*2] * qheight) / 32768 +
- qheight;
- gint16 y2 = (gint32)(samples[(i*2)+1] * qheight) / 32768 +
- (qheight*3);
- smoothwave->imagebuffer[y1*smoothwave->width + i] = 0xff;
- smoothwave->imagebuffer[y2*smoothwave->width + i] = 0xff;
+ for (i = 0; i < MAX (smoothwave->width, samplecount); i++) {
+ gint16 y1 = (gint32) (samples[i * 2] * qheight) / 32768 + qheight;
+ gint16 y2 = (gint32) (samples[(i * 2) + 1] * qheight) / 32768 +
+ (qheight * 3);
+ smoothwave->imagebuffer[y1 * smoothwave->width + i] = 0xff;
+ smoothwave->imagebuffer[y2 * smoothwave->width + i] = 0xff;
/* smoothwave->imagebuffer[i+(smoothwave->width*5)] = i; */
}
- ptr = (guint32 *)smoothwave->imagebuffer;
- for (i=0;i<(smoothwave->width*smoothwave->height)/4;i++) {
- if (*ptr){
+ ptr = (guint32 *) smoothwave->imagebuffer;
+ for (i = 0; i < (smoothwave->width * smoothwave->height) / 4; i++) {
+ if (*ptr) {
*ptr -= ((*ptr & 0xf0f0f0f0ul) >> 4) + ((*ptr & 0xe0e0e0e0ul) >> 5);
ptr++;
- }else{
+ } else {
ptr++;
}
}
GDK_RGB_DITHER_NONE,
smoothwave->imagebuffer,smoothwave->width,
smoothwave->cmap);*/
- gdk_draw_gray_image(smoothwave->image->window,
- smoothwave->image->style->fg_gc[GTK_STATE_NORMAL],
- 0,0,smoothwave->width,smoothwave->height,
- GDK_RGB_DITHER_NORMAL,
- smoothwave->imagebuffer,smoothwave->width);
+ gdk_draw_gray_image (smoothwave->image->window,
+ smoothwave->image->style->fg_gc[GTK_STATE_NORMAL],
+ 0, 0, smoothwave->width, smoothwave->height,
+ GDK_RGB_DITHER_NORMAL, smoothwave->imagebuffer, smoothwave->width);
/* gst_trace_add_entry(NULL,0,buf,"smoothwave: calculated smoothwave"); */
- gst_buffer_unref(buf);
+ gst_buffer_unref (buf);
}
static void
-gst_smoothwave_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_smoothwave_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstSmoothWave *smoothwave;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_SMOOTHWAVE(object));
- smoothwave = GST_SMOOTHWAVE(object);
+ g_return_if_fail (GST_IS_SMOOTHWAVE (object));
+ smoothwave = GST_SMOOTHWAVE (object);
switch (prop_id) {
case ARG_WIDTH:
smoothwave->width = g_value_get_int (value);
- gtk_drawing_area_size(GTK_DRAWING_AREA(smoothwave->image),
- smoothwave->width,smoothwave->height);
- gtk_widget_set_usize(GTK_WIDGET(smoothwave->image),
- smoothwave->width,smoothwave->height);
+ gtk_drawing_area_size (GTK_DRAWING_AREA (smoothwave->image),
+ smoothwave->width, smoothwave->height);
+ gtk_widget_set_usize (GTK_WIDGET (smoothwave->image),
+ smoothwave->width, smoothwave->height);
break;
case ARG_HEIGHT:
smoothwave->height = g_value_get_int (value);
- gtk_drawing_area_size(GTK_DRAWING_AREA(smoothwave->image),
- smoothwave->width,smoothwave->height);
- gtk_widget_set_usize(GTK_WIDGET(smoothwave->image),
- smoothwave->width,smoothwave->height);
+ gtk_drawing_area_size (GTK_DRAWING_AREA (smoothwave->image),
+ smoothwave->width, smoothwave->height);
+ gtk_widget_set_usize (GTK_WIDGET (smoothwave->image),
+ smoothwave->width, smoothwave->height);
break;
default:
break;
}
static void
-gst_smoothwave_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_smoothwave_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstSmoothWave *smoothwave;
/* it's not null if we got it, but it might not be ours */
- smoothwave = GST_SMOOTHWAVE(object);
+ smoothwave = GST_SMOOTHWAVE (object);
switch (prop_id) {
- case ARG_WIDTH: {
+ case ARG_WIDTH:{
g_value_set_int (value, smoothwave->width);
break;
}
- case ARG_HEIGHT: {
+ case ARG_HEIGHT:{
g_value_set_int (value, smoothwave->height);
break;
}
- case ARG_WIDGET: {
+ case ARG_WIDGET:{
g_value_set_object (value, smoothwave->image);
break;
}
- default: {
+ default:{
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- if (!gst_element_register (plugin, "smoothwave", GST_RANK_NONE, GST_TYPE_SMOOTHWAVE))
+ if (!gst_element_register (plugin, "smoothwave", GST_RANK_NONE,
+ GST_TYPE_SMOOTHWAVE))
return FALSE;
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "smoothwave",
- "Fading greyscale waveform display",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "smoothwave",
+ "Fading greyscale waveform display",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
#include <gtk/gtk.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_SMOOTHWAVE \
#define GST_IS_SMOOTHWAVE_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SMOOTHWAVE))
-typedef struct _GstSmoothWave GstSmoothWave;
-typedef struct _GstSmoothWaveClass GstSmoothWaveClass;
+ typedef struct _GstSmoothWave GstSmoothWave;
+ typedef struct _GstSmoothWaveClass GstSmoothWaveClass;
-struct _GstSmoothWave {
- GstElement element;
+ struct _GstSmoothWave
+ {
+ GstElement element;
- GstPad *sinkpad,*srcpad;
+ GstPad *sinkpad, *srcpad;
- gint width,height;
+ gint width, height;
- GdkRgbCmap *cmap;
- GtkWidget *image;
- guchar *imagebuffer;
-};
+ GdkRgbCmap *cmap;
+ GtkWidget *image;
+ guchar *imagebuffer;
+ };
-struct _GstSmoothWaveClass {
- GstElementClass parent_class;
-};
+ struct _GstSmoothWaveClass
+ {
+ GstElementClass parent_class;
+ };
-GType gst_smoothwave_get_type(void);
+ GType gst_smoothwave_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_SMOOTHWAVE_H__ */
+#endif /* __GST_SMOOTHWAVE_H__ */
enum
{
- BOX_VERTICAL = 1,
- BOX_HORIZONTAL = 2,
- BOX_CLOCK = 3,
- TRIGANLE_LINEAR = 4,
+ BOX_VERTICAL = 1,
+ BOX_HORIZONTAL = 2,
+ BOX_CLOCK = 3,
+ TRIGANLE_LINEAR = 4,
};
-static gint boxes_1b[][7] =
-{
+static gint boxes_1b[][7] = {
#define WIPE_B1_1 0
- { BOX_VERTICAL, 0, 0, 0, 1, 1, 1 },
+ {BOX_VERTICAL, 0, 0, 0, 1, 1, 1},
#define WIPE_B1_2 1
- { BOX_HORIZONTAL, 0, 0, 0, 1, 1, 1 }
+ {BOX_HORIZONTAL, 0, 0, 0, 1, 1, 1}
};
-static gint boxes_2b[][7*2] =
-{
+static gint boxes_2b[][7 * 2] = {
#define WIPE_B2_21 0
- { BOX_VERTICAL, 0, 0, 1, 1, 2, 0,
- BOX_VERTICAL, 1, 0, 0, 2, 2, 1 },
+ {BOX_VERTICAL, 0, 0, 1, 1, 2, 0,
+ BOX_VERTICAL, 1, 0, 0, 2, 2, 1},
#define WIPE_B2_22 1
- { BOX_HORIZONTAL, 0, 0, 1, 2, 1, 0,
- BOX_HORIZONTAL, 0, 1, 0, 2, 2, 1 },
+ {BOX_HORIZONTAL, 0, 0, 1, 2, 1, 0,
+ BOX_HORIZONTAL, 0, 1, 0, 2, 2, 1},
};
-static gint box_clock_1b[][1*10] =
-{
+static gint box_clock_1b[][1 * 10] = {
#define WIPE_B1_241 0
- { BOX_CLOCK, 0, 0, 0, 1, 0, 0, 0, 1, 1 },
+ {BOX_CLOCK, 0, 0, 0, 1, 0, 0, 0, 1, 1},
#define WIPE_B1_242 1
- { BOX_CLOCK, 0, 1, 0, 1, 1, 0, 0, 0, 1 },
+ {BOX_CLOCK, 0, 1, 0, 1, 1, 0, 0, 0, 1},
#define WIPE_B1_243 2
- { BOX_CLOCK, 1, 1, 0, 0, 1, 0, 1, 0, 1 },
+ {BOX_CLOCK, 1, 1, 0, 0, 1, 0, 1, 0, 1},
#define WIPE_B1_244 3
- { BOX_CLOCK, 1, 0, 0, 0, 0, 0, 1, 1, 1 },
+ {BOX_CLOCK, 1, 0, 0, 0, 0, 0, 1, 1, 1},
};
#define WIPE_B2_221 0
-static gint box_clock_2b[][2*10] =
-{
+static gint box_clock_2b[][2 * 10] = {
#define WIPE_B2_221 0
- { BOX_CLOCK, 1, 0, 0, 2, 0, 0, 1, 2, 1,
- BOX_CLOCK, 1, 0, 0, 1, 2, 1, 0, 0, 2 },
+ {BOX_CLOCK, 1, 0, 0, 2, 0, 0, 1, 2, 1,
+ BOX_CLOCK, 1, 0, 0, 1, 2, 1, 0, 0, 2},
#define WIPE_B2_222 1
- { BOX_CLOCK, 2, 1, 0, 2, 2, 0, 0, 1, 1,
- BOX_CLOCK, 2, 1, 0, 0, 1, 1, 2, 0, 2 },
+ {BOX_CLOCK, 2, 1, 0, 2, 2, 0, 0, 1, 1,
+ BOX_CLOCK, 2, 1, 0, 0, 1, 1, 2, 0, 2},
#define WIPE_B2_223 2
- { BOX_CLOCK, 1, 2, 0, 0, 2, 0, 1, 0, 1,
- BOX_CLOCK, 1, 2, 0, 1, 0, 1, 2, 2, 2 },
+ {BOX_CLOCK, 1, 2, 0, 0, 2, 0, 1, 0, 1,
+ BOX_CLOCK, 1, 2, 0, 1, 0, 1, 2, 2, 2},
#define WIPE_B2_224 3
- { BOX_CLOCK, 0, 1, 0, 0, 0, 0, 2, 1, 1,
- BOX_CLOCK, 0, 1, 0, 2, 1, 1, 0, 2, 2 },
+ {BOX_CLOCK, 0, 1, 0, 0, 0, 0, 2, 1, 1,
+ BOX_CLOCK, 0, 1, 0, 2, 1, 1, 0, 2, 2},
#define WIPE_B2_225 4
- { BOX_CLOCK, 1, 0, 0, 2, 0, 0, 1, 2, 1,
- BOX_CLOCK, 1, 2, 0, 0, 2, 0, 1, 0, 1 },
+ {BOX_CLOCK, 1, 0, 0, 2, 0, 0, 1, 2, 1,
+ BOX_CLOCK, 1, 2, 0, 0, 2, 0, 1, 0, 1},
#define WIPE_B2_226 5
- { BOX_CLOCK, 0, 1, 0, 0, 0, 0, 2, 1, 1,
- BOX_CLOCK, 2, 1, 0, 2, 2, 0, 0, 1, 1 },
+ {BOX_CLOCK, 0, 1, 0, 0, 0, 0, 2, 1, 1,
+ BOX_CLOCK, 2, 1, 0, 2, 2, 0, 0, 1, 1},
#define WIPE_B2_231 6
- { BOX_CLOCK, 1, 0, 0, 1, 2, 0, 2, 0, 1,
- BOX_CLOCK, 1, 0, 0, 1, 2, 0, 0, 0, 1 },
+ {BOX_CLOCK, 1, 0, 0, 1, 2, 0, 2, 0, 1,
+ BOX_CLOCK, 1, 0, 0, 1, 2, 0, 0, 0, 1},
#define WIPE_B2_232 7
- { BOX_CLOCK, 2, 1, 0, 0, 1, 0, 2, 0, 1,
- BOX_CLOCK, 2, 1, 0, 0, 1, 0, 2, 2, 1 },
+ {BOX_CLOCK, 2, 1, 0, 0, 1, 0, 2, 0, 1,
+ BOX_CLOCK, 2, 1, 0, 0, 1, 0, 2, 2, 1},
#define WIPE_B2_233 8
- { BOX_CLOCK, 1, 2, 0, 1, 0, 0, 2, 2, 1,
- BOX_CLOCK, 1, 2, 0, 1, 0, 0, 0, 2, 1 },
+ {BOX_CLOCK, 1, 2, 0, 1, 0, 0, 2, 2, 1,
+ BOX_CLOCK, 1, 2, 0, 1, 0, 0, 0, 2, 1},
#define WIPE_B2_234 9
- { BOX_CLOCK, 0, 1, 0, 2, 1, 0, 0, 0, 1,
- BOX_CLOCK, 0, 1, 0, 2, 1, 0, 0, 2, 1 },
+ {BOX_CLOCK, 0, 1, 0, 2, 1, 0, 0, 0, 1,
+ BOX_CLOCK, 0, 1, 0, 2, 1, 0, 0, 2, 1},
#define WIPE_B2_251 10
- { BOX_CLOCK, 0, 0, 0, 1, 0, 0, 0, 2, 1,
- BOX_CLOCK, 2, 0, 0, 1, 0, 0, 2, 2, 1 },
+ {BOX_CLOCK, 0, 0, 0, 1, 0, 0, 0, 2, 1,
+ BOX_CLOCK, 2, 0, 0, 1, 0, 0, 2, 2, 1},
#define WIPE_B2_252 11
- { BOX_CLOCK, 0, 0, 0, 0, 1, 0, 2, 0, 1,
- BOX_CLOCK, 0, 2, 0, 0, 1, 0, 2, 2, 1 },
+ {BOX_CLOCK, 0, 0, 0, 0, 1, 0, 2, 0, 1,
+ BOX_CLOCK, 0, 2, 0, 0, 1, 0, 2, 2, 1},
#define WIPE_B2_253 12
- { BOX_CLOCK, 0, 2, 0, 1, 2, 0, 0, 0, 1,
- BOX_CLOCK, 2, 2, 0, 1, 2, 0, 2, 0, 1 },
+ {BOX_CLOCK, 0, 2, 0, 1, 2, 0, 0, 0, 1,
+ BOX_CLOCK, 2, 2, 0, 1, 2, 0, 2, 0, 1},
#define WIPE_B2_254 13
- { BOX_CLOCK, 2, 0, 0, 2, 1, 0, 0, 0, 1,
- BOX_CLOCK, 2, 2, 0, 2, 1, 0, 0, 2, 1 },
+ {BOX_CLOCK, 2, 0, 0, 2, 1, 0, 0, 0, 1,
+ BOX_CLOCK, 2, 2, 0, 2, 1, 0, 0, 2, 1},
};
-static gint box_clock_4b[][4*10] =
-{
+static gint box_clock_4b[][4 * 10] = {
#define WIPE_B4_201 0
- { BOX_CLOCK, 1, 1, 0, 1, 0, 0, 2, 1, 1,
- BOX_CLOCK, 1, 1, 0, 2, 1, 1, 1, 2, 2,
- BOX_CLOCK, 1, 1, 0, 1, 2, 2, 0, 1, 3,
- BOX_CLOCK, 1, 1, 0, 0, 1, 3, 1, 0, 4 },
+ {BOX_CLOCK, 1, 1, 0, 1, 0, 0, 2, 1, 1,
+ BOX_CLOCK, 1, 1, 0, 2, 1, 1, 1, 2, 2,
+ BOX_CLOCK, 1, 1, 0, 1, 2, 2, 0, 1, 3,
+ BOX_CLOCK, 1, 1, 0, 0, 1, 3, 1, 0, 4},
#define WIPE_B4_202 1
- { BOX_CLOCK, 1, 1, 0, 1, 0, 3, 2, 1, 4,
- BOX_CLOCK, 1, 1, 0, 2, 1, 0, 1, 2, 1,
- BOX_CLOCK, 1, 1, 0, 1, 2, 1, 0, 1, 2,
- BOX_CLOCK, 1, 1, 0, 0, 1, 2, 1, 0, 3 },
+ {BOX_CLOCK, 1, 1, 0, 1, 0, 3, 2, 1, 4,
+ BOX_CLOCK, 1, 1, 0, 2, 1, 0, 1, 2, 1,
+ BOX_CLOCK, 1, 1, 0, 1, 2, 1, 0, 1, 2,
+ BOX_CLOCK, 1, 1, 0, 0, 1, 2, 1, 0, 3},
#define WIPE_B4_203 2
- { BOX_CLOCK, 1, 1, 0, 1, 0, 2, 2, 1, 3,
- BOX_CLOCK, 1, 1, 0, 2, 1, 3, 1, 2, 4,
- BOX_CLOCK, 1, 1, 0, 1, 2, 0, 0, 1, 1,
- BOX_CLOCK, 1, 1, 0, 0, 1, 1, 1, 0, 2 },
+ {BOX_CLOCK, 1, 1, 0, 1, 0, 2, 2, 1, 3,
+ BOX_CLOCK, 1, 1, 0, 2, 1, 3, 1, 2, 4,
+ BOX_CLOCK, 1, 1, 0, 1, 2, 0, 0, 1, 1,
+ BOX_CLOCK, 1, 1, 0, 0, 1, 1, 1, 0, 2},
#define WIPE_B4_204 3
- { BOX_CLOCK, 1, 1, 0, 1, 0, 1, 2, 1, 2,
- BOX_CLOCK, 1, 1, 0, 2, 1, 2, 1, 2, 3,
- BOX_CLOCK, 1, 1, 0, 1, 2, 3, 0, 1, 4,
- BOX_CLOCK, 1, 1, 0, 0, 1, 0, 1, 0, 1 },
+ {BOX_CLOCK, 1, 1, 0, 1, 0, 1, 2, 1, 2,
+ BOX_CLOCK, 1, 1, 0, 2, 1, 2, 1, 2, 3,
+ BOX_CLOCK, 1, 1, 0, 1, 2, 3, 0, 1, 4,
+ BOX_CLOCK, 1, 1, 0, 0, 1, 0, 1, 0, 1},
#define WIPE_B4_205 4
- { BOX_CLOCK, 1, 1, 0, 1, 0, 0, 2, 1, 1,
- BOX_CLOCK, 1, 1, 0, 2, 1, 1, 1, 2, 2,
- BOX_CLOCK, 1, 1, 0, 1, 2, 0, 0, 1, 1,
- BOX_CLOCK, 1, 1, 0, 0, 1, 1, 1, 0, 2 },
+ {BOX_CLOCK, 1, 1, 0, 1, 0, 0, 2, 1, 1,
+ BOX_CLOCK, 1, 1, 0, 2, 1, 1, 1, 2, 2,
+ BOX_CLOCK, 1, 1, 0, 1, 2, 0, 0, 1, 1,
+ BOX_CLOCK, 1, 1, 0, 0, 1, 1, 1, 0, 2},
#define WIPE_B4_206 5
- { BOX_CLOCK, 1, 1, 0, 1, 0, 1, 2, 1, 2,
- BOX_CLOCK, 1, 1, 0, 2, 1, 0, 1, 2, 1,
- BOX_CLOCK, 1, 1, 0, 1, 2, 1, 0, 1, 2,
- BOX_CLOCK, 1, 1, 0, 0, 1, 0, 1, 0, 1 },
+ {BOX_CLOCK, 1, 1, 0, 1, 0, 1, 2, 1, 2,
+ BOX_CLOCK, 1, 1, 0, 2, 1, 0, 1, 2, 1,
+ BOX_CLOCK, 1, 1, 0, 1, 2, 1, 0, 1, 2,
+ BOX_CLOCK, 1, 1, 0, 0, 1, 0, 1, 0, 1},
#define WIPE_B4_207 6
- { BOX_CLOCK, 1, 1, 0, 1, 0, 0, 2, 1, 1,
- BOX_CLOCK, 1, 1, 0, 2, 1, 0, 1, 2, 1,
- BOX_CLOCK, 1, 1, 0, 1, 2, 0, 0, 1, 1,
- BOX_CLOCK, 1, 1, 0, 0, 1, 0, 1, 0, 1 },
+ {BOX_CLOCK, 1, 1, 0, 1, 0, 0, 2, 1, 1,
+ BOX_CLOCK, 1, 1, 0, 2, 1, 0, 1, 2, 1,
+ BOX_CLOCK, 1, 1, 0, 1, 2, 0, 0, 1, 1,
+ BOX_CLOCK, 1, 1, 0, 0, 1, 0, 1, 0, 1},
#define WIPE_B4_211 7
- { BOX_CLOCK, 1, 1, 0, 1, 0, 0, 2, 1, 1,
- BOX_CLOCK, 1, 1, 0, 2, 1, 1, 1, 2, 2,
- BOX_CLOCK, 1, 1, 0, 1, 0, 0, 0, 1, 1,
- BOX_CLOCK, 1, 1, 0, 0, 1, 1, 1, 2, 2 },
+ {BOX_CLOCK, 1, 1, 0, 1, 0, 0, 2, 1, 1,
+ BOX_CLOCK, 1, 1, 0, 2, 1, 1, 1, 2, 2,
+ BOX_CLOCK, 1, 1, 0, 1, 0, 0, 0, 1, 1,
+ BOX_CLOCK, 1, 1, 0, 0, 1, 1, 1, 2, 2},
#define WIPE_B4_212 8
- { BOX_CLOCK, 1, 1, 0, 2, 1, 0, 1, 0, 1,
- BOX_CLOCK, 1, 1, 0, 1, 0, 1, 0, 1, 2,
- BOX_CLOCK, 1, 1, 0, 2, 1, 0, 1, 2, 1,
- BOX_CLOCK, 1, 1, 0, 1, 2, 1, 0, 1, 2 },
+ {BOX_CLOCK, 1, 1, 0, 2, 1, 0, 1, 0, 1,
+ BOX_CLOCK, 1, 1, 0, 1, 0, 1, 0, 1, 2,
+ BOX_CLOCK, 1, 1, 0, 2, 1, 0, 1, 2, 1,
+ BOX_CLOCK, 1, 1, 0, 1, 2, 1, 0, 1, 2},
#define WIPE_B4_213 9
- { BOX_CLOCK, 1, 1, 0, 1, 0, 0, 2, 1, 1,
- BOX_CLOCK, 1, 1, 0, 1, 0, 0, 0, 1, 1,
- BOX_CLOCK, 1, 1, 0, 1, 2, 0, 2, 1, 1,
- BOX_CLOCK, 1, 1, 0, 1, 2, 0, 0, 1, 1 },
+ {BOX_CLOCK, 1, 1, 0, 1, 0, 0, 2, 1, 1,
+ BOX_CLOCK, 1, 1, 0, 1, 0, 0, 0, 1, 1,
+ BOX_CLOCK, 1, 1, 0, 1, 2, 0, 2, 1, 1,
+ BOX_CLOCK, 1, 1, 0, 1, 2, 0, 0, 1, 1},
#define WIPE_B4_214 10
- { BOX_CLOCK, 1, 1, 0, 2, 1, 0, 1, 0, 1,
- BOX_CLOCK, 1, 1, 0, 2, 1, 0, 1, 2, 1,
- BOX_CLOCK, 1, 1, 0, 0, 1, 0, 1, 0, 1,
- BOX_CLOCK, 1, 1, 0, 0, 1, 0, 1, 2, 1 },
+ {BOX_CLOCK, 1, 1, 0, 2, 1, 0, 1, 0, 1,
+ BOX_CLOCK, 1, 1, 0, 2, 1, 0, 1, 2, 1,
+ BOX_CLOCK, 1, 1, 0, 0, 1, 0, 1, 0, 1,
+ BOX_CLOCK, 1, 1, 0, 0, 1, 0, 1, 2, 1},
#define WIPE_B4_227 11
- { BOX_CLOCK, 1, 0, 0, 2, 0, 0, 1, 1, 1,
- BOX_CLOCK, 1, 0, 0, 1, 1, 1, 0, 0, 2,
- BOX_CLOCK, 1, 2, 0, 2, 2, 0, 1, 1, 1,
- BOX_CLOCK, 1, 2, 0, 1, 1, 1, 0, 2, 2 },
+ {BOX_CLOCK, 1, 0, 0, 2, 0, 0, 1, 1, 1,
+ BOX_CLOCK, 1, 0, 0, 1, 1, 1, 0, 0, 2,
+ BOX_CLOCK, 1, 2, 0, 2, 2, 0, 1, 1, 1,
+ BOX_CLOCK, 1, 2, 0, 1, 1, 1, 0, 2, 2},
#define WIPE_B4_228 12
- { BOX_CLOCK, 0, 1, 0, 0, 0, 0, 1, 1, 1,
- BOX_CLOCK, 0, 1, 0, 1, 1, 1, 0, 2, 2,
- BOX_CLOCK, 2, 1, 0, 2, 0, 0, 1, 1, 1,
- BOX_CLOCK, 2, 1, 0, 1, 1, 1, 2, 2, 2 },
+ {BOX_CLOCK, 0, 1, 0, 0, 0, 0, 1, 1, 1,
+ BOX_CLOCK, 0, 1, 0, 1, 1, 1, 0, 2, 2,
+ BOX_CLOCK, 2, 1, 0, 2, 0, 0, 1, 1, 1,
+ BOX_CLOCK, 2, 1, 0, 1, 1, 1, 2, 2, 2},
#define WIPE_B4_235 13
- { BOX_CLOCK, 1, 0, 0, 1, 1, 0, 0, 0, 1,
- BOX_CLOCK, 1, 0, 0, 1, 1, 0, 2, 0, 1,
- BOX_CLOCK, 1, 2, 0, 1, 1, 0, 2, 2, 1,
- BOX_CLOCK, 1, 2, 0, 1, 1, 0, 0, 2, 1 },
+ {BOX_CLOCK, 1, 0, 0, 1, 1, 0, 0, 0, 1,
+ BOX_CLOCK, 1, 0, 0, 1, 1, 0, 2, 0, 1,
+ BOX_CLOCK, 1, 2, 0, 1, 1, 0, 2, 2, 1,
+ BOX_CLOCK, 1, 2, 0, 1, 1, 0, 0, 2, 1},
#define WIPE_B4_236 14
- { BOX_CLOCK, 0, 1, 0, 1, 1, 0, 0, 0, 1,
- BOX_CLOCK, 0, 1, 0, 1, 1, 0, 0, 2, 1,
- BOX_CLOCK, 2, 1, 0, 1, 1, 0, 2, 0, 1,
- BOX_CLOCK, 2, 1, 0, 1, 1, 0, 2, 2, 1 },
+ {BOX_CLOCK, 0, 1, 0, 1, 1, 0, 0, 0, 1,
+ BOX_CLOCK, 0, 1, 0, 1, 1, 0, 0, 2, 1,
+ BOX_CLOCK, 2, 1, 0, 1, 1, 0, 2, 0, 1,
+ BOX_CLOCK, 2, 1, 0, 1, 1, 0, 2, 2, 1},
};
-static gint box_clock_8b[][8*10] =
-{
+static gint box_clock_8b[][8 * 10] = {
#define WIPE_B8_261 0
- { BOX_CLOCK, 2, 1, 0, 2, 2, 0, 4, 1, 1,
- BOX_CLOCK, 2, 1, 0, 4, 1, 1, 2, 0, 2,
- BOX_CLOCK, 2, 1, 0, 2, 0, 2, 0, 1, 3,
- BOX_CLOCK, 2, 1, 0, 0, 1, 3, 2, 2, 4,
- BOX_CLOCK, 2, 3, 0, 2, 2, 0, 4, 3, 1,
- BOX_CLOCK, 2, 3, 0, 4, 3, 1, 2, 4, 2,
- BOX_CLOCK, 2, 3, 0, 2, 4, 2, 0, 3, 3,
- BOX_CLOCK, 2, 3, 0, 0, 3, 3, 2, 2, 4 },
+ {BOX_CLOCK, 2, 1, 0, 2, 2, 0, 4, 1, 1,
+ BOX_CLOCK, 2, 1, 0, 4, 1, 1, 2, 0, 2,
+ BOX_CLOCK, 2, 1, 0, 2, 0, 2, 0, 1, 3,
+ BOX_CLOCK, 2, 1, 0, 0, 1, 3, 2, 2, 4,
+ BOX_CLOCK, 2, 3, 0, 2, 2, 0, 4, 3, 1,
+ BOX_CLOCK, 2, 3, 0, 4, 3, 1, 2, 4, 2,
+ BOX_CLOCK, 2, 3, 0, 2, 4, 2, 0, 3, 3,
+ BOX_CLOCK, 2, 3, 0, 0, 3, 3, 2, 2, 4},
#define WIPE_B8_262 1
- { BOX_CLOCK, 1, 2, 0, 2, 2, 0, 1, 0, 1,
- BOX_CLOCK, 1, 2, 0, 1, 0, 1, 0, 2, 2,
- BOX_CLOCK, 1, 2, 0, 0, 2, 2, 1, 4, 3,
- BOX_CLOCK, 1, 2, 0, 1, 4, 3, 2, 2, 4,
- BOX_CLOCK, 3, 2, 0, 2, 2, 0, 3, 0, 1,
- BOX_CLOCK, 3, 2, 0, 3, 0, 1, 4, 2, 2,
- BOX_CLOCK, 3, 2, 0, 4, 2, 2, 3, 4, 3,
- BOX_CLOCK, 3, 2, 0, 3, 4, 3, 2, 2, 4 },
+ {BOX_CLOCK, 1, 2, 0, 2, 2, 0, 1, 0, 1,
+ BOX_CLOCK, 1, 2, 0, 1, 0, 1, 0, 2, 2,
+ BOX_CLOCK, 1, 2, 0, 0, 2, 2, 1, 4, 3,
+ BOX_CLOCK, 1, 2, 0, 1, 4, 3, 2, 2, 4,
+ BOX_CLOCK, 3, 2, 0, 2, 2, 0, 3, 0, 1,
+ BOX_CLOCK, 3, 2, 0, 3, 0, 1, 4, 2, 2,
+ BOX_CLOCK, 3, 2, 0, 4, 2, 2, 3, 4, 3,
+ BOX_CLOCK, 3, 2, 0, 3, 4, 3, 2, 2, 4},
#define WIPE_B8_263 2
- { BOX_CLOCK, 2, 1, 0, 2, 0, 0, 4, 1, 1,
- BOX_CLOCK, 2, 1, 0, 4, 1, 1, 2, 2, 2,
- BOX_CLOCK, 2, 1, 0, 2, 0, 0, 0, 1, 1,
- BOX_CLOCK, 2, 1, 0, 0, 1, 1, 2, 2, 2,
- BOX_CLOCK, 2, 3, 0, 2, 4, 0, 4, 3, 1,
- BOX_CLOCK, 2, 3, 0, 4, 3, 1, 2, 2, 2,
- BOX_CLOCK, 2, 3, 0, 2, 4, 0, 0, 3, 1,
- BOX_CLOCK, 2, 3, 0, 0, 3, 1, 2, 2, 2 },
+ {BOX_CLOCK, 2, 1, 0, 2, 0, 0, 4, 1, 1,
+ BOX_CLOCK, 2, 1, 0, 4, 1, 1, 2, 2, 2,
+ BOX_CLOCK, 2, 1, 0, 2, 0, 0, 0, 1, 1,
+ BOX_CLOCK, 2, 1, 0, 0, 1, 1, 2, 2, 2,
+ BOX_CLOCK, 2, 3, 0, 2, 4, 0, 4, 3, 1,
+ BOX_CLOCK, 2, 3, 0, 4, 3, 1, 2, 2, 2,
+ BOX_CLOCK, 2, 3, 0, 2, 4, 0, 0, 3, 1,
+ BOX_CLOCK, 2, 3, 0, 0, 3, 1, 2, 2, 2},
#define WIPE_B8_264 3
- { BOX_CLOCK, 1, 2, 0, 0, 2, 0, 1, 0, 1,
- BOX_CLOCK, 1, 2, 0, 1, 0, 1, 2, 2, 2,
- BOX_CLOCK, 1, 2, 0, 0, 2, 0, 1, 4, 1,
- BOX_CLOCK, 1, 2, 0, 1, 4, 1, 2, 2, 2,
- BOX_CLOCK, 3, 2, 0, 4, 2, 0, 3, 0, 1,
- BOX_CLOCK, 3, 2, 0, 3, 0, 1, 2, 2, 2,
- BOX_CLOCK, 3, 2, 0, 4, 2, 0, 3, 4, 1,
- BOX_CLOCK, 3, 2, 0, 3, 4, 1, 2, 2, 2 },
+ {BOX_CLOCK, 1, 2, 0, 0, 2, 0, 1, 0, 1,
+ BOX_CLOCK, 1, 2, 0, 1, 0, 1, 2, 2, 2,
+ BOX_CLOCK, 1, 2, 0, 0, 2, 0, 1, 4, 1,
+ BOX_CLOCK, 1, 2, 0, 1, 4, 1, 2, 2, 2,
+ BOX_CLOCK, 3, 2, 0, 4, 2, 0, 3, 0, 1,
+ BOX_CLOCK, 3, 2, 0, 3, 0, 1, 2, 2, 2,
+ BOX_CLOCK, 3, 2, 0, 4, 2, 0, 3, 4, 1,
+ BOX_CLOCK, 3, 2, 0, 3, 4, 1, 2, 2, 2},
};
-static gint triangles_2t[][2*9] =
-{
+static gint triangles_2t[][2 * 9] = {
/* 3 -> 6 */
#define WIPE_T2_3 0
- { 0, 0, 0, 0, 1, 1, 1, 1, 1,
- 1, 0, 1, 0, 0, 0, 1, 1, 1 },
+ {0, 0, 0, 0, 1, 1, 1, 1, 1,
+ 1, 0, 1, 0, 0, 0, 1, 1, 1},
#define WIPE_T2_4 WIPE_T2_3+1
- { 0, 0, 1, 1, 0, 0, 0, 1, 1,
- 1, 0, 0, 0, 1, 1, 1, 1, 1 },
+ {0, 0, 1, 1, 0, 0, 0, 1, 1,
+ 1, 0, 0, 0, 1, 1, 1, 1, 1},
#define WIPE_T2_5 WIPE_T2_4+1
- { 0, 0, 1, 0, 1, 1, 1, 1, 0,
- 1, 0, 1, 0, 0, 1, 1, 1, 0 },
+ {0, 0, 1, 0, 1, 1, 1, 1, 0,
+ 1, 0, 1, 0, 0, 1, 1, 1, 0},
#define WIPE_T2_6 WIPE_T2_5+1
- { 0, 0, 1, 1, 0, 1, 0, 1, 0,
- 1, 0, 1, 0, 1, 0, 1, 1, 1 },
+ {0, 0, 1, 1, 0, 1, 0, 1, 0,
+ 1, 0, 1, 0, 1, 0, 1, 1, 1},
#define WIPE_T2_41 WIPE_T2_6+1
- { 0, 0, 0, 1, 0, 1, 0, 1, 1,
- 1, 0, 1, 0, 1, 1, 1, 1, 2 },
+ {0, 0, 0, 1, 0, 1, 0, 1, 1,
+ 1, 0, 1, 0, 1, 1, 1, 1, 2},
#define WIPE_T2_42 WIPE_T2_41+1
- { 0, 0, 1, 1, 0, 0, 1, 1, 1,
- 0, 0, 1, 0, 1, 2, 1, 1, 1 },
+ {0, 0, 1, 1, 0, 0, 1, 1, 1,
+ 0, 0, 1, 0, 1, 2, 1, 1, 1},
#define WIPE_T2_45 WIPE_T2_42+1
- { 0, 0, 1, 1, 0, 0, 0, 1, 0,
- 1, 0, 0, 0, 1, 0, 1, 1, 1 },
+ {0, 0, 1, 1, 0, 0, 0, 1, 0,
+ 1, 0, 0, 0, 1, 0, 1, 1, 1},
#define WIPE_T2_46 WIPE_T2_45+1
- { 0, 0, 0, 1, 0, 1, 1, 1, 0,
- 0, 0, 0, 0, 1, 1, 1, 1, 0 },
+ {0, 0, 0, 1, 0, 1, 1, 1, 0,
+ 0, 0, 0, 0, 1, 1, 1, 1, 0},
#define WIPE_T2_245 WIPE_T2_46+1
- { 0, 0, 0, 2, 0, 0, 2, 2, 1,
- 2, 2, 0, 0, 2, 0, 0, 0, 1 },
+ {0, 0, 0, 2, 0, 0, 2, 2, 1,
+ 2, 2, 0, 0, 2, 0, 0, 0, 1},
#define WIPE_T2_246 WIPE_T2_245+1
- { 0, 2, 0, 0, 0, 0, 2, 0, 1,
- 2, 0, 0, 2, 2, 0, 0, 2, 1 },
+ {0, 2, 0, 0, 0, 0, 2, 0, 1,
+ 2, 0, 0, 2, 2, 0, 0, 2, 1},
};
-static gint triangles_3t[][3*9] =
-{
+static gint triangles_3t[][3 * 9] = {
/* 23 -> 26 */
#define WIPE_T3_23 0
- { 0, 0, 1, 1, 0, 0, 0, 2, 1,
- 1, 0, 0, 0, 2, 1, 2, 2, 1,
- 1, 0, 0, 2, 0, 1, 2, 2, 1 },
+ {0, 0, 1, 1, 0, 0, 0, 2, 1,
+ 1, 0, 0, 0, 2, 1, 2, 2, 1,
+ 1, 0, 0, 2, 0, 1, 2, 2, 1},
#define WIPE_T3_24 1
- { 0, 0, 1, 2, 0, 1, 2, 1, 0,
- 0, 0, 1, 2, 1, 0, 0, 2, 1,
- 2, 1, 0, 0, 2, 1, 2, 2, 1 },
+ {0, 0, 1, 2, 0, 1, 2, 1, 0,
+ 0, 0, 1, 2, 1, 0, 0, 2, 1,
+ 2, 1, 0, 0, 2, 1, 2, 2, 1},
#define WIPE_T3_25 2
- { 0, 0, 1, 0, 2, 1, 1, 2, 0,
- 0, 0, 1, 2, 0, 1, 1, 2, 0,
- 2, 0, 1, 1, 2, 0, 2, 2, 1 },
+ {0, 0, 1, 0, 2, 1, 1, 2, 0,
+ 0, 0, 1, 2, 0, 1, 1, 2, 0,
+ 2, 0, 1, 1, 2, 0, 2, 2, 1},
#define WIPE_T3_26 3
- { 0, 0, 1, 2, 0, 1, 0, 1, 0,
- 2, 0, 1, 0, 1, 0, 2, 2, 1,
- 0, 1, 0, 0, 2, 1, 2, 2, 1 },
+ {0, 0, 1, 2, 0, 1, 0, 1, 0,
+ 2, 0, 1, 0, 1, 0, 2, 2, 1,
+ 0, 1, 0, 0, 2, 1, 2, 2, 1},
};
-static gint triangles_4t[][4*9] =
-{
+static gint triangles_4t[][4 * 9] = {
#define WIPE_T4_61 0
- { 0, 0, 1, 1, 0, 0, 1, 2, 1,
- 0, 0, 1, 0, 2, 2, 1, 2, 1,
- 1, 0, 0, 2, 0, 1, 1, 2, 1,
- 2, 0, 1, 1, 2, 1, 2, 2, 2 },
+ {0, 0, 1, 1, 0, 0, 1, 2, 1,
+ 0, 0, 1, 0, 2, 2, 1, 2, 1,
+ 1, 0, 0, 2, 0, 1, 1, 2, 1,
+ 2, 0, 1, 1, 2, 1, 2, 2, 2},
#define WIPE_T4_62 1
- { 0, 0, 2, 2, 0, 1, 0, 1, 1,
- 2, 0, 1, 0, 1, 1, 2, 1, 0,
- 0, 1, 1, 2, 1, 0, 2, 2, 1,
- 0, 1, 1, 0, 2, 2, 2, 2, 1 },
+ {0, 0, 2, 2, 0, 1, 0, 1, 1,
+ 2, 0, 1, 0, 1, 1, 2, 1, 0,
+ 0, 1, 1, 2, 1, 0, 2, 2, 1,
+ 0, 1, 1, 0, 2, 2, 2, 2, 1},
#define WIPE_T4_63 2
- { 0, 0, 2, 1, 0, 1, 0, 2, 1,
- 1, 0, 1, 0, 2, 1, 1, 2, 0,
- 1, 0, 1, 1, 2, 0, 2, 2, 1,
- 1, 0, 1, 2, 0, 2, 2, 2, 1 },
+ {0, 0, 2, 1, 0, 1, 0, 2, 1,
+ 1, 0, 1, 0, 2, 1, 1, 2, 0,
+ 1, 0, 1, 1, 2, 0, 2, 2, 1,
+ 1, 0, 1, 2, 0, 2, 2, 2, 1},
#define WIPE_T4_64 3
- { 0, 0, 1, 2, 0, 2, 2, 1, 1,
- 0, 0, 1, 0, 1, 0, 2, 1, 1,
- 0, 1, 0, 2, 1, 1, 0, 2, 1,
- 2, 1, 1, 0, 2, 1, 2, 2, 2 },
+ {0, 0, 1, 2, 0, 2, 2, 1, 1,
+ 0, 0, 1, 0, 1, 0, 2, 1, 1,
+ 0, 1, 0, 2, 1, 1, 0, 2, 1,
+ 2, 1, 1, 0, 2, 1, 2, 2, 2},
#define WIPE_T4_65 4
- { 0, 0, 0, 1, 0, 1, 1, 2, 0,
- 0, 0, 0, 0, 2, 1, 1, 2, 0,
- 1, 0, 1, 2, 0, 0, 1, 2, 0,
- 2, 0, 0, 1, 2, 0, 2, 2, 1 },
+ {0, 0, 0, 1, 0, 1, 1, 2, 0,
+ 0, 0, 0, 0, 2, 1, 1, 2, 0,
+ 1, 0, 1, 2, 0, 0, 1, 2, 0,
+ 2, 0, 0, 1, 2, 0, 2, 2, 1},
#define WIPE_T4_66 5
- { 0, 0, 1, 2, 0, 0, 0, 1, 0,
- 2, 0, 0, 0, 1, 0, 2, 1, 1,
- 0, 1, 0, 2, 1, 1, 2, 2, 0,
- 0, 1, 0, 0, 2, 1, 2, 2, 0 },
+ {0, 0, 1, 2, 0, 0, 0, 1, 0,
+ 2, 0, 0, 0, 1, 0, 2, 1, 1,
+ 0, 1, 0, 2, 1, 1, 2, 2, 0,
+ 0, 1, 0, 0, 2, 1, 2, 2, 0},
#define WIPE_T4_67 6
- { 0, 0, 1, 1, 0, 0, 0, 2, 0,
- 1, 0, 0, 0, 2, 0, 1, 2, 1,
- 1, 0, 0, 1, 2, 1, 2, 2, 0,
- 1, 0, 0, 2, 0, 1, 2, 2, 0 },
+ {0, 0, 1, 1, 0, 0, 0, 2, 0,
+ 1, 0, 0, 0, 2, 0, 1, 2, 1,
+ 1, 0, 0, 1, 2, 1, 2, 2, 0,
+ 1, 0, 0, 2, 0, 1, 2, 2, 0},
#define WIPE_T4_68 7
- { 0, 0, 0, 2, 0, 1, 2, 1, 0,
- 0, 0, 0, 0, 1, 1, 2, 1, 0,
- 0, 1, 1, 2, 1, 0, 0, 2, 0,
- 2, 1, 0, 0, 2, 0, 2, 2, 1 },
+ {0, 0, 0, 2, 0, 1, 2, 1, 0,
+ 0, 0, 0, 0, 1, 1, 2, 1, 0,
+ 0, 1, 1, 2, 1, 0, 0, 2, 0,
+ 2, 1, 0, 0, 2, 0, 2, 2, 1},
#define WIPE_T4_101 8
- { 0, 0, 1, 2, 0, 1, 1, 1, 0,
- 0, 0, 1, 1, 1, 0, 0, 2, 1,
- 1, 1, 0, 0, 2, 1, 2, 2, 1,
- 2, 0, 1, 1, 1, 0, 2, 2, 1 },
+ {0, 0, 1, 2, 0, 1, 1, 1, 0,
+ 0, 0, 1, 1, 1, 0, 0, 2, 1,
+ 1, 1, 0, 0, 2, 1, 2, 2, 1,
+ 2, 0, 1, 1, 1, 0, 2, 2, 1},
};
-static gint triangles_8t[][8*9] =
-{
+static gint triangles_8t[][8 * 9] = {
/* 7 */
#define WIPE_T8_7 0
- { 0, 0, 0, 1, 0, 1, 1, 1, 1,
- 1, 0, 1, 2, 0, 0, 1, 1, 1,
- 2, 0, 0, 1, 1, 1, 2, 1, 1,
- 1, 1, 1, 2, 1, 1, 2, 2, 0,
- 1, 1, 1, 1, 2, 1, 2, 2, 0,
- 1, 1, 1, 0, 2, 0, 1, 2, 1,
- 0, 1, 1, 1, 1, 1, 0, 2, 0,
- 0, 0, 0, 0, 1, 1, 1, 1, 1 },
+ {0, 0, 0, 1, 0, 1, 1, 1, 1,
+ 1, 0, 1, 2, 0, 0, 1, 1, 1,
+ 2, 0, 0, 1, 1, 1, 2, 1, 1,
+ 1, 1, 1, 2, 1, 1, 2, 2, 0,
+ 1, 1, 1, 1, 2, 1, 2, 2, 0,
+ 1, 1, 1, 0, 2, 0, 1, 2, 1,
+ 0, 1, 1, 1, 1, 1, 0, 2, 0,
+ 0, 0, 0, 0, 1, 1, 1, 1, 1},
#define WIPE_T8_43 1
- { 0, 0, 1, 1, 0, 0, 1, 1, 1,
- 1, 0, 0, 2, 0, 1, 1, 1, 1,
- 2, 0, 1, 1, 1, 1, 2, 1, 2,
- 1, 1, 1, 2, 1, 2, 2, 2, 1,
- 1, 1, 1, 1, 2, 0, 2, 2, 1,
- 1, 1, 1, 0, 2, 1, 1, 2, 0,
- 0, 1, 2, 1, 1, 1, 0, 2, 1,
- 0, 0, 1, 0, 1, 2, 1, 1, 1 },
+ {0, 0, 1, 1, 0, 0, 1, 1, 1,
+ 1, 0, 0, 2, 0, 1, 1, 1, 1,
+ 2, 0, 1, 1, 1, 1, 2, 1, 2,
+ 1, 1, 1, 2, 1, 2, 2, 2, 1,
+ 1, 1, 1, 1, 2, 0, 2, 2, 1,
+ 1, 1, 1, 0, 2, 1, 1, 2, 0,
+ 0, 1, 2, 1, 1, 1, 0, 2, 1,
+ 0, 0, 1, 0, 1, 2, 1, 1, 1},
#define WIPE_T8_44 2
- { 0, 0, 1, 1, 0, 2, 1, 1, 1,
- 1, 0, 2, 2, 0, 1, 1, 1, 1,
- 2, 0, 1, 1, 1, 1, 2, 1, 0,
- 1, 1, 1, 2, 1, 0, 2, 2, 1,
- 1, 1, 1, 1, 2, 2, 2, 2, 1,
- 1, 1, 1, 0, 2, 1, 1, 2, 2,
- 0, 1, 0, 1, 1, 1, 0, 2, 1,
- 0, 0, 1, 0, 1, 0, 1, 1, 1 },
+ {0, 0, 1, 1, 0, 2, 1, 1, 1,
+ 1, 0, 2, 2, 0, 1, 1, 1, 1,
+ 2, 0, 1, 1, 1, 1, 2, 1, 0,
+ 1, 1, 1, 2, 1, 0, 2, 2, 1,
+ 1, 1, 1, 1, 2, 2, 2, 2, 1,
+ 1, 1, 1, 0, 2, 1, 1, 2, 2,
+ 0, 1, 0, 1, 1, 1, 0, 2, 1,
+ 0, 0, 1, 0, 1, 0, 1, 1, 1},
#define WIPE_T8_47 3
- { 0, 0, 0, 1, 0, 1, 1, 1, 0,
- 1, 0, 1, 2, 0, 0, 1, 1, 0,
- 2, 0, 0, 1, 1, 0, 2, 1, 1,
- 1, 1, 0, 2, 1, 1, 2, 2, 0,
- 1, 1, 0, 1, 2, 1, 2, 2, 0,
- 1, 1, 0, 0, 2, 0, 1, 2, 1,
- 0, 1, 1, 1, 1, 0, 0, 2, 0,
- 0, 0, 0, 0, 1, 1, 1, 1, 0 },
+ {0, 0, 0, 1, 0, 1, 1, 1, 0,
+ 1, 0, 1, 2, 0, 0, 1, 1, 0,
+ 2, 0, 0, 1, 1, 0, 2, 1, 1,
+ 1, 1, 0, 2, 1, 1, 2, 2, 0,
+ 1, 1, 0, 1, 2, 1, 2, 2, 0,
+ 1, 1, 0, 0, 2, 0, 1, 2, 1,
+ 0, 1, 1, 1, 1, 0, 0, 2, 0,
+ 0, 0, 0, 0, 1, 1, 1, 1, 0},
#define WIPE_T8_48 4
- { 0, 0, 1, 1, 0, 0, 0, 1, 0,
- 1, 0, 0, 0, 1, 0, 1, 1, 1,
- 1, 0, 0, 2, 0, 1, 2, 1, 0,
- 1, 0, 0, 1, 1, 1, 2, 1, 0,
- 0, 1, 0, 1, 1, 1, 1, 2, 0,
- 0, 1, 0, 0, 2, 1, 1, 2, 0,
- 1, 1, 1, 2, 1, 0, 1, 2, 0,
- 2, 1, 0, 1, 2, 0, 2, 2, 1 },
+ {0, 0, 1, 1, 0, 0, 0, 1, 0,
+ 1, 0, 0, 0, 1, 0, 1, 1, 1,
+ 1, 0, 0, 2, 0, 1, 2, 1, 0,
+ 1, 0, 0, 1, 1, 1, 2, 1, 0,
+ 0, 1, 0, 1, 1, 1, 1, 2, 0,
+ 0, 1, 0, 0, 2, 1, 1, 2, 0,
+ 1, 1, 1, 2, 1, 0, 1, 2, 0,
+ 2, 1, 0, 1, 2, 0, 2, 2, 1},
};
-static gint triangles_16t[][16*9] =
-{
+static gint triangles_16t[][16 * 9] = {
/* 8 */
#define WIPE_T16_8 0
- { 0, 0, 1, 2, 0, 1, 1, 1, 0,
- 2, 0, 1, 1, 1, 0, 2, 2, 1,
- 1, 1, 0, 0, 2, 1, 2, 2, 1,
- 0, 0, 1, 1, 1, 0, 0, 2, 1,
- 2, 0, 1, 4, 0, 1, 3, 1, 0,
- 4, 0, 1, 3, 1, 0, 4, 2, 1,
- 3, 1, 0, 2, 2, 1, 4, 2, 1,
- 2, 0, 1, 3, 1, 0, 2, 2, 1,
- 0, 2, 1, 2, 2, 1, 1, 3, 0,
- 2, 2, 1, 1, 3, 0, 2, 4, 1,
- 1, 3, 0, 0, 4, 1, 2, 4, 1,
- 0, 2, 1, 1, 3, 0, 0, 4, 1,
- 2, 2, 1, 4, 2, 1, 3, 3, 0,
- 4, 2, 1, 3, 3, 0, 4, 4, 1,
- 3, 3, 0, 2, 4, 1, 4, 4, 1,
- 2, 2, 1, 3, 3, 0, 2, 4, 1 }
+ {0, 0, 1, 2, 0, 1, 1, 1, 0,
+ 2, 0, 1, 1, 1, 0, 2, 2, 1,
+ 1, 1, 0, 0, 2, 1, 2, 2, 1,
+ 0, 0, 1, 1, 1, 0, 0, 2, 1,
+ 2, 0, 1, 4, 0, 1, 3, 1, 0,
+ 4, 0, 1, 3, 1, 0, 4, 2, 1,
+ 3, 1, 0, 2, 2, 1, 4, 2, 1,
+ 2, 0, 1, 3, 1, 0, 2, 2, 1,
+ 0, 2, 1, 2, 2, 1, 1, 3, 0,
+ 2, 2, 1, 1, 3, 0, 2, 4, 1,
+ 1, 3, 0, 0, 4, 1, 2, 4, 1,
+ 0, 2, 1, 1, 3, 0, 0, 4, 1,
+ 2, 2, 1, 4, 2, 1, 3, 3, 0,
+ 4, 2, 1, 3, 3, 0, 4, 4, 1,
+ 3, 3, 0, 2, 4, 1, 4, 4, 1,
+ 2, 2, 1, 3, 3, 0, 2, 4, 1}
};
typedef struct _GstWipeConfig GstWipeConfig;
-struct _GstWipeConfig {
- gint *objects;
- gint nobjects;
- gint xscale;
- gint yscale;
- gint cscale;
+struct _GstWipeConfig
+{
+ gint *objects;
+ gint nobjects;
+ gint xscale;
+ gint yscale;
+ gint cscale;
};
-static GstWipeConfig wipe_config[] =
-{
+static GstWipeConfig wipe_config[] = {
#define WIPE_CONFIG_1 0
- { boxes_1b[WIPE_B1_1], 1, 0, 0, 0 }, /* 1 */
+ {boxes_1b[WIPE_B1_1], 1, 0, 0, 0}, /* 1 */
#define WIPE_CONFIG_2 WIPE_CONFIG_1+1
- { boxes_1b[WIPE_B1_2], 1, 0, 0, 0 }, /* 2 */
+ {boxes_1b[WIPE_B1_2], 1, 0, 0, 0}, /* 2 */
#define WIPE_CONFIG_3 WIPE_CONFIG_2+1
- { triangles_2t[WIPE_T2_3], 2, 0, 0, 0 }, /* 3 */
+ {triangles_2t[WIPE_T2_3], 2, 0, 0, 0}, /* 3 */
#define WIPE_CONFIG_4 WIPE_CONFIG_3+1
- { triangles_2t[WIPE_T2_4], 2, 0, 0, 0 }, /* 4 */
+ {triangles_2t[WIPE_T2_4], 2, 0, 0, 0}, /* 4 */
#define WIPE_CONFIG_5 WIPE_CONFIG_4+1
- { triangles_2t[WIPE_T2_5], 2, 0, 0, 0 }, /* 5 */
+ {triangles_2t[WIPE_T2_5], 2, 0, 0, 0}, /* 5 */
#define WIPE_CONFIG_6 WIPE_CONFIG_5+1
- { triangles_2t[WIPE_T2_6], 2, 0, 0, 0 }, /* 6 */
+ {triangles_2t[WIPE_T2_6], 2, 0, 0, 0}, /* 6 */
#define WIPE_CONFIG_7 WIPE_CONFIG_6+1
- { triangles_8t[WIPE_T8_7], 8, 1, 1, 0 }, /* 7 */
+ {triangles_8t[WIPE_T8_7], 8, 1, 1, 0}, /* 7 */
#define WIPE_CONFIG_8 WIPE_CONFIG_7+1
- { triangles_16t[WIPE_T16_8], 16, 2, 2, 0 }, /* 8 */
+ {triangles_16t[WIPE_T16_8], 16, 2, 2, 0}, /* 8 */
#define WIPE_CONFIG_21 WIPE_CONFIG_8+1
- { boxes_2b[WIPE_B2_21], 2, 1, 1, 0 }, /* 21 */
+ {boxes_2b[WIPE_B2_21], 2, 1, 1, 0}, /* 21 */
#define WIPE_CONFIG_22 WIPE_CONFIG_21+1
- { boxes_2b[WIPE_B2_22], 2, 1, 1, 0 }, /* 22 */
+ {boxes_2b[WIPE_B2_22], 2, 1, 1, 0}, /* 22 */
#define WIPE_CONFIG_23 WIPE_CONFIG_22+1
- { triangles_3t[WIPE_T3_23], 3, 1, 1, 0 }, /* 23 */
+ {triangles_3t[WIPE_T3_23], 3, 1, 1, 0}, /* 23 */
#define WIPE_CONFIG_24 WIPE_CONFIG_23+1
- { triangles_3t[WIPE_T3_24], 3, 1, 1, 0 }, /* 24 */
+ {triangles_3t[WIPE_T3_24], 3, 1, 1, 0}, /* 24 */
#define WIPE_CONFIG_25 WIPE_CONFIG_24+1
- { triangles_3t[WIPE_T3_23], 3, 1, 1, 0 }, /* 25 */
+ {triangles_3t[WIPE_T3_23], 3, 1, 1, 0}, /* 25 */
#define WIPE_CONFIG_26 WIPE_CONFIG_25+1
- { triangles_3t[WIPE_T3_26], 3, 1, 1, 0 }, /* 26 */
+ {triangles_3t[WIPE_T3_26], 3, 1, 1, 0}, /* 26 */
#define WIPE_CONFIG_41 WIPE_CONFIG_26+1
- { triangles_2t[WIPE_T2_41], 2, 0, 0, 1 }, /* 41 */
+ {triangles_2t[WIPE_T2_41], 2, 0, 0, 1}, /* 41 */
#define WIPE_CONFIG_42 WIPE_CONFIG_41+1
- { triangles_2t[WIPE_T2_42], 2, 0, 0, 1 }, /* 42 */
+ {triangles_2t[WIPE_T2_42], 2, 0, 0, 1}, /* 42 */
#define WIPE_CONFIG_43 WIPE_CONFIG_42+1
- { triangles_8t[WIPE_T8_43], 8, 1, 1, 1 }, /* 43 */
+ {triangles_8t[WIPE_T8_43], 8, 1, 1, 1}, /* 43 */
#define WIPE_CONFIG_44 WIPE_CONFIG_43+1
- { triangles_8t[WIPE_T8_44], 8, 1, 1, 1 }, /* 44 */
+ {triangles_8t[WIPE_T8_44], 8, 1, 1, 1}, /* 44 */
#define WIPE_CONFIG_45 WIPE_CONFIG_44+1
- { triangles_2t[WIPE_T2_45], 2, 0, 0, 0 }, /* 45 */
+ {triangles_2t[WIPE_T2_45], 2, 0, 0, 0}, /* 45 */
#define WIPE_CONFIG_46 WIPE_CONFIG_45+1
- { triangles_2t[WIPE_T2_46], 2, 0, 0, 0 }, /* 46 */
+ {triangles_2t[WIPE_T2_46], 2, 0, 0, 0}, /* 46 */
#define WIPE_CONFIG_47 WIPE_CONFIG_46+1
- { triangles_8t[WIPE_T8_47], 8, 1, 1, 0 }, /* 47 */
+ {triangles_8t[WIPE_T8_47], 8, 1, 1, 0}, /* 47 */
#define WIPE_CONFIG_48 WIPE_CONFIG_47+1
- { triangles_8t[WIPE_T8_48], 8, 1, 1, 0 }, /* 48 */
+ {triangles_8t[WIPE_T8_48], 8, 1, 1, 0}, /* 48 */
#define WIPE_CONFIG_61 WIPE_CONFIG_48+1
- { triangles_4t[WIPE_T4_61], 4, 1, 1, 1 }, /* 61 */
+ {triangles_4t[WIPE_T4_61], 4, 1, 1, 1}, /* 61 */
#define WIPE_CONFIG_62 WIPE_CONFIG_61+1
- { triangles_4t[WIPE_T4_62], 4, 1, 1, 1 }, /* 62 */
+ {triangles_4t[WIPE_T4_62], 4, 1, 1, 1}, /* 62 */
#define WIPE_CONFIG_63 WIPE_CONFIG_62+1
- { triangles_4t[WIPE_T4_63], 4, 1, 1, 1 }, /* 63 */
+ {triangles_4t[WIPE_T4_63], 4, 1, 1, 1}, /* 63 */
#define WIPE_CONFIG_64 WIPE_CONFIG_63+1
- { triangles_4t[WIPE_T4_64], 4, 1, 1, 1 }, /* 64 */
+ {triangles_4t[WIPE_T4_64], 4, 1, 1, 1}, /* 64 */
#define WIPE_CONFIG_65 WIPE_CONFIG_64+1
- { triangles_4t[WIPE_T4_65], 4, 1, 1, 0 }, /* 65 */
+ {triangles_4t[WIPE_T4_65], 4, 1, 1, 0}, /* 65 */
#define WIPE_CONFIG_66 WIPE_CONFIG_65+1
- { triangles_4t[WIPE_T4_66], 4, 1, 1, 0 }, /* 66 */
+ {triangles_4t[WIPE_T4_66], 4, 1, 1, 0}, /* 66 */
#define WIPE_CONFIG_67 WIPE_CONFIG_66+1
- { triangles_4t[WIPE_T4_67], 4, 1, 1, 0 }, /* 67 */
+ {triangles_4t[WIPE_T4_67], 4, 1, 1, 0}, /* 67 */
#define WIPE_CONFIG_68 WIPE_CONFIG_67+1
- { triangles_4t[WIPE_T4_68], 4, 1, 1, 0 }, /* 68 */
+ {triangles_4t[WIPE_T4_68], 4, 1, 1, 0}, /* 68 */
#define WIPE_CONFIG_101 WIPE_CONFIG_68+1
- { triangles_4t[WIPE_T4_101], 4, 1, 1, 0 }, /* 101 */
+ {triangles_4t[WIPE_T4_101], 4, 1, 1, 0}, /* 101 */
#define WIPE_CONFIG_201 WIPE_CONFIG_101+1
- { box_clock_4b[WIPE_B4_201], 4, 1, 1, 2 }, /* 201 */
+ {box_clock_4b[WIPE_B4_201], 4, 1, 1, 2}, /* 201 */
#define WIPE_CONFIG_202 WIPE_CONFIG_201+1
- { box_clock_4b[WIPE_B4_202], 4, 1, 1, 2 }, /* 202 */
+ {box_clock_4b[WIPE_B4_202], 4, 1, 1, 2}, /* 202 */
#define WIPE_CONFIG_203 WIPE_CONFIG_202+1
- { box_clock_4b[WIPE_B4_203], 4, 1, 1, 2 }, /* 203 */
+ {box_clock_4b[WIPE_B4_203], 4, 1, 1, 2}, /* 203 */
#define WIPE_CONFIG_204 WIPE_CONFIG_203+1
- { box_clock_4b[WIPE_B4_204], 4, 1, 1, 2 }, /* 204 */
+ {box_clock_4b[WIPE_B4_204], 4, 1, 1, 2}, /* 204 */
#define WIPE_CONFIG_205 WIPE_CONFIG_204+1
- { box_clock_4b[WIPE_B4_205], 4, 1, 1, 1 }, /* 205 */
+ {box_clock_4b[WIPE_B4_205], 4, 1, 1, 1}, /* 205 */
#define WIPE_CONFIG_206 WIPE_CONFIG_205+1
- { box_clock_4b[WIPE_B4_206], 4, 1, 1, 1 }, /* 206 */
+ {box_clock_4b[WIPE_B4_206], 4, 1, 1, 1}, /* 206 */
#define WIPE_CONFIG_207 WIPE_CONFIG_206+1
- { box_clock_4b[WIPE_B4_207], 4, 1, 1, 0 }, /* 207 */
+ {box_clock_4b[WIPE_B4_207], 4, 1, 1, 0}, /* 207 */
#define WIPE_CONFIG_211 WIPE_CONFIG_207+1
- { box_clock_4b[WIPE_B4_211], 4, 1, 1, 1 }, /* 211 */
+ {box_clock_4b[WIPE_B4_211], 4, 1, 1, 1}, /* 211 */
#define WIPE_CONFIG_212 WIPE_CONFIG_211+1
- { box_clock_4b[WIPE_B4_212], 4, 1, 1, 1 }, /* 212 */
+ {box_clock_4b[WIPE_B4_212], 4, 1, 1, 1}, /* 212 */
#define WIPE_CONFIG_213 WIPE_CONFIG_212+1
- { box_clock_4b[WIPE_B4_213], 4, 1, 1, 0 }, /* 213 */
+ {box_clock_4b[WIPE_B4_213], 4, 1, 1, 0}, /* 213 */
#define WIPE_CONFIG_214 WIPE_CONFIG_213+1
- { box_clock_4b[WIPE_B4_214], 4, 1, 1, 0 }, /* 214 */
+ {box_clock_4b[WIPE_B4_214], 4, 1, 1, 0}, /* 214 */
#define WIPE_CONFIG_221 WIPE_CONFIG_214+1
- { box_clock_2b[WIPE_B2_221], 2, 1, 1, 1 }, /* 221 */
+ {box_clock_2b[WIPE_B2_221], 2, 1, 1, 1}, /* 221 */
#define WIPE_CONFIG_222 WIPE_CONFIG_221+1
- { box_clock_2b[WIPE_B2_222], 2, 1, 1, 1 }, /* 222 */
+ {box_clock_2b[WIPE_B2_222], 2, 1, 1, 1}, /* 222 */
#define WIPE_CONFIG_223 WIPE_CONFIG_222+1
- { box_clock_2b[WIPE_B2_223], 2, 1, 1, 1 }, /* 223 */
+ {box_clock_2b[WIPE_B2_223], 2, 1, 1, 1}, /* 223 */
#define WIPE_CONFIG_224 WIPE_CONFIG_223+1
- { box_clock_2b[WIPE_B2_224], 2, 1, 1, 1 }, /* 224 */
+ {box_clock_2b[WIPE_B2_224], 2, 1, 1, 1}, /* 224 */
#define WIPE_CONFIG_225 WIPE_CONFIG_224+1
- { box_clock_2b[WIPE_B2_225], 2, 1, 1, 0 }, /* 225 */
+ {box_clock_2b[WIPE_B2_225], 2, 1, 1, 0}, /* 225 */
#define WIPE_CONFIG_226 WIPE_CONFIG_225+1
- { box_clock_2b[WIPE_B2_226], 2, 1, 1, 0 }, /* 226 */
+ {box_clock_2b[WIPE_B2_226], 2, 1, 1, 0}, /* 226 */
#define WIPE_CONFIG_227 WIPE_CONFIG_226+1
- { box_clock_4b[WIPE_B4_227], 4, 1, 1, 1 }, /* 227 */
+ {box_clock_4b[WIPE_B4_227], 4, 1, 1, 1}, /* 227 */
#define WIPE_CONFIG_228 WIPE_CONFIG_227+1
- { box_clock_4b[WIPE_B4_228], 4, 1, 1, 1 }, /* 228 */
+ {box_clock_4b[WIPE_B4_228], 4, 1, 1, 1}, /* 228 */
#define WIPE_CONFIG_231 WIPE_CONFIG_228+1
- { box_clock_2b[WIPE_B2_231], 2, 1, 1, 0 }, /* 231 */
+ {box_clock_2b[WIPE_B2_231], 2, 1, 1, 0}, /* 231 */
#define WIPE_CONFIG_232 WIPE_CONFIG_231+1
- { box_clock_2b[WIPE_B2_232], 2, 1, 1, 0 }, /* 232 */
+ {box_clock_2b[WIPE_B2_232], 2, 1, 1, 0}, /* 232 */
#define WIPE_CONFIG_233 WIPE_CONFIG_232+1
- { box_clock_2b[WIPE_B2_233], 2, 1, 1, 0 }, /* 233 */
+ {box_clock_2b[WIPE_B2_233], 2, 1, 1, 0}, /* 233 */
#define WIPE_CONFIG_234 WIPE_CONFIG_233+1
- { box_clock_2b[WIPE_B2_234], 2, 1, 1, 0 }, /* 234 */
+ {box_clock_2b[WIPE_B2_234], 2, 1, 1, 0}, /* 234 */
#define WIPE_CONFIG_235 WIPE_CONFIG_234+1
- { box_clock_4b[WIPE_B4_235], 4, 1, 1, 0 }, /* 235 */
+ {box_clock_4b[WIPE_B4_235], 4, 1, 1, 0}, /* 235 */
#define WIPE_CONFIG_236 WIPE_CONFIG_235+1
- { box_clock_4b[WIPE_B4_236], 4, 1, 1, 0 }, /* 236 */
+ {box_clock_4b[WIPE_B4_236], 4, 1, 1, 0}, /* 236 */
#define WIPE_CONFIG_241 WIPE_CONFIG_236+1
- { box_clock_1b[WIPE_B1_241], 1, 0, 0, 0 }, /* 241 */
+ {box_clock_1b[WIPE_B1_241], 1, 0, 0, 0}, /* 241 */
#define WIPE_CONFIG_242 WIPE_CONFIG_241+1
- { box_clock_1b[WIPE_B1_242], 1, 0, 0, 0 }, /* 242 */
+ {box_clock_1b[WIPE_B1_242], 1, 0, 0, 0}, /* 242 */
#define WIPE_CONFIG_243 WIPE_CONFIG_242+1
- { box_clock_1b[WIPE_B1_243], 1, 0, 0, 0 }, /* 243 */
+ {box_clock_1b[WIPE_B1_243], 1, 0, 0, 0}, /* 243 */
#define WIPE_CONFIG_244 WIPE_CONFIG_243+1
- { box_clock_1b[WIPE_B1_244], 1, 0, 0, 0 }, /* 244 */
+ {box_clock_1b[WIPE_B1_244], 1, 0, 0, 0}, /* 244 */
#define WIPE_CONFIG_245 WIPE_CONFIG_244+1
- { triangles_2t[WIPE_T2_245], 2, 1, 1, 0 }, /* 245 */
+ {triangles_2t[WIPE_T2_245], 2, 1, 1, 0}, /* 245 */
#define WIPE_CONFIG_246 WIPE_CONFIG_245+1
- { triangles_2t[WIPE_T2_246], 2, 1, 1, 0 }, /* 246 */
+ {triangles_2t[WIPE_T2_246], 2, 1, 1, 0}, /* 246 */
#define WIPE_CONFIG_251 WIPE_CONFIG_246+1
- { box_clock_2b[WIPE_B2_251], 2, 1, 1, 0 }, /* 251 */
+ {box_clock_2b[WIPE_B2_251], 2, 1, 1, 0}, /* 251 */
#define WIPE_CONFIG_252 WIPE_CONFIG_251+1
- { box_clock_2b[WIPE_B2_252], 2, 1, 1, 0 }, /* 252 */
+ {box_clock_2b[WIPE_B2_252], 2, 1, 1, 0}, /* 252 */
#define WIPE_CONFIG_253 WIPE_CONFIG_252+1
- { box_clock_2b[WIPE_B2_253], 2, 1, 1, 0 }, /* 253 */
+ {box_clock_2b[WIPE_B2_253], 2, 1, 1, 0}, /* 253 */
#define WIPE_CONFIG_254 WIPE_CONFIG_253+1
- { box_clock_2b[WIPE_B2_254], 2, 1, 1, 0 }, /* 254 */
+ {box_clock_2b[WIPE_B2_254], 2, 1, 1, 0}, /* 254 */
#define WIPE_CONFIG_261 WIPE_CONFIG_254+1
- { box_clock_8b[WIPE_B8_261], 8, 2, 2, 2 }, /* 261 */
+ {box_clock_8b[WIPE_B8_261], 8, 2, 2, 2}, /* 261 */
#define WIPE_CONFIG_262 WIPE_CONFIG_261+1
- { box_clock_8b[WIPE_B8_262], 8, 2, 2, 2 }, /* 262 */
+ {box_clock_8b[WIPE_B8_262], 8, 2, 2, 2}, /* 262 */
#define WIPE_CONFIG_263 WIPE_CONFIG_262+1
- { box_clock_8b[WIPE_B8_263], 8, 2, 2, 1 }, /* 263 */
+ {box_clock_8b[WIPE_B8_263], 8, 2, 2, 1}, /* 263 */
#define WIPE_CONFIG_264 WIPE_CONFIG_263+1
- { box_clock_8b[WIPE_B8_264], 8, 2, 2, 1 }, /* 264 */
+ {box_clock_8b[WIPE_B8_264], 8, 2, 2, 1}, /* 264 */
};
static void
-gst_wipe_boxes_draw (GstMask *mask)
+gst_wipe_boxes_draw (GstMask * mask)
{
GstWipeConfig *config = mask->user_data;
gint *impacts = config->objects;
for (i = 0; i < config->nobjects; i++) {
switch (impacts[0]) {
case BOX_VERTICAL:
- gst_smpte_paint_vbox (mask->data, mask->width,
- impacts[1] * width, impacts[2] * height, impacts[3] * depth,
- impacts[4] * width, impacts[5] * height, impacts[6] * depth);
+ gst_smpte_paint_vbox (mask->data, mask->width,
+ impacts[1] * width, impacts[2] * height, impacts[3] * depth,
+ impacts[4] * width, impacts[5] * height, impacts[6] * depth);
impacts += 7;
- break;
+ break;
case BOX_HORIZONTAL:
- gst_smpte_paint_hbox (mask->data, mask->width,
- impacts[1] * width, impacts[2] * height, impacts[3] * depth,
- impacts[4] * width, impacts[5] * height, impacts[6] * depth);
+ gst_smpte_paint_hbox (mask->data, mask->width,
+ impacts[1] * width, impacts[2] * height, impacts[3] * depth,
+ impacts[4] * width, impacts[5] * height, impacts[6] * depth);
impacts += 7;
case BOX_CLOCK:
- gst_smpte_paint_box_clock (mask->data, mask->width,
- impacts[1] * width, impacts[2] * height, impacts[3] * depth,
- impacts[4] * width, impacts[5] * height, impacts[6] * depth,
- impacts[7] * width, impacts[8] * height, impacts[9] * depth);
+ gst_smpte_paint_box_clock (mask->data, mask->width,
+ impacts[1] * width, impacts[2] * height, impacts[3] * depth,
+ impacts[4] * width, impacts[5] * height, impacts[6] * depth,
+ impacts[7] * width, impacts[8] * height, impacts[9] * depth);
impacts += 10;
default:
- break;
+ break;
}
}
}
static void
-gst_wipe_triangles_clock_draw (GstMask *mask)
+gst_wipe_triangles_clock_draw (GstMask * mask)
{
GstWipeConfig *config = mask->user_data;
gint *impacts = config->objects;
for (i = 0; i < config->nobjects; i++) {
gst_smpte_paint_triangle_clock (mask->data, mask->width,
- impacts[0] * width, impacts[1] * height, impacts[2] * depth,
- impacts[3] * width, impacts[4] * height, impacts[5] * depth,
- impacts[6] * width, impacts[7] * height, impacts[8] * depth);
+ impacts[0] * width, impacts[1] * height, impacts[2] * depth,
+ impacts[3] * width, impacts[4] * height, impacts[5] * depth,
+ impacts[6] * width, impacts[7] * height, impacts[8] * depth);
impacts += 9;
}
}
static void
-gst_wipe_triangles_draw (GstMask *mask)
+gst_wipe_triangles_draw (GstMask * mask)
{
GstWipeConfig *config = mask->user_data;
gint *impacts = config->objects;
for (i = 0; i < config->nobjects; i++) {
gst_smpte_paint_triangle_linear (mask->data, mask->width,
- impacts[0] * width, impacts[1] * height, impacts[2] * depth,
- impacts[3] * width, impacts[4] * height, impacts[5] * depth,
- impacts[6] * width, impacts[7] * height, impacts[8] * depth);
+ impacts[0] * width, impacts[1] * height, impacts[2] * depth,
+ impacts[3] * width, impacts[4] * height, impacts[5] * depth,
+ impacts[6] * width, impacts[7] * height, impacts[8] * depth);
impacts += 9;
}
}
-static GstMaskDefinition definitions[] = {
- { 1, "bar_wipe_lr",
- "A bar moves from left to right",
- gst_wipe_boxes_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_1] },
- { 2, "bar_wipe_tb",
- "A bar moves from top to bottom",
- gst_wipe_boxes_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_2] },
- { 3, "box_wipe_tl",
- "A box expands from the upper-left corner to the lower-right corner",
- gst_wipe_triangles_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_3] },
- { 4, "box_wipe_tr",
- "A box expands from the upper-right corner to the lower-left corner",
- gst_wipe_triangles_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_4] },
- { 5, "box_wipe_br",
- "A box expands from the lower-right corner to the upper-left corner",
- gst_wipe_triangles_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_5] },
- { 6, "box_wipe_bl",
- "A box expands from the lower-left corner to the upper-right corner",
+static GstMaskDefinition definitions[] = {
+ {1, "bar_wipe_lr",
+ "A bar moves from left to right",
+ gst_wipe_boxes_draw, _gst_mask_default_destroy,
+ &wipe_config[WIPE_CONFIG_1]},
+ {2, "bar_wipe_tb",
+ "A bar moves from top to bottom",
+ gst_wipe_boxes_draw, _gst_mask_default_destroy,
+ &wipe_config[WIPE_CONFIG_2]},
+ {3, "box_wipe_tl",
+ "A box expands from the upper-left corner to the lower-right corner",
+ gst_wipe_triangles_draw, _gst_mask_default_destroy,
+ &wipe_config[WIPE_CONFIG_3]},
+ {4, "box_wipe_tr",
+ "A box expands from the upper-right corner to the lower-left corner",
gst_wipe_triangles_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_6] },
- { 7 , "four_box_wipe_ci",
- "A box shape expands from each of the four corners toward the center",
+ &wipe_config[WIPE_CONFIG_4]},
+ {5, "box_wipe_br",
+ "A box expands from the lower-right corner to the upper-left corner",
gst_wipe_triangles_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_7] },
- { 8 , "four_box_wipe_co",
- "A box shape expands from the center of each quadrant toward the corners of each quadrant",
+ &wipe_config[WIPE_CONFIG_5]},
+ {6, "box_wipe_bl",
+ "A box expands from the lower-left corner to the upper-right corner",
gst_wipe_triangles_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_8] },
- { 21, "barndoor_v",
- "A central, vertical line splits and expands toward the left and right edges",
- gst_wipe_boxes_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_21] },
- { 22, "barndoor_h",
- "A central, horizontal line splits and expands toward the top and bottom edges",
- gst_wipe_boxes_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_22] },
- { 23, "box_wipe_tc",
- "A box expands from the top edge's midpoint to the bottom corners",
+ &wipe_config[WIPE_CONFIG_6]},
+ {7, "four_box_wipe_ci",
+ "A box shape expands from each of the four corners toward the center",
gst_wipe_triangles_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_23] },
- { 24, "box_wipe_rc",
- "A box expands from the right edge's midpoint to the left corners",
+ &wipe_config[WIPE_CONFIG_7]},
+ {8, "four_box_wipe_co",
+ "A box shape expands from the center of each quadrant toward the corners of each quadrant",
gst_wipe_triangles_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_24] },
- { 25, "box_wipe_bc",
- "A box expands from the bottom edge's midpoint to the top corners",
+ &wipe_config[WIPE_CONFIG_8]},
+ {21, "barndoor_v",
+ "A central, vertical line splits and expands toward the left and right edges",
+ gst_wipe_boxes_draw, _gst_mask_default_destroy,
+ &wipe_config[WIPE_CONFIG_21]},
+ {22, "barndoor_h",
+ "A central, horizontal line splits and expands toward the top and bottom edges",
+ gst_wipe_boxes_draw, _gst_mask_default_destroy,
+ &wipe_config[WIPE_CONFIG_22]},
+ {23, "box_wipe_tc",
+ "A box expands from the top edge's midpoint to the bottom corners",
+ gst_wipe_triangles_draw, _gst_mask_default_destroy,
+ &wipe_config[WIPE_CONFIG_23]},
+ {24, "box_wipe_rc",
+ "A box expands from the right edge's midpoint to the left corners",
gst_wipe_triangles_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_25] },
- { 26, "box_wipe_lc",
- "A box expands from the left edge's midpoint to the right corners",
+ &wipe_config[WIPE_CONFIG_24]},
+ {25, "box_wipe_bc",
+ "A box expands from the bottom edge's midpoint to the top corners",
gst_wipe_triangles_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_26] },
- { 41, "diagonal_tl",
- "A diagonal line moves from the upper-left corner to the lower-right corner",
+ &wipe_config[WIPE_CONFIG_25]},
+ {26, "box_wipe_lc",
+ "A box expands from the left edge's midpoint to the right corners",
gst_wipe_triangles_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_41] },
- { 42, "diagonal_tr",
- "A diagonal line moves from the upper right corner to the lower-left corner",
+ &wipe_config[WIPE_CONFIG_26]},
+ {41, "diagonal_tl",
+ "A diagonal line moves from the upper-left corner to the lower-right corner",
gst_wipe_triangles_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_42] },
- { 43, "bowtie_v",
- "Two wedge shapes slide in from the top and bottom edges toward the center",
+ &wipe_config[WIPE_CONFIG_41]},
+ {42, "diagonal_tr",
+ "A diagonal line moves from the upper right corner to the lower-left corner",
gst_wipe_triangles_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_43] },
- { 44, "bowtie_h",
- "Two wedge shapes slide in from the left and right edges toward the center",
+ &wipe_config[WIPE_CONFIG_42]},
+ {43, "bowtie_v",
+ "Two wedge shapes slide in from the top and bottom edges toward the center",
gst_wipe_triangles_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_44] },
- { 45, "barndoor_dbl",
- "A diagonal line from the lower-left to upper-right corners splits and expands toward the opposite corners",
+ &wipe_config[WIPE_CONFIG_43]},
+ {44, "bowtie_h",
+ "Two wedge shapes slide in from the left and right edges toward the center",
gst_wipe_triangles_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_45] },
- { 46, "barndoor_dtl",
- "A diagonal line from upper-left to lower-right corners splits and expands toward the opposite corners",
+ &wipe_config[WIPE_CONFIG_44]},
+ {45, "barndoor_dbl",
+ "A diagonal line from the lower-left to upper-right corners splits and expands toward the opposite corners",
gst_wipe_triangles_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_46] },
- { 47, "misc_diagonal_dbd",
- "Four wedge shapes split from the center and retract toward the four edges",
+ &wipe_config[WIPE_CONFIG_45]},
+ {46, "barndoor_dtl",
+ "A diagonal line from upper-left to lower-right corners splits and expands toward the opposite corners",
gst_wipe_triangles_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_47] },
- { 48, "misc_diagonal_dd",
- "A diamond connecting the four edge midpoints simultaneously contracts toward the center and expands toward the edges",
+ &wipe_config[WIPE_CONFIG_46]},
+ {47, "misc_diagonal_dbd",
+ "Four wedge shapes split from the center and retract toward the four edges",
gst_wipe_triangles_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_48] },
- { 61, "vee_d",
- "A wedge shape moves from top to bottom",
+ &wipe_config[WIPE_CONFIG_47]},
+ {48, "misc_diagonal_dd",
+ "A diamond connecting the four edge midpoints simultaneously contracts toward the center and expands toward the edges",
gst_wipe_triangles_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_61] },
- { 62, "vee_l",
- "A wedge shape moves from right to left",
+ &wipe_config[WIPE_CONFIG_48]},
+ {61, "vee_d",
+ "A wedge shape moves from top to bottom",
gst_wipe_triangles_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_62] },
- { 63, "vee_u",
- "A wedge shape moves from bottom to top",
+ &wipe_config[WIPE_CONFIG_61]},
+ {62, "vee_l",
+ "A wedge shape moves from right to left",
gst_wipe_triangles_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_63] },
- { 64, "vee_r",
- "A wedge shape moves from left to right",
+ &wipe_config[WIPE_CONFIG_62]},
+ {63, "vee_u",
+ "A wedge shape moves from bottom to top",
gst_wipe_triangles_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_64] },
- { 65, "barnvee_d",
- "A 'V' shape extending from the bottom edge's midpoint to the opposite corners contracts toward the center and expands toward the edges",
+ &wipe_config[WIPE_CONFIG_63]},
+ {64, "vee_r",
+ "A wedge shape moves from left to right",
gst_wipe_triangles_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_65] },
- { 66, "barnvee_l",
- "A 'V' shape extending from the left edge's midpoint to the opposite corners contracts toward the center and expands toward the edges",
+ &wipe_config[WIPE_CONFIG_64]},
+ {65, "barnvee_d",
+ "A 'V' shape extending from the bottom edge's midpoint to the opposite corners contracts toward the center and expands toward the edges",
gst_wipe_triangles_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_66] },
- { 67, "barnvee_u",
- "A 'V' shape extending from the top edge's midpoint to the opposite corners contracts toward the center and expands toward the edges",
+ &wipe_config[WIPE_CONFIG_65]},
+ {66, "barnvee_l",
+ "A 'V' shape extending from the left edge's midpoint to the opposite corners contracts toward the center and expands toward the edges",
gst_wipe_triangles_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_67] },
- { 68, "barnvee_r",
- "A 'V' shape extending from the right edge's midpoint to the opposite corners contracts toward the center and expands toward the edges",
+ &wipe_config[WIPE_CONFIG_66]},
+ {67, "barnvee_u",
+ "A 'V' shape extending from the top edge's midpoint to the opposite corners contracts toward the center and expands toward the edges",
gst_wipe_triangles_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_68] },
- { 101, "iris_rect",
- "A rectangle expands from the center.",
+ &wipe_config[WIPE_CONFIG_67]},
+ {68, "barnvee_r",
+ "A 'V' shape extending from the right edge's midpoint to the opposite corners contracts toward the center and expands toward the edges",
gst_wipe_triangles_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_101] },
- { 201, "clock_cw12",
- "A radial hand sweeps clockwise from the twelve o'clock position",
+ &wipe_config[WIPE_CONFIG_68]},
+ {101, "iris_rect",
+ "A rectangle expands from the center.",
+ gst_wipe_triangles_draw, _gst_mask_default_destroy,
+ &wipe_config[WIPE_CONFIG_101]},
+ {201, "clock_cw12",
+ "A radial hand sweeps clockwise from the twelve o'clock position",
gst_wipe_boxes_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_201] },
- { 202, "clock_cw3",
- "A radial hand sweeps clockwise from the three o'clock position",
+ &wipe_config[WIPE_CONFIG_201]},
+ {202, "clock_cw3",
+ "A radial hand sweeps clockwise from the three o'clock position",
gst_wipe_boxes_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_202] },
- { 203, "clock_cw6",
- "A radial hand sweeps clockwise from the six o'clock position",
+ &wipe_config[WIPE_CONFIG_202]},
+ {203, "clock_cw6",
+ "A radial hand sweeps clockwise from the six o'clock position",
gst_wipe_boxes_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_203] },
- { 204, "clock_cw9",
- "A radial hand sweeps clockwise from the nine o'clock position",
+ &wipe_config[WIPE_CONFIG_203]},
+ {204, "clock_cw9",
+ "A radial hand sweeps clockwise from the nine o'clock position",
gst_wipe_boxes_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_204] },
- { 205, "pinwheel_tbv",
- "Two radial hands sweep clockwise from the twelve and six o'clock positions",
+ &wipe_config[WIPE_CONFIG_204]},
+ {205, "pinwheel_tbv",
+ "Two radial hands sweep clockwise from the twelve and six o'clock positions",
gst_wipe_boxes_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_205] },
- { 206, "pinwheel_tbh",
- "Two radial hands sweep clockwise from the nine and three o'clock positions",
+ &wipe_config[WIPE_CONFIG_205]},
+ {206, "pinwheel_tbh",
+ "Two radial hands sweep clockwise from the nine and three o'clock positions",
gst_wipe_boxes_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_206] },
- { 207, "pinwheel_fb",
- "Four radial hands sweep clockwise",
+ &wipe_config[WIPE_CONFIG_206]},
+ {207, "pinwheel_fb",
+ "Four radial hands sweep clockwise",
gst_wipe_boxes_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_207] },
- { 211, "fan_ct",
- "A fan unfolds from the top edge, the fan axis at the center",
+ &wipe_config[WIPE_CONFIG_207]},
+ {211, "fan_ct",
+ "A fan unfolds from the top edge, the fan axis at the center",
gst_wipe_boxes_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_211] },
- { 212, "fan_cr",
- "A fan unfolds from the right edge, the fan axis at the center",
+ &wipe_config[WIPE_CONFIG_211]},
+ {212, "fan_cr",
+ "A fan unfolds from the right edge, the fan axis at the center",
gst_wipe_boxes_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_212] },
- { 213, "doublefan_fov",
- "Two fans, their axes at the center, unfold from the top and bottom",
+ &wipe_config[WIPE_CONFIG_212]},
+ {213, "doublefan_fov",
+ "Two fans, their axes at the center, unfold from the top and bottom",
gst_wipe_boxes_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_213] },
- { 214, "doublefan_foh",
- "Two fans, their axes at the center, unfold from the left and right",
+ &wipe_config[WIPE_CONFIG_213]},
+ {214, "doublefan_foh",
+ "Two fans, their axes at the center, unfold from the left and right",
gst_wipe_boxes_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_214] },
- { 221, "singlesweep_cwt",
- "A radial hand sweeps clockwise from the top edge's midpoint",
+ &wipe_config[WIPE_CONFIG_214]},
+ {221, "singlesweep_cwt",
+ "A radial hand sweeps clockwise from the top edge's midpoint",
gst_wipe_boxes_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_221] },
- { 222, "singlesweep_cwr",
- "A radial hand sweeps clockwise from the right edge's midpoint",
+ &wipe_config[WIPE_CONFIG_221]},
+ {222, "singlesweep_cwr",
+ "A radial hand sweeps clockwise from the right edge's midpoint",
gst_wipe_boxes_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_222] },
- { 223, "singlesweep_cwb",
- "A radial hand sweeps clockwise from the bottom edge's midpoint",
+ &wipe_config[WIPE_CONFIG_222]},
+ {223, "singlesweep_cwb",
+ "A radial hand sweeps clockwise from the bottom edge's midpoint",
gst_wipe_boxes_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_223] },
- { 224, "singlesweep_cwl",
- "A radial hand sweeps clockwise from the left edge's midpoint",
+ &wipe_config[WIPE_CONFIG_223]},
+ {224, "singlesweep_cwl",
+ "A radial hand sweeps clockwise from the left edge's midpoint",
gst_wipe_boxes_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_224] },
- { 225, "doublesweep_pv",
- "Two radial hands sweep clockwise and counter-clockwise from the top and bottom edges' midpoints",
+ &wipe_config[WIPE_CONFIG_224]},
+ {225, "doublesweep_pv",
+ "Two radial hands sweep clockwise and counter-clockwise from the top and bottom edges' midpoints",
gst_wipe_boxes_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_225] },
- { 226, "doublesweep_pd",
- "Two radial hands sweep clockwise and counter-clockwise from the left and right edges' midpoints",
+ &wipe_config[WIPE_CONFIG_225]},
+ {226, "doublesweep_pd",
+ "Two radial hands sweep clockwise and counter-clockwise from the left and right edges' midpoints",
gst_wipe_boxes_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_226] },
- { 227, "doublesweep_ov",
- "Two radial hands attached at the top and bottom edges' midpoints sweep from right to left",
+ &wipe_config[WIPE_CONFIG_226]},
+ {227, "doublesweep_ov",
+ "Two radial hands attached at the top and bottom edges' midpoints sweep from right to left",
gst_wipe_boxes_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_227] },
- { 228, "doublesweep_oh",
- "Two radial hands attached at the left and right edges' midpoints sweep from top to bottom",
+ &wipe_config[WIPE_CONFIG_227]},
+ {228, "doublesweep_oh",
+ "Two radial hands attached at the left and right edges' midpoints sweep from top to bottom",
gst_wipe_boxes_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_228] },
- { 231, "fan_t",
- "A fan unfolds from the bottom, the fan axis at the top edge's midpoint",
+ &wipe_config[WIPE_CONFIG_228]},
+ {231, "fan_t",
+ "A fan unfolds from the bottom, the fan axis at the top edge's midpoint",
gst_wipe_boxes_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_231] },
- { 232, "fan_r",
- "A fan unfolds from the left, the fan axis at the right edge's midpoint",
+ &wipe_config[WIPE_CONFIG_231]},
+ {232, "fan_r",
+ "A fan unfolds from the left, the fan axis at the right edge's midpoint",
gst_wipe_boxes_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_232] },
- { 233, "fan_b",
- "A fan unfolds from the top, the fan axis at the bottom edge's midpoint",
+ &wipe_config[WIPE_CONFIG_232]},
+ {233, "fan_b",
+ "A fan unfolds from the top, the fan axis at the bottom edge's midpoint",
gst_wipe_boxes_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_233] },
- { 234, "fan_l",
- "A fan unfolds from the right, the fan axis at the left edge's midpoint",
+ &wipe_config[WIPE_CONFIG_233]},
+ {234, "fan_l",
+ "A fan unfolds from the right, the fan axis at the left edge's midpoint",
gst_wipe_boxes_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_234] },
- { 235, "doublefan_fiv",
- "Two fans, their axes at the top and bottom, unfold from the center",
+ &wipe_config[WIPE_CONFIG_234]},
+ {235, "doublefan_fiv",
+ "Two fans, their axes at the top and bottom, unfold from the center",
gst_wipe_boxes_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_235] },
- { 236, "doublefan_fih",
- "Two fans, their axes at the left and right, unfold from the center",
+ &wipe_config[WIPE_CONFIG_235]},
+ {236, "doublefan_fih",
+ "Two fans, their axes at the left and right, unfold from the center",
gst_wipe_boxes_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_236] },
- { 241, "singlesweep_cwtl",
- "A radial hand sweeps clockwise from the upper-left corner",
+ &wipe_config[WIPE_CONFIG_236]},
+ {241, "singlesweep_cwtl",
+ "A radial hand sweeps clockwise from the upper-left corner",
gst_wipe_boxes_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_241] },
- { 242, "singlesweep_cwbl",
- "A radial hand sweeps counter-clockwise from the lower-left corner.",
+ &wipe_config[WIPE_CONFIG_241]},
+ {242, "singlesweep_cwbl",
+ "A radial hand sweeps counter-clockwise from the lower-left corner.",
gst_wipe_boxes_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_242] },
- { 243, "singlesweep_cwbr",
- "A radial hand sweeps clockwise from the lower-right corner",
+ &wipe_config[WIPE_CONFIG_242]},
+ {243, "singlesweep_cwbr",
+ "A radial hand sweeps clockwise from the lower-right corner",
gst_wipe_boxes_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_243] },
- { 244, "singlesweep_cwtr",
- "A radial hand sweeps counter-clockwise from the upper-right corner",
+ &wipe_config[WIPE_CONFIG_243]},
+ {244, "singlesweep_cwtr",
+ "A radial hand sweeps counter-clockwise from the upper-right corner",
gst_wipe_boxes_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_244] },
- { 245, "doublesweep_pdtl",
- "Two radial hands attached at the upper-left and lower-right corners sweep down and up",
+ &wipe_config[WIPE_CONFIG_244]},
+ {245, "doublesweep_pdtl",
+ "Two radial hands attached at the upper-left and lower-right corners sweep down and up",
gst_wipe_triangles_clock_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_245] },
- { 246, "doublesweep_pdbl",
- "Two radial hands attached at the lower-left and upper-right corners sweep down and up",
+ &wipe_config[WIPE_CONFIG_245]},
+ {246, "doublesweep_pdbl",
+ "Two radial hands attached at the lower-left and upper-right corners sweep down and up",
gst_wipe_triangles_clock_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_246] },
- { 251, "saloondoor_t",
- "Two radial hands attached at the upper-left and upper-right corners sweep down",
+ &wipe_config[WIPE_CONFIG_246]},
+ {251, "saloondoor_t",
+ "Two radial hands attached at the upper-left and upper-right corners sweep down",
gst_wipe_boxes_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_251] },
- { 252, "saloondoor_l",
- "Two radial hands attached at the upper-left and lower-left corners sweep to the right",
+ &wipe_config[WIPE_CONFIG_251]},
+ {252, "saloondoor_l",
+ "Two radial hands attached at the upper-left and lower-left corners sweep to the right",
gst_wipe_boxes_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_252] },
- { 253, "saloondoor_b",
- "Two radial hands attached at the lower-left and lower-right corners sweep up",
+ &wipe_config[WIPE_CONFIG_252]},
+ {253, "saloondoor_b",
+ "Two radial hands attached at the lower-left and lower-right corners sweep up",
gst_wipe_boxes_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_253] },
- { 254, "saloondoor_r",
- "Two radial hands attached at the upper-right and lower-right corners sweep to the left",
+ &wipe_config[WIPE_CONFIG_253]},
+ {254, "saloondoor_r",
+ "Two radial hands attached at the upper-right and lower-right corners sweep to the left",
gst_wipe_boxes_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_254] },
- { 261, "windshield_r",
- "Two radial hands attached at the midpoints of the top and bottom halves sweep from right to left",
+ &wipe_config[WIPE_CONFIG_254]},
+ {261, "windshield_r",
+ "Two radial hands attached at the midpoints of the top and bottom halves sweep from right to left",
gst_wipe_boxes_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_261] },
- { 262, "windshield_u",
- "Two radial hands attached at the midpoints of the left and right halves sweep from top to bottom",
+ &wipe_config[WIPE_CONFIG_261]},
+ {262, "windshield_u",
+ "Two radial hands attached at the midpoints of the left and right halves sweep from top to bottom",
gst_wipe_boxes_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_262] },
- { 263, "windshield_v",
- "Two sets of radial hands attached at the midpoints of the top and bottom halves sweep from top to bottom and bottom to top",
+ &wipe_config[WIPE_CONFIG_262]},
+ {263, "windshield_v",
+ "Two sets of radial hands attached at the midpoints of the top and bottom halves sweep from top to bottom and bottom to top",
gst_wipe_boxes_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_263] },
- { 264, "windshield_h",
- "Two sets of radial hands attached at the midpoints of the left and right halves sweep from left to right and right to left",
+ &wipe_config[WIPE_CONFIG_263]},
+ {264, "windshield_h",
+ "Two sets of radial hands attached at the midpoints of the left and right halves sweep from left to right and right to left",
gst_wipe_boxes_draw, _gst_mask_default_destroy,
- &wipe_config[WIPE_CONFIG_264] },
- { 0, NULL, NULL, NULL }
+ &wipe_config[WIPE_CONFIG_264]},
+ {0, NULL, NULL, NULL}
};
void
i++;
}
}
-
}
static gint
-gst_mask_compare (GstMaskDefinition *def1,
- GstMaskDefinition *def2)
+gst_mask_compare (GstMaskDefinition * def1, GstMaskDefinition * def2)
{
return (def1->type - def2->type);
}
void
-_gst_mask_register (GstMaskDefinition *definition)
+_gst_mask_register (GstMaskDefinition * definition)
{
- masks = g_list_insert_sorted (masks, definition, (GCompareFunc) gst_mask_compare);
+ masks =
+ g_list_insert_sorted (masks, definition, (GCompareFunc) gst_mask_compare);
}
-const GList*
+const GList *
gst_mask_get_definitions (void)
{
return masks;
}
-static GstMaskDefinition*
+static GstMaskDefinition *
gst_mask_find_definition (gint type)
{
GList *walk = masks;
if (def->type == type)
return def;
-
+
walk = g_list_next (walk);
}
return NULL;
}
-GstMask*
+GstMask *
gst_mask_factory_new (gint type, gint bpp, gint width, gint height)
{
GstMaskDefinition *definition;
}
void
-_gst_mask_default_destroy (GstMask *mask)
+_gst_mask_default_destroy (GstMask * mask)
{
g_free (mask->data);
g_free (mask);
}
void
-gst_mask_destroy (GstMask *mask)
+gst_mask_destroy (GstMask * mask)
{
if (mask->destroy_func)
mask->destroy_func (mask);
typedef struct _GstMask GstMask;
typedef struct _GstMaskDefinition GstMaskDefinition;
-typedef void (*GstMaskDrawFunc) (GstMask *mask);
-typedef void (*GstMaskDestroyFunc) (GstMask *mask);
-
-struct _GstMaskDefinition {
- gint type;
- gchar *short_name;
- gchar *long_name;
- GstMaskDrawFunc draw_func;
- GstMaskDestroyFunc destroy_func;
- gpointer user_data;
+typedef void (*GstMaskDrawFunc) (GstMask * mask);
+typedef void (*GstMaskDestroyFunc) (GstMask * mask);
+
+struct _GstMaskDefinition
+{
+ gint type;
+ gchar *short_name;
+ gchar *long_name;
+ GstMaskDrawFunc draw_func;
+ GstMaskDestroyFunc destroy_func;
+ gpointer user_data;
};
-struct _GstMask {
- gint type;
- guint32 *data;
- gpointer user_data;
+struct _GstMask
+{
+ gint type;
+ guint32 *data;
+ gpointer user_data;
- gint width;
- gint height;
- gint bpp;
+ gint width;
+ gint height;
+ gint bpp;
- GstMaskDestroyFunc destroy_func;
+ GstMaskDestroyFunc destroy_func;
};
-void _gst_mask_init (void);
-void _gst_mask_register (GstMaskDefinition *definition);
+void _gst_mask_init (void);
+void _gst_mask_register (GstMaskDefinition * definition);
-void _gst_mask_default_destroy (GstMask *mask);
+void _gst_mask_default_destroy (GstMask * mask);
-const GList* gst_mask_get_definitions (void);
-GstMask* gst_mask_factory_new (gint type, gint bpp, gint width, gint height);
-void gst_mask_destroy (GstMask *mask);
+const GList *gst_mask_get_definitions (void);
+GstMask *gst_mask_factory_new (gint type, gint bpp, gint width, gint height);
+void gst_mask_destroy (GstMask * mask);
#endif /* __GST_MASK_H__ */
};
static GstStaticPadTemplate gst_smpte_src_template =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- GST_VIDEO_CAPS_YUV("I420")
- )
-);
+GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420")
+ )
+ );
static GstStaticPadTemplate gst_smpte_sink1_template =
-GST_STATIC_PAD_TEMPLATE (
- "sink1",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- GST_VIDEO_CAPS_YUV("I420")
- )
-);
+GST_STATIC_PAD_TEMPLATE ("sink1",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420")
+ )
+ );
static GstStaticPadTemplate gst_smpte_sink2_template =
-GST_STATIC_PAD_TEMPLATE (
- "sink2",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- GST_VIDEO_CAPS_YUV("I420")
- )
-);
+GST_STATIC_PAD_TEMPLATE ("sink2",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420")
+ )
+ );
/* SMPTE signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_TYPE,
ARG_BORDER,
#define GST_TYPE_SMPTE_TRANSITION_TYPE (gst_smpte_transition_type_get_type())
static GType
-gst_smpte_transition_type_get_type (void)
+gst_smpte_transition_type_get_type (void)
{
static GType smpte_transition_type = 0;
GEnumValue *smpte_transitions;
if (!smpte_transition_type) {
const GList *definitions;
- gint i=0;
+ gint i = 0;
definitions = gst_mask_get_definitions ();
- smpte_transitions = g_new0 (GEnumValue, g_list_length ((GList *)definitions)+1);
+ smpte_transitions =
+ g_new0 (GEnumValue, g_list_length ((GList *) definitions) + 1);
while (definitions) {
GstMaskDefinition *definition = (GstMaskDefinition *) definitions->data;
+
definitions = g_list_next (definitions);
smpte_transitions[i].value = definition->type;
smpte_transitions[i].value_name = definition->short_name;
smpte_transitions[i].value_nick = definition->long_name;
-
+
i++;
}
- smpte_transition_type =
- g_enum_register_static ("GstSMPTETransitionType", smpte_transitions);
+ smpte_transition_type =
+ g_enum_register_static ("GstSMPTETransitionType", smpte_transitions);
}
return smpte_transition_type;
-}
+}
-static void gst_smpte_class_init (GstSMPTEClass *klass);
-static void gst_smpte_base_init (GstSMPTEClass *klass);
-static void gst_smpte_init (GstSMPTE *smpte);
+static void gst_smpte_class_init (GstSMPTEClass * klass);
+static void gst_smpte_base_init (GstSMPTEClass * klass);
+static void gst_smpte_init (GstSMPTE * smpte);
-static void gst_smpte_loop (GstElement *element);
+static void gst_smpte_loop (GstElement * element);
-static void gst_smpte_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_smpte_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static void gst_smpte_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_smpte_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_smpte_signals[LAST_SIGNAL] = { 0 }; */
static GType
if (!smpte_type) {
static const GTypeInfo smpte_info = {
- sizeof(GstSMPTEClass),
- (GBaseInitFunc)gst_smpte_base_init,
+ sizeof (GstSMPTEClass),
+ (GBaseInitFunc) gst_smpte_base_init,
NULL,
- (GClassInitFunc)gst_smpte_class_init,
+ (GClassInitFunc) gst_smpte_class_init,
NULL,
NULL,
- sizeof(GstSMPTE),
+ sizeof (GstSMPTE),
0,
- (GInstanceInitFunc)gst_smpte_init,
+ (GInstanceInitFunc) gst_smpte_init,
};
- smpte_type = g_type_register_static(GST_TYPE_ELEMENT, "GstSMPTE", &smpte_info, 0);
+ smpte_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstSMPTE", &smpte_info, 0);
}
return smpte_type;
}
static void
-gst_smpte_base_init (GstSMPTEClass *klass)
+gst_smpte_base_init (GstSMPTEClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get(&gst_smpte_sink1_template));
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get(&gst_smpte_sink2_template));
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get(&gst_smpte_src_template));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_smpte_sink1_template));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_smpte_sink2_template));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_smpte_src_template));
gst_element_class_set_details (element_class, &smpte_details);
}
static void
-gst_smpte_class_init (GstSMPTEClass *klass)
+gst_smpte_class_init (GstSMPTEClass * 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);
gobject_class->set_property = gst_smpte_set_property;
gobject_class->get_property = gst_smpte_get_property;
_gst_mask_init ();
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TYPE,
- g_param_spec_enum ("type", "Type", "The type of transition to use",
- GST_TYPE_SMPTE_TRANSITION_TYPE, 1, G_PARAM_READWRITE));
+ g_param_spec_enum ("type", "Type", "The type of transition to use",
+ GST_TYPE_SMPTE_TRANSITION_TYPE, 1, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FPS,
- g_param_spec_float ("fps", "FPS", "Frames per second if no input files are given",
- 0., G_MAXFLOAT, 25., G_PARAM_READWRITE));
+ g_param_spec_float ("fps", "FPS",
+ "Frames per second if no input files are given", 0., G_MAXFLOAT, 25.,
+ G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BORDER,
- g_param_spec_int ("border", "Border", "The border width of the transition",
- 0, G_MAXINT, 0, G_PARAM_READWRITE));
+ g_param_spec_int ("border", "Border",
+ "The border width of the transition", 0, G_MAXINT, 0,
+ G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DEPTH,
- g_param_spec_int ("depth", "Depth", "Depth of the mask in bits",
- 1, 24, 16, G_PARAM_READWRITE));
+ g_param_spec_int ("depth", "Depth", "Depth of the mask in bits", 1, 24,
+ 16, G_PARAM_READWRITE));
}
/* wht yel cya grn mag red blu blk -I Q */
-static int y_colors[] = { 255, 226, 179, 150, 105, 76, 29, 16, 16, 0 };
-static int u_colors[] = { 128, 0, 170, 46, 212, 85, 255, 128, 0, 128 };
-static int v_colors[] = { 128, 155, 0, 21, 235, 255, 107, 128, 128, 255 };
+static int y_colors[] = { 255, 226, 179, 150, 105, 76, 29, 16, 16, 0 };
+static int u_colors[] = { 128, 0, 170, 46, 212, 85, 255, 128, 0, 128 };
+static int v_colors[] = { 128, 155, 0, 21, 235, 255, 107, 128, 128, 255 };
static void
-fill_i420 (guint8 *data, gint width, gint height, gint color)
+fill_i420 (guint8 * data, gint width, gint height, gint color)
{
gint size = width * height, size4 = size >> 2;
guint8 *yp = data;
guint8 *up = data + size;
guint8 *vp = data + size + size4;
-
+
memset (yp, y_colors[color], size);
memset (up, u_colors[color], size4);
memset (vp, v_colors[color], size4);
}
static gboolean
-gst_smpte_update_mask (GstSMPTE *smpte, gint type, gint depth, gint width, gint height)
+gst_smpte_update_mask (GstSMPTE * smpte, gint type, gint depth, gint width,
+ gint height)
{
GstMask *newmask;
}
static gboolean
-gst_smpte_sinkconnect (GstPad *pad, const GstCaps *caps)
+gst_smpte_sinkconnect (GstPad * pad, const GstCaps * caps)
{
GstSMPTE *smpte;
GstStructure *structure;
ret = gst_structure_get_int (structure, "width", &smpte->width);
ret &= gst_structure_get_int (structure, "height", &smpte->height);
ret &= gst_structure_get_double (structure, "framerate", &smpte->fps);
- if (!ret) return GST_PAD_LINK_REFUSED;
+ if (!ret)
+ return GST_PAD_LINK_REFUSED;
- gst_smpte_update_mask (smpte, smpte->type, smpte->depth, smpte->width, smpte->height);
+ gst_smpte_update_mask (smpte, smpte->type, smpte->depth, smpte->width,
+ smpte->height);
/* forward to the next plugin */
- return gst_pad_try_set_caps(smpte->srcpad, caps);
+ return gst_pad_try_set_caps (smpte->srcpad, caps);
}
-static void
-gst_smpte_init (GstSMPTE *smpte)
+static void
+gst_smpte_init (GstSMPTE * smpte)
{
- smpte->sinkpad1 = gst_pad_new_from_template (
- gst_static_pad_template_get(&gst_smpte_sink1_template), "sink1");
+ smpte->sinkpad1 =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_smpte_sink1_template), "sink1");
gst_pad_set_link_function (smpte->sinkpad1, gst_smpte_sinkconnect);
gst_element_add_pad (GST_ELEMENT (smpte), smpte->sinkpad1);
- smpte->sinkpad2 = gst_pad_new_from_template (
- gst_static_pad_template_get(&gst_smpte_sink2_template), "sink2");
+ smpte->sinkpad2 =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_smpte_sink2_template), "sink2");
gst_pad_set_link_function (smpte->sinkpad2, gst_smpte_sinkconnect);
gst_element_add_pad (GST_ELEMENT (smpte), smpte->sinkpad2);
- smpte->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get(&gst_smpte_src_template), "src");
+ smpte->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_smpte_src_template), "src");
gst_element_add_pad (GST_ELEMENT (smpte), smpte->srcpad);
gst_element_set_loop_function (GST_ELEMENT (smpte), gst_smpte_loop);
smpte->type = 1;
smpte->border = 0;
smpte->depth = 16;
- gst_smpte_update_mask (smpte, smpte->type, smpte->depth, smpte->width, smpte->height);
+ gst_smpte_update_mask (smpte, smpte->type, smpte->depth, smpte->width,
+ smpte->height);
}
static void
-gst_smpte_blend_i420 (guint8 *in1, guint8 *in2, guint8 *out, GstMask *mask,
- gint width, gint height, gint border, gint pos)
+gst_smpte_blend_i420 (guint8 * in1, guint8 * in2, guint8 * out, GstMask * mask,
+ gint width, gint height, gint border, gint pos)
{
guint32 *maskp;
gint value;
gint i, j;
gint min, max;
- guint8 *in1u, *in1v, *in2u, *in2v, *outu, *outv;
+ guint8 *in1u, *in1v, *in2u, *in2v, *outu, *outv;
gint lumsize = width * height;
gint chromsize = lumsize >> 2;
- if (border == 0) border++;
+ if (border == 0)
+ border++;
- min = pos - border;
+ min = pos - border;
max = pos;
- in1u = in1 + lumsize; in1v = in1u + chromsize;
- in2u = in2 + lumsize; in2v = in2u + chromsize;
- outu = out + lumsize; outv = outu + chromsize;
-
+ in1u = in1 + lumsize;
+ in1v = in1u + chromsize;
+ in2u = in2 + lumsize;
+ in2v = in2u + chromsize;
+ outu = out + lumsize;
+ outv = outu + chromsize;
+
maskp = mask->data;
for (i = 0; i < height; i++) {
for (j = 0; j < width; j++) {
value = *maskp++;
value = ((CLAMP (value, min, max) - min) << 8) / border;
-
+
*out++ = ((*in1++ * value) + (*in2++ * (256 - value))) >> 8;
if (!(i & 1) && !(j & 1)) {
- *outu++ = ((*in1u++ * value) + (*in2u++ * (256 - value))) >> 8;
- *outv++ = ((*in1v++ * value) + (*in2v++ * (256 - value))) >> 8;
+ *outu++ = ((*in1u++ * value) + (*in2u++ * (256 - value))) >> 8;
+ *outv++ = ((*in1v++ * value) + (*in2v++ * (256 - value))) >> 8;
}
}
}
}
static void
-gst_smpte_loop (GstElement *element)
+gst_smpte_loop (GstElement * element)
{
GstSMPTE *smpte;
GstBuffer *outbuf;
if (GST_IS_EVENT (in1)) {
gst_pad_push (smpte->srcpad, GST_DATA (in1));
in1 = NULL;
- }
- else
+ } else
ts = GST_BUFFER_TIMESTAMP (in1);
}
if (GST_PAD_IS_USABLE (smpte->sinkpad2) && in2 == NULL) {
if (GST_IS_EVENT (in2)) {
gst_pad_push (smpte->srcpad, GST_DATA (in2));
in2 = NULL;
- }
- else
+ } else
ts = GST_BUFFER_TIMESTAMP (in2);
}
fill_i420 (GST_BUFFER_DATA (in2), smpte->width, smpte->height, 0);
}
- if (smpte->position < smpte->duration) {
+ if (smpte->position < smpte->duration) {
outbuf = gst_buffer_new_and_alloc (smpte->width * smpte->height * 3);
if (!GST_PAD_CAPS (smpte->srcpad)) {
GstCaps *caps;
- caps = gst_caps_copy (gst_static_caps_get (
- &gst_smpte_src_template.static_caps));
- gst_caps_set_simple (caps,
- "width", G_TYPE_INT, smpte->width,
- "height", G_TYPE_INT, smpte->height,
- "framerate", G_TYPE_DOUBLE, smpte->fps, NULL);
+
+ caps =
+ gst_caps_copy (gst_static_caps_get (&gst_smpte_src_template.
+ static_caps));
+ gst_caps_set_simple (caps, "width", G_TYPE_INT, smpte->width, "height",
+ G_TYPE_INT, smpte->height, "framerate", G_TYPE_DOUBLE, smpte->fps,
+ NULL);
if (!gst_pad_try_set_caps (smpte->srcpad, caps)) {
- GST_ELEMENT_ERROR (smpte, CORE, NEGOTIATION, (NULL), (NULL));
- return;
+ GST_ELEMENT_ERROR (smpte, CORE, NEGOTIATION, (NULL), (NULL));
+ return;
}
}
- gst_smpte_blend_i420 (GST_BUFFER_DATA (in1),
- GST_BUFFER_DATA (in2),
- GST_BUFFER_DATA (outbuf),
- smpte->mask, smpte->width, smpte->height,
- smpte->border,
- ((1 << smpte->depth) + smpte->border) *
- smpte->position / smpte->duration);
- }
- else {
+ gst_smpte_blend_i420 (GST_BUFFER_DATA (in1),
+ GST_BUFFER_DATA (in2),
+ GST_BUFFER_DATA (outbuf),
+ smpte->mask, smpte->width, smpte->height,
+ smpte->border,
+ ((1 << smpte->depth) + smpte->border) *
+ smpte->position / smpte->duration);
+ } else {
outbuf = in2;
gst_buffer_ref (in2);
}
}
static void
-gst_smpte_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
+gst_smpte_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstSMPTE *smpte;
- smpte = GST_SMPTE(object);
+ smpte = GST_SMPTE (object);
switch (prop_id) {
case ARG_TYPE:
{
gint type = g_value_get_enum (value);
- gst_smpte_update_mask (smpte, type, smpte->depth,
- smpte->width, smpte->height);
+ gst_smpte_update_mask (smpte, type, smpte->depth,
+ smpte->width, smpte->height);
break;
}
case ARG_BORDER:
{
gint depth = g_value_get_int (value);
- gst_smpte_update_mask (smpte, smpte->type, depth,
- smpte->width, smpte->height);
+ gst_smpte_update_mask (smpte, smpte->type, depth,
+ smpte->width, smpte->height);
break;
}
default:
}
static void
-gst_smpte_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
+gst_smpte_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
GstSMPTE *smpte;
- smpte = GST_SMPTE(object);
+ smpte = GST_SMPTE (object);
switch (prop_id) {
case ARG_TYPE:
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- return gst_element_register(plugin, "smpte",
- GST_RANK_NONE, GST_TYPE_SMPTE);
+ return gst_element_register (plugin, "smpte", GST_RANK_NONE, GST_TYPE_SMPTE);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "smpte",
- "Apply the standard SMPTE transitions on video images",
- plugin_init,
- VERSION,
- "LGPL",
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "smpte",
+ "Apply the standard SMPTE transitions on video images",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
typedef struct _GstSMPTE GstSMPTE;
typedef struct _GstSMPTEClass GstSMPTEClass;
-struct _GstSMPTE {
- GstElement element;
+struct _GstSMPTE
+{
+ GstElement element;
- gint format;
- gint width;
- gint height;
- gdouble fps;
+ gint format;
+ gint width;
+ gint height;
+ gdouble fps;
- gint duration;
- gint position;
+ gint duration;
+ gint position;
- GstPad *srcpad,
- *sinkpad1,
- *sinkpad2;
+ GstPad *srcpad, *sinkpad1, *sinkpad2;
- gint type;
- gint border;
- gint depth;
- GstMask *mask;
+ gint type;
+ gint border;
+ gint depth;
+ GstMask *mask;
};
-struct _GstSMPTEClass {
+struct _GstSMPTEClass
+{
GstElementClass parent_class;
};
#include "paint.h"
void
-gst_smpte_paint_vbox (guint32 *dest, gint stride,
- gint x0, gint y0, gint c0,
- gint x1, gint y1, gint c1)
+gst_smpte_paint_vbox (guint32 * dest, gint stride,
+ gint x0, gint y0, gint c0, gint x1, gint y1, gint c1)
{
gint i, j;
gint width, height;
width = x1 - x0;
height = y1 - y0;
-
+
g_assert (width > 0);
g_assert (height > 0);
dest = dest + y0 * stride + x0;
-
+
for (i = 0; i < height; i++) {
for (j = 0; j < width; j++) {
dest[j] = (c1 * j + c0 * (width - j)) / width;
}
void
-gst_smpte_paint_hbox (guint32 *dest, gint stride,
- gint x0, gint y0, gint c0,
- gint x1, gint y1, gint c1)
+gst_smpte_paint_hbox (guint32 * dest, gint stride,
+ gint x0, gint y0, gint c0, gint x1, gint y1, gint c1)
{
gint i, j;
gint width, height;
width = x1 - x0;
height = y1 - y0;
-
+
g_assert (width > 0);
g_assert (height > 0);
dest = dest + y0 * stride + x0;
for (i = 0; i < height; i++) {
- guint32 value = (c1 * i + c0 * (height - i)) / height;
+ guint32 value = (c1 * i + c0 * (height - i)) / height;
+
for (j = 0; j < width; j++) {
dest[j] = value;
}
} G_STMT_END
void
-gst_smpte_paint_triangle_linear (guint32 *dest, gint stride,
- gint x0, gint y0, gint c0,
- gint x1, gint y1, gint c1, gint x2, gint y2, gint c2)
+gst_smpte_paint_triangle_linear (guint32 * dest, gint stride,
+ gint x0, gint y0, gint c0,
+ gint x1, gint y1, gint c1, gint x2, gint y2, gint c2)
{
gint sdxl, sdyl, sdcl, dxlabs, dylabs, dclabs, xrl, yrl, crl, pxl, pyl, pcl;
gint sdxr, sdyr, sdcr, dxrabs, dyrabs, dcrabs, xrr, yrr, crr, pxr, pyr, pcr;
gint i, j, k, seg_start, seg_end;
- if (y0 > y1) { SWAP_INT (x0, x1); SWAP_INT (y0, y1); SWAP_INT (c0, c1); }
- if (y0 > y2) { SWAP_INT (x0, x2); SWAP_INT (y0, y2); SWAP_INT (c0, c2); }
- if (y1 > y2) { SWAP_INT (x1, x2); SWAP_INT (y1, y2); SWAP_INT (c1, c2); }
-
- PREPARE_3D_LINE (x0,y0,c0,x2,y2,c2,
- dxlabs,dylabs,dclabs,
- sdxl, sdyl,sdcl,
- xrl,yrl,crl,
- pxl,pyl,pcl);
-
- PREPARE_3D_LINE (x0,y0,c0,x1,y1,c1,
- dxrabs,dyrabs,dcrabs,
- sdxr, sdyr,sdcr,
- xrr,yrr,crr,
- pxr,pyr,pcr);
+ if (y0 > y1) {
+ SWAP_INT (x0, x1);
+ SWAP_INT (y0, y1);
+ SWAP_INT (c0, c1);
+ }
+ if (y0 > y2) {
+ SWAP_INT (x0, x2);
+ SWAP_INT (y0, y2);
+ SWAP_INT (c0, c2);
+ }
+ if (y1 > y2) {
+ SWAP_INT (x1, x2);
+ SWAP_INT (y1, y2);
+ SWAP_INT (c1, c2);
+ }
+
+ PREPARE_3D_LINE (x0, y0, c0, x2, y2, c2,
+ dxlabs, dylabs, dclabs, sdxl, sdyl, sdcl, xrl, yrl, crl, pxl, pyl, pcl);
+
+ PREPARE_3D_LINE (x0, y0, c0, x1, y1, c1,
+ dxrabs, dyrabs, dcrabs, sdxr, sdyr, sdcr, xrr, yrr, crr, pxr, pyr, pcr);
dest = dest + stride * y0;
seg_start = y0;
gint sign = SIGN (e - s);
e += sign;
- for (j = s; j != e; j+=sign) {
- dest[j] = (ec * (j - s) + sc * (e - j)) / (e - s);
+ for (j = s; j != e; j += sign) {
+ dest[j] = (ec * (j - s) + sc * (e - j)) / (e - s);
}
while (pyr == i) {
- STEP_3D_LINE (dxrabs, dyrabs, dcrabs, sdxr, sdyr, sdcr,
- xrr, yrr, crr, pxr, pyr, pcr);
+ STEP_3D_LINE (dxrabs, dyrabs, dcrabs, sdxr, sdyr, sdcr,
+ xrr, yrr, crr, pxr, pyr, pcr);
}
while (pyl == i) {
- STEP_3D_LINE (dxlabs, dylabs, dclabs, sdxl, sdyl, sdcl,
- xrl, yrl, crl, pxl, pyl, pcl);
+ STEP_3D_LINE (dxlabs, dylabs, dclabs, sdxl, sdyl, sdcl,
+ xrl, yrl, crl, pxl, pyl, pcl);
}
dest += stride;
}
- PREPARE_3D_LINE (x1,y1,c1,x2,y2,c2,
- dxrabs,dyrabs,dcrabs,
- sdxr, sdyr,sdcr,
- xrr,yrr,crr,
- pxr,pyr,pcr);
+ PREPARE_3D_LINE (x1, y1, c1, x2, y2, c2,
+ dxrabs, dyrabs, dcrabs, sdxr, sdyr, sdcr, xrr, yrr, crr, pxr, pyr, pcr);
seg_start = y1;
seg_end = y2;
}
}
-static void
-draw_bresenham_line (guint32 *dest, gint stride,
- gint x0, gint y0,
- gint x1, gint y1,
- guint32 col)
+static void
+draw_bresenham_line (guint32 * dest, gint stride,
+ gint x0, gint y0, gint x1, gint y1, guint32 col)
{
gint dx = abs (x1 - x0);
gint dy = abs (y1 - y0);
x_incr = SIGN (x1 - x0);
y_incr = SIGN (y1 - y0) * stride;
-
- if (dx >= dy) {
+
+ if (dx >= dy) {
dpr = dy << 1;
i = dx;
indep = x_incr;
- }
- else {
+ } else {
dpr = dx << 1;
i = dy;
indep = y_incr;
for (; i >= 0; i--) {
*dest = col;
- if (P > 0) {
+ if (P > 0) {
dest += x_incr;
dest += y_incr;
P += dpru;
}
void
-gst_smpte_paint_triangle_clock (guint32 *dest, gint stride,
- gint x0, gint y0, gint c0,
- gint x1, gint y1, gint c1,
- gint x2, gint y2, gint c2)
+gst_smpte_paint_triangle_clock (guint32 * dest, gint stride,
+ gint x0, gint y0, gint c0,
+ gint x1, gint y1, gint c1, gint x2, gint y2, gint c2)
{
gint i;
gint sign;
gfloat len1;
angle_s = 0.0;
- angle_e = acos (((x1-x0) * (x2-x0) + (y1-y0) * (y2-y0))/
- (sqrt ((x1-x0) * (x1-x0) + (y1-y0) * (y1-y0)) *
- sqrt ((x2-x0) * (x2-x0) + (y2-y0) * (y2-y0))));
+ angle_e = acos (((x1 - x0) * (x2 - x0) + (y1 - y0) * (y2 - y0)) /
+ (sqrt ((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0)) *
+ sqrt ((x2 - x0) * (x2 - x0) + (y2 - y0) * (y2 - y0))));
- len1 = sqrt ((x1-x0) * (x1-x0) + (y1-y0) * (y1-y0));
+ len1 = sqrt ((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0));
if (x1 == x2) {
sign = SIGN (y2 - y1);
if (y1 == i)
angle = 0;
else
- angle = acos (((x1-x0) * (x2-x0) + (y1-y0) * (i-y0)) /
- (len1 * sqrt ((x1-x0) * (x1-x0) + (i-y0) * (i-y0)))) / angle_e;
+ angle = acos (((x1 - x0) * (x2 - x0) + (y1 - y0) * (i - y0)) /
+ (len1 * sqrt ((x1 - x0) * (x1 - x0) + (i - y0) * (i -
+ y0)))) / angle_e;
draw_bresenham_line (dest, stride,
- x0, y0, x1, i,
- (c2 * angle + c1 * (1.0-angle)));
+ x0, y0, x1, i, (c2 * angle + c1 * (1.0 - angle)));
}
- }
- else if (y1 == y2) {
+ } else if (y1 == y2) {
sign = SIGN (x2 - x1);
for (i = x1; i != (x2 + sign); i += sign) {
if (x1 == i)
angle = 0;
else
- angle = acos (((x1-x0) * (i-x0) + (y1-y0) * (y2-y0)) /
- (len1 * sqrt ((i-x0) * (i-x0) + (y2-y0) * (y2-y0)))) / angle_e;
+ angle = acos (((x1 - x0) * (i - x0) + (y1 - y0) * (y2 - y0)) /
+ (len1 * sqrt ((i - x0) * (i - x0) + (y2 - y0) * (y2 -
+ y0)))) / angle_e;
draw_bresenham_line (dest, stride,
- x0, y0, i, y1,
- (c2 * angle + c1 * (1.0-angle)));
+ x0, y0, i, y1, (c2 * angle + c1 * (1.0 - angle)));
}
}
}
void
-gst_smpte_paint_box_clock (guint32 *dest, gint stride,
- gint x0, gint y0, gint c0,
- gint x1, gint y1, gint c1,
- gint x2, gint y2, gint c2)
+gst_smpte_paint_box_clock (guint32 * dest, gint stride,
+ gint x0, gint y0, gint c0,
+ gint x1, gint y1, gint c1, gint x2, gint y2, gint c2)
{
gfloat angle_m, col_m;
gint xv, yv;
- if (x1 == x0) {
+ if (x1 == x0) {
xv = x2;
yv = y1;
} else if (y1 == y0) {
xv = x1;
yv = y2;
- }
- else {
+ } else {
g_warning ("paint box clock: not supported");
return;
}
- angle_m = 2 * acos (((x1-x0) * (xv-x0) + (y1-y0) * (yv-y0))/
- (sqrt ((x1-x0) * (x1-x0) + (y1-y0) * (y1-y0)) *
- sqrt ((xv-x0) * (xv-x0) + (yv-y0) * (yv-y0)))) / M_PI;
-
- col_m = c2 * angle_m + c1 * (1.0-angle_m);
+ angle_m = 2 * acos (((x1 - x0) * (xv - x0) + (y1 - y0) * (yv - y0)) /
+ (sqrt ((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0)) *
+ sqrt ((xv - x0) * (xv - x0) + (yv - y0) * (yv - y0)))) / M_PI;
+
+ col_m = c2 * angle_m + c1 * (1.0 - angle_m);
gst_smpte_paint_triangle_clock (dest, stride,
- x0, y0, c0,
- x1, y1, c1,
- xv, yv, col_m);
+ x0, y0, c0, x1, y1, c1, xv, yv, col_m);
gst_smpte_paint_triangle_clock (dest, stride,
- x0, y0, c0,
- xv, yv, col_m,
- x2, y2, c2);
+ x0, y0, c0, xv, yv, col_m, x2, y2, c2);
}
-
#include <glib.h>
-void gst_smpte_paint_vbox (guint32 *dest, gint stride,
- gint x0, gint y0, gint c0,
- gint x1, gint y1, gint c1);
-void gst_smpte_paint_hbox (guint32 *dest, gint stride,
- gint x0, gint y0, gint c0,
- gint x1, gint y1, gint c1);
+void gst_smpte_paint_vbox (guint32 * dest, gint stride,
+ gint x0, gint y0, gint c0, gint x1, gint y1, gint c1);
+void gst_smpte_paint_hbox (guint32 * dest, gint stride,
+ gint x0, gint y0, gint c0, gint x1, gint y1, gint c1);
-void gst_smpte_paint_triangle_linear (guint32 *dest, gint stride,
- gint x0, gint y0, gint c0,
- gint x1, gint y1, gint c1,
- gint x2, gint y2, gint c2);
+void gst_smpte_paint_triangle_linear (guint32 * dest, gint stride,
+ gint x0, gint y0, gint c0,
+ gint x1, gint y1, gint c1, gint x2, gint y2, gint c2);
-void gst_smpte_paint_triangle_clock (guint32 *dest, gint stride,
- gint x0, gint y0, gint c0,
- gint x1, gint y1, gint c1,
- gint x2, gint y2, gint c2);
+void gst_smpte_paint_triangle_clock (guint32 * dest, gint stride,
+ gint x0, gint y0, gint c0,
+ gint x1, gint y1, gint c1, gint x2, gint y2, gint c2);
-void gst_smpte_paint_box_clock (guint32 *dest, gint stride,
- gint x0, gint y0, gint c0,
- gint x1, gint y1, gint c1,
- gint x2, gint y2, gint c2);
+void gst_smpte_paint_box_clock (guint32 * dest, gint stride,
+ gint x0, gint y0, gint c0,
+ gint x1, gint y1, gint c1, gint x2, gint y2, gint c2);
#endif /* __GST_SMPTE_PAINT_H__ */
extern gboolean _gst_plugin_spew;
-void spectrum_chain(GstPad *pad,GstData *_data);
-gboolean idle_func(gpointer data);
+void spectrum_chain (GstPad * pad, GstData * _data);
+gboolean idle_func (gpointer data);
GtkWidget *drawingarea;
-int main(int argc,char *argv[]) {
+int
+main (int argc, char *argv[])
+{
GstElement *bin;
GstElementFactory *srcfactory;
GstElement *src;
_gst_plugin_spew = TRUE;
- gst_init(&argc,&argv);
- gnome_init("Spectrum","0.0.1",argc,argv);
+ gst_init (&argc, &argv);
+ gnome_init ("Spectrum", "0.0.1", argc, argv);
- bin = gst_bin_new("bin");
+ bin = gst_bin_new ("bin");
- srcfactory = gst_element_factory_find("osssrc");
- spectrumfactory = gst_element_factory_find("gstspectrum");
+ srcfactory = gst_element_factory_find ("osssrc");
+ spectrumfactory = gst_element_factory_find ("gstspectrum");
- src = gst_element_factory_create(srcfactory,"src");
- gtk_object_set(GTK_OBJECT(src),"bytes_per_read",(gulong)1024,NULL);
- spectrum = gst_element_factory_create(spectrumfactory,"spectrum");
- gtk_object_set(GTK_OBJECT(spectrum),"width",256,NULL);
+ src = gst_element_factory_create (srcfactory, "src");
+ gtk_object_set (GTK_OBJECT (src), "bytes_per_read", (gulong) 1024, NULL);
+ spectrum = gst_element_factory_create (spectrumfactory, "spectrum");
+ gtk_object_set (GTK_OBJECT (spectrum), "width", 256, NULL);
- gst_bin_add(GST_BIN(bin),GST_ELEMENT(src));
- gst_bin_add(GST_BIN(bin),GST_ELEMENT(spectrum));
+ gst_bin_add (GST_BIN (bin), GST_ELEMENT (src));
+ gst_bin_add (GST_BIN (bin), GST_ELEMENT (spectrum));
- gst_pad_link(gst_element_get_pad(src,"src"),
- gst_element_get_pad(spectrum,"sink"));
+ gst_pad_link (gst_element_get_pad (src, "src"),
+ gst_element_get_pad (spectrum, "sink"));
- spectrumpad = gst_pad_new("sink",GST_PAD_SINK);
- gst_pad_set_chain_function(spectrumpad,spectrum_chain);
+ spectrumpad = gst_pad_new ("sink", GST_PAD_SINK);
+ gst_pad_set_chain_function (spectrumpad, spectrum_chain);
- gst_pad_link(gst_element_get_pad(spectrum,"src"),spectrumpad);
+ gst_pad_link (gst_element_get_pad (spectrum, "src"), spectrumpad);
- appwindow = gnome_app_new("spectrum","Spectrum");
- drawingarea = gtk_drawing_area_new();
- gtk_drawing_area_size(GTK_DRAWING_AREA(drawingarea),256,32);
- gnome_app_set_contents(GNOME_APP(appwindow),drawingarea);
- gtk_widget_show_all(appwindow);
+ appwindow = gnome_app_new ("spectrum", "Spectrum");
+ drawingarea = gtk_drawing_area_new ();
+ gtk_drawing_area_size (GTK_DRAWING_AREA (drawingarea), 256, 32);
+ gnome_app_set_contents (GNOME_APP (appwindow), drawingarea);
+ gtk_widget_show_all (appwindow);
- gst_element_set_state(GST_ELEMENT(bin),GST_STATE_READY);
- gst_element_set_state(GST_ELEMENT(bin),GST_STATE_PLAYING);
+ gst_element_set_state (GST_ELEMENT (bin), GST_STATE_READY);
+ gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING);
- g_idle_add(idle_func,src);
+ g_idle_add (idle_func, src);
- gtk_main();
+ gtk_main ();
return 0;
}
-void spectrum_chain(GstPad *pad,GstData *_data) {
+void
+spectrum_chain (GstPad * pad, GstData * _data)
+{
GstBuffer *buf = GST_BUFFER (_data);
gint i;
guchar *data = buf->data;
- gdk_draw_rectangle(drawingarea->window,drawingarea->style->black_gc,
- TRUE,0,0,GST_BUFFER_SIZE(buf),25);
- for (i=0;i<GST_BUFFER_SIZE(buf);i++) {
- gdk_draw_rectangle(drawingarea->window,drawingarea->style->white_gc,
- TRUE,i,32-data[i],1,data[i]);
+ gdk_draw_rectangle (drawingarea->window, drawingarea->style->black_gc,
+ TRUE, 0, 0, GST_BUFFER_SIZE (buf), 25);
+ for (i = 0; i < GST_BUFFER_SIZE (buf); i++) {
+ gdk_draw_rectangle (drawingarea->window, drawingarea->style->white_gc,
+ TRUE, i, 32 - data[i], 1, data[i]);
}
- gst_buffer_unref(buf);
+ gst_buffer_unref (buf);
}
-gboolean idle_func(gpointer data) {
+gboolean
+idle_func (gpointer data)
+{
/*gst_src_push(GST_SRC(data)); */
return TRUE;
}
extern fixed gst_spectrum_Sinewave[N_WAVE]; /* placed at end of this file for clarity */
extern fixed gst_spectrum_Loudampl[N_LOUD];
-static int gst_spectrum_db_from_ampl(fixed re, fixed im);
-static fixed gst_spectrum_fix_mpy(fixed a, fixed b);
+static int gst_spectrum_db_from_ampl (fixed re, fixed im);
+static fixed gst_spectrum_fix_mpy (fixed a, fixed b);
/*
fix_fft() - perform fast Fourier transform.
size of data = 2**m
set inverse to 0=dft, 1=idft
*/
-int gst_spectrum_fix_fft(fixed fr[], fixed fi[], int m, int inverse) {
- int mr, nn, i, j, l, k, istep, n, scale, shift;
- fixed qr, qi, tr, ti, wr, wi;
-
- n = 1 << m;
-
- if (n > N_WAVE)
- return -1;
-
- mr = 0;
- nn = n - 1;
- scale = 0;
-
- /* decimation in time - re-order data */
- for (m = 1; m <= nn; ++m)
- {
- l = n;
- do
- {
- l >>= 1;
- }
- while (mr + l > nn);
- mr = (mr & (l - 1)) + l;
-
- if (mr <= m)
- continue;
- tr = fr[m];
- fr[m] = fr[mr];
- fr[mr] = tr;
- ti = fi[m];
- fi[m] = fi[mr];
- fi[mr] = ti;
+int
+gst_spectrum_fix_fft (fixed fr[], fixed fi[], int m, int inverse)
+{
+ int mr, nn, i, j, l, k, istep, n, scale, shift;
+ fixed qr, qi, tr, ti, wr, wi;
+
+ n = 1 << m;
+
+ if (n > N_WAVE)
+ return -1;
+
+ mr = 0;
+ nn = n - 1;
+ scale = 0;
+
+ /* decimation in time - re-order data */
+ for (m = 1; m <= nn; ++m) {
+ l = n;
+ do {
+ l >>= 1;
+ }
+ while (mr + l > nn);
+ mr = (mr & (l - 1)) + l;
+
+ if (mr <= m)
+ continue;
+ tr = fr[m];
+ fr[m] = fr[mr];
+ fr[mr] = tr;
+ ti = fi[m];
+ fi[m] = fi[mr];
+ fi[mr] = ti;
+ }
+
+ l = 1;
+ k = LOG2_N_WAVE - 1;
+ while (l < n) {
+ if (inverse) {
+ /* variable scaling, depending upon data */
+ shift = 0;
+ for (i = 0; i < n; ++i) {
+ j = fr[i];
+ if (j < 0)
+ j = -j;
+ m = fi[i];
+ if (m < 0)
+ m = -m;
+ if (j > 16383 || m > 16383) {
+ shift = 1;
+ break;
}
-
- l = 1;
- k = LOG2_N_WAVE - 1;
- while (l < n)
- {
- if (inverse)
- {
- /* variable scaling, depending upon data */
- shift = 0;
- for (i = 0; i < n; ++i)
- {
- j = fr[i];
- if (j < 0)
- j = -j;
- m = fi[i];
- if (m < 0)
- m = -m;
- if (j > 16383 || m > 16383)
- {
- shift = 1;
- break;
- }
- }
- if (shift)
- ++scale;
- }
- else
- {
- /* fixed scaling, for proper normalization -
- there will be log2(n) passes, so this
- results in an overall factor of 1/n,
- distributed to maximize arithmetic accuracy. */
- shift = 1;
- }
- /* it may not be obvious, but the shift will be performed
- on each data point exactly once, during this pass. */
- istep = l << 1;
- for (m = 0; m < l; ++m)
- {
- j = m << k;
- /* 0 <= j < N_WAVE/2 */
- wr = gst_spectrum_Sinewave[j + N_WAVE / 4];
- wi = -gst_spectrum_Sinewave[j];
- if (inverse)
- wi = -wi;
- if (shift)
- {
- wr >>= 1;
- wi >>= 1;
- }
- for (i = m; i < n; i += istep)
- {
- j = i + l;
- tr = gst_spectrum_fix_mpy(wr, fr[j]) -
- gst_spectrum_fix_mpy(wi, fi[j]);
- ti = gst_spectrum_fix_mpy(wr, fi[j]) +
- gst_spectrum_fix_mpy(wi, fr[j]);
- qr = fr[i];
- qi = fi[i];
- if (shift)
- {
- qr >>= 1;
- qi >>= 1;
- }
- fr[j] = qr - tr;
- fi[j] = qi - ti;
- fr[i] = qr + tr;
- fi[i] = qi + ti;
- }
- }
- --k;
- l = istep;
+ }
+ if (shift)
+ ++scale;
+ } else {
+ /* fixed scaling, for proper normalization -
+ there will be log2(n) passes, so this
+ results in an overall factor of 1/n,
+ distributed to maximize arithmetic accuracy. */
+ shift = 1;
+ }
+ /* it may not be obvious, but the shift will be performed
+ on each data point exactly once, during this pass. */
+ istep = l << 1;
+ for (m = 0; m < l; ++m) {
+ j = m << k;
+ /* 0 <= j < N_WAVE/2 */
+ wr = gst_spectrum_Sinewave[j + N_WAVE / 4];
+ wi = -gst_spectrum_Sinewave[j];
+ if (inverse)
+ wi = -wi;
+ if (shift) {
+ wr >>= 1;
+ wi >>= 1;
+ }
+ for (i = m; i < n; i += istep) {
+ j = i + l;
+ tr = gst_spectrum_fix_mpy (wr, fr[j]) -
+ gst_spectrum_fix_mpy (wi, fi[j]);
+ ti = gst_spectrum_fix_mpy (wr, fi[j]) +
+ gst_spectrum_fix_mpy (wi, fr[j]);
+ qr = fr[i];
+ qi = fi[i];
+ if (shift) {
+ qr >>= 1;
+ qi >>= 1;
}
-
- return scale;
+ fr[j] = qr - tr;
+ fi[j] = qi - ti;
+ fr[i] = qr + tr;
+ fi[i] = qi + ti;
+ }
+ }
+ --k;
+ l = istep;
+ }
+
+ return scale;
}
/* window() - apply a Hanning window */
-void gst_spectrum_window(fixed fr[], int n) {
- int i, j, k;
-
- j = N_WAVE / n;
- n >>= 1;
- for (i = 0, k = N_WAVE / 4; i < n; ++i, k += j)
- FIX_MPY(fr[i], fr[i], 16384 - (gst_spectrum_Sinewave[k] >> 1));
- n <<= 1;
- for (k -= j; i < n; ++i, k -= j)
- FIX_MPY(fr[i], fr[i], 16384 - (gst_spectrum_Sinewave[k] >> 1));
+void
+gst_spectrum_window (fixed fr[], int n)
+{
+ int i, j, k;
+
+ j = N_WAVE / n;
+ n >>= 1;
+ for (i = 0, k = N_WAVE / 4; i < n; ++i, k += j)
+ FIX_MPY (fr[i], fr[i], 16384 - (gst_spectrum_Sinewave[k] >> 1));
+ n <<= 1;
+ for (k -= j; i < n; ++i, k -= j)
+ FIX_MPY (fr[i], fr[i], 16384 - (gst_spectrum_Sinewave[k] >> 1));
}
/* fix_loud() - compute loudness of freq-vis components.
was obtained from an inverse FFT, 0 otherwise.
loud[] is the loudness, in dB wrt 32767; will be +10 to -N_LOUD.
*/
-void gst_spectrum_fix_loud(fixed loud[], fixed fr[], fixed fi[], int n, int scale_shift) {
- int i, max;
-
- max = 0;
- if (scale_shift > 0)
- max = 10;
- scale_shift = (scale_shift + 1) * 6;
-
- for (i = 0; i < n; ++i)
- {
- loud[i] = gst_spectrum_db_from_ampl(fr[i], fi[i]) + scale_shift;
- if (loud[i] > max)
- loud[i] = max;
- }
+void
+gst_spectrum_fix_loud (fixed loud[], fixed fr[], fixed fi[], int n,
+ int scale_shift)
+{
+ int i, max;
+
+ max = 0;
+ if (scale_shift > 0)
+ max = 10;
+ scale_shift = (scale_shift + 1) * 6;
+
+ for (i = 0; i < n; ++i) {
+ loud[i] = gst_spectrum_db_from_ampl (fr[i], fi[i]) + scale_shift;
+ if (loud[i] > max)
+ loud[i] = max;
+ }
}
/* db_from_ampl() - find loudness (in dB) from
the complex amplitude.
*/
-int gst_spectrum_db_from_ampl(fixed re, fixed im) {
- static long loud2[N_LOUD] =
- {0};
- long v;
- int i;
-
- if (loud2[0] == 0)
- {
- loud2[0] = (long) gst_spectrum_Loudampl[0] * (long) gst_spectrum_Loudampl[0];
- for (i = 1; i < N_LOUD; ++i)
- {
- v = (long) gst_spectrum_Loudampl[i] * (long) gst_spectrum_Loudampl[i];
- loud2[i] = v;
- loud2[i - 1] = (loud2[i - 1] + v) / 2;
- }
- }
-
- v = (long) re *(long) re + (long) im *(long) im;
-
- for (i = 0; i < N_LOUD; ++i)
- if (loud2[i] <= v)
- break;
-
- return (-i);
+int
+gst_spectrum_db_from_ampl (fixed re, fixed im)
+{
+ static long loud2[N_LOUD] = { 0 };
+ long v;
+ int i;
+
+ if (loud2[0] == 0) {
+ loud2[0] =
+ (long) gst_spectrum_Loudampl[0] * (long) gst_spectrum_Loudampl[0];
+ for (i = 1; i < N_LOUD; ++i) {
+ v = (long) gst_spectrum_Loudampl[i] * (long) gst_spectrum_Loudampl[i];
+ loud2[i] = v;
+ loud2[i - 1] = (loud2[i - 1] + v) / 2;
+ }
+ }
+
+ v = (long) re *(long) re + (long) im *(long) im;
+
+ for (i = 0; i < N_LOUD; ++i)
+ if (loud2[i] <= v)
+ break;
+
+ return (-i);
}
/*
fix_mpy() - fixed-point multiplication
*/
-fixed gst_spectrum_fix_mpy(fixed a, fixed b) {
- FIX_MPY(a, a, b);
- return a;
+fixed
+gst_spectrum_fix_mpy (fixed a, fixed b)
+{
+ FIX_MPY (a, a, b);
+ return a;
}
/*
iscale() - scale an integer value by (numer/denom)
*/
-int gst_spectrum_iscale(int value, int numer, int denom) {
- return (long) value *(long) numer / (long) denom;
+int
+gst_spectrum_iscale (int value, int numer, int denom)
+{
+ return (long) value *(long) numer / (long) denom;
}
/*
fix_dot() - dot product of two fixed arrays
*/
-fixed gst_spectrum_fix_dot(fixed * hpa, fixed * pb, int n) {
- fixed *pa = hpa; /* FIXME */
- long sum;
- register fixed a, b;
+fixed
+gst_spectrum_fix_dot (fixed * hpa, fixed * pb, int n)
+{
+ fixed *pa = hpa; /* FIXME */
+ long sum;
+ register fixed a, b;
/* seg = FP_SEG(hpa);
off = FP_OFF(hpa);
off &= 0x000F;
pa = MK_FP(seg,off);
*/
- sum = 0L;
- while (n--)
- {
- a = *pa++;
- b = *pb++;
- FIX_MPY(a, a, b);
- sum += a;
- }
+ sum = 0L;
+ while (n--) {
+ a = *pa++;
+ b = *pb++;
+ FIX_MPY (a, a, b);
+ sum += a;
+ }
- if (sum > 0x7FFF)
- sum = 0x7FFF;
- else if (sum < -0x7FFF)
- sum = -0x7FFF;
+ if (sum > 0x7FFF)
+ sum = 0x7FFF;
+ else if (sum < -0x7FFF)
+ sum = -0x7FFF;
- return (fixed) sum;
+ return (fixed) sum;
}
#if N_WAVE != 1024
ERROR:N_WAVE != 1024
#endif
-fixed gst_spectrum_Sinewave[1024] = {
- 0, 201, 402, 603, 804, 1005, 1206, 1406,
- 1607, 1808, 2009, 2209, 2410, 2610, 2811, 3011,
- 3211, 3411, 3611, 3811, 4011, 4210, 4409, 4608,
- 4807, 5006, 5205, 5403, 5601, 5799, 5997, 6195,
- 6392, 6589, 6786, 6982, 7179, 7375, 7571, 7766,
- 7961, 8156, 8351, 8545, 8739, 8932, 9126, 9319,
- 9511, 9703, 9895, 10087, 10278, 10469, 10659, 10849,
- 11038, 11227, 11416, 11604, 11792, 11980, 12166, 12353,
- 12539, 12724, 12909, 13094, 13278, 13462, 13645, 13827,
- 14009, 14191, 14372, 14552, 14732, 14911, 15090, 15268,
- 15446, 15623, 15799, 15975, 16150, 16325, 16499, 16672,
- 16845, 17017, 17189, 17360, 17530, 17699, 17868, 18036,
- 18204, 18371, 18537, 18702, 18867, 19031, 19194, 19357,
- 19519, 19680, 19840, 20000, 20159, 20317, 20474, 20631,
- 20787, 20942, 21096, 21249, 21402, 21554, 21705, 21855,
- 22004, 22153, 22301, 22448, 22594, 22739, 22883, 23027,
- 23169, 23311, 23452, 23592, 23731, 23869, 24006, 24143,
- 24278, 24413, 24546, 24679, 24811, 24942, 25072, 25201,
- 25329, 25456, 25582, 25707, 25831, 25954, 26077, 26198,
- 26318, 26437, 26556, 26673, 26789, 26905, 27019, 27132,
- 27244, 27355, 27466, 27575, 27683, 27790, 27896, 28001,
- 28105, 28208, 28309, 28410, 28510, 28608, 28706, 28802,
- 28897, 28992, 29085, 29177, 29268, 29358, 29446, 29534,
- 29621, 29706, 29790, 29873, 29955, 30036, 30116, 30195,
- 30272, 30349, 30424, 30498, 30571, 30643, 30713, 30783,
- 30851, 30918, 30984, 31049,
- 31113, 31175, 31236, 31297,
- 31356, 31413, 31470, 31525, 31580, 31633, 31684, 31735,
- 31785, 31833, 31880, 31926, 31970, 32014, 32056, 32097,
- 32137, 32176, 32213, 32249, 32284, 32318, 32350, 32382,
- 32412, 32441, 32468, 32495, 32520, 32544, 32567, 32588,
- 32609, 32628, 32646, 32662, 32678, 32692, 32705, 32717,
- 32727, 32736, 32744, 32751, 32757, 32761, 32764, 32766,
- 32767, 32766, 32764, 32761, 32757, 32751, 32744, 32736,
- 32727, 32717, 32705, 32692, 32678, 32662, 32646, 32628,
- 32609, 32588, 32567, 32544, 32520, 32495, 32468, 32441,
- 32412, 32382, 32350, 32318, 32284, 32249, 32213, 32176,
- 32137, 32097, 32056, 32014, 31970, 31926, 31880, 31833,
- 31785, 31735, 31684, 31633, 31580, 31525, 31470, 31413,
- 31356, 31297, 31236, 31175, 31113, 31049, 30984, 30918,
- 30851, 30783, 30713, 30643, 30571, 30498, 30424, 30349,
- 30272, 30195, 30116, 30036, 29955, 29873, 29790, 29706,
- 29621, 29534, 29446, 29358, 29268, 29177, 29085, 28992,
- 28897, 28802, 28706, 28608, 28510, 28410, 28309, 28208,
- 28105, 28001, 27896, 27790, 27683, 27575, 27466, 27355,
- 27244, 27132, 27019, 26905, 26789, 26673, 26556, 26437,
- 26318, 26198, 26077, 25954, 25831, 25707, 25582, 25456,
- 25329, 25201, 25072, 24942, 24811, 24679, 24546, 24413,
- 24278, 24143, 24006, 23869, 23731, 23592, 23452, 23311,
- 23169, 23027, 22883, 22739, 22594, 22448, 22301, 22153,
- 22004, 21855, 21705, 21554, 21402, 21249, 21096, 20942,
- 20787, 20631, 20474, 20317, 20159, 20000, 19840, 19680,
- 19519, 19357, 19194, 19031, 18867, 18702, 18537, 18371,
- 18204, 18036, 17868, 17699, 17530, 17360, 17189, 17017,
- 16845, 16672, 16499, 16325, 16150, 15975, 15799, 15623,
- 15446, 15268, 15090, 14911, 14732, 14552, 14372, 14191,
- 14009, 13827, 13645, 13462, 13278, 13094, 12909, 12724,
- 12539, 12353, 12166, 11980, 11792, 11604, 11416, 11227,
- 11038, 10849, 10659, 10469, 10278, 10087, 9895, 9703,
- 9511, 9319, 9126, 8932, 8739, 8545, 8351, 8156,
- 7961, 7766, 7571, 7375, 7179, 6982, 6786, 6589,
- 6392, 6195, 5997, 5799, 5601, 5403, 5205, 5006,
- 4807, 4608, 4409, 4210, 4011, 3811, 3611, 3411,
- 3211, 3011, 2811, 2610, 2410, 2209, 2009, 1808,
- 1607, 1406, 1206, 1005, 804, 603, 402, 201,
- 0, -201, -402, -603, -804, -1005, -1206, -1406,
- -1607, -1808, -2009, -2209, -2410, -2610, -2811, -3011,
- -3211, -3411, -3611, -3811, -4011, -4210, -4409, -4608,
- -4807, -5006, -5205, -5403, -5601, -5799, -5997, -6195,
- -6392, -6589, -6786, -6982, -7179, -7375, -7571, -7766,
- -7961, -8156, -8351, -8545, -8739, -8932, -9126, -9319,
- -9511, -9703, -9895, -10087, -10278, -10469, -10659, -10849,
- -11038, -11227, -11416, -11604, -11792, -11980, -12166, -12353,
- -12539, -12724, -12909, -13094, -13278, -13462, -13645, -13827,
- -14009, -14191, -14372, -14552, -14732, -14911, -15090, -15268,
- -15446, -15623, -15799, -15975, -16150, -16325, -16499, -16672,
- -16845, -17017, -17189, -17360, -17530, -17699, -17868, -18036,
- -18204, -18371, -18537, -18702, -18867, -19031, -19194, -19357,
- -19519, -19680, -19840, -20000, -20159, -20317, -20474, -20631,
- -20787, -20942, -21096, -21249, -21402, -21554, -21705, -21855,
- -22004, -22153, -22301, -22448, -22594, -22739, -22883, -23027,
- -23169, -23311, -23452, -23592, -23731, -23869, -24006, -24143,
- -24278, -24413, -24546, -24679, -24811, -24942, -25072, -25201,
- -25329, -25456, -25582, -25707, -25831, -25954, -26077, -26198,
- -26318, -26437, -26556, -26673, -26789, -26905, -27019, -27132,
- -27244, -27355, -27466, -27575, -27683, -27790, -27896, -28001,
- -28105, -28208, -28309, -28410, -28510, -28608, -28706, -28802,
- -28897, -28992, -29085, -29177, -29268, -29358, -29446, -29534,
- -29621, -29706, -29790, -29873, -29955, -30036, -30116, -30195,
- -30272, -30349, -30424, -30498, -30571, -30643, -30713, -30783,
- -30851, -30918, -30984, -31049, -31113, -31175, -31236, -31297,
- -31356, -31413, -31470, -31525, -31580, -31633, -31684, -31735,
- -31785, -31833, -31880, -31926, -31970, -32014, -32056, -32097,
- -32137, -32176, -32213, -32249, -32284, -32318, -32350, -32382,
- -32412, -32441, -32468, -32495, -32520, -32544, -32567, -32588,
- -32609, -32628, -32646, -32662, -32678, -32692, -32705, -32717,
- -32727, -32736, -32744, -32751, -32757, -32761, -32764, -32766,
- -32767, -32766, -32764, -32761, -32757, -32751, -32744, -32736,
- -32727, -32717, -32705, -32692, -32678, -32662, -32646, -32628,
- -32609, -32588, -32567, -32544, -32520, -32495, -32468, -32441,
- -32412, -32382, -32350, -32318, -32284, -32249, -32213, -32176,
- -32137, -32097, -32056, -32014, -31970, -31926, -31880, -31833,
- -31785, -31735, -31684, -31633, -31580, -31525, -31470, -31413,
- -31356, -31297, -31236, -31175, -31113, -31049, -30984, -30918,
- -30851, -30783, -30713, -30643, -30571, -30498, -30424, -30349,
- -30272, -30195, -30116, -30036, -29955, -29873, -29790, -29706,
- -29621, -29534, -29446, -29358, -29268, -29177, -29085, -28992,
- -28897, -28802, -28706, -28608, -28510, -28410, -28309, -28208,
- -28105, -28001, -27896, -27790, -27683, -27575, -27466, -27355,
- -27244, -27132, -27019, -26905, -26789, -26673, -26556, -26437,
- -26318, -26198, -26077, -25954, -25831, -25707, -25582, -25456,
- -25329, -25201, -25072, -24942, -24811, -24679, -24546, -24413,
- -24278, -24143, -24006, -23869, -23731, -23592, -23452, -23311,
- -23169, -23027, -22883, -22739, -22594, -22448, -22301, -22153,
- -22004, -21855, -21705, -21554, -21402, -21249, -21096, -20942,
- -20787, -20631, -20474, -20317, -20159, -20000, -19840, -19680,
- -19519, -19357, -19194, -19031, -18867, -18702, -18537, -18371,
- -18204, -18036, -17868, -17699, -17530, -17360, -17189, -17017,
- -16845, -16672, -16499, -16325, -16150, -15975, -15799, -15623,
- -15446, -15268, -15090, -14911, -14732, -14552, -14372, -14191,
- -14009, -13827, -13645, -13462, -13278, -13094, -12909, -12724,
- -12539, -12353, -12166, -11980, -11792, -11604, -11416, -11227,
- -11038, -10849, -10659, -10469, -10278, -10087, -9895, -9703,
- -9511, -9319, -9126, -8932, -8739, -8545, -8351, -8156,
- -7961, -7766, -7571, -7375, -7179, -6982, -6786, -6589,
- -6392, -6195, -5997, -5799, -5601, -5403, -5205, -5006,
- -4807, -4608, -4409, -4210, -4011, -3811, -3611, -3411,
- -3211, -3011, -2811, -2610, -2410, -2209, -2009, -1808,
- -1607, -1406, -1206, -1005, -804, -603, -402, -201,
-};
+ fixed gst_spectrum_Sinewave[1024] = {
+0, 201, 402, 603, 804, 1005, 1206, 1406,
+ 1607, 1808, 2009, 2209, 2410, 2610, 2811, 3011,
+ 3211, 3411, 3611, 3811, 4011, 4210, 4409, 4608,
+ 4807, 5006, 5205, 5403, 5601, 5799, 5997, 6195,
+ 6392, 6589, 6786, 6982, 7179, 7375, 7571, 7766,
+ 7961, 8156, 8351, 8545, 8739, 8932, 9126, 9319,
+ 9511, 9703, 9895, 10087, 10278, 10469, 10659, 10849,
+ 11038, 11227, 11416, 11604, 11792, 11980, 12166, 12353,
+ 12539, 12724, 12909, 13094, 13278, 13462, 13645, 13827,
+ 14009, 14191, 14372, 14552, 14732, 14911, 15090, 15268,
+ 15446, 15623, 15799, 15975, 16150, 16325, 16499, 16672,
+ 16845, 17017, 17189, 17360, 17530, 17699, 17868, 18036,
+ 18204, 18371, 18537, 18702, 18867, 19031, 19194, 19357,
+ 19519, 19680, 19840, 20000, 20159, 20317, 20474, 20631,
+ 20787, 20942, 21096, 21249, 21402, 21554, 21705, 21855,
+ 22004, 22153, 22301, 22448, 22594, 22739, 22883, 23027,
+ 23169, 23311, 23452, 23592, 23731, 23869, 24006, 24143,
+ 24278, 24413, 24546, 24679, 24811, 24942, 25072, 25201,
+ 25329, 25456, 25582, 25707, 25831, 25954, 26077, 26198,
+ 26318, 26437, 26556, 26673, 26789, 26905, 27019, 27132,
+ 27244, 27355, 27466, 27575, 27683, 27790, 27896, 28001,
+ 28105, 28208, 28309, 28410, 28510, 28608, 28706, 28802,
+ 28897, 28992, 29085, 29177, 29268, 29358, 29446, 29534,
+ 29621, 29706, 29790, 29873, 29955, 30036, 30116, 30195,
+ 30272, 30349, 30424, 30498, 30571, 30643, 30713, 30783,
+ 30851, 30918, 30984, 31049,
+ 31113, 31175, 31236, 31297,
+ 31356, 31413, 31470, 31525, 31580, 31633, 31684, 31735,
+ 31785, 31833, 31880, 31926, 31970, 32014, 32056, 32097,
+ 32137, 32176, 32213, 32249, 32284, 32318, 32350, 32382,
+ 32412, 32441, 32468, 32495, 32520, 32544, 32567, 32588,
+ 32609, 32628, 32646, 32662, 32678, 32692, 32705, 32717,
+ 32727, 32736, 32744, 32751, 32757, 32761, 32764, 32766,
+ 32767, 32766, 32764, 32761, 32757, 32751, 32744, 32736,
+ 32727, 32717, 32705, 32692, 32678, 32662, 32646, 32628,
+ 32609, 32588, 32567, 32544, 32520, 32495, 32468, 32441,
+ 32412, 32382, 32350, 32318, 32284, 32249, 32213, 32176,
+ 32137, 32097, 32056, 32014, 31970, 31926, 31880, 31833,
+ 31785, 31735, 31684, 31633, 31580, 31525, 31470, 31413,
+ 31356, 31297, 31236, 31175, 31113, 31049, 30984, 30918,
+ 30851, 30783, 30713, 30643, 30571, 30498, 30424, 30349,
+ 30272, 30195, 30116, 30036, 29955, 29873, 29790, 29706,
+ 29621, 29534, 29446, 29358, 29268, 29177, 29085, 28992,
+ 28897, 28802, 28706, 28608, 28510, 28410, 28309, 28208,
+ 28105, 28001, 27896, 27790, 27683, 27575, 27466, 27355,
+ 27244, 27132, 27019, 26905, 26789, 26673, 26556, 26437,
+ 26318, 26198, 26077, 25954, 25831, 25707, 25582, 25456,
+ 25329, 25201, 25072, 24942, 24811, 24679, 24546, 24413,
+ 24278, 24143, 24006, 23869, 23731, 23592, 23452, 23311,
+ 23169, 23027, 22883, 22739, 22594, 22448, 22301, 22153,
+ 22004, 21855, 21705, 21554, 21402, 21249, 21096, 20942,
+ 20787, 20631, 20474, 20317, 20159, 20000, 19840, 19680,
+ 19519, 19357, 19194, 19031, 18867, 18702, 18537, 18371,
+ 18204, 18036, 17868, 17699, 17530, 17360, 17189, 17017,
+ 16845, 16672, 16499, 16325, 16150, 15975, 15799, 15623,
+ 15446, 15268, 15090, 14911, 14732, 14552, 14372, 14191,
+ 14009, 13827, 13645, 13462, 13278, 13094, 12909, 12724,
+ 12539, 12353, 12166, 11980, 11792, 11604, 11416, 11227,
+ 11038, 10849, 10659, 10469, 10278, 10087, 9895, 9703,
+ 9511, 9319, 9126, 8932, 8739, 8545, 8351, 8156,
+ 7961, 7766, 7571, 7375, 7179, 6982, 6786, 6589,
+ 6392, 6195, 5997, 5799, 5601, 5403, 5205, 5006,
+ 4807, 4608, 4409, 4210, 4011, 3811, 3611, 3411,
+ 3211, 3011, 2811, 2610, 2410, 2209, 2009, 1808,
+ 1607, 1406, 1206, 1005, 804, 603, 402, 201,
+ 0, -201, -402, -603, -804, -1005, -1206, -1406,
+ -1607, -1808, -2009, -2209, -2410, -2610, -2811, -3011,
+ -3211, -3411, -3611, -3811, -4011, -4210, -4409, -4608,
+ -4807, -5006, -5205, -5403, -5601, -5799, -5997, -6195,
+ -6392, -6589, -6786, -6982, -7179, -7375, -7571, -7766,
+ -7961, -8156, -8351, -8545, -8739, -8932, -9126, -9319,
+ -9511, -9703, -9895, -10087, -10278, -10469, -10659, -10849,
+ -11038, -11227, -11416, -11604, -11792, -11980, -12166, -12353,
+ -12539, -12724, -12909, -13094, -13278, -13462, -13645, -13827,
+ -14009, -14191, -14372, -14552, -14732, -14911, -15090, -15268,
+ -15446, -15623, -15799, -15975, -16150, -16325, -16499, -16672,
+ -16845, -17017, -17189, -17360, -17530, -17699, -17868, -18036,
+ -18204, -18371, -18537, -18702, -18867, -19031, -19194, -19357,
+ -19519, -19680, -19840, -20000, -20159, -20317, -20474, -20631,
+ -20787, -20942, -21096, -21249, -21402, -21554, -21705, -21855,
+ -22004, -22153, -22301, -22448, -22594, -22739, -22883, -23027,
+ -23169, -23311, -23452, -23592, -23731, -23869, -24006, -24143,
+ -24278, -24413, -24546, -24679, -24811, -24942, -25072, -25201,
+ -25329, -25456, -25582, -25707, -25831, -25954, -26077, -26198,
+ -26318, -26437, -26556, -26673, -26789, -26905, -27019, -27132,
+ -27244, -27355, -27466, -27575, -27683, -27790, -27896, -28001,
+ -28105, -28208, -28309, -28410, -28510, -28608, -28706, -28802,
+ -28897, -28992, -29085, -29177, -29268, -29358, -29446, -29534,
+ -29621, -29706, -29790, -29873, -29955, -30036, -30116, -30195,
+ -30272, -30349, -30424, -30498, -30571, -30643, -30713, -30783,
+ -30851, -30918, -30984, -31049, -31113, -31175, -31236, -31297,
+ -31356, -31413, -31470, -31525, -31580, -31633, -31684, -31735,
+ -31785, -31833, -31880, -31926, -31970, -32014, -32056, -32097,
+ -32137, -32176, -32213, -32249, -32284, -32318, -32350, -32382,
+ -32412, -32441, -32468, -32495, -32520, -32544, -32567, -32588,
+ -32609, -32628, -32646, -32662, -32678, -32692, -32705, -32717,
+ -32727, -32736, -32744, -32751, -32757, -32761, -32764, -32766,
+ -32767, -32766, -32764, -32761, -32757, -32751, -32744, -32736,
+ -32727, -32717, -32705, -32692, -32678, -32662, -32646, -32628,
+ -32609, -32588, -32567, -32544, -32520, -32495, -32468, -32441,
+ -32412, -32382, -32350, -32318, -32284, -32249, -32213, -32176,
+ -32137, -32097, -32056, -32014, -31970, -31926, -31880, -31833,
+ -31785, -31735, -31684, -31633, -31580, -31525, -31470, -31413,
+ -31356, -31297, -31236, -31175, -31113, -31049, -30984, -30918,
+ -30851, -30783, -30713, -30643, -30571, -30498, -30424, -30349,
+ -30272, -30195, -30116, -30036, -29955, -29873, -29790, -29706,
+ -29621, -29534, -29446, -29358, -29268, -29177, -29085, -28992,
+ -28897, -28802, -28706, -28608, -28510, -28410, -28309, -28208,
+ -28105, -28001, -27896, -27790, -27683, -27575, -27466, -27355,
+ -27244, -27132, -27019, -26905, -26789, -26673, -26556, -26437,
+ -26318, -26198, -26077, -25954, -25831, -25707, -25582, -25456,
+ -25329, -25201, -25072, -24942, -24811, -24679, -24546, -24413,
+ -24278, -24143, -24006, -23869, -23731, -23592, -23452, -23311,
+ -23169, -23027, -22883, -22739, -22594, -22448, -22301, -22153,
+ -22004, -21855, -21705, -21554, -21402, -21249, -21096, -20942,
+ -20787, -20631, -20474, -20317, -20159, -20000, -19840, -19680,
+ -19519, -19357, -19194, -19031, -18867, -18702, -18537, -18371,
+ -18204, -18036, -17868, -17699, -17530, -17360, -17189, -17017,
+ -16845, -16672, -16499, -16325, -16150, -15975, -15799, -15623,
+ -15446, -15268, -15090, -14911, -14732, -14552, -14372, -14191,
+ -14009, -13827, -13645, -13462, -13278, -13094, -12909, -12724,
+ -12539, -12353, -12166, -11980, -11792, -11604, -11416, -11227,
+ -11038, -10849, -10659, -10469, -10278, -10087, -9895, -9703,
+ -9511, -9319, -9126, -8932, -8739, -8545, -8351, -8156,
+ -7961, -7766, -7571, -7375, -7179, -6982, -6786, -6589,
+ -6392, -6195, -5997, -5799, -5601, -5403, -5205, -5006,
+ -4807, -4608, -4409, -4210, -4011, -3811, -3611, -3411,
+ -3211, -3011, -2811, -2610, -2410, -2209, -2009, -1808,
+ -1607, -1406, -1206, -1005, -804, -603, -402, -201,};
#if N_LOUD != 100
ERROR:N_LOUD != 100
#endif
-fixed gst_spectrum_Loudampl[100] = {
- 32767, 29203, 26027, 23197, 20674, 18426, 16422, 14636,
- 13044, 11626, 10361, 9234, 8230, 7335, 6537, 5826,
- 5193, 4628, 4125, 3676, 3276, 2920, 2602, 2319,
- 2067, 1842, 1642, 1463, 1304, 1162, 1036, 923,
- 823, 733, 653, 582, 519, 462, 412, 367,
- 327, 292, 260, 231, 206, 184, 164, 146,
- 130, 116, 103, 92, 82, 73, 65, 58,
- 51, 46, 41, 36, 32, 29, 26, 23,
- 20, 18, 16, 14, 13, 11, 10, 9,
- 8, 7, 6, 5, 5, 4, 4, 3,
- 3, 2, 2, 2, 2, 1, 1, 1,
- 1, 1, 1, 0, 0, 0, 0, 0,
- 0, 0, 0, 0,
-};
+ fixed gst_spectrum_Loudampl[100] = {
+32767, 29203, 26027, 23197, 20674, 18426, 16422, 14636,
+ 13044, 11626, 10361, 9234, 8230, 7335, 6537, 5826,
+ 5193, 4628, 4125, 3676, 3276, 2920, 2602, 2319,
+ 2067, 1842, 1642, 1463, 1304, 1162, 1036, 923,
+ 823, 733, 653, 582, 519, 462, 412, 367,
+ 327, 292, 260, 231, 206, 184, 164, 146,
+ 130, 116, 103, 92, 82, 73, 65, 58,
+ 51, 46, 41, 36, 32, 29, 26, 23,
+ 20, 18, 16, 14, 13, 11, 10, 9,
+ 8, 7, 6, 5, 5, 4, 4, 3,
+ 3, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,};
#include "gstspectrum.h"
/* elementfactory information */
-static GstElementDetails gst_spectrum_details = GST_ELEMENT_DETAILS (
- "Spectrum analyzer",
- "Filter/Analyzer/Audio",
- "Run an FFT on the audio signal, output spectrum data",
- "Erik Walthinsen <omega@cse.ogi.edu>"
-);
+static GstElementDetails gst_spectrum_details =
+GST_ELEMENT_DETAILS ("Spectrum analyzer",
+ "Filter/Analyzer/Audio",
+ "Run an FFT on the audio signal, output spectrum data",
+ "Erik Walthinsen <omega@cse.ogi.edu>");
/* Spectrum signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_WIDTH,
};
-static void gst_spectrum_base_init (gpointer g_class);
-static void gst_spectrum_class_init (GstSpectrumClass *klass);
-static void gst_spectrum_init (GstSpectrum *spectrum);
+static void gst_spectrum_base_init (gpointer g_class);
+static void gst_spectrum_class_init (GstSpectrumClass * klass);
+static void gst_spectrum_init (GstSpectrum * spectrum);
-static void gst_spectrum_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
+static void gst_spectrum_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
-static void gst_spectrum_chain (GstPad *pad, GstData *_data);
+static void gst_spectrum_chain (GstPad * pad, GstData * _data);
#define fixed short
-int gst_spectrum_fix_fft(fixed fr[], fixed fi[], int m, int inverse);
-void gst_spectrum_fix_loud(fixed loud[], fixed fr[], fixed fi[], int n, int scale_shift);
-void gst_spectrum_window(fixed fr[], int n);
+int gst_spectrum_fix_fft (fixed fr[], fixed fi[], int m, int inverse);
+void gst_spectrum_fix_loud (fixed loud[], fixed fr[], fixed fi[], int n,
+ int scale_shift);
+void gst_spectrum_window (fixed fr[], int n);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_spectrum_signals[LAST_SIGNAL] = { 0 }; */
GType
if (!spectrum_type) {
static const GTypeInfo spectrum_info = {
- sizeof(GstSpectrumClass),
+ sizeof (GstSpectrumClass),
gst_spectrum_base_init,
NULL,
- (GClassInitFunc)gst_spectrum_class_init,
+ (GClassInitFunc) gst_spectrum_class_init,
NULL,
NULL,
- sizeof(GstSpectrum),
+ sizeof (GstSpectrum),
0,
- (GInstanceInitFunc)gst_spectrum_init,
+ (GInstanceInitFunc) gst_spectrum_init,
};
- spectrum_type = g_type_register_static(GST_TYPE_ELEMENT, "GstSpectrum", &spectrum_info, 0);
+ spectrum_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstSpectrum", &spectrum_info,
+ 0);
}
return spectrum_type;
}
gst_element_class_set_details (element_class, &gst_spectrum_details);
}
static void
-gst_spectrum_class_init (GstSpectrumClass *klass)
+gst_spectrum_class_init (GstSpectrumClass * klass)
{
GObjectClass *gobject_class;
- gobject_class = (GObjectClass*)klass;
+ gobject_class = (GObjectClass *) klass;
- parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
+ parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_WIDTH,
- g_param_spec_int("width","width","width",
- G_MININT,G_MAXINT,0,G_PARAM_WRITABLE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_WIDTH, g_param_spec_int ("width", "width", "width", G_MININT, G_MAXINT, 0, G_PARAM_WRITABLE)); /* CHECKME */
gobject_class->set_property = gst_spectrum_set_property;
}
static void
-gst_spectrum_init (GstSpectrum *spectrum)
+gst_spectrum_init (GstSpectrum * spectrum)
{
- spectrum->sinkpad = gst_pad_new("sink",GST_PAD_SINK);
- gst_element_add_pad(GST_ELEMENT(spectrum),spectrum->sinkpad);
- gst_pad_set_chain_function(spectrum->sinkpad,gst_spectrum_chain);
- spectrum->srcpad = gst_pad_new("src",GST_PAD_SRC);
- gst_element_add_pad(GST_ELEMENT(spectrum),spectrum->srcpad);
+ spectrum->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
+ gst_element_add_pad (GST_ELEMENT (spectrum), spectrum->sinkpad);
+ gst_pad_set_chain_function (spectrum->sinkpad, gst_spectrum_chain);
+ spectrum->srcpad = gst_pad_new ("src", GST_PAD_SRC);
+ gst_element_add_pad (GST_ELEMENT (spectrum), spectrum->srcpad);
spectrum->width = 75;
}
static void
-gst_spectrum_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_spectrum_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstSpectrum *spectrum;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_SPECTRUM(object));
- spectrum = GST_SPECTRUM(object);
+ g_return_if_fail (GST_IS_SPECTRUM (object));
+ spectrum = GST_SPECTRUM (object);
switch (prop_id) {
case ARG_WIDTH:
}
static void
-gst_spectrum_chain (GstPad *pad, GstData *_data)
+gst_spectrum_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstSpectrum *spectrum;
gint spec_base, spec_len;
gint16 *re, *im, *loud;
gint16 *samples;
- gint step,pos,i;
+ gint step, pos, i;
guchar *spect;
GstBuffer *newbuf;
- g_return_if_fail(pad != NULL);
- g_return_if_fail(GST_IS_PAD(pad));
- g_return_if_fail(buf != NULL);
+ g_return_if_fail (pad != NULL);
+ g_return_if_fail (GST_IS_PAD (pad));
+ g_return_if_fail (buf != NULL);
spectrum = GST_SPECTRUM (GST_OBJECT_PARENT (pad));
- samples = (gint16 *)GST_BUFFER_DATA(buf);
+ samples = (gint16 *) GST_BUFFER_DATA (buf);
spec_base = 8;
spec_len = 1024;
- im = g_malloc(spec_len * sizeof(gint16));
- g_return_if_fail(im != NULL);
- loud = g_malloc(spec_len * sizeof(gint16));
- g_return_if_fail(loud != NULL);
+ im = g_malloc (spec_len * sizeof (gint16));
+ g_return_if_fail (im != NULL);
+ loud = g_malloc (spec_len * sizeof (gint16));
+ g_return_if_fail (loud != NULL);
- memset(im,0,spec_len * sizeof(gint16));
+ memset (im, 0, spec_len * sizeof (gint16));
/*if (spectrum->meta->channels == 2) { */
- re = g_malloc(spec_len * sizeof(gint16));
- for (i=0;i<spec_len;i++)
- re[i] = (samples[(i*2)] + samples[(i*2)+1]) >> 1;
+ re = g_malloc (spec_len * sizeof (gint16));
+ for (i = 0; i < spec_len; i++)
+ re[i] = (samples[(i * 2)] + samples[(i * 2) + 1]) >> 1;
/*} else */
/* re = samples; */
- gst_spectrum_window(re,spec_len);
- gst_spectrum_fix_fft(re,im,spec_base,FALSE);
- gst_spectrum_fix_loud(loud,re,im,spec_len,0);
- if (re != samples) g_free(re);
- g_free(im);
- step = spec_len / (spectrum->width*2);
- spect = (guchar *)g_malloc(spectrum->width);
- for (i=0,pos=0;i<spectrum->width;i++,pos += step) {
+ gst_spectrum_window (re, spec_len);
+ gst_spectrum_fix_fft (re, im, spec_base, FALSE);
+ gst_spectrum_fix_loud (loud, re, im, spec_len, 0);
+ if (re != samples)
+ g_free (re);
+ g_free (im);
+ step = spec_len / (spectrum->width * 2);
+ spect = (guchar *) g_malloc (spectrum->width);
+ for (i = 0, pos = 0; i < spectrum->width; i++, pos += step) {
if (loud[pos] > -60)
spect[i] = (loud[pos] + 60) / 2;
else
/* if (spect[i] > 15); */
/* spect[i] = 15; */
}
- g_free(loud);
- gst_buffer_unref(buf);
+ g_free (loud);
+ gst_buffer_unref (buf);
/* g_free(samples); */
- newbuf = gst_buffer_new();
- g_return_if_fail(newbuf != NULL);
- GST_BUFFER_DATA(newbuf) = spect;
- GST_BUFFER_SIZE(newbuf) = spectrum->width;
+ newbuf = gst_buffer_new ();
+ g_return_if_fail (newbuf != NULL);
+ GST_BUFFER_DATA (newbuf) = spect;
+ GST_BUFFER_SIZE (newbuf) = spectrum->width;
- gst_pad_push(spectrum->srcpad,GST_DATA (newbuf));
+ gst_pad_push (spectrum->srcpad, GST_DATA (newbuf));
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- return gst_element_register (plugin, "spectrum", GST_RANK_NONE, GST_TYPE_SPECTRUM);
+ return gst_element_register (plugin, "spectrum", GST_RANK_NONE,
+ GST_TYPE_SPECTRUM);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "spectrum",
- "Run an FFT on the audio signal, output spectrum data",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "spectrum",
+ "Run an FFT on the audio signal, output spectrum data",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_SPECTRUM \
#define GST_IS_SPECTRUM_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SPECTRUM))
-typedef struct _GstSpectrum GstSpectrum;
-typedef struct _GstSpectrumClass GstSpectrumClass;
+ typedef struct _GstSpectrum GstSpectrum;
+ typedef struct _GstSpectrumClass GstSpectrumClass;
-struct _GstSpectrum {
- GstElement element;
+ struct _GstSpectrum
+ {
+ GstElement element;
- GstPad *sinkpad,*srcpad;
+ GstPad *sinkpad, *srcpad;
- gint width;
-};
+ gint width;
+ };
-struct _GstSpectrumClass {
- GstElementClass parent_class;
-};
+ struct _GstSpectrumClass
+ {
+ GstElementClass parent_class;
+ };
-GType gst_spectrum_get_type(void);
+ GType gst_spectrum_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_SPECTRUM_H__ */
+#endif /* __GST_SPECTRUM_H__ */
#include <gtk/gtk.h>
#include <gst/gst.h>
-void set_speed (GtkAdjustment *adj, gpointer data)
+void
+set_speed (GtkAdjustment * adj, gpointer data)
{
- GstElement *speed = GST_ELEMENT(data);
- g_object_set (speed, "speed", adj->value, NULL);
+ GstElement *speed = GST_ELEMENT (data);
+
+ g_object_set (speed, "speed", adj->value, NULL);
}
-int main(int argc, char **argv)
+int
+main (int argc, char **argv)
{
- GtkWidget *window, *vbox, *hscale, *button;
- GstElement *filesrc, *mad, *stereo2mono, *speed, *osssink, *pipeline;
-
- gst_init (&argc, &argv);
- gtk_init (&argc, &argv);
-
- if (argc!=2) {
- g_print("usage: %s <your.mp3>\n", argv[0]);
- exit(-1);
- }
-
- window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_window_set_default_size(GTK_WINDOW(window), 400, 80);
- vbox = gtk_vbox_new(FALSE, 0);
- gtk_widget_show(vbox);
- hscale = gtk_hscale_new(GTK_ADJUSTMENT(gtk_adjustment_new(1.0, 0.01, 4.0,
- 0.1, 0.0, 0.0)));
- gtk_scale_set_digits(GTK_SCALE(hscale), 2);
- gtk_range_set_update_policy(GTK_RANGE(hscale), GTK_UPDATE_CONTINUOUS);
- button = gtk_button_new_with_label("quit");
- gtk_container_add(GTK_CONTAINER(window), vbox);
- gtk_box_pack_start(GTK_BOX(vbox), hscale, TRUE, TRUE, 2);
- gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 2);
- gtk_widget_show(hscale);
- gtk_signal_connect(GTK_OBJECT(button), "clicked", gtk_main_quit, NULL);
- gtk_widget_show(button);
-
- filesrc = gst_element_factory_make("filesrc", "filesrc");
- mad = gst_element_factory_make("mad", "mad");
- stereo2mono = gst_element_factory_make("stereo2mono", "stereo2mono");
- speed = gst_element_factory_make("speed", "speed");
- osssink = gst_element_factory_make("osssink", "osssink");
- g_object_set(osssink, "fragment", 0x00180008, NULL);
-
- gtk_signal_connect(GTK_OBJECT(gtk_range_get_adjustment(GTK_RANGE(hscale))),
- "value_changed", G_CALLBACK (set_speed), speed);
-
- pipeline = gst_pipeline_new("app");
- gst_bin_add_many (GST_BIN(pipeline), filesrc, mad, stereo2mono, speed, osssink, NULL);
- gst_element_link_many (filesrc, mad, stereo2mono, speed, osssink, NULL);
- g_object_set(G_OBJECT(filesrc), "location", argv[1], NULL);
-
- gst_element_set_state(pipeline, GST_STATE_PLAYING);
-
- gtk_widget_show(window);
- gtk_idle_add((GtkFunction)gst_bin_iterate, pipeline);
-
- gtk_main();
-
- return 0;
+ GtkWidget *window, *vbox, *hscale, *button;
+ GstElement *filesrc, *mad, *stereo2mono, *speed, *osssink, *pipeline;
+
+ gst_init (&argc, &argv);
+ gtk_init (&argc, &argv);
+
+ if (argc != 2) {
+ g_print ("usage: %s <your.mp3>\n", argv[0]);
+ exit (-1);
+ }
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_default_size (GTK_WINDOW (window), 400, 80);
+ vbox = gtk_vbox_new (FALSE, 0);
+ gtk_widget_show (vbox);
+ hscale = gtk_hscale_new (GTK_ADJUSTMENT (gtk_adjustment_new (1.0, 0.01, 4.0,
+ 0.1, 0.0, 0.0)));
+ gtk_scale_set_digits (GTK_SCALE (hscale), 2);
+ gtk_range_set_update_policy (GTK_RANGE (hscale), GTK_UPDATE_CONTINUOUS);
+ button = gtk_button_new_with_label ("quit");
+ gtk_container_add (GTK_CONTAINER (window), vbox);
+ gtk_box_pack_start (GTK_BOX (vbox), hscale, TRUE, TRUE, 2);
+ gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 2);
+ gtk_widget_show (hscale);
+ gtk_signal_connect (GTK_OBJECT (button), "clicked", gtk_main_quit, NULL);
+ gtk_widget_show (button);
+
+ filesrc = gst_element_factory_make ("filesrc", "filesrc");
+ mad = gst_element_factory_make ("mad", "mad");
+ stereo2mono = gst_element_factory_make ("stereo2mono", "stereo2mono");
+ speed = gst_element_factory_make ("speed", "speed");
+ osssink = gst_element_factory_make ("osssink", "osssink");
+ g_object_set (osssink, "fragment", 0x00180008, NULL);
+
+ gtk_signal_connect (GTK_OBJECT (gtk_range_get_adjustment (GTK_RANGE
+ (hscale))), "value_changed", G_CALLBACK (set_speed), speed);
+
+ pipeline = gst_pipeline_new ("app");
+ gst_bin_add_many (GST_BIN (pipeline), filesrc, mad, stereo2mono, speed,
+ osssink, NULL);
+ gst_element_link_many (filesrc, mad, stereo2mono, speed, osssink, NULL);
+ g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
+
+ gst_element_set_state (pipeline, GST_STATE_PLAYING);
+
+ gtk_widget_show (window);
+ gtk_idle_add ((GtkFunction) gst_bin_iterate, pipeline);
+
+ gtk_main ();
+
+ return 0;
}
#define SPEED_NUMBUF 6
/* elementfactory information */
-static GstElementDetails speed_details = GST_ELEMENT_DETAILS (
- "Speed",
- "Filter/Effect/Audio",
- "Set speed/pitch on audio/raw streams (resampler)",
- "Andy Wingo <apwingo@eos.ncsu.edu>"
-);
+static GstElementDetails speed_details = GST_ELEMENT_DETAILS ("Speed",
+ "Filter/Effect/Audio",
+ "Set speed/pitch on audio/raw streams (resampler)",
+ "Andy Wingo <apwingo@eos.ncsu.edu>");
/* Filter signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_SPEED
};
static GstStaticPadTemplate gst_speed_sink_template =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
+ GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- GST_AUDIO_INT_PAD_TEMPLATE_CAPS "; "
- GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS
- )
-);
+ GST_STATIC_CAPS (GST_AUDIO_INT_PAD_TEMPLATE_CAPS "; "
+ GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS)
+ );
static GstStaticPadTemplate gst_speed_src_template =
-GST_STATIC_PAD_TEMPLATE (
- "src",
+ GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- GST_AUDIO_INT_PAD_TEMPLATE_CAPS "; "
- GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS
- )
-);
+ GST_STATIC_CAPS (GST_AUDIO_INT_PAD_TEMPLATE_CAPS "; "
+ GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS)
+ );
-static void speed_base_init (gpointer g_class);
-static void speed_class_init (GstSpeedClass *klass);
-static void speed_init (GstSpeed *filter);
+static void speed_base_init (gpointer g_class);
+static void speed_class_init (GstSpeedClass * klass);
+static void speed_init (GstSpeed * filter);
-static void speed_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void speed_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+static void speed_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void speed_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec);
-static gboolean speed_parse_caps (GstSpeed *filter, const GstCaps *caps);
+static gboolean speed_parse_caps (GstSpeed * filter, const GstCaps * caps);
-static void speed_loop (GstElement *element);
+static void speed_loop (GstElement * element);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_filter_signals[LAST_SIGNAL] = { 0 }; */
static GstPadLinkReturn
-speed_link (GstPad *pad, const GstCaps *caps)
+speed_link (GstPad * pad, const GstCaps * caps)
{
GstSpeed *filter;
GstPad *otherpad;
g_return_val_if_fail (GST_IS_SPEED (filter), GST_PAD_LINK_REFUSED);
otherpad = (pad == filter->srcpad ? filter->sinkpad : filter->srcpad);
- if (! speed_parse_caps (filter, caps)) return GST_PAD_LINK_REFUSED;
+ if (!speed_parse_caps (filter, caps))
+ return GST_PAD_LINK_REFUSED;
- return gst_pad_try_set_caps(otherpad, caps);
+ return gst_pad_try_set_caps (otherpad, caps);
}
static gboolean
-speed_parse_caps (GstSpeed *filter, const GstCaps *caps)
+speed_parse_caps (GstSpeed * filter, const GstCaps * caps)
{
const gchar *mimetype;
GstStructure *structure;
gboolean ret;
- g_return_val_if_fail(filter != NULL, FALSE);
- g_return_val_if_fail(caps != NULL, FALSE);
+ g_return_val_if_fail (filter != NULL, FALSE);
+ g_return_val_if_fail (caps != NULL, FALSE);
structure = gst_caps_get_structure (caps, 0);
ret &= gst_structure_get_int (structure, "channels", &filter->channels);
ret &= gst_structure_get_int (structure, "width", &filter->width);
ret &= gst_structure_get_int (structure, "endianness", &filter->endianness);
- ret &= gst_structure_get_int (structure, "buffer-frames", &filter->buffer_frames);
+ ret &=
+ gst_structure_get_int (structure, "buffer-frames",
+ &filter->buffer_frames);
mimetype = gst_structure_get_name (structure);
- if (strcmp(mimetype, "audio/x-raw-int") == 0) {
+ if (strcmp (mimetype, "audio/x-raw-int") == 0) {
filter->format = GST_SPEED_FORMAT_INT;
ret &= gst_structure_get_int (structure, "depth", &filter->depth);
ret &= gst_structure_get_boolean (structure, "signed", &filter->is_signed);
- } else if (strcmp(mimetype, "audio/x-raw-float") == 0) {
+ } else if (strcmp (mimetype, "audio/x-raw-float") == 0) {
filter->format = GST_SPEED_FORMAT_FLOAT;
- } else {
+ } else {
return FALSE;
}
return ret;
GType
-gst_speed_get_type(void) {
+gst_speed_get_type (void)
+{
static GType speed_type = 0;
if (!speed_type) {
static const GTypeInfo speed_info = {
- sizeof(GstSpeedClass),
+ sizeof (GstSpeedClass),
speed_base_init,
NULL,
- (GClassInitFunc)speed_class_init,
+ (GClassInitFunc) speed_class_init,
NULL,
NULL,
- sizeof(GstSpeed),
+ sizeof (GstSpeed),
0,
- (GInstanceInitFunc)speed_init,
+ (GInstanceInitFunc) speed_init,
};
- speed_type = g_type_register_static(GST_TYPE_ELEMENT, "GstSpeed", &speed_info, 0);
+ speed_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstSpeed", &speed_info, 0);
}
return speed_type;
}
gst_static_pad_template_get (&gst_speed_sink_template));
}
static void
-speed_class_init (GstSpeedClass *klass)
+speed_class_init (GstSpeedClass * klass)
{
- GObjectClass *gobject_class = (GObjectClass*)klass;
+ GObjectClass *gobject_class = (GObjectClass *) klass;
gobject_class->set_property = speed_set_property;
gobject_class->get_property = speed_get_property;
- parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
+ parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_SPEED,
- g_param_spec_float("speed","speed","speed",
- 0.1,40.0,1.0,G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SPEED,
+ g_param_spec_float ("speed", "speed", "speed",
+ 0.1, 40.0, 1.0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
}
static void
-speed_init (GstSpeed *filter)
+speed_init (GstSpeed * filter)
{
- filter->sinkpad = gst_pad_new_from_template(
- gst_static_pad_template_get (&gst_speed_sink_template), "sink");
- gst_pad_set_link_function(filter->sinkpad, speed_link);
- gst_element_add_pad(GST_ELEMENT(filter),filter->sinkpad);
-
- filter->srcpad = gst_pad_new_from_template(
- gst_static_pad_template_get (&gst_speed_src_template), "src");
- gst_pad_set_link_function(filter->srcpad, speed_link);
- gst_element_add_pad(GST_ELEMENT(filter),filter->srcpad);
-
- gst_element_set_loop_function(GST_ELEMENT(filter),speed_loop);
+ filter->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_speed_sink_template), "sink");
+ gst_pad_set_link_function (filter->sinkpad, speed_link);
+ gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
+
+ filter->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_speed_src_template), "src");
+ gst_pad_set_link_function (filter->srcpad, speed_link);
+ gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
+
+ gst_element_set_loop_function (GST_ELEMENT (filter), speed_loop);
}
static void
-speed_loop (GstElement *element)
+speed_loop (GstElement * element)
{
- GstSpeed *filter = GST_SPEED(element);
+ GstSpeed *filter = GST_SPEED (element);
GstBuffer *in, *out;
guint i, j, nin, nout;
gfloat interp, speed, lower, i_float;
- g_return_if_fail(filter != NULL);
- g_return_if_fail(GST_IS_SPEED(filter));
+ g_return_if_fail (filter != NULL);
+ g_return_if_fail (GST_IS_SPEED (filter));
i = j = 0;
speed = filter->speed;
-
- in = GST_BUFFER (gst_pad_pull(filter->sinkpad));
+
+ in = GST_BUFFER (gst_pad_pull (filter->sinkpad));
if (GST_IS_EVENT (in)) {
gst_pad_event_default (filter->sinkpad, GST_EVENT (in));
/* this is a bit nasty, but hey, it's what you've got to do to keep the same
* algorithm and multiple data types in c. */
- if (filter->format==GST_SPEED_FORMAT_FLOAT) {
+ if (filter->format == GST_SPEED_FORMAT_FLOAT) {
#define _FORMAT gfloat
#include "filter.func"
#undef _FORMAT
- } else if (filter->format==GST_SPEED_FORMAT_INT && filter->width==16) {
+ } else if (filter->format == GST_SPEED_FORMAT_INT && filter->width == 16) {
#define _FORMAT gint16
#include "filter.func"
#undef _FORMAT
- } else if (filter->format==GST_SPEED_FORMAT_INT && filter->width==8) {
+ } else if (filter->format == GST_SPEED_FORMAT_INT && filter->width == 8) {
#define _FORMAT gint8
#include "filter.func"
#undef _FORMAT
} else {
- GST_ELEMENT_ERROR (filter, CORE, NEGOTIATION, (NULL),
- ("format wasn't negotiated before chain function"));
+ GST_ELEMENT_ERROR (filter, CORE, NEGOTIATION, (NULL),
+ ("format wasn't negotiated before chain function"));
gst_element_yield (element);
}
}
static void
-speed_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+speed_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstSpeed *filter;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_SPEED(object));
- filter = GST_SPEED(object);
+ g_return_if_fail (GST_IS_SPEED (object));
+ filter = GST_SPEED (object);
- switch (prop_id)
- {
+ switch (prop_id) {
case ARG_SPEED:
filter->speed = g_value_get_float (value);
break;
}
static void
-speed_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+speed_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstSpeed *filter;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_SPEED(object));
- filter = GST_SPEED(object);
+ g_return_if_fail (GST_IS_SPEED (object));
+ filter = GST_SPEED (object);
switch (prop_id) {
case ARG_SPEED:
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- return gst_element_register(plugin, "speed", GST_RANK_NONE, GST_TYPE_SPEED);
+ return gst_element_register (plugin, "speed", GST_RANK_NONE, GST_TYPE_SPEED);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "speed",
- "Set speed/pitch on audio/raw streams (resampler)",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "speed",
+ "Set speed/pitch on audio/raw streams (resampler)",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_TYPE_SPEED \
(gst_speed_get_type())
#define GST_SPEED(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SPEED))
#define GST_IS_SPEED_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SPEED))
-
typedef struct _GstSpeed GstSpeed;
typedef struct _GstSpeedClass GstSpeedClass;
typedef enum _GstSpeedFormat GstSpeedFormat;
-enum _GstSpeedFormat {
+enum _GstSpeedFormat
+{
GST_SPEED_FORMAT_INT,
GST_SPEED_FORMAT_FLOAT
};
-struct _GstSpeed {
+struct _GstSpeed
+{
GstElement element;
GstPad *sinkpad, *srcpad;
gboolean is_signed;
};
-struct _GstSpeedClass {
+struct _GstSpeedClass
+{
GstElementClass parent_class;
};
-GType gst_speed_get_type(void);
+GType gst_speed_get_type (void);
G_END_DECLS
-
#endif /* __GST_SPEED_H__ */
#include <gststereo.h>
/* elementfactory information */
-static GstElementDetails stereo_details = GST_ELEMENT_DETAILS (
- "Stereo effect",
- "Filter/Effect/Audio",
- "Muck with the stereo signal to enhance its 'stereo-ness'",
- "Erik Walthinsen <omega@cse.ogi.edu>"
-);
+static GstElementDetails stereo_details = GST_ELEMENT_DETAILS ("Stereo effect",
+ "Filter/Effect/Audio",
+ "Muck with the stereo signal to enhance its 'stereo-ness'",
+ "Erik Walthinsen <omega@cse.ogi.edu>");
/* Stereo signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_ACTIVE,
ARG_STEREO
};
-static void gst_stereo_base_init (gpointer g_class);
-static void gst_stereo_class_init (GstStereoClass *klass);
-static void gst_stereo_init (GstStereo *stereo);
+static void gst_stereo_base_init (gpointer g_class);
+static void gst_stereo_class_init (GstStereoClass * klass);
+static void gst_stereo_init (GstStereo * stereo);
-static void gst_stereo_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void gst_stereo_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+static void gst_stereo_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_stereo_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static void gst_stereo_chain (GstPad *pad, GstData *_data);
+static void gst_stereo_chain (GstPad * pad, GstData * _data);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_stereo_signals[LAST_SIGNAL] = { 0 }; */
GType
-gst_stereo_get_type(void) {
+gst_stereo_get_type (void)
+{
static GType stereo_type = 0;
if (!stereo_type) {
static const GTypeInfo stereo_info = {
- sizeof(GstStereoClass),
+ sizeof (GstStereoClass),
gst_stereo_base_init,
NULL,
- (GClassInitFunc)gst_stereo_class_init,
+ (GClassInitFunc) gst_stereo_class_init,
NULL,
NULL,
- sizeof(GstStereo),
+ sizeof (GstStereo),
0,
- (GInstanceInitFunc)gst_stereo_init,
+ (GInstanceInitFunc) gst_stereo_init,
};
- stereo_type = g_type_register_static(GST_TYPE_ELEMENT, "GstStereo", &stereo_info, 0);
+ stereo_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstStereo", &stereo_info, 0);
}
return stereo_type;
}
gst_stereo_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
+
gst_element_class_set_details (element_class, &stereo_details);
}
static void
-gst_stereo_class_init (GstStereoClass *klass)
+gst_stereo_class_init (GstStereoClass * 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);
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_ACTIVE,
- g_param_spec_int("active","active","active",
- G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_STEREO,
- g_param_spec_float("stereo","stereo","stereo",
- 0.0,1.0,0.0,G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ACTIVE, g_param_spec_int ("active", "active", "active", G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_STEREO, g_param_spec_float ("stereo", "stereo", "stereo", 0.0, 1.0, 0.0, G_PARAM_READWRITE)); /* CHECKME */
gobject_class->set_property = gst_stereo_set_property;
gobject_class->get_property = gst_stereo_get_property;
}
static void
-gst_stereo_init (GstStereo *stereo)
+gst_stereo_init (GstStereo * stereo)
{
- stereo->sinkpad = gst_pad_new("sink",GST_PAD_SINK);
- gst_element_add_pad(GST_ELEMENT(stereo),stereo->sinkpad);
- gst_pad_set_chain_function(stereo->sinkpad,gst_stereo_chain);
- stereo->srcpad = gst_pad_new("src",GST_PAD_SRC);
- gst_element_add_pad(GST_ELEMENT(stereo),stereo->srcpad);
+ stereo->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
+ gst_element_add_pad (GST_ELEMENT (stereo), stereo->sinkpad);
+ gst_pad_set_chain_function (stereo->sinkpad, gst_stereo_chain);
+ stereo->srcpad = gst_pad_new ("src", GST_PAD_SRC);
+ gst_element_add_pad (GST_ELEMENT (stereo), stereo->srcpad);
stereo->active = FALSE;
stereo->stereo = 2.5;
}
static void
-gst_stereo_chain (GstPad *pad,GstData *_data)
+gst_stereo_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstStereo *stereo;
gint16 *data;
gint samples;
gint i;
- gdouble avg,ldiff,rdiff,tmp,mul;
+ gdouble avg, ldiff, rdiff, tmp, mul;
- g_return_if_fail(pad != NULL);
- g_return_if_fail(GST_IS_PAD(pad));
- g_return_if_fail(buf != NULL);
+ g_return_if_fail (pad != NULL);
+ g_return_if_fail (GST_IS_PAD (pad));
+ g_return_if_fail (buf != NULL);
- stereo = GST_STEREO(GST_OBJECT_PARENT (pad));
- g_return_if_fail(stereo != NULL);
- g_return_if_fail(GST_IS_STEREO(stereo));
+ stereo = GST_STEREO (GST_OBJECT_PARENT (pad));
+ g_return_if_fail (stereo != NULL);
+ g_return_if_fail (GST_IS_STEREO (stereo));
/* FIXME */
/* if (buf->meta) */
if (stereo->active) {
/*if (stereo->meta.channels == 2 && stereo->meta.format == AFMT_S16_LE) { */
- data = (gint16 *)GST_BUFFER_DATA(buf);
- samples = GST_BUFFER_SIZE(buf) / 2;
- mul = stereo->stereo;
- for (i = 0; i < samples / 2; i += 2) {
- avg = (data[i] + data[i + 1]) / 2;
- ldiff = data[i] - avg;
- rdiff = data[i + 1] - avg;
-
- tmp = avg + ldiff * mul;
- if (tmp < -32768)
- tmp = -32768;
- if (tmp > 32767)
- tmp = 32767;
- data[i] = tmp;
-
- tmp = avg + rdiff * mul;
- if (tmp < -32768)
- tmp = -32768;
- if (tmp > 32767)
- tmp = 32767;
- data[i + 1] = tmp;
- }
+ data = (gint16 *) GST_BUFFER_DATA (buf);
+ samples = GST_BUFFER_SIZE (buf) / 2;
+ mul = stereo->stereo;
+ for (i = 0; i < samples / 2; i += 2) {
+ avg = (data[i] + data[i + 1]) / 2;
+ ldiff = data[i] - avg;
+ rdiff = data[i + 1] - avg;
+
+ tmp = avg + ldiff * mul;
+ if (tmp < -32768)
+ tmp = -32768;
+ if (tmp > 32767)
+ tmp = 32767;
+ data[i] = tmp;
+
+ tmp = avg + rdiff * mul;
+ if (tmp < -32768)
+ tmp = -32768;
+ if (tmp > 32767)
+ tmp = 32767;
+ data[i + 1] = tmp;
+ }
/*} */
}
- gst_pad_push(stereo->srcpad,GST_DATA (buf));
+ gst_pad_push (stereo->srcpad, GST_DATA (buf));
}
static void
-gst_stereo_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_stereo_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstStereo *stereo;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_STEREO(object));
- stereo = GST_STEREO(object);
+ g_return_if_fail (GST_IS_STEREO (object));
+ stereo = GST_STEREO (object);
switch (prop_id) {
case ARG_ACTIVE:
}
static void
-gst_stereo_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_stereo_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstStereo *stereo;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_STEREO(object));
- stereo = GST_STEREO(object);
+ g_return_if_fail (GST_IS_STEREO (object));
+ stereo = GST_STEREO (object);
switch (prop_id) {
case ARG_ACTIVE:
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- return gst_element_register (plugin, "stereo", GST_RANK_NONE, GST_TYPE_STEREO);
+ return gst_element_register (plugin, "stereo", GST_RANK_NONE,
+ GST_TYPE_STEREO);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "stereo",
- "Muck with the stereo signal, enhance it's 'stereo-ness'",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
-
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "stereo",
+ "Muck with the stereo signal, enhance it's 'stereo-ness'",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_STEREO \
#define GST_IS_STEREO_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_STEREO))
-typedef struct _GstStereo GstStereo;
-typedef struct _GstStereoClass GstStereoClass;
+ typedef struct _GstStereo GstStereo;
+ typedef struct _GstStereoClass GstStereoClass;
-struct _GstStereo {
- GstElement element;
+ struct _GstStereo
+ {
+ GstElement element;
- GstPad *sinkpad,*srcpad;
+ GstPad *sinkpad, *srcpad;
- gint8 active;
- gfloat stereo;
-};
+ gint8 active;
+ gfloat stereo;
+ };
-struct _GstStereoClass {
- GstElementClass parent_class;
-};
+ struct _GstStereoClass
+ {
+ GstElementClass parent_class;
+ };
-GType gst_stereo_get_type(void);
+ GType gst_stereo_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_STEREO_H__ */
+#endif /* __GST_STEREO_H__ */
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
-
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
/* Object header */
#include "gstswitch.h"
-enum {
+enum
+{
ARG_0,
ARG_NB_SOURCES,
ARG_ACTIVE_SOURCE
GST_DEBUG_CATEGORY_EXTERN (GST_CAT_DATAFLOW);
/* ElementFactory information */
-static GstElementDetails gst_switch_details = GST_ELEMENT_DETAILS (
- "Switch",
- "Generic",
- "N-to-1 input switching",
- "Julien Moutte <julien@moutte.net>"
-);
+static GstElementDetails gst_switch_details = GST_ELEMENT_DETAILS ("Switch",
+ "Generic",
+ "N-to-1 input switching",
+ "Julien Moutte <julien@moutte.net>");
static GstStaticPadTemplate gst_switch_sink_factory =
-GST_STATIC_PAD_TEMPLATE (
- "sink%d",
- GST_PAD_SINK,
- GST_PAD_REQUEST,
- GST_STATIC_CAPS_ANY
-);
+GST_STATIC_PAD_TEMPLATE ("sink%d",
+ GST_PAD_SINK,
+ GST_PAD_REQUEST,
+ GST_STATIC_CAPS_ANY);
static GstElementClass *parent_class = NULL;
/* ============================================================= */
static void
-gst_switch_release_pad (GstElement *element, GstPad *pad)
+gst_switch_release_pad (GstElement * element, GstPad * pad)
{
GList *sinkpads = NULL;
GstSwitch *gstswitch = NULL;
GstSwitchPad *switchpad = NULL;
-
+
g_return_if_fail (GST_IS_SWITCH (element));
-
+
gstswitch = GST_SWITCH (element);
-
+
GST_CAT_LOG_OBJECT (GST_CAT_ELEMENT_PADS, gstswitch,
- "releasing requested pad %p", pad);
-
+ "releasing requested pad %p", pad);
+
sinkpads = gstswitch->sinkpads;
-
+
/* Walking through our pad list searching for the pad we want to release */
while (sinkpads) {
switchpad = sinkpads->data;
-
+
if (switchpad && switchpad->sinkpad == pad)
break;
- else
+ else
switchpad = NULL;
-
+
sinkpads = g_list_next (sinkpads);
}
-
+
/* Releasing the found pad */
if (switchpad) {
/* We unref the data of that pad to loose our reference */
}
}
-static GstPad*
-gst_switch_request_new_pad (GstElement *element,
- GstPadTemplate *templ,
- const gchar *unused)
+static GstPad *
+gst_switch_request_new_pad (GstElement * element,
+ GstPadTemplate * templ, const gchar * unused)
{
char *name = NULL;
GstPad *sinkpad = NULL;
GstSwitch *gstswitch = NULL;
GstSwitchPad *switchpad = NULL;
-
+
g_return_val_if_fail (GST_IS_SWITCH (element), NULL);
-
+
gstswitch = GST_SWITCH (element);
-
+
/* We only provide requested sink pads */
if (templ->direction != GST_PAD_SINK) {
GST_CAT_LOG_OBJECT (GST_CAT_ELEMENT_PADS, gstswitch,
- "requested a non sink pad");
+ "requested a non sink pad");
return NULL;
}
-
+
name = g_strdup_printf ("sink%d", gstswitch->nb_sinkpads);
-
+
sinkpad = gst_pad_new_from_template (templ, name);
-
+
if (name)
g_free (name);
-
+
/* That pad will proxy caps and link */
gst_pad_set_link_function (sinkpad,
- GST_DEBUG_FUNCPTR (gst_pad_proxy_pad_link));
+ GST_DEBUG_FUNCPTR (gst_pad_proxy_pad_link));
gst_pad_set_getcaps_function (sinkpad,
- GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
-
+ GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
+
gst_element_add_pad (GST_ELEMENT (gstswitch), sinkpad);
-
+
switchpad = g_new0 (GstSwitchPad, 1);
if (!switchpad)
return NULL;
-
+
switchpad->sinkpad = sinkpad;
switchpad->data = NULL;
switchpad->forwarded = FALSE;
switchpad->eos = FALSE;
-
+
gstswitch->sinkpads = g_list_insert (gstswitch->sinkpads, switchpad,
- gstswitch->nb_sinkpads);
+ gstswitch->nb_sinkpads);
gstswitch->nb_sinkpads++;
-
+
if (GST_PAD_CAPS (gstswitch->srcpad)) {
gst_pad_try_set_caps (sinkpad, GST_PAD_CAPS (gstswitch->srcpad));
}
-
+
return sinkpad;
}
static gboolean
-gst_switch_poll_sinkpads (GstSwitch *gstswitch)
+gst_switch_poll_sinkpads (GstSwitch * gstswitch)
{
GList *pads;
-
+
g_return_val_if_fail (gstswitch != NULL, FALSE);
g_return_val_if_fail (GST_IS_SWITCH (gstswitch), FALSE);
-
+
pads = gstswitch->sinkpads;
-
+
while (pads) {
GstSwitchPad *switchpad = pads->data;
-
+
/* We only pull from usable pads and non EOS pads */
if (GST_PAD_IS_USABLE (switchpad->sinkpad) && !switchpad->eos) {
-
+
GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, gstswitch,
- "polling pad %p",
- switchpad->sinkpad);
-
+ "polling pad %p", switchpad->sinkpad);
+
/* We loose the reference to the data we stored */
if (switchpad->data) {
- gst_data_unref (switchpad->data);
+ gst_data_unref (switchpad->data);
}
-
+
/* If that data was not forwarded we unref it another time to destroy it */
if (!switchpad->forwarded && switchpad->data) {
- gst_data_unref (switchpad->data);
+ gst_data_unref (switchpad->data);
}
-
+
switchpad->data = NULL;
switchpad->data = gst_pad_pull (switchpad->sinkpad);
-
+
if (!switchpad->data) {
- GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, gstswitch,
- "received NULL data from pad %p",
- switchpad->sinkpad);
+ GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, gstswitch,
+ "received NULL data from pad %p", switchpad->sinkpad);
+ } else {
+ gst_data_ref (switchpad->data);
+ switchpad->forwarded = FALSE;
+
+ /* If the buffer is an EOS event we tag the pad as being in EOS. That
+ means we won't try to pull more data from that pad */
+ if (GST_IS_EVENT (switchpad->data) &&
+ (GST_EVENT_TYPE (GST_EVENT (switchpad->data)) == GST_EVENT_EOS)) {
+ GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, gstswitch,
+ "received EOS event on pad %p", switchpad->sinkpad);
+ switchpad->eos = TRUE;
+ }
}
- else {
- gst_data_ref (switchpad->data);
- switchpad->forwarded = FALSE;
-
- /* If the buffer is an EOS event we tag the pad as being in EOS. That
- means we won't try to pull more data from that pad */
- if (GST_IS_EVENT (switchpad->data) &&
- (GST_EVENT_TYPE (GST_EVENT (switchpad->data)) == GST_EVENT_EOS)) {
- GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, gstswitch,
- "received EOS event on pad %p",
- switchpad->sinkpad);
- switchpad->eos = TRUE;
- }
- }
- }
- else {
+ } else {
GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, gstswitch,
- "not pulling from pad %s (eos is %d)",
- gst_pad_get_name (switchpad->sinkpad),
- switchpad->eos);
+ "not pulling from pad %s (eos is %d)",
+ gst_pad_get_name (switchpad->sinkpad), switchpad->eos);
}
pads = g_list_next (pads);
}
-
+
return TRUE;
}
-static void
-gst_switch_loop (GstElement *element)
+static void
+gst_switch_loop (GstElement * element)
{
GstSwitch *gstswitch = NULL;
GstSwitchPad *switchpad = NULL;
-
+
g_return_if_fail (element != NULL);
g_return_if_fail (GST_IS_SWITCH (element));
-
+
gstswitch = GST_SWITCH (element);
-
+
/* We poll all our sinkpads */
gst_switch_poll_sinkpads (gstswitch);
-
+
/* We get the active sinkpad */
switchpad = g_list_nth_data (gstswitch->sinkpads, gstswitch->active_sinkpad);
-
+
if (switchpad && switchpad->data) {
GstData *data = switchpad->data;
-
+
/* Loose our reference to that data */
gst_data_unref (switchpad->data);
switchpad->data = NULL;
-
+
GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, gstswitch,
- "using data from active pad %p",
- switchpad->sinkpad);
-
+ "using data from active pad %p", switchpad->sinkpad);
+
if (GST_IS_EVENT (data)) {
GstEvent *event = GST_EVENT (data);
+
GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, gstswitch,
- "handling event from active pad %p",
- switchpad->sinkpad);
+ "handling event from active pad %p", switchpad->sinkpad);
/* Handling event */
gst_pad_event_default (switchpad->sinkpad, event);
- }
- else {
+ } else {
/* Pushing active sinkpad data to srcpad */
GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, gstswitch,
- "pushing data from active pad %p to %p",
- switchpad->sinkpad, gstswitch->srcpad);
+ "pushing data from active pad %p to %p",
+ switchpad->sinkpad, gstswitch->srcpad);
gst_pad_push (gstswitch->srcpad, data);
}
-
+
/* Mark this data as forwarded so that it won't get unrefed on next poll */
switchpad->forwarded = TRUE;
}
}
static GstElementStateReturn
-gst_switch_change_state (GstElement *element)
+gst_switch_change_state (GstElement * element)
{
GstSwitch *gstswitch;
case GST_STATE_PAUSED_TO_PLAYING:
break;
case GST_STATE_PLAYING_TO_PAUSED:
- {
- GList *sinkpads = NULL;
-
- sinkpads = gstswitch->sinkpads;
-
- while (sinkpads) {
- GstSwitchPad *switchpad = sinkpads->data;
-
- /* If a data is still stored in our structure we unref it */
- if (switchpad->data) {
- gst_data_unref (switchpad->data);
- switchpad->data = NULL;
- }
-
- switchpad->forwarded = FALSE;
- switchpad->eos = FALSE;
-
- sinkpads = g_list_next (sinkpads);
- }
+ {
+ GList *sinkpads = NULL;
+
+ sinkpads = gstswitch->sinkpads;
+
+ while (sinkpads) {
+ GstSwitchPad *switchpad = sinkpads->data;
+
+ /* If a data is still stored in our structure we unref it */
+ if (switchpad->data) {
+ gst_data_unref (switchpad->data);
+ switchpad->data = NULL;
+ }
+
+ switchpad->forwarded = FALSE;
+ switchpad->eos = FALSE;
+
+ sinkpads = g_list_next (sinkpads);
}
+ }
break;
case GST_STATE_PAUSED_TO_READY:
break;
if (GST_ELEMENT_CLASS (parent_class)->change_state)
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
- else
+ else
return GST_STATE_SUCCESS;
}
/* =========================================== */
static void
-gst_switch_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
+gst_switch_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstSwitch *gstswitch = NULL;
-
+
g_return_if_fail (GST_IS_SWITCH (object));
-
+
gstswitch = GST_SWITCH (object);
-
+
switch (prop_id) {
case ARG_ACTIVE_SOURCE:
gstswitch->active_sinkpad = g_value_get_int (value);
}
static void
-gst_switch_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
+gst_switch_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
GstSwitch *gstswitch = NULL;
-
+
g_return_if_fail (GST_IS_SWITCH (object));
-
+
gstswitch = GST_SWITCH (object);
-
+
switch (prop_id) {
case ARG_ACTIVE_SOURCE:
g_value_set_int (value, gstswitch->active_sinkpad);
/* =========================================== */
static void
-gst_switch_dispose (GObject *object)
+gst_switch_dispose (GObject * object)
{
GstSwitch *gstswitch = NULL;
GList *sinkpads = NULL;
-
+
gstswitch = GST_SWITCH (object);
sinkpads = gstswitch->sinkpads;
-
+
while (sinkpads) {
GstSwitchPad *switchpad = sinkpads->data;
-
+
/* If a data is still stored in our structure we unref it */
if (switchpad->data) {
gst_data_unref (switchpad->data);
switchpad->data = NULL;
}
-
+
/* Freeing our structure */
g_free (switchpad);
-
+
sinkpads = g_list_next (sinkpads);
}
-
+
/* Freeing the list correctly */
- if (gstswitch->sinkpads) {
+ if (gstswitch->sinkpads) {
g_list_free (gstswitch->sinkpads);
gstswitch->sinkpads = NULL;
}
-
+
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
-gst_switch_init (GstSwitch *gstswitch)
+gst_switch_init (GstSwitch * gstswitch)
{
gstswitch->srcpad = gst_pad_new ("src", GST_PAD_SRC);
gst_element_add_pad (GST_ELEMENT (gstswitch), gstswitch->srcpad);
gst_pad_set_link_function (gstswitch->srcpad,
- GST_DEBUG_FUNCPTR (gst_pad_proxy_pad_link));
+ GST_DEBUG_FUNCPTR (gst_pad_proxy_pad_link));
gst_pad_set_getcaps_function (gstswitch->srcpad,
- GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
+ GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
gst_element_set_loop_function (GST_ELEMENT (gstswitch), gst_switch_loop);
-
+
gstswitch->sinkpads = NULL;
gstswitch->active_sinkpad = 0;
gstswitch->nb_sinkpads = 0;
gst_switch_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
+
gst_element_class_set_details (element_class, &gst_switch_details);
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&gst_switch_sink_factory));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_switch_sink_factory));
}
static void
-gst_switch_class_init (GstSwitchClass *klass)
+gst_switch_class_init (GstSwitchClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
gstelement_class = (GstElementClass *) klass;
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
-
+
g_object_class_install_property (gobject_class,
- ARG_NB_SOURCES,
- g_param_spec_int ("nb_sources",
- "number of sources",
- "number of sources",
- G_MININT, G_MAXINT, 0,
- G_PARAM_READABLE));
+ ARG_NB_SOURCES,
+ g_param_spec_int ("nb_sources",
+ "number of sources",
+ "number of sources", G_MININT, G_MAXINT, 0, G_PARAM_READABLE));
g_object_class_install_property (gobject_class,
- ARG_ACTIVE_SOURCE,
- g_param_spec_int ("active_source",
- "active source",
- "active source",
- G_MININT, G_MAXINT, 0,
- G_PARAM_READWRITE));
-
+ ARG_ACTIVE_SOURCE,
+ g_param_spec_int ("active_source",
+ "active source",
+ "active source", G_MININT, G_MAXINT, 0, G_PARAM_READWRITE));
+
gobject_class->dispose = gst_switch_dispose;
gobject_class->set_property = gst_switch_set_property;
gobject_class->get_property = gst_switch_get_property;
-
+
gstelement_class->change_state = gst_switch_change_state;
gstelement_class->request_new_pad = gst_switch_request_new_pad;
gstelement_class->release_pad = gst_switch_release_pad;
static GType switch_type = 0;
if (!switch_type) {
- static const GTypeInfo switch_info = {
- sizeof(GstSwitchClass),
- gst_switch_base_init,
- NULL,
- (GClassInitFunc) gst_switch_class_init,
- NULL,
- NULL,
- sizeof(GstSwitch),
- 0,
- (GInstanceInitFunc) gst_switch_init,
- };
-
- switch_type = g_type_register_static (GST_TYPE_ELEMENT,
- "GstSwitch", &switch_info, 0);
+ static const GTypeInfo switch_info = {
+ sizeof (GstSwitchClass),
+ gst_switch_base_init,
+ NULL,
+ (GClassInitFunc) gst_switch_class_init,
+ NULL,
+ NULL,
+ sizeof (GstSwitch),
+ 0,
+ (GInstanceInitFunc) gst_switch_init,
+ };
+
+ switch_type = g_type_register_static (GST_TYPE_ELEMENT,
+ "GstSwitch", &switch_info, 0);
}
-
+
return switch_type;
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
return gst_element_register (plugin, "switch", GST_RANK_NONE,
- GST_TYPE_SWITCH);
+ GST_TYPE_SWITCH);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "switch",
- "N-to-1 input switching",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "switch",
+ "N-to-1 input switching",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
-
+
#ifndef __GST_SWITCH_H__
#define __GST_SWITCH_H__
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_TYPE_SWITCH \
(gst_switch_get_type())
#define GST_SWITCH(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_SWITCH))
#define GST_IS_SWITCH_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_SWITCH))
-
typedef struct _GstSwitchPad GstSwitchPad;
typedef struct _GstSwitch GstSwitch;
typedef struct _GstSwitchClass GstSwitchClass;
-struct _GstSwitchPad {
+struct _GstSwitchPad
+{
GstPad *sinkpad;
GstData *data;
gboolean forwarded;
gboolean eos;
};
-struct _GstSwitch {
+struct _GstSwitch
+{
GstElement element;
-
+
GList *sinkpads;
GstPad *srcpad;
-
+
guint nb_sinkpads;
guint active_sinkpad;
};
-struct _GstSwitchClass {
+struct _GstSwitchClass
+{
GstElementClass parent_class;
};
GType gst_switch_get_type (void);
G_END_DECLS
-
#endif /* __GST_SWITCH_H__ */
//typedef struct _GstVBIDec GstVBIDec;
typedef struct _GstVBIDecClass GstVBIDecClass;
-struct _GstVBIDec {
- GstElement element;
+struct _GstVBIDec
+{
+ GstElement element;
/* pads */
- GstPad *sinkpad,
- *srcpad;
- char caption[128];
- vbiscreen_t *vbiscreen;
- vbidata_t *vbidata;
- int caption_type;
- gboolean dvd_input;
+ GstPad *sinkpad, *srcpad;
+ char caption[128];
+ vbiscreen_t *vbiscreen;
+ vbidata_t *vbidata;
+ int caption_type;
+ gboolean dvd_input;
};
-struct _GstVBIDecClass {
+struct _GstVBIDecClass
+{
GstElementClass parent_class;
};
-GType gst_vbidec_get_type(void);
+GType gst_vbidec_get_type (void);
/* elementfactory information */
-static GstElementDetails gst_vbidec_details = GST_ELEMENT_DETAILS (
- "VBI decoder",
- "Codec/Decoder/Video",
- "Decodes closed captions and XDS data from VBI data",
- "David I. Lehn <dlehn@users.sourceforge.net>"
-);
+static GstElementDetails gst_vbidec_details =
+GST_ELEMENT_DETAILS ("VBI decoder",
+ "Codec/Decoder/Video",
+ "Decodes closed captions and XDS data from VBI data",
+ "David I. Lehn <dlehn@users.sourceforge.net>");
/* VBIDec signals and args */
-enum {
+enum
+{
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_VERBOSE,
ARG_CAPTION_TYPE,
};
static GstStaticPadTemplate gst_vbidec_sink_template =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS_ANY
-);
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS_ANY);
static GstStaticPadTemplate gst_vbidec_src_template =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ( "text/plain" )
-);
+GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("text/plain")
+ );
#define GST_TYPE_VBIDEC_CAPTION_TYPE_TYPE (gst_vbidec_caption_type_get_type())
{
static GType vbidec_caption_type_type = 0;
static GEnumValue vbidec_caption_type[] = {
- { CAPTURE_OFF, "0", "Closed Captions off"},
- { CAPTURE_CC1, "1", "Closed Caption CC1"},
- { CAPTURE_CC2, "2", "Closed Caption CC2"},
- { CAPTURE_CC3, "4", "Closed Caption CC3"},
- { CAPTURE_CC4, "5", "Closed Caption CC4"},
- { CAPTURE_T1, "6", "Closed Caption T1"},
- { CAPTURE_T2, "7", "Closed Caption T2"},
- { CAPTURE_T3, "8", "Closed Caption T3"},
- { CAPTURE_T4, "9", "Closed Caption T4"},
+ {CAPTURE_OFF, "0", "Closed Captions off"},
+ {CAPTURE_CC1, "1", "Closed Caption CC1"},
+ {CAPTURE_CC2, "2", "Closed Caption CC2"},
+ {CAPTURE_CC3, "4", "Closed Caption CC3"},
+ {CAPTURE_CC4, "5", "Closed Caption CC4"},
+ {CAPTURE_T1, "6", "Closed Caption T1"},
+ {CAPTURE_T2, "7", "Closed Caption T2"},
+ {CAPTURE_T3, "8", "Closed Caption T3"},
+ {CAPTURE_T4, "9", "Closed Caption T4"},
{0, NULL, NULL},
};
if (!vbidec_caption_type_type) {
- vbidec_caption_type_type = g_enum_register_static ("GstVBIDecCaptionTypeType", vbidec_caption_type);
+ vbidec_caption_type_type =
+ g_enum_register_static ("GstVBIDecCaptionTypeType",
+ vbidec_caption_type);
}
return vbidec_caption_type_type;
}
-static void gst_vbidec_base_init (gpointer g_class);
-static void gst_vbidec_class_init (GstVBIDecClass *klass);
-static void gst_vbidec_init (GstVBIDec *vbidec);
+static void gst_vbidec_base_init (gpointer g_class);
+static void gst_vbidec_class_init (GstVBIDecClass * klass);
+static void gst_vbidec_init (GstVBIDec * vbidec);
-static void gst_vbidec_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_vbidec_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static void gst_vbidec_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_vbidec_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static void gst_vbidec_chain (GstPad *pad, GstData *_data);
+static void gst_vbidec_chain (GstPad * pad, GstData * _data);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_vbidec_signals[LAST_SIGNAL] = { 0 };*/
GType
if (!vbidec_type) {
static const GTypeInfo vbidec_info = {
- sizeof(GstVBIDecClass),
+ sizeof (GstVBIDecClass),
gst_vbidec_base_init,
NULL,
- (GClassInitFunc)gst_vbidec_class_init,
+ (GClassInitFunc) gst_vbidec_class_init,
NULL,
NULL,
- sizeof(GstVBIDec),
+ sizeof (GstVBIDec),
0,
- (GInstanceInitFunc)gst_vbidec_init,
+ (GInstanceInitFunc) gst_vbidec_init,
};
- vbidec_type = g_type_register_static(GST_TYPE_ELEMENT, "GstVBIDec", &vbidec_info, 0);
+ vbidec_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstVBIDec", &vbidec_info, 0);
}
return vbidec_type;
}
gst_static_pad_template_get (&gst_vbidec_sink_template));
}
static void
-gst_vbidec_class_init(GstVBIDecClass *klass)
+gst_vbidec_class_init (GstVBIDecClass * 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);
- gobject_class->set_property = gst_vbidec_set_property;
- gobject_class->get_property = gst_vbidec_get_property;
+ gobject_class->set_property = gst_vbidec_set_property;
+ gobject_class->get_property = gst_vbidec_get_property;
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VERBOSE,
g_param_spec_boolean ("verbose", "verbose", "verbose",
- FALSE, G_PARAM_WRITABLE));
+ FALSE, G_PARAM_WRITABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_CAPTION_TYPE,
g_param_spec_enum ("caption type", "caption type", "Closed Caption Type",
- GST_TYPE_VBIDEC_CAPTION_TYPE_TYPE, CAPTURE_OFF, G_PARAM_READWRITE));
+ GST_TYPE_VBIDEC_CAPTION_TYPE_TYPE, CAPTURE_OFF, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DVD_INPUT,
- g_param_spec_boolean ("dvd input", "dvd input", "VBI is encapsulated in MPEG2 GOP user_data field (as on DVDs)",
- FALSE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("dvd input", "dvd input",
+ "VBI is encapsulated in MPEG2 GOP user_data field (as on DVDs)",
+ FALSE, G_PARAM_READWRITE));
}
static void
-gst_vbidec_init (GstVBIDec *vbidec)
+gst_vbidec_init (GstVBIDec * vbidec)
{
/* create the sink and src pads */
- vbidec->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&gst_vbidec_sink_template), "sink");
+ vbidec->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_vbidec_sink_template), "sink");
gst_element_add_pad (GST_ELEMENT (vbidec), vbidec->sinkpad);
- gst_pad_set_chain_function (vbidec->sinkpad, GST_DEBUG_FUNCPTR (gst_vbidec_chain));
+ gst_pad_set_chain_function (vbidec->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_vbidec_chain));
- vbidec->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&gst_vbidec_src_template), "src");
+ vbidec->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_vbidec_src_template), "src");
gst_element_add_pad (GST_ELEMENT (vbidec), vbidec->srcpad);
- vbidec->vbiscreen = vbiscreen_new(0, 0, 1.0, 0, (void *)vbidec);
- vbidec->vbidata = vbidata_new_line(vbidec->vbiscreen, 0);
+ vbidec->vbiscreen = vbiscreen_new (0, 0, 1.0, 0, (void *) vbidec);
+ vbidec->vbidata = vbidata_new_line (vbidec->vbiscreen, 0);
vbidec->caption_type = CAPTURE_OFF;
- vbidata_capture_mode(vbidec->vbidata, vbidec->caption_type);
+ vbidata_capture_mode (vbidec->vbidata, vbidec->caption_type);
vbidec->dvd_input = FALSE;
}
static void
-line21_decode(GstVBIDec *vbidec, guint8 *data, guint32 size)
+line21_decode (GstVBIDec * vbidec, guint8 * data, guint32 size)
{
- vbidata_process_line(vbidec->vbidata, data, 0);
+ vbidata_process_line (vbidec->vbidata, data, 0);
}
static void
-dvd_user_data_decode(GstVBIDec *vbidec, guint8 *data, guint32 size)
+dvd_user_data_decode (GstVBIDec * vbidec, guint8 * data, guint32 size)
{
//char caption[128];
//int ci; /* caption index */
- int i; /* buf index */
+ int i; /* buf index */
int num_disp_field;
guint8 b1, b2;
int w;
//g_print("== %p %d\n", data, size);
i = 0;
/* Check for Closed Captioning data */
- if (data[i] != 0x43 || data[i+1] != 0x43 ||
- data[i+2] != 0x01 || data[i+3] != 0xf8) {
+ if (data[i] != 0x43 || data[i + 1] != 0x43 ||
+ data[i + 2] != 0x01 || data[i + 3] != 0xf8) {
g_print ("non-CC data\n");
return;
}
//g_print ("CC data\n");
- i += 4; /* above */
- i += 4; /* ? */
+ i += 4; /* above */
+ i += 4; /* ? */
num_disp_field = data[i] & 0x3f;
//g_print ("ndf %d\n", num_disp_field);
while ((data[i] & 0xfe) == 0xfe) {
if (data[i] & 0x1) {
- b1 = data[i+1] & 0x7f;
- b2 = data[i+2] & 0x7f;
+ b1 = data[i + 1] & 0x7f;
+ b2 = data[i + 2] & 0x7f;
w = (b2 << 8) | b1;
- vbidata_process_16b(vbidec->vbidata, 0, w);
+ vbidata_process_16b (vbidec->vbidata, 0, w);
}
i += 3;
}
}
static void
-gst_vbidec_chain (GstPad *pad, GstData *_data)
+gst_vbidec_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstVBIDec *vbidec = GST_VBIDEC (gst_pad_get_parent (pad));
pts = GST_BUFFER_TIMESTAMP (buf);
/*
- g_print("** user_data: addr:%p len:%d state:%d\n", data, size, 0);
- {
- int i;
- guint8 ud;
- g_print("** \"");
- for (i=0; i<size; i++) {
- ud = data[i];
- if (isprint((char)ud)) {
- g_print("%c", (char)ud);
- } else {
- g_print("[0x%02x]", ud);
- }
- }
- g_print("\"\n");
- }
- */
+ g_print("** user_data: addr:%p len:%d state:%d\n", data, size, 0);
+ {
+ int i;
+ guint8 ud;
+ g_print("** \"");
+ for (i=0; i<size; i++) {
+ ud = data[i];
+ if (isprint((char)ud)) {
+ g_print("%c", (char)ud);
+ } else {
+ g_print("[0x%02x]", ud);
+ }
+ }
+ g_print("\"\n");
+ }
+ */
if (vbidec->dvd_input) {
- dvd_user_data_decode(vbidec, data, size);
+ dvd_user_data_decode (vbidec, data, size);
} else {
- line21_decode(vbidec, data, size);
+ line21_decode (vbidec, data, size);
}
- gst_buffer_unref(buf);
+ gst_buffer_unref (buf);
}
void
-gst_vbidec_show_text (GstVBIDec *vbidec, char *text, int len)
+gst_vbidec_show_text (GstVBIDec * vbidec, char *text, int len)
{
//fprintf(stderr, "%*s\n", len, text);
if (len > 0) {
if (GST_PAD_IS_USABLE (vbidec->srcpad)) {
GstBuffer *buf = gst_buffer_new_and_alloc (len);
+
memcpy (GST_BUFFER_DATA (buf), text, len);
GST_BUFFER_SIZE (buf) = len;
// FIXME
}
static void
-gst_vbidec_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_vbidec_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstVBIDec *vbidec;
switch (prop_id) {
case ARG_VERBOSE:
- vbidata_set_verbose(vbidec->vbidata, g_value_get_boolean (value));
- vbiscreen_set_verbose(vbidec->vbiscreen, g_value_get_boolean (value));
+ vbidata_set_verbose (vbidec->vbidata, g_value_get_boolean (value));
+ vbiscreen_set_verbose (vbidec->vbiscreen, g_value_get_boolean (value));
break;
case ARG_DVD_INPUT:
- vbidec->dvd_input = g_value_get_boolean(value);
+ vbidec->dvd_input = g_value_get_boolean (value);
break;
case ARG_CAPTION_TYPE:
- vbidec->caption_type = g_value_get_enum(value);
- vbidata_capture_mode(vbidec->vbidata, vbidec->caption_type);
+ vbidec->caption_type = g_value_get_enum (value);
+ vbidata_capture_mode (vbidec->vbidata, vbidec->caption_type);
break;
default:
break;
}
static void
-gst_vbidec_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_vbidec_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstVBIDec *vbidec;
switch (prop_id) {
case ARG_DVD_INPUT:
- g_value_set_boolean(value, vbidec->dvd_input);
+ g_value_set_boolean (value, vbidec->dvd_input);
break;
case ARG_CAPTION_TYPE:
- g_value_set_enum(value, vbidec->caption_type);
+ g_value_set_enum (value, vbidec->caption_type);
break;
default:
break;
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- return gst_element_register (plugin, "vbidec", GST_RANK_NONE, GST_TYPE_VBIDEC);
+ return gst_element_register (plugin, "vbidec", GST_RANK_NONE,
+ GST_TYPE_VBIDEC);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "vbidec",
- "Decodes closed captions and XDS data from VBI data",
- plugin_init,
- VERSION,
- "GPL",
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "vbidec",
+ "Decodes closed captions and XDS data from VBI data",
+ plugin_init, VERSION, "GPL", GST_PACKAGE, GST_ORIGIN)
typedef struct _GstVBIDec GstVBIDec;
-void gst_vbidec_show_text (GstVBIDec *vbidec, char *text, int len);
+void gst_vbidec_show_text (GstVBIDec * vbidec, char *text, int len);
struct vbidata_s
{
- int fd;
- vbiscreen_t *vs;
- /*tvtime_osd_t *osd;*/
- char buf[ 65536 ];
- int wanttop;
- int wanttext;
-
- unsigned int colour;
- int row, ital;
- int indent, ul;
- int chan;
-
- unsigned int current_colour;
- int current_row, current_ital;
- int current_indent, current_ul;
- int current_chan;
- int current_istext;
-
- int initialised;
- int enabled;
- int lastcode;
- int lastcount;
- int verbose;
-
- /* XDS data */
- char xds_packet[ 2048 ];
- int xds_cursor;
-
- char *program_name;
- char *network_name;
- char *call_letters;
- const char *rating;
- const char *program_type;
- int start_day;
- int start_month;
- int start_min;
- int start_hour;
- int length_hour;
- int length_min;
- int length_elapsed_hour;
- int length_elapsed_min;
- int length_elapsed_sec;
- char *program_desc[8];
+ int fd;
+ vbiscreen_t *vs;
+ /*tvtime_osd_t *osd; */
+ char buf[65536];
+ int wanttop;
+ int wanttext;
+
+ unsigned int colour;
+ int row, ital;
+ int indent, ul;
+ int chan;
+
+ unsigned int current_colour;
+ int current_row, current_ital;
+ int current_indent, current_ul;
+ int current_chan;
+ int current_istext;
+
+ int initialised;
+ int enabled;
+ int lastcode;
+ int lastcount;
+ int verbose;
+
+ /* XDS data */
+ char xds_packet[2048];
+ int xds_cursor;
+
+ char *program_name;
+ char *network_name;
+ char *call_letters;
+ const char *rating;
+ const char *program_type;
+ int start_day;
+ int start_month;
+ int start_min;
+ int start_hour;
+ int length_hour;
+ int length_min;
+ int length_elapsed_hour;
+ int length_elapsed_min;
+ int length_elapsed_sec;
+ char *program_desc[8];
};
/* this is NOT exactly right */
//static char *ccode = " !\"#$%&'()\0341+,-./0123456789:;<=>?@"
static char *ccode = " !\"#$%&'()a+,-./0123456789:;<=>?@"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
// "abcdefghijklmnopqrstuvwxyz"
// "[\0351]\0355\0363\0372abcdefghijklmnopqr"
- "[e]iouabcdefghijklmnopqr"
+ "[e]iouabcdefghijklmnopqr"
// "stuvwxyz\0347\0367\0245\0244\0240";
- "stuvwxyzcoNn ";
+ "stuvwxyzcoNn ";
static char *wccode = "\0256\0260\0275\0277T\0242\0243#\0340 "
- "\0350\0354\0362\0371";
+ "\0350\0354\0362\0371";
static char *extcode1 = "\0301\0311\0323\0332\0334\0374"
- "`\0241*'-\0251S*\"\"\0300\0302"
- "\0307\0310\0312\0313\0353\0316\0317\0357"
- "\0324\0331\0371\0333\0253\0273";
+ "`\0241*'-\0251S*\"\"\0300\0302"
+ "\0307\0310\0312\0313\0353\0316\0317\0357" "\0324\0331\0371\0333\0253\0273";
static char *extcode2 = "\0303\0343\0315\0314\0354\0322\0362\0325"
- "{}\\^_|~\0304\0344\0326\0366\0337\0245\0244|"
- "\0305\0345\0330\0370++++";
+ "{}\\^_|~\0304\0344\0326\0366\0337\0245\0244|" "\0305\0345\0330\0370++++";
-int parityok(int n)
+int
+parityok (int n)
{ /* check parity for 2 bytes packed in n */
- int j, k;
- for (k = 0, j = 0; j < 7; j++)
- if (n & (1 << j))
- k++;
- if ((k & 1) && (n & 0x80))
- return 0;
- for (k = 0, j = 8; j < 15; j++)
- if (n & (1 << j))
- k++;
- if ((k & 1) && (n & 0x8000))
- return 0;
- return 1;
+ int j, k;
+
+ for (k = 0, j = 0; j < 7; j++)
+ if (n & (1 << j))
+ k++;
+ if ((k & 1) && (n & 0x80))
+ return 0;
+ for (k = 0, j = 8; j < 15; j++)
+ if (n & (1 << j))
+ k++;
+ if ((k & 1) && (n & 0x8000))
+ return 0;
+ return 1;
}
-int decodebit(unsigned char *data, int threshold)
+int
+decodebit (unsigned char *data, int threshold)
{
- return ((data[0] + data[1] + data[2] + data[3] + data[4] + data[5] +
- data[6] + data[7] + data[8] + data[9] + data[10] + data[11] +
- data[12] + data[13] + data[14] + data[15] + data[16] + data[17] +
- data[18] + data[19] + data[20] + data[21] + data[22] + data[23] +
- data[24] + data[25] + data[26] + data[27] + data[28] + data[29] +
- data[30] + data[31])>>5 > threshold);
+ return ((data[0] + data[1] + data[2] + data[3] + data[4] + data[5] +
+ data[6] + data[7] + data[8] + data[9] + data[10] + data[11] +
+ data[12] + data[13] + data[14] + data[15] + data[16] + data[17] +
+ data[18] + data[19] + data[20] + data[21] + data[22] + data[23] +
+ data[24] + data[25] + data[26] + data[27] + data[28] + data[29] +
+ data[30] + data[31]) >> 5 > threshold);
}
-int ccdecode(unsigned char *vbiline)
+int
+ccdecode (unsigned char *vbiline)
{
- int max = 0, maxval = 0, minval = 255, i = 0, clk = 0, tmp = 0;
- int sample, packedbits = 0;
-
- for (i=0; i<250; i++) {
- sample = vbiline[i];
- if (sample - maxval > 10)
- (maxval = sample, max = i);
- if (sample < minval)
- minval = sample;
- if (maxval - sample > 40)
- break;
- }
- sample = ((maxval + minval) >> 1);
- pll = max;
-
- /* found clock lead-in, double-check start */
+ int max = 0, maxval = 0, minval = 255, i = 0, clk = 0, tmp = 0;
+ int sample, packedbits = 0;
+
+ for (i = 0; i < 250; i++) {
+ sample = vbiline[i];
+ if (sample - maxval > 10)
+ (maxval = sample, max = i);
+ if (sample < minval)
+ minval = sample;
+ if (maxval - sample > 40)
+ break;
+ }
+ sample = ((maxval + minval) >> 1);
+ pll = max;
+
+ /* found clock lead-in, double-check start */
#ifndef PAL_DECODE
- i = max + 478;
+ i = max + 478;
#else
- i = max + 538;
+ i = max + 538;
#endif
- if (!decodebit(&vbiline[i], sample))
- return 0;
+ if (!decodebit (&vbiline[i], sample))
+ return 0;
#ifndef PAL_DECODE
- tmp = i + 57; /* tmp = data bit zero */
+ tmp = i + 57; /* tmp = data bit zero */
#else
- tmp = i + 71;
+ tmp = i + 71;
#endif
- for (i = 0; i < 16; i++) {
+ for (i = 0; i < 16; i++) {
#ifndef PAL_DECODE
- clk = tmp + i * 57;
+ clk = tmp + i * 57;
#else
- clk = tmp + i * 71;
+ clk = tmp + i * 71;
#endif
- if (decodebit(&vbiline[clk], sample)) {
- packedbits |= 1 << i;
- }
+ if (decodebit (&vbiline[clk], sample)) {
+ packedbits |= 1 << i;
}
- if (parityok(packedbits))
- return packedbits;
- return 0;
+ }
+ if (parityok (packedbits))
+ return packedbits;
+ return 0;
} /* ccdecode */
-const char *movies[] = { "N/A", "G", "PG", "PG-13", "R",
- "NC-17", "X", "Not Rated" };
-const char *usa_tv[] = { "Not Rated", "TV-Y", "TV-Y7", "TV-G",
- "TV-PG", "TV-14", "TV-MA", "Not Rated" };
-const char *cane_tv[] = { "Exempt", "C", "C8+", "G", "PG",
- "14+", "18+", "Reserved" };
-const char *canf_tv[] = { "Exempt", "G", "8 ans +", "13 ans +",
- "16 ans +", "18 ans +", "Reserved",
- "Reserved" };
+const char *movies[] = { "N/A", "G", "PG", "PG-13", "R",
+ "NC-17", "X", "Not Rated"
+};
+const char *usa_tv[] = { "Not Rated", "TV-Y", "TV-Y7", "TV-G",
+ "TV-PG", "TV-14", "TV-MA", "Not Rated"
+};
+const char *cane_tv[] = { "Exempt", "C", "C8+", "G", "PG",
+ "14+", "18+", "Reserved"
+};
+const char *canf_tv[] = { "Exempt", "G", "8 ans +", "13 ans +",
+ "16 ans +", "18 ans +", "Reserved",
+ "Reserved"
+};
const char *months[] = { 0, "Jan", "Feb", "Mar", "Apr", "May",
- "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
+ "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
+};
-static const char *eia608_program_type[ 96 ] = {
+static const char *eia608_program_type[96] = {
"education", "entertainment", "movie", "news", "religious", "sports",
"other", "action", "advertisement", "animated", "anthology",
"automobile", "awards", "baseball", "basketball", "bulletin", "business",
};
-static void parse_xds_packet( vbidata_t *vbi, char *packet, int length )
+static void
+parse_xds_packet (vbidata_t * vbi, char *packet, int length)
{
- int sum = 0;
- int i;
-
- if( !vbi ) return;
-
- /* Check the checksum for validity of the packet. */
- for( i = 0; i < length - 1; i++ ) {
- sum += packet[ i ];
+ int sum = 0;
+ int i;
+
+ if (!vbi)
+ return;
+
+ /* Check the checksum for validity of the packet. */
+ for (i = 0; i < length - 1; i++) {
+ sum += packet[i];
+ }
+ if ((((~sum) & 0x7f) + 1) != packet[length - 1]) {
+ return;
+ }
+
+ /* Stick a null at the end, and cut off the last two characters. */
+ packet[length - 2] = '\0';
+ length -= 2;
+
+ if (packet[0] == 0x01 && packet[1] == 0x03) {
+ if (vbi->program_name && !strcmp (vbi->program_name, packet + 2)) {
+ return;
}
- if( (((~sum) & 0x7f) + 1) != packet[ length - 1 ] ) {
- return;
+ if (vbi->verbose)
+ fprintf (stderr, "Current program name: '%s'\n", packet + 2);
+ if (vbi->program_name)
+ free (vbi->program_name);
+ vbi->program_name = strdup (packet + 2);
+ /*tvtime_osd_set_show_name( vbi->osd, vbi->program_name ); */
+ } else if (packet[0] == 0x03 && packet[1] == 0x03) {
+ if (vbi->verbose)
+ fprintf (stderr, "Future program name: '%s'\n", packet + 2);
+ } else if (packet[0] == 0x05 && packet[1] == 0x01) {
+ if (vbi->network_name && !strcmp (vbi->network_name, packet + 2)) {
+ return;
}
- /* Stick a null at the end, and cut off the last two characters. */
- packet[ length - 2 ] = '\0';
- length -= 2;
-
- if( packet[ 0 ] == 0x01 && packet[ 1 ] == 0x03 ) {
- if( vbi->program_name && !strcmp(vbi->program_name, packet + 2 ) ) {
- return;
- }
- if( vbi->verbose ) fprintf( stderr, "Current program name: '%s'\n", packet + 2 );
- if( vbi->program_name ) free( vbi->program_name );
- vbi->program_name = strdup(packet + 2);
- /*tvtime_osd_set_show_name( vbi->osd, vbi->program_name );*/
- } else if( packet[ 0 ] == 0x03 && packet[ 1 ] == 0x03 ) {
- if( vbi->verbose ) fprintf( stderr, "Future program name: '%s'\n", packet + 2 );
- } else if( packet[ 0 ] == 0x05 && packet[ 1 ] == 0x01 ) {
- if( vbi->network_name && !strcmp(vbi->network_name, packet + 2 ) ) {
- return;
- }
-
- if( vbi->verbose ) fprintf( stderr, "Network name: '%s'\n", packet + 2 );
- if( vbi->network_name ) free( vbi->network_name );
- vbi->network_name = strdup( packet + 2 );
- /*tvtime_osd_set_network_name( vbi->osd, vbi->network_name );*/
- } else if( packet[ 0 ] == 0x01 && packet[ 1 ] == 0x05 ) {
- int movie_rating = packet[ 2 ] & 7;
- int scheme = (packet[ 2 ] & 56) >> 3;
- int tv_rating = packet[ 3 ] & 7;
- int VSL = packet[ 3 ] & 56;
- const char * str;
-
- switch( VSL | scheme ) {
- case 3: /* Canadian English TV */
- str = cane_tv[ tv_rating ];
- break;
- case 7: /* Canadian French TV */
- str = canf_tv[ tv_rating ];
- break;
- case 19: /* Reserved */
- case 31:
- str = "";
- break;
- default:
- if( ((VSL | scheme) & 3) == 1 ) {
- /* USA TV */
- str = usa_tv[ tv_rating ];
- } else {
- /* MPAA Movie Rating */
- str = movies[ movie_rating ];
- }
- break;
- }
-
- if( vbi->rating && !strcmp(vbi->rating, str ) ) {
- return;
- }
-
- if( vbi->verbose ) fprintf( stderr, "Show rating: %s", str );
- if( ((VSL | scheme) & 3) == 1 || ((VSL | scheme) & 3) == 0 ) {
- /* show VSLD for the americans */
- if( (VSL | scheme) & 32 ) {
- if( vbi->verbose ) fprintf( stderr, " V" );
- }
- if( (VSL | scheme) & 16 ) {
- if( vbi->verbose ) fprintf( stderr, " S" );
- }
- if( (VSL | scheme) & 8 ) {
- if( vbi->verbose ) fprintf( stderr, " L" );
- }
- if( (VSL | scheme) & 4 ) {
- if( vbi->verbose ) fprintf( stderr, " D" );
- }
- }
- if( vbi->verbose ) fprintf( stderr, "\n" );
- vbi->rating = str;
- /*tvtime_osd_set_show_rating( vbi->osd, vbi->rating );*/
- } else if( packet[ 0 ] == 0x05 && packet[ 1 ] == 0x02 ) {
- if( vbi->call_letters && !strcmp(vbi->call_letters, packet + 2 ) ) {
- return;
- }
-
- if( vbi->verbose ) fprintf( stderr, "Network call letters: '%s'\n", packet + 2 );
- if( vbi->call_letters ) free( vbi->call_letters );
- vbi->call_letters = strdup( packet + 2 );
- /*tvtime_osd_set_network_call( vbi->osd, vbi->call_letters );*/
- } else if( packet[ 0 ] == 0x01 && packet[ 1 ] == 0x01 ) {
- int month = packet[5];// & 15;
- int day = packet[4];// & 31;
- int hour = packet[3];// & 31;
- int min = packet[2];// & 63;
- char str[33];
- if( vbi->verbose ) fprintf( stderr, "Program Start: %02d %s, %02d:%02d\n",
- day & 31, months[month & 15], hour & 31, min & 63 );
- // packet[ 3 ], packet[ 4 ], packet[ 5 ], packet[ 6 ] );
- //packet[ 5 ] & 31, packet[ 6 ], packet[ 4 ] & 31, packet[ 3 ] & 63 );
- vbi->start_month = month & 15;
- vbi->start_day = day & 31;
- vbi->start_hour = hour & 31;
- vbi->start_min = hour & 63;
- snprintf( str, 32, "%02d %s, %02d:%02d",
- day & 31, months[month & 15], hour & 31, min & 63 );
- /*tvtime_osd_set_show_start( vbi->osd, str );*/
- } else if( packet[ 0 ] == 0x01 && packet[ 1 ] == 0x04 ) {
- if( vbi->verbose ) fprintf( stderr, "Program type: " );
- for( i = 0; i < length - 2; i++ ) {
- int cur = packet[ 2 + i ] - 0x20;
- if( cur >= 0 && cur < 96 ) {
- if( vbi->verbose ) fprintf( stderr, "%s%s", i ? ", " : "", eia608_program_type[ cur ] );
- /* this will cause us to keep only the last type we check */
- vbi->program_type = eia608_program_type[ cur ];
- }
- }
- if( vbi->verbose ) fprintf( stderr, "\n" );
- } else if( packet[ 0 ] < 0x03 && packet[ 1 ] >= 0x10 && packet[ 1 ] <= 0x17 ) {
-
- if( vbi->program_desc[ packet[1] & 0xf ] &&
- !strcmp(vbi->program_desc[ packet[1] & 0xf ], packet + 2 ) ) {
- return;
- }
-
- if( vbi->verbose ) fprintf( stderr, "Program Description: Line %d", packet[1] & 0xf );
- if( vbi->verbose ) fprintf( stderr, "%s\n", packet + 2 );
- if( vbi->program_desc[ packet[1] & 0xf ] )
- free( vbi->program_desc[ packet[1] & 0xf ] );
- vbi->program_desc[ packet[1] & 0xf ] = strdup( packet + 2 );
- } else if( packet[ 0 ] == 0x01 && packet[ 1 ] == 0x02 ) {
- char str[ 33 ];
- str[0] = 0;
- if( vbi->verbose ) fprintf( stderr, "Program Length: %02d:%02d",
- packet[ 3 ] & 63, packet[ 2 ] & 63 );
- vbi->length_hour = packet[ 3 ] & 63;
- vbi->length_min = packet[ 2 ] & 63;
- snprintf( str, 32, "%02d:%02d",
- packet[ 3 ] & 63, packet[ 2 ] & 63 );
- if( length > 4 ) {
- if( vbi->verbose ) fprintf( stderr, " Elapsed: %02d:%02d", packet[ 5 ] & 63,
- packet[ 4 ] & 63 );
- vbi->length_elapsed_hour = packet[ 5 ] & 63;
- vbi->length_elapsed_min = packet[ 4 ] & 63;
- snprintf( str, 32, "%02d:%02d/%02d:%02d",
- packet[ 5 ] & 63, packet[ 4 ] & 63,
- packet[ 3 ] & 63, packet[ 2 ] & 63 );
- } else {
- vbi->length_elapsed_hour = 0;
- vbi->length_elapsed_min = 0;
- }
-
- if( length > 6 ) {
- if( vbi->verbose ) fprintf( stderr, ".%02d", packet[ 6 ] & 63 );
- vbi->length_elapsed_hour = packet[ 6 ] & 63;
- snprintf( str, 32, "%02d:%02d.%02d/%02d:%02d",
- packet[ 5 ] & 63, packet[ 4 ] & 63, packet[ 6 ] & 63,
- packet[ 3 ] & 63, packet[ 2 ] & 63 );
- } else {
- vbi->length_elapsed_hour = 0;
- }
- /*tvtime_osd_set_show_length( vbi->osd, str );*/
- if( vbi->verbose ) fprintf( stderr, "\n" );
- } else if( packet[ 0 ] == 0x05 && packet[ 1 ] == 0x04 ) {
- if( vbi->verbose ) fprintf( stderr, "Transmission Signal Identifier (TSID): 0x%04x\n",
- packet[ 2 ] << 24 | packet[ 3 ] << 16 | packet[ 4 ] << 8 | packet[ 5 ] );
- } else {
- /* unknown */
-
- if( vbi->verbose ) fprintf( stderr, "Unknown XDS packet, class " );
- switch( packet[ 0 ] ) {
- case 0x1: if( vbi->verbose ) fprintf( stderr, "CURRENT start\n" ); break;
- case 0x2: if( vbi->verbose ) fprintf( stderr, "CURRENT continue\n" ); break;
+ if (vbi->verbose)
+ fprintf (stderr, "Network name: '%s'\n", packet + 2);
+ if (vbi->network_name)
+ free (vbi->network_name);
+ vbi->network_name = strdup (packet + 2);
+ /*tvtime_osd_set_network_name( vbi->osd, vbi->network_name ); */
+ } else if (packet[0] == 0x01 && packet[1] == 0x05) {
+ int movie_rating = packet[2] & 7;
+ int scheme = (packet[2] & 56) >> 3;
+ int tv_rating = packet[3] & 7;
+ int VSL = packet[3] & 56;
+ const char *str;
+
+ switch (VSL | scheme) {
+ case 3: /* Canadian English TV */
+ str = cane_tv[tv_rating];
+ break;
+ case 7: /* Canadian French TV */
+ str = canf_tv[tv_rating];
+ break;
+ case 19: /* Reserved */
+ case 31:
+ str = "";
+ break;
+ default:
+ if (((VSL | scheme) & 3) == 1) {
+ /* USA TV */
+ str = usa_tv[tv_rating];
+ } else {
+ /* MPAA Movie Rating */
+ str = movies[movie_rating];
+ }
+ break;
+ }
- case 0x3: if( vbi->verbose ) fprintf( stderr, "FUTURE start\n" ); break;
- case 0x4: if( vbi->verbose ) fprintf( stderr, "FUTURE continue\n" ); break;
+ if (vbi->rating && !strcmp (vbi->rating, str)) {
+ return;
+ }
- case 0x5: if( vbi->verbose ) fprintf( stderr, "CHANNEL start\n" ); break;
- case 0x6: if( vbi->verbose ) fprintf( stderr, "CHANNEL continue\n" ); break;
+ if (vbi->verbose)
+ fprintf (stderr, "Show rating: %s", str);
+ if (((VSL | scheme) & 3) == 1 || ((VSL | scheme) & 3) == 0) {
+ /* show VSLD for the americans */
+ if ((VSL | scheme) & 32) {
+ if (vbi->verbose)
+ fprintf (stderr, " V");
+ }
+ if ((VSL | scheme) & 16) {
+ if (vbi->verbose)
+ fprintf (stderr, " S");
+ }
+ if ((VSL | scheme) & 8) {
+ if (vbi->verbose)
+ fprintf (stderr, " L");
+ }
+ if ((VSL | scheme) & 4) {
+ if (vbi->verbose)
+ fprintf (stderr, " D");
+ }
+ }
+ if (vbi->verbose)
+ fprintf (stderr, "\n");
+ vbi->rating = str;
+ /*tvtime_osd_set_show_rating( vbi->osd, vbi->rating ); */
+ } else if (packet[0] == 0x05 && packet[1] == 0x02) {
+ if (vbi->call_letters && !strcmp (vbi->call_letters, packet + 2)) {
+ return;
+ }
- case 0x7: if( vbi->verbose ) fprintf( stderr, "MISC start\n" ); break;
- case 0x8: if( vbi->verbose ) fprintf( stderr, "MISC continue\n" ); break;
+ if (vbi->verbose)
+ fprintf (stderr, "Network call letters: '%s'\n", packet + 2);
+ if (vbi->call_letters)
+ free (vbi->call_letters);
+ vbi->call_letters = strdup (packet + 2);
+ /*tvtime_osd_set_network_call( vbi->osd, vbi->call_letters ); */
+ } else if (packet[0] == 0x01 && packet[1] == 0x01) {
+ int month = packet[5]; // & 15;
+ int day = packet[4]; // & 31;
+ int hour = packet[3]; // & 31;
+ int min = packet[2]; // & 63;
+ char str[33];
+
+ if (vbi->verbose)
+ fprintf (stderr, "Program Start: %02d %s, %02d:%02d\n",
+ day & 31, months[month & 15], hour & 31, min & 63);
+ // packet[ 3 ], packet[ 4 ], packet[ 5 ], packet[ 6 ] );
+ //packet[ 5 ] & 31, packet[ 6 ], packet[ 4 ] & 31, packet[ 3 ] & 63 );
+ vbi->start_month = month & 15;
+ vbi->start_day = day & 31;
+ vbi->start_hour = hour & 31;
+ vbi->start_min = hour & 63;
+ snprintf (str, 32, "%02d %s, %02d:%02d",
+ day & 31, months[month & 15], hour & 31, min & 63);
+ /*tvtime_osd_set_show_start( vbi->osd, str ); */
+ } else if (packet[0] == 0x01 && packet[1] == 0x04) {
+ if (vbi->verbose)
+ fprintf (stderr, "Program type: ");
+ for (i = 0; i < length - 2; i++) {
+ int cur = packet[2 + i] - 0x20;
+
+ if (cur >= 0 && cur < 96) {
+ if (vbi->verbose)
+ fprintf (stderr, "%s%s", i ? ", " : "", eia608_program_type[cur]);
+ /* this will cause us to keep only the last type we check */
+ vbi->program_type = eia608_program_type[cur];
+ }
+ }
+ if (vbi->verbose)
+ fprintf (stderr, "\n");
+ } else if (packet[0] < 0x03 && packet[1] >= 0x10 && packet[1] <= 0x17) {
- case 0x9: if( vbi->verbose ) fprintf( stderr, "PUB start\n" ); break;
- case 0xa: if( vbi->verbose ) fprintf( stderr, "PUB continue\n" ); break;
+ if (vbi->program_desc[packet[1] & 0xf] &&
+ !strcmp (vbi->program_desc[packet[1] & 0xf], packet + 2)) {
+ return;
+ }
- case 0xb: if( vbi->verbose ) fprintf( stderr, "RES start\n" ); break;
- case 0xc: if( vbi->verbose ) fprintf( stderr, "RES continue\n" ); break;
+ if (vbi->verbose)
+ fprintf (stderr, "Program Description: Line %d", packet[1] & 0xf);
+ if (vbi->verbose)
+ fprintf (stderr, "%s\n", packet + 2);
+ if (vbi->program_desc[packet[1] & 0xf])
+ free (vbi->program_desc[packet[1] & 0xf]);
+ vbi->program_desc[packet[1] & 0xf] = strdup (packet + 2);
+ } else if (packet[0] == 0x01 && packet[1] == 0x02) {
+ char str[33];
+
+ str[0] = 0;
+ if (vbi->verbose)
+ fprintf (stderr, "Program Length: %02d:%02d",
+ packet[3] & 63, packet[2] & 63);
+ vbi->length_hour = packet[3] & 63;
+ vbi->length_min = packet[2] & 63;
+ snprintf (str, 32, "%02d:%02d", packet[3] & 63, packet[2] & 63);
+ if (length > 4) {
+ if (vbi->verbose)
+ fprintf (stderr, " Elapsed: %02d:%02d", packet[5] & 63, packet[4] & 63);
+ vbi->length_elapsed_hour = packet[5] & 63;
+ vbi->length_elapsed_min = packet[4] & 63;
+ snprintf (str, 32, "%02d:%02d/%02d:%02d",
+ packet[5] & 63, packet[4] & 63, packet[3] & 63, packet[2] & 63);
+ } else {
+ vbi->length_elapsed_hour = 0;
+ vbi->length_elapsed_min = 0;
+ }
- case 0xd: if( vbi->verbose ) fprintf( stderr, "UNDEF start\n" ); break;
- case 0xe: if( vbi->verbose ) fprintf( stderr, "UNDEF continue\n" ); break;
- }
- for( i = 0; i < length; i++ ) {
- if( vbi->verbose ) fprintf( stderr, "0x%02x ", packet[ i ] );
- }
- if( vbi->verbose ) fprintf( stderr, "\n" );
+ if (length > 6) {
+ if (vbi->verbose)
+ fprintf (stderr, ".%02d", packet[6] & 63);
+ vbi->length_elapsed_hour = packet[6] & 63;
+ snprintf (str, 32, "%02d:%02d.%02d/%02d:%02d",
+ packet[5] & 63, packet[4] & 63, packet[6] & 63,
+ packet[3] & 63, packet[2] & 63);
+ } else {
+ vbi->length_elapsed_hour = 0;
}
+ /*tvtime_osd_set_show_length( vbi->osd, str ); */
+ if (vbi->verbose)
+ fprintf (stderr, "\n");
+ } else if (packet[0] == 0x05 && packet[1] == 0x04) {
+ if (vbi->verbose)
+ fprintf (stderr, "Transmission Signal Identifier (TSID): 0x%04x\n",
+ packet[2] << 24 | packet[3] << 16 | packet[4] << 8 | packet[5]);
+ } else {
+ /* unknown */
+
+ if (vbi->verbose)
+ fprintf (stderr, "Unknown XDS packet, class ");
+ switch (packet[0]) {
+ case 0x1:
+ if (vbi->verbose)
+ fprintf (stderr, "CURRENT start\n");
+ break;
+ case 0x2:
+ if (vbi->verbose)
+ fprintf (stderr, "CURRENT continue\n");
+ break;
+
+ case 0x3:
+ if (vbi->verbose)
+ fprintf (stderr, "FUTURE start\n");
+ break;
+ case 0x4:
+ if (vbi->verbose)
+ fprintf (stderr, "FUTURE continue\n");
+ break;
+
+ case 0x5:
+ if (vbi->verbose)
+ fprintf (stderr, "CHANNEL start\n");
+ break;
+ case 0x6:
+ if (vbi->verbose)
+ fprintf (stderr, "CHANNEL continue\n");
+ break;
+
+ case 0x7:
+ if (vbi->verbose)
+ fprintf (stderr, "MISC start\n");
+ break;
+ case 0x8:
+ if (vbi->verbose)
+ fprintf (stderr, "MISC continue\n");
+ break;
+
+ case 0x9:
+ if (vbi->verbose)
+ fprintf (stderr, "PUB start\n");
+ break;
+ case 0xa:
+ if (vbi->verbose)
+ fprintf (stderr, "PUB continue\n");
+ break;
+
+ case 0xb:
+ if (vbi->verbose)
+ fprintf (stderr, "RES start\n");
+ break;
+ case 0xc:
+ if (vbi->verbose)
+ fprintf (stderr, "RES continue\n");
+ break;
+
+ case 0xd:
+ if (vbi->verbose)
+ fprintf (stderr, "UNDEF start\n");
+ break;
+ case 0xe:
+ if (vbi->verbose)
+ fprintf (stderr, "UNDEF continue\n");
+ break;
+ }
+ for (i = 0; i < length; i++) {
+ if (vbi->verbose)
+ fprintf (stderr, "0x%02x ", packet[i]);
+ }
+ if (vbi->verbose)
+ fprintf (stderr, "\n");
+ }
}
-static int xds_decode( vbidata_t *vbi, int b1, int b2 )
+static int
+xds_decode (vbidata_t * vbi, int b1, int b2)
{
- if( !vbi ) return 0;
- if( vbi->xds_cursor > 2046 ) {
- vbi->xds_cursor = 0;
- }
+ if (!vbi)
+ return 0;
+ if (vbi->xds_cursor > 2046) {
+ vbi->xds_cursor = 0;
+ }
- if( !vbi->xds_cursor && b1 > 0xf ) {
- return 0;
- }
+ if (!vbi->xds_cursor && b1 > 0xf) {
+ return 0;
+ }
- if( b1 < 0xf && (b1 & 0x2) ) {
- /* ignore the continue and thus 'support' continuation of
- a single packet */
- return 1;
- } else if( b1 < 0xf ) {
- /* kill old packet cause we got a new one */
- vbi->xds_cursor = 0;
- }
+ if (b1 < 0xf && (b1 & 0x2)) {
+ /* ignore the continue and thus 'support' continuation of
+ a single packet */
+ return 1;
+ } else if (b1 < 0xf) {
+ /* kill old packet cause we got a new one */
+ vbi->xds_cursor = 0;
+ }
- vbi->xds_packet[ vbi->xds_cursor ] = b1;
- vbi->xds_packet[ vbi->xds_cursor + 1 ] = b2;
- vbi->xds_cursor += 2;
+ vbi->xds_packet[vbi->xds_cursor] = b1;
+ vbi->xds_packet[vbi->xds_cursor + 1] = b2;
+ vbi->xds_cursor += 2;
- if( b1 == 0xf ) {
- parse_xds_packet( vbi, vbi->xds_packet, vbi->xds_cursor );
- vbi->xds_cursor = 0;
- }
+ if (b1 == 0xf) {
+ parse_xds_packet (vbi, vbi->xds_packet, vbi->xds_cursor);
+ vbi->xds_cursor = 0;
+ }
- return 1;
+ return 1;
}
#define NOMODE 0
#define T3 3
#define T4 4
-const unsigned int colours[] = {
- 0xFFFFFFFFU, /* white */
- 0xFF00FF00U, /* green */
- 0xFF0000FFU, /* blue */
- 0xFF00C7C7U, /* cyan */
- 0xFFFF0000U, /* red */
- 0xFFFFFF00U, /* yellow */
- 0xFFC700C7U /* magenta */
+const unsigned int colours[] = {
+ 0xFFFFFFFFU, /* white */
+ 0xFF00FF00U, /* green */
+ 0xFF0000FFU, /* blue */
+ 0xFF00C7C7U, /* cyan */
+ 0xFFFF0000U, /* red */
+ 0xFFFFFF00U, /* yellow */
+ 0xFFC700C7U /* magenta */
};
const int rows[] = {
- 11,
- 0, /* unused */
- 1,
- 2,
- 3,
- 4,
- 12,
- 13,
- 14,
- 15,
- 5,
- 6,
- 7,
- 8,
- 9,
- 10
+ 11,
+ 0, /* unused */
+ 1,
+ 2,
+ 3,
+ 4,
+ 12,
+ 13,
+ 14,
+ 15,
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10
};
#define ROLL_2 6
#define PAINT_ON 10
-static int Process16b( vbidata_t *vbi, int bottom, int w1 )
+static int
+Process16b (vbidata_t * vbi, int bottom, int w1)
{
- int b1, b2;
+ int b1, b2;
- b1 = w1 & 0x7f;
- b2 = (w1 >> 8) & 0x7f;
+ b1 = w1 & 0x7f;
+ b2 = (w1 >> 8) & 0x7f;
- if( !b1 && !b2 ) {
- return 0;
+ if (!b1 && !b2) {
+ return 0;
+ }
+
+ if (vbi->enabled && b1 >= 0x10 && b1 <= 0x1F && b2 >= 0x20 && b2 <= 0x7F) {
+ int code;
+
+ if ((b2 & 64)) {
+ /* Preamble Code */
+ /* This sets up colors and indenting */
+
+ if (!bottom && vbi->lastcode == ((b1 << 8) | b2)) {
+ vbi->lastcount = (vbi->lastcount + 1) % 2;
+ return 1;
+ }
+
+ vbi->current_chan = (b1 & 8) >> 3;
+ if (!bottom == vbi->wanttop) {
+ if (vbi->chan != vbi->current_chan)
+ return 0;
+ } else
+ return 0;
+
+ vbi->current_ital = (b2 & 1);
+ if (!(b2 & 16)) {
+ vbi->current_colour = colours[(b2 & 30) >> 1];
+ vbi->current_indent = 0;
+ } else {
+ vbi->current_colour = 0xFFFFFFFFU; /* white */
+ vbi->current_indent = 4 * ((b2 & 14) >> 1);
+ }
+ vbi->current_row = rows[((b1 & 7) << 1) | ((b2 & 32) >> 5)];
+ vbi->current_ul = b2 & 1;
+
+ if (vbi->verbose)
+ fprintf (stderr, "field: %d chan %d, ital %d, ul %d, colour 0x%x, "
+ "indent %d, row %d\n", bottom, vbi->current_chan,
+ vbi->current_ital, vbi->current_ul, vbi->current_colour,
+ vbi->current_indent, vbi->current_row);
+
+ if (!bottom == vbi->wanttop &&
+ vbi->current_chan == vbi->chan &&
+ vbi->current_istext == vbi->wanttext) {
+
+ vbi->indent = vbi->current_indent;
+ vbi->ital = vbi->current_ital;
+ vbi->colour = vbi->current_colour;
+ vbi->row = vbi->current_row;
+ vbi->current_istext = 0;
+
+ vbiscreen_new_caption (vbi->vs, vbi->indent, vbi->ital,
+ vbi->colour, vbi->row);
+
+ }
+
+ vbi->lastcode = (b1 << 8) | b2;
+ vbi->lastcount = 0;
+ return 1;
}
- if( vbi->enabled &&
- b1 >= 0x10 && b1 <= 0x1F && b2 >= 0x20 && b2 <= 0x7F ) {
- int code;
- if( (b2 & 64) ) {
- /* Preamble Code */
- /* This sets up colors and indenting */
-
- if( !bottom && vbi->lastcode == ( (b1 << 8) | b2 ) ) {
- vbi->lastcount = (vbi->lastcount + 1) % 2;
- return 1;
- }
-
- vbi->current_chan = (b1 & 8) >> 3;
- if( !bottom == vbi->wanttop ) {
- if( vbi->chan != vbi->current_chan )
- return 0;
- } else return 0;
-
- vbi->current_ital = (b2 & 1);
- if( !(b2 & 16) ) {
- vbi->current_colour = colours[ (b2 & 30) >> 1 ];
- vbi->current_indent = 0;
- } else {
- vbi->current_colour = 0xFFFFFFFFU; /* white */
- vbi->current_indent = 4*( (b2 & 14) >> 1 );
- }
- vbi->current_row = rows[ ((b1 & 7) << 1) | ((b2 & 32) >> 5) ];
- vbi->current_ul = b2 & 1;
-
- if( vbi->verbose ) fprintf( stderr, "field: %d chan %d, ital %d, ul %d, colour 0x%x, "
- "indent %d, row %d\n", bottom, vbi->current_chan,
- vbi->current_ital, vbi->current_ul, vbi->current_colour,
- vbi->current_indent, vbi->current_row );
-
- if( !bottom == vbi->wanttop &&
- vbi->current_chan == vbi->chan &&
- vbi->current_istext == vbi->wanttext ) {
-
- vbi->indent = vbi->current_indent;
- vbi->ital = vbi->current_ital;
- vbi->colour = vbi->current_colour;
- vbi->row = vbi->current_row;
- vbi->current_istext = 0;
-
- vbiscreen_new_caption( vbi->vs, vbi->indent, vbi->ital,
- vbi->colour, vbi->row );
-
- }
-
- vbi->lastcode = ( b1 << 8) | b2;
- vbi->lastcount = 0;
- return 1;
- }
-
- if( (b1 & 8) == 1 ) {
- /* Midrow code */
- if( !vbi->initialised ) return 0;
-
- if( !bottom && vbi->lastcode == ( (b1 << 8) | b2 ) ) {
- vbi->lastcount = (vbi->lastcount + 1) % 2;
- return 1;
- }
-
- if( vbi->verbose ) fprintf( stderr, "Midrow TODO: Add me.\n" );
-
- vbi->lastcode = ( b1 << 8) | b2;
- return 1;
- }
-
- if( (b1 & 2) && !(b2 & 64) ) {
- if( !vbi->initialised ) return 0;
-
- if( !bottom && vbi->lastcode == ( (b1 << 8) | b2 ) ) {
- vbi->lastcount = (vbi->lastcount + 1) % 2;
- return 1;
- }
-
- if( vbi->verbose ) fprintf( stderr, "Tab Offset: %d columns\n", b2 & 3 );
- if( vbi->wanttext && vbi->current_istext &&
- vbi->current_chan == vbi->chan && !bottom == vbi->wanttop ) {
- vbiscreen_tab( vbi->vs, b2 & 3 );
- }
- vbi->lastcode = ( b1 << 8) | b2;
- return 1;
- }
-
- switch( (code = b2 & 15) ) {
- case 0: /* POP-UP */
- case 5: /* ROLL UP 2 */
- case 6: /* ROLL UP 3 */
- case 7: /* ROLL UP 4 */
- case 9: /* PAINT-ON */
- case 10:/* TEXT */
- case 11:/* TEXT */
- vbi->initialised = 1;
- if( !bottom && vbi->lastcode == ( (b1 << 8) | b2 ) ) {
- /* This is the repeated Control Code */
- vbi->lastcount = (vbi->lastcount + 1) % 2;
- return 1;
- }
- switch( code ) {
- case 0: /* POP-UP */
- if( !vbi->wanttext && vbi->current_chan == vbi->chan &&
- !bottom == vbi->wanttop ) {
- if( vbi->verbose )
- fprintf( stderr, "Pop-Up\n");
- vbi->indent = vbi->current_indent;
- vbi->ital = vbi->current_ital;
- vbi->colour = vbi->current_colour;
- vbi->row = vbi->current_row;
- vbi->current_istext = 0;
- vbiscreen_set_mode( vbi->vs, 1, POP_UP );
- }
- break;
- case 5: /* ROLL UP 2 */
- if( !vbi->wanttext && vbi->current_chan == vbi->chan &&
- !bottom == vbi->wanttop ) {
- if( vbi->verbose )
- fprintf( stderr, "Roll-Up 2 (RU2)\n");
- vbi->indent = vbi->current_indent;
- vbi->ital = vbi->current_ital;
- vbi->colour = vbi->current_colour;
- vbi->row = vbi->current_row;
- vbi->current_istext = 0;
- vbiscreen_set_mode( vbi->vs, 1, ROLL_2 );
- }
- break;
- case 6: /* ROLL UP 3 */
- if( !vbi->wanttext && vbi->current_chan == vbi->chan &&
- !bottom == vbi->wanttop ) {
- if( vbi->verbose )
- fprintf( stderr, "Roll-Up 3 (RU3)\n");
- vbi->indent = vbi->current_indent;
- vbi->ital = vbi->current_ital;
- vbi->colour = vbi->current_colour;
- vbi->row = vbi->current_row;
- vbi->current_istext = 0;
- vbiscreen_set_mode( vbi->vs, 1, ROLL_3 );
- }
- break;
- case 7: /* ROLL UP 4 */
- if( !vbi->wanttext && vbi->current_chan == vbi->chan &&
- !bottom == vbi->wanttop ) {
- if( vbi->verbose )
- fprintf( stderr, "Roll-Up 4 (RU4)\n");
- vbi->indent = vbi->current_indent;
- vbi->ital = vbi->current_ital;
- vbi->colour = vbi->current_colour;
- vbi->row = vbi->current_row;
- vbi->current_istext = 0;
- vbiscreen_set_mode( vbi->vs, 1, ROLL_4 );
- }
- break;
- case 9: /* PAINT-ON */
- if( !vbi->wanttext && vbi->current_chan == vbi->chan &&
- !bottom == vbi->wanttop ) {
- if( vbi->verbose )
- fprintf( stderr, "Paint-On\n");
- vbi->indent = vbi->current_indent;
- vbi->ital = vbi->current_ital;
- vbi->colour = vbi->current_colour;
- vbi->row = vbi->current_row;
- vbi->current_istext = 0;
- vbiscreen_set_mode( vbi->vs, 1, PAINT_ON );
- }
- break;
- case 10:/* TEXT */
- if( vbi->wanttext && vbi->current_chan == vbi->chan &&
- !bottom == vbi->wanttop ) {
- if( vbi->verbose )
- fprintf( stderr, "Text Restart\n");
- vbi->indent = vbi->current_indent;
- vbi->ital = vbi->current_ital;
- vbi->colour = vbi->current_colour;
- vbi->row = vbi->current_row;
- vbi->current_istext = 1;
- vbiscreen_set_mode( vbi->vs, 0, 0 );
- }
- break;
- case 11:/* TEXT */
- if( vbi->wanttext && vbi->current_chan == vbi->chan &&
- !bottom == vbi->wanttop ) {
- if( vbi->verbose )
- fprintf( stderr, "Resume Text Display\n");
- vbi->indent = vbi->current_indent;
- vbi->ital = vbi->current_ital;
- vbi->colour = vbi->current_colour;
- vbi->row = vbi->current_row;
- vbi->current_istext = 1;
- vbiscreen_set_mode( vbi->vs, 0, 0 );
- }
- break;
- default: /* impossible */
- break;
- }
- break;
- case 1:
- if( !vbi->initialised ) return 0;
- if( !bottom && vbi->lastcode == ( (b1 << 8) | b2 ) ) {
- vbi->lastcount = (vbi->lastcount + 1) % 2;
- }
- if( !bottom == vbi->wanttop && vbi->current_chan == vbi->chan &&
- vbi->current_istext == vbi->wanttext ) {
- if( vbi->verbose )
- fprintf( stderr, "Backspace\n");
- vbiscreen_backspace( vbi->vs );
- }
- break;
- case 2:
- case 3:
- if( !vbi->initialised ) return 0;
- fprintf( stderr, "Reserved\n");
- break;
- case 4:
- if( !vbi->initialised ) return 0;
- if( !bottom && vbi->lastcode == ( (b1 << 8) | b2 ) ) {
- vbi->lastcount = (vbi->lastcount + 1) % 2;
- }
- if( !bottom == vbi->wanttop && vbi->current_chan == vbi->chan &&
- vbi->current_istext == vbi->wanttext ) {
- if( vbi->verbose )
- fprintf( stderr, "Delete to End of Row\n");
- vbiscreen_delete_to_end( vbi->vs );
- }
- break;
- case 8:
- if( !vbi->initialised ) return 0;
- if( vbi->verbose )
- fprintf( stderr, "Flash On\n");
- break;
- case 12:
- case 13:
- case 14:
- case 15:
- if( !vbi->initialised ) return 0;
- if( !bottom && vbi->lastcode == ( (b1 << 8) | b2 ) ) {
- vbi->lastcount = (vbi->lastcount + 1) % 2;
- return 1;
- }
-
- switch( code ) {
- case 12:
- /* Show buffer 1, Fill buffer 2 */
- if( !bottom == vbi->wanttop &&
- vbi->current_chan == vbi->chan &&
- vbi->current_istext == vbi->wanttext ) {
- if( vbi->verbose )
- fprintf( stderr, "Erase Displayed Memory\n");
- vbiscreen_erase_displayed( vbi->vs );
- }
- break;
- case 13:
- if( !bottom == vbi->wanttop &&
- vbi->current_chan == vbi->chan &&
- vbi->current_istext == vbi->wanttext ) {
- if( vbi->verbose )
- fprintf( stderr, "Carriage Return\n");
- vbiscreen_carriage_return( vbi->vs );
- }
- break;
- case 14:
- if( !bottom == vbi->wanttop &&
- vbi->current_chan == vbi->chan &&
- vbi->current_istext == vbi->wanttext ) {
- if( vbi->verbose )
- fprintf( stderr, "Erase Non-Displayed\n");
- vbiscreen_erase_non_displayed( vbi->vs );
- }
- break;
- case 15:
- /* Show buffer 2, Fill Buffer 1 */
- if( !bottom == vbi->wanttop &&
- vbi->current_chan == vbi->chan &&
- vbi->current_istext == vbi->wanttext ) {
- if( vbi->verbose )
- fprintf( stderr, "End Of Caption\n");
- vbiscreen_end_of_caption( vbi->vs );
- }
- break;
- default: /* impossible */
- return 0;
- break;
- }
- break;
- default: /* Impossible */
- return 0;
- break;
- }
-
- if( vbi->lastcode != ((b1 << 8) | b2) ) {
- vbi->lastcount = 0;
- }
-
- vbi->lastcode = (b1 << 8) | b2;
- return 1;
- }
+ if ((b1 & 8) == 1) {
+ /* Midrow code */
+ if (!vbi->initialised)
+ return 0;
- if( bottom && xds_decode( vbi, b1, b2 ) ) {
- return 1;
- }
+ if (!bottom && vbi->lastcode == ((b1 << 8) | b2)) {
+ vbi->lastcount = (vbi->lastcount + 1) % 2;
+ return 1;
+ }
- if( !vbi->enabled ) return 0;
+ if (vbi->verbose)
+ fprintf (stderr, "Midrow TODO: Add me.\n");
- vbi->lastcode = 0;
- vbi->lastcount = 0;
+ vbi->lastcode = (b1 << 8) | b2;
+ return 1;
+ }
- if( !vbi->initialised )
- return 0;
+ if ((b1 & 2) && !(b2 & 64)) {
+ if (!vbi->initialised)
+ return 0;
+
+ if (!bottom && vbi->lastcode == ((b1 << 8) | b2)) {
+ vbi->lastcount = (vbi->lastcount + 1) % 2;
+ return 1;
+ }
+
+ if (vbi->verbose)
+ fprintf (stderr, "Tab Offset: %d columns\n", b2 & 3);
+ if (vbi->wanttext && vbi->current_istext &&
+ vbi->current_chan == vbi->chan && !bottom == vbi->wanttop) {
+ vbiscreen_tab (vbi->vs, b2 & 3);
+ }
+ vbi->lastcode = (b1 << 8) | b2;
+ return 1;
+ }
- if( !bottom != vbi->wanttop || vbi->current_chan != vbi->chan ||
- vbi->current_istext != vbi->wanttext ) {
- return 0;
+ switch ((code = b2 & 15)) {
+ case 0: /* POP-UP */
+ case 5: /* ROLL UP 2 */
+ case 6: /* ROLL UP 3 */
+ case 7: /* ROLL UP 4 */
+ case 9: /* PAINT-ON */
+ case 10: /* TEXT */
+ case 11: /* TEXT */
+ vbi->initialised = 1;
+ if (!bottom && vbi->lastcode == ((b1 << 8) | b2)) {
+ /* This is the repeated Control Code */
+ vbi->lastcount = (vbi->lastcount + 1) % 2;
+ return 1;
+ }
+ switch (code) {
+ case 0: /* POP-UP */
+ if (!vbi->wanttext && vbi->current_chan == vbi->chan &&
+ !bottom == vbi->wanttop) {
+ if (vbi->verbose)
+ fprintf (stderr, "Pop-Up\n");
+ vbi->indent = vbi->current_indent;
+ vbi->ital = vbi->current_ital;
+ vbi->colour = vbi->current_colour;
+ vbi->row = vbi->current_row;
+ vbi->current_istext = 0;
+ vbiscreen_set_mode (vbi->vs, 1, POP_UP);
+ }
+ break;
+ case 5: /* ROLL UP 2 */
+ if (!vbi->wanttext && vbi->current_chan == vbi->chan &&
+ !bottom == vbi->wanttop) {
+ if (vbi->verbose)
+ fprintf (stderr, "Roll-Up 2 (RU2)\n");
+ vbi->indent = vbi->current_indent;
+ vbi->ital = vbi->current_ital;
+ vbi->colour = vbi->current_colour;
+ vbi->row = vbi->current_row;
+ vbi->current_istext = 0;
+ vbiscreen_set_mode (vbi->vs, 1, ROLL_2);
+ }
+ break;
+ case 6: /* ROLL UP 3 */
+ if (!vbi->wanttext && vbi->current_chan == vbi->chan &&
+ !bottom == vbi->wanttop) {
+ if (vbi->verbose)
+ fprintf (stderr, "Roll-Up 3 (RU3)\n");
+ vbi->indent = vbi->current_indent;
+ vbi->ital = vbi->current_ital;
+ vbi->colour = vbi->current_colour;
+ vbi->row = vbi->current_row;
+ vbi->current_istext = 0;
+ vbiscreen_set_mode (vbi->vs, 1, ROLL_3);
+ }
+ break;
+ case 7: /* ROLL UP 4 */
+ if (!vbi->wanttext && vbi->current_chan == vbi->chan &&
+ !bottom == vbi->wanttop) {
+ if (vbi->verbose)
+ fprintf (stderr, "Roll-Up 4 (RU4)\n");
+ vbi->indent = vbi->current_indent;
+ vbi->ital = vbi->current_ital;
+ vbi->colour = vbi->current_colour;
+ vbi->row = vbi->current_row;
+ vbi->current_istext = 0;
+ vbiscreen_set_mode (vbi->vs, 1, ROLL_4);
+ }
+ break;
+ case 9: /* PAINT-ON */
+ if (!vbi->wanttext && vbi->current_chan == vbi->chan &&
+ !bottom == vbi->wanttop) {
+ if (vbi->verbose)
+ fprintf (stderr, "Paint-On\n");
+ vbi->indent = vbi->current_indent;
+ vbi->ital = vbi->current_ital;
+ vbi->colour = vbi->current_colour;
+ vbi->row = vbi->current_row;
+ vbi->current_istext = 0;
+ vbiscreen_set_mode (vbi->vs, 1, PAINT_ON);
+ }
+ break;
+ case 10: /* TEXT */
+ if (vbi->wanttext && vbi->current_chan == vbi->chan &&
+ !bottom == vbi->wanttop) {
+ if (vbi->verbose)
+ fprintf (stderr, "Text Restart\n");
+ vbi->indent = vbi->current_indent;
+ vbi->ital = vbi->current_ital;
+ vbi->colour = vbi->current_colour;
+ vbi->row = vbi->current_row;
+ vbi->current_istext = 1;
+ vbiscreen_set_mode (vbi->vs, 0, 0);
+ }
+ break;
+ case 11: /* TEXT */
+ if (vbi->wanttext && vbi->current_chan == vbi->chan &&
+ !bottom == vbi->wanttop) {
+ if (vbi->verbose)
+ fprintf (stderr, "Resume Text Display\n");
+ vbi->indent = vbi->current_indent;
+ vbi->ital = vbi->current_ital;
+ vbi->colour = vbi->current_colour;
+ vbi->row = vbi->current_row;
+ vbi->current_istext = 1;
+ vbiscreen_set_mode (vbi->vs, 0, 0);
+ }
+ break;
+ default: /* impossible */
+ break;
+ }
+ break;
+ case 1:
+ if (!vbi->initialised)
+ return 0;
+ if (!bottom && vbi->lastcode == ((b1 << 8) | b2)) {
+ vbi->lastcount = (vbi->lastcount + 1) % 2;
+ }
+ if (!bottom == vbi->wanttop && vbi->current_chan == vbi->chan &&
+ vbi->current_istext == vbi->wanttext) {
+ if (vbi->verbose)
+ fprintf (stderr, "Backspace\n");
+ vbiscreen_backspace (vbi->vs);
+ }
+ break;
+ case 2:
+ case 3:
+ if (!vbi->initialised)
+ return 0;
+ fprintf (stderr, "Reserved\n");
+ break;
+ case 4:
+ if (!vbi->initialised)
+ return 0;
+ if (!bottom && vbi->lastcode == ((b1 << 8) | b2)) {
+ vbi->lastcount = (vbi->lastcount + 1) % 2;
+ }
+ if (!bottom == vbi->wanttop && vbi->current_chan == vbi->chan &&
+ vbi->current_istext == vbi->wanttext) {
+ if (vbi->verbose)
+ fprintf (stderr, "Delete to End of Row\n");
+ vbiscreen_delete_to_end (vbi->vs);
+ }
+ break;
+ case 8:
+ if (!vbi->initialised)
+ return 0;
+ if (vbi->verbose)
+ fprintf (stderr, "Flash On\n");
+ break;
+ case 12:
+ case 13:
+ case 14:
+ case 15:
+ if (!vbi->initialised)
+ return 0;
+ if (!bottom && vbi->lastcode == ((b1 << 8) | b2)) {
+ vbi->lastcount = (vbi->lastcount + 1) % 2;
+ return 1;
+ }
+
+ switch (code) {
+ case 12:
+ /* Show buffer 1, Fill buffer 2 */
+ if (!bottom == vbi->wanttop &&
+ vbi->current_chan == vbi->chan &&
+ vbi->current_istext == vbi->wanttext) {
+ if (vbi->verbose)
+ fprintf (stderr, "Erase Displayed Memory\n");
+ vbiscreen_erase_displayed (vbi->vs);
+ }
+ break;
+ case 13:
+ if (!bottom == vbi->wanttop &&
+ vbi->current_chan == vbi->chan &&
+ vbi->current_istext == vbi->wanttext) {
+ if (vbi->verbose)
+ fprintf (stderr, "Carriage Return\n");
+ vbiscreen_carriage_return (vbi->vs);
+ }
+ break;
+ case 14:
+ if (!bottom == vbi->wanttop &&
+ vbi->current_chan == vbi->chan &&
+ vbi->current_istext == vbi->wanttext) {
+ if (vbi->verbose)
+ fprintf (stderr, "Erase Non-Displayed\n");
+ vbiscreen_erase_non_displayed (vbi->vs);
+ }
+ break;
+ case 15:
+ /* Show buffer 2, Fill Buffer 1 */
+ if (!bottom == vbi->wanttop &&
+ vbi->current_chan == vbi->chan &&
+ vbi->current_istext == vbi->wanttext) {
+ if (vbi->verbose)
+ fprintf (stderr, "End Of Caption\n");
+ vbiscreen_end_of_caption (vbi->vs);
+ }
+ break;
+ default: /* impossible */
+ return 0;
+ break;
+ }
+ break;
+ default: /* Impossible */
+ return 0;
+ break;
}
- if( b1 == 0x11 || b1 == 0x19 ||
- b1 == 0x12 || b1 == 0x13 ||
- b1 == 0x1A || b1 == 0x1B ) {
- switch( b1 ) {
- case 0x1A:
- case 0x12:
- /* use extcode1 */
- if( b1 > 31 && b2 > 31 && b1 <= 0x3F && b2 <= 0x3F )
- if( vbi->verbose )
- fprintf( stderr, "char %d (%c), char %d (%c)\n", b1,
- extcode1[b1-32] , b2, extcode1[b2-32] );
-
- break;
- case 0x13:
- case 0x1B:
- /* use extcode2 */
- if( b1 > 31 && b2 > 31 && b1 <= 0x3F && b2 <= 0x3F )
- if( vbi->verbose )
- fprintf( stderr, "char %d (%c), char %d (%c)\n", b1,
- extcode2[b1-32] , b2, extcode2[b2-32] );
-
- break;
- case 0x11:
- case 0x19:
- /* use wcode */
- if( b1 > 31 && b2 > 31 && b1 <= 0x3F && b2 <= 0x3F )
- if( vbi->verbose )
- fprintf( stderr, "char %d (%c), char %d (%c)\n", b1,
- wccode[b1-32] , b2, wccode[b2-32] );
-
- break;
- default:
- break;
- }
- } else if( b1 ) {
- /* use ccode */
- if( b1 < 32 ) b1 = 32;
- if( b2 < 32 ) b2 = 32;
- if( vbi->verbose )
- fprintf( stderr, "vbidata: data: %c %c\n", ccode[b1-32],
- ccode[b2-32] );
- vbiscreen_print( vbi->vs, ccode[b1-32], ccode[b2-32] );
+ if (vbi->lastcode != ((b1 << 8) | b2)) {
+ vbi->lastcount = 0;
}
+ vbi->lastcode = (b1 << 8) | b2;
+ return 1;
+ }
+ if (bottom && xds_decode (vbi, b1, b2)) {
return 1;
+ }
+
+ if (!vbi->enabled)
+ return 0;
+
+ vbi->lastcode = 0;
+ vbi->lastcount = 0;
+
+ if (!vbi->initialised)
+ return 0;
+
+ if (!bottom != vbi->wanttop || vbi->current_chan != vbi->chan ||
+ vbi->current_istext != vbi->wanttext) {
+ return 0;
+ }
+
+ if (b1 == 0x11 || b1 == 0x19 ||
+ b1 == 0x12 || b1 == 0x13 || b1 == 0x1A || b1 == 0x1B) {
+ switch (b1) {
+ case 0x1A:
+ case 0x12:
+ /* use extcode1 */
+ if (b1 > 31 && b2 > 31 && b1 <= 0x3F && b2 <= 0x3F)
+ if (vbi->verbose)
+ fprintf (stderr, "char %d (%c), char %d (%c)\n", b1,
+ extcode1[b1 - 32], b2, extcode1[b2 - 32]);
+
+ break;
+ case 0x13:
+ case 0x1B:
+ /* use extcode2 */
+ if (b1 > 31 && b2 > 31 && b1 <= 0x3F && b2 <= 0x3F)
+ if (vbi->verbose)
+ fprintf (stderr, "char %d (%c), char %d (%c)\n", b1,
+ extcode2[b1 - 32], b2, extcode2[b2 - 32]);
+
+ break;
+ case 0x11:
+ case 0x19:
+ /* use wcode */
+ if (b1 > 31 && b2 > 31 && b1 <= 0x3F && b2 <= 0x3F)
+ if (vbi->verbose)
+ fprintf (stderr, "char %d (%c), char %d (%c)\n", b1,
+ wccode[b1 - 32], b2, wccode[b2 - 32]);
+
+ break;
+ default:
+ break;
+ }
+ } else if (b1) {
+ /* use ccode */
+ if (b1 < 32)
+ b1 = 32;
+ if (b2 < 32)
+ b2 = 32;
+ if (vbi->verbose)
+ fprintf (stderr, "vbidata: data: %c %c\n", ccode[b1 - 32],
+ ccode[b2 - 32]);
+ vbiscreen_print (vbi->vs, ccode[b1 - 32], ccode[b2 - 32]);
+ }
+
+
+ return 1;
} /* Process16b */
-int ProcessLine( vbidata_t *vbi, unsigned char *s, int bottom )
+int
+ProcessLine (vbidata_t * vbi, unsigned char *s, int bottom)
{
- int w1;
- /*char *outbuf = NULL;*/
+ int w1;
- if( !vbi ) return 0;
+ /*char *outbuf = NULL; */
- w1 = ccdecode(s);
+ if (!vbi)
+ return 0;
- return Process16b(vbi, bottom, w1);
+ w1 = ccdecode (s);
+
+ return Process16b (vbi, bottom, w1);
} /* ProcessLine */
-vbidata_t *vbidata_new_file( const char *filename, vbiscreen_t *vs,
- /*tvtime_osd_t* osd,*/ int verbose )
+vbidata_t *
+vbidata_new_file (const char *filename, vbiscreen_t * vs,
+ /*tvtime_osd_t* osd, */ int verbose)
{
- vbidata_t *vbi = (vbidata_t *) malloc( sizeof( vbidata_t ) );
- if( !vbi ) {
- return 0;
- }
+ vbidata_t *vbi = (vbidata_t *) malloc (sizeof (vbidata_t));
- vbi->fd = open( filename, O_RDONLY );
- if( vbi->fd < 0 ) {
- fprintf( stderr, "vbidata: Can't open %s: %s\n",
- filename, strerror( errno ) );
- free( vbi );
- return 0;
- }
+ if (!vbi) {
+ return 0;
+ }
+
+ vbi->fd = open (filename, O_RDONLY);
+ if (vbi->fd < 0) {
+ fprintf (stderr, "vbidata: Can't open %s: %s\n",
+ filename, strerror (errno));
+ free (vbi);
+ return 0;
+ }
- vbi->vs = vs;
- /*vbi->osd = osd;*/
- vbi->verbose = verbose;
+ vbi->vs = vs;
+ /*vbi->osd = osd; */
+ vbi->verbose = verbose;
- vbidata_reset( vbi );
+ vbidata_reset (vbi);
- return vbi;
+ return vbi;
}
-vbidata_t *vbidata_new_line( vbiscreen_t *vs, int verbose )
+vbidata_t *
+vbidata_new_line (vbiscreen_t * vs, int verbose)
{
- vbidata_t *vbi = (vbidata_t *) malloc( sizeof( vbidata_t ) );
- if( !vbi ) {
- return 0;
- }
+ vbidata_t *vbi = (vbidata_t *) malloc (sizeof (vbidata_t));
+
+ if (!vbi) {
+ return 0;
+ }
- vbi->vs = vs;
- /*vbi->osd = osd;*/
- vbi->verbose = verbose;
+ vbi->vs = vs;
+ /*vbi->osd = osd; */
+ vbi->verbose = verbose;
- vbidata_reset( vbi );
+ vbidata_reset (vbi);
- return vbi;
+ return vbi;
}
-void vbidata_delete( vbidata_t *vbi )
+void
+vbidata_delete (vbidata_t * vbi)
{
- if( !vbi ) return;
- if( vbi->fd != 0 ) {
- close( vbi->fd );
- }
- free( vbi );
+ if (!vbi)
+ return;
+ if (vbi->fd != 0) {
+ close (vbi->fd);
+ }
+ free (vbi);
}
-void vbidata_reset( vbidata_t *vbi )
+void
+vbidata_reset (vbidata_t * vbi)
{
- if( !vbi ) return;
-
- vbi->wanttop = 0;
- vbi->wanttext = 0;
- vbi->colour = 0xFFFFFFFFU;
- vbi->row = 0;
-
- vbi->ital = 0;
- vbi->indent = 0;
- vbi->ul=0;
-
- vbi->chan=0;
-
- vbi->initialised = 0;
- vbi->enabled = 0;
-
- memset(vbi->program_desc, 0, 8*sizeof(char*) );
- vbi->program_name = NULL;
- vbi->network_name = NULL;
- vbi->call_letters = NULL;
- vbi->rating = NULL;
- vbi->program_type = NULL;
-
- vbi->start_day = 0;
- vbi->start_month = 0;
- vbi->start_min = 0;
- vbi->start_hour = 0;
- vbi->length_hour = 0;
- vbi->length_min = 0;
- vbi->length_elapsed_hour = 0;
- vbi->length_elapsed_min = 0;
- vbi->length_elapsed_sec = 0;
-
- /*
- tvtime_osd_set_network_call( vbi->osd, "" );
- tvtime_osd_set_network_name( vbi->osd, "" );
- tvtime_osd_set_show_name( vbi->osd, "" );
- tvtime_osd_set_show_rating( vbi->osd, "" );
- tvtime_osd_set_show_start( vbi->osd, "" );
- tvtime_osd_set_show_length( vbi->osd, "" );
- */
-
-
-
- vbi->lastcode = 0;
- vbi->lastcount = 0;
- vbi->xds_packet[ 0 ] = 0;
- vbi->xds_cursor = 0;
- vbiscreen_reset( vbi->vs );
+ if (!vbi)
+ return;
+
+ vbi->wanttop = 0;
+ vbi->wanttext = 0;
+ vbi->colour = 0xFFFFFFFFU;
+ vbi->row = 0;
+
+ vbi->ital = 0;
+ vbi->indent = 0;
+ vbi->ul = 0;
+
+ vbi->chan = 0;
+
+ vbi->initialised = 0;
+ vbi->enabled = 0;
+
+ memset (vbi->program_desc, 0, 8 * sizeof (char *));
+ vbi->program_name = NULL;
+ vbi->network_name = NULL;
+ vbi->call_letters = NULL;
+ vbi->rating = NULL;
+ vbi->program_type = NULL;
+
+ vbi->start_day = 0;
+ vbi->start_month = 0;
+ vbi->start_min = 0;
+ vbi->start_hour = 0;
+ vbi->length_hour = 0;
+ vbi->length_min = 0;
+ vbi->length_elapsed_hour = 0;
+ vbi->length_elapsed_min = 0;
+ vbi->length_elapsed_sec = 0;
+
+ /*
+ tvtime_osd_set_network_call( vbi->osd, "" );
+ tvtime_osd_set_network_name( vbi->osd, "" );
+ tvtime_osd_set_show_name( vbi->osd, "" );
+ tvtime_osd_set_show_rating( vbi->osd, "" );
+ tvtime_osd_set_show_start( vbi->osd, "" );
+ tvtime_osd_set_show_length( vbi->osd, "" );
+ */
+
+
+
+ vbi->lastcode = 0;
+ vbi->lastcount = 0;
+ vbi->xds_packet[0] = 0;
+ vbi->xds_cursor = 0;
+ vbiscreen_reset (vbi->vs);
}
-void vbidata_set_verbose( vbidata_t *vbi, int verbose )
+void
+vbidata_set_verbose (vbidata_t * vbi, int verbose)
{
- vbi->verbose = verbose;
+ vbi->verbose = verbose;
}
-void vbidata_capture_mode( vbidata_t *vbi, int mode )
+void
+vbidata_capture_mode (vbidata_t * vbi, int mode)
{
- if( !vbi ) return;
- switch( mode ) {
+ if (!vbi)
+ return;
+ switch (mode) {
case CAPTURE_OFF:
- vbi->enabled = 0;
- break;
+ vbi->enabled = 0;
+ break;
case CAPTURE_CC1:
- vbi->wanttop = 1;
- vbi->wanttext = 0;
- vbi->chan = 0;
- vbi->enabled = 1;
- break;
+ vbi->wanttop = 1;
+ vbi->wanttext = 0;
+ vbi->chan = 0;
+ vbi->enabled = 1;
+ break;
case CAPTURE_CC2:
- vbi->wanttop = 1;
- vbi->wanttext = 0;
- vbi->chan = 1;
- vbi->enabled = 1;
- break;
+ vbi->wanttop = 1;
+ vbi->wanttext = 0;
+ vbi->chan = 1;
+ vbi->enabled = 1;
+ break;
case CAPTURE_CC3:
- vbi->wanttop = 0;
- vbi->wanttext = 0;
- vbi->chan = 0;
- vbi->enabled = 1;
- break;
+ vbi->wanttop = 0;
+ vbi->wanttext = 0;
+ vbi->chan = 0;
+ vbi->enabled = 1;
+ break;
case CAPTURE_CC4:
- vbi->wanttop = 0;
- vbi->wanttext = 0;
- vbi->chan = 1;
- vbi->enabled = 1;
- break;
+ vbi->wanttop = 0;
+ vbi->wanttext = 0;
+ vbi->chan = 1;
+ vbi->enabled = 1;
+ break;
case CAPTURE_T1:
- vbi->wanttop = 1;
- vbi->wanttext = 1;
- vbi->chan = 0;
- vbi->enabled = 1;
- break;
+ vbi->wanttop = 1;
+ vbi->wanttext = 1;
+ vbi->chan = 0;
+ vbi->enabled = 1;
+ break;
case CAPTURE_T2:
- vbi->wanttop = 1;
- vbi->wanttext = 1;
- vbi->chan = 1;
- vbi->enabled = 1;
- break;
+ vbi->wanttop = 1;
+ vbi->wanttext = 1;
+ vbi->chan = 1;
+ vbi->enabled = 1;
+ break;
case CAPTURE_T3:
- vbi->wanttop = 0;
- vbi->wanttext = 1;
- vbi->chan = 0;
- vbi->enabled = 1;
- break;
+ vbi->wanttop = 0;
+ vbi->wanttext = 1;
+ vbi->chan = 0;
+ vbi->enabled = 1;
+ break;
case CAPTURE_T4:
- vbi->wanttop = 0;
- vbi->wanttext = 1;
- vbi->chan = 1;
- vbi->enabled = 1;
- break;
+ vbi->wanttop = 0;
+ vbi->wanttext = 1;
+ vbi->chan = 1;
+ vbi->enabled = 1;
+ break;
default:
- vbi->enabled = 0;
- break;
- }
+ vbi->enabled = 0;
+ break;
+ }
}
-void vbidata_process_frame( vbidata_t *vbi, int printdebug )
+void
+vbidata_process_frame (vbidata_t * vbi, int printdebug)
{
- if( read( vbi->fd, vbi->buf, 65536 ) < 65536 ) {
- fprintf( stderr, "error, can't read vbi data.\n" );
- return;
- }
+ if (read (vbi->fd, vbi->buf, 65536) < 65536) {
+ fprintf (stderr, "error, can't read vbi data.\n");
+ return;
+ }
- ProcessLine( vbi, &vbi->buf[ DO_LINE*2048 ], 0 );
- ProcessLine( vbi, &vbi->buf[ (16+DO_LINE)*2048 ], 1 );
+ ProcessLine (vbi, &vbi->buf[DO_LINE * 2048], 0);
+ ProcessLine (vbi, &vbi->buf[(16 + DO_LINE) * 2048], 1);
}
-void vbidata_process_line( vbidata_t *vbi, unsigned char *s, int bottom)
+void
+vbidata_process_line (vbidata_t * vbi, unsigned char *s, int bottom)
{
- ProcessLine( vbi, s, bottom );
+ ProcessLine (vbi, s, bottom);
}
-void vbidata_process_16b( vbidata_t *vbi, int bottom, int w)
+void
+vbidata_process_16b (vbidata_t * vbi, int bottom, int w)
{
- Process16b( vbi, bottom, w );
+ Process16b (vbi, bottom, w);
}
-
#define CAPTURE_T3 8
#define CAPTURE_T4 9
-vbidata_t *vbidata_new_file( const char *filename, vbiscreen_t *vs,
- /*tvtime_osd_t* osd,*/ int verbose );
-vbidata_t *vbidata_new_line( vbiscreen_t *vs, int verbose );
+vbidata_t *vbidata_new_file (const char *filename, vbiscreen_t * vs,
+ /*tvtime_osd_t* osd, */ int verbose);
+vbidata_t *vbidata_new_line (vbiscreen_t * vs, int verbose);
-void vbidata_delete( vbidata_t *vbi );
-void vbidata_reset( vbidata_t *vbi );
-void vbidata_set_verbose( vbidata_t *vbi, int verbose );
-void vbidata_capture_mode( vbidata_t *vbi, int mode );
-void vbidata_process_frame( vbidata_t *vbi, int printdebug );
-void vbidata_process_line( vbidata_t *vbi, unsigned char *s, int bottom );
-void vbidata_process_16b( vbidata_t *vbi, int bottom, int w );
+void vbidata_delete (vbidata_t * vbi);
+void vbidata_reset (vbidata_t * vbi);
+void vbidata_set_verbose (vbidata_t * vbi, int verbose);
+void vbidata_capture_mode (vbidata_t * vbi, int mode);
+void vbidata_process_frame (vbidata_t * vbi, int printdebug);
+void vbidata_process_line (vbidata_t * vbi, unsigned char *s, int bottom);
+void vbidata_process_16b (vbidata_t * vbi, int bottom, int w);
#endif /* VBIDATA_H_INCLUDED */
#define FONT_SIZE 20
typedef struct osd_string_s osd_string_t;
-struct osd_string_s {
+struct osd_string_s
+{
int width;
int height;
int r, g, b;
GstVBIDec *vbidec;
};
-osd_string_t *osd_string_new(char *c, int s, int w, int h, int a, void *user_data) {
+osd_string_t *
+osd_string_new (char *c, int s, int w, int h, int a, void *user_data)
+{
osd_string_t *os;
- os = (osd_string_t *)malloc(sizeof(osd_string_t));
+
+ os = (osd_string_t *) malloc (sizeof (osd_string_t));
if (!os)
return NULL;
os->width = 0;
os->height = 0;
os->r = os->g = os->b = 0;
os->visible = 1;
- os->vbidec = (GstVBIDec *)user_data;
+ os->vbidec = (GstVBIDec *) user_data;
return os;
}
-void osd_string_show_text(osd_string_t *os, char *s, int len ) {
+
+void
+osd_string_show_text (osd_string_t * os, char *s, int len)
+{
/* FIXME: just print data when it gets here */
if (len > 0) {
- gst_vbidec_show_text(os->vbidec, s, len);
+ gst_vbidec_show_text (os->vbidec, s, len);
}
}
-int osd_string_get_height(osd_string_t *os) {
+int
+osd_string_get_height (osd_string_t * os)
+{
return os->height;
}
-int osd_string_get_width(osd_string_t *os) {
+
+int
+osd_string_get_width (osd_string_t * os)
+{
return os->width;
}
-void osd_string_delete(osd_string_t *os) {
- free(os);
+
+void
+osd_string_delete (osd_string_t * os)
+{
+ free (os);
}
-void osd_string_set_colour_rgb(osd_string_t *os, int r, int g, int b) {
+
+void
+osd_string_set_colour_rgb (osd_string_t * os, int r, int g, int b)
+{
os->r = r;
os->g = g;
os->b = b;
}
-void blit_colour_packed422_scanline( unsigned char *d, int w, int luma, int cb, int cr) {
+
+void
+blit_colour_packed422_scanline (unsigned char *d, int w, int luma, int cb,
+ int cr)
+{
}
-int osd_string_visible(osd_string_t *os) {
+int
+osd_string_visible (osd_string_t * os)
+{
return os->visible;
}
-void osd_string_composite_packed422_scanline(osd_string_t *os, unsigned char *a, unsigned char *b, int w, int x, int y) {
+
+void
+osd_string_composite_packed422_scanline (osd_string_t * os, unsigned char *a,
+ unsigned char *b, int w, int x, int y)
+{
}
-struct vbiscreen_s {
+struct vbiscreen_s
+{
+
+ osd_string_t *line[ROWS];
- osd_string_t *line[ ROWS ];
+ char buffers[ROWS * COLS * 2];
+ char text[2 * ROWS * COLS];
+ char hiddenbuf[COLS];
+ char paintbuf[ROWS * COLS];
- char buffers[ ROWS * COLS * 2 ];
- char text[ 2 * ROWS * COLS ];
- char hiddenbuf[ COLS ];
- char paintbuf[ ROWS * COLS ];
+ unsigned int fgcolour;
+ unsigned int bgcolour;
+ int bg_luma, bg_cb, bg_cr;
- unsigned int fgcolour;
- unsigned int bgcolour;
- int bg_luma, bg_cb, bg_cr;
+ int frame_width;
+ int frame_height;
+ int frame_aspect;
- int frame_width;
- int frame_height;
- int frame_aspect;
+ int x, y; /* where to draw console */
+ int width, height; /* the size box we have to draw in */
+ int rowheight, charwidth;
- int x, y; /* where to draw console */
- int width, height; /* the size box we have to draw in */
- int rowheight, charwidth;
-
- int curx, cury; /* cursor position */
- int rows, cols; /* 32 cols 15 rows */
- int captions, style; /* CC (1) or Text (0), RU2 RU3 RU4 POP_UP PAINT_ON */
- int first_line; /* where to start drawing */
- int curbuffer;
- int top_of_screen; /* a pointer into line[] */
- int indent;
- int got_eoc;
- int scroll;
+ int curx, cury; /* cursor position */
+ int rows, cols; /* 32 cols 15 rows */
+ int captions, style; /* CC (1) or Text (0), RU2 RU3 RU4 POP_UP PAINT_ON */
+ int first_line; /* where to start drawing */
+ int curbuffer;
+ int top_of_screen; /* a pointer into line[] */
+ int indent;
+ int got_eoc;
+ int scroll;
- char *fontfile;
- int fontsize;
- int verbose;
+ char *fontfile;
+ int fontsize;
+ int verbose;
- void *user_data;
+ void *user_data;
};
-vbiscreen_t *vbiscreen_new( int video_width, int video_height,
- double video_aspect, int verbose, void *user_data )
+vbiscreen_t *
+vbiscreen_new (int video_width, int video_height,
+ double video_aspect, int verbose, void *user_data)
{
- int i=0, fontsize = FONT_SIZE;
- vbiscreen_t *vs = (vbiscreen_t *)malloc(sizeof(struct vbiscreen_s));
+ int i = 0, fontsize = FONT_SIZE;
+ vbiscreen_t *vs = (vbiscreen_t *) malloc (sizeof (struct vbiscreen_s));
- if( !vs ) {
- return NULL;
- }
+ if (!vs) {
+ return NULL;
+ }
- vs->verbose = verbose;
- vs->x = 0;
- vs->y = 0;
- vs->frame_width = video_width;
- vs->frame_height = video_height;
- vs->frame_aspect = video_aspect;
- vs->curx = 0;
- vs->cury = 0;
- vs->fgcolour = 0xFFFFFFFFU; /* white */
- vs->bgcolour = 0xFF000000U; /* black */
- vs->bg_luma = 16;
- vs->bg_cb = 128;
- vs->bg_cr = 128;
- vs->rows = ROWS;
- vs->cols = COLS;
- /*vs->fontfile = DATADIR "/FreeMonoBold.ttf";*/
- vs->fontfile = NULL;
- vs->fontsize = fontsize;
- vs->width = video_width;
- vs->height = video_height;
- vs->first_line = 0;
- vs->captions = 0;
- vs->style = 0;
- vs->curbuffer = 0;
- vs->top_of_screen = 0;
- vs->indent = 0;
- memset( vs->buffers, 0, 2 * COLS * ROWS );
- memset( vs->hiddenbuf, 0, COLS );
- memset( vs->paintbuf, 0, ROWS * COLS );
- vs->scroll = 0;
-
- vs->user_data = user_data;
-
- vs->line[0] = osd_string_new( vs->fontfile, fontsize, video_width,
- video_height,
- video_aspect,
- user_data);
-
- if( !vs->line[0] ) {
- vs->fontfile = "./FreeMonoBold.ttf";
-
- vs->line[0] = osd_string_new( vs->fontfile, fontsize,
- video_width,
- video_height,
- video_aspect,
- user_data);
- }
+ vs->verbose = verbose;
+ vs->x = 0;
+ vs->y = 0;
+ vs->frame_width = video_width;
+ vs->frame_height = video_height;
+ vs->frame_aspect = video_aspect;
+ vs->curx = 0;
+ vs->cury = 0;
+ vs->fgcolour = 0xFFFFFFFFU; /* white */
+ vs->bgcolour = 0xFF000000U; /* black */
+ vs->bg_luma = 16;
+ vs->bg_cb = 128;
+ vs->bg_cr = 128;
+ vs->rows = ROWS;
+ vs->cols = COLS;
+ /*vs->fontfile = DATADIR "/FreeMonoBold.ttf"; */
+ vs->fontfile = NULL;
+ vs->fontsize = fontsize;
+ vs->width = video_width;
+ vs->height = video_height;
+ vs->first_line = 0;
+ vs->captions = 0;
+ vs->style = 0;
+ vs->curbuffer = 0;
+ vs->top_of_screen = 0;
+ vs->indent = 0;
+ memset (vs->buffers, 0, 2 * COLS * ROWS);
+ memset (vs->hiddenbuf, 0, COLS);
+ memset (vs->paintbuf, 0, ROWS * COLS);
+ vs->scroll = 0;
+
+ vs->user_data = user_data;
+
+ vs->line[0] = osd_string_new (vs->fontfile, fontsize, video_width,
+ video_height, video_aspect, user_data);
+
+ if (!vs->line[0]) {
+ vs->fontfile = "./FreeMonoBold.ttf";
+
+ vs->line[0] = osd_string_new (vs->fontfile, fontsize,
+ video_width, video_height, video_aspect, user_data);
+ }
- if( !vs->line[0] ) {
- fprintf( stderr, "vbiscreen: Could not find my font (%s)!\n",
- vs->fontfile );
- vbiscreen_delete( vs );
- return NULL;
- }
+ if (!vs->line[0]) {
+ fprintf (stderr, "vbiscreen: Could not find my font (%s)!\n", vs->fontfile);
+ vbiscreen_delete (vs);
+ return NULL;
+ }
- osd_string_show_text( vs->line[ 0 ], "W", 0 );
- vs->rowheight = osd_string_get_height( vs->line[ 0 ] );
- vs->charwidth = osd_string_get_width( vs->line[ 0 ] );
- osd_string_delete( vs->line[ 0 ] );
-
- for( i = 0; i < ROWS; i++ ) {
- vs->line[ i ] = osd_string_new( vs->fontfile, fontsize,
- video_width, video_height,
- video_aspect,
- user_data);
- if( !vs->line[ i ] ) {
- fprintf( stderr, "vbiscreen: Could not allocate a line.\n" );
- vbiscreen_delete( vs );
- return NULL;
- }
- osd_string_set_colour_rgb( vs->line[ i ],
- (vs->fgcolour & 0xff0000) >> 16,
- (vs->fgcolour & 0xff00) >> 8,
- (vs->fgcolour & 0xff) );
- osd_string_show_text( vs->line[ i ], " ", 0 );
+ osd_string_show_text (vs->line[0], "W", 0);
+ vs->rowheight = osd_string_get_height (vs->line[0]);
+ vs->charwidth = osd_string_get_width (vs->line[0]);
+ osd_string_delete (vs->line[0]);
+
+ for (i = 0; i < ROWS; i++) {
+ vs->line[i] = osd_string_new (vs->fontfile, fontsize,
+ video_width, video_height, video_aspect, user_data);
+ if (!vs->line[i]) {
+ fprintf (stderr, "vbiscreen: Could not allocate a line.\n");
+ vbiscreen_delete (vs);
+ return NULL;
}
- memset( vs->text, 0, 2 * ROWS * COLS );
- return vs;
+ osd_string_set_colour_rgb (vs->line[i],
+ (vs->fgcolour & 0xff0000) >> 16,
+ (vs->fgcolour & 0xff00) >> 8, (vs->fgcolour & 0xff));
+ osd_string_show_text (vs->line[i], " ", 0);
+ }
+ memset (vs->text, 0, 2 * ROWS * COLS);
+ return vs;
}
-void blank_screen( vbiscreen_t *vs )
+void
+blank_screen (vbiscreen_t * vs)
{
- int i;
+ int i;
- if( vs->verbose ) fprintf( stderr, "in blank\n");
- for( i = 0; i < ROWS; i++ ) {
- osd_string_show_text( vs->line[ i ], " ", 0 );
- }
+ if (vs->verbose)
+ fprintf (stderr, "in blank\n");
+ for (i = 0; i < ROWS; i++) {
+ osd_string_show_text (vs->line[i], " ", 0);
+ }
}
-void clear_screen( vbiscreen_t *vs )
+void
+clear_screen (vbiscreen_t * vs)
{
- int base, i;
- if( !vs ) return;
+ int base, i;
- base = vs->top_of_screen * COLS;
- for( i = 0; i < ROWS * COLS; i++ ) {
- vs->text[ base ] = 0;
- base++;
- base %= 2 * ROWS * COLS;
- }
- blank_screen( vs );
+ if (!vs)
+ return;
+
+ base = vs->top_of_screen * COLS;
+ for (i = 0; i < ROWS * COLS; i++) {
+ vs->text[base] = 0;
+ base++;
+ base %= 2 * ROWS * COLS;
+ }
+ blank_screen (vs);
}
-void clear_hidden_roll( vbiscreen_t *vs )
+void
+clear_hidden_roll (vbiscreen_t * vs)
{
- if( !vs ) return;
- memset( vs->hiddenbuf, 0, COLS );
+ if (!vs)
+ return;
+ memset (vs->hiddenbuf, 0, COLS);
}
-void clear_hidden_pop( vbiscreen_t *vs )
+void
+clear_hidden_pop (vbiscreen_t * vs)
{
- if( !vs ) return;
- memset( vs->buffers + vs->curbuffer * COLS * ROWS , 0, COLS * ROWS );
+ if (!vs)
+ return;
+ memset (vs->buffers + vs->curbuffer * COLS * ROWS, 0, COLS * ROWS);
}
-void clear_hidden_paint( vbiscreen_t *vs )
+void
+clear_hidden_paint (vbiscreen_t * vs)
{
- if( !vs ) return;
- memset( vs->paintbuf , 0, COLS * ROWS );
+ if (!vs)
+ return;
+ memset (vs->paintbuf, 0, COLS * ROWS);
}
-void clear_displayed_pop( vbiscreen_t *vs )
+void
+clear_displayed_pop (vbiscreen_t * vs)
{
- if( !vs ) return;
- memset( vs->buffers + ( vs->curbuffer ^ 1 ) * COLS * ROWS , 0, COLS * ROWS );
+ if (!vs)
+ return;
+ memset (vs->buffers + (vs->curbuffer ^ 1) * COLS * ROWS, 0, COLS * ROWS);
}
-void vbiscreen_dump_screen_text( vbiscreen_t *vs )
+void
+vbiscreen_dump_screen_text (vbiscreen_t * vs)
{
- int i, offset;
-
- if( !vs ) return;
- offset = vs->top_of_screen * COLS;
-
- fprintf( stderr, "\n 0123456789abcdefghij012345678901" );
- for( i = 0; i < ROWS * COLS; i++ ) {
- if( !(i % COLS) )
- fprintf( stderr, "\n%.2d ", i / COLS );
- fprintf( stderr, "%c", vs->text[ offset ] ? vs->text[ offset ] : ' ' );
- offset++;
- offset %= 2 * ROWS * COLS;
- }
- fprintf( stderr, "\n 0123456789abcdefghij012345678901\n " );
- for( i = 0; i < COLS; i++ ) {
- fprintf( stderr, "%c", vs->text[ offset ] ? vs->text[ offset ] : ' ' );
- offset++;
- offset %= 2 * ROWS * COLS;
- }
- fprintf( stderr, "\n 0123456789abcdefghij012345678901\n" );
+ int i, offset;
+
+ if (!vs)
+ return;
+ offset = vs->top_of_screen * COLS;
+
+ fprintf (stderr, "\n 0123456789abcdefghij012345678901");
+ for (i = 0; i < ROWS * COLS; i++) {
+ if (!(i % COLS))
+ fprintf (stderr, "\n%.2d ", i / COLS);
+ fprintf (stderr, "%c", vs->text[offset] ? vs->text[offset] : ' ');
+ offset++;
+ offset %= 2 * ROWS * COLS;
+ }
+ fprintf (stderr, "\n 0123456789abcdefghij012345678901\n ");
+ for (i = 0; i < COLS; i++) {
+ fprintf (stderr, "%c", vs->text[offset] ? vs->text[offset] : ' ');
+ offset++;
+ offset %= 2 * ROWS * COLS;
+ }
+ fprintf (stderr, "\n 0123456789abcdefghij012345678901\n");
}
-int update_row_x( vbiscreen_t *vs, int row )
+int
+update_row_x (vbiscreen_t * vs, int row)
{
- char text[ COLS + 1 ];
- int i, j, haschars = 0, base;
-
- if( !vs ) return 0;
-
- text[ COLS ] = 0;
- base = ( ( vs->top_of_screen + row ) % ( 2 * ROWS ) ) * COLS;
- for( j = 0, i = base; i < base + COLS; i++, j++ ) {
- if( vs->text[ i ] ) {
- text[ j ] = vs->text[ i ];
- haschars = 1;
- } else {
- text[ j ] = ' ';
- }
+ char text[COLS + 1];
+ int i, j, haschars = 0, base;
+
+ if (!vs)
+ return 0;
+
+ text[COLS] = 0;
+ base = ((vs->top_of_screen + row) % (2 * ROWS)) * COLS;
+ for (j = 0, i = base; i < base + COLS; i++, j++) {
+ if (vs->text[i]) {
+ text[j] = vs->text[i];
+ haschars = 1;
+ } else {
+ text[j] = ' ';
}
+ }
- osd_string_set_colour_rgb( vs->line[ row ],
- ( vs->fgcolour & 0xff0000 ) >> 16,
- ( vs->fgcolour & 0xff00 ) >> 8,
- ( vs->fgcolour & 0xff ) );
- if( !haschars )
- osd_string_show_text( vs->line[ row ], " ", 0 );
- else
- osd_string_show_text( vs->line[ row ], text, 51 );
+ osd_string_set_colour_rgb (vs->line[row],
+ (vs->fgcolour & 0xff0000) >> 16,
+ (vs->fgcolour & 0xff00) >> 8, (vs->fgcolour & 0xff));
+ if (!haschars)
+ osd_string_show_text (vs->line[row], " ", 0);
+ else
+ osd_string_show_text (vs->line[row], text, 51);
- return haschars;
+ return haschars;
}
-void update_row( vbiscreen_t *vs )
+void
+update_row (vbiscreen_t * vs)
{
- if( !vs ) return;
+ if (!vs)
+ return;
- update_row_x( vs, vs->cury );
- //vbiscreen_dump_screen_text( vs );
+ update_row_x (vs, vs->cury);
+ //vbiscreen_dump_screen_text( vs );
}
-void update_all_rows( vbiscreen_t *vs )
+void
+update_all_rows (vbiscreen_t * vs)
{
- int row = 0;
+ int row = 0;
- if( !vs ) return;
+ if (!vs)
+ return;
- for( row = 0; row < ROWS; row++ ) {
- update_row_x( vs, row );
- }
- //vbiscreen_dump_screen_text( vs );
+ for (row = 0; row < ROWS; row++) {
+ update_row_x (vs, row);
+ }
+ //vbiscreen_dump_screen_text( vs );
}
-void vbiscreen_delete( vbiscreen_t *vs )
+void
+vbiscreen_delete (vbiscreen_t * vs)
{
- free( vs );
+ free (vs);
}
-void copy_row_to_screen( vbiscreen_t *vs, char *row )
+void
+copy_row_to_screen (vbiscreen_t * vs, char *row)
{
- int base, i, j;
+ int base, i, j;
- base = ( ( vs->top_of_screen + vs->cury ) % ( 2 * ROWS ) ) * COLS;
- for( j = 0, i = base;
- i < base + COLS;
- j++, i++ ) {
- vs->text[ i ] = row[ j ];
- }
- update_row( vs );
+ base = ((vs->top_of_screen + vs->cury) % (2 * ROWS)) * COLS;
+ for (j = 0, i = base; i < base + COLS; j++, i++) {
+ vs->text[i] = row[j];
+ }
+ update_row (vs);
}
-void scroll_screen( vbiscreen_t *vs )
+void
+scroll_screen (vbiscreen_t * vs)
{
- int start_row;
+ int start_row;
- if( !vs || !vs->captions || !vs->style || vs->style > ROLL_4 )
- return;
-
- start_row = ( vs->first_line + vs->top_of_screen ) % ( 2 * ROWS );
- if( vs->verbose )
- fprintf ( stderr, "start row : %d first line %d\n ", start_row,
- vs->first_line );
+ if (!vs || !vs->captions || !vs->style || vs->style > ROLL_4)
+ return;
- /* zero out top row */
- memset( (char *)( vs->text + start_row * COLS ), 0, COLS );
- vs->top_of_screen = ( vs->top_of_screen + 1 ) % ( 2 * ROWS );
- vs->curx = vs->indent;
- update_all_rows( vs );
- copy_row_to_screen( vs, vs->hiddenbuf );
- clear_hidden_roll( vs );
- vs->scroll = 26;
+ start_row = (vs->first_line + vs->top_of_screen) % (2 * ROWS);
+ if (vs->verbose)
+ fprintf (stderr, "start row : %d first line %d\n ", start_row,
+ vs->first_line);
+
+ /* zero out top row */
+ memset ((char *) (vs->text + start_row * COLS), 0, COLS);
+ vs->top_of_screen = (vs->top_of_screen + 1) % (2 * ROWS);
+ vs->curx = vs->indent;
+ update_all_rows (vs);
+ copy_row_to_screen (vs, vs->hiddenbuf);
+ clear_hidden_roll (vs);
+ vs->scroll = 26;
}
-void vbiscreen_set_verbose( vbiscreen_t *vs, int verbose )
+void
+vbiscreen_set_verbose (vbiscreen_t * vs, int verbose)
{
- vs->verbose = verbose;
+ vs->verbose = verbose;
}
-void vbiscreen_new_caption( vbiscreen_t *vs, int indent, int ital,
- unsigned int colour, int row )
+void
+vbiscreen_new_caption (vbiscreen_t * vs, int indent, int ital,
+ unsigned int colour, int row)
{
- if( !vs ) return;
- if( vs->verbose ) fprintf( stderr, "indent: %d, ital: %d, colour: 0x%x, row: %d\n", indent, ital, colour, row );
-
- if( 0 && vs->captions && vs->style <= ROLL_4 && vs->style ) {
- if( row != vs->cury+1 ) {
- vs->cury = row - 1;
- clear_hidden_roll( vs );
- } else {
+ if (!vs)
+ return;
+ if (vs->verbose)
+ fprintf (stderr, "indent: %d, ital: %d, colour: 0x%x, row: %d\n", indent,
+ ital, colour, row);
+
+ if (0 && vs->captions && vs->style <= ROLL_4 && vs->style) {
+ if (row != vs->cury + 1) {
+ vs->cury = row - 1;
+ clear_hidden_roll (vs);
+ } else {
// scroll_screen( vs );
- }
}
+ }
- if( vs->style > ROLL_4 ) {
- vs->cury = ( ( row > 0 ) ? row - 1 : 0 );
- }
+ if (vs->style > ROLL_4) {
+ vs->cury = ((row > 0) ? row - 1 : 0);
+ }
- vs->fgcolour = colour;
- vs->indent = indent;
- vs->curx = indent;
-}
-
-void vbiscreen_set_mode( vbiscreen_t *vs, int caption, int style )
-{
- if( !vs ) return;
- if( vs->verbose )
- fprintf( stderr, "in set mode\n");
-
- if( vs->verbose ) {
- fprintf( stderr, "Caption: %d ", caption );
- switch( style ) {
- case ROLL_2:
- fprintf( stderr, "ROLL 2\n");
- break;
- case ROLL_3:
- fprintf( stderr, "ROLL 3\n" );
- break;
- case ROLL_4:
- fprintf( stderr, "ROLL 4\n" );
- break;
- case POP_UP:
- fprintf( stderr, "POP UP\n" );
- break;
- case PAINT_ON:
- fprintf( stderr, "PAINT ON\n" );
- break;
- default:
- break;
- }
+ vs->fgcolour = colour;
+ vs->indent = indent;
+ vs->curx = indent;
+}
+
+void
+vbiscreen_set_mode (vbiscreen_t * vs, int caption, int style)
+{
+ if (!vs)
+ return;
+ if (vs->verbose)
+ fprintf (stderr, "in set mode\n");
+
+ if (vs->verbose) {
+ fprintf (stderr, "Caption: %d ", caption);
+ switch (style) {
+ case ROLL_2:
+ fprintf (stderr, "ROLL 2\n");
+ break;
+ case ROLL_3:
+ fprintf (stderr, "ROLL 3\n");
+ break;
+ case ROLL_4:
+ fprintf (stderr, "ROLL 4\n");
+ break;
+ case POP_UP:
+ fprintf (stderr, "POP UP\n");
+ break;
+ case PAINT_ON:
+ fprintf (stderr, "PAINT ON\n");
+ break;
+ default:
+ break;
}
- if( !caption ) {
- /* text mode */
- vs->cury = 0;
- } else {
- /* captioning mode */
- /* styles: ru2 ru3 ru4 pop paint
- */
- if( style != POP_UP && vs->style == POP_UP && !vs->got_eoc ) {
- /* stupid that sometimes they dont send a EOC */
- vbiscreen_end_of_caption( vs );
- }
-
- switch( style ) {
- case ROLL_2:
- case ROLL_3:
- case ROLL_4:
- if( vs->style == style ) {
- return;
- }
- vs->first_line = ROWS - (style - 4);
-
- if( vs->verbose )
- fprintf( stderr, "first_line %d\n", vs->first_line );
-
- vs->cury = ROWS - 1;
- break;
- case POP_UP:
- vs->got_eoc = 0;
- break;
- case PAINT_ON:
- break;
- }
+ }
+ if (!caption) {
+ /* text mode */
+ vs->cury = 0;
+ } else {
+ /* captioning mode */
+ /* styles: ru2 ru3 ru4 pop paint
+ */
+ if (style != POP_UP && vs->style == POP_UP && !vs->got_eoc) {
+ /* stupid that sometimes they dont send a EOC */
+ vbiscreen_end_of_caption (vs);
}
- vs->captions = caption;
- vs->style = style;
-}
+ switch (style) {
+ case ROLL_2:
+ case ROLL_3:
+ case ROLL_4:
+ if (vs->style == style) {
+ return;
+ }
+ vs->first_line = ROWS - (style - 4);
+
+ if (vs->verbose)
+ fprintf (stderr, "first_line %d\n", vs->first_line);
+
+ vs->cury = ROWS - 1;
+ break;
+ case POP_UP:
+ vs->got_eoc = 0;
+ break;
+ case PAINT_ON:
+ break;
+ }
+ }
-void vbiscreen_tab( vbiscreen_t *vs, int cols )
-{
- if( !vs ) return;
- if( cols < 0 || cols > 3 ) return;
- vs->curx += cols;
- if( vs->curx > 31 ) vs->curx = 31;
+ vs->captions = caption;
+ vs->style = style;
}
-void vbiscreen_set_colour( vbiscreen_t *vs, unsigned int col )
+void
+vbiscreen_tab (vbiscreen_t * vs, int cols)
{
- if( !vs ) return;
- vs->fgcolour = col;
+ if (!vs)
+ return;
+ if (cols < 0 || cols > 3)
+ return;
+ vs->curx += cols;
+ if (vs->curx > 31)
+ vs->curx = 31;
}
-void vbiscreen_clear_current_cell( vbiscreen_t *vs )
+void
+vbiscreen_set_colour (vbiscreen_t * vs, unsigned int col)
{
- vs->text[ ( ( vs->top_of_screen + vs->cury ) % ( 2 * ROWS ) ) * COLS
- + vs->curx + vs->indent ] = 0;
+ if (!vs)
+ return;
+ vs->fgcolour = col;
}
-void vbiscreen_set_current_cell( vbiscreen_t *vs, char text )
+void
+vbiscreen_clear_current_cell (vbiscreen_t * vs)
{
- int base;
- if( !vs ) return;
- base = ( ( vs->top_of_screen + vs->cury ) % ( 2 * ROWS ) ) * COLS;
- if( g_ascii_isprint( text ) )
- vs->text[ base + vs->curx + vs->indent ] = text;
- else
- vs->text[ base + vs->curx + vs->indent ] = ' ';
+ vs->text[((vs->top_of_screen + vs->cury) % (2 * ROWS)) * COLS
+ + vs->curx + vs->indent] = 0;
}
-void vbiscreen_delete_to_end( vbiscreen_t *vs )
+void
+vbiscreen_set_current_cell (vbiscreen_t * vs, char text)
{
- int i;
- if( !vs ) return;
- if( vs->verbose ) fprintf( stderr, "in del to end\n");
- for( i = vs->curx; i < COLS; i++ ) {
- vbiscreen_clear_current_cell( vs );
- vs->curx++;
- }
- vs->curx = COLS-1; /* is this right ? */
- if( vs->captions && vs->style && vs->style != POP_UP )
- update_row( vs );
+ int base;
+
+ if (!vs)
+ return;
+ base = ((vs->top_of_screen + vs->cury) % (2 * ROWS)) * COLS;
+ if (g_ascii_isprint (text))
+ vs->text[base + vs->curx + vs->indent] = text;
+ else
+ vs->text[base + vs->curx + vs->indent] = ' ';
}
-void vbiscreen_backspace( vbiscreen_t *vs )
+void
+vbiscreen_delete_to_end (vbiscreen_t * vs)
{
- if( !vs ) return;
- if( vs->verbose ) fprintf( stderr, "in backspace\n");
- if( !vs->curx ) return;
- vs->curx--;
- vbiscreen_clear_current_cell( vs );
- update_row( vs );
+ int i;
+
+ if (!vs)
+ return;
+ if (vs->verbose)
+ fprintf (stderr, "in del to end\n");
+ for (i = vs->curx; i < COLS; i++) {
+ vbiscreen_clear_current_cell (vs);
+ vs->curx++;
+ }
+ vs->curx = COLS - 1; /* is this right ? */
+ if (vs->captions && vs->style && vs->style != POP_UP)
+ update_row (vs);
}
-void vbiscreen_erase_displayed( vbiscreen_t *vs )
+void
+vbiscreen_backspace (vbiscreen_t * vs)
+{
+ if (!vs)
+ return;
+ if (vs->verbose)
+ fprintf (stderr, "in backspace\n");
+ if (!vs->curx)
+ return;
+ vs->curx--;
+ vbiscreen_clear_current_cell (vs);
+ update_row (vs);
+}
+
+void
+vbiscreen_erase_displayed (vbiscreen_t * vs)
{
- if( !vs ) return;
- if( vs->verbose ) fprintf( stderr, "in erase disp\n");
+ if (!vs)
+ return;
+ if (vs->verbose)
+ fprintf (stderr, "in erase disp\n");
- if( vs->captions && vs->style && vs->style <= ROLL_4 ) {
- clear_hidden_roll( vs );
- }
+ if (vs->captions && vs->style && vs->style <= ROLL_4) {
+ clear_hidden_roll (vs);
+ }
- clear_displayed_pop( vs );
- clear_screen( vs );
+ clear_displayed_pop (vs);
+ clear_screen (vs);
}
-void vbiscreen_erase_non_displayed( vbiscreen_t *vs )
+void
+vbiscreen_erase_non_displayed (vbiscreen_t * vs)
{
- if( !vs ) return;
- if( vs->verbose ) fprintf( stderr, "in erase non disp\n");
-
- if( vs->captions && vs->style == POP_UP ) {
- memset( vs->buffers + vs->curbuffer * COLS * ROWS + vs->cury * COLS, 0, COLS );
+ if (!vs)
+ return;
+ if (vs->verbose)
+ fprintf (stderr, "in erase non disp\n");
+
+ if (vs->captions && vs->style == POP_UP) {
+ memset (vs->buffers + vs->curbuffer * COLS * ROWS + vs->cury * COLS, 0,
+ COLS);
// clear_hidden_pop( vs );
- } else if( vs->captions && vs->style && vs->style <= ROLL_4 ) {
- clear_hidden_roll( vs );
- }
+ } else if (vs->captions && vs->style && vs->style <= ROLL_4) {
+ clear_hidden_roll (vs);
+ }
}
-void vbiscreen_carriage_return( vbiscreen_t *vs )
+void
+vbiscreen_carriage_return (vbiscreen_t * vs)
{
- if( !vs ) return;
- if( vs->verbose ) fprintf( stderr, "in CR\n");
- if( vs->style != POP_UP) {
- /* not sure if this is right for text mode */
- /* in text mode, perhaps a CR on last row clears screen and goes
- * to (0,0) */
- scroll_screen( vs );
- }
+ if (!vs)
+ return;
+ if (vs->verbose)
+ fprintf (stderr, "in CR\n");
+ if (vs->style != POP_UP) {
+ /* not sure if this is right for text mode */
+ /* in text mode, perhaps a CR on last row clears screen and goes
+ * to (0,0) */
+ scroll_screen (vs);
+ }
- /* keep cursor on bottom for rollup */
- if( vs->captions && vs->style && vs->style <= ROLL_4 )
- vs->cury--;
+ /* keep cursor on bottom for rollup */
+ if (vs->captions && vs->style && vs->style <= ROLL_4)
+ vs->cury--;
- vs->cury++;
- vs->curx = 0;
+ vs->cury++;
+ vs->curx = 0;
}
-void copy_buf_to_screen( vbiscreen_t *vs, char *buf )
+void
+copy_buf_to_screen (vbiscreen_t * vs, char *buf)
{
- int base, i, j;
- if( !vs ) return;
+ int base, i, j;
- base = vs->top_of_screen * COLS;
- for( j = 0, i = 0; i < ROWS * COLS; i++, j++ ) {
- vs->text[ base ] = buf[ j ];
- base++;
- base %= 2 * ROWS * COLS;
- }
- update_all_rows( vs );
+ if (!vs)
+ return;
+
+ base = vs->top_of_screen * COLS;
+ for (j = 0, i = 0; i < ROWS * COLS; i++, j++) {
+ vs->text[base] = buf[j];
+ base++;
+ base %= 2 * ROWS * COLS;
+ }
+ update_all_rows (vs);
}
-void vbiscreen_end_of_caption( vbiscreen_t *vs )
+void
+vbiscreen_end_of_caption (vbiscreen_t * vs)
{
- /*int i;*/
- if( !vs ) return;
- if( vs->verbose ) fprintf( stderr, "in end of caption\n");
+ /*int i; */
+ if (!vs)
+ return;
+ if (vs->verbose)
+ fprintf (stderr, "in end of caption\n");
+
+ if (vs->style == PAINT_ON) {
+ copy_buf_to_screen (vs, vs->paintbuf);
+ clear_hidden_paint (vs);
+ } else if (vs->style == POP_UP) {
+ copy_buf_to_screen (vs, vs->buffers + vs->curbuffer * COLS * ROWS);
+ vs->curbuffer ^= 1;
+ }
+
+ /* to be safe? */
+ vs->curx = 0;
+ vs->cury = ROWS - 1;
+ vs->got_eoc = 1;
+}
- if( vs->style == PAINT_ON ) {
- copy_buf_to_screen( vs, vs->paintbuf );
- clear_hidden_paint( vs );
- } else if( vs->style == POP_UP ) {
- copy_buf_to_screen( vs, vs->buffers + vs->curbuffer * COLS * ROWS );
- vs->curbuffer ^= 1;
+void
+vbiscreen_print (vbiscreen_t * vs, char c1, char c2)
+{
+ if (!vs)
+ return;
+ if (vs->verbose)
+ fprintf (stderr, "in print (%d, %d)[%c %c]\n", vs->curx, vs->cury, c1, c2);
+ if (vs->captions && vs->style == POP_UP) {
+ /* this all gets displayed at another time */
+ if (vs->curx != COLS - 1) {
+ *(vs->buffers + vs->curx + vs->curbuffer * ROWS * COLS +
+ vs->cury * COLS) = c1;
+ vs->curx++;
}
- /* to be safe? */
- vs->curx = 0;
- vs->cury = ROWS - 1;
- vs->got_eoc = 1;
-}
-
-void vbiscreen_print( vbiscreen_t *vs, char c1, char c2 )
-{
- if( !vs ) return;
- if( vs->verbose ) fprintf( stderr, "in print (%d, %d)[%c %c]\n", vs->curx, vs->cury, c1, c2);
- if( vs->captions && vs->style == POP_UP ) {
- /* this all gets displayed at another time */
- if( vs->curx != COLS-1 ) {
- *(vs->buffers + vs->curx + vs->curbuffer * ROWS * COLS + vs->cury * COLS ) = c1;
- vs->curx++;
- }
-
- if( vs->curx != COLS-1 && c2 ) {
- *(vs->buffers + vs->curx + vs->curbuffer * ROWS * COLS + vs->cury * COLS ) = c2;
- vs->curx++;
- } else if( c2 ) {
- *(vs->buffers + vs->curx + vs->curbuffer * ROWS * COLS + vs->cury * COLS ) = c2;
- }
+ if (vs->curx != COLS - 1 && c2) {
+ *(vs->buffers + vs->curx + vs->curbuffer * ROWS * COLS +
+ vs->cury * COLS) = c2;
+ vs->curx++;
+ } else if (c2) {
+ *(vs->buffers + vs->curx + vs->curbuffer * ROWS * COLS +
+ vs->cury * COLS) = c2;
}
+ }
- if( vs->captions && vs->style == PAINT_ON ) {
- if( vs->curx != COLS-1 ) {
- vs->paintbuf[ vs->curx + vs->cury * COLS ] = c1;
- vs->curx++;
- }
-
- if( vs->curx != COLS-1 && c2 ) {
- vs->paintbuf[ vs->curx + vs->cury * COLS ] = c2;
- vs->curx++;
- } else if( c2 ) {
- vs->paintbuf[ vs->curx + vs->cury * COLS ] = c2;
- }
+ if (vs->captions && vs->style == PAINT_ON) {
+ if (vs->curx != COLS - 1) {
+ vs->paintbuf[vs->curx + vs->cury * COLS] = c1;
+ vs->curx++;
}
- if( vs->captions && vs->style && vs->style <= ROLL_4 ) {
- if( vs->curx != COLS-1 ) {
- vs->hiddenbuf[ vs->curx ] = c1;
- vs->curx++;
- } else {
- vs->hiddenbuf[ vs->curx ] = c1;
- }
-
- if( vs->curx != COLS-1 && c2 ) {
- vs->hiddenbuf[ vs->curx ] = c2;
- vs->curx++;
- } else if( c2 ) {
- vs->hiddenbuf[ vs->curx ] = c2;
- }
+ if (vs->curx != COLS - 1 && c2) {
+ vs->paintbuf[vs->curx + vs->cury * COLS] = c2;
+ vs->curx++;
+ } else if (c2) {
+ vs->paintbuf[vs->curx + vs->cury * COLS] = c2;
+ }
+ }
+
+ if (vs->captions && vs->style && vs->style <= ROLL_4) {
+ if (vs->curx != COLS - 1) {
+ vs->hiddenbuf[vs->curx] = c1;
+ vs->curx++;
+ } else {
+ vs->hiddenbuf[vs->curx] = c1;
}
-}
-void vbiscreen_reset( vbiscreen_t *vs )
-{
- if( !vs ) return;
- clear_screen( vs );
- clear_hidden_pop( vs );
- clear_displayed_pop( vs );
- clear_hidden_roll( vs );
- vs->captions = 0;
- vs->style = 0;
-}
-
-void vbiscreen_composite_packed422_scanline( vbiscreen_t *vs,
- unsigned char *output,
- int width, int xpos,
- int scanline )
-{
- int x=0, y=0, row=0, index=0;
-
- if( !vs ) return;
- if( !output ) return;
- if( scanline >= vs->y && scanline < vs->y + vs->height ) {
-
- if( 0 && !vs->captions )
- blit_colour_packed422_scanline( output + (vs->x*2), vs->width,
- vs->bg_luma, vs->bg_cb,
- vs->bg_cr );
-
- index = vs->top_of_screen * COLS;
- x = ( vs->x + vs->charwidth) & ~1;
- for( row = 0; row < ROWS; row++ ) {
- y = vs->y + row * vs->rowheight + vs->rowheight;
- if( osd_string_visible( vs->line[ row ] ) ) {
- if( scanline >= y &&
- scanline < y + vs->rowheight ) {
-
- int startx;
- int strx;
-
- startx = x - xpos;
- strx = 0;
-
- if( startx < 0 ) {
- strx = -startx;
- startx = 0;
- }
-
-
- if( startx < width ) {
-
- if( vs->captions )
- blit_colour_packed422_scanline(
- output + (startx*2),
- osd_string_get_width( vs->line[ row ] ),
- vs->bg_luma,
- vs->bg_cb,
- vs->bg_cr );
-
- osd_string_composite_packed422_scanline(
- vs->line[ row ],
- output + (startx*2),
- output + (startx*2),
- width - startx,
- strx,
- scanline - y );
- }
- }
- index++;
- }
- }
+ if (vs->curx != COLS - 1 && c2) {
+ vs->hiddenbuf[vs->curx] = c2;
+ vs->curx++;
+ } else if (c2) {
+ vs->hiddenbuf[vs->curx] = c2;
}
+ }
}
+void
+vbiscreen_reset (vbiscreen_t * vs)
+{
+ if (!vs)
+ return;
+ clear_screen (vs);
+ clear_hidden_pop (vs);
+ clear_displayed_pop (vs);
+ clear_hidden_roll (vs);
+ vs->captions = 0;
+ vs->style = 0;
+}
+
+void
+vbiscreen_composite_packed422_scanline (vbiscreen_t * vs,
+ unsigned char *output, int width, int xpos, int scanline)
+{
+ int x = 0, y = 0, row = 0, index = 0;
+
+ if (!vs)
+ return;
+ if (!output)
+ return;
+ if (scanline >= vs->y && scanline < vs->y + vs->height) {
+
+ if (0 && !vs->captions)
+ blit_colour_packed422_scanline (output + (vs->x * 2), vs->width,
+ vs->bg_luma, vs->bg_cb, vs->bg_cr);
+
+ index = vs->top_of_screen * COLS;
+ x = (vs->x + vs->charwidth) & ~1;
+ for (row = 0; row < ROWS; row++) {
+ y = vs->y + row * vs->rowheight + vs->rowheight;
+ if (osd_string_visible (vs->line[row])) {
+ if (scanline >= y && scanline < y + vs->rowheight) {
+
+ int startx;
+ int strx;
+
+ startx = x - xpos;
+ strx = 0;
+
+ if (startx < 0) {
+ strx = -startx;
+ startx = 0;
+ }
+
+
+ if (startx < width) {
+
+ if (vs->captions)
+ blit_colour_packed422_scanline (output + (startx * 2),
+ osd_string_get_width (vs->line[row]),
+ vs->bg_luma, vs->bg_cb, vs->bg_cr);
+
+ osd_string_composite_packed422_scanline (vs->line[row],
+ output + (startx * 2),
+ output + (startx * 2), width - startx, strx, scanline - y);
+ }
+ }
+ index++;
+ }
+ }
+ }
+}
typedef struct vbiscreen_s vbiscreen_t;
-vbiscreen_t *vbiscreen_new( int video_width, int video_height,
- double video_aspect, int verbose, void *user_data );
-void vbiscreen_delete( vbiscreen_t *vs );
-void vbiscreen_set_verbose( vbiscreen_t *vs, int verbose );
-void vbiscreen_set_mode( vbiscreen_t *vs, int caption, int style);
-void vbiscreen_new_caption( vbiscreen_t *vs, int indent, int ital,
- unsigned int colour, int row );
-void vbiscreen_tab( vbiscreen_t *vs, int cols );
-void vbiscreen_delete_to_end( vbiscreen_t *vs );
-void vbiscreen_backspace( vbiscreen_t *vs );
-void vbiscreen_erase_displayed( vbiscreen_t *vs );
-void vbiscreen_erase_non_displayed( vbiscreen_t *vs );
-void vbiscreen_carriage_return( vbiscreen_t *vs );
-void vbiscreen_end_of_caption( vbiscreen_t *vs );
-void vbiscreen_print( vbiscreen_t *vs, char c1, char c2 );
-void vbiscreen_composite_packed422_scanline( vbiscreen_t *vs,
- unsigned char *output,
- int width, int xpos,
- int scanline );
-void vbiscreen_dump_screen_text( vbiscreen_t *vs );
-void vbiscreen_reset( vbiscreen_t *vs );
+vbiscreen_t *vbiscreen_new (int video_width, int video_height,
+ double video_aspect, int verbose, void *user_data);
+void vbiscreen_delete (vbiscreen_t * vs);
+void vbiscreen_set_verbose (vbiscreen_t * vs, int verbose);
+void vbiscreen_set_mode (vbiscreen_t * vs, int caption, int style);
+void vbiscreen_new_caption (vbiscreen_t * vs, int indent, int ital,
+ unsigned int colour, int row);
+void vbiscreen_tab (vbiscreen_t * vs, int cols);
+void vbiscreen_delete_to_end (vbiscreen_t * vs);
+void vbiscreen_backspace (vbiscreen_t * vs);
+void vbiscreen_erase_displayed (vbiscreen_t * vs);
+void vbiscreen_erase_non_displayed (vbiscreen_t * vs);
+void vbiscreen_carriage_return (vbiscreen_t * vs);
+void vbiscreen_end_of_caption (vbiscreen_t * vs);
+void vbiscreen_print (vbiscreen_t * vs, char c1, char c2);
+void vbiscreen_composite_packed422_scanline (vbiscreen_t * vs,
+ unsigned char *output, int width, int xpos, int scanline);
+void vbiscreen_dump_screen_text (vbiscreen_t * vs);
+void vbiscreen_reset (vbiscreen_t * vs);
#endif
typedef struct _GstVideoCrop GstVideoCrop;
typedef struct _GstVideoCropClass GstVideoCropClass;
-struct _GstVideoCrop {
- GstElement element;
+struct _GstVideoCrop
+{
+ GstElement element;
/* pads */
- GstPad *sinkpad;
- GstPad *srcpad;
+ GstPad *sinkpad;
+ GstPad *srcpad;
/* caps */
- gint width, height;
- gdouble fps;
- gint crop_left, crop_right, crop_top, crop_bottom;
+ gint width, height;
+ gdouble fps;
+ gint crop_left, crop_right, crop_top, crop_bottom;
};
-struct _GstVideoCropClass {
+struct _GstVideoCropClass
+{
GstElementClass parent_class;
};
/* elementfactory information */
-static GstElementDetails gst_video_crop_details = GST_ELEMENT_DETAILS (
- "video crop filter",
- "Filter/Effect/Video",
- "Crops video into a user defined region",
- "Wim Taymans <wim.taymans@chello.be>"
-);
+static GstElementDetails gst_video_crop_details =
+GST_ELEMENT_DETAILS ("video crop filter",
+ "Filter/Effect/Video",
+ "Crops video into a user defined region",
+ "Wim Taymans <wim.taymans@chello.be>");
/* VideoCrop signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_LEFT,
ARG_RIGHT,
};
static GstStaticPadTemplate gst_video_crop_src_template =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420"))
-);
+GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420"))
+ );
static GstStaticPadTemplate gst_video_crop_sink_template =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420"))
-);
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420"))
+ );
-static void gst_video_crop_base_init (gpointer g_class);
-static void gst_video_crop_class_init (GstVideoCropClass *klass);
-static void gst_video_crop_init (GstVideoCrop *video_crop);
+static void gst_video_crop_base_init (gpointer g_class);
+static void gst_video_crop_class_init (GstVideoCropClass * klass);
+static void gst_video_crop_init (GstVideoCrop * video_crop);
-static void gst_video_crop_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_video_crop_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static void gst_video_crop_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_video_crop_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
static GstPadLinkReturn
- gst_video_crop_sink_link (GstPad *pad, const GstCaps *caps);
-static void gst_video_crop_chain (GstPad *pad, GstData *_data);
+gst_video_crop_sink_link (GstPad * pad, const GstCaps * caps);
+static void gst_video_crop_chain (GstPad * pad, GstData * _data);
-static GstElementStateReturn
- gst_video_crop_change_state (GstElement *element);
+static GstElementStateReturn gst_video_crop_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
+
/* static guint gst_video_crop_signals[LAST_SIGNAL] = { 0 }; */
GType
if (!video_crop_type) {
static const GTypeInfo video_crop_info = {
- sizeof(GstVideoCropClass),
+ sizeof (GstVideoCropClass),
gst_video_crop_base_init,
NULL,
- (GClassInitFunc)gst_video_crop_class_init,
+ (GClassInitFunc) gst_video_crop_class_init,
NULL,
NULL,
- sizeof(GstVideoCrop),
+ sizeof (GstVideoCrop),
0,
- (GInstanceInitFunc)gst_video_crop_init,
+ (GInstanceInitFunc) gst_video_crop_init,
};
- video_crop_type = g_type_register_static(GST_TYPE_ELEMENT, "GstVideoCrop", &video_crop_info, 0);
+ video_crop_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstVideoCrop",
+ &video_crop_info, 0);
}
return video_crop_type;
}
gst_element_class_set_details (element_class, &gst_video_crop_details);
- gst_element_class_add_pad_template (element_class,
+ gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_video_crop_sink_template));
- gst_element_class_add_pad_template (element_class,
+ gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_video_crop_src_template));
}
static void
-gst_video_crop_class_init (GstVideoCropClass *klass)
+gst_video_crop_class_init (GstVideoCropClass * 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);
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LEFT,
- g_param_spec_int ("left", "Left", "Pixels to crop at left",
- 0, G_MAXINT, 0, G_PARAM_READWRITE));
+ g_param_spec_int ("left", "Left", "Pixels to crop at left",
+ 0, G_MAXINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_RIGHT,
- g_param_spec_int ("right", "Right", "Pixels to crop at right",
- 0, G_MAXINT, 0, G_PARAM_READWRITE));
+ g_param_spec_int ("right", "Right", "Pixels to crop at right",
+ 0, G_MAXINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TOP,
- g_param_spec_int ("top", "Top", "Pixels to crop at top",
- 0, G_MAXINT, 0, G_PARAM_READWRITE));
+ g_param_spec_int ("top", "Top", "Pixels to crop at top",
+ 0, G_MAXINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BOTTOM,
- g_param_spec_int ("bottom", "Bottom", "Pixels to crop at bottom",
- 0, G_MAXINT, 0, G_PARAM_READWRITE));
+ g_param_spec_int ("bottom", "Bottom", "Pixels to crop at bottom",
+ 0, G_MAXINT, 0, G_PARAM_READWRITE));
gobject_class->set_property = gst_video_crop_set_property;
gobject_class->get_property = gst_video_crop_get_property;
}
static void
-gst_video_crop_init (GstVideoCrop *video_crop)
+gst_video_crop_init (GstVideoCrop * video_crop)
{
/* create the sink and src pads */
- video_crop->sinkpad = gst_pad_new_from_template(
- gst_static_pad_template_get (&gst_video_crop_sink_template), "sink");
+ video_crop->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_video_crop_sink_template), "sink");
gst_element_add_pad (GST_ELEMENT (video_crop), video_crop->sinkpad);
gst_pad_set_chain_function (video_crop->sinkpad, gst_video_crop_chain);
gst_pad_set_link_function (video_crop->sinkpad, gst_video_crop_sink_link);
- video_crop->srcpad = gst_pad_new_from_template(
- gst_static_pad_template_get (&gst_video_crop_src_template), "src");
+ video_crop->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_video_crop_src_template), "src");
gst_element_add_pad (GST_ELEMENT (video_crop), video_crop->srcpad);
video_crop->crop_right = 0;
/* do we need this function? */
static void
-gst_video_crop_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_video_crop_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstVideoCrop *video_crop;
-
+
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_VIDEO_CROP (object));
-
+
video_crop = GST_VIDEO_CROP (object);
switch (prop_id) {
}
}
static void
-gst_video_crop_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_video_crop_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstVideoCrop *video_crop;
-
+
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_VIDEO_CROP (object));
-
+
video_crop = GST_VIDEO_CROP (object);
switch (prop_id) {
}
static GstPadLinkReturn
-gst_video_crop_sink_link (GstPad *pad, const GstCaps *caps)
+gst_video_crop_sink_link (GstPad * pad, const GstCaps * caps)
{
GstVideoCrop *video_crop;
GstStructure *structure;
video_crop = GST_VIDEO_CROP (gst_pad_get_parent (pad));
structure = gst_caps_get_structure (caps, 0);
- ret = gst_structure_get_int (structure, "width", &video_crop->width);
+ ret = gst_structure_get_int (structure, "width", &video_crop->width);
ret &= gst_structure_get_int (structure, "height", &video_crop->height);
ret &= gst_structure_get_double (structure, "framerate", &video_crop->fps);
#define GST_VIDEO_I420_V_ROWSTRIDE(width) ((width)/2)
static void
-gst_video_crop_i420 (GstVideoCrop *video_crop, GstBuffer *src_buffer, GstBuffer *dest_buffer)
+gst_video_crop_i420 (GstVideoCrop * video_crop, GstBuffer * src_buffer,
+ GstBuffer * dest_buffer)
{
guint8 *src;
guint8 *dest;
guint8 *srcY, *srcU, *srcV;
guint8 *destY, *destU, *destV;
gint out_width = video_crop->width -
- (video_crop->crop_left + video_crop->crop_right);
+ (video_crop->crop_left + video_crop->crop_right);
gint out_height = video_crop->height -
- (video_crop->crop_top + video_crop->crop_bottom);
+ (video_crop->crop_top + video_crop->crop_bottom);
gint src_stride;
gint j;
src = GST_BUFFER_DATA (src_buffer);
dest = GST_BUFFER_DATA (dest_buffer);
- g_return_if_fail(GST_BUFFER_SIZE (dest_buffer) == GST_VIDEO_I420_SIZE(out_width,out_height));
+ g_return_if_fail (GST_BUFFER_SIZE (dest_buffer) ==
+ GST_VIDEO_I420_SIZE (out_width, out_height));
- srcY = src + GST_VIDEO_I420_Y_OFFSET(video_crop->width, video_crop->height);
- destY = dest + GST_VIDEO_I420_Y_OFFSET(out_width, out_height);
+ srcY = src + GST_VIDEO_I420_Y_OFFSET (video_crop->width, video_crop->height);
+ destY = dest + GST_VIDEO_I420_Y_OFFSET (out_width, out_height);
- src_stride = GST_VIDEO_I420_Y_ROWSTRIDE(video_crop->width);
+ src_stride = GST_VIDEO_I420_Y_ROWSTRIDE (video_crop->width);
/* copy Y plane first */
destY += out_width;
}
- src_stride = GST_VIDEO_I420_U_ROWSTRIDE(video_crop->width);
+ src_stride = GST_VIDEO_I420_U_ROWSTRIDE (video_crop->width);
- destU = dest + GST_VIDEO_I420_U_OFFSET(out_width, out_height);
- destV = dest + GST_VIDEO_I420_V_OFFSET(out_width, out_height);
+ destU = dest + GST_VIDEO_I420_U_OFFSET (out_width, out_height);
+ destV = dest + GST_VIDEO_I420_V_OFFSET (out_width, out_height);
- srcU = src + GST_VIDEO_I420_U_OFFSET(video_crop->width, video_crop->height);
- srcV = src + GST_VIDEO_I420_V_OFFSET(video_crop->width, video_crop->height);
+ srcU = src + GST_VIDEO_I420_U_OFFSET (video_crop->width, video_crop->height);
+ srcV = src + GST_VIDEO_I420_V_OFFSET (video_crop->width, video_crop->height);
- srcU += src_stride * (video_crop->crop_top/2) + (video_crop->crop_left/2);
- srcV += src_stride * (video_crop->crop_top/2) + (video_crop->crop_left/2);
+ srcU += src_stride * (video_crop->crop_top / 2) + (video_crop->crop_left / 2);
+ srcV += src_stride * (video_crop->crop_top / 2) + (video_crop->crop_left / 2);
- for (j = 0; j < out_height/2; j++) {
+ for (j = 0; j < out_height / 2; j++) {
/* copy U plane */
- memcpy (destU, srcU, out_width/2);
+ memcpy (destU, srcU, out_width / 2);
srcU += src_stride;
- destU += out_width/2;
+ destU += out_width / 2;
/* copy V plane */
- memcpy (destV, srcV, out_width/2);
+ memcpy (destV, srcV, out_width / 2);
srcV += src_stride;
- destV += out_width/2;
+ destV += out_width / 2;
}
}
static void
-gst_video_crop_chain (GstPad *pad, GstData *_data)
+gst_video_crop_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buffer = GST_BUFFER (_data);
GstVideoCrop *video_crop;
}
new_width = video_crop->width -
- (video_crop->crop_left + video_crop->crop_right);
+ (video_crop->crop_left + video_crop->crop_right);
new_height = video_crop->height -
- (video_crop->crop_top + video_crop->crop_bottom);
+ (video_crop->crop_top + video_crop->crop_bottom);
outbuf = gst_buffer_new_and_alloc ((new_width * new_height * 3) / 2);
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buffer);
}
static GstElementStateReturn
-gst_video_crop_change_state (GstElement *element)
+gst_video_crop_change_state (GstElement * element)
{
GstVideoCrop *video_crop;
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- return gst_element_register (plugin, "videocrop", GST_RANK_PRIMARY, GST_TYPE_VIDEO_CROP);
+ return gst_element_register (plugin, "videocrop", GST_RANK_PRIMARY,
+ GST_TYPE_VIDEO_CROP);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "videocrop",
- "Crops video into a user defined region",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "videocrop",
+ "Crops video into a user defined region",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
#include <gst/video/video.h>
/* elementfactory information */
-static GstElementDetails videodrop_details = GST_ELEMENT_DETAILS (
- "Video frame dropper",
- "Filter/Effect/Video",
- "Re-FPS'es video",
- "Ronald Bultje <rbultje@ronald.bitfreak.net>"
-);
+static GstElementDetails videodrop_details =
+GST_ELEMENT_DETAILS ("Video frame dropper",
+ "Filter/Effect/Video",
+ "Re-FPS'es video",
+ "Ronald Bultje <rbultje@ronald.bitfreak.net>");
/* GstVideodrop signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_SPEED
- /* FILL ME */
+ /* FILL ME */
};
static GstStaticPadTemplate gst_videodrop_src_template =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS(
- GST_VIDEO_CAPS_YUV("{ YUY2, I420, YV12, YUYV, UYVY }")
- )
-);
+GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("{ YUY2, I420, YV12, YUYV, UYVY }")
+ )
+ );
static GstStaticPadTemplate gst_videodrop_sink_template =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS(
- GST_VIDEO_CAPS_YUV("{ YUY2, I420, YV12, YUYV, UYVY }")
- )
-);
-
-static void gst_videodrop_base_init (gpointer g_class);
-static void gst_videodrop_class_init (GstVideodropClass *klass);
-static void gst_videodrop_init (GstVideodrop *videodrop);
-static void gst_videodrop_chain (GstPad *pad, GstData *_data);
-
-static void gst_videodrop_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gst_videodrop_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("{ YUY2, I420, YV12, YUYV, UYVY }")
+ )
+ );
-static GstElementStateReturn
- gst_videodrop_change_state (GstElement *element);
+static void gst_videodrop_base_init (gpointer g_class);
+static void gst_videodrop_class_init (GstVideodropClass * klass);
+static void gst_videodrop_init (GstVideodrop * videodrop);
+static void gst_videodrop_chain (GstPad * pad, GstData * _data);
+
+static void gst_videodrop_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+static void gst_videodrop_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
+
+static GstElementStateReturn gst_videodrop_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_videodrop_signals[LAST_SIGNAL] = { 0 }; */
GType
};
videodrop_type = g_type_register_static (GST_TYPE_ELEMENT,
- "GstVideodrop",
- &videodrop_info, 0);
+ "GstVideodrop", &videodrop_info, 0);
}
return videodrop_type;
gst_static_pad_template_get (&gst_videodrop_src_template));
}
static void
-gst_videodrop_class_init (GstVideodropClass *klass)
+gst_videodrop_class_init (GstVideodropClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
g_object_class_install_property (object_class, ARG_SPEED,
- g_param_spec_float ("speed", "Speed",
- "Output speed (relative to input)",
- 0.01, 100, 1, G_PARAM_READWRITE));
+ g_param_spec_float ("speed", "Speed",
+ "Output speed (relative to input)", 0.01, 100, 1, G_PARAM_READWRITE));
object_class->set_property = gst_videodrop_set_property;
object_class->get_property = gst_videodrop_get_property;
}
static GstCaps *
-gst_videodrop_getcaps (GstPad *pad)
+gst_videodrop_getcaps (GstPad * pad)
{
GstVideodrop *videodrop;
GstPad *otherpad;
videodrop = GST_VIDEODROP (gst_pad_get_parent (pad));
otherpad = (pad == videodrop->srcpad) ? videodrop->sinkpad :
- videodrop->srcpad;
+ videodrop->srcpad;
caps = gst_pad_get_allowed_caps (otherpad);
- for (i=0;i<gst_caps_get_size(caps);i++) {
+ for (i = 0; i < gst_caps_get_size (caps); i++) {
structure = gst_caps_get_structure (caps, i);
gst_structure_set (structure,
- "framerate", GST_TYPE_DOUBLE_RANGE, 0.0, G_MAXDOUBLE, NULL);
+ "framerate", GST_TYPE_DOUBLE_RANGE, 0.0, G_MAXDOUBLE, NULL);
}
-
+
return caps;
}
static GstPadLinkReturn
-gst_videodrop_link (GstPad *pad, const GstCaps *caps)
+gst_videodrop_link (GstPad * pad, const GstCaps * caps)
{
GstVideodrop *videodrop;
GstStructure *structure;
videodrop = GST_VIDEODROP (gst_pad_get_parent (pad));
otherpad = (pad == videodrop->srcpad) ? videodrop->sinkpad :
- videodrop->srcpad;
+ videodrop->srcpad;
structure = gst_caps_get_structure (caps, 0);
ret = gst_structure_get_double (structure, "framerate", &fps);
- if (!ret) return GST_PAD_LINK_REFUSED;
+ if (!ret)
+ return GST_PAD_LINK_REFUSED;
if (gst_pad_is_negotiated (otherpad)) {
othercaps = gst_caps_copy (caps);
} else {
otherfps = videodrop->to_fps;
}
- gst_caps_set_simple (othercaps,
- "framerate", G_TYPE_DOUBLE, otherfps, NULL);
+ gst_caps_set_simple (othercaps, "framerate", G_TYPE_DOUBLE, otherfps, NULL);
link_ret = gst_pad_try_set_caps (otherpad, othercaps);
if (GST_PAD_LINK_FAILED (link_ret)) {
return link_ret;
}
static void
-gst_videodrop_init (GstVideodrop *videodrop)
+gst_videodrop_init (GstVideodrop * videodrop)
{
GST_FLAG_SET (videodrop, GST_ELEMENT_EVENT_AWARE);
-
+
GST_DEBUG ("gst_videodrop_init");
- videodrop->sinkpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&gst_videodrop_sink_template), "sink");
+ videodrop->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_videodrop_sink_template), "sink");
gst_element_add_pad (GST_ELEMENT (videodrop), videodrop->sinkpad);
gst_pad_set_chain_function (videodrop->sinkpad, gst_videodrop_chain);
gst_pad_set_getcaps_function (videodrop->sinkpad, gst_videodrop_getcaps);
gst_pad_set_link_function (videodrop->sinkpad, gst_videodrop_link);
- videodrop->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&gst_videodrop_src_template), "src");
- gst_element_add_pad (GST_ELEMENT(videodrop), videodrop->srcpad);
+ videodrop->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_videodrop_src_template), "src");
+ gst_element_add_pad (GST_ELEMENT (videodrop), videodrop->srcpad);
gst_pad_set_getcaps_function (videodrop->srcpad, gst_videodrop_getcaps);
gst_pad_set_link_function (videodrop->srcpad, gst_videodrop_link);
}
static void
-gst_videodrop_chain (GstPad *pad, GstData *data)
+gst_videodrop_chain (GstPad * pad, GstData * data)
{
GstVideodrop *videodrop = GST_VIDEODROP (gst_pad_get_parent (pad));
GstBuffer *buf;
/* since we rely on timestamps of the source, we need to handle
* changes in time carefully. */
gint64 time;
+
if (gst_event_discont_get_value (event, GST_FORMAT_TIME, &time)) {
- videodrop->time_adjust = time;
+ videodrop->time_adjust = time;
videodrop->total = videodrop->pass = 0;
} else {
- GST_ELEMENT_ERROR (videodrop, STREAM, TOO_LAZY, (NULL),
- ("Received discont, but no time information"));
+ GST_ELEMENT_ERROR (videodrop, STREAM, TOO_LAZY, (NULL),
+ ("Received discont, but no time information"));
gst_event_unref (event);
return;
}
videodrop->total++;
while (((GST_BUFFER_TIMESTAMP (buf) - videodrop->time_adjust) *
- videodrop->to_fps * videodrop->speed / GST_SECOND) >= videodrop->pass) {
+ videodrop->to_fps * videodrop->speed / GST_SECOND) >=
+ videodrop->pass) {
/* since we write to the struct (time/duration), we need a new struct,
* but we don't want to copy around data - a subbuffer is the easiest
* way to accomplish that... */
/* adjust timestamp/duration and push forward */
GST_BUFFER_TIMESTAMP (copy) = videodrop->time_adjust / videodrop->speed +
- GST_SECOND * videodrop->pass / videodrop->to_fps;
+ GST_SECOND * videodrop->pass / videodrop->to_fps;
GST_BUFFER_DURATION (copy) = GST_SECOND / videodrop->to_fps;
gst_pad_push (videodrop->srcpad, GST_DATA (copy));
}
static void
-gst_videodrop_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+gst_videodrop_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec)
{
GstVideodrop *videodrop = GST_VIDEODROP (object);
}
static void
-gst_videodrop_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+gst_videodrop_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec)
{
GstVideodrop *videodrop = GST_VIDEODROP (object);
}
static GstElementStateReturn
-gst_videodrop_change_state (GstElement *element)
+gst_videodrop_change_state (GstElement * element)
{
GstVideodrop *videodrop = GST_VIDEODROP (element);
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- return gst_element_register (plugin, "videodrop", GST_RANK_NONE, GST_TYPE_VIDEODROP);
+ return gst_element_register (plugin, "videodrop", GST_RANK_NONE,
+ GST_TYPE_VIDEODROP);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "videodrop",
- "Re-FPS'es video",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "videodrop",
+ "Re-FPS'es video",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define GST_TYPE_VIDEODROP \
(gst_videodrop_get_type())
#define GST_VIDEODROP(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VIDEODROP))
#define GST_IS_VIDEODROP_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VIDEODROP))
-
typedef struct _GstVideodrop GstVideodrop;
typedef struct _GstVideodropClass GstVideodropClass;
-struct _GstVideodrop {
+struct _GstVideodrop
+{
GstElement element;
GstPad *sinkpad, *srcpad;
/* video state */
gboolean inited;
- gfloat from_fps,
- to_fps;
+ gfloat from_fps, to_fps;
gfloat speed;
guint64 pass, total, time_adjust;
};
-struct _GstVideodropClass {
+struct _GstVideodropClass
+{
GstElementClass parent_class;
};
-GType gst_videodrop_get_type(void);
+GType gst_videodrop_get_type (void);
G_END_DECLS
-
#endif /* __GST_VIDEODROP_H__ */
#include "gstvirtualdub.h"
-struct _elements_entry {
+struct _elements_entry
+{
gchar *name;
- GType (*type) (void);
+ GType (*type) (void);
GstElementDetails *details;
- gboolean (*factoryinit) (GstElementFactory *factory);
+ gboolean (*factoryinit) (GstElementFactory * factory);
};
static struct _elements_entry _elements[] = {
- { "xsharpen", gst_xsharpen_get_type, &gst_xsharpen_details, NULL },
- { NULL, 0 },
+ {"xsharpen", gst_xsharpen_get_type, &gst_xsharpen_details, NULL},
+ {NULL, 0},
};
-GstPadTemplate*
+GstPadTemplate *
gst_virtualdub_src_factory (void)
{
static GstPadTemplate *templ = NULL;
+
if (!templ) {
- templ = GST_PAD_TEMPLATE_NEW (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_CAPS_NEW (
- "virtualdub_src",
- "video/x-raw-rgb",
- "bpp", GST_PROPS_INT (32),
- "depth", GST_PROPS_INT (32),
- "endianness", GST_PROPS_INT (G_BYTE_ORDER),
- "red_mask", GST_PROPS_INT (0xff0000),
- "green_mask", GST_PROPS_INT (0xff00),
- "blue_mask", GST_PROPS_INT (0xff),
- "width", GST_PROPS_INT_RANGE (16, 4096),
- "height", GST_PROPS_INT_RANGE (16, 4096),
- "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT)
- )
- );
+ templ = GST_PAD_TEMPLATE_NEW ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_CAPS_NEW ("virtualdub_src",
+ "video/x-raw-rgb",
+ "bpp", GST_PROPS_INT (32),
+ "depth", GST_PROPS_INT (32),
+ "endianness", GST_PROPS_INT (G_BYTE_ORDER),
+ "red_mask", GST_PROPS_INT (0xff0000),
+ "green_mask", GST_PROPS_INT (0xff00),
+ "blue_mask", GST_PROPS_INT (0xff),
+ "width", GST_PROPS_INT_RANGE (16, 4096),
+ "height", GST_PROPS_INT_RANGE (16, 4096),
+ "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT)
+ )
+ );
}
return templ;
}
-GstPadTemplate*
+GstPadTemplate *
gst_virtualdub_sink_factory (void)
{
static GstPadTemplate *templ = NULL;
+
if (!templ) {
- templ = GST_PAD_TEMPLATE_NEW (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_CAPS_NEW (
- "virtualdub_sink",
- "video/x-raw-rgb",
- "bpp", GST_PROPS_INT (32),
- "depth", GST_PROPS_INT (32),
- "endianness", GST_PROPS_INT (G_BYTE_ORDER),
- "red_mask", GST_PROPS_INT (0xff0000),
- "green_mask", GST_PROPS_INT (0xff00),
- "blue_mask", GST_PROPS_INT (0xff),
- "width", GST_PROPS_INT_RANGE (16, 4096),
- "height", GST_PROPS_INT_RANGE (16, 4096),
- "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT)
- )
- );
+ templ = GST_PAD_TEMPLATE_NEW ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_CAPS_NEW ("virtualdub_sink",
+ "video/x-raw-rgb",
+ "bpp", GST_PROPS_INT (32),
+ "depth", GST_PROPS_INT (32),
+ "endianness", GST_PROPS_INT (G_BYTE_ORDER),
+ "red_mask", GST_PROPS_INT (0xff0000),
+ "green_mask", GST_PROPS_INT (0xff00),
+ "blue_mask", GST_PROPS_INT (0xff),
+ "width", GST_PROPS_INT_RANGE (16, 4096),
+ "height", GST_PROPS_INT_RANGE (16, 4096),
+ "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT)
+ )
+ );
}
return templ;
}
while (_elements[i].name) {
factory = gst_element_factory_new (_elements[i].name,
- (_elements[i].type) (),
- _elements[i].details);
+ (_elements[i].type) (), _elements[i].details);
if (!factory) {
- g_warning ("gst_virtualdub_new failed for `%s'",
- _elements[i].name);
+ g_warning ("gst_virtualdub_new failed for `%s'", _elements[i].name);
continue;
}
- gst_element_factory_add_pad_template (factory, gst_virtualdub_src_factory ());
- gst_element_factory_add_pad_template (factory, gst_virtualdub_sink_factory ());
+ gst_element_factory_add_pad_template (factory,
+ gst_virtualdub_src_factory ());
+ gst_element_factory_add_pad_template (factory,
+ gst_virtualdub_sink_factory ());
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
if (_elements[i].factoryinit) {
#include <gst/gst.h>
-typedef unsigned int Pixel;
-typedef unsigned int Pixel32;
-typedef unsigned char Pixel8;
-typedef int PixCoord;
-typedef int PixDim;
-typedef int PixOffset;
+typedef unsigned int Pixel;
+typedef unsigned int Pixel32;
+typedef unsigned char Pixel8;
+typedef int PixCoord;
+typedef int PixDim;
+typedef int PixOffset;
#define R_MASK (0x00ff0000)
"",
"Filter/Video/Effect",
"LGPL",
- "Apply a sharpen effect on video"
- VERSION,
+ "Apply a sharpen effect on video" VERSION,
"Jeremy SIMON <jsimon13@yahoo.fr>",
"(C) 2000 Donald Graft",
};
ARG_0,
};
-static void gst_xsharpen_class_init (GstXsharpenClass * klass);
-static void gst_xsharpen_init (GstXsharpen * sharpen);
+static void gst_xsharpen_class_init (GstXsharpenClass * klass);
+static void gst_xsharpen_init (GstXsharpen * sharpen);
-static void gst_xsharpen_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec);
-static void gst_xsharpen_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec);
+static void gst_xsharpen_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_xsharpen_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static void gst_xsharpen_chain (GstPad * pad, GstData *_data);
+static void gst_xsharpen_chain (GstPad * pad, GstData * _data);
static GstElementClass *parent_class = NULL;
-GType gst_xsharpen_get_type (void)
+GType
+gst_xsharpen_get_type (void)
{
static GType xsharpen_type = 0;
(GInstanceInitFunc) gst_xsharpen_init,
};
- xsharpen_type = g_type_register_static (GST_TYPE_ELEMENT, "GstXsharpen", &xsharpen_info, 0);
+ xsharpen_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstXsharpen", &xsharpen_info,
+ 0);
}
return xsharpen_type;
}
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_STRENGTH,
- g_param_spec_int("strength", "strength", "strength",
- 0, 255, 255, (GParamFlags)G_PARAM_READWRITE ));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_STRENGTH,
+ g_param_spec_int ("strength", "strength", "strength",
+ 0, 255, 255, (GParamFlags) G_PARAM_READWRITE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_THRESHOLD,
- g_param_spec_int("threshold", "threshold", "threshold",
- 0, 255, 255, (GParamFlags)G_PARAM_READWRITE ));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_THRESHOLD,
+ g_param_spec_int ("threshold", "threshold", "threshold",
+ 0, 255, 255, (GParamFlags) G_PARAM_READWRITE));
gobject_class->set_property = gst_xsharpen_set_property;
gobject_class->get_property = gst_xsharpen_get_property;
gst_caps_get_int (caps, "width", &sharpen->width);
gst_caps_get_int (caps, "height", &sharpen->height);
- sharpen->strengthinv = 255 - sharpen->strength;
+ sharpen->strengthinv = 255 - sharpen->strength;
sharpen->dstpitch = sharpen->srcpitch = sharpen->width * sizeof (Pixel32);
static void
gst_xsharpen_init (GstXsharpen * sharpen)
{
- sharpen->sinkpad = gst_pad_new_from_template (gst_virtualdub_sink_factory (), "sink");
+ sharpen->sinkpad =
+ gst_pad_new_from_template (gst_virtualdub_sink_factory (), "sink");
gst_pad_set_chain_function (sharpen->sinkpad, gst_xsharpen_chain);
gst_pad_set_link_function (sharpen->sinkpad, gst_xsharpen_sinkconnect);
gst_element_add_pad (GST_ELEMENT (sharpen), sharpen->sinkpad);
- sharpen->srcpad = gst_pad_new_from_template (gst_virtualdub_src_factory (), "src");
+ sharpen->srcpad =
+ gst_pad_new_from_template (gst_virtualdub_src_factory (), "src");
gst_element_add_pad (GST_ELEMENT (sharpen), sharpen->srcpad);
}
static void
-gst_xsharpen_chain (GstPad * pad, GstData *_data)
+gst_xsharpen_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstXsharpen *xsharpen;
- GstBuffer *outbuf;
- gint x, y;
- gint r, g, b, R, G, B;
- Pixel32 p, min, max;
- gint luma, lumac, lumamax, lumamin, mindiff, maxdiff;
- Pixel32 *src_buf, *dst_buf, *src, *dst;
+ GstBuffer *outbuf;
+ gint x, y;
+ gint r, g, b, R, G, B;
+ Pixel32 p, min, max;
+ gint luma, lumac, lumamax, lumamin, mindiff, maxdiff;
+ Pixel32 *src_buf, *dst_buf, *src, *dst;
xsharpen = GST_XSHARPEN (gst_pad_get_parent (pad));
- outbuf = gst_buffer_new ();
- GST_BUFFER_SIZE (outbuf) = ( xsharpen->width * xsharpen->height * sizeof (Pixel32));
+ outbuf = gst_buffer_new ();
+ GST_BUFFER_SIZE (outbuf) =
+ (xsharpen->width * xsharpen->height * sizeof (Pixel32));
GST_BUFFER_DATA (outbuf) = g_malloc (GST_BUFFER_SIZE (outbuf));
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
-
- src_buf = (Pixel32 *)GST_BUFFER_DATA (buf);
- dst_buf = (Pixel32 *)GST_BUFFER_DATA (outbuf);
+
+ src_buf = (Pixel32 *) GST_BUFFER_DATA (buf);
+ dst_buf = (Pixel32 *) GST_BUFFER_DATA (outbuf);
min = max = 0;
/* First copy through the four border lines. */
src = src_buf;
dst = dst_buf;
- for (x = 0; x < xsharpen->width; x++)
- {
+ for (x = 0; x < xsharpen->width; x++) {
dst[x] = src[x];
}
-
- src = (Pixel *)((char *)src_buf + (xsharpen->height - 1) * xsharpen->srcpitch);
- dst = (Pixel *)((char *)dst_buf + (xsharpen->height - 1) * xsharpen->dstpitch);
-
- for (x = 0; x < xsharpen->width; x++)
- {
+
+ src =
+ (Pixel *) ((char *) src_buf + (xsharpen->height -
+ 1) * xsharpen->srcpitch);
+ dst =
+ (Pixel *) ((char *) dst_buf + (xsharpen->height -
+ 1) * xsharpen->dstpitch);
+
+ for (x = 0; x < xsharpen->width; x++) {
dst[x] = src[x];
}
-
+
src = src_buf;
dst = dst_buf;
-
- for (y = 0; y < xsharpen->height; y++)
- {
+
+ for (y = 0; y < xsharpen->height; y++) {
dst[0] = src[0];
- dst[xsharpen->width-1] = src[xsharpen->width-1];
- src = (Pixel *)((char *)src + xsharpen->srcpitch);
- dst = (Pixel *)((char *)dst + xsharpen->dstpitch);
+ dst[xsharpen->width - 1] = src[xsharpen->width - 1];
+ src = (Pixel *) ((char *) src + xsharpen->srcpitch);
+ dst = (Pixel *) ((char *) dst + xsharpen->dstpitch);
}
/* Now calculate and store the pixel luminances for the remaining pixels. */
src = src_buf;
- for (y = 0; y < xsharpen->height; y++)
- {
- for (x = 0; x < xsharpen->width; x++)
- {
+ for (y = 0; y < xsharpen->height; y++) {
+ for (x = 0; x < xsharpen->width; x++) {
r = (src[x] >> 16) & 0xff;
g = (src[x] >> 8) & 0xff;
b = src[x] & 0xff;
src[x] &= 0x00ffffff;
src[x] |= (luma << 24);
}
- src = (Pixel *)((char *)src + xsharpen->srcpitch);
+ src = (Pixel *) ((char *) src + xsharpen->srcpitch);
}
/* Finally run the 3x3 rank-order sharpening kernel over the pixels. */
- src = (Pixel *)((char *)src_buf + xsharpen->srcpitch);
- dst = (Pixel *)((char *)dst_buf + xsharpen->dstpitch);
-
- for (y = 1; y < xsharpen->height - 1; y++)
- {
- for (x = 1; x < xsharpen->width - 1; x++)
- {
+ src = (Pixel *) ((char *) src_buf + xsharpen->srcpitch);
+ dst = (Pixel *) ((char *) dst_buf + xsharpen->dstpitch);
+
+ for (y = 1; y < xsharpen->height - 1; y++) {
+ for (x = 1; x < xsharpen->width - 1; x++) {
/* Find the brightest and dimmest pixels in the 3x3 window
surrounding the current pixel. */
-
+
lumamax = -1;
lumamin = 1000;
-
- p = ((Pixel32 *)((char *)src - xsharpen->srcpitch))[x-1];
+
+ p = ((Pixel32 *) ((char *) src - xsharpen->srcpitch))[x - 1];
luma = p >> 24;
- if (luma > lumamax)
- {
- lumamax = luma;
- max = p;
+ if (luma > lumamax) {
+ lumamax = luma;
+ max = p;
}
- if (luma < lumamin)
- {
- lumamin = luma;
- min = p;
+ if (luma < lumamin) {
+ lumamin = luma;
+ min = p;
}
- p = ((Pixel32 *)((char *)src - xsharpen->srcpitch))[x];
+ p = ((Pixel32 *) ((char *) src - xsharpen->srcpitch))[x];
luma = p >> 24;
- if (luma > lumamax)
- {
- lumamax = luma;
- max = p;
+ if (luma > lumamax) {
+ lumamax = luma;
+ max = p;
}
- if (luma < lumamin)
- {
- lumamin = luma;
- min = p;
+ if (luma < lumamin) {
+ lumamin = luma;
+ min = p;
}
-
- p = ((Pixel32 *)((char *)src - xsharpen->srcpitch))[x+1];
+
+ p = ((Pixel32 *) ((char *) src - xsharpen->srcpitch))[x + 1];
luma = p >> 24;
- if (luma > lumamax)
- {
- lumamax = luma;
- max = p;
+ if (luma > lumamax) {
+ lumamax = luma;
+ max = p;
}
- if (luma < lumamin)
- {
- lumamin = luma;
- min = p;
+ if (luma < lumamin) {
+ lumamin = luma;
+ min = p;
}
-
- p = src[x-1];
+
+ p = src[x - 1];
luma = p >> 24;
- if (luma > lumamax)
- {
- lumamax = luma;
- max = p;
+ if (luma > lumamax) {
+ lumamax = luma;
+ max = p;
}
- if (luma < lumamin)
- {
- lumamin = luma;
- min = p;
+ if (luma < lumamin) {
+ lumamin = luma;
+ min = p;
}
p = src[x];
lumac = luma = p >> 24;
- if (luma > lumamax)
- {
- lumamax = luma;
- max = p;
+ if (luma > lumamax) {
+ lumamax = luma;
+ max = p;
}
- if (luma < lumamin)
- {
- lumamin = luma;
- min = p;
+ if (luma < lumamin) {
+ lumamin = luma;
+ min = p;
}
- p = src[x+1];
+ p = src[x + 1];
luma = p >> 24;
- if (luma > lumamax)
- {
- lumamax = luma;
- max = p;
+ if (luma > lumamax) {
+ lumamax = luma;
+ max = p;
}
- if (luma < lumamin)
- {
- lumamin = luma;
- min = p;
+ if (luma < lumamin) {
+ lumamin = luma;
+ min = p;
}
-
- p = ((Pixel32 *)((char *)src + xsharpen->srcpitch))[x-1];
+
+ p = ((Pixel32 *) ((char *) src + xsharpen->srcpitch))[x - 1];
luma = p >> 24;
- if (luma > lumamax)
- {
- lumamax = luma;
- max = p;
+ if (luma > lumamax) {
+ lumamax = luma;
+ max = p;
}
- if (luma < lumamin)
- {
- lumamin = luma;
- min = p;
+ if (luma < lumamin) {
+ lumamin = luma;
+ min = p;
}
- p = ((Pixel32 *)((char *)src + xsharpen->srcpitch))[x];
+ p = ((Pixel32 *) ((char *) src + xsharpen->srcpitch))[x];
luma = p >> 24;
- if (luma > lumamax)
- {
- lumamax = luma;
- max = p;
+ if (luma > lumamax) {
+ lumamax = luma;
+ max = p;
}
- if (luma < lumamin)
- {
- lumamin = luma;
- min = p;
+ if (luma < lumamin) {
+ lumamin = luma;
+ min = p;
}
- p = ((Pixel32 *)((char *)src + xsharpen->srcpitch))[x+1];
+ p = ((Pixel32 *) ((char *) src + xsharpen->srcpitch))[x + 1];
luma = p >> 24;
- if (luma > lumamax)
- {
- lumamax = luma;
- max = p;
+ if (luma > lumamax) {
+ lumamax = luma;
+ max = p;
}
- if (luma < lumamin)
- {
- lumamin = luma;
- min = p;
+ if (luma < lumamin) {
+ lumamin = luma;
+ min = p;
}
/* Determine whether the current pixel is closer to the
pixel to that closest pixel. If the difference is within
threshold, map the current pixel to the closest pixel;
otherwise pass it through. */
-
+
p = -1;
- if (xsharpen->strength != 0)
- {
- mindiff = lumac - lumamin;
- maxdiff = lumamax - lumac;
- if (mindiff > maxdiff)
- {
- if (maxdiff < xsharpen->threshold)
- {
- p = max;
- }
- }
- else
- {
- if (mindiff < xsharpen->threshold)
- {
- p = min;
- }
- }
+ if (xsharpen->strength != 0) {
+ mindiff = lumac - lumamin;
+ maxdiff = lumamax - lumac;
+ if (mindiff > maxdiff) {
+ if (maxdiff < xsharpen->threshold) {
+ p = max;
+ }
+ } else {
+ if (mindiff < xsharpen->threshold) {
+ p = min;
+ }
+ }
}
- if (p == -1)
- {
- dst[x] = src[x];
- }
- else
- {
- R = (src[x] >> 16) & 0xff;
- G = (src[x] >> 8) & 0xff;
- B = src[x] & 0xff;
- r = (p >> 16) & 0xff;
- g = (p >> 8) & 0xff;
- b = p & 0xff;
- r = (xsharpen->strength * r + xsharpen->strengthinv * R) / 255;
- g = (xsharpen->strength * g + xsharpen->strengthinv * G) / 255;
- b = (xsharpen->strength * b + xsharpen->strengthinv * B) / 255;
- dst[x] = (r << 16) | (g << 8) | b;
+ if (p == -1) {
+ dst[x] = src[x];
+ } else {
+ R = (src[x] >> 16) & 0xff;
+ G = (src[x] >> 8) & 0xff;
+ B = src[x] & 0xff;
+ r = (p >> 16) & 0xff;
+ g = (p >> 8) & 0xff;
+ b = p & 0xff;
+ r = (xsharpen->strength * r + xsharpen->strengthinv * R) / 255;
+ g = (xsharpen->strength * g + xsharpen->strengthinv * G) / 255;
+ b = (xsharpen->strength * b + xsharpen->strengthinv * B) / 255;
+ dst[x] = (r << 16) | (g << 8) | b;
}
}
- src = (Pixel *)((char *)src + xsharpen->srcpitch);
- dst = (Pixel *)((char *)dst + xsharpen->dstpitch);
+ src = (Pixel *) ((char *) src + xsharpen->srcpitch);
+ dst = (Pixel *) ((char *) dst + xsharpen->dstpitch);
}
gst_buffer_unref (buf);
}
static void
-gst_xsharpen_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec)
+gst_xsharpen_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstXsharpen *xsharpen;
case ARG_STRENGTH:
xsharpen->strength = g_value_get_int (value);
xsharpen->strengthinv = 255 - xsharpen->strength;
- case ARG_THRESHOLD:
+ case ARG_THRESHOLD:
xsharpen->threshold = g_value_get_int (value);
default:
break;
}
static void
-gst_xsharpen_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec)
+gst_xsharpen_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstXsharpen *xsharpen;
switch (prop_id) {
case ARG_STRENGTH:
- g_value_set_int (value, xsharpen->strength );
+ g_value_set_int (value, xsharpen->strength);
break;
case ARG_THRESHOLD:
- g_value_set_int (value, xsharpen->threshold );
+ g_value_set_int (value, xsharpen->threshold);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
#include <gst/video/video.h>
#include "gsty4mencode.h"
-static GstElementDetails y4mencode_details = GST_ELEMENT_DETAILS (
- "Y4mEncode",
- "Codec/Encoder/Video",
- "Encodes a YUV frame into the yuv4mpeg format (mjpegtools)",
- "Wim Taymans <wim.taymans@chello.be>"
-);
+static GstElementDetails y4mencode_details = GST_ELEMENT_DETAILS ("Y4mEncode",
+ "Codec/Encoder/Video",
+ "Encodes a YUV frame into the yuv4mpeg format (mjpegtools)",
+ "Wim Taymans <wim.taymans@chello.be>");
/* Filter signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0
};
static GstStaticPadTemplate y4mencode_src_factory =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("application/x-yuv4mpeg, "
- "y4mversion = (int) 1"
- )
-);
+GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("application/x-yuv4mpeg, " "y4mversion = (int) 1")
+ );
static GstStaticPadTemplate y4mencode_sink_factory =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420"))
-);
-
-static void gst_y4mencode_base_init (gpointer g_class);
-static void gst_y4mencode_class_init (GstY4mEncodeClass *klass);
-static void gst_y4mencode_init (GstY4mEncode *filter);
-
-static void gst_y4mencode_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gst_y4mencode_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-
-static void gst_y4mencode_chain (GstPad *pad,
- GstData *_data);
-static GstElementStateReturn
- gst_y4mencode_change_state (GstElement *element);
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420"))
+ );
+
+static void gst_y4mencode_base_init (gpointer g_class);
+static void gst_y4mencode_class_init (GstY4mEncodeClass * klass);
+static void gst_y4mencode_init (GstY4mEncode * filter);
+
+static void gst_y4mencode_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+static void gst_y4mencode_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
+
+static void gst_y4mencode_chain (GstPad * pad, GstData * _data);
+static GstElementStateReturn gst_y4mencode_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
+
/*static guint gst_filter_signals[LAST_SIGNAL] = { 0 }; */
GType
-gst_y4mencode_get_type(void) {
+gst_y4mencode_get_type (void)
+{
static GType y4mencode_type = 0;
if (!y4mencode_type) {
static const GTypeInfo y4mencode_info = {
- sizeof(GstY4mEncodeClass),
+ sizeof (GstY4mEncodeClass),
gst_y4mencode_base_init,
NULL,
- (GClassInitFunc)gst_y4mencode_class_init,
+ (GClassInitFunc) gst_y4mencode_class_init,
NULL,
NULL,
- sizeof(GstY4mEncode),
+ sizeof (GstY4mEncode),
0,
- (GInstanceInitFunc)gst_y4mencode_init,
+ (GInstanceInitFunc) gst_y4mencode_init,
};
- y4mencode_type = g_type_register_static(GST_TYPE_ELEMENT,
- "GstY4mEncode",
- &y4mencode_info, 0);
+ y4mencode_type = g_type_register_static (GST_TYPE_ELEMENT,
+ "GstY4mEncode", &y4mencode_info, 0);
}
return y4mencode_type;
}
gst_y4mencode_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&y4mencode_src_factory));
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&y4mencode_sink_factory));
+
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&y4mencode_src_factory));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&y4mencode_sink_factory));
gst_element_class_set_details (element_class, &y4mencode_details);
}
static void
-gst_y4mencode_class_init (GstY4mEncodeClass *klass)
+gst_y4mencode_class_init (GstY4mEncodeClass * 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);
gstelement_class->change_state = gst_y4mencode_change_state;
}
static GstPadLinkReturn
-gst_y4mencode_sinkconnect (GstPad *pad, const GstCaps *caps)
+gst_y4mencode_sinkconnect (GstPad * pad, const GstCaps * caps)
{
GstY4mEncode *filter;
gint idx = -1, i;
gdouble fps;
gdouble framerates[] = {
00.000,
- 23.976, 24.000, /* 24fps movie */
- 25.000, /* PAL */
- 29.970, 30.000, /* NTSC */
+ 23.976, 24.000, /* 24fps movie */
+ 25.000, /* PAL */
+ 29.970, 30.000, /* NTSC */
50.000,
59.940, 60.000
};
structure = gst_caps_get_structure (caps, 0);
- gst_structure_get_int (structure, "width", &filter->width);
- gst_structure_get_int (structure, "height", &filter->height);
- gst_structure_get_double (structure, "framerate", &fps);
+ gst_structure_get_int (structure, "width", &filter->width);
+ gst_structure_get_int (structure, "height", &filter->height);
+ gst_structure_get_double (structure, "framerate", &fps);
/* find fps idx */
for (i = 1; i < 9; i++) {
if (idx == -1) {
- idx = i;
+ idx = i;
} else {
- gdouble old_diff = fabs(framerates[idx] - fps),
- new_diff = fabs(framerates[i] - fps);
+ gdouble old_diff = fabs (framerates[idx] - fps),
+ new_diff = fabs (framerates[i] - fps);
if (new_diff < old_diff) {
- idx = i;
+ idx = i;
}
}
}
}
static void
-gst_y4mencode_init (GstY4mEncode *filter)
+gst_y4mencode_init (GstY4mEncode * filter)
{
- filter->sinkpad = gst_pad_new_from_template(
- gst_static_pad_template_get (&y4mencode_sink_factory), "sink");
+ filter->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&y4mencode_sink_factory), "sink");
gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
gst_pad_set_chain_function (filter->sinkpad, gst_y4mencode_chain);
gst_pad_set_link_function (filter->sinkpad, gst_y4mencode_sinkconnect);
- filter->srcpad = gst_pad_new_from_template(
- gst_static_pad_template_get (&y4mencode_src_factory), "src");
+ filter->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&y4mencode_src_factory), "src");
gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
filter->init = TRUE;
}
static void
-gst_y4mencode_chain (GstPad *pad,GstData *_data)
+gst_y4mencode_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
GstY4mEncode *filter;
- GstBuffer* outbuf;
+ GstBuffer *outbuf;
gchar *header;
gint len;
- g_return_if_fail(pad != NULL);
- g_return_if_fail(GST_IS_PAD(pad));
- g_return_if_fail(buf != NULL);
+ g_return_if_fail (pad != NULL);
+ g_return_if_fail (GST_IS_PAD (pad));
+ g_return_if_fail (buf != NULL);
filter = GST_Y4MENCODE (gst_pad_get_parent (pad));
- g_return_if_fail(filter != NULL);
- g_return_if_fail(GST_IS_Y4MENCODE(filter));
+ g_return_if_fail (filter != NULL);
+ g_return_if_fail (GST_IS_Y4MENCODE (filter));
outbuf = gst_buffer_new ();
GST_BUFFER_DATA (outbuf) = g_malloc (GST_BUFFER_SIZE (buf) + 256);
if (filter->init) {
header = "YUV4MPEG %d %d %d\nFRAME\n";
filter->init = FALSE;
- }
- else {
+ } else {
header = "FRAME\n";
}
snprintf (GST_BUFFER_DATA (outbuf), 255, header,
- filter->width, filter->height, filter->fps_idx);
+ filter->width, filter->height, filter->fps_idx);
len = strlen (GST_BUFFER_DATA (outbuf));
- memcpy (GST_BUFFER_DATA (outbuf) + len, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
+ memcpy (GST_BUFFER_DATA (outbuf) + len, GST_BUFFER_DATA (buf),
+ GST_BUFFER_SIZE (buf));
GST_BUFFER_SIZE (outbuf) = GST_BUFFER_SIZE (buf) + len;
- gst_buffer_unref(buf);
+ gst_buffer_unref (buf);
- gst_pad_push(filter->srcpad,GST_DATA (outbuf));
+ gst_pad_push (filter->srcpad, GST_DATA (outbuf));
}
static void
-gst_y4mencode_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_y4mencode_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
GstY4mEncode *filter;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_Y4MENCODE(object));
- filter = GST_Y4MENCODE(object);
+ g_return_if_fail (GST_IS_Y4MENCODE (object));
+ filter = GST_Y4MENCODE (object);
switch (prop_id) {
default:
}
static void
-gst_y4mencode_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_y4mencode_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstY4mEncode *filter;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_Y4MENCODE(object));
- filter = GST_Y4MENCODE(object);
+ g_return_if_fail (GST_IS_Y4MENCODE (object));
+ filter = GST_Y4MENCODE (object);
switch (prop_id) {
default:
}
static GstElementStateReturn
-gst_y4mencode_change_state (GstElement *element)
+gst_y4mencode_change_state (GstElement * element)
{
GstY4mEncode *filter;
g_return_val_if_fail (GST_IS_Y4MENCODE (element), GST_STATE_FAILURE);
- filter = GST_Y4MENCODE(element);
+ filter = GST_Y4MENCODE (element);
if (GST_STATE_TRANSITION (element) == GST_STATE_NULL_TO_READY) {
filter->init = TRUE;
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- return gst_element_register (plugin, "y4menc", GST_RANK_NONE, GST_TYPE_Y4MENCODE);
+ return gst_element_register (plugin, "y4menc", GST_RANK_NONE,
+ GST_TYPE_Y4MENCODE);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "y4menc",
- "Encodes a YUV frame into the yuv4mpeg format (mjpegtools)",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "y4menc",
+ "Encodes a YUV frame into the yuv4mpeg format (mjpegtools)",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_Y4MENCODE \
#define GST_IS_Y4MENCODE_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_Y4MENCODE))
-typedef struct _GstY4mEncode GstY4mEncode;
-typedef struct _GstY4mEncodeClass GstY4mEncodeClass;
+ typedef struct _GstY4mEncode GstY4mEncode;
+ typedef struct _GstY4mEncodeClass GstY4mEncodeClass;
-struct _GstY4mEncode {
- GstElement element;
+ struct _GstY4mEncode
+ {
+ GstElement element;
- GstPad *sinkpad,*srcpad;
+ GstPad *sinkpad, *srcpad;
- gint width, height;
- gfloat fps_idx;
+ gint width, height;
+ gfloat fps_idx;
- gboolean init;
+ gboolean init;
-};
+ };
-struct _GstY4mEncodeClass {
- GstElementClass parent_class;
-};
+ struct _GstY4mEncodeClass
+ {
+ GstElementClass parent_class;
+ };
-GType gst_y4mencode_get_type(void);
+ GType gst_y4mencode_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_Y4MENCODE_H__ */
+#endif /* __GST_Y4MENCODE_H__ */
LAST_SIGNAL,
};
-static void cdplayer_base_init (gpointer g_class);
-static void cdplayer_class_init (CDPlayerClass *klass);
-static void cdplayer_init (CDPlayer *cdp);
-static void cdplayer_dispose (GObject *object);
+static void cdplayer_base_init (gpointer g_class);
+static void cdplayer_class_init (CDPlayerClass * klass);
+static void cdplayer_init (CDPlayer * cdp);
+static void cdplayer_dispose (GObject * object);
-static void cdplayer_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *spec);
-static void cdplayer_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *spec);
-static gboolean cdplayer_iterate (GstBin *bin);
+static void cdplayer_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * spec);
+static void cdplayer_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * spec);
+static gboolean cdplayer_iterate (GstBin * bin);
-static GstElementStateReturn
- cdplayer_change_state (GstElement * element);
+static GstElementStateReturn cdplayer_change_state (GstElement * element);
static GstElementClass *parent_class;
static guint cdplayer_signals[LAST_SIGNAL] = { 0 };
-static GstElementDetails cdplayer_details = GST_ELEMENT_DETAILS (
- "CD Player",
- "Generic/Bin",
- "Play CD audio through the CD Drive",
- "Charles Schmidt <cbschmid@uiuc.edu>, "
- "Wim Taymans <wim.taymans@chello.be>"
-);
+static GstElementDetails cdplayer_details = GST_ELEMENT_DETAILS ("CD Player",
+ "Generic/Bin",
+ "Play CD audio through the CD Drive",
+ "Charles Schmidt <cbschmid@uiuc.edu>, "
+ "Wim Taymans <wim.taymans@chello.be>");
GType
NULL
};
- cdplayer_type = g_type_register_static (GST_TYPE_BIN, "CDPlayer", &cdplayer_info, 0);
+ cdplayer_type =
+ g_type_register_static (GST_TYPE_BIN, "CDPlayer", &cdplayer_info, 0);
}
return cdplayer_type;
gobject_klass->get_property = cdplayer_get_property;
g_object_class_install_property (gobject_klass, ARG_DEVICE,
- g_param_spec_string ("device", "device", "CDROM device", NULL,
- G_PARAM_READWRITE));
+ g_param_spec_string ("device", "device", "CDROM device", NULL,
+ G_PARAM_READWRITE));
g_object_class_install_property (gobject_klass, ARG_NUM_TRACKS,
- g_param_spec_int ("num_tracks", "num_tracks", "Number of Tracks",
- G_MININT, G_MAXINT, 0, G_PARAM_READABLE));
+ g_param_spec_int ("num_tracks", "num_tracks", "Number of Tracks",
+ G_MININT, G_MAXINT, 0, G_PARAM_READABLE));
g_object_class_install_property (gobject_klass, ARG_START_TRACK,
- g_param_spec_int ("start_track", "start_track",
- "Track to start playback on", 1,
- CDPLAYER_MAX_TRACKS - 1, 1,
- G_PARAM_READWRITE));
+ g_param_spec_int ("start_track", "start_track",
+ "Track to start playback on", 1,
+ CDPLAYER_MAX_TRACKS - 1, 1, G_PARAM_READWRITE));
g_object_class_install_property (gobject_klass, ARG_END_TRACK,
- g_param_spec_int ("end_track", "end_track",
- "Track to end playback on", 0,
- CDPLAYER_MAX_TRACKS - 1, 0,
- G_PARAM_READWRITE));
+ g_param_spec_int ("end_track", "end_track",
+ "Track to end playback on", 0,
+ CDPLAYER_MAX_TRACKS - 1, 0, G_PARAM_READWRITE));
g_object_class_install_property (gobject_klass, ARG_CURRENT_TRACK,
- g_param_spec_int ("current_track", "current_track",
- "Current track playing", 1,
- CDPLAYER_MAX_TRACKS - 1, 1, G_PARAM_READABLE));
+ g_param_spec_int ("current_track", "current_track",
+ "Current track playing", 1,
+ CDPLAYER_MAX_TRACKS - 1, 1, G_PARAM_READABLE));
g_object_class_install_property (gobject_klass, ARG_CDDB_DISCID,
- g_param_spec_uint ("cddb_discid", "cddb_discid", "CDDB Disc ID",
- 0, G_MAXUINT, 1, G_PARAM_READABLE));
+ g_param_spec_uint ("cddb_discid", "cddb_discid", "CDDB Disc ID",
+ 0, G_MAXUINT, 1, G_PARAM_READABLE));
cdplayer_signals[TRACK_CHANGE] =
- g_signal_new ("track-change", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (CDPlayerClass, track_change), NULL, NULL,
- gst_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
+ g_signal_new ("track-change", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (CDPlayerClass, track_change), NULL,
+ NULL, gst_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
return;
}
}
static void
-cdplayer_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * spec)
+cdplayer_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * spec)
{
CDPlayer *cdp;
static void
-cdplayer_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * spec)
+cdplayer_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * spec)
{
CDPlayer *cdp;
if (current_track != -1 && current_track != cdp->current_track) {
cdp->current_track = current_track;
- g_signal_emit (G_OBJECT (cdp), cdplayer_signals[TRACK_CHANGE], 0, cdp->current_track);
+ g_signal_emit (G_OBJECT (cdp), cdplayer_signals[TRACK_CHANGE], 0,
+ cdp->current_track);
}
return TRUE;
cdp->paused = FALSE;
} else {
- if (cd_start (CDPLAYER_CD (cdp), cdp->start_track, cdp->end_track) == FALSE) {
+ if (cd_start (CDPLAYER_CD (cdp), cdp->start_track,
+ cdp->end_track) == FALSE) {
return GST_STATE_FAILURE;
}
}
break;
case GST_STATE_NULL:
/* stop & close fd */
- if (cd_stop (CDPLAYER_CD (cdp)) == FALSE || cd_close (CDPLAYER_CD (cdp)) == FALSE) {
+ if (cd_stop (CDPLAYER_CD (cdp)) == FALSE
+ || cd_close (CDPLAYER_CD (cdp)) == FALSE) {
return GST_STATE_FAILURE;
}
static gboolean
plugin_init (GstPlugin * plugin)
{
- return gst_element_register (plugin, "cdplayer", GST_RANK_NONE, GST_TYPE_CDPLAYER);
+ return gst_element_register (plugin, "cdplayer", GST_RANK_NONE,
+ GST_TYPE_CDPLAYER);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "cdplayer",
- "CD Player",
- plugin_init,
- VERSION,
- GST_LICENSE, /* ? */
- GST_PACKAGE,
- GST_ORIGIN
-);
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, GST_VERSION_MINOR, "cdplayer", "CD Player", plugin_init, VERSION, GST_LICENSE, /* ? */
+ GST_PACKAGE, GST_ORIGIN);
typedef struct _CDPlayer CDPlayer;
typedef struct _CDPlayerClass CDPlayerClass;
-struct _CDPlayer {
- GstBin element;
-
- /* properties */
- gchar *device;
- gint num_tracks;
- gint start_track;
- gint end_track;
- gint current_track;
- guint32 cddb_discid;
+struct _CDPlayer
+{
+ GstBin element;
- /* private */
- struct cd cd;
- gboolean paused;
+ /* properties */
+ gchar *device;
+ gint num_tracks;
+ gint start_track;
+ gint end_track;
+ gint current_track;
+ guint32 cddb_discid;
+
+ /* private */
+ struct cd cd;
+ gboolean paused;
};
-struct _CDPlayerClass {
- GstBinClass parent_class;
+struct _CDPlayerClass
+{
+ GstBinClass parent_class;
- /* signal callbacks */
- void (*track_change) (GstElement *element,guint track);
+ /* signal callbacks */
+ void (*track_change) (GstElement * element, guint track);
};
-GType cdplayer_get_type(void);
-
-#endif
+GType cdplayer_get_type (void);
+#endif
/* private functions */
-static void cd_fix_track_range(struct cd *cd,gint *start_track,gint *end_track);
-static gint cddb_sum(gint n);
+static void cd_fix_track_range (struct cd *cd, gint * start_track,
+ gint * end_track);
+static gint cddb_sum (gint n);
#if defined(HAVE_LINUX_CDROM_H)
#include <linux/cdrom.h>
CDStatus cd_status(struct cd *cd);
gint cd_current_track(struct cd *cd);
gboolean cd_close(struct cd *cd);
-*/
+*/
#if defined(HAVE_CDROM_SOLARIS)
#include "gstcdplayer_ioctl_solaris.h"
#elif defined(HAVE_CDROM_BSD)
*/
#endif
-static void cd_fix_track_range(struct cd *cd,gint *start_track,gint *end_track)
+static void
+cd_fix_track_range (struct cd *cd, gint * start_track, gint * end_track)
{
- if (*start_track <= 0) {
- *start_track = 1;
- }
+ if (*start_track <= 0) {
+ *start_track = 1;
+ }
- if (*start_track > cd->num_tracks) {
- *start_track = cd->num_tracks;
- }
+ if (*start_track > cd->num_tracks) {
+ *start_track = cd->num_tracks;
+ }
- if (*end_track < *start_track && *end_track != LEADOUT) {
- *end_track = *start_track;
- }
+ if (*end_track < *start_track && *end_track != LEADOUT) {
+ *end_track = *start_track;
+ }
- if (*end_track > cd->num_tracks || *end_track + 1 > cd->num_tracks) {
- *end_track = LEADOUT;
- }
+ if (*end_track > cd->num_tracks || *end_track + 1 > cd->num_tracks) {
+ *end_track = LEADOUT;
+ }
- return;
+ return;
}
/* this cddb info is from
this will probably be of interest to anyone wishing to actually use the discid
http://www.freedb.org/modules.php?name=Sections&sop=viewarticle&artid=28
*/
-static gint cddb_sum(gint n)
+static gint
+cddb_sum (gint n)
{
- gint ret = 0;
+ gint ret = 0;
- while (n > 0) {
- ret += n % 10;
- n /= 10;
- }
+ while (n > 0) {
+ ret += n % 10;
+ n /= 10;
+ }
- return ret;
+ return ret;
}
-guint32 cd_cddb_discid(struct cd *cd)
+guint32
+cd_cddb_discid (struct cd * cd)
{
- guint i;
- guint n = 0;
- guint t;
+ guint i;
+ guint n = 0;
+ guint t;
- for (i = 1; i <= cd->num_tracks; i++) {
- n += cddb_sum(cd->tracks[i].minute * 60 + cd->tracks[i].second);
- }
+ for (i = 1; i <= cd->num_tracks; i++) {
+ n += cddb_sum (cd->tracks[i].minute * 60 + cd->tracks[i].second);
+ }
- t = (cd->tracks[LEADOUT].minute * 60 + cd->tracks[LEADOUT].second) - (cd->tracks[1].minute * 60 + cd->tracks[1].second);
+ t = (cd->tracks[LEADOUT].minute * 60 + cd->tracks[LEADOUT].second) -
+ (cd->tracks[1].minute * 60 + cd->tracks[1].second);
- return ((n % 0xff) << 24 | t << 8 | (cd->num_tracks));
+ return ((n % 0xff) << 24 | t << 8 | (cd->num_tracks));
}
#define CDPLAYER_MAX_TRACKS 128
-typedef enum {
- CD_PLAYING,
- CD_COMPLETED,
- CD_ERROR
+typedef enum
+{
+ CD_PLAYING,
+ CD_COMPLETED,
+ CD_ERROR
} CDStatus;
-struct cd_msf {
- guint8 minute;
- guint8 second;
- guint8 frame;
+struct cd_msf
+{
+ guint8 minute;
+ guint8 second;
+ guint8 frame;
- gboolean data_track;
+ gboolean data_track;
};
-struct cd {
- gint fd;
- gint num_tracks;
- struct cd_msf tracks[CDPLAYER_MAX_TRACKS];
+struct cd
+{
+ gint fd;
+ gint num_tracks;
+ struct cd_msf tracks[CDPLAYER_MAX_TRACKS];
};
/* these are defined by the different cdrom type header files */
-gboolean cd_init(struct cd *cd,const gchar *device);
-gboolean cd_start(struct cd *cd,gint start_track,gint end_track);
-gboolean cd_pause(struct cd *cd);
-gboolean cd_resume(struct cd *cd);
-gboolean cd_stop(struct cd *cd);
-CDStatus cd_status(struct cd *cd);
-gint cd_current_track(struct cd *cd);
-gboolean cd_close(struct cd *cd);
+gboolean cd_init (struct cd *cd, const gchar * device);
+gboolean cd_start (struct cd *cd, gint start_track, gint end_track);
+gboolean cd_pause (struct cd *cd);
+gboolean cd_resume (struct cd *cd);
+gboolean cd_stop (struct cd *cd);
+CDStatus cd_status (struct cd *cd);
+gint cd_current_track (struct cd *cd);
+gboolean cd_close (struct cd *cd);
-guint32 cd_cddb_discid(struct cd *cd);
+guint32 cd_cddb_discid (struct cd *cd);
#endif
* Boston, MA 02111-1307, USA.
*/
-#ifdef HAVE_CDROM_BSD_NETBSD /* net & open */
+#ifdef HAVE_CDROM_BSD_NETBSD /* net & open */
#ifndef CDIOREADTOCHDR
#define CDIOREADTOCHDR CDIOREADTOCHEADER
#endif
-gboolean cd_init(struct cd *cd,const gchar *device)
+gboolean
+cd_init (struct cd *cd, const gchar * device)
{
- struct ioc_toc_header toc_header;
- struct ioc_read_toc_entry toc_entry;
- struct cd_toc_entry toc_entry_data;
- guint i;
-
- cd->fd = open(device,O_RDONLY | O_NONBLOCK);
-
- if (cd->fd == -1) {
- return FALSE;
- }
-
- /* get the toc header information */
- if (ioctl(cd->fd,CDIOREADTOCHDR,&toc_header) != 0) {
- close(cd->fd);
- cd->fd = -1;
- return FALSE;
- }
-
- /* read each entry in the toc header */
- for (i = 1; i <= toc_header.ending_track; i++) {
- toc_entry.address_format = CD_MSF_FORMAT;
- toc_entry.starting_track = i;
- toc_entry.data = &toc_entry_data;
- toc_entry.data_len = sizeof(toc_entry_data);
-
- if (ioctl(cd->fd,CDIOREADTOCENTRYS,&toc_entry) != 0) {
- close(cd->fd);
- cd->fd = -1;
- return FALSE;
- }
-
- cd->tracks[i].minute = toc_entry.data->addr.msf.minute;
- cd->tracks[i].second = toc_entry.data->addr.msf.second;
- cd->tracks[i].frame = toc_entry.data->addr.msf.frame;
- cd->tracks[i].data_track = (toc_entry.data->control & 4) == 4;
- }
-
- /* read the leadout */
- toc_entry.address_format = CD_MSF_FORMAT;
- toc_entry.starting_track = 0xAA; /* leadout */
- toc_entry.data = &toc_entry_data;
- toc_entry.data_len = sizeof(toc_entry_data);
-
- if (ioctl(cd->fd,CDIOREADTOCENTRYS,&toc_entry) != 0) {
- close(cd->fd);
- cd->fd = -1;
- return FALSE;
- }
-
- cd->tracks[LEADOUT].minute = toc_entry.data->addr.msf.minute;
- cd->tracks[LEADOUT].second = toc_entry.data->addr.msf.second;
- cd->tracks[LEADOUT].frame = toc_entry.data->addr.msf.frame;
-
- cd->num_tracks = toc_header.ending_track;
-
- return TRUE;
+ struct ioc_toc_header toc_header;
+ struct ioc_read_toc_entry toc_entry;
+ struct cd_toc_entry toc_entry_data;
+ guint i;
+
+ cd->fd = open (device, O_RDONLY | O_NONBLOCK);
+
+ if (cd->fd == -1) {
+ return FALSE;
+ }
+
+ /* get the toc header information */
+ if (ioctl (cd->fd, CDIOREADTOCHDR, &toc_header) != 0) {
+ close (cd->fd);
+ cd->fd = -1;
+ return FALSE;
+ }
+
+ /* read each entry in the toc header */
+ for (i = 1; i <= toc_header.ending_track; i++) {
+ toc_entry.address_format = CD_MSF_FORMAT;
+ toc_entry.starting_track = i;
+ toc_entry.data = &toc_entry_data;
+ toc_entry.data_len = sizeof (toc_entry_data);
+
+ if (ioctl (cd->fd, CDIOREADTOCENTRYS, &toc_entry) != 0) {
+ close (cd->fd);
+ cd->fd = -1;
+ return FALSE;
+ }
+
+ cd->tracks[i].minute = toc_entry.data->addr.msf.minute;
+ cd->tracks[i].second = toc_entry.data->addr.msf.second;
+ cd->tracks[i].frame = toc_entry.data->addr.msf.frame;
+ cd->tracks[i].data_track = (toc_entry.data->control & 4) == 4;
+ }
+
+ /* read the leadout */
+ toc_entry.address_format = CD_MSF_FORMAT;
+ toc_entry.starting_track = 0xAA; /* leadout */
+ toc_entry.data = &toc_entry_data;
+ toc_entry.data_len = sizeof (toc_entry_data);
+
+ if (ioctl (cd->fd, CDIOREADTOCENTRYS, &toc_entry) != 0) {
+ close (cd->fd);
+ cd->fd = -1;
+ return FALSE;
+ }
+
+ cd->tracks[LEADOUT].minute = toc_entry.data->addr.msf.minute;
+ cd->tracks[LEADOUT].second = toc_entry.data->addr.msf.second;
+ cd->tracks[LEADOUT].frame = toc_entry.data->addr.msf.frame;
+
+ cd->num_tracks = toc_header.ending_track;
+
+ return TRUE;
}
#elif defined HAVE_CDROM_BSD_DARWIN
-gboolean cd_init(struct cd *cd,const gchar *device)
+gboolean
+cd_init (struct cd *cd, const gchar * device)
{
- struct ioc_toc_header toc_header;
- struct ioc_read_toc_entry toc_entry;
- guint i;
-
- cd->fd = open(device,O_RDONLY | O_NONBLOCK);
-
- if (cd->fd == -1) {
- return FALSE;
- }
-
- /* get the toc header information */
- if (ioctl(cd->fd,CDIOREADTOCHDR,&toc_header) != 0) {
- close(cd->fd);
- cd->fd = -1;
- return FALSE;
- }
-
- /* read each entry in the toc header */
- for (i = 1; i <= toc_header.ending_track; i++) {
- toc_entry.address_format = CD_MSF_FORMAT;
- toc_entry.starting_track = i;
-
- if (ioctl(cd->fd,CDIOREADTOCENTRYS,&toc_entry) != 0) {
- close(cd->fd);
- cd->fd = -1;
- return FALSE;
- }
-
- cd->tracks[i].minute = toc_entry.data->addr[1];
- cd->tracks[i].second = toc_entry.data->addr[2];
- cd->tracks[i].frame = toc_entry.data->addr[3];
- cd->tracks[i].data_track = (toc_entry.data->control & 4) == 4;
- }
-
- /* read the leadout */
- toc_entry.address_format = CD_MSF_FORMAT;
- toc_entry.starting_track = 0xAA; /* leadout */
- toc_entry.data = &toc_entry_data;
- toc_entry.data_len = sizeof(toc_entry_data);
-
- if (ioctl(cd->fd,CDIOREADTOCENTRYS,&toc_entry) != 0) {
- close(cd->fd);
- cd->fd = -1;
- return FALSE;
- }
-
- cd->tracks[LEADOUT].minute = toc_entry.data->addr[1];
- cd->tracks[LEADOUT].second = toc_entry.data->addr[2];
- cd->tracks[LEADOUT].frame = toc_entry.data->addr[3];
-
- cd->num_tracks = toc_header.ending_track;
-
- return TRUE;
+ struct ioc_toc_header toc_header;
+ struct ioc_read_toc_entry toc_entry;
+ guint i;
+
+ cd->fd = open (device, O_RDONLY | O_NONBLOCK);
+
+ if (cd->fd == -1) {
+ return FALSE;
+ }
+
+ /* get the toc header information */
+ if (ioctl (cd->fd, CDIOREADTOCHDR, &toc_header) != 0) {
+ close (cd->fd);
+ cd->fd = -1;
+ return FALSE;
+ }
+
+ /* read each entry in the toc header */
+ for (i = 1; i <= toc_header.ending_track; i++) {
+ toc_entry.address_format = CD_MSF_FORMAT;
+ toc_entry.starting_track = i;
+
+ if (ioctl (cd->fd, CDIOREADTOCENTRYS, &toc_entry) != 0) {
+ close (cd->fd);
+ cd->fd = -1;
+ return FALSE;
+ }
+
+ cd->tracks[i].minute = toc_entry.data->addr[1];
+ cd->tracks[i].second = toc_entry.data->addr[2];
+ cd->tracks[i].frame = toc_entry.data->addr[3];
+ cd->tracks[i].data_track = (toc_entry.data->control & 4) == 4;
+ }
+
+ /* read the leadout */
+ toc_entry.address_format = CD_MSF_FORMAT;
+ toc_entry.starting_track = 0xAA; /* leadout */
+ toc_entry.data = &toc_entry_data;
+ toc_entry.data_len = sizeof (toc_entry_data);
+
+ if (ioctl (cd->fd, CDIOREADTOCENTRYS, &toc_entry) != 0) {
+ close (cd->fd);
+ cd->fd = -1;
+ return FALSE;
+ }
+
+ cd->tracks[LEADOUT].minute = toc_entry.data->addr[1];
+ cd->tracks[LEADOUT].second = toc_entry.data->addr[2];
+ cd->tracks[LEADOUT].frame = toc_entry.data->addr[3];
+
+ cd->num_tracks = toc_header.ending_track;
+
+ return TRUE;
}
#else /* free */
-gboolean cd_init(struct cd *cd,const gchar *device)
+gboolean
+cd_init (struct cd *cd, const gchar * device)
{
- struct ioc_toc_header toc_header;
- struct ioc_read_toc_entry toc_entry;
- guint i;
-
- cd->fd = open(device,O_RDONLY | O_NONBLOCK);
-
- if (cd->fd == -1) {
- return FALSE;
- }
-
- /* get the toc header information */
- if (ioctl(cd->fd,CDIOREADTOCHDR,&toc_header) != 0) {
- close(cd->fd);
- cd->fd = -1;
- return FALSE;
- }
-
- /* read each entry in the toc header */
- for (i = 1; i <= toc_header.ending_track; i++) {
- toc_entry.address_format = CD_MSF_FORMAT;
- toc_entry.starting_track = i;
-
- if (ioctl(cd->fd,CDIOREADTOCENTRYS,&toc_entry) != 0) {
- close(cd->fd);
- cd->fd = -1;
- return FALSE;
- }
-
- cd->tracks[i].minute = toc_entry.entry.addr.msf.minute;
- cd->tracks[i].second = toc_entry.entry.addr.msf.second;
- cd->tracks[i].frame = toc_entry.entry.addr.msf.frame;
- cd->tracks[i].data_track = (toc_entry.data->control & 4) == 4;
- }
-
- /* read the leadout */
- toc_entry.address_format = CD_MSF_FORMAT;
- toc_entry.starting_track = 0xAA; /* leadout */
- toc_entry.data = &toc_entry_data;
- toc_entry.data_len = sizeof(toc_entry_data);
-
- if (ioctl(cd->fd,CDIOREADTOCENTRYS,&toc_entry) != 0) {
- close(cd->fd);
- cd->fd = -1;
- return FALSE;
- }
-
- cd->tracks[LEADOUT].minute = toc_entry.entry.addr.msf.minute;
- cd->tracks[LEADOUT].second = toc_entry.entry.addr.msf.second;
- cd->tracks[LEADOUT].frame = toc_entry.entry.addr.msf.frame;
-
- cd->num_tracks = toc_header.ending_track;
-
- return TRUE;
+ struct ioc_toc_header toc_header;
+ struct ioc_read_toc_entry toc_entry;
+ guint i;
+
+ cd->fd = open (device, O_RDONLY | O_NONBLOCK);
+
+ if (cd->fd == -1) {
+ return FALSE;
+ }
+
+ /* get the toc header information */
+ if (ioctl (cd->fd, CDIOREADTOCHDR, &toc_header) != 0) {
+ close (cd->fd);
+ cd->fd = -1;
+ return FALSE;
+ }
+
+ /* read each entry in the toc header */
+ for (i = 1; i <= toc_header.ending_track; i++) {
+ toc_entry.address_format = CD_MSF_FORMAT;
+ toc_entry.starting_track = i;
+
+ if (ioctl (cd->fd, CDIOREADTOCENTRYS, &toc_entry) != 0) {
+ close (cd->fd);
+ cd->fd = -1;
+ return FALSE;
+ }
+
+ cd->tracks[i].minute = toc_entry.entry.addr.msf.minute;
+ cd->tracks[i].second = toc_entry.entry.addr.msf.second;
+ cd->tracks[i].frame = toc_entry.entry.addr.msf.frame;
+ cd->tracks[i].data_track = (toc_entry.data->control & 4) == 4;
+ }
+
+ /* read the leadout */
+ toc_entry.address_format = CD_MSF_FORMAT;
+ toc_entry.starting_track = 0xAA; /* leadout */
+ toc_entry.data = &toc_entry_data;
+ toc_entry.data_len = sizeof (toc_entry_data);
+
+ if (ioctl (cd->fd, CDIOREADTOCENTRYS, &toc_entry) != 0) {
+ close (cd->fd);
+ cd->fd = -1;
+ return FALSE;
+ }
+
+ cd->tracks[LEADOUT].minute = toc_entry.entry.addr.msf.minute;
+ cd->tracks[LEADOUT].second = toc_entry.entry.addr.msf.second;
+ cd->tracks[LEADOUT].frame = toc_entry.entry.addr.msf.frame;
+
+ cd->num_tracks = toc_header.ending_track;
+
+ return TRUE;
}
#endif
-gboolean cd_start(struct cd *cd,gint start_track,gint end_track)
+gboolean
+cd_start (struct cd * cd, gint start_track, gint end_track)
{
- struct ioc_play_msf msf;
+ struct ioc_play_msf msf;
- if (cd->fd == -1) {
- return FALSE;
- }
+ if (cd->fd == -1) {
+ return FALSE;
+ }
- cd_fix_track_range(cd,&start_track,&end_track);
+ cd_fix_track_range (cd, &start_track, &end_track);
- msf.start_m = cd->tracks[start_track].minute;
- msf.start_s = cd->tracks[start_track].second;
- msf.start_f = cd->tracks[start_track].frame;
+ msf.start_m = cd->tracks[start_track].minute;
+ msf.start_s = cd->tracks[start_track].second;
+ msf.start_f = cd->tracks[start_track].frame;
- if (end_track == LEADOUT) {
- msf.end_m = cd->tracks[end_track].minute;
- msf.end_s = cd->tracks[end_track].second;
- msf.end_f = cd->tracks[end_track].frame;
- } else {
- msf.end_m = cd->tracks[end_track+1].minute;
- msf.end_s = cd->tracks[end_track+1].second;
- msf.end_f = cd->tracks[end_track+1].frame;
- }
+ if (end_track == LEADOUT) {
+ msf.end_m = cd->tracks[end_track].minute;
+ msf.end_s = cd->tracks[end_track].second;
+ msf.end_f = cd->tracks[end_track].frame;
+ } else {
+ msf.end_m = cd->tracks[end_track + 1].minute;
+ msf.end_s = cd->tracks[end_track + 1].second;
+ msf.end_f = cd->tracks[end_track + 1].frame;
+ }
- if (ioctl(cd->fd,CDIOCPLAYMSF,&msf) != 0) {
- return FALSE;
- }
+ if (ioctl (cd->fd, CDIOCPLAYMSF, &msf) != 0) {
+ return FALSE;
+ }
}
-gboolean cd_pause(struct cd *cd)
+gboolean
+cd_pause (struct cd * cd)
{
- if (cd->fd == -1) {
- return FALSE;
- }
+ if (cd->fd == -1) {
+ return FALSE;
+ }
- if (ioctl(cd->fd,CDIOCPAUSE,NULL) != 0) {
- return FALSE;
- }
+ if (ioctl (cd->fd, CDIOCPAUSE, NULL) != 0) {
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
-gboolean cd_resume(struct cd *cd)
+gboolean
+cd_resume (struct cd * cd)
{
- if (cd->fd == -1) {
- return FALSE;
- }
+ if (cd->fd == -1) {
+ return FALSE;
+ }
- if (ioctl(cd->fd,CDIOCRESUME,NULL) != 0) {
- return FALSE;
- }
+ if (ioctl (cd->fd, CDIOCRESUME, NULL) != 0) {
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
-gboolean cd_stop(struct cd *cd)
+gboolean
+cd_stop (struct cd * cd)
{
- if (cd->fd == -1) {
- return FALSE;
- }
+ if (cd->fd == -1) {
+ return FALSE;
+ }
- if (ioctl(cd->fd,CDIOCSTOP,NULL) != 0) {
- return FALSE;
- }
+ if (ioctl (cd->fd, CDIOCSTOP, NULL) != 0) {
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
/* -1 for error, 0 for not playing, 1 for playing */
-CDStatus cd_status(struct cd *cd)
+CDStatus
+cd_status (struct cd * cd)
{
- struct ioc_read_subchannel sub_channel;
- struct cd_sub_channel_info sub_channel_info;
-
- if (cd->fd == -1) {
- return -1;
- }
-
- sub_channel.address_format = CD_MSF_FORMAT;
- sub_channel.data_format = CD_CURRENT_POSITION;
- sub_channel.track = 0;
- sub_channel.data = &sub_channel_info;
- sub_channel.data_len = sizeof(sub_channel_info);
-
- if (ioctl(cd->fd,CDIOCREADSUBCHANNEL,&sub_channel) != 0) {
- return FALSE;
- }
-
- switch (sub_channel.data->header.audio_status) {
- case CD_AS_PLAY_IN_PROGRESS:
- case CD_AS_PLAY_PAUSED:
- return CD_PLAYING;
- break;
- case CD_AS_PLAY_COMPLETED:
- return CD_COMPLETED;
- break;
- case CD_AS_AUDIO_INVALID:
- case CD_AS_PLAY_ERROR:
- default:
- return CD_ERROR;
- break;
-
- }
+ struct ioc_read_subchannel sub_channel;
+ struct cd_sub_channel_info sub_channel_info;
+
+ if (cd->fd == -1) {
+ return -1;
+ }
+
+ sub_channel.address_format = CD_MSF_FORMAT;
+ sub_channel.data_format = CD_CURRENT_POSITION;
+ sub_channel.track = 0;
+ sub_channel.data = &sub_channel_info;
+ sub_channel.data_len = sizeof (sub_channel_info);
+
+ if (ioctl (cd->fd, CDIOCREADSUBCHANNEL, &sub_channel) != 0) {
+ return FALSE;
+ }
+
+ switch (sub_channel.data->header.audio_status) {
+ case CD_AS_PLAY_IN_PROGRESS:
+ case CD_AS_PLAY_PAUSED:
+ return CD_PLAYING;
+ break;
+ case CD_AS_PLAY_COMPLETED:
+ return CD_COMPLETED;
+ break;
+ case CD_AS_AUDIO_INVALID:
+ case CD_AS_PLAY_ERROR:
+ default:
+ return CD_ERROR;
+ break;
+
+ }
}
-gint cd_current_track(struct cd *cd)
+gint
+cd_current_track (struct cd *cd)
{
- struct ioc_read_subchannel sub_channel;
- struct cd_sub_channel_info sub_channel_info;
-
- if (cd->fd == -1) {
- return -1;
- }
-
- sub_channel.address_format = CD_MSF_FORMAT;
- sub_channel.data_format = CD_TRACK_INFO;
- sub_channel.track = 0;
- sub_channel.data = &sub_channel_info;
- sub_channel.data_len = sizeof(sub_channel_info);
-
- if (ioctl(cd->fd,CDIOCREADSUBCHANNEL,&sub_channel) != 0) {
- return -1;
- }
-
+ struct ioc_read_subchannel sub_channel;
+ struct cd_sub_channel_info sub_channel_info;
+
+ if (cd->fd == -1) {
+ return -1;
+ }
+
+ sub_channel.address_format = CD_MSF_FORMAT;
+ sub_channel.data_format = CD_TRACK_INFO;
+ sub_channel.track = 0;
+ sub_channel.data = &sub_channel_info;
+ sub_channel.data_len = sizeof (sub_channel_info);
+
+ if (ioctl (cd->fd, CDIOCREADSUBCHANNEL, &sub_channel) != 0) {
+ return -1;
+ }
#ifdef __NetBSD__
- return sub_channel.data->what.track_info.track_number;
+ return sub_channel.data->what.track_info.track_number;
#else
- return sub_channel.data->track_number;
+ return sub_channel.data->track_number;
#endif
}
-gboolean cd_close(struct cd *cd)
+gboolean
+cd_close (struct cd * cd)
{
- if (cd->fd == -1) {
- return TRUE;
- }
+ if (cd->fd == -1) {
+ return TRUE;
+ }
- if (close(cd->fd) != 0) {
- return FALSE;
- }
+ if (close (cd->fd) != 0) {
+ return FALSE;
+ }
- cd->fd = -1;
+ cd->fd = -1;
- return TRUE;
+ return TRUE;
}
-
#define CDPLAYER(x) ((CDPlayer *)x)
#define FD(x) ((int)x)
-gboolean cd_init(struct cd *cd,const gchar *device)
+gboolean
+cd_init (struct cd *cd, const gchar * device)
{
- CDPLAYER *cdplayer;
- CDSTATUS status;
- CDTRACKINFO info;
- guint i;
+ CDPLAYER *cdplayer;
+ CDSTATUS status;
+ CDTRACKINFO info;
+ guint i;
- cdplayer = CDOpen(device,"r");
+ cdplayer = CDOpen (device, "r");
- if (cdplayer == NULL) {
- return FALSE;
- }
+ if (cdplayer == NULL) {
+ return FALSE;
+ }
- cd->fd = FD(cdplayer);
+ cd->fd = FD (cdplayer);
- if (CDgetstatus(cdplayer,&status) == 0) {
- CDclose(cdplayer);
- cd->fd = 0;
- return FALSE;
- }
+ if (CDgetstatus (cdplayer, &status) == 0) {
+ CDclose (cdplayer);
+ cd->fd = 0;
+ return FALSE;
+ }
- for (i = 1; i < status.last; i++) {
- if (CDgettrackinfo(cdplayer,i,&info) == 0) {
- CDclose(cdplayer);
- cd->fd = 0;
- return FALSE;
- }
+ for (i = 1; i < status.last; i++) {
+ if (CDgettrackinfo (cdplayer, i, &info) == 0) {
+ CDclose (cdplayer);
+ cd->fd = 0;
+ return FALSE;
+ }
- cd->tracks[i].minute = info.start_min;
- cd->tracks[i].second = info.start_sec;
- cd->tracks[i].frame = info.start_frame;
+ cd->tracks[i].minute = info.start_min;
+ cd->tracks[i].second = info.start_sec;
+ cd->tracks[i].frame = info.start_frame;
- }
+ }
- /* there is no leadout information */
-
+ /* there is no leadout information */
- cd->num_tracks = status.last;
- return TRUE;
+ cd->num_tracks = status.last;
+
+ return TRUE;
}
-gboolean cd_start(struct cd *cd,gint start_track,gint end_track)
+gboolean
+cd_start (struct cd * cd, gint start_track, gint end_track)
{
- if (cd->fd == 0) {
- return FALSE;
- }
+ if (cd->fd == 0) {
+ return FALSE;
+ }
+
+ cd_fix_track_range (cd, &start_track, &end_track);
- cd_fix_track_range(cd,&start_track,&end_track);
-
}
-gboolean cd_pause(struct cd *cd)
+gboolean
+cd_pause (struct cd * cd)
{
}
-gboolean cd_resume(struct cd *cd)
+gboolean
+cd_resume (struct cd *cd)
{
}
-gboolean cd_stop(struct cd *cd)
+gboolean
+cd_stop (struct cd *cd)
{
}
/* -1 for error, 0 for not playing, 1 for playing */
-CDStatus cd_status(struct cd *cd)
+CDStatus
+cd_status (struct cd *cd)
{
}
-gint cd_current_track(struct cd *cd)
+gint
+cd_current_track (struct cd *cd)
{
}
-gboolean cd_close(struct cd *cd)
+gboolean
+cd_close (struct cd *cd)
{
}
-
* Boston, MA 02111-1307, USA.
*/
-gboolean cd_init(struct cd *cd,const gchar *device)
+gboolean
+cd_init (struct cd *cd, const gchar * device)
{
- struct cdrom_tochdr toc_header;
- struct cdrom_tocentry toc_entry;
- guint i;
-
- cd->fd = open(device,O_RDONLY | O_NONBLOCK);
-
- if (cd->fd == -1) {
- return FALSE;
- }
-
- /* get the toc header information */
- if (ioctl(cd->fd,CDROMREADTOCHDR,&toc_header) != 0) {
- close(cd->fd);
- cd->fd = -1;
- return FALSE;
- }
-
- /* read each entry in the toc header */
- for (i = 1; i <= toc_header.cdth_trk1; i++) {
- toc_entry.cdte_format = CDROM_MSF;
- toc_entry.cdte_track = i;
-
- if (ioctl(cd->fd,CDROMREADTOCENTRY,&toc_entry) != 0) {
- close(cd->fd);
- cd->fd = -1;
- return FALSE;
- }
-
- cd->tracks[i].minute = toc_entry.cdte_addr.msf.minute;
- cd->tracks[i].second = toc_entry.cdte_addr.msf.second;
- cd->tracks[i].frame = toc_entry.cdte_addr.msf.frame;
- cd->tracks[i].data_track = (toc_entry.cdte_ctrl == CDROM_DATA_TRACK);
- }
-
- /* read the leadout */
- toc_entry.cdte_track = CDROM_LEADOUT;
- toc_entry.cdte_format = CDROM_MSF;
- if (ioctl(cd->fd,CDROMREADTOCENTRY,&toc_entry) != 0) {
- close(cd->fd);
- cd->fd = -1;
- return FALSE;
- }
- cd->tracks[LEADOUT].minute = toc_entry.cdte_addr.msf.minute;
- cd->tracks[LEADOUT].second = toc_entry.cdte_addr.msf.second;
- cd->tracks[LEADOUT].frame = toc_entry.cdte_addr.msf.frame;
-
- cd->num_tracks = toc_header.cdth_trk1;
-
- return TRUE;
+ struct cdrom_tochdr toc_header;
+ struct cdrom_tocentry toc_entry;
+ guint i;
+
+ cd->fd = open (device, O_RDONLY | O_NONBLOCK);
+
+ if (cd->fd == -1) {
+ return FALSE;
+ }
+
+ /* get the toc header information */
+ if (ioctl (cd->fd, CDROMREADTOCHDR, &toc_header) != 0) {
+ close (cd->fd);
+ cd->fd = -1;
+ return FALSE;
+ }
+
+ /* read each entry in the toc header */
+ for (i = 1; i <= toc_header.cdth_trk1; i++) {
+ toc_entry.cdte_format = CDROM_MSF;
+ toc_entry.cdte_track = i;
+
+ if (ioctl (cd->fd, CDROMREADTOCENTRY, &toc_entry) != 0) {
+ close (cd->fd);
+ cd->fd = -1;
+ return FALSE;
+ }
+
+ cd->tracks[i].minute = toc_entry.cdte_addr.msf.minute;
+ cd->tracks[i].second = toc_entry.cdte_addr.msf.second;
+ cd->tracks[i].frame = toc_entry.cdte_addr.msf.frame;
+ cd->tracks[i].data_track = (toc_entry.cdte_ctrl == CDROM_DATA_TRACK);
+ }
+
+ /* read the leadout */
+ toc_entry.cdte_track = CDROM_LEADOUT;
+ toc_entry.cdte_format = CDROM_MSF;
+ if (ioctl (cd->fd, CDROMREADTOCENTRY, &toc_entry) != 0) {
+ close (cd->fd);
+ cd->fd = -1;
+ return FALSE;
+ }
+ cd->tracks[LEADOUT].minute = toc_entry.cdte_addr.msf.minute;
+ cd->tracks[LEADOUT].second = toc_entry.cdte_addr.msf.second;
+ cd->tracks[LEADOUT].frame = toc_entry.cdte_addr.msf.frame;
+
+ cd->num_tracks = toc_header.cdth_trk1;
+
+ return TRUE;
}
-gboolean cd_start(struct cd *cd,gint start_track,gint end_track)
+gboolean
+cd_start (struct cd * cd, gint start_track, gint end_track)
{
- struct cdrom_msf msf;
+ struct cdrom_msf msf;
- if (cd->fd == -1) {
- return FALSE;
- }
+ if (cd->fd == -1) {
+ return FALSE;
+ }
- cd_fix_track_range(cd,&start_track,&end_track);
+ cd_fix_track_range (cd, &start_track, &end_track);
- msf.cdmsf_min0 = cd->tracks[start_track].minute;
- msf.cdmsf_sec0 = cd->tracks[start_track].second;
- msf.cdmsf_frame0 = cd->tracks[start_track].frame;
+ msf.cdmsf_min0 = cd->tracks[start_track].minute;
+ msf.cdmsf_sec0 = cd->tracks[start_track].second;
+ msf.cdmsf_frame0 = cd->tracks[start_track].frame;
- if (end_track == LEADOUT) {
- msf.cdmsf_min1 = cd->tracks[end_track].minute;
- msf.cdmsf_sec1 = cd->tracks[end_track].second;
- msf.cdmsf_frame1 = cd->tracks[end_track].frame;
- } else {
- msf.cdmsf_min1 = cd->tracks[end_track+1].minute;
- msf.cdmsf_sec1 = cd->tracks[end_track+1].second;
- msf.cdmsf_frame1 = cd->tracks[end_track+1].frame;
- }
+ if (end_track == LEADOUT) {
+ msf.cdmsf_min1 = cd->tracks[end_track].minute;
+ msf.cdmsf_sec1 = cd->tracks[end_track].second;
+ msf.cdmsf_frame1 = cd->tracks[end_track].frame;
+ } else {
+ msf.cdmsf_min1 = cd->tracks[end_track + 1].minute;
+ msf.cdmsf_sec1 = cd->tracks[end_track + 1].second;
+ msf.cdmsf_frame1 = cd->tracks[end_track + 1].frame;
+ }
- if (ioctl(cd->fd,CDROMPLAYMSF,&msf) != 0) {
- return FALSE;
- }
+ if (ioctl (cd->fd, CDROMPLAYMSF, &msf) != 0) {
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
-gboolean cd_pause(struct cd *cd)
+gboolean
+cd_pause (struct cd * cd)
{
- if (cd->fd == -1) {
- return FALSE;
- }
+ if (cd->fd == -1) {
+ return FALSE;
+ }
- if (ioctl(cd->fd,CDROMPAUSE,NULL) != 0) {
- return FALSE;
- }
+ if (ioctl (cd->fd, CDROMPAUSE, NULL) != 0) {
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
-gboolean cd_resume(struct cd *cd)
+gboolean
+cd_resume (struct cd * cd)
{
- if (cd->fd == -1) {
- return FALSE;
- }
+ if (cd->fd == -1) {
+ return FALSE;
+ }
- if (ioctl(cd->fd,CDROMRESUME,NULL) != 0) {
- return FALSE;
- }
+ if (ioctl (cd->fd, CDROMRESUME, NULL) != 0) {
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
-gboolean cd_stop(struct cd *cd)
+gboolean
+cd_stop (struct cd * cd)
{
- if (cd->fd == -1) {
- return FALSE;
- }
+ if (cd->fd == -1) {
+ return FALSE;
+ }
- if (ioctl(cd->fd,CDROMSTOP,NULL) != 0) {
- return FALSE;
- }
+ if (ioctl (cd->fd, CDROMSTOP, NULL) != 0) {
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
/* -1 for error, 0 for not playing, 1 for playing */
-CDStatus cd_status(struct cd *cd)
+CDStatus
+cd_status (struct cd * cd)
{
- struct cdrom_subchnl sub_channel;
-
- if (cd->fd == -1) {
- return -1;
- }
-
- sub_channel.cdsc_format = CDROM_MSF;
-
- if (ioctl(cd->fd,CDROMSUBCHNL,&sub_channel) != 0) {
- return -1;
- }
-
- switch (sub_channel.cdsc_audiostatus) {
- case CDROM_AUDIO_COMPLETED:
- return CD_COMPLETED;
- break;
- case CDROM_AUDIO_PLAY:
- case CDROM_AUDIO_PAUSED:
- return CD_PLAYING;
- break;
- case CDROM_AUDIO_ERROR:
- default:
- return CD_ERROR;
- }
+ struct cdrom_subchnl sub_channel;
+
+ if (cd->fd == -1) {
+ return -1;
+ }
+
+ sub_channel.cdsc_format = CDROM_MSF;
+
+ if (ioctl (cd->fd, CDROMSUBCHNL, &sub_channel) != 0) {
+ return -1;
+ }
+
+ switch (sub_channel.cdsc_audiostatus) {
+ case CDROM_AUDIO_COMPLETED:
+ return CD_COMPLETED;
+ break;
+ case CDROM_AUDIO_PLAY:
+ case CDROM_AUDIO_PAUSED:
+ return CD_PLAYING;
+ break;
+ case CDROM_AUDIO_ERROR:
+ default:
+ return CD_ERROR;
+ }
}
-gint cd_current_track(struct cd *cd)
+gint
+cd_current_track (struct cd * cd)
{
- struct cdrom_subchnl sub_channel;
+ struct cdrom_subchnl sub_channel;
- if (cd->fd == -1) {
- return -1;
- }
+ if (cd->fd == -1) {
+ return -1;
+ }
- sub_channel.cdsc_format = CDROM_MSF;
+ sub_channel.cdsc_format = CDROM_MSF;
- if (ioctl(cd->fd,CDROMSUBCHNL,&sub_channel) != 0) {
- return -1;
- }
+ if (ioctl (cd->fd, CDROMSUBCHNL, &sub_channel) != 0) {
+ return -1;
+ }
- return sub_channel.cdsc_trk;
+ return sub_channel.cdsc_trk;
}
-gboolean cd_close(struct cd *cd)
+gboolean
+cd_close (struct cd * cd)
{
- if (cd->fd == -1) {
- return TRUE;
- }
+ if (cd->fd == -1) {
+ return TRUE;
+ }
- if (close(cd->fd) != 0) {
- return FALSE;
- }
+ if (close (cd->fd) != 0) {
+ return FALSE;
+ }
- cd->fd = -1;
+ cd->fd = -1;
- return TRUE;
+ return TRUE;
}
-
unsigned short bit_rate;
unsigned short frm_size[3];
};
-
-
-static const struct frmsize_s frmsizecod_tbl[64] =
- {
- { 32 ,{64 ,69 ,96 } },
- { 32 ,{64 ,70 ,96 } },
- { 40 ,{80 ,87 ,120 } },
- { 40 ,{80 ,88 ,120 } },
- { 48 ,{96 ,104 ,144 } },
- { 48 ,{96 ,105 ,144 } },
- { 56 ,{112 ,121 ,168 } },
- { 56 ,{112 ,122 ,168 } },
- { 64 ,{128 ,139 ,192 } },
- { 64 ,{128 ,140 ,192 } },
- { 80 ,{160 ,174 ,240 } },
- { 80 ,{160 ,175 ,240 } },
- { 96 ,{192 ,208 ,288 } },
- { 96 ,{192 ,209 ,288 } },
- { 112 ,{224 ,243 ,336 } },
- { 112 ,{224 ,244 ,336 } },
- { 128 ,{256 ,278 ,384 } },
- { 128 ,{256 ,279 ,384 } },
- { 160 ,{320 ,348 ,480 } },
- { 160 ,{320 ,349 ,480 } },
- { 192 ,{384 ,417 ,576 } },
- { 192 ,{384 ,418 ,576 } },
- { 224 ,{448 ,487 ,672 } },
- { 224 ,{448 ,488 ,672 } },
- { 256 ,{512 ,557 ,768 } },
- { 256 ,{512 ,558 ,768 } },
- { 320 ,{640 ,696 ,960 } },
- { 320 ,{640 ,697 ,960 } },
- { 384 ,{768 ,835 ,1152 } },
- { 384 ,{768 ,836 ,1152 } },
- { 448 ,{896 ,975 ,1344 } },
- { 448 ,{896 ,976 ,1344 } },
- { 512 ,{1024 ,1114 ,1536 } },
- { 512 ,{1024 ,1115 ,1536 } },
- { 576 ,{1152 ,1253 ,1728 } },
- { 576 ,{1152 ,1254 ,1728 } },
- { 640 ,{1280 ,1393 ,1920 } },
- { 640 ,{1280 ,1394 ,1920 } }
- };
+
+
+static const struct frmsize_s frmsizecod_tbl[64] = {
+ {32, {64, 69, 96}},
+ {32, {64, 70, 96}},
+ {40, {80, 87, 120}},
+ {40, {80, 88, 120}},
+ {48, {96, 104, 144}},
+ {48, {96, 105, 144}},
+ {56, {112, 121, 168}},
+ {56, {112, 122, 168}},
+ {64, {128, 139, 192}},
+ {64, {128, 140, 192}},
+ {80, {160, 174, 240}},
+ {80, {160, 175, 240}},
+ {96, {192, 208, 288}},
+ {96, {192, 209, 288}},
+ {112, {224, 243, 336}},
+ {112, {224, 244, 336}},
+ {128, {256, 278, 384}},
+ {128, {256, 279, 384}},
+ {160, {320, 348, 480}},
+ {160, {320, 349, 480}},
+ {192, {384, 417, 576}},
+ {192, {384, 418, 576}},
+ {224, {448, 487, 672}},
+ {224, {448, 488, 672}},
+ {256, {512, 557, 768}},
+ {256, {512, 558, 768}},
+ {320, {640, 696, 960}},
+ {320, {640, 697, 960}},
+ {384, {768, 835, 1152}},
+ {384, {768, 836, 1152}},
+ {448, {896, 975, 1344}},
+ {448, {896, 976, 1344}},
+ {512, {1024, 1114, 1536}},
+ {512, {1024, 1115, 1536}},
+ {576, {1152, 1253, 1728}},
+ {576, {1152, 1254, 1728}},
+ {640, {1280, 1393, 1920}},
+ {640, {1280, 1394, 1920}}
+};
* (S/PDIF) padded packets.
*/
extern void
-ac3p_init(ac3_padder *padder)
+ac3p_init (ac3_padder * padder)
{
const char sync[4] = { 0x72, 0xF8, 0x1F, 0x4E };
padder->remaining = 0;
/* Initialize the sync bytes in the frame. */
- memcpy(padder->frame.header, sync, 4);
+ memcpy (padder->frame.header, sync, 4);
}
* function returns the %AC3P_EVENT_PUSH event.
*/
extern void
-ac3p_push_data(ac3_padder *padder, guchar *data, guint size)
+ac3p_push_data (ac3_padder * padder, guchar * data, guint size)
{
padder->in_ptr = data;
padder->remaining = size;
* pushing the data.
*/
extern int
-ac3p_parse(ac3_padder *padder)
+ac3p_parse (ac3_padder * padder)
{
while (padder->remaining > 0) {
switch (padder->state) {
- case AC3P_STATE_SYNC1:
- if (*(padder->in_ptr) == 0x0b) {
- /* The first sync byte was found. Go to the next state. */
- padder->frame.sync_byte1 = 0x0b;
- padder->state = AC3P_STATE_SYNC2;
- }
- ac3p_in_fw(padder);
- break;
-
- case AC3P_STATE_SYNC2:
- if (*(padder->in_ptr) == 0x77) {
- /* The second sync byte was seen right after the first. Go to
- the next state. */
- padder->frame.sync_byte2 = 0x77;
- padder->state = AC3P_STATE_HEADER;
-
- /* Skip one byte. */
- ac3p_in_fw(padder);
-
- /* Prepare for reading the header. */
- padder->out_ptr = (guchar *) &(padder->frame.crc1);
- /* Discount the 2 sync bytes from the header size. */
- padder->bytes_to_copy = AC3P_AC3_HEADER_SIZE - 2;
- }
- else {
- /* The second sync byte was not seen. Go back to the
- first state. */
- padder->state = AC3P_STATE_SYNC1;
- }
- break;
-
- case AC3P_STATE_HEADER:
- if (padder->bytes_to_copy > 0) {
- /* Copy one byte. */
- *(padder->out_ptr) = *(padder->in_ptr);
- ac3p_in_fw(padder);
- ac3p_out_fw(padder);
- }
- else {
- int fscod;
-
- /* The header is ready: */
-
- fscod = (padder->frame.code >> 6) & 0x03;
-
- /* Calculate the frame size. */
- padder->ac3_frame_size =
- 2 * frmsizecod_tbl[padder->frame.code & 0x3f].frm_size[fscod];
-
- /* Set up the IEC header. */
- if (padder->ac3_frame_size > 0) {
- padder->frame.header[4] = IEC61937_DATA_TYPE_AC3;
- }
- else {
- /* Don't know what it is, better be careful. */
- padder->state = AC3P_STATE_SYNC1;
- break;
- }
- padder->frame.header[5] = 0x00;
- padder->frame.header[6] = (padder->ac3_frame_size*8) & 0xFF;
- padder->frame.header[7] = ((padder->ac3_frame_size*8) >> 8) & 0xFF;
-
- /* Prepare for reading the body. */
- padder->bytes_to_copy = padder->ac3_frame_size - AC3P_AC3_HEADER_SIZE;
- padder->state = AC3P_STATE_CONTENT;
- }
- break;
-
- case AC3P_STATE_CONTENT:
- if (padder->bytes_to_copy > 0) {
- /* Copy one byte. */
- *(padder->out_ptr) = *(padder->in_ptr);
- ac3p_in_fw(padder);
- ac3p_out_fw(padder);
- }
- else {
- guint16 *ptr, i;
-
- /* Frame ready. Prepare for output: */
-
- /* Zero the non AC3 portion of the padded frame. */
- memset(&(padder->frame.sync_byte1) + padder->ac3_frame_size, 0,
- AC3P_IEC_FRAME_SIZE - AC3P_IEC_HEADER_SIZE - padder->ac3_frame_size);
-
- /* Fix the byte order in the AC3 portion: */
- ptr = (guint16 *) &(padder->frame.sync_byte1);
- i = padder->ac3_frame_size / 2;
- while (i > 0) {
- *ptr = GUINT16_TO_BE(*ptr);
- ptr++;
- i--;
- }
-
- /* Start over again. */
- padder->state = AC3P_STATE_SYNC1;
-
- return AC3P_EVENT_FRAME;
- }
- break;
+ case AC3P_STATE_SYNC1:
+ if (*(padder->in_ptr) == 0x0b) {
+ /* The first sync byte was found. Go to the next state. */
+ padder->frame.sync_byte1 = 0x0b;
+ padder->state = AC3P_STATE_SYNC2;
+ }
+ ac3p_in_fw (padder);
+ break;
+
+ case AC3P_STATE_SYNC2:
+ if (*(padder->in_ptr) == 0x77) {
+ /* The second sync byte was seen right after the first. Go to
+ the next state. */
+ padder->frame.sync_byte2 = 0x77;
+ padder->state = AC3P_STATE_HEADER;
+
+ /* Skip one byte. */
+ ac3p_in_fw (padder);
+
+ /* Prepare for reading the header. */
+ padder->out_ptr = (guchar *) & (padder->frame.crc1);
+ /* Discount the 2 sync bytes from the header size. */
+ padder->bytes_to_copy = AC3P_AC3_HEADER_SIZE - 2;
+ } else {
+ /* The second sync byte was not seen. Go back to the
+ first state. */
+ padder->state = AC3P_STATE_SYNC1;
+ }
+ break;
+
+ case AC3P_STATE_HEADER:
+ if (padder->bytes_to_copy > 0) {
+ /* Copy one byte. */
+ *(padder->out_ptr) = *(padder->in_ptr);
+ ac3p_in_fw (padder);
+ ac3p_out_fw (padder);
+ } else {
+ int fscod;
+
+ /* The header is ready: */
+
+ fscod = (padder->frame.code >> 6) & 0x03;
+
+ /* Calculate the frame size. */
+ padder->ac3_frame_size =
+ 2 * frmsizecod_tbl[padder->frame.code & 0x3f].frm_size[fscod];
+
+ /* Set up the IEC header. */
+ if (padder->ac3_frame_size > 0) {
+ padder->frame.header[4] = IEC61937_DATA_TYPE_AC3;
+ } else {
+ /* Don't know what it is, better be careful. */
+ padder->state = AC3P_STATE_SYNC1;
+ break;
+ }
+ padder->frame.header[5] = 0x00;
+ padder->frame.header[6] = (padder->ac3_frame_size * 8) & 0xFF;
+ padder->frame.header[7] = ((padder->ac3_frame_size * 8) >> 8) & 0xFF;
+
+ /* Prepare for reading the body. */
+ padder->bytes_to_copy = padder->ac3_frame_size - AC3P_AC3_HEADER_SIZE;
+ padder->state = AC3P_STATE_CONTENT;
+ }
+ break;
+
+ case AC3P_STATE_CONTENT:
+ if (padder->bytes_to_copy > 0) {
+ /* Copy one byte. */
+ *(padder->out_ptr) = *(padder->in_ptr);
+ ac3p_in_fw (padder);
+ ac3p_out_fw (padder);
+ } else {
+ guint16 *ptr, i;
+
+ /* Frame ready. Prepare for output: */
+
+ /* Zero the non AC3 portion of the padded frame. */
+ memset (&(padder->frame.sync_byte1) + padder->ac3_frame_size, 0,
+ AC3P_IEC_FRAME_SIZE - AC3P_IEC_HEADER_SIZE -
+ padder->ac3_frame_size);
+
+ /* Fix the byte order in the AC3 portion: */
+ ptr = (guint16 *) & (padder->frame.sync_byte1);
+ i = padder->ac3_frame_size / 2;
+ while (i > 0) {
+ *ptr = GUINT16_TO_BE (*ptr);
+ ptr++;
+ i--;
+ }
+
+ /* Start over again. */
+ padder->state = AC3P_STATE_SYNC1;
+
+ return AC3P_EVENT_FRAME;
+ }
+ break;
}
}
return AC3P_EVENT_PUSH;
}
-
/* An IEC958 padded AC3 frame. */
-typedef struct {
+typedef struct
+{
/* IEC header. */
guchar header[AC3P_IEC_HEADER_SIZE];
guchar bsidmod;
guchar acmod;
/* End of AC3 header. */
-
- unsigned char data[AC3P_IEC_FRAME_SIZE - AC3P_IEC_HEADER_SIZE
- - AC3P_AC3_HEADER_SIZE];
+
+ unsigned char data[AC3P_IEC_FRAME_SIZE - AC3P_IEC_HEADER_SIZE
+ - AC3P_AC3_HEADER_SIZE];
} ac3p_iec958_burst_frame;
/* The internal state for the padder. */
-typedef struct {
- guint state; /* State of the reading automaton. */
+typedef struct
+{
+ guint state; /* State of the reading automaton. */
- guchar *in_ptr; /* Input pointer, marking the current
- postion in the input buffer. */
- guint remaining; /* The number of bytes remaining in the current
- reading buffer. */
+ guchar *in_ptr; /* Input pointer, marking the current
+ postion in the input buffer. */
+ guint remaining; /* The number of bytes remaining in the current
+ reading buffer. */
- guchar *out_ptr; /* Output pointer, marking the current
- position in the output frame. */
+ guchar *out_ptr; /* Output pointer, marking the current
+ position in the output frame. */
guint bytes_to_copy;
- /* Number of bytes that still must be copied
- to the output frame *during this reading
- stage*. */
+ /* Number of bytes that still must be copied
+ to the output frame *during this reading
+ stage*. */
guint ac3_frame_size;
- /* The size in bytes of the pure AC3 portion
- of the current frame. */
+ /* The size in bytes of the pure AC3 portion
+ of the current frame. */
ac3p_iec958_burst_frame frame;
- /* The current output frame. */
+ /* The current output frame. */
} ac3_padder;
-extern void
-ac3p_init(ac3_padder *padder);
+extern void ac3p_init (ac3_padder * padder);
-extern void
-ac3p_push_data(ac3_padder *padder, guchar *data, guint size);
+extern void ac3p_push_data (ac3_padder * padder, guchar * data, guint size);
-extern int
-ac3p_parse(ac3_padder *padder);
+extern int ac3p_parse (ac3_padder * padder);
/**
/* Dxr3AudioSink signals and args */
-enum {
+enum
+{
SIGNAL_FLUSHED,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_DIGITAL_PCM
};
static GstStaticPadTemplate dxr3audiosink_pcm_sink_factory =
-GST_STATIC_PAD_TEMPLATE (
- "pcm_sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "audio/x-raw-int, "
- "endianness = (int) BYTE_ORDER, "
- "signed = (boolean) TRUE, "
- "width = (int) 16, "
- "depth = (int) 16, "
- "rate = (int) { 32000, 44100, 48000, 66000 }, "
- "channels = (int) 2"
- )
-);
+GST_STATIC_PAD_TEMPLATE ("pcm_sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-raw-int, "
+ "endianness = (int) BYTE_ORDER, "
+ "signed = (boolean) TRUE, "
+ "width = (int) 16, "
+ "depth = (int) 16, "
+ "rate = (int) { 32000, 44100, 48000, 66000 }, " "channels = (int) 2")
+ );
static GstStaticPadTemplate dxr3audiosink_ac3_sink_factory =
-GST_STATIC_PAD_TEMPLATE (
- "ac3_sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "audio/x-ac3"
- /* no parameters needed, we don't need a parsed stream */
- )
-);
-
-
-static void dxr3audiosink_class_init (Dxr3AudioSinkClass *klass);
-static void dxr3audiosink_base_init (Dxr3AudioSinkClass *klass);
-static void dxr3audiosink_init (Dxr3AudioSink *sink);
-
-static void dxr3audiosink_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void dxr3audiosink_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-
-static gboolean dxr3audiosink_open (Dxr3AudioSink *sink);
-static gboolean dxr3audiosink_set_mode_pcm (Dxr3AudioSink *sink);
-static gboolean dxr3audiosink_set_mode_ac3 (Dxr3AudioSink *sink);
-static void dxr3audiosink_close (Dxr3AudioSink *sink);
-static void dxr3audiosink_set_clock (GstElement *element,
- GstClock *clock);
-
-static GstPadLinkReturn dxr3audiosink_pcm_sinklink (GstPad *pad,
- const GstCaps *caps);
-static void dxr3audiosink_set_scr (Dxr3AudioSink *sink,
- guint32 scr);
-
-static gboolean dxr3audiosink_handle_event (GstPad *pad,
- GstEvent *event);
-static void dxr3audiosink_chain_pcm (GstPad *pad,GstData *buf);
-static void dxr3audiosink_chain_ac3 (GstPad *pad, GstData *buf);
+GST_STATIC_PAD_TEMPLATE ("ac3_sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-ac3"
+ /* no parameters needed, we don't need a parsed stream */
+ )
+ );
+
+
+static void dxr3audiosink_class_init (Dxr3AudioSinkClass * klass);
+static void dxr3audiosink_base_init (Dxr3AudioSinkClass * klass);
+static void dxr3audiosink_init (Dxr3AudioSink * sink);
+
+static void dxr3audiosink_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+static void dxr3audiosink_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
+
+static gboolean dxr3audiosink_open (Dxr3AudioSink * sink);
+static gboolean dxr3audiosink_set_mode_pcm (Dxr3AudioSink * sink);
+static gboolean dxr3audiosink_set_mode_ac3 (Dxr3AudioSink * sink);
+static void dxr3audiosink_close (Dxr3AudioSink * sink);
+static void dxr3audiosink_set_clock (GstElement * element, GstClock * clock);
+
+static GstPadLinkReturn dxr3audiosink_pcm_sinklink (GstPad * pad,
+ const GstCaps * caps);
+static void dxr3audiosink_set_scr (Dxr3AudioSink * sink, guint32 scr);
+
+static gboolean dxr3audiosink_handle_event (GstPad * pad, GstEvent * event);
+static void dxr3audiosink_chain_pcm (GstPad * pad, GstData * buf);
+static void dxr3audiosink_chain_ac3 (GstPad * pad, GstData * buf);
/* static void dxr3audiosink_wait (Dxr3AudioSink *sink, */
/* GstClockTime time); */
/* static int dxr3audiosink_mvcommand (Dxr3AudioSink *sink, */
/* int command); */
-static GstElementStateReturn dxr3audiosink_change_state (GstElement *element);
+static GstElementStateReturn dxr3audiosink_change_state (GstElement * element);
-static void dxr3audiosink_flushed (Dxr3AudioSink *sink);
+static void dxr3audiosink_flushed (Dxr3AudioSink * sink);
static GstElementClass *parent_class = NULL;
static guint dxr3audiosink_signals[LAST_SIGNAL] = { 0 };
extern GType
-dxr3audiosink_get_type (void)
+dxr3audiosink_get_type (void)
{
static GType dxr3audiosink_type = 0;
if (!dxr3audiosink_type) {
static const GTypeInfo dxr3audiosink_info = {
- sizeof(Dxr3AudioSinkClass),
+ sizeof (Dxr3AudioSinkClass),
(GBaseInitFunc) dxr3audiosink_base_init,
NULL,
(GClassInitFunc) dxr3audiosink_class_init,
(GInstanceInitFunc) dxr3audiosink_init,
};
dxr3audiosink_type = g_type_register_static (GST_TYPE_ELEMENT,
- "Dxr3AudioSink",
- &dxr3audiosink_info, 0);
+ "Dxr3AudioSink", &dxr3audiosink_info, 0);
}
return dxr3audiosink_type;
static void
-dxr3audiosink_base_init (Dxr3AudioSinkClass *klass)
+dxr3audiosink_base_init (Dxr3AudioSinkClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&dxr3audiosink_pcm_sink_factory));
+ gst_static_pad_template_get (&dxr3audiosink_pcm_sink_factory));
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&dxr3audiosink_ac3_sink_factory));
- gst_element_class_set_details (element_class,
- &dxr3audiosink_details);
+ gst_static_pad_template_get (&dxr3audiosink_ac3_sink_factory));
+ gst_element_class_set_details (element_class, &dxr3audiosink_details);
}
static void
-dxr3audiosink_class_init (Dxr3AudioSinkClass *klass)
+dxr3audiosink_class_init (Dxr3AudioSinkClass * 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);
dxr3audiosink_signals[SIGNAL_FLUSHED] =
- g_signal_new ("flushed", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (Dxr3AudioSinkClass, flushed),
- NULL, NULL,
- dxr3_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ g_signal_new ("flushed", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (Dxr3AudioSinkClass, flushed),
+ NULL, NULL, dxr3_marshal_VOID__VOID, G_TYPE_NONE, 0);
klass->flushed = dxr3audiosink_flushed;
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DIGITAL_PCM,
- g_param_spec_boolean ("digital-pcm", "Digital PCM",
- "Use the digital output for PCM sound",
- FALSE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("digital-pcm", "Digital PCM",
+ "Use the digital output for PCM sound", FALSE, G_PARAM_READWRITE));
gobject_class->set_property = dxr3audiosink_set_property;
gobject_class->get_property = dxr3audiosink_get_property;
}
-static void
-dxr3audiosink_init (Dxr3AudioSink *sink)
+static void
+dxr3audiosink_init (Dxr3AudioSink * sink)
{
GstPadTemplate *temp;
gst_pad_set_chain_function (sink->ac3_sinkpad, dxr3audiosink_chain_ac3);
gst_element_add_pad (GST_ELEMENT (sink), sink->ac3_sinkpad);
- GST_FLAG_SET (GST_ELEMENT(sink), GST_ELEMENT_EVENT_AWARE);
+ GST_FLAG_SET (GST_ELEMENT (sink), GST_ELEMENT_EVENT_AWARE);
sink->card_number = 0;
/* Initially don't use digital output. */
sink->digital_pcm = FALSE;
- /* Initially there's no padder.*/
+ /* Initially there's no padder. */
sink->padder = NULL;
sink->mode = DXR3AUDIOSINK_MODE_NONE;
static void
-dxr3audiosink_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
+dxr3audiosink_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
Dxr3AudioSink *sink;
sink = DXR3AUDIOSINK (object);
switch (prop_id) {
- case ARG_DIGITAL_PCM:
- sink->digital_pcm = g_value_get_boolean (value);
- /* Refresh the setup of the device. */
- if (sink->mode == DXR3AUDIOSINK_MODE_PCM) {
- dxr3audiosink_set_mode_pcm (sink);
- }
- g_object_notify (G_OBJECT (sink), "digital-pcm");
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ case ARG_DIGITAL_PCM:
+ sink->digital_pcm = g_value_get_boolean (value);
+ /* Refresh the setup of the device. */
+ if (sink->mode == DXR3AUDIOSINK_MODE_PCM) {
+ dxr3audiosink_set_mode_pcm (sink);
+ }
+ g_object_notify (G_OBJECT (sink), "digital-pcm");
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
-static void
-dxr3audiosink_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
+static void
+dxr3audiosink_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
Dxr3AudioSink *sink;
-
+
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_DXR3AUDIOSINK (object));
-
+
sink = DXR3AUDIOSINK (object);
-
+
switch (prop_id) {
- case ARG_DIGITAL_PCM:
- g_value_set_boolean (value, sink->digital_pcm);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ case ARG_DIGITAL_PCM:
+ g_value_set_boolean (value, sink->digital_pcm);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
static gboolean
-dxr3audiosink_open (Dxr3AudioSink *sink)
+dxr3audiosink_open (Dxr3AudioSink * sink)
{
- g_return_val_if_fail (!GST_FLAG_IS_SET (sink,
- DXR3AUDIOSINK_OPEN), FALSE);
+ g_return_val_if_fail (!GST_FLAG_IS_SET (sink, DXR3AUDIOSINK_OPEN), FALSE);
/* Compute the name of the audio device file. */
sink->audio_filename = g_strdup_printf ("/dev/em8300_ma-%d",
- sink->card_number );
+ sink->card_number);
sink->audio_fd = open (sink->audio_filename, O_WRONLY);
if (sink->audio_fd < 0) {
GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE,
- (_("Could not open audio device \"%s\" for writing."), sink->audio_filename),
- GST_ERROR_SYSTEM);
+ (_("Could not open audio device \"%s\" for writing."),
+ sink->audio_filename), GST_ERROR_SYSTEM);
return FALSE;
}
/* Open the control device. */
sink->control_filename = g_strdup_printf ("/dev/em8300-%d",
- sink->card_number );
+ sink->card_number);
sink->control_fd = open (sink->control_filename, O_WRONLY);
if (sink->control_fd < 0) {
GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE,
- (_("Could not open control device \"%s\" for writing."), sink->control_filename),
- GST_ERROR_SYSTEM);
+ (_("Could not open control device \"%s\" for writing."),
+ sink->control_filename), GST_ERROR_SYSTEM);
return FALSE;
}
* Set the operation mode of the element to PCM.
*/
static gboolean
-dxr3audiosink_set_mode_pcm (Dxr3AudioSink *sink)
+dxr3audiosink_set_mode_pcm (Dxr3AudioSink * sink)
{
int tmp, oss_mode, audiomode;
/* Set the audio device mode. */
oss_mode = (G_BYTE_ORDER == G_BIG_ENDIAN ? AFMT_S16_BE : AFMT_S16_LE);
tmp = oss_mode;
- if (ioctl (sink->audio_fd, SNDCTL_DSP_SETFMT, &tmp) < 0 ||
- tmp != oss_mode) {
+ if (ioctl (sink->audio_fd, SNDCTL_DSP_SETFMT, &tmp) < 0 || tmp != oss_mode) {
GST_ELEMENT_ERROR (sink, RESOURCE, SETTINGS,
- (_("Could not configure audio device \"%s\"."), sink->audio_filename),
- GST_ERROR_SYSTEM);
+ (_("Could not configure audio device \"%s\"."), sink->audio_filename),
+ GST_ERROR_SYSTEM);
return FALSE;
}
/* Set the card's general audio output mode. */
audiomode = sink->digital_pcm ?
- EM8300_AUDIOMODE_DIGITALPCM : EM8300_AUDIOMODE_ANALOG;
+ EM8300_AUDIOMODE_DIGITALPCM : EM8300_AUDIOMODE_ANALOG;
ioctl (sink->control_fd, EM8300_IOCTL_SET_AUDIOMODE, &audiomode);
/* Set the sampling rate. */
tmp = sink->rate;
if (ioctl (sink->audio_fd, SNDCTL_DSP_SPEED, &tmp) < 0) {
GST_ELEMENT_ERROR (sink, RESOURCE, SETTINGS,
- (_("Could not set audio device \"%s\" to %d Hz."), sink->audio_filename, sink->rate),
- GST_ERROR_SYSTEM);
+ (_("Could not set audio device \"%s\" to %d Hz."), sink->audio_filename,
+ sink->rate), GST_ERROR_SYSTEM);
return FALSE;
}
/* Get rid of the padder, if any. */
if (sink->padder != NULL) {
- g_free(sink->padder);
+ g_free (sink->padder);
sink->padder = NULL;
}
* Set the operation mode of the element to AC3.
*/
static gboolean
-dxr3audiosink_set_mode_ac3 (Dxr3AudioSink *sink)
+dxr3audiosink_set_mode_ac3 (Dxr3AudioSink * sink)
{
- int tmp, audiomode;
+ int tmp, audiomode;
if (sink->audio_fd == -1 || sink->control_fd == -1) {
return FALSE;
if (ioctl (sink->audio_fd, SNDCTL_DSP_SPEED, &tmp) < 0 ||
tmp != AC3_BYTE_RATE) {
GST_ELEMENT_ERROR (sink, RESOURCE, SETTINGS,
- (_("Could not set audio device \"%s\" to %d Hz."), sink->audio_filename, AC3_BYTE_RATE),
- GST_ERROR_SYSTEM);
+ (_("Could not set audio device \"%s\" to %d Hz."), sink->audio_filename,
+ AC3_BYTE_RATE), GST_ERROR_SYSTEM);
return FALSE;
}
/* Create a padder if necessary, */
if (sink->padder == NULL) {
- sink->padder = g_malloc (sizeof(ac3_padder));
- ac3p_init(sink->padder);
+ sink->padder = g_malloc (sizeof (ac3_padder));
+ ac3p_init (sink->padder);
}
sink->mode = DXR3AUDIOSINK_MODE_AC3;
static void
-dxr3audiosink_close (Dxr3AudioSink *sink)
+dxr3audiosink_close (Dxr3AudioSink * sink)
{
g_return_if_fail (GST_FLAG_IS_SET (sink, DXR3AUDIOSINK_OPEN));
if (close (sink->audio_fd) != 0) {
GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE,
- (_("Could not close audio device \"%s\"."), sink->audio_filename),
- GST_ERROR_SYSTEM);
+ (_("Could not close audio device \"%s\"."), sink->audio_filename),
+ GST_ERROR_SYSTEM);
return;
}
if (close (sink->control_fd) != 0) {
GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE,
- (_("Could not close control device \"%s\"."), sink->audio_filename),
- GST_ERROR_SYSTEM);
+ (_("Could not close control device \"%s\"."), sink->audio_filename),
+ GST_ERROR_SYSTEM);
return;
}
/* Get rid of the padder, if any. */
if (sink->padder != NULL) {
- g_free(sink->padder);
+ g_free (sink->padder);
sink->padder = NULL;
}
}
static void
-dxr3audiosink_set_clock (GstElement *element, GstClock *clock)
+dxr3audiosink_set_clock (GstElement * element, GstClock * clock)
{
Dxr3AudioSink *src = DXR3AUDIOSINK (element);
static GstPadLinkReturn
-dxr3audiosink_pcm_sinklink (GstPad *pad, const GstCaps *caps)
+dxr3audiosink_pcm_sinklink (GstPad * pad, const GstCaps * caps)
{
Dxr3AudioSink *sink = DXR3AUDIOSINK (gst_pad_get_parent (pad));
GstStructure *structure = gst_caps_get_structure (caps, 0);
static void
-dxr3audiosink_set_scr (Dxr3AudioSink *sink, guint32 scr)
+dxr3audiosink_set_scr (Dxr3AudioSink * sink, guint32 scr)
{
guint32 zero = 0;
static gboolean
-dxr3audiosink_handle_event (GstPad *pad, GstEvent *event)
+dxr3audiosink_handle_event (GstPad * pad, GstEvent * event)
{
GstEventType type;
Dxr3AudioSink *sink = DXR3AUDIOSINK (gst_pad_get_parent (pad));
type = event ? GST_EVENT_TYPE (event) : GST_EVENT_UNKNOWN;
switch (type) {
- case GST_EVENT_FLUSH:
- if (sink->control_fd >= 0) {
- unsigned audiomode;
-
- if (sink->mode == DXR3AUDIOSINK_MODE_AC3) {
- audiomode = EM8300_AUDIOMODE_DIGITALPCM;
- ioctl (sink->control_fd, EM8300_IOCTL_SET_AUDIOMODE, &audiomode);
- audiomode = EM8300_AUDIOMODE_DIGITALAC3;
- ioctl (sink->control_fd, EM8300_IOCTL_SET_AUDIOMODE, &audiomode);
+ case GST_EVENT_FLUSH:
+ if (sink->control_fd >= 0) {
+ unsigned audiomode;
+
+ if (sink->mode == DXR3AUDIOSINK_MODE_AC3) {
+ audiomode = EM8300_AUDIOMODE_DIGITALPCM;
+ ioctl (sink->control_fd, EM8300_IOCTL_SET_AUDIOMODE, &audiomode);
+ audiomode = EM8300_AUDIOMODE_DIGITALAC3;
+ ioctl (sink->control_fd, EM8300_IOCTL_SET_AUDIOMODE, &audiomode);
+ }
+
+ /* Report the flush operation. */
+ g_signal_emit (G_OBJECT (sink),
+ dxr3audiosink_signals[SIGNAL_FLUSHED], 0);
}
-
- /* Report the flush operation. */
- g_signal_emit (G_OBJECT (sink),
- dxr3audiosink_signals[SIGNAL_FLUSHED], 0);
- }
- break;
- default:
- gst_pad_event_default (pad, event);
- break;
+ break;
+ default:
+ gst_pad_event_default (pad, event);
+ break;
}
return TRUE;
}
-static void
-dxr3audiosink_chain_pcm (GstPad *pad, GstData *_data)
+static void
+dxr3audiosink_chain_pcm (GstPad * pad, GstData * _data)
{
Dxr3AudioSink *sink;
gint bytes_written = 0;
in = MPEGTIME_TO_DXRTIME (sink->scr - (odelay * 90) / 192);
diff = in > out ? in - out : out - in;
if (diff > 1800) {
- dxr3audiosink_set_scr (sink, in);
+ dxr3audiosink_set_scr (sink, in);
}
}
/* Update our SCR value. */
sink->scr += (unsigned) (GST_BUFFER_SIZE (buf) *
- (90000.0 / ((float)sink->rate * 4)));
+ (90000.0 / ((float) sink->rate * 4)));
/* Write the buffer to the sound device. */
bytes_written = write (sink->audio_fd, GST_BUFFER_DATA (buf),
- GST_BUFFER_SIZE (buf));
+ GST_BUFFER_SIZE (buf));
if (bytes_written < GST_BUFFER_SIZE (buf)) {
fprintf (stderr, "dxr3audiosink: Warning: %d bytes should be "
- "written, only %d bytes written\n",
- GST_BUFFER_SIZE (buf), bytes_written);
+ "written, only %d bytes written\n",
+ GST_BUFFER_SIZE (buf), bytes_written);
}
}
}
-static void
-dxr3audiosink_chain_ac3 (GstPad *pad, GstData *_data)
+static void
+dxr3audiosink_chain_ac3 (GstPad * pad, GstData * _data)
{
Dxr3AudioSink *sink;
gint bytes_written = 0;
dxr3audiosink_set_mode_ac3 (sink);
}
- if (GST_FLAG_IS_SET (sink, DXR3AUDIOSINK_OPEN))
- {
+ if (GST_FLAG_IS_SET (sink, DXR3AUDIOSINK_OPEN)) {
int event;
if (GST_BUFFER_TIMESTAMP (buf) != GST_CLOCK_TIME_NONE) {
}
/* Push the new data into the padder. */
- ac3p_push_data(sink->padder, GST_BUFFER_DATA (buf),
- GST_BUFFER_SIZE (buf));
+ ac3p_push_data (sink->padder, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
/* Parse the data. */
event = ac3p_parse (sink->padder);
while (event != AC3P_EVENT_PUSH) {
switch (event) {
- case AC3P_EVENT_FRAME:
- /* We have a new frame: */
+ case AC3P_EVENT_FRAME:
+ /* We have a new frame: */
- /* Update the system reference clock (SCR) in the card. */
- {
- unsigned in, out, odelay;
- unsigned diff;
+ /* Update the system reference clock (SCR) in the card. */
+ {
+ unsigned in, out, odelay;
+ unsigned diff;
- ioctl (sink->control_fd, EM8300_IOCTL_SCR_GET, &out);
+ ioctl (sink->control_fd, EM8300_IOCTL_SCR_GET, &out);
- ioctl (sink->audio_fd, SNDCTL_DSP_GETODELAY, &odelay);
- /* 192000 bytes/sec */
+ ioctl (sink->audio_fd, SNDCTL_DSP_GETODELAY, &odelay);
+ /* 192000 bytes/sec */
- in = MPEGTIME_TO_DXRTIME (sink->scr - (odelay * 90) / 192);
- diff = in > out ? in - out : out - in;
- if (diff > 1800) {
- dxr3audiosink_set_scr (sink, in);
- }
- }
+ in = MPEGTIME_TO_DXRTIME (sink->scr - (odelay * 90) / 192);
+ diff = in > out ? in - out : out - in;
+ if (diff > 1800) {
+ dxr3audiosink_set_scr (sink, in);
+ }
+ }
- /* Update our SCR value. */
- sink->scr += TIME_FOR_BYTES (ac3p_frame_size (sink->padder));
+ /* Update our SCR value. */
+ sink->scr += TIME_FOR_BYTES (ac3p_frame_size (sink->padder));
- /* Write the frame to the sound device. */
- bytes_written = write (sink->audio_fd, ac3p_frame (sink->padder),
- AC3P_IEC_FRAME_SIZE);
+ /* Write the frame to the sound device. */
+ bytes_written = write (sink->audio_fd, ac3p_frame (sink->padder),
+ AC3P_IEC_FRAME_SIZE);
- if (bytes_written < AC3P_IEC_FRAME_SIZE)
- {
- fprintf (stderr, "dxr3audiosink: Warning: %d bytes should be "
- "written, only %d bytes written\n",
- AC3P_IEC_FRAME_SIZE, bytes_written);
- }
+ if (bytes_written < AC3P_IEC_FRAME_SIZE) {
+ fprintf (stderr, "dxr3audiosink: Warning: %d bytes should be "
+ "written, only %d bytes written\n",
+ AC3P_IEC_FRAME_SIZE, bytes_written);
+ }
- break;
+ break;
}
event = ac3p_parse (sink->padder);
}
}
- gst_buffer_unref(buf);
+ gst_buffer_unref (buf);
}
#if 0
* Make the sink wait the specified amount of time.
*/
static void
-dxr3audiosink_wait (Dxr3AudioSink *sink, GstClockTime time)
+dxr3audiosink_wait (Dxr3AudioSink * sink, GstClockTime time)
{
GstClockID id;
GstClockTimeDiff jitter;
static int
-dxr3audiosink_mvcommand (Dxr3AudioSink *sink, int command)
+dxr3audiosink_mvcommand (Dxr3AudioSink * sink, int command)
{
em8300_register_t regs;
-
+
regs.microcode_register = 1;
regs.reg = 0;
regs.val = command;
-
+
return ioctl (sink->control_fd, EM8300_IOCTL_WRITEREG, ®s);
}
#endif
static GstElementStateReturn
-dxr3audiosink_change_state (GstElement *element)
+dxr3audiosink_change_state (GstElement * element)
{
g_return_val_if_fail (GST_IS_DXR3AUDIOSINK (element), GST_STATE_FAILURE);
if (GST_FLAG_IS_SET (element, DXR3AUDIOSINK_OPEN)) {
dxr3audiosink_close (DXR3AUDIOSINK (element));
}
- }
- else {
+ } else {
if (!GST_FLAG_IS_SET (element, DXR3AUDIOSINK_OPEN)) {
if (!dxr3audiosink_open (DXR3AUDIOSINK (element))) {
- return GST_STATE_FAILURE;
+ return GST_STATE_FAILURE;
}
}
}
* queues due to a received flush event
*/
static void
-dxr3audiosink_flushed (Dxr3AudioSink *sink)
+dxr3audiosink_flushed (Dxr3AudioSink * sink)
{
/* Do nothing. */
}
#include "ac3_padder.h"
G_BEGIN_DECLS
-
-
#define GST_TYPE_DXR3AUDIOSINK \
(dxr3audiosink_get_type())
#define DXR3AUDIOSINK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DXR3AUDIOSINK))
#define GST_IS_DXR3AUDIOSINK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DXR3AUDIOSINK))
-
-
typedef struct _Dxr3AudioSink Dxr3AudioSink;
typedef struct _Dxr3AudioSinkClass Dxr3AudioSinkClass;
-typedef enum {
+typedef enum
+{
DXR3AUDIOSINK_OPEN = GST_ELEMENT_FLAG_LAST,
- DXR3AUDIOSINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
+ DXR3AUDIOSINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
} Dxr3AudioSinkFlags;
/* PCM or AC3? */
-typedef enum {
- DXR3AUDIOSINK_MODE_NONE, /* No mode set. */
- DXR3AUDIOSINK_MODE_AC3, /* AC3 out. */
- DXR3AUDIOSINK_MODE_PCM, /* PCM out. */
+typedef enum
+{
+ DXR3AUDIOSINK_MODE_NONE, /* No mode set. */
+ DXR3AUDIOSINK_MODE_AC3, /* AC3 out. */
+ DXR3AUDIOSINK_MODE_PCM, /* PCM out. */
} Dxr3AudioSinkMode;
/* Information for a delayed SCR set operation. */
-typedef struct {
+typedef struct
+{
struct _Dxr3AudioSink *sink;
guint32 scr;
} Dxr3AudioSinkDelayedSCR;
-struct _Dxr3AudioSink {
+struct _Dxr3AudioSink
+{
GstElement element;
- GstPad *pcm_sinkpad; /* The AC3 audio sink pad. */
- GstPad *ac3_sinkpad; /* The PCM audio sink pad. */
+ GstPad *pcm_sinkpad; /* The AC3 audio sink pad. */
+ GstPad *ac3_sinkpad; /* The PCM audio sink pad. */
- int card_number; /* The number of the card to open. */
+ int card_number; /* The number of the card to open. */
- gchar *audio_filename; /* File name for the audio device. */
- int audio_fd; /* File descriptor for the audio device. */
+ gchar *audio_filename; /* File name for the audio device. */
+ int audio_fd; /* File descriptor for the audio device. */
- gchar *control_filename; /* File name for the control device. */
- int control_fd; /* File descriptor for the control
- device. */
+ gchar *control_filename; /* File name for the control device. */
+ int control_fd; /* File descriptor for the control
+ device. */
- guint64 scr; /* The current System Reference Clock value
- for the audio stream. */
+ guint64 scr; /* The current System Reference Clock value
+ for the audio stream. */
- gboolean digital_pcm; /* Should PCM use the digital or the
- analog output? */
+ gboolean digital_pcm; /* Should PCM use the digital or the
+ analog output? */
- Dxr3AudioSinkMode mode; /* The current sound output mode. */
+ Dxr3AudioSinkMode mode; /* The current sound output mode. */
- gint rate; /* The sampling rate for PCM sound. */
+ gint rate; /* The sampling rate for PCM sound. */
- ac3_padder *padder; /* AC3 to SPDIF padder object. */
+ ac3_padder *padder; /* AC3 to SPDIF padder object. */
- GstClock *clock; /* The clock for this element. */
+ GstClock *clock; /* The clock for this element. */
};
-struct _Dxr3AudioSinkClass {
+struct _Dxr3AudioSinkClass
+{
GstElementClass parent_class;
/* signals */
- void (*flushed) (Dxr3AudioSink *sink);
+ void (*flushed) (Dxr3AudioSink * sink);
};
-extern GType dxr3audiosink_get_type (void);
-extern gboolean dxr3audiosink_factory_init (GstPlugin *plugin);
+extern GType dxr3audiosink_get_type (void);
+extern gboolean dxr3audiosink_factory_init (GstPlugin * plugin);
G_END_DECLS
-
#endif /* __DXR3AUDIOINK_H__ */
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
if (!gst_element_register (plugin, "dxr3videosink",
- GST_RANK_NONE, GST_TYPE_DXR3VIDEOSINK) ||
+ GST_RANK_NONE, GST_TYPE_DXR3VIDEOSINK) ||
!gst_element_register (plugin, "dxr3audiosink",
- GST_RANK_NONE, GST_TYPE_DXR3AUDIOSINK) ||
+ GST_RANK_NONE, GST_TYPE_DXR3AUDIOSINK) ||
!gst_element_register (plugin, "dxr3spusink",
- GST_RANK_NONE, GST_TYPE_DXR3SPUSINK))
+ GST_RANK_NONE, GST_TYPE_DXR3SPUSINK))
return FALSE;
#ifdef ENABLE_NLS
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "dxr3",
- "dxr3 mpeg video board elements",
- plugin_init,
- VERSION,
- "GPL",
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "dxr3",
+ "dxr3 mpeg video board elements",
+ plugin_init, VERSION, "GPL", GST_PACKAGE, GST_ORIGIN)
/* Dxr3SpuSink signals and args */
-enum {
+enum
+{
SET_CLUT_SIGNAL,
HIGHLIGHT_ON_SIGNAL,
HIGHLIGHT_OFF_SIGNAL,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
};
static GstStaticPadTemplate dxr3spusink_sink_factory =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS_ANY
-);
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS_ANY);
-static void dxr3spusink_class_init (Dxr3SpuSinkClass *klass);
-static void dxr3spusink_base_init (Dxr3SpuSinkClass *klass);
-static void dxr3spusink_init (Dxr3SpuSink *dxr3spusink);
+static void dxr3spusink_class_init (Dxr3SpuSinkClass * klass);
+static void dxr3spusink_base_init (Dxr3SpuSinkClass * klass);
+static void dxr3spusink_init (Dxr3SpuSink * dxr3spusink);
-static void dxr3spusink_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void dxr3spusink_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
+static void dxr3spusink_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+static void dxr3spusink_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
-static gboolean dxr3spusink_open (Dxr3SpuSink *sink);
-static void dxr3spusink_close (Dxr3SpuSink *sink);
-static void dxr3spusink_set_clock (GstElement *element,
- GstClock *clock);
+static gboolean dxr3spusink_open (Dxr3SpuSink * sink);
+static void dxr3spusink_close (Dxr3SpuSink * sink);
+static void dxr3spusink_set_clock (GstElement * element, GstClock * clock);
-static gboolean dxr3spusink_handle_event (GstPad *pad, GstEvent *event);
-static void dxr3spusink_chain (GstPad *pad,GstData *_data);
+static gboolean dxr3spusink_handle_event (GstPad * pad, GstEvent * event);
+static void dxr3spusink_chain (GstPad * pad, GstData * _data);
-static GstElementStateReturn dxr3spusink_change_state (GstElement *element);
+static GstElementStateReturn dxr3spusink_change_state (GstElement * element);
/* static void dxr3spusink_wait (Dxr3SpuSink *sink, */
/* GstClockTime time); */
-static void dxr3spusink_set_clut (Dxr3SpuSink *sink,
- const guint32 *clut);
-static void dxr3spusink_highlight_on (Dxr3SpuSink *sink,
- unsigned palette,
- unsigned sx, unsigned sy,
- unsigned ex, unsigned ey,
- unsigned pts);
-static void dxr3spusink_highlight_off (Dxr3SpuSink *sink);
+static void dxr3spusink_set_clut (Dxr3SpuSink * sink, const guint32 * clut);
+static void dxr3spusink_highlight_on (Dxr3SpuSink * sink,
+ unsigned palette,
+ unsigned sx, unsigned sy, unsigned ex, unsigned ey, unsigned pts);
+static void dxr3spusink_highlight_off (Dxr3SpuSink * sink);
-static void dxr3spusink_flushed (Dxr3SpuSink *sink);
+static void dxr3spusink_flushed (Dxr3SpuSink * sink);
static GstElementClass *parent_class = NULL;
GType
-dxr3spusink_get_type (void)
+dxr3spusink_get_type (void)
{
static GType dxr3spusink_type = 0;
if (!dxr3spusink_type) {
static const GTypeInfo dxr3spusink_info = {
sizeof (Dxr3SpuSinkClass),
- (GBaseInitFunc)dxr3spusink_base_init,
+ (GBaseInitFunc) dxr3spusink_base_init,
NULL,
- (GClassInitFunc)dxr3spusink_class_init,
+ (GClassInitFunc) dxr3spusink_class_init,
NULL,
NULL,
sizeof (Dxr3SpuSink),
0,
- (GInstanceInitFunc)dxr3spusink_init,
+ (GInstanceInitFunc) dxr3spusink_init,
};
dxr3spusink_type = g_type_register_static (GST_TYPE_ELEMENT,
- "Dxr3SpuSink",
- &dxr3spusink_info, 0);
+ "Dxr3SpuSink", &dxr3spusink_info, 0);
}
return dxr3spusink_type;
}
static void
-dxr3spusink_base_init (Dxr3SpuSinkClass *klass)
+dxr3spusink_base_init (Dxr3SpuSinkClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&dxr3spusink_sink_factory));
- gst_element_class_set_details (element_class,
- &dxr3spusink_details);
+ gst_static_pad_template_get (&dxr3spusink_sink_factory));
+ gst_element_class_set_details (element_class, &dxr3spusink_details);
}
static void
-dxr3spusink_class_init (Dxr3SpuSinkClass *klass)
+dxr3spusink_class_init (Dxr3SpuSinkClass * 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);
dxr3spusink_signals[SET_CLUT_SIGNAL] =
- g_signal_new ("set-clut",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (Dxr3SpuSinkClass, set_clut),
- NULL, NULL,
- dxr3_marshal_VOID__POINTER,
- G_TYPE_NONE, 1,
- G_TYPE_POINTER);
+ g_signal_new ("set-clut",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (Dxr3SpuSinkClass, set_clut),
+ NULL, NULL, dxr3_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER);
dxr3spusink_signals[HIGHLIGHT_ON_SIGNAL] =
- g_signal_new ("highlight-on",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (Dxr3SpuSinkClass, highlight_on),
- NULL, NULL,
- dxr3_marshal_VOID__UINT_UINT_UINT_UINT_UINT_UINT,
- G_TYPE_NONE, 6,
- G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT,
- G_TYPE_UINT, G_TYPE_UINT);
+ g_signal_new ("highlight-on",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (Dxr3SpuSinkClass, highlight_on),
+ NULL, NULL,
+ dxr3_marshal_VOID__UINT_UINT_UINT_UINT_UINT_UINT,
+ G_TYPE_NONE, 6,
+ G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT,
+ G_TYPE_UINT, G_TYPE_UINT);
dxr3spusink_signals[HIGHLIGHT_OFF_SIGNAL] =
- g_signal_new ("highlight-off",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (Dxr3SpuSinkClass, highlight_off),
- NULL, NULL,
- dxr3_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ g_signal_new ("highlight-off",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (Dxr3SpuSinkClass, highlight_off),
+ NULL, NULL, dxr3_marshal_VOID__VOID, G_TYPE_NONE, 0);
dxr3spusink_signals[SIGNAL_FLUSHED] =
- g_signal_new ("flushed", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (Dxr3SpuSinkClass, flushed),
- NULL, NULL,
- dxr3_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ g_signal_new ("flushed", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (Dxr3SpuSinkClass, flushed),
+ NULL, NULL, dxr3_marshal_VOID__VOID, G_TYPE_NONE, 0);
klass->set_clut = dxr3spusink_set_clut;
klass->highlight_on = dxr3spusink_highlight_on;
}
-static void
-dxr3spusink_init (Dxr3SpuSink *sink)
+static void
+dxr3spusink_init (Dxr3SpuSink * sink)
{
GstPad *pad;
- pad = gst_pad_new_from_template (
- gst_static_pad_template_get (&dxr3spusink_sink_factory), "sink");
+ pad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&dxr3spusink_sink_factory), "sink");
gst_element_add_pad (GST_ELEMENT (sink), pad);
gst_pad_set_chain_function (pad, dxr3spusink_chain);
static void
-dxr3spusink_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
+dxr3spusink_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
Dxr3SpuSink *sink;
}
-static void
-dxr3spusink_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
+static void
+dxr3spusink_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
Dxr3SpuSink *sink;
-
+
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_DXR3SPUSINK (object));
-
+
sink = DXR3SPUSINK (object);
-
+
switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
static gboolean
-dxr3spusink_open (Dxr3SpuSink *sink)
+dxr3spusink_open (Dxr3SpuSink * sink)
{
- g_return_val_if_fail (!GST_FLAG_IS_SET (sink,
- DXR3SPUSINK_OPEN), FALSE);
+ g_return_val_if_fail (!GST_FLAG_IS_SET (sink, DXR3SPUSINK_OPEN), FALSE);
/* Compute the name of the spu device file. */
- sink->spu_filename = g_strdup_printf ("/dev/em8300_sp-%d",
- sink->card_number );
+ sink->spu_filename = g_strdup_printf ("/dev/em8300_sp-%d", sink->card_number);
sink->spu_fd = open (sink->spu_filename, O_WRONLY);
if (sink->spu_fd < 0) {
GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE,
- (_("Could not open spu device \"%s\" for writing."), sink->spu_filename), GST_ERROR_SYSTEM);
+ (_("Could not open spu device \"%s\" for writing."),
+ sink->spu_filename), GST_ERROR_SYSTEM);
return FALSE;
}
/* Open the control device. */
sink->control_filename = g_strdup_printf ("/dev/em8300-%d",
- sink->card_number );
+ sink->card_number);
sink->control_fd = open (sink->control_filename, O_WRONLY);
if (sink->control_fd < 0) {
GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE,
- (_("Could not open control device \"%s\" for writing."), sink->control_filename),
- GST_ERROR_SYSTEM);
+ (_("Could not open control device \"%s\" for writing."),
+ sink->control_filename), GST_ERROR_SYSTEM);
return FALSE;
}
static void
-dxr3spusink_close (Dxr3SpuSink *sink)
+dxr3spusink_close (Dxr3SpuSink * sink)
{
g_return_if_fail (GST_FLAG_IS_SET (sink, DXR3SPUSINK_OPEN));
if (close (sink->spu_fd) != 0) {
GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE,
- (_("Could not close spu device \"%s\"."), sink->spu_filename),
- GST_ERROR_SYSTEM);
+ (_("Could not close spu device \"%s\"."), sink->spu_filename),
+ GST_ERROR_SYSTEM);
return;
}
- if (close (sink->control_fd) != 0)
- {
+ if (close (sink->control_fd) != 0) {
GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE,
- (_("Could not close control device \"%s\"."), sink->control_filename),
- GST_ERROR_SYSTEM);
+ (_("Could not close control device \"%s\"."), sink->control_filename),
+ GST_ERROR_SYSTEM);
return;
}
static void
-dxr3spusink_set_clock (GstElement *element, GstClock *clock)
+dxr3spusink_set_clock (GstElement * element, GstClock * clock)
{
Dxr3SpuSink *src = DXR3SPUSINK (element);
-
+
src->clock = clock;
}
static gboolean
-dxr3spusink_handle_event (GstPad *pad, GstEvent *event)
+dxr3spusink_handle_event (GstPad * pad, GstEvent * event)
{
GstEventType type;
Dxr3SpuSink *sink;
type = event ? GST_EVENT_TYPE (event) : GST_EVENT_UNKNOWN;
switch (type) {
- case GST_EVENT_FLUSH:
- if (sink->control_fd >= 0) {
- int subdevice;
- subdevice = EM8300_SUBDEVICE_SUBPICTURE;
- ioctl (sink->control_fd, EM8300_IOCTL_FLUSH, &subdevice);
-
- /* FIXME: There should be a nicer way to do this, but I tried
- everything and nothing else seems to really reset the video
- fifo. */
+ case GST_EVENT_FLUSH:
+ if (sink->control_fd >= 0) {
+ int subdevice;
+
+ subdevice = EM8300_SUBDEVICE_SUBPICTURE;
+ ioctl (sink->control_fd, EM8300_IOCTL_FLUSH, &subdevice);
+
+ /* FIXME: There should be a nicer way to do this, but I tried
+ everything and nothing else seems to really reset the video
+ fifo. */
/* dxr3spusink_close (sink); */
/* dxr3spusink_open (sink); */
- /* Report the flush operation. */
- g_signal_emit (G_OBJECT (sink),
- dxr3spusink_signals[SIGNAL_FLUSHED], 0);
- }
- break;
- default:
- gst_pad_event_default (pad, event);
- break;
+ /* Report the flush operation. */
+ g_signal_emit (G_OBJECT (sink), dxr3spusink_signals[SIGNAL_FLUSHED], 0);
+ }
+ break;
+ default:
+ gst_pad_event_default (pad, event);
+ break;
}
return TRUE;
}
-static void
-dxr3spusink_chain (GstPad *pad, GstData *_data)
+static void
+dxr3spusink_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
Dxr3SpuSink *sink;
The card needs the PTS to be written *before* the actual data. */
if (GST_BUFFER_TIMESTAMP (buf) != GST_CLOCK_TIME_NONE) {
guint pts = (guint) GSTTIME_TO_MPEGTIME (GST_BUFFER_TIMESTAMP (buf));
+
ioctl (sink->spu_fd, EM8300_IOCTL_SPU_SETPTS, &pts);
}
bytes_written = write (sink->spu_fd, GST_BUFFER_DATA (buf),
- GST_BUFFER_SIZE (buf));
+ GST_BUFFER_SIZE (buf));
if (bytes_written < GST_BUFFER_SIZE (buf)) {
fprintf (stderr, "dxr3spusink: Warning: %d bytes should be written,"
- " only %d bytes written\n",
- GST_BUFFER_SIZE (buf), bytes_written);
+ " only %d bytes written\n", GST_BUFFER_SIZE (buf), bytes_written);
}
}
static GstElementStateReturn
-dxr3spusink_change_state (GstElement *element)
+dxr3spusink_change_state (GstElement * element)
{
g_return_val_if_fail (GST_IS_DXR3SPUSINK (element), GST_STATE_FAILURE);
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY:
if (!GST_FLAG_IS_SET (element, DXR3SPUSINK_OPEN)) {
- if (!dxr3spusink_open (DXR3SPUSINK (element))) {
- return GST_STATE_FAILURE;
- }
+ if (!dxr3spusink_open (DXR3SPUSINK (element))) {
+ return GST_STATE_FAILURE;
+ }
}
break;
case GST_STATE_READY_TO_PAUSED:
break;
case GST_STATE_READY_TO_NULL:
if (GST_FLAG_IS_SET (element, DXR3SPUSINK_OPEN)) {
- dxr3spusink_close (DXR3SPUSINK (element));
+ dxr3spusink_close (DXR3SPUSINK (element));
}
break;
}
* Make the sink wait the specified amount of time.
*/
static void
-dxr3spusink_wait (Dxr3SpuSink *sink, GstClockTime time)
+dxr3spusink_wait (Dxr3SpuSink * sink, GstClockTime time)
{
GstClockID id;
GstClockTimeDiff jitter;
* Set a new SPU color lookup table (clut) in the dxr3 card.
*/
static void
-dxr3spusink_set_clut (Dxr3SpuSink *sink, const guint32 *clut)
+dxr3spusink_set_clut (Dxr3SpuSink * sink, const guint32 * clut)
{
guint32 clut_fixed[16];
int i;
/* Fix the byte order of the table. */
- for (i=0; i<16; i++) {
+ for (i = 0; i < 16; i++) {
clut_fixed[i] = GUINT32_TO_LE (clut[i]);
}
if (ioctl (sink->spu_fd, EM8300_IOCTL_SPU_SETPALETTE, clut_fixed))
fprintf (stderr, "dxr3spusink: failed to set CLUT (%s)\n",
- strerror (errno));
+ strerror (errno));
}
static void
-dxr3spusink_highlight_on (Dxr3SpuSink *sink, unsigned palette,
- unsigned sx, unsigned sy,
- unsigned ex, unsigned ey,
- unsigned pts)
+dxr3spusink_highlight_on (Dxr3SpuSink * sink, unsigned palette,
+ unsigned sx, unsigned sy, unsigned ex, unsigned ey, unsigned pts)
{
em8300_button_t btn;
if (ioctl (sink->spu_fd, EM8300_IOCTL_SPU_BUTTON, &btn)) {
fprintf (stderr, "dxr3spusink: failed to set spu button (%s)\n",
- strerror (errno));
+ strerror (errno));
}
}
static void
-dxr3spusink_highlight_off (Dxr3SpuSink *sink)
+dxr3spusink_highlight_off (Dxr3SpuSink * sink)
{
if (ioctl (sink->spu_fd, EM8300_IOCTL_SPU_BUTTON, NULL)) {
fprintf (stderr, "dxr3spusink: failed to set spu button (%s)\n",
- strerror (errno));
+ strerror (errno));
}
}
* queues due to a received flush event
*/
static void
-dxr3spusink_flushed (Dxr3SpuSink *sink)
+dxr3spusink_flushed (Dxr3SpuSink * sink)
{
/* Do nothing. */
}
#include <gst/gst.h>
G_BEGIN_DECLS
-
-
#define GST_TYPE_DXR3SPUSINK \
(dxr3spusink_get_type())
#define DXR3SPUSINK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DXR3SPUSINK))
#define GST_IS_DXR3SPUSINK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DXR3SPUSINK))
-
-
typedef struct _Dxr3SpuSink Dxr3SpuSink;
typedef struct _Dxr3SpuSinkClass Dxr3SpuSinkClass;
-typedef enum {
+typedef enum
+{
DXR3SPUSINK_OPEN = GST_ELEMENT_FLAG_LAST,
- DXR3SPUSINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
+ DXR3SPUSINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
} Dxr3SpuSinkFlags;
-struct _Dxr3SpuSink {
+struct _Dxr3SpuSink
+{
GstElement element;
- int card_number; /* The number of the card to open. */
+ int card_number; /* The number of the card to open. */
- gchar *spu_filename; /* File name for the spu device. */
- int spu_fd; /* File descriptor for the spu device. */
+ gchar *spu_filename; /* File name for the spu device. */
+ int spu_fd; /* File descriptor for the spu device. */
gchar *control_filename; /* File name for the control device. */
int control_fd; /* File descriptor for the control
- device. */
+ device. */
GstClock *clock; /* The clock for this element. */
};
-struct _Dxr3SpuSinkClass {
+struct _Dxr3SpuSinkClass
+{
GstElementClass parent_class;
/* Signals */
- void (*set_clut) (Dxr3SpuSink *sink, const guint32 *clut);
- void (*highlight_on) (Dxr3SpuSink *sink, unsigned palette,
- unsigned sx, unsigned sy,
- unsigned ex, unsigned ey,
- unsigned pts);
- void (*highlight_off) (Dxr3SpuSink *sink);
- void (*flushed) (Dxr3SpuSink *sink);
+ void (*set_clut) (Dxr3SpuSink * sink, const guint32 * clut);
+ void (*highlight_on) (Dxr3SpuSink * sink, unsigned palette,
+ unsigned sx, unsigned sy, unsigned ex, unsigned ey, unsigned pts);
+ void (*highlight_off) (Dxr3SpuSink * sink);
+ void (*flushed) (Dxr3SpuSink * sink);
};
-extern GType dxr3spusink_get_type (void);
-extern gboolean dxr3spusink_factory_init (GstPlugin *plugin);
+extern GType dxr3spusink_get_type (void);
+extern gboolean dxr3spusink_factory_init (GstPlugin * plugin);
G_END_DECLS
-
#endif /* __DXR3SPUSINK_H__ */
/* Dxr3VideoSink signals and args */
-enum {
+enum
+{
SIGNAL_FLUSHED,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
};
/* Possible states for the MPEG start code scanner. */
-enum {
- SCAN_STATE_WAITING, /* Waiting for a code. */
- SCAN_STATE_0, /* 0 seen. */
- SCAN_STATE_00, /* 00 seen. */
- SCAN_STATE_001 /* 001 seen. */
+enum
+{
+ SCAN_STATE_WAITING, /* Waiting for a code. */
+ SCAN_STATE_0, /* 0 seen. */
+ SCAN_STATE_00, /* 00 seen. */
+ SCAN_STATE_001 /* 001 seen. */
};
/* Possible states for the MPEG sequence parser. */
-enum {
- PARSE_STATE_WAITING, /* Waiting for the start of a sequence. */
- PARSE_STATE_START, /* Start of sequence seen. */
- PARSE_STATE_PICTURE, /* Picture start seen. */
+enum
+{
+ PARSE_STATE_WAITING, /* Waiting for the start of a sequence. */
+ PARSE_STATE_START, /* Start of sequence seen. */
+ PARSE_STATE_PICTURE, /* Picture start seen. */
};
#define START_CODE_SEQUENCE_END 0xB7
static GstStaticPadTemplate dxr3videosink_sink_factory =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "video/mpeg, "
- "mpegversion = (int) { 1, 2 }, "
- "systemstream = (boolean) FALSE"
- /* width/height/framerate omitted, we don't
- * need a parsed stream */
- )
-);
-
-
-static void dxr3videosink_class_init (Dxr3VideoSinkClass *klass);
-static void dxr3videosink_base_init (Dxr3VideoSinkClass *klass);
-static void dxr3videosink_init (Dxr3VideoSink *dxr3videosink);
-
-static void dxr3videosink_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void dxr3videosink_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-
-static gboolean dxr3videosink_open (Dxr3VideoSink *sink);
-static void dxr3videosink_close (Dxr3VideoSink *sink);
-static void dxr3videosink_set_clock (GstElement *element,
- GstClock *clock);
-
-static void dxr3videosink_reset_parser (Dxr3VideoSink *sink);
-static int dxr3videosink_next_start_code (Dxr3VideoSink *sink);
-static void dxr3videosink_discard_data (Dxr3VideoSink *sink,
- guint cut);
-static void dxr3videosink_write_data (Dxr3VideoSink *sink,
- guint cut);
-static void dxr3videosink_parse_data (Dxr3VideoSink *sink);
-
-static gboolean dxr3videosink_handle_event (GstPad *pad, GstEvent *event);
-static void dxr3videosink_chain (GstPad *pad,GstData *_data);
-
-static GstElementStateReturn dxr3videosink_change_state (GstElement *element);
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/mpeg, "
+ "mpegversion = (int) { 1, 2 }, " "systemstream = (boolean) FALSE"
+ /* width/height/framerate omitted, we don't
+ * need a parsed stream */
+ )
+ );
+
+
+static void dxr3videosink_class_init (Dxr3VideoSinkClass * klass);
+static void dxr3videosink_base_init (Dxr3VideoSinkClass * klass);
+static void dxr3videosink_init (Dxr3VideoSink * dxr3videosink);
+
+static void dxr3videosink_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+static void dxr3videosink_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
+
+static gboolean dxr3videosink_open (Dxr3VideoSink * sink);
+static void dxr3videosink_close (Dxr3VideoSink * sink);
+static void dxr3videosink_set_clock (GstElement * element, GstClock * clock);
+
+static void dxr3videosink_reset_parser (Dxr3VideoSink * sink);
+static int dxr3videosink_next_start_code (Dxr3VideoSink * sink);
+static void dxr3videosink_discard_data (Dxr3VideoSink * sink, guint cut);
+static void dxr3videosink_write_data (Dxr3VideoSink * sink, guint cut);
+static void dxr3videosink_parse_data (Dxr3VideoSink * sink);
+
+static gboolean dxr3videosink_handle_event (GstPad * pad, GstEvent * event);
+static void dxr3videosink_chain (GstPad * pad, GstData * _data);
+
+static GstElementStateReturn dxr3videosink_change_state (GstElement * element);
/* static void dxr3videosink_wait (Dxr3VideoSink *sink, */
/* GstClockTime time); */
-static int dxr3videosink_mvcommand (Dxr3VideoSink *sink,
- int command);
+static int dxr3videosink_mvcommand (Dxr3VideoSink * sink, int command);
-static void dxr3videosink_flushed (Dxr3VideoSink *sink);
+static void dxr3videosink_flushed (Dxr3VideoSink * sink);
static GstElementClass *parent_class = NULL;
static guint dxr3videosink_signals[LAST_SIGNAL] = { 0 };
extern GType
-dxr3videosink_get_type (void)
+dxr3videosink_get_type (void)
{
static GType dxr3videosink_type = 0;
(GInstanceInitFunc) dxr3videosink_init,
};
dxr3videosink_type = g_type_register_static (GST_TYPE_ELEMENT,
- "Dxr3VideoSink",
- &dxr3videosink_info, 0);
+ "Dxr3VideoSink", &dxr3videosink_info, 0);
}
return dxr3videosink_type;
static void
-dxr3videosink_base_init (Dxr3VideoSinkClass *klass)
+dxr3videosink_base_init (Dxr3VideoSinkClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&dxr3videosink_sink_factory));
- gst_element_class_set_details (element_class,
- &dxr3videosink_details);
+ gst_static_pad_template_get (&dxr3videosink_sink_factory));
+ gst_element_class_set_details (element_class, &dxr3videosink_details);
}
static void
-dxr3videosink_class_init (Dxr3VideoSinkClass *klass)
+dxr3videosink_class_init (Dxr3VideoSinkClass * 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);
dxr3videosink_signals[SIGNAL_FLUSHED] =
- g_signal_new ("flushed", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (Dxr3VideoSinkClass, flushed),
- NULL, NULL,
- dxr3_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ g_signal_new ("flushed", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (Dxr3VideoSinkClass, flushed),
+ NULL, NULL, dxr3_marshal_VOID__VOID, G_TYPE_NONE, 0);
klass->flushed = dxr3videosink_flushed;
}
-static void
-dxr3videosink_init (Dxr3VideoSink *sink)
+static void
+dxr3videosink_init (Dxr3VideoSink * sink)
{
GstPad *pad;
- pad = gst_pad_new_from_template (
- gst_static_pad_template_get (&dxr3videosink_sink_factory), "sink");
+ pad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&dxr3videosink_sink_factory), "sink");
gst_element_add_pad (GST_ELEMENT (sink), pad);
gst_pad_set_chain_function (pad, dxr3videosink_chain);
static void
-dxr3videosink_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec)
+dxr3videosink_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
Dxr3VideoSink *sink;
}
-static void
-dxr3videosink_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
+static void
+dxr3videosink_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
Dxr3VideoSink *sink;
-
+
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_DXR3VIDEOSINK (object));
-
+
sink = DXR3VIDEOSINK (object);
-
+
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
static gboolean
-dxr3videosink_open (Dxr3VideoSink *sink)
+dxr3videosink_open (Dxr3VideoSink * sink)
{
- g_return_val_if_fail (!GST_FLAG_IS_SET (sink,
- DXR3VIDEOSINK_OPEN), FALSE);
+ g_return_val_if_fail (!GST_FLAG_IS_SET (sink, DXR3VIDEOSINK_OPEN), FALSE);
/* Compute the name of the video device file. */
sink->video_filename = g_strdup_printf ("/dev/em8300_mv-%d",
- sink->card_number );
+ sink->card_number);
sink->video_fd = open (sink->video_filename, O_WRONLY);
if (sink->video_fd < 0) {
GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE,
- (_("Could not open video device \"%s\" for writing."), sink->video_filename),
- GST_ERROR_SYSTEM);
+ (_("Could not open video device \"%s\" for writing."),
+ sink->video_filename), GST_ERROR_SYSTEM);
return FALSE;
}
/* Open the control device. */
sink->control_filename = g_strdup_printf ("/dev/em8300-%d",
- sink->card_number );
+ sink->card_number);
sink->control_fd = open (sink->control_filename, O_WRONLY);
if (sink->control_fd < 0) {
GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE,
- (_("Could not open control device \"%s\" for writing."), sink->control_filename),
- GST_ERROR_SYSTEM);
+ (_("Could not open control device \"%s\" for writing."),
+ sink->control_filename), GST_ERROR_SYSTEM);
return FALSE;
}
static void
-dxr3videosink_close (Dxr3VideoSink *sink)
+dxr3videosink_close (Dxr3VideoSink * sink)
{
g_return_if_fail (GST_FLAG_IS_SET (sink, DXR3VIDEOSINK_OPEN));
- if (close (sink->video_fd) != 0)
- {
+ if (close (sink->video_fd) != 0) {
GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE,
- (_("Could not close video device \"%s\"."), sink->video_filename),
- GST_ERROR_SYSTEM);
+ (_("Could not close video device \"%s\"."), sink->video_filename),
+ GST_ERROR_SYSTEM);
return;
}
- if (close (sink->control_fd) != 0)
- {
+ if (close (sink->control_fd) != 0) {
GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE,
- (_("Could not close control device \"%s\"."), sink->control_filename),
- GST_ERROR_SYSTEM);
+ (_("Could not close control device \"%s\"."), sink->control_filename),
+ GST_ERROR_SYSTEM);
return;
}
static void
-dxr3videosink_set_clock (GstElement *element, GstClock *clock)
+dxr3videosink_set_clock (GstElement * element, GstClock * clock)
{
Dxr3VideoSink *src = DXR3VIDEOSINK (element);
static void
-dxr3videosink_reset_parser (Dxr3VideoSink *sink)
+dxr3videosink_reset_parser (Dxr3VideoSink * sink)
{
if (sink->cur_buf != NULL) {
gst_buffer_unref (sink->cur_buf);
static int
-dxr3videosink_next_start_code (Dxr3VideoSink *sink)
+dxr3videosink_next_start_code (Dxr3VideoSink * sink)
{
guchar c;
c = (GST_BUFFER_DATA (sink->cur_buf))[sink->scan_pos];
switch (sink->scan_state) {
- case SCAN_STATE_WAITING:
- if (c == 0x00) {
- sink->scan_state = SCAN_STATE_0;
- }
- break;
- case SCAN_STATE_0:
- if (c == 0x00) {
- sink->scan_state = SCAN_STATE_00;
- }
- else {
- sink->scan_state = SCAN_STATE_WAITING;
- }
- break;
- case SCAN_STATE_00:
- if (c == 0x01) {
- sink->scan_state = SCAN_STATE_001;
- }
- else if (c != 0x00) {
- sink->scan_state = SCAN_STATE_WAITING;
- }
- break;
- case SCAN_STATE_001:
- sink->scan_pos++;
- sink->scan_state = SCAN_STATE_WAITING;
- return c;
+ case SCAN_STATE_WAITING:
+ if (c == 0x00) {
+ sink->scan_state = SCAN_STATE_0;
+ }
+ break;
+ case SCAN_STATE_0:
+ if (c == 0x00) {
+ sink->scan_state = SCAN_STATE_00;
+ } else {
+ sink->scan_state = SCAN_STATE_WAITING;
+ }
+ break;
+ case SCAN_STATE_00:
+ if (c == 0x01) {
+ sink->scan_state = SCAN_STATE_001;
+ } else if (c != 0x00) {
+ sink->scan_state = SCAN_STATE_WAITING;
+ }
+ break;
+ case SCAN_STATE_001:
+ sink->scan_pos++;
+ sink->scan_state = SCAN_STATE_WAITING;
+ return c;
}
sink->scan_pos++;
static void
-dxr3videosink_discard_data (Dxr3VideoSink *sink, guint cut)
+dxr3videosink_discard_data (Dxr3VideoSink * sink, guint cut)
{
GstBuffer *sub;
guint size;
if (GST_BUFFER_SIZE (sink->cur_buf) == size) {
gst_buffer_unref (sink->cur_buf);
sink->cur_buf = NULL;
- }
- else {
+ } else {
sub = gst_buffer_create_sub (sink->cur_buf, size,
- GST_BUFFER_SIZE (sink->cur_buf)
- - size);
+ GST_BUFFER_SIZE (sink->cur_buf)
+ - size);
gst_buffer_unref (sink->cur_buf);
sink->cur_buf = sub;
}
static void
-dxr3videosink_write_data (Dxr3VideoSink *sink, guint cut)
+dxr3videosink_write_data (Dxr3VideoSink * sink, guint cut)
{
guint size, written;
guint8 *data;
while (size > 0) {
written = write (sink->video_fd, data, size);
if (written < 0) {
- GST_ELEMENT_ERROR (sink, RESOURCE, WRITE,
- (_("Could not write to device \"%s\"."), sink->video_filename),
- GST_ERROR_SYSTEM);
- break;
+ GST_ELEMENT_ERROR (sink, RESOURCE, WRITE,
+ (_("Could not write to device \"%s\"."), sink->video_filename),
+ GST_ERROR_SYSTEM);
+ break;
}
size = size - written;
data = data + written;
static void
-dxr3videosink_parse_data (Dxr3VideoSink *sink)
+dxr3videosink_parse_data (Dxr3VideoSink * sink)
{
int code;
while (code >= 0) {
switch (sink->parse_state) {
- case PARSE_STATE_WAITING:
- if (code == START_CODE_SEQUENCE_HEADER) {
- dxr3videosink_discard_data (sink, 4);
- sink->parse_state = PARSE_STATE_START;
- sink->cur_ts = sink->last_ts;
- }
- break;
-
- case PARSE_STATE_START:
- switch (code) {
- case START_CODE_SEQUENCE_HEADER:
- dxr3videosink_discard_data (sink, 4);
- sink->cur_ts = sink->last_ts;
- break;
- case START_CODE_SEQUENCE_END:
- dxr3videosink_discard_data (sink, 0);
- sink->parse_state = PARSE_STATE_WAITING;
- break;
- case START_CODE_PICTURE:
- sink->parse_state = PARSE_STATE_PICTURE;
- break;
- }
- break;
-
- case PARSE_STATE_PICTURE:
- switch (code) {
- case START_CODE_SEQUENCE_HEADER:
- dxr3videosink_write_data (sink, 4);
- sink->parse_state = PARSE_STATE_START;
- sink->cur_ts = sink->last_ts;
- break;
- case START_CODE_SEQUENCE_END:
- dxr3videosink_write_data (sink, 0);
- sink->parse_state = PARSE_STATE_WAITING;
- break;
- case START_CODE_PICTURE:
- dxr3videosink_write_data (sink, 4);
- break;
- }
- break;
+ case PARSE_STATE_WAITING:
+ if (code == START_CODE_SEQUENCE_HEADER) {
+ dxr3videosink_discard_data (sink, 4);
+ sink->parse_state = PARSE_STATE_START;
+ sink->cur_ts = sink->last_ts;
+ }
+ break;
+
+ case PARSE_STATE_START:
+ switch (code) {
+ case START_CODE_SEQUENCE_HEADER:
+ dxr3videosink_discard_data (sink, 4);
+ sink->cur_ts = sink->last_ts;
+ break;
+ case START_CODE_SEQUENCE_END:
+ dxr3videosink_discard_data (sink, 0);
+ sink->parse_state = PARSE_STATE_WAITING;
+ break;
+ case START_CODE_PICTURE:
+ sink->parse_state = PARSE_STATE_PICTURE;
+ break;
+ }
+ break;
+
+ case PARSE_STATE_PICTURE:
+ switch (code) {
+ case START_CODE_SEQUENCE_HEADER:
+ dxr3videosink_write_data (sink, 4);
+ sink->parse_state = PARSE_STATE_START;
+ sink->cur_ts = sink->last_ts;
+ break;
+ case START_CODE_SEQUENCE_END:
+ dxr3videosink_write_data (sink, 0);
+ sink->parse_state = PARSE_STATE_WAITING;
+ break;
+ case START_CODE_PICTURE:
+ dxr3videosink_write_data (sink, 4);
+ break;
+ }
+ break;
}
static gboolean
-dxr3videosink_handle_event (GstPad *pad, GstEvent *event)
+dxr3videosink_handle_event (GstPad * pad, GstEvent * event)
{
GstEventType type;
Dxr3VideoSink *sink;
type = event ? GST_EVENT_TYPE (event) : GST_EVENT_UNKNOWN;
switch (type) {
- case GST_EVENT_EMPTY:
- //fprintf (stderr, "++++++ Video empty event\n");
+ case GST_EVENT_EMPTY:
+ //fprintf (stderr, "++++++ Video empty event\n");
{
/* FIXME: Handle this with a discontinuity or something. */
/* Write an MPEG2 sequence end code, to ensure that the card
static guint8 sec[4] = { 0x00, 0x00, 0x01, 0xb7 };
if (sink->cur_buf != NULL) {
- dxr3videosink_write_data (sink, 0);
+ dxr3videosink_write_data (sink, 0);
}
write (sink->video_fd, &sec, 4);
}
- break;
+ break;
- case GST_EVENT_DISCONTINUOUS:
- //fprintf (stderr, "++++++ Video discont event\n");
+ case GST_EVENT_DISCONTINUOUS:
+ //fprintf (stderr, "++++++ Video discont event\n");
{
gint64 time;
gboolean has_time;
unsigned cur_scr, mpeg_scr, diff;
- has_time = gst_event_discont_get_value (event,
- GST_FORMAT_TIME,
- &time);
+ has_time = gst_event_discont_get_value (event, GST_FORMAT_TIME, &time);
if (has_time) {
/* fprintf (stderr, "^^^^^^ Discontinuous event has time %.4f\n", */
/* (double) time / GST_SECOND); */
- /* If the SCR in the card is way off, fix it. */
- ioctl (sink->control_fd, EM8300_IOCTL_SCR_GET, &cur_scr);
- mpeg_scr = MPEGTIME_TO_DXRTIME (GSTTIME_TO_MPEGTIME (time));
+ /* If the SCR in the card is way off, fix it. */
+ ioctl (sink->control_fd, EM8300_IOCTL_SCR_GET, &cur_scr);
+ mpeg_scr = MPEGTIME_TO_DXRTIME (GSTTIME_TO_MPEGTIME (time));
+
+ diff = cur_scr > mpeg_scr ? cur_scr - mpeg_scr : mpeg_scr - cur_scr;
+ if (diff > 1800) {
+ unsigned zero = 0;
- diff = cur_scr > mpeg_scr ? cur_scr - mpeg_scr : mpeg_scr - cur_scr;
- if (diff > 1800) {
- unsigned zero = 0;
/* fprintf (stderr, "====== Adjusting SCR from video\n"); */
- ioctl (sink->control_fd, EM8300_IOCTL_SCR_SET, &zero);
- ioctl (sink->control_fd, EM8300_IOCTL_SCR_SET, &mpeg_scr);
- }
- }
- else {
+ ioctl (sink->control_fd, EM8300_IOCTL_SCR_SET, &zero);
+ ioctl (sink->control_fd, EM8300_IOCTL_SCR_SET, &mpeg_scr);
+ }
+ } else {
/* fprintf (stderr, "^^^^^^ Discontinuous event has no time\n"); */
}
}
- break;
+ break;
- case GST_EVENT_FLUSH:
- dxr3videosink_reset_parser (sink);
- break;
+ case GST_EVENT_FLUSH:
+ dxr3videosink_reset_parser (sink);
+ break;
- default:
- gst_pad_event_default (pad, event);
- break;
+ default:
+ gst_pad_event_default (pad, event);
+ break;
}
return TRUE;
}
-static void
-dxr3videosink_chain (GstPad *pad, GstData *_data)
+static void
+dxr3videosink_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
Dxr3VideoSink *sink;
if (sink->cur_buf == NULL) {
sink->cur_buf = buf;
- }
- else {
+ } else {
merged = gst_buffer_merge (sink->cur_buf, buf);
gst_buffer_unref (sink->cur_buf);
gst_buffer_unref (buf);
static GstElementStateReturn
-dxr3videosink_change_state (GstElement *element)
+dxr3videosink_change_state (GstElement * element)
{
g_return_val_if_fail (GST_IS_DXR3VIDEOSINK (element), GST_STATE_FAILURE);
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY:
if (!GST_FLAG_IS_SET (element, DXR3VIDEOSINK_OPEN)) {
- if (!dxr3videosink_open (DXR3VIDEOSINK (element))) {
- return GST_STATE_FAILURE;
- }
+ if (!dxr3videosink_open (DXR3VIDEOSINK (element))) {
+ return GST_STATE_FAILURE;
+ }
}
break;
case GST_STATE_READY_TO_PAUSED:
break;
case GST_STATE_READY_TO_NULL:
if (GST_FLAG_IS_SET (element, DXR3VIDEOSINK_OPEN)) {
- dxr3videosink_close (DXR3VIDEOSINK (element));
+ dxr3videosink_close (DXR3VIDEOSINK (element));
}
break;
}
* Make the sink wait the specified amount of time.
*/
static void
-dxr3videosink_wait (Dxr3VideoSink *sink, GstClockTime time)
+dxr3videosink_wait (Dxr3VideoSink * sink, GstClockTime time)
{
GstClockID id;
GstClockTimeDiff jitter;
* Send an MVCOMMAND to the card.
*/
static int
-dxr3videosink_mvcommand (Dxr3VideoSink *sink, int command)
+dxr3videosink_mvcommand (Dxr3VideoSink * sink, int command)
{
em8300_register_t regs;
-
+
regs.microcode_register = 1;
regs.reg = 0;
regs.val = command;
-
+
return ioctl (sink->control_fd, EM8300_IOCTL_WRITEREG, ®s);
}
* queues due to a received flush event
*/
static void
-dxr3videosink_flushed (Dxr3VideoSink *sink)
+dxr3videosink_flushed (Dxr3VideoSink * sink)
{
/* Do nothing. */
}
#include <gst/gst.h>
G_BEGIN_DECLS
-
-
#define GST_TYPE_DXR3VIDEOSINK \
(dxr3videosink_get_type())
#define DXR3VIDEOSINK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DXR3VIDEOSINK))
#define GST_IS_DXR3VIDEOSINK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DXR3VIDEOSINK))
-
-
typedef struct _Dxr3VideoSink Dxr3VideoSink;
typedef struct _Dxr3VideoSinkClass Dxr3VideoSinkClass;
-typedef enum {
+typedef enum
+{
DXR3VIDEOSINK_OPEN = GST_ELEMENT_FLAG_LAST,
- DXR3VIDEOSINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
+ DXR3VIDEOSINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
} Dxr3VideoSinkFlags;
-struct _Dxr3VideoSink {
+struct _Dxr3VideoSink
+{
GstElement element;
int card_number; /* The number of the card to open. */
int video_fd; /* File descriptor for the video device. */
gchar *control_filename; /* File name for the control device. */
- int control_fd; /* File descriptor for the control
- device. */
+ int control_fd; /* File descriptor for the control
+ device. */
GstClock *clock; /* The clock for this element. */
GstClockTime last_ts; /* Last timestamp received. */
GstBuffer *cur_buf; /* The buffer we are currently
- building. */
+ building. */
GstClockTime cur_ts; /* Timestamp associated to the
- current buffer. */
+ current buffer. */
guchar scan_state; /* The current state of the MPEG start
- code scanner. */
+ code scanner. */
guint scan_pos; /* The current position of the MPEG
- start code scanner (with respect to
- the start of the current buffer. */
+ start code scanner (with respect to
+ the start of the current buffer. */
guchar parse_state; /* The current state of the MPEG
- sequence parser. */
+ sequence parser. */
};
-struct _Dxr3VideoSinkClass {
+struct _Dxr3VideoSinkClass
+{
GstElementClass parent_class;
/* signals */
- void (*flushed) (Dxr3VideoSink *sink);
+ void (*flushed) (Dxr3VideoSink * sink);
};
-extern GType dxr3videosink_get_type (void);
-extern gboolean dxr3videosink_factory_init (GstPlugin *plugin);
+extern GType dxr3videosink_get_type (void);
+extern gboolean dxr3videosink_factory_init (GstPlugin * plugin);
G_END_DECLS
-
#endif /* __DXR3VIDEOSINK_H__ */
* *\r
* version 1.0ß *\r
* *\r
- *************************************************************/\r
-\r
+ *************************************************************/ \r
+ \r
#ifndef __ARB_MULTITEXTURE_H_\r
#define __ARB_MULTITEXTURE_H_\r
-\r
+ \r
/*\r
* GLOBAL SWITCHES - enable/disable advanced features of this header\r
*\r
- */\r
-#define ARB_MULTITEXTURE_INITIALIZE 1 // enable generic init-routines\r
+ */ \r
+#define ARB_MULTITEXTURE_INITIALIZE 1 // enable generic init-routines\r
#ifndef _WIN32\r
#define GL_GLEXT_PROTOTYPES 1\r
-#endif\r
-\r
+#endif /* \r */
+ \r
#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
+extern "C"
+{
+ \r
+#endif /* \r */
+ \r
#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__)\r
#define WIN32_LEAN_AND_MEAN 1\r
#include <windows.h>\r
-#endif\r
-\r
+#endif /* \r */
+ \r
#ifndef APIENTRY\r
#define APIENTRY\r
-#endif\r
-\r
-\r
+#endif /* \r */
+ \r\r
// Header file version number, required by OpenGL ABI for Linux\r
//#define GL_GLEXT_VERSION 7\r
-\r
-\r
+ \r\r
/* \r
* NEW TOKENS TO OPENGL 1.2.1 \r
*\r
- */\r
+ */ \r
#ifndef GL_ARB_multitexture\r
#define GL_TEXTURE0_ARB 0x84C0\r
#define GL_TEXTURE1_ARB 0x84C1\r
#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1\r
#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2\r
#define GL_ARB_multitexture 1\r
-#endif\r
-\r
+#endif /* \r */
+ \r
#ifndef _WIN32\r
#ifdef GL_GLEXT_PROTOTYPES\r
-extern void APIENTRY glActiveTextureARB (GLenum);\r
-extern void APIENTRY glClientActiveTextureARB (GLenum);\r
-extern void APIENTRY glMultiTexCoord1dARB (GLenum, GLdouble);\r
-extern void APIENTRY glMultiTexCoord1dvARB (GLenum, const GLdouble *);\r
-extern void APIENTRY glMultiTexCoord1fARB (GLenum, GLfloat);\r
-extern void APIENTRY glMultiTexCoord1fvARB (GLenum, const GLfloat *);\r
-extern void APIENTRY glMultiTexCoord1iARB (GLenum, GLint);\r
-extern void APIENTRY glMultiTexCoord1ivARB (GLenum, const GLint *);\r
-extern void APIENTRY glMultiTexCoord1sARB (GLenum, GLshort);\r
-extern void APIENTRY glMultiTexCoord1svARB (GLenum, const GLshort *);\r
-extern void APIENTRY glMultiTexCoord2dARB (GLenum, GLdouble, GLdouble);\r
-extern void APIENTRY glMultiTexCoord2dvARB (GLenum, const GLdouble *);\r
-extern void APIENTRY glMultiTexCoord2fARB (GLenum, GLfloat, GLfloat);\r
-extern void APIENTRY glMultiTexCoord2fvARB (GLenum, const GLfloat *);\r
-extern void APIENTRY glMultiTexCoord2iARB (GLenum, GLint, GLint);\r
-extern void APIENTRY glMultiTexCoord2ivARB (GLenum, const GLint *);\r
-extern void APIENTRY glMultiTexCoord2sARB (GLenum, GLshort, GLshort);\r
-extern void APIENTRY glMultiTexCoord2svARB (GLenum, const GLshort *);\r
-extern void APIENTRY glMultiTexCoord3dARB (GLenum, GLdouble, GLdouble, GLdouble);\r
-extern void APIENTRY glMultiTexCoord3dvARB (GLenum, const GLdouble *);\r
-extern void APIENTRY glMultiTexCoord3fARB (GLenum, GLfloat, GLfloat, GLfloat);\r
-extern void APIENTRY glMultiTexCoord3fvARB (GLenum, const GLfloat *);\r
-extern void APIENTRY glMultiTexCoord3iARB (GLenum, GLint, GLint, GLint);\r
-extern void APIENTRY glMultiTexCoord3ivARB (GLenum, const GLint *);\r
-extern void APIENTRY glMultiTexCoord3sARB (GLenum, GLshort, GLshort, GLshort);\r
-extern void APIENTRY glMultiTexCoord3svARB (GLenum, const GLshort *);\r
-extern void APIENTRY glMultiTexCoord4dARB (GLenum, GLdouble, GLdouble, GLdouble, GLdouble);\r
-extern void APIENTRY glMultiTexCoord4dvARB (GLenum, const GLdouble *);\r
-extern void APIENTRY glMultiTexCoord4fARB (GLenum, GLfloat, GLfloat, GLfloat, GLfloat);\r
-extern void APIENTRY glMultiTexCoord4fvARB (GLenum, const GLfloat *);\r
-extern void APIENTRY glMultiTexCoord4iARB (GLenum, GLint, GLint, GLint, GLint);\r
-extern void APIENTRY glMultiTexCoord4ivARB (GLenum, const GLint *);\r
-extern void APIENTRY glMultiTexCoord4sARB (GLenum, GLshort, GLshort, GLshort, GLshort);\r
-extern void APIENTRY glMultiTexCoord4svARB (GLenum, const GLshort *);\r
-#endif // GL_GLEXT_PROTOTYPES\r
-#else // not _WIN32\r
-typedef void (APIENTRY * PFNGLACTIVETEXTUREARBPROC) (GLenum texture);\r
-typedef void (APIENTRY * PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture);\r
-typedef void (APIENTRY * PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s);\r
-typedef void (APIENTRY * PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v);\r
-typedef void (APIENTRY * PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s);\r
-typedef void (APIENTRY * PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v);\r
-typedef void (APIENTRY * PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s);\r
-typedef void (APIENTRY * PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v);\r
-typedef void (APIENTRY * PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s);\r
-typedef void (APIENTRY * PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v);\r
-typedef void (APIENTRY * PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t);\r
-typedef void (APIENTRY * PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v);\r
-typedef void (APIENTRY * PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t);\r
-typedef void (APIENTRY * PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v);\r
-typedef void (APIENTRY * PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t);\r
-typedef void (APIENTRY * PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v);\r
-typedef void (APIENTRY * PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t);\r
-typedef void (APIENTRY * PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v);\r
-typedef void (APIENTRY * PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r);\r
-typedef void (APIENTRY * PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v);\r
-typedef void (APIENTRY * PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r);\r
-typedef void (APIENTRY * PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v);\r
-typedef void (APIENTRY * PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r);\r
-typedef void (APIENTRY * PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v);\r
-typedef void (APIENTRY * PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r);\r
-typedef void (APIENTRY * PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v);\r
-typedef void (APIENTRY * PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);\r
-typedef void (APIENTRY * PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v);\r
-typedef void (APIENTRY * PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);\r
-typedef void (APIENTRY * PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v);\r
-typedef void (APIENTRY * PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q);\r
-typedef void (APIENTRY * PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v);\r
-typedef void (APIENTRY * PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);\r
-typedef void (APIENTRY * PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v);\r
-#endif // _WIN32\r
-\r
+ extern void APIENTRY glActiveTextureARB (GLenum);
+ \rextern void APIENTRY glClientActiveTextureARB (GLenum);
+ \rextern void APIENTRY glMultiTexCoord1dARB (GLenum, GLdouble);
+ \rextern void APIENTRY glMultiTexCoord1dvARB (GLenum, const GLdouble *);
+ \rextern void APIENTRY glMultiTexCoord1fARB (GLenum, GLfloat);
+ \rextern void APIENTRY glMultiTexCoord1fvARB (GLenum, const GLfloat *);
+ \rextern void APIENTRY glMultiTexCoord1iARB (GLenum, GLint);
+ \rextern void APIENTRY glMultiTexCoord1ivARB (GLenum, const GLint *);
+ \rextern void APIENTRY glMultiTexCoord1sARB (GLenum, GLshort);
+ \rextern void APIENTRY glMultiTexCoord1svARB (GLenum, const GLshort *);
+ \rextern void APIENTRY glMultiTexCoord2dARB (GLenum, GLdouble, GLdouble);
+ \rextern void APIENTRY glMultiTexCoord2dvARB (GLenum, const GLdouble *);
+ \rextern void APIENTRY glMultiTexCoord2fARB (GLenum, GLfloat, GLfloat);
+ \rextern void APIENTRY glMultiTexCoord2fvARB (GLenum, const GLfloat *);
+ \rextern void APIENTRY glMultiTexCoord2iARB (GLenum, GLint, GLint);
+ \rextern void APIENTRY glMultiTexCoord2ivARB (GLenum, const GLint *);
+ \rextern void APIENTRY glMultiTexCoord2sARB (GLenum, GLshort, GLshort);
+ \rextern void APIENTRY glMultiTexCoord2svARB (GLenum, const GLshort *);
+ \rextern void APIENTRY glMultiTexCoord3dARB (GLenum, GLdouble, GLdouble,
+ GLdouble);
+ \rextern void APIENTRY glMultiTexCoord3dvARB (GLenum, const GLdouble *);
+ \rextern void APIENTRY glMultiTexCoord3fARB (GLenum, GLfloat, GLfloat,
+ GLfloat);
+ \rextern void APIENTRY glMultiTexCoord3fvARB (GLenum, const GLfloat *);
+ \rextern void APIENTRY glMultiTexCoord3iARB (GLenum, GLint, GLint, GLint);
+ \rextern void APIENTRY glMultiTexCoord3ivARB (GLenum, const GLint *);
+ \rextern void APIENTRY glMultiTexCoord3sARB (GLenum, GLshort, GLshort,
+ GLshort);
+ \rextern void APIENTRY glMultiTexCoord3svARB (GLenum, const GLshort *);
+ \rextern void APIENTRY glMultiTexCoord4dARB (GLenum, GLdouble, GLdouble,
+ GLdouble, GLdouble);
+ \rextern void APIENTRY glMultiTexCoord4dvARB (GLenum, const GLdouble *);
+ \rextern void APIENTRY glMultiTexCoord4fARB (GLenum, GLfloat, GLfloat,
+ GLfloat, GLfloat);
+ \rextern void APIENTRY glMultiTexCoord4fvARB (GLenum, const GLfloat *);
+ \rextern void APIENTRY glMultiTexCoord4iARB (GLenum, GLint, GLint, GLint,
+ GLint);
+ \rextern void APIENTRY glMultiTexCoord4ivARB (GLenum, const GLint *);
+ \rextern void APIENTRY glMultiTexCoord4sARB (GLenum, GLshort, GLshort,
+ GLshort, GLshort);
+ \rextern void APIENTRY glMultiTexCoord4svARB (GLenum, const GLshort *);
+ \r
+#endif // GL_GLEXT_PROTOTYPES\r
+#else // not _WIN32\r
+ typedef void (APIENTRY * PFNGLACTIVETEXTUREARBPROC) (GLenum texture);
+ \rtypedef void (APIENTRY * PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture);
+ \rtypedef void (APIENTRY * PFNGLMULTITEXCOORD1DARBPROC) (GLenum target,
+ GLdouble s);
+ \rtypedef void (APIENTRY * PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target,
+ const GLdouble * v);
+ \rtypedef void (APIENTRY * PFNGLMULTITEXCOORD1FARBPROC) (GLenum target,
+ GLfloat s);
+ \rtypedef void (APIENTRY * PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target,
+ const GLfloat * v);
+ \rtypedef void (APIENTRY * PFNGLMULTITEXCOORD1IARBPROC) (GLenum target,
+ GLint s);
+ \rtypedef void (APIENTRY * PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target,
+ const GLint * v);
+ \rtypedef void (APIENTRY * PFNGLMULTITEXCOORD1SARBPROC) (GLenum target,
+ GLshort s);
+ \rtypedef void (APIENTRY * PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target,
+ const GLshort * v);
+ \rtypedef void (APIENTRY * PFNGLMULTITEXCOORD2DARBPROC) (GLenum target,
+ GLdouble s, GLdouble t);
+ \rtypedef void (APIENTRY * PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target,
+ const GLdouble * v);
+ \rtypedef void (APIENTRY * PFNGLMULTITEXCOORD2FARBPROC) (GLenum target,
+ GLfloat s, GLfloat t);
+ \rtypedef void (APIENTRY * PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target,
+ const GLfloat * v);
+ \rtypedef void (APIENTRY * PFNGLMULTITEXCOORD2IARBPROC) (GLenum target,
+ GLint s, GLint t);
+ \rtypedef void (APIENTRY * PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target,
+ const GLint * v);
+ \rtypedef void (APIENTRY * PFNGLMULTITEXCOORD2SARBPROC) (GLenum target,
+ GLshort s, GLshort t);
+ \rtypedef void (APIENTRY * PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target,
+ const GLshort * v);
+ \rtypedef void (APIENTRY * PFNGLMULTITEXCOORD3DARBPROC) (GLenum target,
+ GLdouble s, GLdouble t, GLdouble r);
+ \rtypedef void (APIENTRY * PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target,
+ const GLdouble * v);
+ \rtypedef void (APIENTRY * PFNGLMULTITEXCOORD3FARBPROC) (GLenum target,
+ GLfloat s, GLfloat t, GLfloat r);
+ \rtypedef void (APIENTRY * PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target,
+ const GLfloat * v);
+ \rtypedef void (APIENTRY * PFNGLMULTITEXCOORD3IARBPROC) (GLenum target,
+ GLint s, GLint t, GLint r);
+ \rtypedef void (APIENTRY * PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target,
+ const GLint * v);
+ \rtypedef void (APIENTRY * PFNGLMULTITEXCOORD3SARBPROC) (GLenum target,
+ GLshort s, GLshort t, GLshort r);
+ \rtypedef void (APIENTRY * PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target,
+ const GLshort * v);
+ \rtypedef void (APIENTRY * PFNGLMULTITEXCOORD4DARBPROC) (GLenum target,
+ GLdouble s, GLdouble t, GLdouble r, GLdouble q);
+ \rtypedef void (APIENTRY * PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target,
+ const GLdouble * v);
+ \rtypedef void (APIENTRY * PFNGLMULTITEXCOORD4FARBPROC) (GLenum target,
+ GLfloat s, GLfloat t, GLfloat r, GLfloat q);
+ \rtypedef void (APIENTRY * PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target,
+ const GLfloat * v);
+ \rtypedef void (APIENTRY * PFNGLMULTITEXCOORD4IARBPROC) (GLenum target,
+ GLint s, GLint t, GLint r, GLint q);
+ \rtypedef void (APIENTRY * PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target,
+ const GLint * v);
+ \rtypedef void (APIENTRY * PFNGLMULTITEXCOORD4SARBPROC) (GLenum target,
+ GLshort s, GLshort t, GLshort r, GLshort q);
+ \rtypedef void (APIENTRY * PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target,
+ const GLshort * v);
+ \r
+#endif // _WIN32\r
+ \r
#ifdef ARB_MULTITEXTURE_INITIALIZE\r
#include<string.h> // string manipulation for runtime-check\r
-\r
+ \r
#ifdef _WIN32\r
-PFNGLACTIVETEXTUREARBPROC glActiveTextureARB = NULL;\r
-PFNGLCLIENTACTIVETEXTUREARBPROC glClientActiveTextureARB = NULL;\r
-PFNGLMULTITEXCOORD1DARBPROC glMultiTexCoord1dARB = NULL;\r
-PFNGLMULTITEXCOORD1DVARBPROC glMultiTexCoord1dvARB = NULL;\r
-PFNGLMULTITEXCOORD1FARBPROC glMultiTexCoord1fARB = NULL;\r
-PFNGLMULTITEXCOORD1FVARBPROC glMultiTexCoord1fvARB = NULL;\r
-PFNGLMULTITEXCOORD1IARBPROC glMultiTexCoord1iARB = NULL;\r
-PFNGLMULTITEXCOORD1IVARBPROC glMultiTexCoord1ivARB = NULL;\r
-PFNGLMULTITEXCOORD1SARBPROC glMultiTexCoord1sARB = NULL;\r
-PFNGLMULTITEXCOORD1SVARBPROC glMultiTexCoord1svARB = NULL;\r
-PFNGLMULTITEXCOORD2DARBPROC glMultiTexCoord2dARB = NULL;\r
-PFNGLMULTITEXCOORD2DVARBPROC glMultiTexCoord2dvARB = NULL;\r
-PFNGLMULTITEXCOORD2FARBPROC glMultiTexCoord2fARB = NULL;\r
-PFNGLMULTITEXCOORD2FVARBPROC glMultiTexCoord2fvARB = NULL;\r
-PFNGLMULTITEXCOORD2IARBPROC glMultiTexCoord2iARB = NULL;\r
-PFNGLMULTITEXCOORD2IVARBPROC glMultiTexCoord2ivARB = NULL;\r
-PFNGLMULTITEXCOORD2SARBPROC glMultiTexCoord2sARB = NULL;\r
-PFNGLMULTITEXCOORD2SVARBPROC glMultiTexCoord2svARB = NULL;\r
-PFNGLMULTITEXCOORD3DARBPROC glMultiTexCoord3dARB = NULL;\r
-PFNGLMULTITEXCOORD3DVARBPROC glMultiTexCoord3dvARB = NULL;\r
-PFNGLMULTITEXCOORD3FARBPROC glMultiTexCoord3fARB = NULL;\r
-PFNGLMULTITEXCOORD3FVARBPROC glMultiTexCoord3fvARB = NULL;\r
-PFNGLMULTITEXCOORD3IARBPROC glMultiTexCoord3iARB = NULL;\r
-PFNGLMULTITEXCOORD3IVARBPROC glMultiTexCoord3ivARB = NULL;\r
-PFNGLMULTITEXCOORD3SARBPROC glMultiTexCoord3sARB = NULL;\r
-PFNGLMULTITEXCOORD3SVARBPROC glMultiTexCoord3svARB = NULL;\r
-PFNGLMULTITEXCOORD4DARBPROC glMultiTexCoord4dARB = NULL;\r
-PFNGLMULTITEXCOORD4DVARBPROC glMultiTexCoord4dvARB = NULL;\r
-PFNGLMULTITEXCOORD4FARBPROC glMultiTexCoord4fARB = NULL;\r
-PFNGLMULTITEXCOORD4FVARBPROC glMultiTexCoord4fvARB = NULL;\r
-PFNGLMULTITEXCOORD4IARBPROC glMultiTexCoord4iARB = NULL;\r
-PFNGLMULTITEXCOORD4IVARBPROC glMultiTexCoord4ivARB = NULL;\r
-PFNGLMULTITEXCOORD4SARBPROC glMultiTexCoord4sARB = NULL;\r
-PFNGLMULTITEXCOORD4SVARBPROC glMultiTexCoord4svARB = NULL;\r
-#endif // _WIN32 \r
-\r
-int CheckForARBMultitextureSupport(void) {\r
- const char search[]="GL_ARB_multitexture";\r
- int i, pos=0;\r
- int maxpos=strlen(search)-1;\r
- char extensions[10000];\r
- printf("Getting GLstring, context is %p\n", glXGetCurrentContext());\r
- strcpy(extensions,(const char *)glGetString(GL_EXTENSIONS));\r
- printf("Examinig GLstring\n");\r
- int len=strlen(extensions);\r
- for ( i=0; i<len; i++) {\r
- if ((i==0) || ((i>1) && extensions[i-1]==' ')) {\r
- pos=0;\r
- while(extensions[i]!=' ') {\r
- if (extensions[i]==search[pos]) pos++;\r
- if ((pos>maxpos) && extensions[i+1]==' ') {\r
- //if (debug)\r
- {\r
- //fprintf(stderr, search);\r
- //fprintf(stderr, " supported.\n");\r
- }\r
- return 1;\r
- }\r
- ++i;\r
- }\r
- }\r
- }\r
- //printf(search);\r
- //printf(" not supported.\n");\r
- return 0;\r
-}\r
-\r
-int GL_ARB_multitexture_Init(void) {\r
- if (!CheckForARBMultitextureSupport()) return 0;\r
+ PFNGLACTIVETEXTUREARBPROC glActiveTextureARB = NULL;
+ \rPFNGLCLIENTACTIVETEXTUREARBPROC glClientActiveTextureARB = NULL;
+ \rPFNGLMULTITEXCOORD1DARBPROC glMultiTexCoord1dARB = NULL;
+ \rPFNGLMULTITEXCOORD1DVARBPROC glMultiTexCoord1dvARB = NULL;
+ \rPFNGLMULTITEXCOORD1FARBPROC glMultiTexCoord1fARB = NULL;
+ \rPFNGLMULTITEXCOORD1FVARBPROC glMultiTexCoord1fvARB = NULL;
+ \rPFNGLMULTITEXCOORD1IARBPROC glMultiTexCoord1iARB = NULL;
+ \rPFNGLMULTITEXCOORD1IVARBPROC glMultiTexCoord1ivARB = NULL;
+ \rPFNGLMULTITEXCOORD1SARBPROC glMultiTexCoord1sARB = NULL;
+ \rPFNGLMULTITEXCOORD1SVARBPROC glMultiTexCoord1svARB = NULL;
+ \rPFNGLMULTITEXCOORD2DARBPROC glMultiTexCoord2dARB = NULL;
+ \rPFNGLMULTITEXCOORD2DVARBPROC glMultiTexCoord2dvARB = NULL;
+ \rPFNGLMULTITEXCOORD2FARBPROC glMultiTexCoord2fARB = NULL;
+ \rPFNGLMULTITEXCOORD2FVARBPROC glMultiTexCoord2fvARB = NULL;
+ \rPFNGLMULTITEXCOORD2IARBPROC glMultiTexCoord2iARB = NULL;
+ \rPFNGLMULTITEXCOORD2IVARBPROC glMultiTexCoord2ivARB = NULL;
+ \rPFNGLMULTITEXCOORD2SARBPROC glMultiTexCoord2sARB = NULL;
+ \rPFNGLMULTITEXCOORD2SVARBPROC glMultiTexCoord2svARB = NULL;
+ \rPFNGLMULTITEXCOORD3DARBPROC glMultiTexCoord3dARB = NULL;
+ \rPFNGLMULTITEXCOORD3DVARBPROC glMultiTexCoord3dvARB = NULL;
+ \rPFNGLMULTITEXCOORD3FARBPROC glMultiTexCoord3fARB = NULL;
+ \rPFNGLMULTITEXCOORD3FVARBPROC glMultiTexCoord3fvARB = NULL;
+ \rPFNGLMULTITEXCOORD3IARBPROC glMultiTexCoord3iARB = NULL;
+ \rPFNGLMULTITEXCOORD3IVARBPROC glMultiTexCoord3ivARB = NULL;
+ \rPFNGLMULTITEXCOORD3SARBPROC glMultiTexCoord3sARB = NULL;
+ \rPFNGLMULTITEXCOORD3SVARBPROC glMultiTexCoord3svARB = NULL;
+ \rPFNGLMULTITEXCOORD4DARBPROC glMultiTexCoord4dARB = NULL;
+ \rPFNGLMULTITEXCOORD4DVARBPROC glMultiTexCoord4dvARB = NULL;
+ \rPFNGLMULTITEXCOORD4FARBPROC glMultiTexCoord4fARB = NULL;
+ \rPFNGLMULTITEXCOORD4FVARBPROC glMultiTexCoord4fvARB = NULL;
+ \rPFNGLMULTITEXCOORD4IARBPROC glMultiTexCoord4iARB = NULL;
+ \rPFNGLMULTITEXCOORD4IVARBPROC glMultiTexCoord4ivARB = NULL;
+ \rPFNGLMULTITEXCOORD4SARBPROC glMultiTexCoord4sARB = NULL;
+ \rPFNGLMULTITEXCOORD4SVARBPROC glMultiTexCoord4svARB = NULL;
+ \r
+#endif // _WIN32 \r
+ \rint CheckForARBMultitextureSupport (void)
+ {
+ \rconst char search[] = "GL_ARB_multitexture";
+ \rint i, pos = 0;
+ \rint maxpos = strlen (search) - 1;
+ \rchar extensions[10000];
+ \rprintf ("Getting GLstring, context is %p\n", glXGetCurrentContext ());
+ \rstrcpy (extensions, (const char *) glGetString (GL_EXTENSIONS));
+ \rprintf ("Examinig GLstring\n");
+ \rint len = strlen (extensions);
+ \rfor (i = 0; i < len; i++)
+ {
+ \rif ((i == 0) || ((i > 1) && extensions[i - 1] == ' ')) {
+ \rpos = 0;
+ \rwhile (extensions[i] != ' ')
+ {
+ \rif (extensions[i] == search[pos])
+ pos++;
+ \rif ((pos > maxpos) && extensions[i + 1] == ' ') {
+ \r
+ //if (debug)\r
+ {
+ \r
+ //fprintf(stderr, search);\r
+ //fprintf(stderr, " supported.\n");\r
+ }
+ \rreturn 1;
+ \r}
+ \r++i;
+ \r}
+ \r}
+ \r}
+ \r
+ //printf(search);\r
+ //printf(" not supported.\n");\r
+ return 0;
+ \r}
+ \r\rint GL_ARB_multitexture_Init (void)
+ {
+ \rif (!CheckForARBMultitextureSupport ())
+ return 0;
+ \r
#ifdef _WIN32\r
- glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC) wglGetProcAddress("glActiveTextureARB");\r
- if (glActiveTextureARB==NULL) {fprintf(stderr,"glActiveTextureARB not found.\n"); return 0; }\r
- glClientActiveTextureARB = (PFNGLCLIENTACTIVETEXTUREARBPROC) wglGetProcAddress("glClientActiveTextureARB");\r
- if (glClientActiveTextureARB==NULL) {fprintf(stderr,"glClientActiveTextureARB not found.\n"); return 0; }\r
- glMultiTexCoord1dARB = (PFNGLMULTITEXCOORD1DARBPROC) wglGetProcAddress("glMultiTexCoord1dARB");\r
- if (glMultiTexCoord1dARB==NULL) {fprintf(stderr,"glMultiTexCoord1dARB not found.\n"); return 0; }\r
- glMultiTexCoord1dvARB = (PFNGLMULTITEXCOORD1DVARBPROC) wglGetProcAddress("glMultiTexCoord1dvARB");\r
- if (glMultiTexCoord1dvARB==NULL) {fprintf(stderr,"glMultiTexCoord1dAvRB not found.\n"); return 0; }\r
- glMultiTexCoord1fARB = (PFNGLMULTITEXCOORD1FARBPROC) wglGetProcAddress("glMultiTexCoord1fARB");\r
- if (glMultiTexCoord1fARB==NULL) {fprintf(stderr,"glMultiTexCoord1fARB not found.\n"); return 0; }\r
- glMultiTexCoord1fvARB = (PFNGLMULTITEXCOORD1FVARBPROC) wglGetProcAddress("glMultiTexCoord1fvARB");\r
- if (glMultiTexCoord1fvARB==NULL) {fprintf(stderr,"glMultiTexCoord1fvARB not found.\n"); return 0; }\r
- glMultiTexCoord1iARB = (PFNGLMULTITEXCOORD1IARBPROC) wglGetProcAddress("glMultiTexCoord1iARB");\r
- if (glMultiTexCoord1iARB==NULL) {fprintf(stderr,"glMultiTexCoord1iARB not found.\n"); return 0; }\r
- glMultiTexCoord1ivARB = (PFNGLMULTITEXCOORD1IVARBPROC) wglGetProcAddress("glMultiTexCoord1ivARB");\r
- if (glMultiTexCoord1ivARB==NULL) {fprintf(stderr,"glMultiTexCoord1ivARB not found.\n"); return 0; }\r
- glMultiTexCoord1sARB = (PFNGLMULTITEXCOORD1SARBPROC) wglGetProcAddress("glMultiTexCoord1sARB");\r
- if (glMultiTexCoord1sARB==NULL) {fprintf(stderr,"glMultiTexCoord1sARB not found.\n"); return 0; }\r
- glMultiTexCoord1svARB = (PFNGLMULTITEXCOORD1SVARBPROC) wglGetProcAddress("glMultiTexCoord1svARB");\r
- if (glMultiTexCoord1svARB==NULL) {fprintf(stderr,"glMultiTexCoord1svARB not found.\n"); return 0; }\r
- glMultiTexCoord2dARB = (PFNGLMULTITEXCOORD2DARBPROC) wglGetProcAddress("glMultiTexCoord2dARB");\r
- if (glMultiTexCoord2dARB==NULL) {fprintf(stderr,"glMultiTexCoord2dARB not found.\n"); return 0; }\r
- glMultiTexCoord2dvARB = (PFNGLMULTITEXCOORD2DVARBPROC) wglGetProcAddress("glMultiTexCoord2dvARB");\r
- if (glMultiTexCoord2dvARB==NULL) {fprintf(stderr,"glMultiTexCoord2dAvRB not found.\n"); return 0; }\r
- glMultiTexCoord2fARB = (PFNGLMULTITEXCOORD2FARBPROC) wglGetProcAddress("glMultiTexCoord2fARB");\r
- if (glMultiTexCoord2fARB==NULL) {fprintf(stderr,"glMultiTexCoord2fARB not found.\n"); return 0; }\r
- glMultiTexCoord2fvARB = (PFNGLMULTITEXCOORD2FVARBPROC) wglGetProcAddress("glMultiTexCoord2fvARB");\r
- if (glMultiTexCoord2fvARB==NULL) {fprintf(stderr,"glMultiTexCoord2fvARB not found.\n"); return 0; }\r
- glMultiTexCoord2iARB = (PFNGLMULTITEXCOORD2IARBPROC) wglGetProcAddress("glMultiTexCoord2iARB");\r
- if (glMultiTexCoord2iARB==NULL) {fprintf(stderr,"glMultiTexCoord2iARB not found.\n"); return 0; }\r
- glMultiTexCoord2ivARB = (PFNGLMULTITEXCOORD2IVARBPROC) wglGetProcAddress("glMultiTexCoord2ivARB");\r
- if (glMultiTexCoord2ivARB==NULL) {fprintf(stderr,"glMultiTexCoord2ivARB not found.\n"); return 0; }\r
- glMultiTexCoord2sARB = (PFNGLMULTITEXCOORD2SARBPROC) wglGetProcAddress("glMultiTexCoord2sARB");\r
- if (glMultiTexCoord2sARB==NULL) {fprintf(stderr,"glMultiTexCoord2sARB not found.\n"); return 0; }\r
- glMultiTexCoord2svARB = (PFNGLMULTITEXCOORD2SVARBPROC) wglGetProcAddress("glMultiTexCoord2svARB");\r
- if (glMultiTexCoord2svARB==NULL) {fprintf(stderr,"glMultiTexCoord2svARB not found.\n"); return 0; }\r
- glMultiTexCoord3dARB = (PFNGLMULTITEXCOORD3DARBPROC) wglGetProcAddress("glMultiTexCoord3dARB");\r
- if (glMultiTexCoord3dARB==NULL) {fprintf(stderr,"glMultiTexCoord3dARB not found.\n"); return 0; }\r
- glMultiTexCoord3dvARB = (PFNGLMULTITEXCOORD3DVARBPROC) wglGetProcAddress("glMultiTexCoord3dvARB");\r
- if (glMultiTexCoord3dvARB==NULL) {fprintf(stderr,"glMultiTexCoord3dAvRB not found.\n"); return 0; }\r
- glMultiTexCoord3fARB = (PFNGLMULTITEXCOORD3FARBPROC) wglGetProcAddress("glMultiTexCoord3fARB");\r
- if (glMultiTexCoord3fARB==NULL) {fprintf(stderr,"glMultiTexCoord3fARB not found.\n"); return 0; }\r
- glMultiTexCoord3fvARB = (PFNGLMULTITEXCOORD3FVARBPROC) wglGetProcAddress("glMultiTexCoord3fvARB");\r
- if (glMultiTexCoord3fvARB==NULL) {fprintf(stderr,"glMultiTexCoord3fvARB not found.\n"); return 0; }\r
- glMultiTexCoord3iARB = (PFNGLMULTITEXCOORD3IARBPROC) wglGetProcAddress("glMultiTexCoord3iARB");\r
- if (glMultiTexCoord3iARB==NULL) {fprintf(stderr,"glMultiTexCoord3iARB not found.\n"); return 0; }\r
- glMultiTexCoord3ivARB = (PFNGLMULTITEXCOORD3IVARBPROC) wglGetProcAddress("glMultiTexCoord3ivARB");\r
- if (glMultiTexCoord3ivARB==NULL) {fprintf(stderr,"glMultiTexCoord3ivARB not found.\n"); return 0; }\r
- glMultiTexCoord3sARB = (PFNGLMULTITEXCOORD3SARBPROC) wglGetProcAddress("glMultiTexCoord3sARB");\r
- if (glMultiTexCoord3sARB==NULL) {fprintf(stderr,"glMultiTexCoord3sARB not found.\n"); return 0; }\r
- glMultiTexCoord3svARB = (PFNGLMULTITEXCOORD3SVARBPROC) wglGetProcAddress("glMultiTexCoord3svARB");\r
- if (glMultiTexCoord3svARB==NULL) {fprintf(stderr,"glMultiTexCoord3svARB not found.\n"); return 0; }\r
- glMultiTexCoord4dARB = (PFNGLMULTITEXCOORD4DARBPROC) wglGetProcAddress("glMultiTexCoord4dARB");\r
- if (glMultiTexCoord4dARB==NULL) {fprintf(stderr,"glMultiTexCoord4dARB not found.\n"); return 0; }\r
- glMultiTexCoord4dvARB = (PFNGLMULTITEXCOORD4DVARBPROC) wglGetProcAddress("glMultiTexCoord4dvARB");\r
- if (glMultiTexCoord4dvARB==NULL) {fprintf(stderr,"glMultiTexCoord4dAvRB not found.\n"); return 0; }\r
- glMultiTexCoord4fARB = (PFNGLMULTITEXCOORD4FARBPROC) wglGetProcAddress("glMultiTexCoord4fARB");\r
- if (glMultiTexCoord4fARB==NULL) {fprintf(stderr,"glMultiTexCoord4fARB not found.\n"); return 0; }\r
- glMultiTexCoord4fvARB = (PFNGLMULTITEXCOORD4FVARBPROC) wglGetProcAddress("glMultiTexCoord4fvARB");\r
- if (glMultiTexCoord4fvARB==NULL) {fprintf(stderr,"glMultiTexCoord4fvARB not found.\n"); return 0; }\r
- glMultiTexCoord4iARB = (PFNGLMULTITEXCOORD4IARBPROC) wglGetProcAddress("glMultiTexCoord4iARB");\r
- if (glMultiTexCoord4iARB==NULL) {fprintf(stderr,"glMultiTexCoord4iARB not found.\n"); return 0; }\r
- glMultiTexCoord4ivARB = (PFNGLMULTITEXCOORD4IVARBPROC) wglGetProcAddress("glMultiTexCoord4ivARB");\r
- if (glMultiTexCoord4ivARB==NULL) {fprintf(stderr,"glMultiTexCoord4ivARB not found.\n"); return 0; }\r
- glMultiTexCoord4sARB = (PFNGLMULTITEXCOORD4SARBPROC) wglGetProcAddress("glMultiTexCoord4sARB");\r
- if (glMultiTexCoord4sARB==NULL) {fprintf(stderr,"glMultiTexCoord4sARB not found.\n"); return 0; }\r
- glMultiTexCoord4svARB = (PFNGLMULTITEXCOORD4SVARBPROC) wglGetProcAddress("glMultiTexCoord4svARB");\r
- if (glMultiTexCoord4svARB==NULL) {fprintf(stderr,"glMultiTexCoord4svARB not found.\n"); return 0; }\r
+ glActiveTextureARB =
+ (PFNGLACTIVETEXTUREARBPROC) wglGetProcAddress ("glActiveTextureARB");
+ \rif (glActiveTextureARB == NULL) {
+ fprintf (stderr, "glActiveTextureARB not found.\n");
+ return 0;
+ }
+ \rglClientActiveTextureARB = (PFNGLCLIENTACTIVETEXTUREARBPROC)
+ wglGetProcAddress ("glClientActiveTextureARB");
+ \rif (glClientActiveTextureARB == NULL) {
+ fprintf (stderr, "glClientActiveTextureARB not found.\n");
+ return 0;
+ }
+ \rglMultiTexCoord1dARB = (PFNGLMULTITEXCOORD1DARBPROC)
+ wglGetProcAddress ("glMultiTexCoord1dARB");
+ \rif (glMultiTexCoord1dARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord1dARB not found.\n");
+ return 0;
+ }
+ \rglMultiTexCoord1dvARB = (PFNGLMULTITEXCOORD1DVARBPROC)
+ wglGetProcAddress ("glMultiTexCoord1dvARB");
+ \rif (glMultiTexCoord1dvARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord1dAvRB not found.\n");
+ return 0;
+ }
+ \rglMultiTexCoord1fARB = (PFNGLMULTITEXCOORD1FARBPROC)
+ wglGetProcAddress ("glMultiTexCoord1fARB");
+ \rif (glMultiTexCoord1fARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord1fARB not found.\n");
+ return 0;
+ }
+ \rglMultiTexCoord1fvARB = (PFNGLMULTITEXCOORD1FVARBPROC)
+ wglGetProcAddress ("glMultiTexCoord1fvARB");
+ \rif (glMultiTexCoord1fvARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord1fvARB not found.\n");
+ return 0;
+ }
+ \rglMultiTexCoord1iARB = (PFNGLMULTITEXCOORD1IARBPROC)
+ wglGetProcAddress ("glMultiTexCoord1iARB");
+ \rif (glMultiTexCoord1iARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord1iARB not found.\n");
+ return 0;
+ }
+ \rglMultiTexCoord1ivARB = (PFNGLMULTITEXCOORD1IVARBPROC)
+ wglGetProcAddress ("glMultiTexCoord1ivARB");
+ \rif (glMultiTexCoord1ivARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord1ivARB not found.\n");
+ return 0;
+ }
+ \rglMultiTexCoord1sARB = (PFNGLMULTITEXCOORD1SARBPROC)
+ wglGetProcAddress ("glMultiTexCoord1sARB");
+ \rif (glMultiTexCoord1sARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord1sARB not found.\n");
+ return 0;
+ }
+ \rglMultiTexCoord1svARB = (PFNGLMULTITEXCOORD1SVARBPROC)
+ wglGetProcAddress ("glMultiTexCoord1svARB");
+ \rif (glMultiTexCoord1svARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord1svARB not found.\n");
+ return 0;
+ }
+ \rglMultiTexCoord2dARB = (PFNGLMULTITEXCOORD2DARBPROC)
+ wglGetProcAddress ("glMultiTexCoord2dARB");
+ \rif (glMultiTexCoord2dARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord2dARB not found.\n");
+ return 0;
+ }
+ \rglMultiTexCoord2dvARB = (PFNGLMULTITEXCOORD2DVARBPROC)
+ wglGetProcAddress ("glMultiTexCoord2dvARB");
+ \rif (glMultiTexCoord2dvARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord2dAvRB not found.\n");
+ return 0;
+ }
+ \rglMultiTexCoord2fARB = (PFNGLMULTITEXCOORD2FARBPROC)
+ wglGetProcAddress ("glMultiTexCoord2fARB");
+ \rif (glMultiTexCoord2fARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord2fARB not found.\n");
+ return 0;
+ }
+ \rglMultiTexCoord2fvARB = (PFNGLMULTITEXCOORD2FVARBPROC)
+ wglGetProcAddress ("glMultiTexCoord2fvARB");
+ \rif (glMultiTexCoord2fvARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord2fvARB not found.\n");
+ return 0;
+ }
+ \rglMultiTexCoord2iARB = (PFNGLMULTITEXCOORD2IARBPROC)
+ wglGetProcAddress ("glMultiTexCoord2iARB");
+ \rif (glMultiTexCoord2iARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord2iARB not found.\n");
+ return 0;
+ }
+ \rglMultiTexCoord2ivARB = (PFNGLMULTITEXCOORD2IVARBPROC)
+ wglGetProcAddress ("glMultiTexCoord2ivARB");
+ \rif (glMultiTexCoord2ivARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord2ivARB not found.\n");
+ return 0;
+ }
+ \rglMultiTexCoord2sARB = (PFNGLMULTITEXCOORD2SARBPROC)
+ wglGetProcAddress ("glMultiTexCoord2sARB");
+ \rif (glMultiTexCoord2sARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord2sARB not found.\n");
+ return 0;
+ }
+ \rglMultiTexCoord2svARB = (PFNGLMULTITEXCOORD2SVARBPROC)
+ wglGetProcAddress ("glMultiTexCoord2svARB");
+ \rif (glMultiTexCoord2svARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord2svARB not found.\n");
+ return 0;
+ }
+ \rglMultiTexCoord3dARB = (PFNGLMULTITEXCOORD3DARBPROC)
+ wglGetProcAddress ("glMultiTexCoord3dARB");
+ \rif (glMultiTexCoord3dARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord3dARB not found.\n");
+ return 0;
+ }
+ \rglMultiTexCoord3dvARB = (PFNGLMULTITEXCOORD3DVARBPROC)
+ wglGetProcAddress ("glMultiTexCoord3dvARB");
+ \rif (glMultiTexCoord3dvARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord3dAvRB not found.\n");
+ return 0;
+ }
+ \rglMultiTexCoord3fARB = (PFNGLMULTITEXCOORD3FARBPROC)
+ wglGetProcAddress ("glMultiTexCoord3fARB");
+ \rif (glMultiTexCoord3fARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord3fARB not found.\n");
+ return 0;
+ }
+ \rglMultiTexCoord3fvARB = (PFNGLMULTITEXCOORD3FVARBPROC)
+ wglGetProcAddress ("glMultiTexCoord3fvARB");
+ \rif (glMultiTexCoord3fvARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord3fvARB not found.\n");
+ return 0;
+ }
+ \rglMultiTexCoord3iARB = (PFNGLMULTITEXCOORD3IARBPROC)
+ wglGetProcAddress ("glMultiTexCoord3iARB");
+ \rif (glMultiTexCoord3iARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord3iARB not found.\n");
+ return 0;
+ }
+ \rglMultiTexCoord3ivARB = (PFNGLMULTITEXCOORD3IVARBPROC)
+ wglGetProcAddress ("glMultiTexCoord3ivARB");
+ \rif (glMultiTexCoord3ivARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord3ivARB not found.\n");
+ return 0;
+ }
+ \rglMultiTexCoord3sARB = (PFNGLMULTITEXCOORD3SARBPROC)
+ wglGetProcAddress ("glMultiTexCoord3sARB");
+ \rif (glMultiTexCoord3sARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord3sARB not found.\n");
+ return 0;
+ }
+ \rglMultiTexCoord3svARB = (PFNGLMULTITEXCOORD3SVARBPROC)
+ wglGetProcAddress ("glMultiTexCoord3svARB");
+ \rif (glMultiTexCoord3svARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord3svARB not found.\n");
+ return 0;
+ }
+ \rglMultiTexCoord4dARB = (PFNGLMULTITEXCOORD4DARBPROC)
+ wglGetProcAddress ("glMultiTexCoord4dARB");
+ \rif (glMultiTexCoord4dARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord4dARB not found.\n");
+ return 0;
+ }
+ \rglMultiTexCoord4dvARB = (PFNGLMULTITEXCOORD4DVARBPROC)
+ wglGetProcAddress ("glMultiTexCoord4dvARB");
+ \rif (glMultiTexCoord4dvARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord4dAvRB not found.\n");
+ return 0;
+ }
+ \rglMultiTexCoord4fARB = (PFNGLMULTITEXCOORD4FARBPROC)
+ wglGetProcAddress ("glMultiTexCoord4fARB");
+ \rif (glMultiTexCoord4fARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord4fARB not found.\n");
+ return 0;
+ }
+ \rglMultiTexCoord4fvARB = (PFNGLMULTITEXCOORD4FVARBPROC)
+ wglGetProcAddress ("glMultiTexCoord4fvARB");
+ \rif (glMultiTexCoord4fvARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord4fvARB not found.\n");
+ return 0;
+ }
+ \rglMultiTexCoord4iARB = (PFNGLMULTITEXCOORD4IARBPROC)
+ wglGetProcAddress ("glMultiTexCoord4iARB");
+ \rif (glMultiTexCoord4iARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord4iARB not found.\n");
+ return 0;
+ }
+ \rglMultiTexCoord4ivARB = (PFNGLMULTITEXCOORD4IVARBPROC)
+ wglGetProcAddress ("glMultiTexCoord4ivARB");
+ \rif (glMultiTexCoord4ivARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord4ivARB not found.\n");
+ return 0;
+ }
+ \rglMultiTexCoord4sARB = (PFNGLMULTITEXCOORD4SARBPROC)
+ wglGetProcAddress ("glMultiTexCoord4sARB");
+ \rif (glMultiTexCoord4sARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord4sARB not found.\n");
+ return 0;
+ }
+ \rglMultiTexCoord4svARB = (PFNGLMULTITEXCOORD4SVARBPROC)
+ wglGetProcAddress ("glMultiTexCoord4svARB");
+ \rif (glMultiTexCoord4svARB == NULL) {
+ fprintf (stderr, "glMultiTexCoord4svARB not found.\n");
+ return 0;
+ }
+ \r
#endif // _WIN32\r
- return 1;\r
-}\r
-\r
+ return 1;
+ \r}
+ \r\r
#endif // ARB_MULTITEXTURE_INITIALIZE\r
-\r
+ \r
#ifdef __cplusplus\r
-}\r
-#endif\r
+}
+
\r
+#endif /* \r */
+ \r
#endif // not __ARB_MULTITEXTURE_H_\r
* *\r
* version 1.0ß *\r
* *\r
- *************************************************************/\r
-\r
+ *************************************************************/ \r
+ \r
#ifndef __EXT_paletted_texture_H_\r
#define __EXT_paletted_texture_H_\r
-\r
+ \r
/*\r
* GLOBAL SWITCHES - enable/disable advanced features of this header\r
*\r
- */\r
-#define EXT_PALETTED_TEXTURE_INITIALIZE 1 // enable generic init-routines\r
+ */ \r
+#define EXT_PALETTED_TEXTURE_INITIALIZE 1 // enable generic init-routines\r
#ifndef _WIN32\r
#define GL_GLEXT_PROTOTYPES 1\r
-#endif\r
-\r
+#endif /* \r */
+ \r
#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
+extern "C"
+{
+ \r
+#endif /* \r */
+ \r
#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__)\r
#define WIN32_LEAN_AND_MEAN 1\r
#include <windows.h>\r
-#endif\r
-\r
+#endif /* \r */
+ \r
#ifndef APIENTRY\r
#define APIENTRY\r
-#endif\r
-\r
-\r
+#endif /* \r */
+ \r\r
// Header file version number, required by OpenGL ABI for Linux\r
//#define GL_GLEXT_VERSION 7\r
-\r
-\r
+ \r\r
/* \r
* NEW TOKENS TO OPENGL 1.2.1 \r
*\r
- */\r
+ */ \r
#ifndef GL_EXT_paletted_texture\r
#define GL_COLOR_INDEX1_EXT 0x80E2 \r
#define GL_COLOR_INDEX2_EXT 0x80E3 \r
#define GL_COLOR_TABLE_INTENSITY_SIZE_EXT 0x80DF\r
#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED\r
#define GL_EXT_paletted_texture 1\r
-#endif\r
-\r
+#endif /* \r */
+ \r
#ifndef _WIN32\r
#ifdef GL_GLEXT_PROTOTYPES\r
-extern void APIENTRY glColorTableEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); \r
-extern void APIENTRY glColorSubTableEXT(GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); \r
-extern void APIENTRY glGetColorTableEXT(GLenum, GLenum, GLenum, GLvoid *);\r
-extern void APIENTRY glGetColorTableParameterivEXT(GLenum, GLenum, GLint *);\r
-extern void APIENTRY glGetColorTableParameterfvEXT(GLenum, GLenum, GLfloat *);\r
-#endif // GL_GLEXT_PROTOTYPES \r
-#else // _WIN32\r
-typedef void (APIENTRY * PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *data); \r
-typedef void (APIENTRY * PFNGLCOLORSUBTABLEEXTPROC)(GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data);\r
-typedef void (APIENTRY * PFNGLGETCOLORTABLEEXTPROC)(GLenum target, GLenum format, GLenum type, GLvoid *data);\r
-typedef void (APIENTRY * PFNGLGETCOLORTABLEPARAMETERIVEXTPROC)(GLenum target, GLenum pname, GLint *params); \r
-typedef void (APIENTRY * PFNGLGETCOLORTABLEPARAMETERFVEXTPROC)(GLenum target, GLenum pname, GLfloat *params);\r
-#endif // not _WIN32\r
-\r
+ extern void APIENTRY glColorTableEXT (GLenum, GLenum, GLsizei, GLenum, GLenum,
+ const GLvoid *);
+ \rextern void APIENTRY glColorSubTableEXT (GLenum, GLsizei, GLsizei, GLenum,
+ GLenum, const GLvoid *);
+ \rextern void APIENTRY glGetColorTableEXT (GLenum, GLenum, GLenum, GLvoid *);
+ \rextern void APIENTRY glGetColorTableParameterivEXT (GLenum, GLenum,
+ GLint *);
+ \rextern void APIENTRY glGetColorTableParameterfvEXT (GLenum, GLenum,
+ GLfloat *);
+ \r
+#endif // GL_GLEXT_PROTOTYPES \r
+#else // _WIN32\r
+ typedef void (APIENTRY * PFNGLCOLORTABLEEXTPROC) (GLenum target,
+ GLenum internalFormat, GLsizei width, GLenum format, GLenum type,
+ const GLvoid * data);
+ \rtypedef void (APIENTRY * PFNGLCOLORSUBTABLEEXTPROC) (GLenum target,
+ GLsizei start, GLsizei count, GLenum format, GLenum type,
+ const GLvoid * data);
+ \rtypedef void (APIENTRY * PFNGLGETCOLORTABLEEXTPROC) (GLenum target,
+ GLenum format, GLenum type, GLvoid * data);
+ \rtypedef void (APIENTRY *
+ PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname,
+ GLint * params);
+ \rtypedef void (APIENTRY *
+ PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname,
+ GLfloat * params);
+ \r
+#endif // not _WIN32\r
+ \r
#ifdef EXT_PALETTED_TEXTURE_INITIALIZE\r
-#include<string.h> // string manipulation for runtime-check\r
-\r
+#include<string.h> // string manipulation for runtime-check\r
+ \r
#ifdef _WIN32\r
-PFNGLCOLORTABLEEXTPROC glColorTableEXT = NULL;\r
-PFNGLCOLORSUBTABLEEXTPROC glColorSubTableEXT = NULL;\r
-PFNGLGETCOLORTABLEEXTPROC glGetColorTableEXT = NULL;\r
-PFNGLGETCOLORTABLEPARAMETERIVEXTPROC glGetColorTableParameterivEXT = NULL;\r
-PFNGLGETCOLORTABLEPARAMETERFVEXTPROC glGetColorTableParameterfvEXT = NULL;\r
-#endif // _WIN32\r
-\r
-int CheckForEXTPalettedTextureSupport(void) {\r
- const char search[]="GL_EXT_paletted_texture";\r
- int i, pos=0;\r
- int maxpos=strlen(search)-1;\r
- char extensions[10000];\r
- strcpy(extensions,(const char *)glGetString(GL_EXTENSIONS));\r
- int len=strlen(extensions);\r
- for (i=0; i<len; i++) {\r
- if ((i==0) || ((i>1) && extensions[i-1]==' ')) {\r
- pos=0;\r
- while(extensions[i]!=' ') {\r
- if (extensions[i]==search[pos]) pos++;\r
- if ((pos>maxpos) && extensions[i+1]==' ') {\r
- //printf(search);\r
- //printf(" supported.\n");\r
- return 1;\r
- }\r
- i++;\r
- }\r
- }\r
- }\r
- //printf(search);\r
- //printf(" not supported.\n");\r
- return 0;\r
-}\r
-\r
-int GL_EXT_paletted_texture_Init(void) {\r
- if (!CheckForEXTPalettedTextureSupport()) return 0;\r
-\r
+ PFNGLCOLORTABLEEXTPROC glColorTableEXT = NULL;
+ \rPFNGLCOLORSUBTABLEEXTPROC glColorSubTableEXT = NULL;
+ \rPFNGLGETCOLORTABLEEXTPROC glGetColorTableEXT = NULL;
+ \rPFNGLGETCOLORTABLEPARAMETERIVEXTPROC glGetColorTableParameterivEXT = NULL;
+ \rPFNGLGETCOLORTABLEPARAMETERFVEXTPROC glGetColorTableParameterfvEXT = NULL;
+ \r
+#endif // _WIN32\r
+ \rint CheckForEXTPalettedTextureSupport (void)
+ {
+ \rconst char search[] = "GL_EXT_paletted_texture";
+ \rint i, pos = 0;
+ \rint maxpos = strlen (search) - 1;
+ \rchar extensions[10000];
+ \rstrcpy (extensions, (const char *) glGetString (GL_EXTENSIONS));
+ \rint len = strlen (extensions);
+ \rfor (i = 0; i < len; i++)
+ {
+ \rif ((i == 0) || ((i > 1) && extensions[i - 1] == ' ')) {
+ \rpos = 0;
+ \rwhile (extensions[i] != ' ')
+ {
+ \rif (extensions[i] == search[pos])
+ pos++;
+ \rif ((pos > maxpos) && extensions[i + 1] == ' ') {
+ \r
+ //printf(search);\r
+ //printf(" supported.\n");\r
+ return 1;
+ \r}
+ \ri++;
+ \r}
+ \r}
+ \r}
+ \r
+ //printf(search);\r
+ //printf(" not supported.\n");\r
+ return 0;
+ \r}
+ \r\rint GL_EXT_paletted_texture_Init (void)
+ {
+ \rif (!CheckForEXTPalettedTextureSupport ())
+ return 0;
+ \r\r
#ifdef _WIN32\r
- glColorTableEXT = (PFNGLCOLORTABLEEXTPROC) wglGetProcAddress("glColorTableEXT");\r
- if (glColorTableEXT==NULL) {fprintf(stderr,"glColorTableEXT not found.\n"); return 0;}\r
- glColorSubTableEXT = (PFNGLCOLORSUBTABLEEXTPROC) wglGetProcAddress("glColorSubTableEXT");\r
- if (glColorSubTableEXT==NULL) {fprintf(stderr,"glColorSubTableEXT not found.\n"); return 0;}\r
- glGetColorTableEXT = (PFNGLGETCOLORTABLEEXTPROC) wglGetProcAddress("glGetColorTableEXT");\r
- if (glGetColorTableEXT==NULL) {fprintf(stderr,"glGetColorTableEXT not found.\n"); return 0;}\r
- glGetColorTableParameterivEXT = (PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) wglGetProcAddress("glGetColorTableParameterivEXT");\r
- if (glGetColorTableParameterivEXT==NULL) {fprintf(stderr,"glGetColorTableParameterivEXT not found.\n"); return 0;}\r
- glGetColorTableParameterfvEXT = (PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) wglGetProcAddress("glGetColorTableParameterfvEXT");\r
- if (glGetColorTableParameterfvEXT==NULL) {fprintf(stderr,"glGetColorTableParameterfvEXT not found.\n"); return 0;}\r
+ glColorTableEXT =
+ (PFNGLCOLORTABLEEXTPROC) wglGetProcAddress ("glColorTableEXT");
+ \rif (glColorTableEXT == NULL) {
+ fprintf (stderr, "glColorTableEXT not found.\n");
+ return 0;
+ }
+ \rglColorSubTableEXT =
+ (PFNGLCOLORSUBTABLEEXTPROC) wglGetProcAddress ("glColorSubTableEXT");
+ \rif (glColorSubTableEXT == NULL) {
+ fprintf (stderr, "glColorSubTableEXT not found.\n");
+ return 0;
+ }
+ \rglGetColorTableEXT =
+ (PFNGLGETCOLORTABLEEXTPROC) wglGetProcAddress ("glGetColorTableEXT");
+ \rif (glGetColorTableEXT == NULL) {
+ fprintf (stderr, "glGetColorTableEXT not found.\n");
+ return 0;
+ }
+ \rglGetColorTableParameterivEXT = (PFNGLGETCOLORTABLEPARAMETERIVEXTPROC)
+ wglGetProcAddress ("glGetColorTableParameterivEXT");
+ \rif (glGetColorTableParameterivEXT == NULL) {
+ fprintf (stderr, "glGetColorTableParameterivEXT not found.\n");
+ return 0;
+ }
+ \rglGetColorTableParameterfvEXT = (PFNGLGETCOLORTABLEPARAMETERFVEXTPROC)
+ wglGetProcAddress ("glGetColorTableParameterfvEXT");
+ \rif (glGetColorTableParameterfvEXT == NULL) {
+ fprintf (stderr, "glGetColorTableParameterfvEXT not found.\n");
+ return 0;
+ }
+ \r
#endif // _WIN32\r
- return 1;\r
-}\r
-\r
+ return 1;
+ \r}
+ \r\r
#endif // EXT_PALETTED_TEXTURE_INITIALIZE\r
-\r
+ \r
#ifdef __cplusplus\r
-}\r
-#endif\r
+}
+
\r
+#endif /* \r */
+ \r
#endif // not __EXT_PALETTED_TEXTURE_H_\r
* *\r
* version 2.0ß *\r
* *\r
- *************************************************************/\r
-\r
+ *************************************************************/ \r
+ \r
#ifndef __NV_register_combiners_H_\r
#define __NV_register_combiners_H_\r
-\r
+ \r
/*\r
* GLOBAL SWITCHES - enable/disable advanced features of this header\r
*\r
- */\r
-#define NV_REGISTER_COMBINERS_INITIALIZE 1 // enable generic init-routines\r
+ */ \r
+#define NV_REGISTER_COMBINERS_INITIALIZE 1 // enable generic init-routines\r
#ifndef _WIN32\r
#define GL_GLEXT_PROTOTYPES 1\r
-#endif\r
-\r
+#endif /* \r */
+ \r
#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
+extern "C"
+{
+ \r
+#endif /* \r */
+ \r
#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__)\r
#define WIN32_LEAN_AND_MEAN 1\r
#include <windows.h>\r
-#endif\r
-\r
+#endif /* \r */
+ \r
#ifndef APIENTRY\r
#define APIENTRY\r
-#endif\r
-\r
-\r
+#endif /* \r */
+ \r\r
// Header file version number, required by OpenGL ABI for Linux\r
//#define GL_GLEXT_VERSION 7\r
-\r
-\r
+ \r\r
/* \r
* NEW TOKENS TO OPENGL 1.2.1 \r
*\r
- */\r
+ */ \r
#ifndef GL_NV_register_combiners\r
#define GL_REGISTER_COMBINERS_NV 0x8522\r
#define GL_COMBINER0_NV 0x8550\r
#define GL_COLOR_SUM_CLAMP_NV 0x854F\r
#define GL_MAX_GENERAL_COMBINERS_NV 0x854D\r
#define GL_NV_register_combiners 1\r
-#endif\r
-\r
+#endif /* \r */
+ \r
#ifndef _WIN32\r
#ifdef GL_GLEXT_PROTOTYPES\r
-extern void APIENTRY glCombinerParameterfvNV(GLenum, const GLfloat *);\r
-extern void APIENTRY glCombinerParameterivNV(GLenum, const GLint *); \r
-extern void APIENTRY glCombinerParameterfNV (GLenum, GLfloat); \r
-extern void APIENTRY glCombinerParameteriNV (GLenum, GLint); \r
-extern void APIENTRY glCombinerInputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum); \r
-extern void APIENTRY glCombinerOutputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLboolean, GLboolean, GLboolean); \r
-extern void APIENTRY glFinalCombinerInputNV (GLenum, GLenum, GLenum, GLenum); \r
-extern void APIENTRY glGetCombinerInputParameterfvNV (GLenum, GLenum, GLenum, GLenum, GLfloat *); \r
-extern void APIENTRY glGetCombinerInputParameterivNV (GLenum, GLenum, GLenum, GLenum, GLint *); \r
-extern void APIENTRY glGetCombinerOutputParameterfvNV(GLenum, GLenum, GLenum, GLfloat *); \r
-extern void APIENTRY glGetCombinerOutputParameterivNV(GLenum, GLenum, GLenum, GLint *);\r
-extern void APIENTRY glGetFinalCombinerInputParameterfvNV(GLenum, GLenum, GLfloat *); \r
-extern void APIENTRY glGetFinalCombinerInputParameterivNV(GLenum, GLenum, GLint *);\r
-#endif // GL_GLEXT_PROTOTYPES \r
-#else // _WIN32\r
-typedef void (APIENTRY * PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params);\r
-typedef void (APIENTRY * PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); \r
-typedef void (APIENTRY * PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); \r
-typedef void (APIENTRY * PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); \r
-typedef void (APIENTRY * PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); \r
-typedef void (APIENTRY * PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); \r
-typedef void (APIENTRY * PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); \r
-typedef void (APIENTRY * PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); \r
-typedef void (APIENTRY * PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); \r
-typedef void (APIENTRY * PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC)(GLenum stage, GLenum portion, GLenum pname, GLfloat *params); \r
-typedef void (APIENTRY * PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC)(GLenum stage, GLenum portion, GLenum pname, GLint *params);\r
-typedef void (APIENTRY * PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC)(GLenum variable, GLenum pname, GLfloat *params); \r
-typedef void (APIENTRY * PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC)(GLenum variable, GLenum pname, GLint *params);\r
-#endif // not _WIN32\r
-\r
+ extern void APIENTRY glCombinerParameterfvNV (GLenum, const GLfloat *);
+ \rextern void APIENTRY glCombinerParameterivNV (GLenum, const GLint *);
+ \rextern void APIENTRY glCombinerParameterfNV (GLenum, GLfloat);
+ \rextern void APIENTRY glCombinerParameteriNV (GLenum, GLint);
+ \rextern void APIENTRY glCombinerInputNV (GLenum, GLenum, GLenum, GLenum,
+ GLenum, GLenum);
+ \rextern void APIENTRY glCombinerOutputNV (GLenum, GLenum, GLenum, GLenum,
+ GLenum, GLenum, GLenum, GLboolean, GLboolean, GLboolean);
+ \rextern void APIENTRY glFinalCombinerInputNV (GLenum, GLenum, GLenum,
+ GLenum);
+ \rextern void APIENTRY glGetCombinerInputParameterfvNV (GLenum, GLenum,
+ GLenum, GLenum, GLfloat *);
+ \rextern void APIENTRY glGetCombinerInputParameterivNV (GLenum, GLenum,
+ GLenum, GLenum, GLint *);
+ \rextern void APIENTRY glGetCombinerOutputParameterfvNV (GLenum, GLenum,
+ GLenum, GLfloat *);
+ \rextern void APIENTRY glGetCombinerOutputParameterivNV (GLenum, GLenum,
+ GLenum, GLint *);
+ \rextern void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum, GLenum,
+ GLfloat *);
+ \rextern void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum, GLenum,
+ GLint *);
+ \r
+#endif // GL_GLEXT_PROTOTYPES \r
+#else // _WIN32\r
+ typedef void (APIENTRY * PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname,
+ const GLfloat * params);
+ \rtypedef void (APIENTRY * PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname,
+ const GLint * params);
+ \rtypedef void (APIENTRY * PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname,
+ GLfloat param);
+ \rtypedef void (APIENTRY * PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname,
+ GLint param);
+ \rtypedef void (APIENTRY * PFNGLCOMBINERINPUTNVPROC) (GLenum stage,
+ GLenum portion, GLenum variable, GLenum input, GLenum mapping,
+ GLenum componentUsage);
+ \rtypedef void (APIENTRY * PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage,
+ GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput,
+ GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct,
+ GLboolean muxSum);
+ \rtypedef void (APIENTRY * PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable,
+ GLenum input, GLenum mapping, GLenum componentUsage);
+ \rtypedef void (APIENTRY *
+ PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion,
+ GLenum variable, GLenum pname, GLfloat * params);
+ \rtypedef void (APIENTRY *
+ PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion,
+ GLenum variable, GLenum pname, GLint * params);
+ \rtypedef void (APIENTRY *
+ PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion,
+ GLenum pname, GLfloat * params);
+ \rtypedef void (APIENTRY *
+ PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion,
+ GLenum pname, GLint * params);
+ \rtypedef void (APIENTRY *
+ PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable,
+ GLenum pname, GLfloat * params);
+ \rtypedef void (APIENTRY *
+ PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable,
+ GLenum pname, GLint * params);
+ \r
+#endif // not _WIN32\r
+ \r
#ifdef NV_REGISTER_COMBINERS_INITIALIZE\r
-#include<string.h> // string manipulation for runtime-check\r
-\r
+#include<string.h> // string manipulation for runtime-check\r
+ \r
#ifdef _WIN32\r
-PFNGLCOMBINERPARAMETERFVNVPROC glCombinerParameterfvNV = NULL;\r
-PFNGLCOMBINERPARAMETERIVNVPROC glCombinerParameterivNV = NULL;\r
-PFNGLCOMBINERPARAMETERFNVPROC glCombinerParameterfNV = NULL;\r
-PFNGLCOMBINERPARAMETERINVPROC glCombinerParameteriNV = NULL;\r
-PFNGLCOMBINERINPUTNVPROC glCombinerInputNV = NULL;\r
-PFNGLCOMBINEROUTPUTNVPROC glCombinerOutputNV = NULL;\r
-PFNGLFINALCOMBINERINPUTNVPROC glFinalCombinerInputNV = NULL;\r
-PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC glGetCombinerInputParameterfvNV = NULL;\r
-PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC glGetCombinerInputParameterivNV = NULL;\r
-PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC glGetCombinerOutputParameterfvNV = NULL;\r
-PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC glGetCombinerOutputParameterivNV = NULL;\r
-PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC glGetFinalCombinerInputParameterfvNV = NULL;\r
-PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC glGetFinalCombinerInputParameterivNV = NULL;\r
-#endif // _WIN32\r
-\r
-int CheckForNVRegisterCombinersSupport(void) {\r
- const char search[]="GL_NV_register_combiners";\r
- int i, pos=0;\r
- int maxpos=strlen(search)-1;\r
- char extensions[10000];\r
- strcpy(extensions,(const char *)glGetString(GL_EXTENSIONS));\r
- int len=strlen(extensions);\r
- for (i=0; i<len; i++) {\r
- if ((i==0) || ((i>1) && extensions[i-1]==' ')) {\r
- pos=0;\r
- while(extensions[i]!=' ') {\r
- if (extensions[i]==search[pos]) pos++;\r
- if ((pos>maxpos) && extensions[i+1]==' ') {\r
- //printf(search);\r
- // printf(" supported.\n");\r
- return 1;\r
- }\r
- i++;\r
- }\r
- }\r
- }\r
- //printf(search);\r
- //printf(" not supported.\n");\r
- return 0;\r
-}\r
-\r
-int GL_NV_register_combiners_Init(void) {\r
- if (!CheckForNVRegisterCombinersSupport()) return 0;\r
-\r
+ PFNGLCOMBINERPARAMETERFVNVPROC glCombinerParameterfvNV = NULL;
+ \rPFNGLCOMBINERPARAMETERIVNVPROC glCombinerParameterivNV = NULL;
+ \rPFNGLCOMBINERPARAMETERFNVPROC glCombinerParameterfNV = NULL;
+ \rPFNGLCOMBINERPARAMETERINVPROC glCombinerParameteriNV = NULL;
+ \rPFNGLCOMBINERINPUTNVPROC glCombinerInputNV = NULL;
+ \rPFNGLCOMBINEROUTPUTNVPROC glCombinerOutputNV = NULL;
+ \rPFNGLFINALCOMBINERINPUTNVPROC glFinalCombinerInputNV = NULL;
+ \rPFNGLGETCOMBINERINPUTPARAMETERFVNVPROC glGetCombinerInputParameterfvNV =
+ NULL;
+ \rPFNGLGETCOMBINERINPUTPARAMETERIVNVPROC glGetCombinerInputParameterivNV =
+ NULL;
+ \rPFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC glGetCombinerOutputParameterfvNV =
+ NULL;
+ \rPFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC glGetCombinerOutputParameterivNV =
+ NULL;
+ \rPFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC
+ glGetFinalCombinerInputParameterfvNV = NULL;
+ \rPFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC
+ glGetFinalCombinerInputParameterivNV = NULL;
+ \r
+#endif // _WIN32\r
+ \rint CheckForNVRegisterCombinersSupport (void)
+ {
+ \rconst char search[] = "GL_NV_register_combiners";
+ \rint i, pos = 0;
+ \rint maxpos = strlen (search) - 1;
+ \rchar extensions[10000];
+ \rstrcpy (extensions, (const char *) glGetString (GL_EXTENSIONS));
+ \rint len = strlen (extensions);
+ \rfor (i = 0; i < len; i++)
+ {
+ \rif ((i == 0) || ((i > 1) && extensions[i - 1] == ' ')) {
+ \rpos = 0;
+ \rwhile (extensions[i] != ' ')
+ {
+ \rif (extensions[i] == search[pos])
+ pos++;
+ \rif ((pos > maxpos) && extensions[i + 1] == ' ') {
+ \r
+ //printf(search);\r
+ // printf(" supported.\n");\r
+ return 1;
+ \r}
+ \ri++;
+ \r}
+ \r}
+ \r}
+ \r
+ //printf(search);\r
+ //printf(" not supported.\n");\r
+ return 0;
+ \r}
+ \r\rint GL_NV_register_combiners_Init (void)
+ {
+ \rif (!CheckForNVRegisterCombinersSupport ())
+ return 0;
+ \r\r
#ifdef _WIN32\r
- glCombinerParameterfvNV=(PFNGLCOMBINERPARAMETERFVNVPROC) wglGetProcAddress("glCombinerParameterfvNV");\r
- if (glCombinerParameterfvNV==NULL) {fprintf(stderr,"glCombinerParameterfvNV not found.\n"); return 0;}\r
- glCombinerParameterivNV=(PFNGLCOMBINERPARAMETERIVNVPROC) wglGetProcAddress("glCombinerParameterivNV");\r
- if (glCombinerParameterivNV==NULL) {fprintf(stderr,"glCombinerParameterivNV not found.\n"); return 0;}\r
- glCombinerParameterfNV=(PFNGLCOMBINERPARAMETERFNVPROC) wglGetProcAddress("glCombinerParameterfNV");\r
- if (glCombinerParameterfvNV==NULL) {fprintf(stderr,"glCombinerParameterfNV not found.\n"); return 0;}\r
- glCombinerParameteriNV=(PFNGLCOMBINERPARAMETERINVPROC) wglGetProcAddress("glCombinerParameteriNV");\r
- if (glCombinerParameterivNV==NULL) {fprintf(stderr,"glCombinerParameteriNV not found.\n"); return 0;}\r
- glCombinerInputNV=(PFNGLCOMBINERINPUTNVPROC) wglGetProcAddress("glCombinerInputNV");\r
- if (glCombinerInputNV==NULL) {fprintf(stderr,"glCombinerInputNV not found.\n"); return 0;}\r
- glCombinerOutputNV=(PFNGLCOMBINEROUTPUTNVPROC) wglGetProcAddress("glCombinerOutputNV");\r
- if (glCombinerOutputNV==NULL) {fprintf(stderr,"glCombinerOutputNV not found.\n"); return 0;}\r
- glFinalCombinerInputNV=(PFNGLFINALCOMBINERINPUTNVPROC) wglGetProcAddress("glFinalCombinerInputNV");\r
- if (glFinalCombinerInputNV==NULL) {fprintf(stderr,"glFinalCombinerInputNV not found.\n"); return 0;}\r
- glGetCombinerInputParameterfvNV=(PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) wglGetProcAddress("glGetCombinerInputParameterfvNV");\r
- if (glGetCombinerInputParameterfvNV==NULL) {fprintf(stderr,"glGetCombinerInputParameterfvNV not found.\n"); return 0;}\r
- glGetCombinerInputParameterivNV=(PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) wglGetProcAddress("glGetCombinerInputParameterivNV");\r
- if (glGetCombinerInputParameterivNV==NULL) {fprintf(stderr,"glGetCombinerInputParameterivNV not found.\n"); return 0;}\r
- glGetCombinerOutputParameterfvNV=(PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) wglGetProcAddress("glGetCombinerOutputParameterfvNV");\r
- if (glGetCombinerOutputParameterfvNV==NULL) {fprintf(stderr,"glGetCombinerOutputParameterfvNV not found.\n"); return 0;}\r
- glGetCombinerOutputParameterivNV=(PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) wglGetProcAddress("glGetCombinerOutputParameterivNV");\r
- if (glGetCombinerOutputParameterivNV==NULL) {fprintf(stderr,"glGetCombinerOutputParameterivNV not found.\n"); return 0;}\r
- glGetFinalCombinerInputParameterfvNV=(PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) wglGetProcAddress("glGetFinalCombinerInputParameterfvNV");\r
- if (glGetFinalCombinerInputParameterfvNV==NULL) {fprintf(stderr,"glGetFinalCombinerInputParameterfvNV not found.\n"); return 0;}\r
- glGetFinalCombinerInputParameterivNV=(PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) wglGetProcAddress("glGetFinalCombinerInputParameterivNV");\r
- if (glGetFinalCombinerInputParameterivNV==NULL) {fprintf(stderr,"glGetFinalCombinerInputParameterivNV not found.\n"); return 0;}\r
+ glCombinerParameterfvNV = (PFNGLCOMBINERPARAMETERFVNVPROC)
+ wglGetProcAddress ("glCombinerParameterfvNV");
+ \rif (glCombinerParameterfvNV == NULL) {
+ fprintf (stderr, "glCombinerParameterfvNV not found.\n");
+ return 0;
+ }
+ \rglCombinerParameterivNV = (PFNGLCOMBINERPARAMETERIVNVPROC)
+ wglGetProcAddress ("glCombinerParameterivNV");
+ \rif (glCombinerParameterivNV == NULL) {
+ fprintf (stderr, "glCombinerParameterivNV not found.\n");
+ return 0;
+ }
+ \rglCombinerParameterfNV = (PFNGLCOMBINERPARAMETERFNVPROC)
+ wglGetProcAddress ("glCombinerParameterfNV");
+ \rif (glCombinerParameterfvNV == NULL) {
+ fprintf (stderr, "glCombinerParameterfNV not found.\n");
+ return 0;
+ }
+ \rglCombinerParameteriNV = (PFNGLCOMBINERPARAMETERINVPROC)
+ wglGetProcAddress ("glCombinerParameteriNV");
+ \rif (glCombinerParameterivNV == NULL) {
+ fprintf (stderr, "glCombinerParameteriNV not found.\n");
+ return 0;
+ }
+ \rglCombinerInputNV =
+ (PFNGLCOMBINERINPUTNVPROC) wglGetProcAddress ("glCombinerInputNV");
+ \rif (glCombinerInputNV == NULL) {
+ fprintf (stderr, "glCombinerInputNV not found.\n");
+ return 0;
+ }
+ \rglCombinerOutputNV =
+ (PFNGLCOMBINEROUTPUTNVPROC) wglGetProcAddress ("glCombinerOutputNV");
+ \rif (glCombinerOutputNV == NULL) {
+ fprintf (stderr, "glCombinerOutputNV not found.\n");
+ return 0;
+ }
+ \rglFinalCombinerInputNV = (PFNGLFINALCOMBINERINPUTNVPROC)
+ wglGetProcAddress ("glFinalCombinerInputNV");
+ \rif (glFinalCombinerInputNV == NULL) {
+ fprintf (stderr, "glFinalCombinerInputNV not found.\n");
+ return 0;
+ }
+ \rglGetCombinerInputParameterfvNV = (PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC)
+ wglGetProcAddress ("glGetCombinerInputParameterfvNV");
+ \rif (glGetCombinerInputParameterfvNV == NULL) {
+ fprintf (stderr, "glGetCombinerInputParameterfvNV not found.\n");
+ return 0;
+ }
+ \rglGetCombinerInputParameterivNV = (PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC)
+ wglGetProcAddress ("glGetCombinerInputParameterivNV");
+ \rif (glGetCombinerInputParameterivNV == NULL) {
+ fprintf (stderr, "glGetCombinerInputParameterivNV not found.\n");
+ return 0;
+ }
+ \rglGetCombinerOutputParameterfvNV =
+ (PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC)
+ wglGetProcAddress ("glGetCombinerOutputParameterfvNV");
+ \rif (glGetCombinerOutputParameterfvNV == NULL) {
+ fprintf (stderr, "glGetCombinerOutputParameterfvNV not found.\n");
+ return 0;
+ }
+ \rglGetCombinerOutputParameterivNV =
+ (PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC)
+ wglGetProcAddress ("glGetCombinerOutputParameterivNV");
+ \rif (glGetCombinerOutputParameterivNV == NULL) {
+ fprintf (stderr, "glGetCombinerOutputParameterivNV not found.\n");
+ return 0;
+ }
+ \rglGetFinalCombinerInputParameterfvNV =
+ (PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC)
+ wglGetProcAddress ("glGetFinalCombinerInputParameterfvNV");
+ \rif (glGetFinalCombinerInputParameterfvNV == NULL) {
+ fprintf (stderr, "glGetFinalCombinerInputParameterfvNV not found.\n");
+ return 0;
+ }
+ \rglGetFinalCombinerInputParameterivNV =
+ (PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC)
+ wglGetProcAddress ("glGetFinalCombinerInputParameterivNV");
+ \rif (glGetFinalCombinerInputParameterivNV == NULL) {
+ fprintf (stderr, "glGetFinalCombinerInputParameterivNV not found.\n");
+ return 0;
+ }
+ \r
#endif // _WIN32\r
- return 1;\r
-}\r
-\r
+ return 1;
+ \r}
+ \r\r
#endif // NV_REGISTER_COMBINERS_INITIALIZE\r
-\r
+ \r
#ifdef __cplusplus\r
-}\r
-#endif\r
+}
+
\r
+#endif /* \r */
+ \r
#endif // not __NV_REGISTER_COMBINERS_H_\r
//#include <GL/glext.h>
#include <GL/glu.h>
#include <string.h>
-#include <math.h>
+#include <math.h>
// too lazy to write an API for this ;)
#include "regcomb_yuvrgb.c"
#include "gstglsink.h"
typedef struct _GstGLImageConnection GstGLImageConnection;
-struct _GstGLImageConnection {
+struct _GstGLImageConnection
+{
GstImageConnection conn;
Display *dpy;
gint w, h;
gint bpp;
-
+
int ytex_id;
int uvtex_id;
- int septex_id;
+ int septex_id;
unsigned char *m_memory;
int m_bufslots[4];
};
struct _GstNvImage
{
GstImageData data;
- int slot; // < AGP_BUFSLOTS: allocated from AGP mem, otherwise from CPU mem
+ int slot; // < AGP_BUFSLOTS: allocated from AGP mem, otherwise from CPU mem
GstGLImageConnection *conn;
};
-static GstGLImageInfo * gst_gl_nvimage_info (GstImageInfo *info);
-static GstGLImageConnection * gst_gl_nvimage_connection (GstImageConnection *conn);
-static gboolean gst_gl_nvimage_check_xvideo ();
-
-static GstCaps * gst_gl_nvimage_get_caps (GstImageInfo *info);
-static GstImageConnection * gst_gl_nvimage_set_caps (GstImageInfo *info, GstCaps *caps);
-static GstImageData * gst_gl_nvimage_get_image (GstImageInfo *info, GstImageConnection *conn);
-static void gst_gl_nvimage_put_image (GstImageInfo *info, GstImageData *image);
-static void gst_gl_nvimage_free_image (GstImageData *image);
-static void gst_gl_nvimage_open_conn (GstImageConnection *conn, GstImageInfo *info);
-static void gst_gl_nvimage_close_conn (GstImageConnection *conn, GstImageInfo *info);
-static void gst_gl_nvimage_free_conn (GstImageConnection *conn);
-
-GstImagePlugin* get_gl_nvimage_plugin(void)
+static GstGLImageInfo *gst_gl_nvimage_info (GstImageInfo * info);
+static GstGLImageConnection *gst_gl_nvimage_connection (GstImageConnection *
+ conn);
+static gboolean gst_gl_nvimage_check_xvideo ();
+
+static GstCaps *gst_gl_nvimage_get_caps (GstImageInfo * info);
+static GstImageConnection *gst_gl_nvimage_set_caps (GstImageInfo * info,
+ GstCaps * caps);
+static GstImageData *gst_gl_nvimage_get_image (GstImageInfo * info,
+ GstImageConnection * conn);
+static void gst_gl_nvimage_put_image (GstImageInfo * info,
+ GstImageData * image);
+static void gst_gl_nvimage_free_image (GstImageData * image);
+static void gst_gl_nvimage_open_conn (GstImageConnection * conn,
+ GstImageInfo * info);
+static void gst_gl_nvimage_close_conn (GstImageConnection * conn,
+ GstImageInfo * info);
+static void gst_gl_nvimage_free_conn (GstImageConnection * conn);
+
+GstImagePlugin *
+get_gl_nvimage_plugin (void)
{
static GstImagePlugin plugin = { gst_gl_nvimage_get_caps,
- gst_gl_nvimage_set_caps,
- gst_gl_nvimage_get_image,
- gst_gl_nvimage_put_image,
- gst_gl_nvimage_free_image};
+ gst_gl_nvimage_set_caps,
+ gst_gl_nvimage_get_image,
+ gst_gl_nvimage_put_image,
+ gst_gl_nvimage_free_image
+ };
return &plugin;
}
static GstGLImageInfo *
-gst_gl_nvimage_info (GstImageInfo *info)
+gst_gl_nvimage_info (GstImageInfo * info)
{
- if (info == NULL || info->id != GST_MAKE_FOURCC ('X', 'l', 'i', 'b'))
- {
+ if (info == NULL || info->id != GST_MAKE_FOURCC ('X', 'l', 'i', 'b')) {
return NULL;
}
return (GstGLImageInfo *) info;
}
static GstGLImageConnection *
-gst_gl_nvimage_connection (GstImageConnection *conn)
+gst_gl_nvimage_connection (GstImageConnection * conn)
{
if (conn == NULL || conn->free_conn != gst_gl_nvimage_free_conn)
- return NULL;
+ return NULL;
return (GstGLImageConnection *) conn;
}
gst_gl_nvimage_check_xvideo ()
{
//int ver, rel, req, ev, err;
- printf("Checking NVidia OpenGL extensions.\n");
- if (!GL_ARB_multitexture_Init()) return FALSE;
- if (!GL_EXT_paletted_texture_Init()) return FALSE;
- if (!GL_NV_register_combiners_Init()) return FALSE;
+ printf ("Checking NVidia OpenGL extensions.\n");
+ if (!GL_ARB_multitexture_Init ())
+ return FALSE;
+ if (!GL_EXT_paletted_texture_Init ())
+ return FALSE;
+ if (!GL_NV_register_combiners_Init ())
+ return FALSE;
-#if 0
+#if 0
if (display == NULL)
return FALSE;
- if (Success == XvQueryExtension (display,&ver,&rel,&req,&ev,&err))
+ if (Success == XvQueryExtension (display, &ver, &rel, &req, &ev, &err))
return TRUE;
#endif
return TRUE;
}
-static GstCaps *
-gst_gl_nvimage_get_caps (GstImageInfo *info)
+static GstCaps *
+gst_gl_nvimage_get_caps (GstImageInfo * info)
{
//gint i;
//int adaptors;
//int formats;
GstCaps *caps = NULL;
GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
-
- g_warning("nvimage get caps called, context %p !\n", glXGetCurrentContext());
+
+ g_warning ("nvimage get caps called, context %p !\n",
+ glXGetCurrentContext ());
/* we don't handle these image information */
- if (xinfo == NULL)
- {
- printf("Invalid XInfo struct !\n");
- return NULL;
- }
+ if (xinfo == NULL) {
+ printf ("Invalid XInfo struct !\n");
+ return NULL;
+ }
- if (gst_gl_nvimage_check_xvideo () == FALSE)
- {
- g_warning("GL_NVImage: Server has no NVidia extension support\n");
+ if (gst_gl_nvimage_check_xvideo () == FALSE) {
+ g_warning ("GL_NVImage: Server has no NVidia extension support\n");
return NULL;
}
- caps = gst_caps_append (caps, GST_CAPS_NEW (
- "nvimage_caps",
- "video/x-raw-yuv",
- "format", GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y', 'V', '1', '2')),
- "width", GST_PROPS_INT_RANGE (0, 1024),
- "height", GST_PROPS_INT_RANGE (0, 1024))
- );
- g_warning("nvimage returns caps !\n");
+ caps = gst_caps_append (caps, GST_CAPS_NEW ("nvimage_caps",
+ "video/x-raw-yuv",
+ "format", GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y', 'V', '1', '2')),
+ "width", GST_PROPS_INT_RANGE (0, 1024),
+ "height", GST_PROPS_INT_RANGE (0, 1024))
+ );
+ g_warning ("nvimage returns caps !\n");
return caps;
}
static GstImageConnection *
-gst_gl_nvimage_set_caps (GstImageInfo *info, GstCaps *caps)
+gst_gl_nvimage_set_caps (GstImageInfo * info, GstCaps * caps)
{
//gint i, j = 0;
//int adaptors;
GstGLImageConnection *conn;
GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
guint32 format;
-
+
/* we don't handle these image information */
- if (xinfo == NULL) return NULL;
-
+ if (xinfo == NULL)
+ return NULL;
+
conn = g_new0 (GstGLImageConnection, 1);
conn->conn.open_conn = gst_gl_nvimage_open_conn;
conn->conn.close_conn = gst_gl_nvimage_close_conn;
conn->conn.free_conn = gst_gl_nvimage_free_conn;
- gst_caps_get (caps,
- "width", &conn->w,
- "height", &conn->h,
- "format", &format,
- NULL);
+ gst_caps_get (caps,
+ "width", &conn->w, "height", &conn->h, "format", &format, NULL);
// maybe I should a bit more checking here, e.g. maximum size smaller than maximum texture extents
- if (format != GST_MAKE_FOURCC ('Y', 'V', '1', '2'))
- {
- GST_DEBUG ("GL_NVImage: Format is invalid !\n");
- return NULL;
- }
- if (0) //conn->port == (XvPortID) -1)
+ if (format != GST_MAKE_FOURCC ('Y', 'V', '1', '2')) {
+ GST_DEBUG ("GL_NVImage: Format is invalid !\n");
+ return NULL;
+ }
+ if (0) //conn->port == (XvPortID) -1)
{
/* this happens if the plugin can't handle the caps, so no warning */
g_free (conn);
return NULL;
}
-
+
GST_DEBUG ("GL_NVImage: caps %p are ok, creating image", caps);
return (GstImageConnection *) conn;
}
static GstImageData *
-gst_gl_nvimage_get_image (GstImageInfo *info, GstImageConnection *conn)
+gst_gl_nvimage_get_image (GstImageInfo * info, GstImageConnection * conn)
{
GstNvImage *image;
- GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
- GstGLImageConnection *nvconn = gst_gl_nvimage_connection (conn);
-
+ GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
+ GstGLImageConnection *nvconn = gst_gl_nvimage_connection (conn);
+
/* checks */
- if (xinfo == NULL) return NULL;
- if (nvconn == NULL) return NULL;
+ if (xinfo == NULL)
+ return NULL;
+ if (nvconn == NULL)
+ return NULL;
// I should also check the current GLX context !
// Ah, Don't have to, I am guarantueed to be in the same thread as put_image
- image = g_new0(GstNvImage, 1);
+ image = g_new0 (GstNvImage, 1);
- image->data.size = nvconn->w * nvconn->h * 3/2;
+ image->data.size = nvconn->w * nvconn->h * 3 / 2;
//g_warning("Allocating %d bytes from main memory !", image->data.size);
- image->data.data = g_malloc(image->data.size);
+ image->data.data = g_malloc (image->data.size);
//image->slot = AGP_BUFSLOTS; // no AGP slot
image->conn = nvconn;
- if (image->data.data == NULL)
- {
+ if (image->data.data == NULL) {
g_warning ("GL_NvImage: data allocation failed!");
g_free (image);
return NULL;
return (GstImageData *) image;
}
-static void
-gst_gl_nvimage_put_image (GstImageInfo *info, GstImageData *image)
+static void
+gst_gl_nvimage_put_image (GstImageInfo * info, GstImageData * image)
{
GstNvImage *im = (GstNvImage *) image;
- GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
-
- int img_width = im->conn->w;
- int img_height = im->conn->h;
+ GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
+
+ int img_width = im->conn->w;
+ int img_height = im->conn->h;
int uv_width = img_width >> 1;
int uv_height = img_height >> 1;
-
+
unsigned char *buf_y = im->data.data;
unsigned char *buf_v = (buf_y + img_width * img_height);
- unsigned char *buf_u = buf_v + ((img_width/2) * (img_height/2));
+ unsigned char *buf_u = buf_v + ((img_width / 2) * (img_height / 2));
/* checks omitted for speed (and lazyness), do we need them? */
g_assert (xinfo != NULL);
-
+
// both upload the video, and redraw the screen
//glClearColor(0,0.5, 0.3,1.0); // a test color
- glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
+ glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glTranslatef(0.0, 0.0, -5.0);
- glDisable(GL_TEXTURE_2D);
+ glMatrixMode (GL_MODELVIEW);
+ glLoadIdentity ();
+ glTranslatef (0.0, 0.0, -5.0);
+ glDisable (GL_TEXTURE_2D);
- if (xinfo->info.demo)
- {
- //g_print("Putting image, context is %p\n", glXGetCurrentContext());
+ if (xinfo->info.demo) {
+ //g_print("Putting image, context is %p\n", glXGetCurrentContext());
- glTranslatef(0.0, 0.0, -5.0); // make it avoid the clipping plane, zoom 2.0 instead
- glRotatef(180.0*sin(xinfo->rotX),1,0,0);
- glRotatef(180.0*cos(xinfo->rotY),0,1,0);
+ glTranslatef (0.0, 0.0, -5.0); // make it avoid the clipping plane, zoom 2.0 instead
+ glRotatef (180.0 * sin (xinfo->rotX), 1, 0, 0);
+ glRotatef (180.0 * cos (xinfo->rotY), 0, 1, 0);
- xinfo->rotX += 0.01;
- xinfo->rotY -= 0.015;
- float zoom = xinfo->zoom;
- glScalef(zoom,zoom,zoom);
- //glScalef(0.1,0.1,0.1);
+ xinfo->rotX += 0.01;
+ xinfo->rotY -= 0.015;
+ float zoom = xinfo->zoom;
- if (xinfo->zoom > 2.0)
- xinfo->zoomdir = -0.01;
+ glScalef (zoom, zoom, zoom);
+ //glScalef(0.1,0.1,0.1);
- if (xinfo->zoom < 1.0)
- xinfo->zoomdir = 0.01;
+ if (xinfo->zoom > 2.0)
+ xinfo->zoomdir = -0.01;
- xinfo->zoom += xinfo->zoomdir;
- }
+ if (xinfo->zoom < 1.0)
+ xinfo->zoomdir = 0.01;
+ xinfo->zoom += xinfo->zoomdir;
+ }
//Draws the surface rectangle
- if (Ywidth != im->conn->w || Yheight != im->conn->h)
- {
- Ywidth = im->conn->w; Yheight = im->conn->h; UVwidth = im->conn->w/2; UVheight = im->conn->h/2;
- Initialize_Backend(Ywidth,Yheight,UVwidth,UVheight,GL_LINEAR);
+ if (Ywidth != im->conn->w || Yheight != im->conn->h) {
+ Ywidth = im->conn->w;
+ Yheight = im->conn->h;
+ UVwidth = im->conn->w / 2;
+ UVheight = im->conn->h / 2;
+ Initialize_Backend (Ywidth, Yheight, UVwidth, UVheight, GL_LINEAR);
}
- LoadYUVPlanes(Yhandle,Uhandle,Vhandle,img_width,img_height,uv_width,uv_height,buf_y,buf_u,buf_v);
- float xmax = (float)(im->conn->w-1)/tex_xsize;
- float ymax = (float)(im->conn->h-1)/tex_ysize;
+ LoadYUVPlanes (Yhandle, Uhandle, Vhandle, img_width, img_height, uv_width,
+ uv_height, buf_y, buf_u, buf_v);
+ float xmax = (float) (im->conn->w - 1) / tex_xsize;
+ float ymax = (float) (im->conn->h - 1) / tex_ysize;
/* Upload the texture here */
//g_warning("PUTTING IMAGE %f %f %d %d\n", xmax, ymax, tex_xsize, tex_ysize);
//glColor4f(1,1,1,1); // do NOT set a color here ! Done by Initialize_Backend, or actually SetConst !
- glBegin(GL_QUADS);
+ glBegin (GL_QUADS);
- float aspect = img_width/(float)img_height;
+ float aspect = img_width / (float) img_height;
float hor = aspect;
//g_print("Drawing vertices, context is %p\n", glXGetCurrentContext());
- glNormal3f(0, -1, 0);
- glMultiTexCoord2fARB(GL_TEXTURE0_ARB,0,0);
- glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0,0);
- glMultiTexCoord2fARB(GL_TEXTURE2_ARB,0,0);
- glVertex3f(-hor,1,0);
-
- glMultiTexCoord2fARB(GL_TEXTURE0_ARB,0,ymax);
- glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0,ymax);
- glMultiTexCoord2fARB(GL_TEXTURE2_ARB,0,ymax);
- glVertex3f(-hor,-1,0);
-
- glMultiTexCoord2fARB(GL_TEXTURE0_ARB,xmax,ymax);
- glMultiTexCoord2fARB(GL_TEXTURE1_ARB,xmax,ymax);
- glMultiTexCoord2fARB(GL_TEXTURE2_ARB,xmax,ymax);
- glVertex3f(hor,-1,0);
-
- glMultiTexCoord2fARB(GL_TEXTURE0_ARB,xmax,0);
- glMultiTexCoord2fARB(GL_TEXTURE1_ARB,xmax,0);
- glMultiTexCoord2fARB(GL_TEXTURE2_ARB,xmax,0);
- glVertex3f(hor,1,0);
-
- glEnd();
-
- if (xinfo->info.dumpvideo)
- {
- static int framenr = 0;
- char capfilename[255];
- static guint8 *cap_image_data = NULL, *cap_image_data2 = NULL;
- int i;
-
- // hmmmm, is this reentrant ?!
- if (cap_image_data == NULL)
- cap_image_data = (guint8 *)malloc(img_width * img_height * 3);
-
- if (cap_image_data2 == NULL)
- cap_image_data2 = (guint8 *)malloc(img_width * img_height * 3);
-
- printf("Recording frame #%d\n", framenr);
- glReadPixels(0,0,img_width,img_height,GL_RGB,GL_UNSIGNED_BYTE,cap_image_data);
- // invert the pixels
- for (i = 0; i < img_height; i++)
- memcpy(cap_image_data2 + i * img_width * 3, cap_image_data + (img_height-1-i) * img_width * 3, img_width*3);
-
- sprintf(capfilename, "cap%04d.ppm", framenr);
- FILE *outfile = fopen(capfilename, "wb");
- if (outfile != NULL)
- {
- fprintf(outfile, "P6\n");
- fprintf(outfile,"# created by glsink from GStreamer\n");
- fprintf(outfile,"%d %d\n",img_width,img_height);
- fprintf(outfile,"255\n");
- fwrite(cap_image_data2, sizeof(char), img_width*img_height*3, outfile);
- fclose(outfile);
- }
- framenr++;
+ glNormal3f (0, -1, 0);
+ glMultiTexCoord2fARB (GL_TEXTURE0_ARB, 0, 0);
+ glMultiTexCoord2fARB (GL_TEXTURE1_ARB, 0, 0);
+ glMultiTexCoord2fARB (GL_TEXTURE2_ARB, 0, 0);
+ glVertex3f (-hor, 1, 0);
+
+ glMultiTexCoord2fARB (GL_TEXTURE0_ARB, 0, ymax);
+ glMultiTexCoord2fARB (GL_TEXTURE1_ARB, 0, ymax);
+ glMultiTexCoord2fARB (GL_TEXTURE2_ARB, 0, ymax);
+ glVertex3f (-hor, -1, 0);
+
+ glMultiTexCoord2fARB (GL_TEXTURE0_ARB, xmax, ymax);
+ glMultiTexCoord2fARB (GL_TEXTURE1_ARB, xmax, ymax);
+ glMultiTexCoord2fARB (GL_TEXTURE2_ARB, xmax, ymax);
+ glVertex3f (hor, -1, 0);
+
+ glMultiTexCoord2fARB (GL_TEXTURE0_ARB, xmax, 0);
+ glMultiTexCoord2fARB (GL_TEXTURE1_ARB, xmax, 0);
+ glMultiTexCoord2fARB (GL_TEXTURE2_ARB, xmax, 0);
+ glVertex3f (hor, 1, 0);
+
+ glEnd ();
+
+ if (xinfo->info.dumpvideo) {
+ static int framenr = 0;
+ char capfilename[255];
+ static guint8 *cap_image_data = NULL, *cap_image_data2 = NULL;
+ int i;
+
+ // hmmmm, is this reentrant ?!
+ if (cap_image_data == NULL)
+ cap_image_data = (guint8 *) malloc (img_width * img_height * 3);
+
+ if (cap_image_data2 == NULL)
+ cap_image_data2 = (guint8 *) malloc (img_width * img_height * 3);
+
+ printf ("Recording frame #%d\n", framenr);
+ glReadPixels (0, 0, img_width, img_height, GL_RGB, GL_UNSIGNED_BYTE,
+ cap_image_data);
+ // invert the pixels
+ for (i = 0; i < img_height; i++)
+ memcpy (cap_image_data2 + i * img_width * 3,
+ cap_image_data + (img_height - 1 - i) * img_width * 3, img_width * 3);
+
+ sprintf (capfilename, "cap%04d.ppm", framenr);
+ FILE *outfile = fopen (capfilename, "wb");
+
+ if (outfile != NULL) {
+ fprintf (outfile, "P6\n");
+ fprintf (outfile, "# created by glsink from GStreamer\n");
+ fprintf (outfile, "%d %d\n", img_width, img_height);
+ fprintf (outfile, "255\n");
+ fwrite (cap_image_data2, sizeof (char), img_width * img_height * 3,
+ outfile);
+ fclose (outfile);
}
+ framenr++;
+ }
- glXSwapBuffers(xinfo->dpy, xinfo->win);
+ glXSwapBuffers (xinfo->dpy, xinfo->win);
}
-static void
-gst_gl_nvimage_free_image (GstImageData *image)
+static void
+gst_gl_nvimage_free_image (GstImageData * image)
{
GstNvImage *im = (GstNvImage *) image;
+
g_return_if_fail (im != NULL);
- GstGLImageConnection *nvconn = im->conn;
+ GstGLImageConnection *nvconn = im->conn;
- if (im->slot < AGP_BUFSLOTS)
- {
- nvconn->m_bufslots[im->slot] = 0;
- }
- else
- g_free(im->data.data);
+ if (im->slot < AGP_BUFSLOTS) {
+ nvconn->m_bufslots[im->slot] = 0;
+ } else
+ g_free (im->data.data);
g_free (im);
}
static void
-gst_gl_nvimage_open_conn (GstImageConnection *conn, GstImageInfo *info)
+gst_gl_nvimage_open_conn (GstImageConnection * conn, GstImageInfo * info)
{
//GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
//GstGLImageConnection *xconn = gst_gl_nvimage_connection (conn);
- g_print("Opening NVidia connection; OpenGL on Nvidia, using register combiners.\n");
+ g_print
+ ("Opening NVidia connection; OpenGL on Nvidia, using register combiners.\n");
{
- Ywidth = TEX_XSIZE; Yheight = TEX_YSIZE; UVwidth = TEX_XSIZE/2; UVheight = TEX_YSIZE/2;
- Initialize_Backend(Ywidth,Yheight,UVwidth,UVheight,GL_LINEAR);
+ Ywidth = TEX_XSIZE;
+ Yheight = TEX_YSIZE;
+ UVwidth = TEX_XSIZE / 2;
+ UVheight = TEX_YSIZE / 2;
+ Initialize_Backend (Ywidth, Yheight, UVwidth, UVheight, GL_LINEAR);
}
- g_print("Done\n");
+ g_print ("Done\n");
}
static void
-gst_gl_nvimage_close_conn (GstImageConnection *conn, GstImageInfo *info)
+gst_gl_nvimage_close_conn (GstImageConnection * conn, GstImageInfo * info)
{
GstGLImageConnection *xconn = gst_gl_nvimage_connection (conn);
+
//GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
// anything needed in here ? Oh, maybe drawing de-init, or something
- glDeleteTextures(1, &xconn->ytex_id);
- glDeleteTextures(1, &xconn->uvtex_id);
- glDeleteTextures(1, &xconn->septex_id);
+ glDeleteTextures (1, &xconn->ytex_id);
+ glDeleteTextures (1, &xconn->uvtex_id);
+ glDeleteTextures (1, &xconn->septex_id);
}
-static void
-gst_gl_nvimage_free_conn (GstImageConnection *conn)
+static void
+gst_gl_nvimage_free_conn (GstImageConnection * conn)
{
- GstGLImageConnection *nvconn = gst_gl_nvimage_connection (conn);
+ GstGLImageConnection *nvconn = gst_gl_nvimage_connection (conn);
g_free (nvconn);
}
-
#include "gstglsink.h"
typedef struct _GstGLImageConnection GstGLImageConnection;
-struct _GstGLImageConnection {
+struct _GstGLImageConnection
+{
GstImageConnection conn;
Display *dpy;
gint w, h;
gint bpp;
-
+
int ytex_id;
int uvtex_id;
- int septex_id;
+ int septex_id;
unsigned char *m_memory;
int m_bufslots[4];
};
struct _GstNvImage
{
GstImageData data;
- int slot; // < AGP_BUFSLOTS: allocated from AGP mem, otherwise from CPU mem
+ int slot; // < AGP_BUFSLOTS: allocated from AGP mem, otherwise from CPU mem
GstGLImageConnection *conn;
};
-static GstGLImageInfo * gst_gl_nvimage_info (GstImageInfo *info);
-static GstGLImageConnection * gst_gl_nvimage_connection (GstImageConnection *conn);
-static gboolean gst_gl_nvimage_check_xvideo ();
-
-static GstCaps * gst_gl_nvimage_get_caps (GstImageInfo *info);
-static GstImageConnection * gst_gl_nvimage_set_caps (GstImageInfo *info, GstCaps *caps);
-static GstImageData * gst_gl_nvimage_get_image (GstImageInfo *info, GstImageConnection *conn);
-static void gst_gl_nvimage_put_image (GstImageInfo *info, GstImageData *image);
-static void gst_gl_nvimage_free_image (GstImageData *image);
-static void gst_gl_nvimage_open_conn (GstImageConnection *conn, GstImageInfo *info);
-static void gst_gl_nvimage_close_conn (GstImageConnection *conn, GstImageInfo *info);
-static void gst_gl_nvimage_free_conn (GstImageConnection *conn);
-
-GstImagePlugin* get_gl_nvimage_plugin(void)
+static GstGLImageInfo *gst_gl_nvimage_info (GstImageInfo * info);
+static GstGLImageConnection *gst_gl_nvimage_connection (GstImageConnection *
+ conn);
+static gboolean gst_gl_nvimage_check_xvideo ();
+
+static GstCaps *gst_gl_nvimage_get_caps (GstImageInfo * info);
+static GstImageConnection *gst_gl_nvimage_set_caps (GstImageInfo * info,
+ GstCaps * caps);
+static GstImageData *gst_gl_nvimage_get_image (GstImageInfo * info,
+ GstImageConnection * conn);
+static void gst_gl_nvimage_put_image (GstImageInfo * info,
+ GstImageData * image);
+static void gst_gl_nvimage_free_image (GstImageData * image);
+static void gst_gl_nvimage_open_conn (GstImageConnection * conn,
+ GstImageInfo * info);
+static void gst_gl_nvimage_close_conn (GstImageConnection * conn,
+ GstImageInfo * info);
+static void gst_gl_nvimage_free_conn (GstImageConnection * conn);
+
+GstImagePlugin *
+get_gl_nvimage_plugin (void)
{
static GstImagePlugin plugin = { gst_gl_nvimage_get_caps,
- gst_gl_nvimage_set_caps,
- gst_gl_nvimage_get_image,
- gst_gl_nvimage_put_image,
- gst_gl_nvimage_free_image};
+ gst_gl_nvimage_set_caps,
+ gst_gl_nvimage_get_image,
+ gst_gl_nvimage_put_image,
+ gst_gl_nvimage_free_image
+ };
return &plugin;
}
static GstGLImageInfo *
-gst_gl_nvimage_info (GstImageInfo *info)
+gst_gl_nvimage_info (GstImageInfo * info)
{
- if (info == NULL || info->id != GST_MAKE_FOURCC ('X', 'l', 'i', 'b'))
- {
+ if (info == NULL || info->id != GST_MAKE_FOURCC ('X', 'l', 'i', 'b')) {
return NULL;
}
return (GstGLImageInfo *) info;
}
static GstGLImageConnection *
-gst_gl_nvimage_connection (GstImageConnection *conn)
+gst_gl_nvimage_connection (GstImageConnection * conn)
{
if (conn == NULL || conn->free_conn != gst_gl_nvimage_free_conn)
- return NULL;
+ return NULL;
return (GstGLImageConnection *) conn;
}
gst_gl_nvimage_check_xvideo ()
{
int ver, rel, req, ev, err;
-
-#if 0
+
+#if 0
if (display == NULL)
return FALSE;
- if (Success == XvQueryExtension (display,&ver,&rel,&req,&ev,&err))
+ if (Success == XvQueryExtension (display, &ver, &rel, &req, &ev, &err))
return TRUE;
#endif
return FALSE;
}
-static GstCaps *
-gst_gl_nvimage_get_caps (GstImageInfo *info)
+static GstCaps *
+gst_gl_nvimage_get_caps (GstImageInfo * info)
{
gint i;
int adaptors;
int formats;
GstCaps *caps = NULL;
GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
-
+
/* we don't handle these image information */
- if (xinfo == NULL) return NULL;
+ if (xinfo == NULL)
+ return NULL;
- if (gst_gl_nvimage_check_xvideo () == FALSE)
- {
- g_warning("GL_NVImage: Server has no NVidia extension support\n");
+ if (gst_gl_nvimage_check_xvideo () == FALSE) {
+ g_warning ("GL_NVImage: Server has no NVidia extension support\n");
return NULL;
}
- caps = gst_caps_append (caps, GST_CAPS_NEW (
- "xvimage_caps",
- "video/raw",
- "format", GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y', 'C', '1', '2')),
- "width", GST_PROPS_INT_RANGE (0, 1024),
- "height", GST_PROPS_INT_RANGE (0, 1024))
- );
+ caps = gst_caps_append (caps, GST_CAPS_NEW ("xvimage_caps",
+ "video/raw",
+ "format", GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y', 'C', '1', '2')),
+ "width", GST_PROPS_INT_RANGE (0, 1024),
+ "height", GST_PROPS_INT_RANGE (0, 1024))
+ );
return caps;
}
static GstImageConnection *
-gst_gl_nvimage_set_caps (GstImageInfo *info, GstCaps *caps)
+gst_gl_nvimage_set_caps (GstImageInfo * info, GstCaps * caps)
{
gint i, j = 0;
int adaptors;
GstGLImageConnection *conn;
GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
guint32 format;
-
+
/* we don't handle these image information */
- if (xinfo == NULL) return NULL;
-
+ if (xinfo == NULL)
+ return NULL;
+
conn = g_new0 (GstGLImageConnection, 1);
conn->conn.open_conn = gst_gl_nvimage_open_conn;
conn->conn.close_conn = gst_gl_nvimage_close_conn;
conn->conn.free_conn = gst_gl_nvimage_free_conn;
- gst_caps_get (caps,
- "width", &conn->w,
- "height", &conn->h,
- "format", &format,
- NULL);
+ gst_caps_get (caps,
+ "width", &conn->w, "height", &conn->h, "format", &format, NULL);
// maybe I should a bit more checking here, e.g. maximum size smaller than maximum texture extents
- if (format != GST_MAKE_FOURCC ('R', 'G', 'B', ' '))
- {
- GST_DEBUG (GST_CAT_PLUGIN_INFO, "GL_NVImage: Format is invalid !\n");
- return NULL;
- }
- if (0) //conn->port == (XvPortID) -1)
+ if (format != GST_MAKE_FOURCC ('R', 'G', 'B', ' ')) {
+ GST_DEBUG (GST_CAT_PLUGIN_INFO, "GL_NVImage: Format is invalid !\n");
+ return NULL;
+ }
+ if (0) //conn->port == (XvPortID) -1)
{
/* this happens if the plugin can't handle the caps, so no warning */
g_free (conn);
return NULL;
}
-
- GST_DEBUG (GST_CAT_PLUGIN_INFO, "GL_NVImage: caps %p are ok, creating image", caps);
+
+ GST_DEBUG (GST_CAT_PLUGIN_INFO, "GL_NVImage: caps %p are ok, creating image",
+ caps);
return (GstImageConnection *) conn;
}
static GstImageData *
-gst_gl_nvimage_get_image (GstImageInfo *info, GstImageConnection *conn)
+gst_gl_nvimage_get_image (GstImageInfo * info, GstImageConnection * conn)
{
GstNvImage *image;
- GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
- GstGLImageConnection *nvconn = gst_gl_nvimage_connection (conn);
+ GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
+ GstGLImageConnection *nvconn = gst_gl_nvimage_connection (conn);
int slot = 0;
-
+
/* checks */
- if (xinfo == NULL) return NULL;
- if (nvconn == NULL) return NULL;
+ if (xinfo == NULL)
+ return NULL;
+ if (nvconn == NULL)
+ return NULL;
// I should also check the current GLX context !
// Ah, Don't have to, I am guarantueed to always be in the same thread
- image = g_new0(GstNvImage, 1);
-
- for (slot = 0; slot < AGP_BUFSLOTS; slot++)
- {
- if (!nvconn->m_bufslots[slot]) break;
- }
-
- image->data.size = nvconn->w * nvconn->h * 3/2;
-
- if (slot < AGP_BUFSLOTS) // found an AGP buffer slot
- {
- image->data.data = nvconn->m_memory + slot * YUVTEX_SIZE;
- image->slot = slot; // store for freeing
- nvconn->m_bufslots[slot] = 1; // it is now taken
- }
- else
- {
- g_warning("Allocating from main memory !");
- image->data.data = g_malloc(image->data.size);
- image->slot = AGP_BUFSLOTS; // no AGP slot
- }
- image->conn = nvconn;
+ image = g_new0 (GstNvImage, 1);
- if (image->data.data == NULL)
+ for (slot = 0; slot < AGP_BUFSLOTS; slot++) {
+ if (!nvconn->m_bufslots[slot])
+ break;
+ }
+
+ image->data.size = nvconn->w * nvconn->h * 3 / 2;
+
+ if (slot < AGP_BUFSLOTS) // found an AGP buffer slot
{
+ image->data.data = nvconn->m_memory + slot * YUVTEX_SIZE;
+ image->slot = slot; // store for freeing
+ nvconn->m_bufslots[slot] = 1; // it is now taken
+ } else {
+ g_warning ("Allocating from main memory !");
+ image->data.data = g_malloc (image->data.size);
+ image->slot = AGP_BUFSLOTS; // no AGP slot
+ }
+ image->conn = nvconn;
+
+ if (image->data.data == NULL) {
g_warning ("GL_NvImage: data allocation failed!");
g_free (image);
return NULL;
return (GstImageData *) image;
}
-static void
-gst_gl_nvimage_put_image (GstImageInfo *info, GstImageData *image)
+static void
+gst_gl_nvimage_put_image (GstImageInfo * info, GstImageData * image)
{
GstNvImage *im = (GstNvImage *) image;
- GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
-
+ GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
+
/* checks omitted for speed (and lazyness), do we need them? */
g_assert (xinfo != NULL);
-
+
/* Upload the texture here */
- g_warning("PUTTING IMAGE - BROOOKEN");
+ g_warning ("PUTTING IMAGE - BROOOKEN");
// both upload the video, and redraw the screen
- glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
+ glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glEnable(GL_TEXTURE_2D);
+ glEnable (GL_TEXTURE_2D);
- glPushMatrix();
+ glPushMatrix ();
//glTranslatef(0,1,0);
- glRotatef(xinfo->rotX-250,1,0,0);
- glRotatef(xinfo->rotY,0,1,0);
+ glRotatef (xinfo->rotX - 250, 1, 0, 0);
+ glRotatef (xinfo->rotY, 0, 1, 0);
int zoom = xinfo->zoom;
- glScaled(zoom,zoom,zoom);
+
+ glScaled (zoom, zoom, zoom);
//Draws the surface rectangle
- glBindTexture(GL_TEXTURE_2D, im->conn->ytex_id);
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, im->conn->w, im->conn->h, GL_RGBA,
- GL_UNSIGNED_BYTE, im->data.data);
- float xmax = (float)im->conn->w/TEX_XSIZE;
- float ymax = (float)im->conn->h/TEX_YSIZE;
+ glBindTexture (GL_TEXTURE_2D, im->conn->ytex_id);
+ glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, im->conn->w, im->conn->h, GL_RGBA,
+ GL_UNSIGNED_BYTE, im->data.data);
+ float xmax = (float) im->conn->w / TEX_XSIZE;
+ float ymax = (float) im->conn->h / TEX_YSIZE;
+
+ glColor4f (1, 1, 1, 1);
+ glBegin (GL_QUADS);
- glColor4f(1,1,1,1);
- glBegin(GL_QUADS);
+ glNormal3f (0, -1, 0);
- glNormal3f(0, -1, 0);
-
- glTexCoord2f(xmax, 0);
- glVertex3f(4,0,-4);
+ glTexCoord2f (xmax, 0);
+ glVertex3f (4, 0, -4);
- glTexCoord2f(0, 0);
- glVertex3f(-4,0,-4);
+ glTexCoord2f (0, 0);
+ glVertex3f (-4, 0, -4);
- glTexCoord2f(0, ymax);
- glVertex3f(-4,0,4);
+ glTexCoord2f (0, ymax);
+ glVertex3f (-4, 0, 4);
- glTexCoord2f(xmax, ymax);
- glVertex3f(4,0,4);
+ glTexCoord2f (xmax, ymax);
+ glVertex3f (4, 0, 4);
- glEnd();
+ glEnd ();
- glPopMatrix();
+ glPopMatrix ();
- glXSwapBuffers(xinfo->dpy, xinfo->win);
+ glXSwapBuffers (xinfo->dpy, xinfo->win);
}
-static void
-gst_gl_nvimage_free_image (GstImageData *image)
+static void
+gst_gl_nvimage_free_image (GstImageData * image)
{
GstNvImage *im = (GstNvImage *) image;
+
g_return_if_fail (im != NULL);
- GstGLImageConnection *nvconn = im->conn;
+ GstGLImageConnection *nvconn = im->conn;
- if (im->slot < AGP_BUFSLOTS)
- {
- nvconn->m_bufslots[im->slot] = 0;
- }
- else
- g_free(im->data.data);
+ if (im->slot < AGP_BUFSLOTS) {
+ nvconn->m_bufslots[im->slot] = 0;
+ } else
+ g_free (im->data.data);
g_free (im);
}
static void
-gst_gl_nvimage_open_conn (GstImageConnection *conn, GstImageInfo *info)
+gst_gl_nvimage_open_conn (GstImageConnection * conn, GstImageInfo * info)
{
- GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
+ GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
GstGLImageConnection *xconn = gst_gl_nvimage_connection (conn);
- unsigned char data_sep[2][2] = {{0, 255}, {0, 255}};
+ unsigned char data_sep[2][2] = { {0, 255}, {0, 255} };
int slot;
- g_warning("Opening NVidia Connection");
- xconn->m_memory = (unsigned char*)glXAllocateMemoryNV(AGP_BUFSLOTS*YUVTEX_SIZE, 0, 1.0, 1.0);
-
- if (!xconn->m_memory)
- {
- printf("Unable to acquire graphics card mem... will acquire in normal memory.\n");
- for (slot = 0; slot < AGP_BUFSLOTS; slot++)
- xconn->m_bufslots[slot] = 1;
- }
- else
- {
- // maybe this fast writable memory, awfully slow to read from, though
- glPixelDataRangeNV(GL_WRITE_PIXEL_DATA_RANGE_NV, AGP_BUFSLOTS*YUVTEX_SIZE, xconn->m_memory);
- glEnableClientState(GL_WRITE_PIXEL_DATA_RANGE_NV);
-
- for (slot = 0; slot < AGP_BUFSLOTS; slot++)
- xconn->m_bufslots[slot] = 0;
- }
-
- glGenTextures(1, &xconn->ytex_id);
- glBindTexture(GL_TEXTURE_2D, xconn->ytex_id);
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE8_ALPHA8, TEX_XSIZE, TEX_YSIZE, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, NULL);
-
- glActiveTextureARB(GL_TEXTURE1_ARB);
- glGenTextures(1, &xconn->uvtex_id);
- glBindTexture(GL_TEXTURE_2D, xconn->uvtex_id);
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE8_ALPHA8, TEX_XSIZE/2, TEX_YSIZE/2, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, NULL);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD);
-
- glActiveTextureARB(GL_TEXTURE2_ARB);
- glGenTextures(1, &xconn->septex_id);
- glBindTexture(GL_TEXTURE_2D, xconn->septex_id);
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE8, 2, 2, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, data_sep);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD);
-
- glFlushPixelDataRangeNV(GL_WRITE_PIXEL_DATA_RANGE_NV);
+ g_warning ("Opening NVidia Connection");
+ xconn->m_memory =
+ (unsigned char *) glXAllocateMemoryNV (AGP_BUFSLOTS * YUVTEX_SIZE, 0, 1.0,
+ 1.0);
+
+ if (!xconn->m_memory) {
+ printf
+ ("Unable to acquire graphics card mem... will acquire in normal memory.\n");
+ for (slot = 0; slot < AGP_BUFSLOTS; slot++)
+ xconn->m_bufslots[slot] = 1;
+ } else {
+ // maybe this fast writable memory, awfully slow to read from, though
+ glPixelDataRangeNV (GL_WRITE_PIXEL_DATA_RANGE_NV,
+ AGP_BUFSLOTS * YUVTEX_SIZE, xconn->m_memory);
+ glEnableClientState (GL_WRITE_PIXEL_DATA_RANGE_NV);
+
+ for (slot = 0; slot < AGP_BUFSLOTS; slot++)
+ xconn->m_bufslots[slot] = 0;
+ }
+
+ glGenTextures (1, &xconn->ytex_id);
+ glBindTexture (GL_TEXTURE_2D, xconn->ytex_id);
+ glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+ glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ glTexImage2D (GL_TEXTURE_2D, 0, GL_LUMINANCE8_ALPHA8, TEX_XSIZE, TEX_YSIZE, 0,
+ GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, NULL);
+
+ glActiveTextureARB (GL_TEXTURE1_ARB);
+ glGenTextures (1, &xconn->uvtex_id);
+ glBindTexture (GL_TEXTURE_2D, xconn->uvtex_id);
+ glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
+ glTexImage2D (GL_TEXTURE_2D, 0, GL_LUMINANCE8_ALPHA8, TEX_XSIZE / 2,
+ TEX_YSIZE / 2, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, NULL);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+ glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD);
+
+ glActiveTextureARB (GL_TEXTURE2_ARB);
+ glGenTextures (1, &xconn->septex_id);
+ glBindTexture (GL_TEXTURE_2D, xconn->septex_id);
+ glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
+ glTexImage2D (GL_TEXTURE_2D, 0, GL_LUMINANCE8, 2, 2, 0, GL_LUMINANCE,
+ GL_UNSIGNED_BYTE, data_sep);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+ glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD);
+
+ glFlushPixelDataRangeNV (GL_WRITE_PIXEL_DATA_RANGE_NV);
//glEnable(GL_TEXTURE_2D);
- glActiveTextureARB(GL_TEXTURE0_ARB);
- glEnable(GL_TEXTURE_2D);
- glActiveTextureARB(GL_TEXTURE1_ARB);
- glEnable(GL_TEXTURE_2D);
- glActiveTextureARB(GL_TEXTURE2_ARB);
- glEnable(GL_TEXTURE_2D);
- glActiveTextureARB(GL_TEXTURE0_ARB);
+ glActiveTextureARB (GL_TEXTURE0_ARB);
+ glEnable (GL_TEXTURE_2D);
+ glActiveTextureARB (GL_TEXTURE1_ARB);
+ glEnable (GL_TEXTURE_2D);
+ glActiveTextureARB (GL_TEXTURE2_ARB);
+ glEnable (GL_TEXTURE_2D);
+ glActiveTextureARB (GL_TEXTURE0_ARB);
}
static void
-gst_gl_nvimage_close_conn (GstImageConnection *conn, GstImageInfo *info)
+gst_gl_nvimage_close_conn (GstImageConnection * conn, GstImageInfo * info)
{
GstGLImageConnection *xconn = gst_gl_nvimage_connection (conn);
- GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
+ GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
// anything needed in here ? Oh, maybe drawing de-init, or something
- glDeleteTextures(1, &xconn->ytex_id);
- glDeleteTextures(1, &xconn->uvtex_id);
- glDeleteTextures(1, &xconn->septex_id);
+ glDeleteTextures (1, &xconn->ytex_id);
+ glDeleteTextures (1, &xconn->uvtex_id);
+ glDeleteTextures (1, &xconn->septex_id);
}
-static void
-gst_gl_nvimage_free_conn (GstImageConnection *conn)
+static void
+gst_gl_nvimage_free_conn (GstImageConnection * conn)
{
- GstGLImageConnection *nvconn = gst_gl_nvimage_connection (conn);
+ GstGLImageConnection *nvconn = gst_gl_nvimage_connection (conn);
g_free (nvconn);
}
-
#include <GL/glx.h>
#include <GL/gl.h>
#include <GL/glu.h>
-#include <math.h>
+#include <math.h>
#include "gstglsink.h"
typedef struct _GstGLImageConnection GstGLImageConnection;
// this contains everything to draw an image, including all necessary graphics card data.
-struct _GstGLImageConnection {
+struct _GstGLImageConnection
+{
GstImageConnection conn;
- Display *dpy; // the Xlib drawing context
- GLXContext ctx; // The GLX drawing context
+ Display *dpy; // the Xlib drawing context
+ GLXContext ctx; // The GLX drawing context
gint w, h;
gint bpp;
-
+
int rgbatex_id;
unsigned char *m_memory;
};
GstGLImageConnection *conn;
};
-static GstGLImageInfo * gst_gl_rgbimage_info (GstImageInfo *info);
-static GstGLImageConnection * gst_gl_rgbimage_connection (GstImageConnection *conn);
-
-static GstCaps * gst_gl_rgbimage_get_caps (GstImageInfo *info);
-static GstImageConnection * gst_gl_rgbimage_set_caps (GstImageInfo *info, GstCaps *caps);
-static GstImageData * gst_gl_rgbimage_get_image (GstImageInfo *info, GstImageConnection *conn);
-static void gst_gl_rgbimage_put_image (GstImageInfo *info, GstImageData *image);
-static void gst_gl_rgbimage_free_image (GstImageData *image);
-static void gst_gl_rgbimage_open_conn (GstImageConnection *conn, GstImageInfo *info);
-static void gst_gl_rgbimage_close_conn (GstImageConnection *conn, GstImageInfo *info);
-static void gst_gl_rgbimage_free_conn (GstImageConnection *conn);
-
-GstImagePlugin* get_gl_rgbimage_plugin(void)
+static GstGLImageInfo *gst_gl_rgbimage_info (GstImageInfo * info);
+static GstGLImageConnection *gst_gl_rgbimage_connection (GstImageConnection *
+ conn);
+
+static GstCaps *gst_gl_rgbimage_get_caps (GstImageInfo * info);
+static GstImageConnection *gst_gl_rgbimage_set_caps (GstImageInfo * info,
+ GstCaps * caps);
+static GstImageData *gst_gl_rgbimage_get_image (GstImageInfo * info,
+ GstImageConnection * conn);
+static void gst_gl_rgbimage_put_image (GstImageInfo * info,
+ GstImageData * image);
+static void gst_gl_rgbimage_free_image (GstImageData * image);
+static void gst_gl_rgbimage_open_conn (GstImageConnection * conn,
+ GstImageInfo * info);
+static void gst_gl_rgbimage_close_conn (GstImageConnection * conn,
+ GstImageInfo * info);
+static void gst_gl_rgbimage_free_conn (GstImageConnection * conn);
+
+GstImagePlugin *
+get_gl_rgbimage_plugin (void)
{
static GstImagePlugin plugin = { gst_gl_rgbimage_get_caps,
- gst_gl_rgbimage_set_caps,
- gst_gl_rgbimage_get_image,
- gst_gl_rgbimage_put_image,
- gst_gl_rgbimage_free_image};
+ gst_gl_rgbimage_set_caps,
+ gst_gl_rgbimage_get_image,
+ gst_gl_rgbimage_put_image,
+ gst_gl_rgbimage_free_image
+ };
return &plugin;
}
static GstGLImageInfo *
-gst_gl_rgbimage_info (GstImageInfo *info)
+gst_gl_rgbimage_info (GstImageInfo * info)
{
- if (info == NULL || info->id != GST_MAKE_FOURCC ('X', 'l', 'i', 'b'))
- {
+ if (info == NULL || info->id != GST_MAKE_FOURCC ('X', 'l', 'i', 'b')) {
return NULL;
}
return (GstGLImageInfo *) info;
}
static GstGLImageConnection *
-gst_gl_rgbimage_connection (GstImageConnection *conn)
+gst_gl_rgbimage_connection (GstImageConnection * conn)
{
if (conn == NULL || conn->free_conn != gst_gl_rgbimage_free_conn)
- return NULL;
+ return NULL;
return (GstGLImageConnection *) conn;
}
GstCaps *
-gst_gl_rgbimage_get_caps (GstImageInfo *info)
+gst_gl_rgbimage_get_caps (GstImageInfo * info)
{
GstCaps *caps = NULL;
Visual *visual;
XWindowAttributes attrib;
XImage *ximage;
GstGLImageInfo *xinfo = gst_gl_rgbimage_info (info);
-
- g_warning("rgbimage get caps called, context %p, endianness %d !\n", glXGetCurrentContext(), G_BIG_ENDIAN);
+
+ g_warning ("rgbimage get caps called, context %p, endianness %d !\n",
+ glXGetCurrentContext (), G_BIG_ENDIAN);
/* we don't handle this image information */
- if (xinfo == NULL) return NULL;
+ if (xinfo == NULL)
+ return NULL;
+
+ XGetWindowAttributes (xinfo->dpy, xinfo->win, &attrib);
- XGetWindowAttributes(xinfo->dpy, xinfo->win, &attrib);
-
visual = attrib.visual;
if (attrib.depth <= 8)
xpad = 8;
xpad = 16;
else
xpad = 32;
-
+
// create a temporary image
- ximage = XCreateImage (xinfo->dpy, visual, attrib.depth, ZPixmap, 0, NULL,
- 100, 100, xpad, (attrib.depth + 7) / 8 * 100);
+ ximage = XCreateImage (xinfo->dpy, visual, attrib.depth, ZPixmap, 0, NULL,
+ 100, 100, xpad, (attrib.depth + 7) / 8 * 100);
if (ximage != NULL) {
- caps =
- GST_CAPS_NEW (
- "forcing Video RGB",
- "video/x-raw-rgb",
- "format", GST_PROPS_FOURCC (GST_STR_FOURCC ("RGB ")),
- "depth", GST_PROPS_INT(24),
- "bpp", GST_PROPS_INT(24),
- "red_mask", GST_PROPS_INT(0xff),
- "green_mask", GST_PROPS_INT(0xff00),
- "blue_mask", GST_PROPS_INT(0xff0000),
- "endianness", GST_PROPS_INT(G_BIG_ENDIAN), /*= 1234/4321 (INT) <- endianness */
-
- "width", GST_PROPS_INT_RANGE (0, TEX_XSIZE), /* can't have videos larger than TEX_SIZE */
- "height", GST_PROPS_INT_RANGE (0, TEX_YSIZE)
- );
+ caps =
+ GST_CAPS_NEW ("forcing Video RGB", "video/x-raw-rgb", "format",
+ GST_PROPS_FOURCC (GST_STR_FOURCC ("RGB ")), "depth", GST_PROPS_INT (24),
+ "bpp", GST_PROPS_INT (24), "red_mask", GST_PROPS_INT (0xff),
+ "green_mask", GST_PROPS_INT (0xff00), "blue_mask",
+ GST_PROPS_INT (0xff0000), "endianness", GST_PROPS_INT (G_BIG_ENDIAN),
+ /*= 1234/4321 (INT) <- endianness */
+ "width", GST_PROPS_INT_RANGE (0, TEX_XSIZE), /* can't have videos larger than TEX_SIZE */
+ "height", GST_PROPS_INT_RANGE (0, TEX_YSIZE)
+ );
XDestroyImage (ximage);
}
-
+
printf ("GL_RGBImage: returning caps at %p", caps);
return caps;
}
-static GstImageConnection *
-gst_gl_rgbimage_set_caps (GstImageInfo *info, GstCaps *caps)
+static GstImageConnection *
+gst_gl_rgbimage_set_caps (GstImageInfo * info, GstCaps * caps)
{
- g_warning("in set_caps !\n");
+ g_warning ("in set_caps !\n");
GstGLImageConnection *new = NULL;
Visual *visual;
XWindowAttributes attrib;
- GstGLImageInfo *xinfo = gst_gl_rgbimage_info (info);
+ GstGLImageInfo *xinfo = gst_gl_rgbimage_info (info);
guint32 format;
gint depth;
gint endianness;
gint width, height, bpp;
/* check if this is the right image info */
- if (xinfo == NULL) return NULL;
-
- XGetWindowAttributes(xinfo->dpy, xinfo->win, &attrib);
-
+ if (xinfo == NULL)
+ return NULL;
+
+ XGetWindowAttributes (xinfo->dpy, xinfo->win, &attrib);
+
visual = attrib.visual;
gst_caps_get (caps,
- "format", &format,
- "depth", &depth,
- "endianness", &endianness,
- "red_mask", &red_mask,
- "green_mask", &green_mask,
- "blue_mask", &blue_mask,
- "width", &width,
- "height", &height,
- "bpp", &bpp,
- NULL);
-
+ "format", &format,
+ "depth", &depth,
+ "endianness", &endianness,
+ "red_mask", &red_mask,
+ "green_mask", &green_mask,
+ "blue_mask", &blue_mask,
+ "width", &width, "height", &height, "bpp", &bpp, NULL);
+
/* check if the caps are ok */
- if (format != GST_MAKE_FOURCC ('R', 'G', 'B', ' ')) return NULL;
+ if (format != GST_MAKE_FOURCC ('R', 'G', 'B', ' '))
+ return NULL;
/* if (gst_caps_get_int (caps, "bpp") != ???) return NULL; */
//if (depth != attrib.depth) return NULL;
//if (endianness != ((ImageByteOrder (xinfo->dpy) == LSBFirst) ? G_LITTLE_ENDIAN : G_BIG_ENDIAN)) return NULL;
//if (green_mask != visual->green_mask) return NULL;
//if (blue_mask != visual->blue_mask) return NULL;
GST_DEBUG ("GL_RGBImage: caps %p are ok, creating image", caps);
-
+
new = g_new (GstGLImageConnection, 1);
new->conn.open_conn = gst_gl_rgbimage_open_conn;
new->conn.close_conn = gst_gl_rgbimage_close_conn;
new->w = width;
new->h = height;
new->bpp = bpp;
-
+
return (GstImageConnection *) new;
}
static GstImageData *
-gst_gl_rgbimage_get_image (GstImageInfo *info, GstImageConnection *conn)
+gst_gl_rgbimage_get_image (GstImageInfo * info, GstImageConnection * conn)
{
GstGLImage *image;
+
//XWindowAttributes attrib;
- GstGLImageInfo *xinfo = gst_gl_rgbimage_info (info);
- GstGLImageConnection *xconn = gst_gl_rgbimage_connection (conn);
-
+ GstGLImageInfo *xinfo = gst_gl_rgbimage_info (info);
+ GstGLImageConnection *xconn = gst_gl_rgbimage_connection (conn);
+
image = g_new (GstGLImage, 1);
/* checks */
- if (xinfo == NULL) return NULL;
- if (xconn == NULL) return NULL;
- if (xinfo->dpy != xconn->dpy)
- {
+ if (xinfo == NULL)
+ return NULL;
+ if (xconn == NULL)
+ return NULL;
+ if (xinfo->dpy != xconn->dpy) {
g_warning ("XImage: wrong x display specified in 'get_image'\n");
return NULL;
}
image->conn = xconn;
image->data.size = xconn->w * xconn->h * 4;
- image->data.data = g_malloc(image->data.size);
- if (image->data.data == NULL)
- {
+ image->data.data = g_malloc (image->data.size);
+ if (image->data.data == NULL) {
g_warning ("GL_RGBImage: data allocation failed!");
g_free (image);
return NULL;
static void
-gst_gl_rgbimage_put_image (GstImageInfo *info, GstImageData *image)
+gst_gl_rgbimage_put_image (GstImageInfo * info, GstImageData * image)
{
float xmax, ymax;
GstGLImageInfo *xinfo = gst_gl_rgbimage_info (info);
GstGLImage *im = (GstGLImage *) image;
- int img_width = im->conn->w;
- int img_height = im->conn->h;
+ int img_width = im->conn->w;
+ int img_height = im->conn->h;
g_assert (xinfo != NULL);
// both upload the video, and redraw the screen
- glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
+ glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glTranslatef(0.0, 0.0, -5.0);
+ glMatrixMode (GL_MODELVIEW);
+ glLoadIdentity ();
+ glTranslatef (0.0, 0.0, -5.0);
- glEnable(GL_TEXTURE_2D);
+ glEnable (GL_TEXTURE_2D);
- if (xinfo->info.demo)
- {
- glTranslatef(0.0, 0.0, -5.0); // make it avoid the clipping plane, zoom 2.0 instead
- glRotatef(180.0*sin(xinfo->rotX),1,0,0);
- glRotatef(180.0*cos(xinfo->rotY),0,1,0);
+ if (xinfo->info.demo) {
+ glTranslatef (0.0, 0.0, -5.0); // make it avoid the clipping plane, zoom 2.0 instead
+ glRotatef (180.0 * sin (xinfo->rotX), 1, 0, 0);
+ glRotatef (180.0 * cos (xinfo->rotY), 0, 1, 0);
- xinfo->rotX += 0.01;
- xinfo->rotY -= 0.015;
- float zoom = xinfo->zoom;
- glScalef(zoom,zoom,zoom);
+ xinfo->rotX += 0.01;
+ xinfo->rotY -= 0.015;
+ float zoom = xinfo->zoom;
- if (xinfo->zoom > 2.0)
- xinfo->zoomdir = -0.01;
+ glScalef (zoom, zoom, zoom);
- if (xinfo->zoom < 1.0)
- xinfo->zoomdir = 0.01;
+ if (xinfo->zoom > 2.0)
+ xinfo->zoomdir = -0.01;
- xinfo->zoom += xinfo->zoomdir;
- }
+ if (xinfo->zoom < 1.0)
+ xinfo->zoomdir = 0.01;
+ xinfo->zoom += xinfo->zoomdir;
+ }
//Draws the surface rectangle
- glBindTexture(GL_TEXTURE_2D, im->conn->rgbatex_id);
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, im->conn->w, im->conn->h, GL_RGB,
- GL_UNSIGNED_BYTE, im->data.data);
- xmax = (float)im->conn->w/TEX_XSIZE;
- ymax = (float)im->conn->h/TEX_YSIZE;
+ glBindTexture (GL_TEXTURE_2D, im->conn->rgbatex_id);
+ glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, im->conn->w, im->conn->h, GL_RGB,
+ GL_UNSIGNED_BYTE, im->data.data);
+ xmax = (float) im->conn->w / TEX_XSIZE;
+ ymax = (float) im->conn->h / TEX_YSIZE;
- float aspect = img_width/(float)img_height;
+ float aspect = img_width / (float) img_height;
float hor = aspect;
- glColor4f(1,1,1,1);
- glBegin(GL_QUADS);
-
- glNormal3f(0, -1, 0);
-
- glTexCoord2f(xmax, 0);
- glVertex3f(hor,1,0);
-
- glTexCoord2f(0, 0);
- glVertex3f(-hor,1,0);
-
- glTexCoord2f(0, ymax);
- glVertex3f(-hor,-1,0);
-
- glTexCoord2f(xmax, ymax);
- glVertex3f(hor,-1,0);
- glEnd();
-
- if (xinfo->info.dumpvideo)
- {
- static int framenr = 0;
- char capfilename[255];
- static guint8 *cap_image_data = NULL, *cap_image_data2 = NULL;
- int i;
-
- // hmmmm, is this reentrant ?!
- if (cap_image_data == NULL)
- cap_image_data = (guint8 *)malloc(img_width * img_height * 3);
-
- if (cap_image_data2 == NULL)
- cap_image_data2 = (guint8 *)malloc(img_width * img_height * 3);
-
- printf("Recording frame #%d\n", framenr);
- glReadPixels(0,0,img_width,img_height,GL_RGB,GL_UNSIGNED_BYTE,cap_image_data);
- // invert the pixels
- for (i = 0; i < img_height; i++)
- memcpy(cap_image_data2 + i * img_width * 3, cap_image_data + (img_height-1-i) * img_width * 3, img_width*3);
-
- sprintf(capfilename, "cap%04d.ppm", framenr);
- FILE *outfile = fopen(capfilename, "wb");
- if (outfile != NULL)
- {
- fprintf(outfile, "P6\n");
- fprintf(outfile,"# created by raw_zb\n");
- fprintf(outfile,"%d %d\n",img_width,img_height);
- fprintf(outfile,"255\n");
- fwrite(cap_image_data2, sizeof(char), img_width*img_height*3, outfile);
- fclose(outfile);
- }
- framenr++;
+ glColor4f (1, 1, 1, 1);
+ glBegin (GL_QUADS);
+
+ glNormal3f (0, -1, 0);
+
+ glTexCoord2f (xmax, 0);
+ glVertex3f (hor, 1, 0);
+
+ glTexCoord2f (0, 0);
+ glVertex3f (-hor, 1, 0);
+
+ glTexCoord2f (0, ymax);
+ glVertex3f (-hor, -1, 0);
+
+ glTexCoord2f (xmax, ymax);
+ glVertex3f (hor, -1, 0);
+ glEnd ();
+
+ if (xinfo->info.dumpvideo) {
+ static int framenr = 0;
+ char capfilename[255];
+ static guint8 *cap_image_data = NULL, *cap_image_data2 = NULL;
+ int i;
+
+ // hmmmm, is this reentrant ?!
+ if (cap_image_data == NULL)
+ cap_image_data = (guint8 *) malloc (img_width * img_height * 3);
+
+ if (cap_image_data2 == NULL)
+ cap_image_data2 = (guint8 *) malloc (img_width * img_height * 3);
+
+ printf ("Recording frame #%d\n", framenr);
+ glReadPixels (0, 0, img_width, img_height, GL_RGB, GL_UNSIGNED_BYTE,
+ cap_image_data);
+ // invert the pixels
+ for (i = 0; i < img_height; i++)
+ memcpy (cap_image_data2 + i * img_width * 3,
+ cap_image_data + (img_height - 1 - i) * img_width * 3, img_width * 3);
+
+ sprintf (capfilename, "cap%04d.ppm", framenr);
+ FILE *outfile = fopen (capfilename, "wb");
+
+ if (outfile != NULL) {
+ fprintf (outfile, "P6\n");
+ fprintf (outfile, "# created by raw_zb\n");
+ fprintf (outfile, "%d %d\n", img_width, img_height);
+ fprintf (outfile, "255\n");
+ fwrite (cap_image_data2, sizeof (char), img_width * img_height * 3,
+ outfile);
+ fclose (outfile);
}
+ framenr++;
+ }
- glXSwapBuffers(xinfo->dpy, xinfo->win);
+ glXSwapBuffers (xinfo->dpy, xinfo->win);
}
void
-gst_gl_rgbimage_free_image (GstImageData *image)
+gst_gl_rgbimage_free_image (GstImageData * image)
{
GstGLImage *im = (GstGLImage *) image;
- g_warning ("gst_gl_rgbimage_free_image doesn't do anything yet -> freeing image\n");
+ g_warning
+ ("gst_gl_rgbimage_free_image doesn't do anything yet -> freeing image\n");
g_free (im->data.data);
g_free (im);
}
/* Creates an OpenGL texture to upload the picture over */
static void
-gst_gl_rgbimage_open_conn (GstImageConnection *conn, GstImageInfo *info)
+gst_gl_rgbimage_open_conn (GstImageConnection * conn, GstImageInfo * info)
{
- g_warning("Opening RGB Connection; classic OpenGL 1.2 renderer.");
+ g_warning ("Opening RGB Connection; classic OpenGL 1.2 renderer.");
//GstGLImageInfo *xinfo = gst_gl_rgbimage_info (info);
GstGLImageConnection *xconn = gst_gl_rgbimage_connection (conn);
- glGenTextures(1, &xconn->rgbatex_id);
- glBindTexture(GL_TEXTURE_2D, xconn->rgbatex_id);
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TEX_XSIZE, TEX_YSIZE, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ glGenTextures (1, &xconn->rgbatex_id);
+ glBindTexture (GL_TEXTURE_2D, xconn->rgbatex_id);
+ glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+ glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, TEX_XSIZE, TEX_YSIZE, 0, GL_RGBA,
+ GL_UNSIGNED_BYTE, NULL);
}
/* Deletes the creates OpenGL textures */
-static void
-gst_gl_rgbimage_close_conn (GstImageConnection *conn, GstImageInfo *info)
+static void
+gst_gl_rgbimage_close_conn (GstImageConnection * conn, GstImageInfo * info)
{
GstGLImageConnection *xconn = gst_gl_rgbimage_connection (conn);
+
//GstGLImageInfo *xinfo = gst_gl_rgbimage_info (info);
- glDeleteTextures(1, &xconn->rgbatex_id);
- }
+ glDeleteTextures (1, &xconn->rgbatex_id);
+}
static void
-gst_gl_rgbimage_free_conn (GstImageConnection *conn)
+gst_gl_rgbimage_free_conn (GstImageConnection * conn)
{
GstGLImageConnection *xconn = gst_gl_rgbimage_connection (conn);
-
+
g_assert (xconn != NULL);
-
+
g_free (xconn);
}
-
-
/* default template - initiated with class struct to allow gst-register to work
with X running */
GST_PAD_TEMPLATE_FACTORY (gst_glsink_sink_template_factory,
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_CAPS_NEW ( "glsink_rgbsink", "video/x-raw-rgb",
- "framerate", GST_PROPS_FLOAT_RANGE(0, G_MAXFLOAT),
- "width", GST_PROPS_INT_RANGE(0, G_MAXINT),
- "height", GST_PROPS_INT_RANGE(0, G_MAXINT)),
- GST_CAPS_NEW ( "glsink_yuvsink", "video/x-raw-yuv",
- "framerate", GST_PROPS_FLOAT_RANGE(0, G_MAXFLOAT),
- "width", GST_PROPS_INT_RANGE(0, G_MAXINT),
- "height", GST_PROPS_INT_RANGE(0, G_MAXINT))
-)
+ "sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_CAPS_NEW ("glsink_rgbsink", "video/x-raw-rgb",
+ "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT),
+ "width", GST_PROPS_INT_RANGE (0, G_MAXINT),
+ "height", GST_PROPS_INT_RANGE (0, G_MAXINT)),
+ GST_CAPS_NEW ("glsink_yuvsink", "video/x-raw-yuv",
+ "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT),
+ "width", GST_PROPS_INT_RANGE (0, G_MAXINT),
+ "height", GST_PROPS_INT_RANGE (0, G_MAXINT))
+ )
/* glsink signals and args */
-enum {
- LAST_SIGNAL
-};
-
-
-enum {
- ARG_0,
- ARG_WIDTH,
- ARG_HEIGHT,
- ARG_FRAMES_DISPLAYED,
- ARG_FRAME_TIME,
- ARG_HOOK,
- ARG_MUTE,
- ARG_REPAINT,
- ARG_DEMO,
- ARG_DUMP
-};
+ enum
+ {
+ LAST_SIGNAL
+ };
+
+
+ enum
+ {
+ ARG_0,
+ ARG_WIDTH,
+ ARG_HEIGHT,
+ ARG_FRAMES_DISPLAYED,
+ ARG_FRAME_TIME,
+ ARG_HOOK,
+ ARG_MUTE,
+ ARG_REPAINT,
+ ARG_DEMO,
+ ARG_DUMP
+ };
/* GLsink class */
#define GST_TYPE_GLSINK (gst_glsink_get_type())
#define GST_IS_GLSINK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_GLSINK))
#define GST_IS_GLSINK_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_GLSINK))
-typedef struct _GstGLSink GstGLSink;
-typedef struct _GstGLSinkClass GstGLSinkClass;
+ typedef struct _GstGLSink GstGLSink;
+ typedef struct _GstGLSinkClass GstGLSinkClass;
-struct _GstGLSink {
- GstElement element;
+ struct _GstGLSink
+ {
+ GstElement element;
- GstPad *sinkpad;
+ GstPad *sinkpad;
- gint frames_displayed;
- guint64 frame_time;
- gint width, height;
- gboolean muted;
- gint demo; // some kind of fun demo mode to let GL show its 3D capabilities
- gboolean dumpvideo; // dump the video down to .ppm:s
- GstBuffer *last_image; /* not thread safe ? */
-
- GstClock *clock;
+ gint frames_displayed;
+ guint64 frame_time;
+ gint width, height;
+ gboolean muted;
+ gint demo; // some kind of fun demo mode to let GL show its 3D capabilities
+ gboolean dumpvideo; // dump the video down to .ppm:s
+ GstBuffer *last_image; /* not thread safe ? */
- GMutex *cache_lock;
- GList *cache;
-
- /* plugins */
- GstImagePlugin* plugin;
- GstImageConnection *conn;
-
- /* allow anybody to hook in here */
- GstImageInfo *hook;
-};
+ GstClock *clock;
-struct _GstGLSinkClass {
- GstElementClass parent_class;
+ GMutex *cache_lock;
+ GList *cache;
- /* plugins */
- GList *plugins;
-};
+ /* plugins */
+ GstImagePlugin *plugin;
+ GstImageConnection *conn;
+
+ /* allow anybody to hook in here */
+ GstImageInfo *hook;
+ };
+ struct _GstGLSinkClass
+ {
+ GstElementClass parent_class;
+
+ /* plugins */
+ GList *plugins;
+ };
+
+
+ static GType gst_glsink_get_type (void);
+ static void gst_glsink_base_init (gpointer g_class);
+ static void gst_glsink_class_init (GstGLSinkClass * klass);
+ static void gst_glsink_init (GstGLSink * sink);
-static GType gst_glsink_get_type (void);
-static void gst_glsink_base_init (gpointer g_class);
-static void gst_glsink_class_init (GstGLSinkClass *klass);
-static void gst_glsink_init (GstGLSink *sink);
/* static void gst_glsink_dispose (GObject *object); */
-static void gst_glsink_chain (GstPad *pad, GstData *_data);
-static void gst_glsink_set_clock (GstElement *element, GstClock *clock);
-static GstElementStateReturn gst_glsink_change_state (GstElement *element);
-static GstPadLinkReturn gst_glsink_sinkconnect (GstPad *pad, GstCaps *caps);
-static GstCaps * gst_glsink_getcaps (GstPad *pad, GstCaps *caps);
+ static void gst_glsink_chain (GstPad * pad, GstData * _data);
+ static void gst_glsink_set_clock (GstElement * element, GstClock * clock);
+ static GstElementStateReturn gst_glsink_change_state (GstElement *
+ element);
+ static GstPadLinkReturn gst_glsink_sinkconnect (GstPad * pad,
+ GstCaps * caps);
+ static GstCaps *gst_glsink_getcaps (GstPad * pad, GstCaps * caps);
-static void gst_glsink_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_glsink_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+ static void gst_glsink_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+ static void gst_glsink_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static void gst_glsink_release_conn (GstGLSink *sink);
-static void gst_glsink_append_cache (GstGLSink *sink, GstImageData *image);
-static gboolean gst_glsink_set_caps (GstGLSink *sink, GstCaps *caps);
+ static void gst_glsink_release_conn (GstGLSink * sink);
+ static void gst_glsink_append_cache (GstGLSink * sink,
+ GstImageData * image);
+ static gboolean gst_glsink_set_caps (GstGLSink * sink, GstCaps * caps);
/* prototypes from plugins */
-extern GstImagePlugin* get_gl_rgbimage_plugin (void);
-extern GstImagePlugin* get_gl_nvimage_plugin (void);
+ extern GstImagePlugin *get_gl_rgbimage_plugin (void);
+ extern GstImagePlugin *get_gl_nvimage_plugin (void);
+
/* default output */
-extern void gst_glxwindow_new (GstGLSink *sink);
-extern void gst_glxwindow_hook_context (GstImageInfo *info);
-extern void gst_glxwindow_unhook_context (GstImageInfo *info);
+ extern void gst_glxwindow_new (GstGLSink * sink);
+ extern void gst_glxwindow_hook_context (GstImageInfo * info);
+ extern void gst_glxwindow_unhook_context (GstImageInfo * info);
-static GstPadTemplate *sink_template;
+ static GstPadTemplate *sink_template;
+
+ static GstElementClass *parent_class = NULL;
-static GstElementClass *parent_class = NULL;
/* static guint gst_glsink_signals[LAST_SIGNAL] = { 0 }; */
-static GType
-gst_glsink_get_type (void)
+ static GType gst_glsink_get_type (void)
{
static GType videosink_type = 0;
if (!videosink_type) {
static const GTypeInfo videosink_info = {
- sizeof(GstGLSinkClass),
+ sizeof (GstGLSinkClass),
gst_glsink_base_init,
NULL,
(GClassInitFunc) gst_glsink_class_init,
NULL,
NULL,
- sizeof(GstGLSink),
+ sizeof (GstGLSink),
0,
(GInstanceInitFunc) gst_glsink_init,
};
- videosink_type = g_type_register_static(GST_TYPE_ELEMENT, "GstGLSink", &videosink_info, 0);
+ videosink_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstGLSink", &videosink_info,
+ 0);
}
return videosink_type;
}
gst_glsink_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
+
gst_element_class_set_details (element_class, &gst_glsink_details);
- gst_element_class_add_pad_template (
- element_class,
- GST_PAD_TEMPLATE_GET (gst_glsink_sink_template_factory));
+ gst_element_class_add_pad_template (element_class,
+ GST_PAD_TEMPLATE_GET (gst_glsink_sink_template_factory));
}
static void
-gst_glsink_class_init (GstGLSinkClass *klass)
+gst_glsink_class_init (GstGLSinkClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
gobject_class = (GObjectClass *) klass;
- gstelement_class = (GstElementClass*) klass;
+ gstelement_class = (GstElementClass *) klass;
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
- g_object_class_install_property (gobject_class, ARG_WIDTH,
- g_param_spec_int ("width", "Width", "The video width",
- G_MININT, G_MAXINT, 0, G_PARAM_READABLE)); /* CHECKME */
- g_object_class_install_property (gobject_class, ARG_HEIGHT,
- g_param_spec_int ("height", "Height", "The video height",
- G_MININT, G_MAXINT, 0, G_PARAM_READABLE)); /* CHECKME */
- g_object_class_install_property (gobject_class, ARG_FRAMES_DISPLAYED,
- g_param_spec_int ("frames_displayed", "Frames Displayed", "The number of frames displayed so far",
- G_MININT,G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property (gobject_class, ARG_FRAME_TIME,
- g_param_spec_int ("frame_time", "Frame time", "The interval between frames",
- G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (gobject_class, ARG_WIDTH, g_param_spec_int ("width", "Width", "The video width", G_MININT, G_MAXINT, 0, G_PARAM_READABLE)); /* CHECKME */
+ g_object_class_install_property (gobject_class, ARG_HEIGHT, g_param_spec_int ("height", "Height", "The video height", G_MININT, G_MAXINT, 0, G_PARAM_READABLE)); /* CHECKME */
+ g_object_class_install_property (gobject_class, ARG_FRAMES_DISPLAYED, g_param_spec_int ("frames_displayed", "Frames Displayed", "The number of frames displayed so far", G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (gobject_class, ARG_FRAME_TIME, g_param_spec_int ("frame_time", "Frame time", "The interval between frames", G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */
g_object_class_install_property (gobject_class, ARG_HOOK,
- g_param_spec_pointer ("hook", "Hook", "The object receiving the output", G_PARAM_WRITABLE));
+ g_param_spec_pointer ("hook", "Hook", "The object receiving the output",
+ G_PARAM_WRITABLE));
g_object_class_install_property (gobject_class, ARG_MUTE,
- g_param_spec_boolean ("mute", "Mute", "mute the output ?", FALSE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("mute", "Mute", "mute the output ?", FALSE,
+ G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_REPAINT,
- g_param_spec_boolean ("repaint", "Repaint", "repaint the current frame", FALSE, G_PARAM_WRITABLE));
+ g_param_spec_boolean ("repaint", "Repaint", "repaint the current frame",
+ FALSE, G_PARAM_WRITABLE));
g_object_class_install_property (gobject_class, ARG_DEMO,
- g_param_spec_int ("demo", "Demo", "demo mode (shows 3D capabilities)",0, 1, 0, G_PARAM_READWRITE));
+ g_param_spec_int ("demo", "Demo", "demo mode (shows 3D capabilities)", 0,
+ 1, 0, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_DUMP,
- g_param_spec_boolean ("dump", "Dump", "stores sequence of frames in .ppm files", FALSE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("dump", "Dump",
+ "stores sequence of frames in .ppm files", FALSE, G_PARAM_READWRITE));
gobject_class->set_property = gst_glsink_set_property;
gobject_class->get_property = gst_glsink_get_property;
/*gobject_class->dispose = gst_glsink_dispose; */
-
+
gstelement_class->change_state = gst_glsink_change_state;
gstelement_class->set_clock = gst_glsink_set_clock;
-
+
/* plugins */
klass->plugins = NULL;
klass->plugins = g_list_append (klass->plugins, get_gl_rgbimage_plugin ());
buffer upload
*/
static void
-gst_glsink_init (GstGLSink *sink)
+gst_glsink_init (GstGLSink * sink)
{
sink->sinkpad = gst_pad_new_from_template (sink_template, "sink");
gst_element_add_pad (GST_ELEMENT (sink), sink->sinkpad);
sink->width = 0;
sink->height = 0;
sink->muted = FALSE;
- sink->clock = NULL;
- GST_FLAG_SET(sink, GST_ELEMENT_THREAD_SUGGESTED);
+ sink->clock = NULL;
+ GST_FLAG_SET (sink, GST_ELEMENT_THREAD_SUGGESTED);
GST_FLAG_SET (sink, GST_ELEMENT_EVENT_AWARE);
-
+
/* create bufferpool and image cache */
GST_DEBUG ("glsink: creating bufferpool");
- sink->cache_lock = g_mutex_new();
- sink->cache = NULL;
-
+ sink->cache_lock = g_mutex_new ();
+ sink->cache = NULL;
+
/* plugins */
sink->plugin = NULL;
sink->conn = NULL;
-
+
/* do initialization of default hook here */
- gst_glxwindow_new (sink);
+ gst_glxwindow_new (sink);
//printf("GLSink_init: Current context %p\n", glXGetCurrentContext());
- gst_glxwindow_unhook_context(sink->hook);
+ gst_glxwindow_unhook_context (sink->hook);
}
/** frees the temporary connection that tests the window system capabilities */
static void
-gst_glsink_release_conn (GstGLSink *sink)
+gst_glsink_release_conn (GstGLSink * sink)
{
- if (sink->conn == NULL) return;
-
+ if (sink->conn == NULL)
+ return;
+
/* free last image if any */
- if (sink->last_image != NULL)
- {
+ if (sink->last_image != NULL) {
gst_buffer_unref (sink->last_image);
sink->last_image = NULL;
}
/* free cache */
g_mutex_lock (sink->cache_lock);
- while (sink->cache)
- {
+ while (sink->cache) {
sink->plugin->free_image ((GstImageData *) sink->cache->data);
sink->cache = g_list_delete_link (sink->cache, sink->cache);
}
g_mutex_unlock (sink->cache_lock);
-
+
/* release connection */
sink->conn->free_conn (sink->conn);
sink->conn = NULL;
}
-static void
-gst_glsink_append_cache (GstGLSink *sink, GstImageData *image)
+static void
+gst_glsink_append_cache (GstGLSink * sink, GstImageData * image)
{
g_mutex_lock (sink->cache_lock);
sink->cache = g_list_prepend (sink->cache, image);
Create a new buffer to hand up the chain.
This allows the plugins to make its own decoding buffers
*/
-static GstBuffer*
-gst_glsink_buffer_new (GstBufferPool *pool, gint64 location,
- guint size, gpointer user_data)
+static GstBuffer *
+gst_glsink_buffer_new (GstBufferPool * pool, gint64 location,
+ guint size, gpointer user_data)
{
GstGLSink *sink;
GstBuffer *buffer;
GstImageData *image;
-
+
sink = GST_GLSINK (user_data);
-
+
/* If cache is non-empty, get buffer from there */
if (sink->cache != NULL) {
g_mutex_lock (sink->cache_lock);
/* otherwise, get one from the plugin */
image = sink->plugin->get_image (sink->hook, sink->conn);
}
-
+
buffer = gst_buffer_new ();
GST_BUFFER_DATA (buffer) = image->data;
GST_BUFFER_SIZE (buffer) = image->size;
GST_BUFFER_POOL_PRIVATE (buffer) = image;
-
+
return buffer;
}
Free a buffer that the chain doesn't need anymore.
*/
static void
-gst_glsink_buffer_free (GstBufferPool *pool, GstBuffer *buffer, gpointer user_data)
+gst_glsink_buffer_free (GstBufferPool * pool, GstBuffer * buffer,
+ gpointer user_data)
{
- GstGLSink *sink = GST_GLSINK (gst_buffer_pool_get_user_data (GST_BUFFER_BUFFERPOOL (buffer)));
+ GstGLSink *sink =
+ GST_GLSINK (gst_buffer_pool_get_user_data (GST_BUFFER_BUFFERPOOL
+ (buffer)));
- gst_glsink_append_cache (sink, (GstImageData *) GST_BUFFER_POOL_PRIVATE (buffer));
+ gst_glsink_append_cache (sink,
+ (GstImageData *) GST_BUFFER_POOL_PRIVATE (buffer));
/* set to NULL so the data is not freed */
GST_BUFFER_DATA (buffer) = NULL;
Go through the plugin list, finding the plugin that first fits the given parameters
*/
static gboolean
-gst_glsink_set_caps (GstGLSink *sink, GstCaps *caps)
+gst_glsink_set_caps (GstGLSink * sink, GstCaps * caps)
{
- g_warning("in glsink set caps!\n");
- printf("Getting GLstring, context is %p\n", glXGetCurrentContext());
-
+ g_warning ("in glsink set caps!\n");
+ printf ("Getting GLstring, context is %p\n", glXGetCurrentContext ());
+
GList *list = ((GstGLSinkClass *) G_OBJECT_GET_CLASS (sink))->plugins;
GstImageConnection *conn = NULL;
- while (list)
- {
- printf("AGetting GLstring, context is %p\n", glXGetCurrentContext());
+
+ while (list) {
+ printf ("AGetting GLstring, context is %p\n", glXGetCurrentContext ());
GstImagePlugin *plugin = (GstImagePlugin *) list->data;
- if ((conn = plugin->set_caps (sink->hook, caps)) != NULL)
- {
+
+ if ((conn = plugin->set_caps (sink->hook, caps)) != NULL) {
//gst_glsink_release_conn (sink);
- printf("BGetting GLstring, context is %p\n", glXGetCurrentContext());
+ printf ("BGetting GLstring, context is %p\n", glXGetCurrentContext ());
sink->conn = conn;
- printf("CGetting GLstring, context is %p\n", glXGetCurrentContext());
+ printf ("CGetting GLstring, context is %p\n", glXGetCurrentContext ());
sink->plugin = plugin;
sink->conn->open_conn (sink->conn, sink->hook);
return TRUE;
Link the input video sink internally.
*/
static GstPadLinkReturn
-gst_glsink_sinkconnect (GstPad *pad, GstCaps *caps)
+gst_glsink_sinkconnect (GstPad * pad, GstCaps * caps)
{
- g_warning("in glsink sinkconnect!\n");
+ g_warning ("in glsink sinkconnect!\n");
GstGLSink *sink;
guint32 fourcc, print_format, result;
/* we are not going to act on variable caps */
if (!GST_CAPS_IS_FIXED (caps))
return GST_PAD_LINK_DELAYED;
-
- gst_glxwindow_hook_context(sink->hook);
+
+ gst_glxwindow_hook_context (sink->hook);
/* try to set the caps on the output */
result = gst_glsink_set_caps (sink, caps);
- gst_glxwindow_unhook_context(sink->hook);
+ gst_glxwindow_unhook_context (sink->hook);
+
+ if (result == FALSE) {
+ return GST_PAD_LINK_REFUSED;
+ }
- if (result == FALSE)
- {
- return GST_PAD_LINK_REFUSED;
- }
-
/* remember width & height */
gst_caps_get_int (caps, "width", &sink->width);
gst_caps_get_int (caps, "height", &sink->height);
gst_caps_get_fourcc_int (caps, "format", &fourcc);
print_format = GULONG_FROM_LE (fourcc);
- GST_DEBUG ("glsink: setting %08x (%4.4s) %dx%d\n",
- fourcc, (gchar*)&print_format, sink->width, sink->height);
+ GST_DEBUG ("glsink: setting %08x (%4.4s) %dx%d\n",
+ fourcc, (gchar *) & print_format, sink->width, sink->height);
/* emit signal */
g_object_freeze_notify (G_OBJECT (sink));
return GST_PAD_LINK_OK;
}
static GstCaps *
-gst_glsink_getcaps (GstPad *pad, GstCaps *caps)
+gst_glsink_getcaps (GstPad * pad, GstCaps * caps)
{
- g_warning("in glsink get caps!\n");
+ g_warning ("in glsink get caps!\n");
/* what is the "caps" parameter good for? */
GstGLSink *sink = GST_GLSINK (gst_pad_get_parent (pad));
GstCaps *ret = NULL;
GList *list = ((GstGLSinkClass *) G_OBJECT_GET_CLASS (sink))->plugins;
-
- gst_glxwindow_hook_context(sink->hook);
- while (list)
- {
- ret = gst_caps_append (ret, ((GstImagePlugin *) list->data)->get_caps (sink->hook));
+
+ gst_glxwindow_hook_context (sink->hook);
+ while (list) {
+ ret =
+ gst_caps_append (ret,
+ ((GstImagePlugin *) list->data)->get_caps (sink->hook));
list = g_list_next (list);
}
- gst_glxwindow_unhook_context(sink->hook);
+ gst_glxwindow_unhook_context (sink->hook);
return ret;
}
static void
-gst_glsink_set_clock (GstElement *element, GstClock *clock)
+gst_glsink_set_clock (GstElement * element, GstClock * clock)
{
GstGLSink *sink = GST_GLSINK (element);
-
+
sink->clock = clock;
}
static void
-gst_glsink_chain (GstPad *pad, GstData *_data)
+gst_glsink_chain (GstPad * pad, GstData * _data)
{
//g_warning("in glsink_chain!\n");
GstBuffer *buf = GST_BUFFER (_data);
switch (GST_EVENT_TYPE (event)) {
default:
- gst_pad_event_default (pad, event);
+ gst_pad_event_default (pad, event);
}
return;
}
- GST_DEBUG ("glsink: clock wait: %llu %u",
- GST_BUFFER_TIMESTAMP (buf), GST_BUFFER_SIZE (buf));
+ GST_DEBUG ("glsink: clock wait: %llu %u",
+ GST_BUFFER_TIMESTAMP (buf), GST_BUFFER_SIZE (buf));
#if 0
GstClockTime time = GST_BUFFER_TIMESTAMP (buf);
static int frame_drops = 0;
if (sink->clock && time != -1) {
- if (time < gst_clock_get_time(sink->clock))
- {
- g_warning("Frame drop (%d consecutive) !!", frame_drops);
- /* we are going to drop late buffers */
- gst_buffer_unref (buf);
- frame_drops++;
- return;
- }
- frame_drops = 0; // we made it - reset time
+ if (time < gst_clock_get_time (sink->clock)) {
+ g_warning ("Frame drop (%d consecutive) !!", frame_drops);
+ /* we are going to drop late buffers */
+ gst_buffer_unref (buf);
+ frame_drops++;
+ return;
+ }
+ frame_drops = 0; // we made it - reset time
GstClockReturn ret;
- GstClockID id = gst_clock_new_single_shot_id (sink->clock, GST_BUFFER_TIMESTAMP (buf));
+ GstClockID id =
+ gst_clock_new_single_shot_id (sink->clock, GST_BUFFER_TIMESTAMP (buf));
ret = gst_element_clock_wait (GST_ELEMENT (sink), id, NULL);
gst_clock_id_free (id);
sink->frames_displayed++;
g_object_notify (G_OBJECT (sink), "frames_displayed");
- if (!sink->muted)
- {
- if (glXGetCurrentContext() == NULL)
- {
- printf("Rehooking window !\n");
- gst_glxwindow_hook_context(sink->hook);
+ if (!sink->muted) {
+ if (glXGetCurrentContext () == NULL) {
+ printf ("Rehooking window !\n");
+ gst_glxwindow_hook_context (sink->hook);
#if 1
- GST_DEBUG("Initializing OpenGL parameters\n");
- /* initialize OpenGL drawing */
- glEnable(GL_DEPTH_TEST);
- glEnable(GL_TEXTURE_2D);
- glClearDepth(1.0f);
- glClearColor(0, 0, 0, 0);
-
- glEnable(GL_AUTO_NORMAL); // let OpenGL generate the Normals
-
- glDisable(GL_BLEND);
- glDisable(GL_CULL_FACE);
- glPolygonMode(GL_FRONT, GL_FILL);
- glPolygonMode(GL_BACK, GL_FILL);
-
- glShadeModel(GL_SMOOTH);
- glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
-
- GstGLImageInfo *window = (GstGLImageInfo *)sink->hook;
- int w=window->width, h = window->height;
-
- glViewport(0, 0, (GLint) w, (GLint) h);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
-
- GLfloat aspect = (GLfloat) w / (GLfloat) h;
- glFrustum(-aspect, aspect, -1.0, 1.0, 5.0, 500.0);
+ GST_DEBUG ("Initializing OpenGL parameters\n");
+ /* initialize OpenGL drawing */
+ glEnable (GL_DEPTH_TEST);
+ glEnable (GL_TEXTURE_2D);
+ glClearDepth (1.0f);
+ glClearColor (0, 0, 0, 0);
+
+ glEnable (GL_AUTO_NORMAL); // let OpenGL generate the Normals
+
+ glDisable (GL_BLEND);
+ glDisable (GL_CULL_FACE);
+ glPolygonMode (GL_FRONT, GL_FILL);
+ glPolygonMode (GL_BACK, GL_FILL);
+
+ glShadeModel (GL_SMOOTH);
+ glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
+
+ GstGLImageInfo *window = (GstGLImageInfo *) sink->hook;
+ int w = window->width, h = window->height;
+
+ glViewport (0, 0, (GLint) w, (GLint) h);
+ glMatrixMode (GL_PROJECTION);
+ glLoadIdentity ();
+
+ GLfloat aspect = (GLfloat) w / (GLfloat) h;
+
+ glFrustum (-aspect, aspect, -1.0, 1.0, 5.0, 500.0);
#endif
- gst_glxwindow_unhook_context(sink->hook);
- gst_glxwindow_hook_context(sink->hook);
- glMatrixMode(GL_MODELVIEW);
-#if 0
- sink->hook->free_info(sink->hook);
- printf("Reallocating window brutally !\n");
- gst_glxwindow_new(sink);
+ gst_glxwindow_unhook_context (sink->hook);
+ gst_glxwindow_hook_context (sink->hook);
+ glMatrixMode (GL_MODELVIEW);
+#if 0
+ sink->hook->free_info (sink->hook);
+ printf ("Reallocating window brutally !\n");
+ gst_glxwindow_new (sink);
#endif
- }
-
+ }
+
/* free last_image, if any */
if (sink->last_image != NULL)
gst_buffer_unref (sink->last_image);
if (sink->bufferpool && GST_BUFFER_BUFFERPOOL (buf) == sink->bufferpool) {
-
+
// awful hack ! But I currently have no other solution without changing the API
sink->hook->demo = sink->demo;
sink->hook->dumpvideo = sink->dumpvideo;
- sink->plugin->put_image (sink->hook, (GstImageData *) GST_BUFFER_POOL_PRIVATE (buf));
+ sink->plugin->put_image (sink->hook,
+ (GstImageData *) GST_BUFFER_POOL_PRIVATE (buf));
sink->last_image = buf;
} else {
- buffer = gst_buffer_new_from_pool (gst_glsink_get_bufferpool (sink->sinkpad),
- 0, GST_BUFFER_SIZE (buf));
- memcpy (GST_BUFFER_DATA (buffer), GST_BUFFER_DATA (buf),
- GST_BUFFER_SIZE (buf) > GST_BUFFER_SIZE (buffer) ?
- GST_BUFFER_SIZE (buffer) : GST_BUFFER_SIZE (buf));
+ buffer =
+ gst_buffer_new_from_pool (gst_glsink_get_bufferpool (sink->sinkpad),
+ 0, GST_BUFFER_SIZE (buf));
+ memcpy (GST_BUFFER_DATA (buffer), GST_BUFFER_DATA (buf),
+ GST_BUFFER_SIZE (buf) >
+ GST_BUFFER_SIZE (buffer) ? GST_BUFFER_SIZE (buffer) :
+ GST_BUFFER_SIZE (buf));
- sink->plugin->put_image (sink->hook, (GstImageData *) GST_BUFFER_POOL_PRIVATE (buffer));
+ sink->plugin->put_image (sink->hook,
+ (GstImageData *) GST_BUFFER_POOL_PRIVATE (buffer));
sink->last_image = buffer;
gst_buffer_unref (buf);
//gst_glxwindow_unhook_context(sink->hook);
}
-
+
}
static void
-gst_glsink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_glsink_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
//g_warning("in set_property!\n");
GstGLSink *sink;
sink->frame_time = g_value_get_int (value);
break;
case ARG_HOOK:
- if (sink->hook)
- {
+ if (sink->hook) {
sink->hook->free_info (sink->hook);
}
sink->hook = g_value_get_pointer (value);
break;
case ARG_REPAINT:
if (sink->last_image != NULL) {
- sink->plugin->put_image (sink->hook, (GstImageData *) GST_BUFFER_POOL_PRIVATE (sink->last_image));
+ sink->plugin->put_image (sink->hook,
+ (GstImageData *) GST_BUFFER_POOL_PRIVATE (sink->last_image));
}
break;
default:
}
static void
-gst_glsink_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_glsink_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
//g_warning("in get_property!\n");
GstGLSink *sink;
/* it's not null if we got it, but it might not be ours */
- sink = GST_GLSINK(object);
+ sink = GST_GLSINK (object);
switch (prop_id) {
case ARG_WIDTH:
g_value_set_int (value, sink->frames_displayed);
break;
case ARG_FRAME_TIME:
- g_value_set_int (value, sink->frame_time/1000000);
+ g_value_set_int (value, sink->frame_time / 1000000);
break;
case ARG_MUTE:
g_value_set_boolean (value, sink->muted);
case ARG_DUMP:
g_value_set_boolean (value, sink->dumpvideo);
break;
- default:
+ default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
static GstElementStateReturn
-gst_glsink_change_state (GstElement *element)
+gst_glsink_change_state (GstElement * element)
{
//g_warning("in change_state!\n");
GstGLSink *sink;
case GST_STATE_NULL_TO_READY:
break;
case GST_STATE_READY_TO_PAUSED:
- {
- //g_warning("Going GST_STATE_READY_TO_PAUSED: %p", sink->conn);
- }
+ {
+ //g_warning("Going GST_STATE_READY_TO_PAUSED: %p", sink->conn);
+ }
break;
case GST_STATE_PAUSED_TO_PLAYING:
- {
- //g_warning("Going GST_STATE_PAUSED_TO_PLAYING: %p", sink->conn);
- }
+ {
+ //g_warning("Going GST_STATE_PAUSED_TO_PLAYING: %p", sink->conn);
+ }
break;
case GST_STATE_PLAYING_TO_PAUSED:
break;
case GST_STATE_PAUSED_TO_READY:
if (sink->conn)
- sink->conn->close_conn (sink->conn, sink->hook);
+ sink->conn->close_conn (sink->conn, sink->hook);
if (sink->last_image) {
gst_buffer_unref (sink->last_image);
- sink->last_image = NULL;
+ sink->last_image = NULL;
}
break;
case GST_STATE_READY_TO_NULL:
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
/* Loading the library containing GstVideoSink, our parent object */
if (!gst_library_load ("gstvideo"))
return FALSE;
/* this is needed later on in the _real_ init (during a gst-launch) */
- sink_template = gst_pad_template_new (
- "sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- NULL);
+ sink_template = gst_pad_template_new ("sink",
+ GST_PAD_SINK, GST_PAD_ALWAYS, NULL);
if (!gst_element_register (plugin, "glsink", GST_RANK_NONE, GST_TYPE_GLSINK))
return FALSE;
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "glsink",
- "An OpenGL based video sink - uses OpenGL and GLX to draw video, utilizing different acceleration options",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-);
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "glsink",
+ "An OpenGL based video sink - uses OpenGL and GLX to draw video, utilizing different acceleration options",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN);
#include <gst/gst.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define MAX_FLIP_BUFFERS 1
-typedef struct _GstImageInfo GstImageInfo;
-struct _GstImageInfo {
- gulong id;
- int demo;
- int dumpvideo;
- void (*free_info) (GstImageInfo *info);
-};
-
-
-typedef struct _GstImageData GstImageData;
-struct _GstImageData {
- gint size;
- gchar *data;
-};
-
-typedef struct _GstImageConnection GstImageConnection;
-struct _GstImageConnection {
- void (*open_conn) (GstImageConnection *conn, GstImageInfo *info);
- void (*close_conn) (GstImageConnection *conn, GstImageInfo *info);
- void (*free_conn) (GstImageConnection *conn);
-};
-
-typedef GstCaps * (*GstImagePluginGetCapsFunc) (GstImageInfo *info);
-typedef GstImageConnection * (*GstImagePluginSetCapsFunc) (GstImageInfo *info, GstCaps *caps);
-typedef GstImageData* (*GstImagePluginGetImageFunc) (GstImageInfo *info, GstImageConnection *conn);
-typedef void (*GstImagePluginPutImageFunc) (GstImageInfo *info, GstImageData *image);
-typedef void (*GstImagePluginFreeImageFunc) (GstImageData *image);
-
-typedef struct _GstImagePlugin GstImagePlugin;
-struct _GstImagePlugin {
- GstImagePluginGetCapsFunc get_caps;
- GstImagePluginSetCapsFunc set_caps;
- GstImagePluginGetImageFunc get_image;
- GstImagePluginPutImageFunc put_image;
- GstImagePluginFreeImageFunc free_image;
-};
-
-typedef struct _GstGLImageInfo GstGLImageInfo;
+ typedef struct _GstImageInfo GstImageInfo;
+ struct _GstImageInfo
+ {
+ gulong id;
+ int demo;
+ int dumpvideo;
+ void (*free_info) (GstImageInfo * info);
+ };
+
+
+ typedef struct _GstImageData GstImageData;
+ struct _GstImageData
+ {
+ gint size;
+ gchar *data;
+ };
+
+ typedef struct _GstImageConnection GstImageConnection;
+ struct _GstImageConnection
+ {
+ void (*open_conn) (GstImageConnection * conn, GstImageInfo * info);
+ void (*close_conn) (GstImageConnection * conn, GstImageInfo * info);
+ void (*free_conn) (GstImageConnection * conn);
+ };
+
+ typedef GstCaps *(*GstImagePluginGetCapsFunc) (GstImageInfo * info);
+ typedef GstImageConnection *(*GstImagePluginSetCapsFunc) (GstImageInfo * info,
+ GstCaps * caps);
+ typedef GstImageData *(*GstImagePluginGetImageFunc) (GstImageInfo * info,
+ GstImageConnection * conn);
+ typedef void (*GstImagePluginPutImageFunc) (GstImageInfo * info,
+ GstImageData * image);
+ typedef void (*GstImagePluginFreeImageFunc) (GstImageData * image);
+
+ typedef struct _GstImagePlugin GstImagePlugin;
+ struct _GstImagePlugin
+ {
+ GstImagePluginGetCapsFunc get_caps;
+ GstImagePluginSetCapsFunc set_caps;
+ GstImagePluginGetImageFunc get_image;
+ GstImagePluginPutImageFunc put_image;
+ GstImagePluginFreeImageFunc free_image;
+ };
+
+ typedef struct _GstGLImageInfo GstGLImageInfo;
/* stuff about our window grouped together */
-struct _GstGLImageInfo {
- GstImageInfo info;
- Display *dpy;
- int screen;
- Window win;
- GLXContext ctx;
- XSetWindowAttributes attr;
- Bool fs;
- //XF86VidModeModeInfo deskMode;
- int x, y;
- unsigned int width, height;
- unsigned int depth;
- /* window specific from here */
- GstElement *sink;
- gulong handler_id;
- float rotX,rotY,zoom, zoomdir;
-};
+ struct _GstGLImageInfo
+ {
+ GstImageInfo info;
+ Display *dpy;
+ int screen;
+ Window win;
+ GLXContext ctx;
+ XSetWindowAttributes attr;
+ Bool fs;
+ //XF86VidModeModeInfo deskMode;
+ int x, y;
+ unsigned int width, height;
+ unsigned int depth;
+ /* window specific from here */
+ GstElement *sink;
+ gulong handler_id;
+ float rotX, rotY, zoom, zoomdir;
+ };
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_VIDEOSINK_H__ */
+#endif /* __GST_VIDEOSINK_H__ */
#include <GL/gl.h>
#include <GL/glu.h>
#include "gstglsink.h"
-#include <string.h> /* strncmp */
+#include <string.h> /* strncmp */
/* attributes for a single buffered visual in RGBA format with at least
* 4 bits per color and a 16 bit depth buffer */
-static int attrListSgl[] =
-{
- GLX_RGBA, GLX_RED_SIZE, 4,
- GLX_GREEN_SIZE, 4,
- GLX_BLUE_SIZE, 4,
+static int attrListSgl[] = {
+ GLX_RGBA, GLX_RED_SIZE, 4,
+ GLX_GREEN_SIZE, 4,
+ GLX_BLUE_SIZE, 4,
GLX_DEPTH_SIZE, 16,
None
};
/* attributes for a double buffered visual in RGBA format with at least
* 4 bits per color and a 16 bit depth buffer */
-static int attrListDbl[] =
- {
- GLX_RGBA, GLX_DOUBLEBUFFER,
- GLX_RED_SIZE, 4,
- GLX_GREEN_SIZE, 4,
- GLX_BLUE_SIZE, 4,
- GLX_DEPTH_SIZE, 16,
- None
- };
+static int attrListDbl[] = {
+ GLX_RGBA, GLX_DOUBLEBUFFER,
+ GLX_RED_SIZE, 4,
+ GLX_GREEN_SIZE, 4,
+ GLX_BLUE_SIZE, 4,
+ GLX_DEPTH_SIZE, 16,
+ None
+};
-GLfloat LightAmbient[] = { 0.1, 0.1, 0.1, 1.0 }; /* reddish ambient light */
-GLfloat LightDiffuse[] = { 0.6, 0.6, 0.6, 1.0 }; /* bluish diffuse light. */
-GLfloat LightPosition[] = { 1.5, 1.5, 1.5, 0.0 }; /* position */
+GLfloat LightAmbient[] = { 0.1, 0.1, 0.1, 1.0 }; /* reddish ambient light */
+GLfloat LightDiffuse[] = { 0.6, 0.6, 0.6, 1.0 }; /* bluish diffuse light. */
+GLfloat LightPosition[] = { 1.5, 1.5, 1.5, 0.0 }; /* position */
void
-gst_glxwindow_unhook_context(GstImageInfo *info)
+gst_glxwindow_unhook_context (GstImageInfo * info)
{
GstGLImageInfo *window = (GstGLImageInfo *) info;
- if (window->ctx)
- {
- if (!glXMakeCurrent(window->dpy, None, NULL))
- {
- printf("Could not release drawing context.\n");
- }
- else
- printf("Released drawing context.\n");
- }
+ if (window->ctx) {
+ if (!glXMakeCurrent (window->dpy, None, NULL)) {
+ printf ("Could not release drawing context.\n");
+ } else
+ printf ("Released drawing context.\n");
+ }
}
void
-gst_glxwindow_hook_context(GstImageInfo *info)
+gst_glxwindow_hook_context (GstImageInfo * info)
{
GstGLImageInfo *window = (GstGLImageInfo *) info;
- if (window->ctx && window->win && window->ctx)
- {
- if (!glXMakeCurrent(window->dpy, window->win, window->ctx))
- {
- printf("Could not acquire GLX drawing context.\n");
- }
- else
- printf("Acquired drawing context.\n");
- }
+ if (window->ctx && window->win && window->ctx) {
+ if (!glXMakeCurrent (window->dpy, window->win, window->ctx)) {
+ printf ("Could not acquire GLX drawing context.\n");
+ } else
+ printf ("Acquired drawing context.\n");
+ }
}
static void
-gst_glxwindow_free (GstImageInfo *info)
+gst_glxwindow_free (GstImageInfo * info)
{
GstGLImageInfo *window = (GstGLImageInfo *) info;
-
+
g_signal_handler_disconnect (window->sink, window->handler_id);
- if (window->ctx)
- {
- if (!glXMakeCurrent(window->dpy, None, NULL))
- {
- printf("Could not release drawing context.\n");
- }
- glXDestroyContext(window->dpy, window->ctx);
- window->ctx = NULL;
- }
-#if 0
- /* switch back to original desktop resolution if we were in fs */
- if (GLWin.fs)
- {
- XF86VidModeSwitchToMode(GLWin.dpy, GLWin.screen, &GLWin.deskMode);
- XF86VidModeSetViewPort(GLWin.dpy, GLWin.screen, 0, 0);
+ if (window->ctx) {
+ if (!glXMakeCurrent (window->dpy, None, NULL)) {
+ printf ("Could not release drawing context.\n");
}
+ glXDestroyContext (window->dpy, window->ctx);
+ window->ctx = NULL;
+ }
+#if 0
+ /* switch back to original desktop resolution if we were in fs */
+ if (GLWin.fs) {
+ XF86VidModeSwitchToMode (GLWin.dpy, GLWin.screen, &GLWin.deskMode);
+ XF86VidModeSetViewPort (GLWin.dpy, GLWin.screen, 0, 0);
+ }
#endif
XCloseDisplay (window->dpy);
g_free (window);
}
static void
-gst_glxwindow_callback(GObject *object, GParamSpec *pspec, GstGLImageInfo *data)
+gst_glxwindow_callback (GObject * object, GParamSpec * pspec,
+ GstGLImageInfo * data)
{
- XWindowAttributes attr;
- XGetWindowAttributes(data->dpy, data->win, &attr);
+ XWindowAttributes attr;
- if (strncmp (pspec->name, "width", 5) == 0 || strncmp (pspec->name, "height", 6) == 0)
- {
+ XGetWindowAttributes (data->dpy, data->win, &attr);
+
+ if (strncmp (pspec->name, "width", 5) == 0
+ || strncmp (pspec->name, "height", 6) == 0) {
gint w = 0;
gint h = 0;
+
g_object_get (object, "width", &w, NULL);
g_object_get (object, "height", &h, NULL);
- if (w != attr.width || h != attr.height)
- {
+ if (w != attr.width || h != attr.height) {
attr.width = w;
attr.height = h;
XResizeWindow (data->dpy, data->win, attr.width, attr.height);
XMapRaised (data->dpy, data->win);
// resize OpenGL
- g_warning("resizing in OpenGL");
- glViewport(0, 0, (GLint) w, (GLint) h);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
-
+ g_warning ("resizing in OpenGL");
+ glViewport (0, 0, (GLint) w, (GLint) h);
+ glMatrixMode (GL_PROJECTION);
+ glLoadIdentity ();
+
GLfloat aspect = (GLfloat) h / (GLfloat) w;
- glFrustum(-1.0, 1.0, -aspect, aspect, 5.0, 500.0);
+
+ glFrustum (-1.0, 1.0, -aspect, aspect, 5.0, 500.0);
}
}
- if (attr.width != data->width || attr.height != data->height)
- {
+ if (attr.width != data->width || attr.height != data->height) {
data->width = attr.width;
data->height = attr.height;
}
}
void
-gst_glxwindow_new (GstElement *sink)
+gst_glxwindow_new (GstElement * sink)
{
//XGCValues values;
GstGLImageInfo *new;
int glxMajorVersion, glxMinorVersion;
+
//XSetWindowAttributes attrib;
XVisualInfo *vi;
Atom wmDelete;
Window winDummy;
unsigned int borderDummy;
Colormap cmap;
- char* title = "GLSink (experimental)";
+ char *title = "GLSink (experimental)";
new = g_new0 (GstGLImageInfo, 1);
- if (sink == NULL)
- {
+ if (sink == NULL) {
sink = gst_element_factory_make ("glsink", "glsink");
g_assert (sink != NULL);
}
-
+
/* fill in the ImageInfo */
new->info.id = GST_MAKE_FOURCC ('X', 'l', 'i', 'b');
new->info.free_info = gst_glxwindow_free;
-
+
new->dpy = XOpenDisplay (NULL);
if (!new->dpy) {
g_warning ("open display failed!\n");
g_free (new);
return;
}
- new->screen = DefaultScreen(new->dpy);
+ new->screen = DefaultScreen (new->dpy);
/* get an appropriate visual */
- vi = glXChooseVisual(new->dpy, new->screen, attrListDbl);
- if (vi == NULL)
- {
- vi = glXChooseVisual(new->dpy, new->screen, attrListSgl);
- GST_DEBUG("Only Singlebuffered Visual!\n");
- }
- else
- {
- GST_DEBUG("Got Doublebuffered Visual!\n");
- }
- glXQueryVersion(new->dpy, &glxMajorVersion, &glxMinorVersion);
- GST_DEBUG("glX-Version %d.%d\n", glxMajorVersion, glxMinorVersion);
-
+ vi = glXChooseVisual (new->dpy, new->screen, attrListDbl);
+ if (vi == NULL) {
+ vi = glXChooseVisual (new->dpy, new->screen, attrListSgl);
+ GST_DEBUG ("Only Singlebuffered Visual!\n");
+ } else {
+ GST_DEBUG ("Got Doublebuffered Visual!\n");
+ }
+ glXQueryVersion (new->dpy, &glxMajorVersion, &glxMinorVersion);
+ GST_DEBUG ("glX-Version %d.%d\n", glxMajorVersion, glxMinorVersion);
+
/* create a GLX context */
- new->ctx = glXCreateContext(new->dpy, vi, 0, GL_TRUE);
+ new->ctx = glXCreateContext (new->dpy, vi, 0, GL_TRUE);
/* create a color map */
- cmap = XCreateColormap(new->dpy, RootWindow(new->dpy, vi->screen),
- vi->visual, AllocNone);
+ cmap = XCreateColormap (new->dpy, RootWindow (new->dpy, vi->screen),
+ vi->visual, AllocNone);
new->attr.colormap = cmap;
new->attr.border_pixel = 0;
new->width = 10;
new->height = 10;
- new->rotX = 0;
- new->rotY = 0;
+ new->rotX = 0;
+ new->rotY = 0;
new->zoom = 1;
new->zoomdir = 0.01;
{
- /* create a window in window mode*/
+ /* create a window in window mode */
new->attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask |
- StructureNotifyMask;
- new->win = XCreateWindow(new->dpy, RootWindow(new->dpy, vi->screen),
- new->x, new->y, new->width, new->height, 0, vi->depth, InputOutput, vi->visual,
- CWBorderPixel | CWColormap | CWEventMask, &new->attr);
- if (!new->win)
- {
- g_warning ("create window failed\n");
- g_free (new);
- return;
- }
+ StructureNotifyMask;
+ new->win = XCreateWindow (new->dpy, RootWindow (new->dpy, vi->screen),
+ new->x, new->y, new->width, new->height, 0, vi->depth, InputOutput,
+ vi->visual, CWBorderPixel | CWColormap | CWEventMask, &new->attr);
+ if (!new->win) {
+ g_warning ("create window failed\n");
+ g_free (new);
+ return;
+ }
/* only set window title and handle wm_delete_events if in windowed mode */
- wmDelete = XInternAtom(new->dpy, "WM_DELETE_WINDOW", True);
- XSetWMProtocols(new->dpy, new->win, &wmDelete, 1);
- XSetStandardProperties(new->dpy, new->win, title,
- title, None, NULL, 0, NULL);
- XMapRaised(new->dpy, new->win);
- }
+ wmDelete = XInternAtom (new->dpy, "WM_DELETE_WINDOW", True);
+ XSetWMProtocols (new->dpy, new->win, &wmDelete, 1);
+ XSetStandardProperties (new->dpy, new->win, title,
+ title, None, NULL, 0, NULL);
+ XMapRaised (new->dpy, new->win);
+ }
/* connect the glx-context to the window */
- glXMakeCurrent(new->dpy, new->win, new->ctx);
- XGetGeometry(new->dpy, new->win, &winDummy, &new->x, &new->y,
- &new->width, &new->height, &borderDummy, &new->depth);
- printf("Depth %d\n", new->depth);
- if (glXIsDirect(new->dpy, new->ctx))
- GST_DEBUG ("Congrats, you have Direct Rendering!\n");
+ glXMakeCurrent (new->dpy, new->win, new->ctx);
+ XGetGeometry (new->dpy, new->win, &winDummy, &new->x, &new->y,
+ &new->width, &new->height, &borderDummy, &new->depth);
+ printf ("Depth %d\n", new->depth);
+ if (glXIsDirect (new->dpy, new->ctx))
+ GST_DEBUG ("Congrats, you have Direct Rendering!\n");
else
GST_DEBUG ("Sorry, no Direct Rendering possible!\n");
- g_warning("Initializing OpenGL parameters\n");
+ g_warning ("Initializing OpenGL parameters\n");
/* initialize OpenGL drawing */
- glEnable(GL_DEPTH_TEST);
+ glEnable (GL_DEPTH_TEST);
//glShadeModel(GL_SMOOTH);
- glEnable(GL_TEXTURE_2D);
- glDisable(GL_CULL_FACE);
- glClearDepth(1.0f);
- glClearColor(0, 0, 0, 0);
+ glEnable (GL_TEXTURE_2D);
+ glDisable (GL_CULL_FACE);
+ glClearDepth (1.0f);
+ glClearColor (0, 0, 0, 0);
+
+ glLightfv (GL_LIGHT0, GL_AMBIENT, LightAmbient); /* add lighting. (ambient) */
+ glLightfv (GL_LIGHT0, GL_DIFFUSE, LightDiffuse); /* add lighting. (diffuse). */
+ glLightfv (GL_LIGHT0, GL_POSITION, LightPosition); /* set light position. */
- glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient); /* add lighting. (ambient) */
- glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse); /* add lighting. (diffuse). */
- glLightfv(GL_LIGHT0, GL_POSITION,LightPosition); /* set light position. */
-
- //glEnable(GL_LIGHT0); // Quick And Dirty Lighting (Assumes Light0 Is Set Up)
- //glEnable(GL_LIGHTING); // Enable Lighting
- glDisable(GL_COLOR_MATERIAL); // Enable Material Coloring
- glEnable(GL_AUTO_NORMAL); // let OpenGL generate the Normals
+ //glEnable(GL_LIGHT0); // Quick And Dirty Lighting (Assumes Light0 Is Set Up)
+ //glEnable(GL_LIGHTING); // Enable Lighting
+ glDisable (GL_COLOR_MATERIAL); // Enable Material Coloring
+ glEnable (GL_AUTO_NORMAL); // let OpenGL generate the Normals
- glDisable(GL_BLEND);
+ glDisable (GL_BLEND);
- glPolygonMode(GL_FRONT, GL_FILL);
- glPolygonMode(GL_BACK, GL_FILL);
+ glPolygonMode (GL_FRONT, GL_FILL);
+ glPolygonMode (GL_BACK, GL_FILL);
- glShadeModel(GL_SMOOTH);
- glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
+ glShadeModel (GL_SMOOTH);
+ glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
XSelectInput (new->dpy, new->win, ExposureMask | StructureNotifyMask);
g_object_set (sink, "hook", new, NULL);
new->sink = sink;
- new->handler_id = g_signal_connect (sink, "notify", G_CALLBACK (gst_glxwindow_callback), new);
+ new->handler_id =
+ g_signal_connect (sink, "notify", G_CALLBACK (gst_glxwindow_callback),
+ new);
}
-
unsigned char *VPlane;
// YUV 4:2:2 example
-unsigned int Ywidth=512, Yheight=512;
-unsigned int UVwidth=256, UVheight=512;
+unsigned int Ywidth = 512, Yheight = 512;
+unsigned int UVwidth = 256, UVheight = 512;
int tex_xsize, tex_ysize;
-void GenerateRGBTables(unsigned char *Ytable, // Y-palette
- unsigned char *Utable, // U-palette
- unsigned char *Vtable, // V-palette
- float *bias, // bias (fourth vector to be added)
- float *Uscale, // scaling color for U
- float *Vscale) // scaling color for V
+void
+GenerateRGBTables (unsigned char *Ytable, // Y-palette
+ unsigned char *Utable, // U-palette
+ unsigned char *Vtable, // V-palette
+ float *bias, // bias (fourth vector to be added)
+ float *Uscale, // scaling color for U
+ float *Vscale) // scaling color for V
{
- int i;
- const float mat[9]= { // the modified YUV->RGB matrix
- +1.130469478f,-0.058755723f,+1.596026304f,
- +1.130469478f,-0.450515935f,-0.812967512f,
- +1.130469478f,+1.958477882f, 0.0f
- };
- #define COMPRESS(a)(0.5f*(a)+128.0f) // counter-piece to EXPAND_NORMAL
- #define fCOMPRESS(a) (0.5f*(a)+0.5f);
- #define XCLAMP(a) ((a)<0.0f ? 0.0f : ((a)>255.0f ? 255.0f : (a))) // should not be necessary, but what do you know.
- bias[0]=fCOMPRESS(-0.842580964f);
- bias[1]=fCOMPRESS(+0.563287723f);
- bias[2]=fCOMPRESS(-1.0f);
- bias[3]=0.0f;
- Uscale[0]=8.0f/255.0f;
- Uscale[1]=60.0f/255.0f;
- Uscale[2]=250.0f/255.0f;
- Uscale[3]=0.0f;
- Vscale[0]=204.0f/255.0f;
- Vscale[1]=105.0f/255.0f;
- Vscale[2]=0.5f;
- Vscale[3]=0.0f;
- for (i=0; i<256; i++) {
- // Y-table holds unsigned values
- Ytable[3*i ]=(unsigned char)XCLAMP(mat[0]*(float)i); // R
- Ytable[3*i+1]=(unsigned char)XCLAMP(mat[3]*(float)i); // G
- Ytable[3*i+2]=(unsigned char)XCLAMP(mat[6]*(float)i); // B
- // U-table holds signed values
- Utable[3*i ]=(unsigned char)XCLAMP(COMPRESS(255.0f/ 16.0f*mat[1]*(float)i)); // R
- Utable[3*i+1]=(unsigned char)XCLAMP(COMPRESS(255.0f/120.0f*mat[4]*(float)i)); // G
- Utable[3*i+2]=(unsigned char)XCLAMP(COMPRESS(255.0f/500.0f*mat[7]*(float)i)); // B
- // V-table holds signed values
- Vtable[3*i ]=(unsigned char)XCLAMP(COMPRESS(255.0f/408.0f*mat[2]*(float)i)); // R
- Vtable[3*i+1]=(unsigned char)XCLAMP(COMPRESS(255.0f/210.0f*mat[5]*(float)i)); // G
- Vtable[3*i+2]=(unsigned char)(128.0f-14.0f); // G constant
- }
- #undef fCOMPRESS
- #undef COMPRESS
- #undef XCLAMP
+ int i;
+ const float mat[9] = { // the modified YUV->RGB matrix
+ +1.130469478f, -0.058755723f, +1.596026304f,
+ +1.130469478f, -0.450515935f, -0.812967512f,
+ +1.130469478f, +1.958477882f, 0.0f
+ };
+#define COMPRESS(a)(0.5f*(a)+128.0f) // counter-piece to EXPAND_NORMAL
+#define fCOMPRESS(a) (0.5f*(a)+0.5f);
+#define XCLAMP(a) ((a)<0.0f ? 0.0f : ((a)>255.0f ? 255.0f : (a))) // should not be necessary, but what do you know.
+ bias[0] = fCOMPRESS (-0.842580964f);
+ bias[1] = fCOMPRESS (+0.563287723f);
+ bias[2] = fCOMPRESS (-1.0f);
+ bias[3] = 0.0f;
+ Uscale[0] = 8.0f / 255.0f;
+ Uscale[1] = 60.0f / 255.0f;
+ Uscale[2] = 250.0f / 255.0f;
+ Uscale[3] = 0.0f;
+ Vscale[0] = 204.0f / 255.0f;
+ Vscale[1] = 105.0f / 255.0f;
+ Vscale[2] = 0.5f;
+ Vscale[3] = 0.0f;
+ for (i = 0; i < 256; i++) {
+ // Y-table holds unsigned values
+ Ytable[3 * i] = (unsigned char) XCLAMP (mat[0] * (float) i); // R
+ Ytable[3 * i + 1] = (unsigned char) XCLAMP (mat[3] * (float) i); // G
+ Ytable[3 * i + 2] = (unsigned char) XCLAMP (mat[6] * (float) i); // B
+ // U-table holds signed values
+ Utable[3 * i] = (unsigned char) XCLAMP (COMPRESS (255.0f / 16.0f * mat[1] * (float) i)); // R
+ Utable[3 * i + 1] = (unsigned char) XCLAMP (COMPRESS (255.0f / 120.0f * mat[4] * (float) i)); // G
+ Utable[3 * i + 2] = (unsigned char) XCLAMP (COMPRESS (255.0f / 500.0f * mat[7] * (float) i)); // B
+ // V-table holds signed values
+ Vtable[3 * i] = (unsigned char) XCLAMP (COMPRESS (255.0f / 408.0f * mat[2] * (float) i)); // R
+ Vtable[3 * i + 1] = (unsigned char) XCLAMP (COMPRESS (255.0f / 210.0f * mat[5] * (float) i)); // G
+ Vtable[3 * i + 2] = (unsigned char) (128.0f - 14.0f); // G constant
+ }
+#undef fCOMPRESS
+#undef COMPRESS
+#undef XCLAMP
}
// Sets the constants. Call once prior to rendering.
-void SetConsts(float *bias, float *Uscale, float *Vscale) {
- glEnable(GL_REGISTER_COMBINERS_NV);
- glColor3fv(bias);
- //printf("%f %f %f\n",bias[0],bias[1],bias[2]);
- glCombinerParameterfvNV(GL_CONSTANT_COLOR0_NV,Uscale);
- glCombinerParameterfvNV(GL_CONSTANT_COLOR1_NV,Vscale);
+void
+SetConsts (float *bias, float *Uscale, float *Vscale)
+{
+ glEnable (GL_REGISTER_COMBINERS_NV);
+ glColor3fv (bias);
+ //printf("%f %f %f\n",bias[0],bias[1],bias[2]);
+ glCombinerParameterfvNV (GL_CONSTANT_COLOR0_NV, Uscale);
+ glCombinerParameterfvNV (GL_CONSTANT_COLOR1_NV, Vscale);
}
/*
* SOFTWARE PATH
- */
+ */
-inline void map_EXPAND_NORMAL(float *v) {
- v[0]=2.0f*v[0]-1.0f;
- v[1]=2.0f*v[1]-1.0f;
- v[2]=2.0f*v[2]-1.0f;
+inline void
+map_EXPAND_NORMAL (float *v)
+{
+ v[0] = 2.0f * v[0] - 1.0f;
+ v[1] = 2.0f * v[1] - 1.0f;
+ v[2] = 2.0f * v[2] - 1.0f;
}
-inline void map_UNSIGNED_INVERT(float *v) {
- v[0]=1.0f-v[0];
- v[1]=1.0f-v[1];
- v[2]=1.0f-v[2];
+inline void
+map_UNSIGNED_INVERT (float *v)
+{
+ v[0] = 1.0f - v[0];
+ v[1] = 1.0f - v[1];
+ v[2] = 1.0f - v[2];
}
-inline void map_UNSIGNED_IDENTITY(float *v) {
- v[0]=(v[0]<0.0f ? 0.0f : v[0]);
- v[1]=(v[1]<0.0f ? 0.0f : v[1]);
- v[2]=(v[2]<0.0f ? 0.0f : v[2]);
+inline void
+map_UNSIGNED_IDENTITY (float *v)
+{
+ v[0] = (v[0] < 0.0f ? 0.0f : v[0]);
+ v[1] = (v[1] < 0.0f ? 0.0f : v[1]);
+ v[2] = (v[2] < 0.0f ? 0.0f : v[2]);
}
-inline void map_SIGNED_IDENTITY(float *v) {
+inline void
+map_SIGNED_IDENTITY (float *v)
+{
}
-inline void omap_SCALE_BY_TWO(float *v) {
- v[0]*=2.0f;
- v[1]*=2.0f;
- v[2]*=2.0f;
+inline void
+omap_SCALE_BY_TWO (float *v)
+{
+ v[0] *= 2.0f;
+ v[1] *= 2.0f;
+ v[2] *= 2.0f;
}
-inline void omap_SCALE_BY_ONE_HALF(float *v) {
- v[0]*=0.5f;
- v[1]*=0.5f;
- v[2]*=0.5f;
+inline void
+omap_SCALE_BY_ONE_HALF (float *v)
+{
+ v[0] *= 0.5f;
+ v[1] *= 0.5f;
+ v[2] *= 0.5f;
}
-inline void omap_RANGE(float *v) {
- v[0]=(v[0]<-1.0f ? -1.0f : (v[0]>1.0f ? 1.0f : v[0]));
- v[1]=(v[1]<-1.0f ? -1.0f : (v[1]>1.0f ? 1.0f : v[1]));
- v[2]=(v[2]<-1.0f ? -1.0f : (v[2]>1.0f ? 1.0f : v[2]));
+inline void
+omap_RANGE (float *v)
+{
+ v[0] = (v[0] < -1.0f ? -1.0f : (v[0] > 1.0f ? 1.0f : v[0]));
+ v[1] = (v[1] < -1.0f ? -1.0f : (v[1] > 1.0f ? 1.0f : v[1]));
+ v[2] = (v[2] < -1.0f ? -1.0f : (v[2] > 1.0f ? 1.0f : v[2]));
}
-inline void omap_CLAMP_01(float *v) {
- v[0]=(v[0]<0.0f ? 0.0f : (v[0]>1.0f ? 1.0f : v[0]));
- v[1]=(v[1]<0.0f ? 0.0f : (v[1]>1.0f ? 1.0f : v[1]));
- v[2]=(v[2]<0.0f ? 0.0f : (v[2]>1.0f ? 1.0f : v[2]));
+inline void
+omap_CLAMP_01 (float *v)
+{
+ v[0] = (v[0] < 0.0f ? 0.0f : (v[0] > 1.0f ? 1.0f : v[0]));
+ v[1] = (v[1] < 0.0f ? 0.0f : (v[1] > 1.0f ? 1.0f : v[1]));
+ v[2] = (v[2] < 0.0f ? 0.0f : (v[2] > 1.0f ? 1.0f : v[2]));
}
-void PerformSWCombiner(unsigned char *Result,
- unsigned char *tex0,
- unsigned char *tex1,
- unsigned char *tex2,
- float *COLOR0,
- float *CONST0,
- float *CONST1
- )
+void
+PerformSWCombiner (unsigned char *Result,
+ unsigned char *tex0,
+ unsigned char *tex1,
+ unsigned char *tex2, float *COLOR0, float *CONST0, float *CONST1)
{
- float SPARE0[3];
- float SPARE1[3];
- float A[3],B[3],C[3],D[3];
- float TEX0[3],TEX1[3],TEX2[3];
- float ZERO[3]={0.0f,0.0f,0.0f};
-
- TEX0[0]=(float)tex0[0]/255.0f;
- TEX0[1]=(float)tex0[1]/255.0f;
- TEX0[2]=(float)tex0[2]/255.0f;
-
- TEX1[0]=(float)tex1[0]/255.0f;
- TEX1[1]=(float)tex1[1]/255.0f;
- TEX1[2]=(float)tex1[2]/255.0f;
-
- TEX2[0]=(float)tex2[0]/255.0f;
- TEX2[1]=(float)tex2[1]/255.0f;
- TEX2[2]=(float)tex2[2]/255.0f;
-
- // Combiner Stage 0:
- memcpy(A,TEX0,3*sizeof(float)); map_UNSIGNED_IDENTITY(A);
- memcpy(B,ZERO,3*sizeof(float)); map_UNSIGNED_INVERT(B);
- memcpy(C,COLOR0,3*sizeof(float)); map_EXPAND_NORMAL(C);
- memcpy(D,ZERO,3*sizeof(float)); map_UNSIGNED_INVERT(D);
- SPARE0[0]=A[0]*B[0]+C[0]*D[0];
- SPARE0[1]=A[1]*B[1]+C[1]*D[1];
- SPARE0[2]=A[2]*B[2]+C[2]*D[2];
- omap_SCALE_BY_ONE_HALF(SPARE0);
- omap_RANGE(SPARE0);
-
- // Combiner Stage 1:
- memcpy(A,TEX1,3*sizeof(float)); map_EXPAND_NORMAL(A);
- memcpy(B,CONST0,3*sizeof(float)); map_UNSIGNED_IDENTITY(B);
- memcpy(C,TEX2,3*sizeof(float)); map_EXPAND_NORMAL(C);
- memcpy(D,CONST1,3*sizeof(float)); map_UNSIGNED_IDENTITY(D);
- SPARE1[0]=A[0]*B[0]+C[0]*D[0];
- SPARE1[1]=A[1]*B[1]+C[1]*D[1];
- SPARE1[2]=A[2]*B[2]+C[2]*D[2];
- omap_RANGE(SPARE1);
-
- // Combiner Stage 2:
- memcpy(A,SPARE0,3*sizeof(float)); map_SIGNED_IDENTITY(A);
- memcpy(B,ZERO,3*sizeof(float)); map_UNSIGNED_INVERT(B);
- memcpy(C,SPARE1,3*sizeof(float)); map_SIGNED_IDENTITY(C);
- memcpy(D,ZERO,3*sizeof(float)); map_UNSIGNED_INVERT(D);
- SPARE0[0]=A[0]*B[0]+C[0]*D[0];
- SPARE0[1]=A[1]*B[1]+C[1]*D[1];
- SPARE0[2]=A[2]*B[2]+C[2]*D[2];
- omap_SCALE_BY_TWO(SPARE0);
- omap_RANGE(SPARE0);
-
- // Final Combiner Stage:
- memcpy(A,ZERO,3*sizeof(float)); map_UNSIGNED_INVERT(A);
- memcpy(B,SPARE0,3*sizeof(float)); map_UNSIGNED_IDENTITY(B);
- memcpy(C,ZERO,3*sizeof(float)); map_UNSIGNED_IDENTITY(C);
- memcpy(D,ZERO,3*sizeof(float)); map_UNSIGNED_IDENTITY(D);
- SPARE0[0]=A[0]*B[0]+(1.0f-A[0])*C[0]+D[0];
- SPARE0[1]=A[1]*B[1]+(1.0f-A[1])*C[1]+D[1];
- SPARE0[2]=A[2]*B[2]+(1.0f-A[2])*C[2]+D[2];
- omap_CLAMP_01(SPARE0);
- Result[0]=(unsigned char)(SPARE0[0]*255.0f);
- Result[1]=(unsigned char)(SPARE0[1]*255.0f);
- Result[2]=(unsigned char)(SPARE0[2]*255.0f);
+ float SPARE0[3];
+ float SPARE1[3];
+ float A[3], B[3], C[3], D[3];
+ float TEX0[3], TEX1[3], TEX2[3];
+ float ZERO[3] = { 0.0f, 0.0f, 0.0f };
+
+ TEX0[0] = (float) tex0[0] / 255.0f;
+ TEX0[1] = (float) tex0[1] / 255.0f;
+ TEX0[2] = (float) tex0[2] / 255.0f;
+
+ TEX1[0] = (float) tex1[0] / 255.0f;
+ TEX1[1] = (float) tex1[1] / 255.0f;
+ TEX1[2] = (float) tex1[2] / 255.0f;
+
+ TEX2[0] = (float) tex2[0] / 255.0f;
+ TEX2[1] = (float) tex2[1] / 255.0f;
+ TEX2[2] = (float) tex2[2] / 255.0f;
+
+ // Combiner Stage 0:
+ memcpy (A, TEX0, 3 * sizeof (float));
+ map_UNSIGNED_IDENTITY (A);
+ memcpy (B, ZERO, 3 * sizeof (float));
+ map_UNSIGNED_INVERT (B);
+ memcpy (C, COLOR0, 3 * sizeof (float));
+ map_EXPAND_NORMAL (C);
+ memcpy (D, ZERO, 3 * sizeof (float));
+ map_UNSIGNED_INVERT (D);
+ SPARE0[0] = A[0] * B[0] + C[0] * D[0];
+ SPARE0[1] = A[1] * B[1] + C[1] * D[1];
+ SPARE0[2] = A[2] * B[2] + C[2] * D[2];
+ omap_SCALE_BY_ONE_HALF (SPARE0);
+ omap_RANGE (SPARE0);
+
+ // Combiner Stage 1:
+ memcpy (A, TEX1, 3 * sizeof (float));
+ map_EXPAND_NORMAL (A);
+ memcpy (B, CONST0, 3 * sizeof (float));
+ map_UNSIGNED_IDENTITY (B);
+ memcpy (C, TEX2, 3 * sizeof (float));
+ map_EXPAND_NORMAL (C);
+ memcpy (D, CONST1, 3 * sizeof (float));
+ map_UNSIGNED_IDENTITY (D);
+ SPARE1[0] = A[0] * B[0] + C[0] * D[0];
+ SPARE1[1] = A[1] * B[1] + C[1] * D[1];
+ SPARE1[2] = A[2] * B[2] + C[2] * D[2];
+ omap_RANGE (SPARE1);
+
+ // Combiner Stage 2:
+ memcpy (A, SPARE0, 3 * sizeof (float));
+ map_SIGNED_IDENTITY (A);
+ memcpy (B, ZERO, 3 * sizeof (float));
+ map_UNSIGNED_INVERT (B);
+ memcpy (C, SPARE1, 3 * sizeof (float));
+ map_SIGNED_IDENTITY (C);
+ memcpy (D, ZERO, 3 * sizeof (float));
+ map_UNSIGNED_INVERT (D);
+ SPARE0[0] = A[0] * B[0] + C[0] * D[0];
+ SPARE0[1] = A[1] * B[1] + C[1] * D[1];
+ SPARE0[2] = A[2] * B[2] + C[2] * D[2];
+ omap_SCALE_BY_TWO (SPARE0);
+ omap_RANGE (SPARE0);
+
+ // Final Combiner Stage:
+ memcpy (A, ZERO, 3 * sizeof (float));
+ map_UNSIGNED_INVERT (A);
+ memcpy (B, SPARE0, 3 * sizeof (float));
+ map_UNSIGNED_IDENTITY (B);
+ memcpy (C, ZERO, 3 * sizeof (float));
+ map_UNSIGNED_IDENTITY (C);
+ memcpy (D, ZERO, 3 * sizeof (float));
+ map_UNSIGNED_IDENTITY (D);
+ SPARE0[0] = A[0] * B[0] + (1.0f - A[0]) * C[0] + D[0];
+ SPARE0[1] = A[1] * B[1] + (1.0f - A[1]) * C[1] + D[1];
+ SPARE0[2] = A[2] * B[2] + (1.0f - A[2]) * C[2] + D[2];
+ omap_CLAMP_01 (SPARE0);
+ Result[0] = (unsigned char) (SPARE0[0] * 255.0f);
+ Result[1] = (unsigned char) (SPARE0[1] * 255.0f);
+ Result[2] = (unsigned char) (SPARE0[2] * 255.0f);
}
// Sets up the register combiners. Call once prior to rendering
-void SetupCombiners(void)
+void
+SetupCombiners (void)
{
- glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV,3);
- // Combiner Stage 0: th. OK
- glCombinerInputNV (GL_COMBINER0_NV,GL_RGB,GL_VARIABLE_A_NV,GL_TEXTURE0_ARB, GL_UNSIGNED_IDENTITY_NV,GL_RGB);
- glCombinerInputNV (GL_COMBINER0_NV,GL_RGB,GL_VARIABLE_B_NV,GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB);
- glCombinerInputNV (GL_COMBINER0_NV,GL_RGB,GL_VARIABLE_C_NV,GL_PRIMARY_COLOR_NV,GL_EXPAND_NORMAL_NV, GL_RGB);
- glCombinerInputNV (GL_COMBINER0_NV,GL_RGB,GL_VARIABLE_D_NV,GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB);
- glCombinerOutputNV(GL_COMBINER0_NV,GL_RGB,GL_DISCARD_NV,GL_DISCARD_NV,GL_SPARE0_NV,GL_SCALE_BY_ONE_HALF_NV,GL_NONE,GL_FALSE,GL_FALSE,GL_FALSE);
- // Combiner Stage 1: th. OK
- glCombinerInputNV (GL_COMBINER1_NV,GL_RGB,GL_VARIABLE_A_NV,GL_TEXTURE1_ARB, GL_EXPAND_NORMAL_NV, GL_RGB);
- glCombinerInputNV (GL_COMBINER1_NV,GL_RGB,GL_VARIABLE_B_NV,GL_CONSTANT_COLOR0_NV,GL_UNSIGNED_IDENTITY_NV,GL_RGB);
- glCombinerInputNV (GL_COMBINER1_NV,GL_RGB,GL_VARIABLE_C_NV,GL_TEXTURE2_ARB, GL_EXPAND_NORMAL_NV, GL_RGB);
- glCombinerInputNV (GL_COMBINER1_NV,GL_RGB,GL_VARIABLE_D_NV,GL_CONSTANT_COLOR1_NV,GL_UNSIGNED_IDENTITY_NV,GL_RGB);
- glCombinerOutputNV(GL_COMBINER1_NV,GL_RGB,GL_DISCARD_NV,GL_DISCARD_NV,GL_SPARE1_NV,GL_NONE,GL_NONE,GL_FALSE,GL_FALSE,GL_FALSE);
- // Combiner Stage 2: th. OK
- glCombinerInputNV (GL_COMBINER2_NV,GL_RGB,GL_VARIABLE_A_NV,GL_SPARE0_NV, GL_SIGNED_IDENTITY_NV, GL_RGB);
- glCombinerInputNV (GL_COMBINER2_NV,GL_RGB,GL_VARIABLE_B_NV,GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB);
- glCombinerInputNV (GL_COMBINER2_NV,GL_RGB,GL_VARIABLE_C_NV,GL_SPARE1_NV, GL_SIGNED_IDENTITY_NV, GL_RGB);
- glCombinerInputNV (GL_COMBINER2_NV,GL_RGB,GL_VARIABLE_D_NV,GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB);
- glCombinerOutputNV(GL_COMBINER2_NV,GL_RGB,GL_DISCARD_NV,GL_DISCARD_NV,GL_SPARE0_NV,GL_SCALE_BY_TWO_NV,GL_NONE,GL_FALSE,GL_FALSE,GL_FALSE);
- // Final Sage: th. OK
- glFinalCombinerInputNV(GL_VARIABLE_A_NV,GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB);
- glFinalCombinerInputNV(GL_VARIABLE_B_NV,GL_SPARE0_NV,GL_UNSIGNED_IDENTITY_NV,GL_RGB);
- glFinalCombinerInputNV(GL_VARIABLE_C_NV,GL_ZERO, GL_UNSIGNED_IDENTITY_NV,GL_RGB);
- glFinalCombinerInputNV(GL_VARIABLE_D_NV,GL_ZERO, GL_UNSIGNED_IDENTITY_NV,GL_RGB);
- glFinalCombinerInputNV(GL_VARIABLE_G_NV,GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_ALPHA);
+ glCombinerParameteriNV (GL_NUM_GENERAL_COMBINERS_NV, 3);
+ // Combiner Stage 0: th. OK
+ glCombinerInputNV (GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_A_NV, GL_TEXTURE0_ARB,
+ GL_UNSIGNED_IDENTITY_NV, GL_RGB);
+ glCombinerInputNV (GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_B_NV, GL_ZERO,
+ GL_UNSIGNED_INVERT_NV, GL_RGB);
+ glCombinerInputNV (GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_C_NV,
+ GL_PRIMARY_COLOR_NV, GL_EXPAND_NORMAL_NV, GL_RGB);
+ glCombinerInputNV (GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_D_NV, GL_ZERO,
+ GL_UNSIGNED_INVERT_NV, GL_RGB);
+ glCombinerOutputNV (GL_COMBINER0_NV, GL_RGB, GL_DISCARD_NV, GL_DISCARD_NV,
+ GL_SPARE0_NV, GL_SCALE_BY_ONE_HALF_NV, GL_NONE, GL_FALSE, GL_FALSE,
+ GL_FALSE);
+ // Combiner Stage 1: th. OK
+ glCombinerInputNV (GL_COMBINER1_NV, GL_RGB, GL_VARIABLE_A_NV, GL_TEXTURE1_ARB,
+ GL_EXPAND_NORMAL_NV, GL_RGB);
+ glCombinerInputNV (GL_COMBINER1_NV, GL_RGB, GL_VARIABLE_B_NV,
+ GL_CONSTANT_COLOR0_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
+ glCombinerInputNV (GL_COMBINER1_NV, GL_RGB, GL_VARIABLE_C_NV, GL_TEXTURE2_ARB,
+ GL_EXPAND_NORMAL_NV, GL_RGB);
+ glCombinerInputNV (GL_COMBINER1_NV, GL_RGB, GL_VARIABLE_D_NV,
+ GL_CONSTANT_COLOR1_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
+ glCombinerOutputNV (GL_COMBINER1_NV, GL_RGB, GL_DISCARD_NV, GL_DISCARD_NV,
+ GL_SPARE1_NV, GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE);
+ // Combiner Stage 2: th. OK
+ glCombinerInputNV (GL_COMBINER2_NV, GL_RGB, GL_VARIABLE_A_NV, GL_SPARE0_NV,
+ GL_SIGNED_IDENTITY_NV, GL_RGB);
+ glCombinerInputNV (GL_COMBINER2_NV, GL_RGB, GL_VARIABLE_B_NV, GL_ZERO,
+ GL_UNSIGNED_INVERT_NV, GL_RGB);
+ glCombinerInputNV (GL_COMBINER2_NV, GL_RGB, GL_VARIABLE_C_NV, GL_SPARE1_NV,
+ GL_SIGNED_IDENTITY_NV, GL_RGB);
+ glCombinerInputNV (GL_COMBINER2_NV, GL_RGB, GL_VARIABLE_D_NV, GL_ZERO,
+ GL_UNSIGNED_INVERT_NV, GL_RGB);
+ glCombinerOutputNV (GL_COMBINER2_NV, GL_RGB, GL_DISCARD_NV, GL_DISCARD_NV,
+ GL_SPARE0_NV, GL_SCALE_BY_TWO_NV, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE);
+ // Final Sage: th. OK
+ glFinalCombinerInputNV (GL_VARIABLE_A_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV,
+ GL_RGB);
+ glFinalCombinerInputNV (GL_VARIABLE_B_NV, GL_SPARE0_NV,
+ GL_UNSIGNED_IDENTITY_NV, GL_RGB);
+ glFinalCombinerInputNV (GL_VARIABLE_C_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV,
+ GL_RGB);
+ glFinalCombinerInputNV (GL_VARIABLE_D_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV,
+ GL_RGB);
+ glFinalCombinerInputNV (GL_VARIABLE_G_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV,
+ GL_ALPHA);
}
-unsigned int PowerOfTwo(unsigned int i) {
- unsigned int bitsum=0;
- unsigned int shifts=0;
- unsigned int j=(unsigned int)i;
- // Check wether i is a power of two - may contain at most one set bit
- do {
- bitsum+=j&1;
- j=j>>1;
- ++shifts;
- } while (j>0);
- if (bitsum==1) return i;
- else return (1<<shifts);
+unsigned int
+PowerOfTwo (unsigned int i)
+{
+ unsigned int bitsum = 0;
+ unsigned int shifts = 0;
+ unsigned int j = (unsigned int) i;
+
+ // Check wether i is a power of two - may contain at most one set bit
+ do {
+ bitsum += j & 1;
+ j = j >> 1;
+ ++shifts;
+ } while (j > 0);
+ if (bitsum == 1)
+ return i;
+ else
+ return (1 << shifts);
}
// Initializes textures. Call once prior to rendering
-void InitYUVPlanes(GLuint *Yhandle, GLuint *Uhandle, GLuint *Vhandle,
- unsigned int Ywidth, unsigned int Yheight,
- unsigned int UVwidth, unsigned int UVheight,
- GLenum filter, // filter should be either GL_NEAREST or GL_LINEAR. Test this!
- unsigned char* Ypal, unsigned char *Upal, unsigned char *Vpal)
+void
+InitYUVPlanes (GLuint * Yhandle, GLuint * Uhandle, GLuint * Vhandle, unsigned int Ywidth, unsigned int Yheight, unsigned int UVwidth, unsigned int UVheight, GLenum filter, // filter should be either GL_NEAREST or GL_LINEAR. Test this!
+ unsigned char *Ypal, unsigned char *Upal, unsigned char *Vpal)
{
- glGenTextures(1,Yhandle);
- glGenTextures(1,Uhandle);
- glGenTextures(1,Vhandle);
- glBindTexture(GL_TEXTURE_2D,(*Yhandle));
+ glGenTextures (1, Yhandle);
+ glGenTextures (1, Uhandle);
+ glGenTextures (1, Vhandle);
+ glBindTexture (GL_TEXTURE_2D, (*Yhandle));
#ifdef _WIN32
- glColorTableEXT(GL_TEXTURE_2D,GL_RGB8,256,GL_RGB,GL_UNSIGNED_BYTE,Ypal);
+ glColorTableEXT (GL_TEXTURE_2D, GL_RGB8, 256, GL_RGB, GL_UNSIGNED_BYTE, Ypal);
#else // Hopefully Linux
- glColorTable(GL_TEXTURE_2D,GL_RGB8,256,GL_RGB,GL_UNSIGNED_BYTE,Ypal);
+ glColorTable (GL_TEXTURE_2D, GL_RGB8, 256, GL_RGB, GL_UNSIGNED_BYTE, Ypal);
#endif
- glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,filter);
- glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,filter);
- glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP);
- glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);
- tex_xsize = PowerOfTwo(Ywidth);
- tex_ysize = PowerOfTwo(Yheight);
- glTexImage2D(GL_TEXTURE_2D,0,GL_COLOR_INDEX8_EXT,PowerOfTwo(Ywidth),PowerOfTwo(Yheight),0,GL_COLOR_INDEX,GL_UNSIGNED_BYTE,NULL);
-
- glBindTexture(GL_TEXTURE_2D,(*Uhandle));
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+ tex_xsize = PowerOfTwo (Ywidth);
+ tex_ysize = PowerOfTwo (Yheight);
+ glTexImage2D (GL_TEXTURE_2D, 0, GL_COLOR_INDEX8_EXT, PowerOfTwo (Ywidth),
+ PowerOfTwo (Yheight), 0, GL_COLOR_INDEX, GL_UNSIGNED_BYTE, NULL);
+
+ glBindTexture (GL_TEXTURE_2D, (*Uhandle));
#ifdef _WIN32
- glColorTableEXT(GL_TEXTURE_2D,GL_RGB8,256,GL_RGB,GL_UNSIGNED_BYTE,Upal);
+ glColorTableEXT (GL_TEXTURE_2D, GL_RGB8, 256, GL_RGB, GL_UNSIGNED_BYTE, Upal);
#else // Hopefully Linux
- glColorTable(GL_TEXTURE_2D,GL_RGB8,256,GL_RGB,GL_UNSIGNED_BYTE,Upal);
+ glColorTable (GL_TEXTURE_2D, GL_RGB8, 256, GL_RGB, GL_UNSIGNED_BYTE, Upal);
#endif
- glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,filter);
- glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,filter);
- glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP);
- glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);
- glTexImage2D(GL_TEXTURE_2D,0,GL_COLOR_INDEX8_EXT,PowerOfTwo(UVwidth),PowerOfTwo(UVheight),0,GL_COLOR_INDEX,GL_UNSIGNED_BYTE,NULL);
-
- glBindTexture(GL_TEXTURE_2D,(*Vhandle));
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+ glTexImage2D (GL_TEXTURE_2D, 0, GL_COLOR_INDEX8_EXT, PowerOfTwo (UVwidth),
+ PowerOfTwo (UVheight), 0, GL_COLOR_INDEX, GL_UNSIGNED_BYTE, NULL);
+
+ glBindTexture (GL_TEXTURE_2D, (*Vhandle));
#ifdef _WIN32
- glColorTableEXT(GL_TEXTURE_2D,GL_RGB8,256,GL_RGB,GL_UNSIGNED_BYTE,Vpal);
+ glColorTableEXT (GL_TEXTURE_2D, GL_RGB8, 256, GL_RGB, GL_UNSIGNED_BYTE, Vpal);
#else // Hopefully Linux
- glColorTable(GL_TEXTURE_2D,GL_RGB8,256,GL_RGB,GL_UNSIGNED_BYTE,Vpal);
+ glColorTable (GL_TEXTURE_2D, GL_RGB8, 256, GL_RGB, GL_UNSIGNED_BYTE, Vpal);
#endif
- glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,filter);
- glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,filter);
- glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP);
- glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);
- glTexImage2D(GL_TEXTURE_2D,0,GL_COLOR_INDEX8_EXT,PowerOfTwo(UVwidth),PowerOfTwo(UVheight),0,GL_COLOR_INDEX,GL_UNSIGNED_BYTE,NULL);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+ glTexImage2D (GL_TEXTURE_2D, 0, GL_COLOR_INDEX8_EXT, PowerOfTwo (UVwidth),
+ PowerOfTwo (UVheight), 0, GL_COLOR_INDEX, GL_UNSIGNED_BYTE, NULL);
}
-void LoadYUVPlanes(GLuint Yhandle, GLuint Uhandle, GLuint Vhandle,
- unsigned int Ywidth, unsigned int Yheight,
- unsigned int UVwidth, unsigned int UVheight,
- unsigned char *Ydata,
- unsigned char *Udata,
- unsigned char *Vdata)
+void
+LoadYUVPlanes (GLuint Yhandle, GLuint Uhandle, GLuint Vhandle,
+ unsigned int Ywidth, unsigned int Yheight,
+ unsigned int UVwidth, unsigned int UVheight,
+ unsigned char *Ydata, unsigned char *Udata, unsigned char *Vdata)
{
- glActiveTextureARB(GL_TEXTURE0_ARB);
- glBindTexture(GL_TEXTURE_2D,Yhandle);
- glTexSubImage2D(GL_TEXTURE_2D,0,0,0,Ywidth,Yheight,GL_COLOR_INDEX,GL_UNSIGNED_BYTE,Ydata);
- glEnable(GL_TEXTURE_2D);
-
- glActiveTextureARB(GL_TEXTURE1_ARB);
- glBindTexture(GL_TEXTURE_2D,Uhandle);
- glTexSubImage2D(GL_TEXTURE_2D,0,0,0,UVwidth,UVheight,GL_COLOR_INDEX,GL_UNSIGNED_BYTE,Udata);
- glEnable(GL_TEXTURE_2D);
-
- glActiveTextureARB(GL_TEXTURE2_ARB);
- glBindTexture(GL_TEXTURE_2D,Vhandle);
- glTexSubImage2D(GL_TEXTURE_2D,0,0,0,UVwidth,UVheight,GL_COLOR_INDEX,GL_UNSIGNED_BYTE,Vdata);
- glEnable(GL_TEXTURE_2D);
+ glActiveTextureARB (GL_TEXTURE0_ARB);
+ glBindTexture (GL_TEXTURE_2D, Yhandle);
+ glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, Ywidth, Yheight, GL_COLOR_INDEX,
+ GL_UNSIGNED_BYTE, Ydata);
+ glEnable (GL_TEXTURE_2D);
+
+ glActiveTextureARB (GL_TEXTURE1_ARB);
+ glBindTexture (GL_TEXTURE_2D, Uhandle);
+ glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, UVwidth, UVheight, GL_COLOR_INDEX,
+ GL_UNSIGNED_BYTE, Udata);
+ glEnable (GL_TEXTURE_2D);
+
+ glActiveTextureARB (GL_TEXTURE2_ARB);
+ glBindTexture (GL_TEXTURE_2D, Vhandle);
+ glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, UVwidth, UVheight, GL_COLOR_INDEX,
+ GL_UNSIGNED_BYTE, Vdata);
+ glEnable (GL_TEXTURE_2D);
}
-void Initialize_Backend(unsigned int Ywidth, unsigned int Yheight, unsigned int UVwidth, unsigned int UVheight, GLenum filter)
+void
+Initialize_Backend (unsigned int Ywidth, unsigned int Yheight,
+ unsigned int UVwidth, unsigned int UVheight, GLenum filter)
{
- printf("Reinitializing register combiner backend with res %d x %d!\n", Ywidth, Yheight);
+ printf ("Reinitializing register combiner backend with res %d x %d!\n",
+ Ywidth, Yheight);
//if (!GL_ARB_multitexture_Init()) exit(0);
//if (!GL_EXT_paletted_texture_Init()) exit(0);
//if (!GL_NV_register_combiners_Init()) exit(0);
float bias[4];
float Uscale[4];
float Vscale[4];
- GenerateRGBTables(Ypal,Upal,Vpal,bias,Uscale,Vscale);
- InitYUVPlanes(&Yhandle,&Uhandle,&Vhandle,Ywidth,Yheight,UVwidth,UVheight,filter,Ypal,Upal,Vpal);
- SetupCombiners();
- SetConsts(bias,Uscale,Vscale);
+
+ GenerateRGBTables (Ypal, Upal, Vpal, bias, Uscale, Vscale);
+ InitYUVPlanes (&Yhandle, &Uhandle, &Vhandle, Ywidth, Yheight, UVwidth,
+ UVheight, filter, Ypal, Upal, Vpal);
+ SetupCombiners ();
+ SetConsts (bias, Uscale, Vscale);
}
-void initialize(GLenum filter) {
- glShadeModel(GL_SMOOTH);
- glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
- glClearColor(0.0f,0.0f,0.2f,1.0f);
- Initialize_Backend(Ywidth,Yheight,UVwidth,UVheight,filter);
+void
+initialize (GLenum filter)
+{
+ glShadeModel (GL_SMOOTH);
+ glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
+ glClearColor (0.0f, 0.0f, 0.2f, 1.0f);
+ Initialize_Backend (Ywidth, Yheight, UVwidth, UVheight, filter);
}
#define FNAME "qcam.darkfile"
static unsigned char master_darkmask1[MAX_HEIGHT][MAX_WIDTH];
-static unsigned char master_darkmask2[MAX_HEIGHT/2+1][MAX_WIDTH/2+1];
-static unsigned char master_darkmask4[MAX_HEIGHT/4+1][MAX_WIDTH/4+1];
+static unsigned char master_darkmask2[MAX_HEIGHT / 2 + 1][MAX_WIDTH / 2 + 1];
+static unsigned char master_darkmask4[MAX_HEIGHT / 4 + 1][MAX_WIDTH / 4 + 1];
/*
int
*/
int
-fixdark(const struct qcam *q, scanbuf *scan)
+fixdark (const struct qcam *q, scanbuf * scan)
{
static int init = 0;
static int smallest_dm = 255;
int scale = q->transfer_scale;
if (!init) {
- if (!read_darkmask()) return 0;
+ if (!read_darkmask ())
+ return 0;
for (y = 0; y < MAX_HEIGHT; y++)
for (x = 0; x < MAX_HEIGHT; x++)
- if (master_darkmask1[y][x] < smallest_dm) {
+ if (master_darkmask1[y][x] < smallest_dm) {
smallest_dm = master_darkmask1[y][x];
#ifdef DEBUG
- fprintf(stderr, "Smallest mask is %d at (%d, %d)\n",
- smallest_dm, x, y);
+ fprintf (stderr, "Smallest mask is %d at (%d, %d)\n",
+ smallest_dm, x, y);
#endif
}
init = 1;
if (brightness < smallest_dm) {
#ifdef DEBUG
- fprintf(stderr, "Brightness %d (dark current starts at %d), no fixup needed\n",
+ fprintf (stderr,
+ "Brightness %d (dark current starts at %d), no fixup needed\n",
brightness, smallest_dm);
#endif
return 1;
darkmask[y][x] = master_darkmask4[y][x];
} else {
#ifdef DEBUG
- fprintf(stderr, "Bad transfer_scale in darkmask assignment!\n");
+ fprintf (stderr, "Bad transfer_scale in darkmask assignment!\n");
#endif
return 0;
}
do {
again = 0;
- ccd_y = (q->top-1)/scale;
+ ccd_y = (q->top - 1) / scale;
for (y = 0; y < height; y++, ccd_y++) {
- ccd_x = q->left-1;
+ ccd_x = q->left - 1;
ccd_x /= 2;
ccd_x *= 2;
ccd_x /= scale;
for (x = 0; x < width; x++, ccd_x++) {
- val = scan[y*width + x];
- if (brightness < darkmask[ccd_y][ccd_x]) { /* good pixel */
+ val = scan[y * width + x];
+ if (brightness < darkmask[ccd_y][ccd_x]) { /* good pixel */
new_image[y][x] = val;
- } else { /* bad pixel */
+ } else { /* bad pixel */
/* look at nearby pixels, average the good values */
pixelcount = 0;
pixeltotal = 0;
- if (x > 0) { /* left */
- if (brightness < darkmask[ccd_y][ccd_x-1]) {
+ if (x > 0) { /* left */
+ if (brightness < darkmask[ccd_y][ccd_x - 1]) {
pixelcount++;
- pixeltotal += scan[y*width + x - 1];
+ pixeltotal += scan[y * width + x - 1];
}
}
- if (x < width-1) { /* right */
- if (brightness < darkmask[ccd_y][ccd_x+1]) {
+ if (x < width - 1) { /* right */
+ if (brightness < darkmask[ccd_y][ccd_x + 1]) {
pixelcount++;
- pixeltotal += scan[y*width + x + 1];
+ pixeltotal += scan[y * width + x + 1];
}
}
- if (y > 0) { /* above */
- if (brightness < darkmask[ccd_y-1][ccd_x]) {
+ if (y > 0) { /* above */
+ if (brightness < darkmask[ccd_y - 1][ccd_x]) {
pixelcount++;
- pixeltotal += scan[(y-1)*width + x];
+ pixeltotal += scan[(y - 1) * width + x];
}
}
- if (y < height-1) { /* below */
- if (brightness < darkmask[ccd_y+1][ccd_x]) {
+ if (y < height - 1) { /* below */
+ if (brightness < darkmask[ccd_y + 1][ccd_x]) {
pixelcount++;
- pixeltotal += scan[(y+1)*width + x];
+ pixeltotal += scan[(y + 1) * width + x];
}
}
-
- if (pixelcount == 0) { /* no valid neighbors! */
+
+ if (pixelcount == 0) { /* no valid neighbors! */
again = 1;
} else {
new_image[y][x] = pixeltotal / pixelcount;
for (y = 0; y < height; y++)
for (x = 0; x < width; x++)
- scan[y*width + x] = new_image[y][x];
+ scan[y * width + x] = new_image[y][x];
} while (loopcount++ < MAX_LOOPS && again);
#ifdef DEBUG
- fprintf(stderr, "Darkmask fix took %d loop%s\n",
- loopcount, (loopcount == 1)?"":"s");
+ fprintf (stderr, "Darkmask fix took %d loop%s\n",
+ loopcount, (loopcount == 1) ? "" : "s");
#endif
return 1;
}
-
* prototyped in qcamip.h
*/
-static int qcip_pixel_average(struct qcam *q, scanbuf *scan);
-static int qcip_luminance_std(struct qcam *q, scanbuf *scan, int avg);
+static int qcip_pixel_average (struct qcam *q, scanbuf * scan);
+static int qcip_luminance_std (struct qcam *q, scanbuf * scan, int avg);
/* Private data used by the auto exposure routine */
/* Calculate average pixel value for entire image */
static int
-qcip_pixel_average(struct qcam *q, scanbuf *scan)
+qcip_pixel_average (struct qcam *q, scanbuf * scan)
{
int count = 0;
int sum = 0;
/* Calculate average pixel value for center of image */
static int
-qcip_pixel_average_center(struct qcam *q, scanbuf *scan)
+qcip_pixel_average_center (struct qcam *q, scanbuf * scan)
{
int count = 0;
int sum = 0;
width = q->width / q->transfer_scale;
height = q->height / q->transfer_scale;
- maxcol = width * 2 / 3;
+ maxcol = width * 2 / 3;
maxrow = height * 2 / 3;
- for (i = width/3; i < maxcol; i++) {
- for (j = height/3; j < maxrow; j++) {
- sum += scan[j*width+i];
+ for (i = width / 3; i < maxcol; i++) {
+ for (j = height / 3; j < maxrow; j++) {
+ sum += scan[j * width + i];
count++;
}
}
}
int
-qcip_set_luminance_target(struct qcam *q, int val)
+qcip_set_luminance_target (struct qcam *q, int val)
{
const int max_pixel_val = q->bpp == 6 ? 63 : 15;
}
int
-qcip_set_luminance_tolerance(struct qcam *q, int val)
+qcip_set_luminance_tolerance (struct qcam *q, int val)
{
const int max_pixel_val = q->bpp == 6 ? 63 : 15;
}
int
-qcip_set_luminance_std_target(struct qcam *q, int val)
+qcip_set_luminance_std_target (struct qcam *q, int val)
{
luminance_std_target = val;
return QCIP_XPSR_OK;
}
int
-qcip_set_luminance_std_tolerance(struct qcam *q, int val)
+qcip_set_luminance_std_tolerance (struct qcam *q, int val)
{
luminance_std_tolerance = val;
return QCIP_XPSR_OK;
}
int
-qcip_set_autoexposure_mode(int val)
+qcip_set_autoexposure_mode (int val)
{
ae_mode = val;
return 0;
/* Calculate standard deviation of pixel value for entire image */
static int
-qcip_luminance_std(struct qcam *q, scanbuf *scan, int avg)
+qcip_luminance_std (struct qcam *q, scanbuf * scan, int avg)
{
int count = 0;
int sum = 0;
*/
int
-qcip_autoexposure(struct qcam *q, scanbuf *scan)
+qcip_autoexposure (struct qcam *q, scanbuf * scan)
{
int luminance_dif;
int luminance_avg;
int ret = QCIP_XPSR_OK;
#ifdef DEBUG
- fprintf(stderr, "Brightness: %d Contrast: %d\n",
- qc_getbrightness(q), qc_getcontrast(q));
+ fprintf (stderr, "Brightness: %d Contrast: %d\n",
+ qc_getbrightness (q), qc_getcontrast (q));
#endif
switch (ae_mode) {
- case AE_CTR_AVG:
- luminance_avg = qcip_pixel_average_center(q, scan);
- break;
- case AE_STD_AVG:
- luminance_avg = qcip_pixel_average(q, scan);
- lum_std = qcip_luminance_std(q, scan, luminance_avg);
-
- /* ==>> Contrast adjustment <<== */
-
- /* set target if it has not been explicitly set */
- if (luminance_std_target == -1) {
- luminance_std_target = q->bpp == 6 ? 10 : 2;
- }
+ case AE_CTR_AVG:
+ luminance_avg = qcip_pixel_average_center (q, scan);
+ break;
+ case AE_STD_AVG:
+ luminance_avg = qcip_pixel_average (q, scan);
+ lum_std = qcip_luminance_std (q, scan, luminance_avg);
+
+ /* ==>> Contrast adjustment <<== */
+
+ /* set target if it has not been explicitly set */
+ if (luminance_std_target == -1) {
+ luminance_std_target = q->bpp == 6 ? 10 : 2;
+ }
- /* Adjust contrast to reach target luminance standard deviation */
- lum_std_min = luminance_std_target - luminance_std_tolerance;
- lum_std_max = luminance_std_target + luminance_std_tolerance;
+ /* Adjust contrast to reach target luminance standard deviation */
+ lum_std_min = luminance_std_target - luminance_std_tolerance;
+ lum_std_max = luminance_std_target + luminance_std_tolerance;
- if (lum_std < lum_std_min || lum_std > lum_std_max) {
- ret = QCIP_XPSR_RSCN;
- if (qc_setcontrast(q, luminance_std_target - lum_std + qc_getcontrast(q))) {
- return QCIP_XPSR_ERR;
+ if (lum_std < lum_std_min || lum_std > lum_std_max) {
+ ret = QCIP_XPSR_RSCN;
+ if (qc_setcontrast (q,
+ luminance_std_target - lum_std + qc_getcontrast (q))) {
+ return QCIP_XPSR_ERR;
+ }
}
- }
#ifdef DEBUG
- fprintf(stderr, "Luminance std/target/tolerance: %d/%d/%d\n",
- lum_std, luminance_std_target, luminance_std_tolerance );
+ fprintf (stderr, "Luminance std/target/tolerance: %d/%d/%d\n",
+ lum_std, luminance_std_target, luminance_std_tolerance);
#endif
-
- break;
- case AE_ALL_AVG:
- default:
- luminance_avg = qcip_pixel_average(q, scan);
- break;
+
+ break;
+ case AE_ALL_AVG:
+ default:
+ luminance_avg = qcip_pixel_average (q, scan);
+ break;
}
/* ==>> Brightness adjustment <<== */
lum_max = luminance_target + luminance_tolerance;
#ifdef DEBUG
- fprintf(stderr, "Luminance avg/target/tolerance: %d/%d/%d\n",
- luminance_avg, luminance_target, luminance_tolerance );
+ fprintf (stderr, "Luminance avg/target/tolerance: %d/%d/%d\n",
+ luminance_avg, luminance_target, luminance_tolerance);
#endif
/* check for luminance within target range */
/* Adjusted brightness is out of range ..
* throw in the towel ... auto-exposure has failed!
*/
- if (qc_setbrightness(q, brightness_adj + qc_getbrightness(q))) {
+ if (qc_setbrightness (q, brightness_adj + qc_getbrightness (q))) {
return QCIP_XPSR_ERR;
}
}
#include "qcamip.h"
/* elementfactory information */
-static GstElementDetails gst_qcamsrc_details = GST_ELEMENT_DETAILS (
- "QCam Source",
- "Source/Video",
- "Read from a QuickCam device",
- "Wim Taymans <wim.taymans@chello.be>"
-);
+static GstElementDetails gst_qcamsrc_details =
+GST_ELEMENT_DETAILS ("QCam Source",
+ "Source/Video",
+ "Read from a QuickCam device",
+ "Wim Taymans <wim.taymans@chello.be>");
#define AE_NONE 3
#define DEF_AUTOEXP AE_NONE
static GstStaticPadTemplate gst_qcamsrc_src_factory =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV("I420"))
-);
+GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420"))
+ );
#define GST_TYPE_AUTOEXP_MODE (gst_autoexp_mode_get_type())
static GType
{
static GType autoexp_mode_type = 0;
static GEnumValue autoexp_modes[] = {
- { AE_ALL_AVG, "0", "Average Picture" },
- { AE_CTR_AVG, "1", "Average Center" },
- { AE_STD_AVG, "2", "Standard Deviation" },
- { AE_NONE, "3", "None" },
- { 0, NULL, NULL },
+ {AE_ALL_AVG, "0", "Average Picture"},
+ {AE_CTR_AVG, "1", "Average Center"},
+ {AE_STD_AVG, "2", "Standard Deviation"},
+ {AE_NONE, "3", "None"},
+ {0, NULL, NULL},
};
if (!autoexp_mode_type) {
- autoexp_mode_type = g_enum_register_static ("GstAutoExposureMode", autoexp_modes);
+ autoexp_mode_type =
+ g_enum_register_static ("GstAutoExposureMode", autoexp_modes);
}
return autoexp_mode_type;
}
/* QCamSrc signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_WIDTH,
ARG_HEIGHT,
ARG_AUTOEXP,
};
-static void gst_qcamsrc_base_init (gpointer g_class);
-static void gst_qcamsrc_class_init (GstQCamSrcClass *klass);
-static void gst_qcamsrc_init (GstQCamSrc *qcamsrc);
+static void gst_qcamsrc_base_init (gpointer g_class);
+static void gst_qcamsrc_class_init (GstQCamSrcClass * klass);
+static void gst_qcamsrc_init (GstQCamSrc * qcamsrc);
-static void gst_qcamsrc_set_property (GObject *object, guint prop_id,
- const GValue *value, GParamSpec *pspec);
-static void gst_qcamsrc_get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec);
+static void gst_qcamsrc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_qcamsrc_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
-static GstElementStateReturn gst_qcamsrc_change_state (GstElement *element);
-static void gst_qcamsrc_close (GstQCamSrc *src);
-static gboolean gst_qcamsrc_open (GstQCamSrc *src);
+static GstElementStateReturn gst_qcamsrc_change_state (GstElement * element);
+static void gst_qcamsrc_close (GstQCamSrc * src);
+static gboolean gst_qcamsrc_open (GstQCamSrc * src);
-static GstData* gst_qcamsrc_get (GstPad *pad);
+static GstData *gst_qcamsrc_get (GstPad * pad);
static GstElementClass *parent_class = NULL;
+
/*//static guint gst_qcamsrc_signals[LAST_SIGNAL] = { 0 }; */
GType
if (!qcamsrc_type) {
static const GTypeInfo qcamsrc_info = {
- sizeof(GstQCamSrcClass),
+ sizeof (GstQCamSrcClass),
gst_qcamsrc_base_init,
NULL,
- (GClassInitFunc)gst_qcamsrc_class_init,
+ (GClassInitFunc) gst_qcamsrc_class_init,
NULL,
NULL,
- sizeof(GstQCamSrc),
+ sizeof (GstQCamSrc),
0,
- (GInstanceInitFunc)gst_qcamsrc_init,
+ (GInstanceInitFunc) gst_qcamsrc_init,
NULL
};
- qcamsrc_type = g_type_register_static(GST_TYPE_ELEMENT, "GstQCamSrc", &qcamsrc_info, 0);
+ qcamsrc_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "GstQCamSrc", &qcamsrc_info,
+ 0);
}
return qcamsrc_type;
}
gst_qcamsrc_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
- gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&gst_qcamsrc_src_factory));
+
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_qcamsrc_src_factory));
gst_element_class_set_details (element_class, &gst_qcamsrc_details);
}
static void
-gst_qcamsrc_class_init (GstQCamSrcClass *klass)
+gst_qcamsrc_class_init (GstQCamSrcClass * 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);
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_WIDTH,
- g_param_spec_int ("width", "width", "width",
- 0, 320, DEF_WIDTH, G_PARAM_READWRITE));
- g_object_class_install_property (G_OBJECT_CLASS(klass), ARG_HEIGHT,
- g_param_spec_int ("height", "height", "height",
- 0, 240, DEF_HEIGHT, G_PARAM_READWRITE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_BRIGHTNESS,
- g_param_spec_int ("brightness", "brightness", "brightness",
- 0, 255, DEF_BRIGHTNESS, G_PARAM_READWRITE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_WHITEBAL,
- g_param_spec_int ("whitebal", "whitebal", "whitebal",
- 0, 255, DEF_WHITEBAL, G_PARAM_READWRITE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_CONTRAST,
- g_param_spec_int ("contrast", "contrast", "contrast",
- 0, 255, DEF_CONTRAST, G_PARAM_READWRITE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_TOP,
- g_param_spec_int ("top", "top", "top",
- 0, 240, DEF_TOP, G_PARAM_READWRITE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_LEFT,
- g_param_spec_int ("left", "left", "left",
- 0, 320, DEF_LEFT, G_PARAM_READWRITE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_TRANSFER_SCALE,
- g_param_spec_int ("transfer_scale", "transfer_scale", "transfer_scale",
- 1, 4, DEF_TRANSFER_SCALE, G_PARAM_READWRITE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_DEPTH,
- g_param_spec_int ("depth", "depth", "depth",
- 4, 6, DEF_DEPTH, G_PARAM_READWRITE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_PORT,
- g_param_spec_int ("port","port","port",
- 0, G_MAXINT, DEF_PORT, G_PARAM_READWRITE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_AUTOEXP,
- g_param_spec_enum ("autoexposure", "autoexposure", "autoexposure",
- GST_TYPE_AUTOEXP_MODE, DEF_AUTOEXP, G_PARAM_READWRITE));
+ g_param_spec_int ("width", "width", "width",
+ 0, 320, DEF_WIDTH, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_HEIGHT,
+ g_param_spec_int ("height", "height", "height",
+ 0, 240, DEF_HEIGHT, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BRIGHTNESS,
+ g_param_spec_int ("brightness", "brightness", "brightness",
+ 0, 255, DEF_BRIGHTNESS, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_WHITEBAL,
+ g_param_spec_int ("whitebal", "whitebal", "whitebal",
+ 0, 255, DEF_WHITEBAL, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_CONTRAST,
+ g_param_spec_int ("contrast", "contrast", "contrast",
+ 0, 255, DEF_CONTRAST, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TOP,
+ g_param_spec_int ("top", "top", "top",
+ 0, 240, DEF_TOP, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LEFT,
+ g_param_spec_int ("left", "left", "left",
+ 0, 320, DEF_LEFT, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TRANSFER_SCALE,
+ g_param_spec_int ("transfer_scale", "transfer_scale", "transfer_scale",
+ 1, 4, DEF_TRANSFER_SCALE, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DEPTH,
+ g_param_spec_int ("depth", "depth", "depth",
+ 4, 6, DEF_DEPTH, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PORT,
+ g_param_spec_int ("port", "port", "port",
+ 0, G_MAXINT, DEF_PORT, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_AUTOEXP,
+ g_param_spec_enum ("autoexposure", "autoexposure", "autoexposure",
+ GST_TYPE_AUTOEXP_MODE, DEF_AUTOEXP, G_PARAM_READWRITE));
gobject_class->set_property = gst_qcamsrc_set_property;
gobject_class->get_property = gst_qcamsrc_get_property;
}
static void
-gst_qcamsrc_init (GstQCamSrc *qcamsrc)
+gst_qcamsrc_init (GstQCamSrc * qcamsrc)
{
- qcamsrc->srcpad = gst_pad_new_from_template (
- gst_static_pad_template_get (&gst_qcamsrc_src_factory), "src");
- gst_element_add_pad(GST_ELEMENT(qcamsrc),qcamsrc->srcpad);
- gst_pad_set_get_function (qcamsrc->srcpad,gst_qcamsrc_get);
+ qcamsrc->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get
+ (&gst_qcamsrc_src_factory), "src");
+ gst_element_add_pad (GST_ELEMENT (qcamsrc), qcamsrc->srcpad);
+ gst_pad_set_get_function (qcamsrc->srcpad, gst_qcamsrc_get);
/* if the destination cannot say what it wants, we give this */
- qcamsrc->qcam = qc_init();
+ qcamsrc->qcam = qc_init ();
qcamsrc->qcam->port = DEF_PORT;
qc_setwidth (qcamsrc->qcam, DEF_WIDTH);
qc_setheight (qcamsrc->qcam, DEF_HEIGHT);
qc_settransfer_scale (qcamsrc->qcam, DEF_TRANSFER_SCALE);
qc_setbitdepth (qcamsrc->qcam, DEF_DEPTH);
qcamsrc->autoexposure = DEF_AUTOEXP;
- if (qcamsrc->autoexposure != AE_NONE)
+ if (qcamsrc->autoexposure != AE_NONE)
qcip_set_autoexposure_mode (qcamsrc->autoexposure);
}
-static GstData*
-gst_qcamsrc_get (GstPad *pad)
+static GstData *
+gst_qcamsrc_get (GstPad * pad)
{
GstQCamSrc *qcamsrc;
GstBuffer *buf;
frame = qcamsrc->qcam->width * qcamsrc->qcam->height / (scale * scale);
- buf = gst_buffer_new();
- outdata = GST_BUFFER_DATA(buf) = g_malloc0((frame * 3) / 2);
- GST_BUFFER_SIZE(buf) = (frame * 3) / 2;
+ buf = gst_buffer_new ();
+ outdata = GST_BUFFER_DATA (buf) = g_malloc0 ((frame * 3) / 2);
+ GST_BUFFER_SIZE (buf) = (frame * 3) / 2;
qc_set (qcamsrc->qcam);
if (!GST_PAD_CAPS (pad)) {
- gst_pad_try_set_caps (pad, gst_caps_new_simple("video/x-raw-yuv",
- "format", GST_TYPE_FOURCC, "I420",
- "width", G_TYPE_INT, qcamsrc->qcam->width / scale,
- "height", G_TYPE_INT, qcamsrc->qcam->height / scale,
- "framerate", G_TYPE_DOUBLE, 10., NULL));
+ gst_pad_try_set_caps (pad, gst_caps_new_simple ("video/x-raw-yuv",
+ "format", GST_TYPE_FOURCC, "I420",
+ "width", G_TYPE_INT, qcamsrc->qcam->width / scale,
+ "height", G_TYPE_INT, qcamsrc->qcam->height / scale,
+ "framerate", G_TYPE_DOUBLE, 10., NULL));
}
scan = qc_scan (qcamsrc->qcam);
/* FIXME, this doesn't seem to work... */
/*fixdark(qcamsrc->qcam, scan); */
-
- if (qcamsrc->autoexposure != AE_NONE)
- qcip_autoexposure(qcamsrc->qcam, scan);
- convert = (qcamsrc->qcam->bpp==4?4:2);
+ if (qcamsrc->autoexposure != AE_NONE)
+ qcip_autoexposure (qcamsrc->qcam, scan);
+
+ convert = (qcamsrc->qcam->bpp == 4 ? 4 : 2);
- for (i=frame; i; i--) {
- outdata[i] = scan[i]<<convert;
+ for (i = frame; i; i--) {
+ outdata[i] = scan[i] << convert;
}
- memset (outdata+frame, 128, frame>>1);
+ memset (outdata + frame, 128, frame >> 1);
g_free (scan);
return GST_DATA (buf);
}
static void
-gst_qcamsrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+gst_qcamsrc_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
GstQCamSrc *src;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_QCAMSRC(object));
- src = GST_QCAMSRC(object);
+ g_return_if_fail (GST_IS_QCAMSRC (object));
+ src = GST_QCAMSRC (object);
switch (prop_id) {
case ARG_WIDTH:
break;
case ARG_AUTOEXP:
src->autoexposure = g_value_get_enum (value);
- if (src->autoexposure != AE_NONE)
- qcip_set_autoexposure_mode (src->autoexposure);
+ if (src->autoexposure != AE_NONE)
+ qcip_set_autoexposure_mode (src->autoexposure);
break;
default:
break;
}
static void
-gst_qcamsrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+gst_qcamsrc_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
GstQCamSrc *src;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_QCAMSRC(object));
- src = GST_QCAMSRC(object);
+ g_return_if_fail (GST_IS_QCAMSRC (object));
+ src = GST_QCAMSRC (object);
switch (prop_id) {
case ARG_WIDTH:
}
static GstElementStateReturn
-gst_qcamsrc_change_state (GstElement *element)
+gst_qcamsrc_change_state (GstElement * element)
{
- g_return_val_if_fail(GST_IS_QCAMSRC(element), FALSE);
+ g_return_val_if_fail (GST_IS_QCAMSRC (element), FALSE);
/* if going down into NULL state, close the file if it's open */
- if (GST_STATE_PENDING(element) == GST_STATE_NULL) {
- if (GST_FLAG_IS_SET(element,GST_QCAMSRC_OPEN))
- gst_qcamsrc_close(GST_QCAMSRC(element));
- /* otherwise (READY or higher) we need to open the sound card */
+ if (GST_STATE_PENDING (element) == GST_STATE_NULL) {
+ if (GST_FLAG_IS_SET (element, GST_QCAMSRC_OPEN))
+ gst_qcamsrc_close (GST_QCAMSRC (element));
+ /* otherwise (READY or higher) we need to open the sound card */
} else {
- if (!GST_FLAG_IS_SET(element,GST_QCAMSRC_OPEN)) {
+ if (!GST_FLAG_IS_SET (element, GST_QCAMSRC_OPEN)) {
gst_info ("qcamsrc: opening\n");
- if (!gst_qcamsrc_open(GST_QCAMSRC(element))) {
+ if (!gst_qcamsrc_open (GST_QCAMSRC (element))) {
gst_info ("qcamsrc: open failed\n");
- return GST_STATE_FAILURE;
+ return GST_STATE_FAILURE;
}
}
}
- if (GST_ELEMENT_CLASS(parent_class)->change_state)
- return GST_ELEMENT_CLASS(parent_class)->change_state(element);
+ if (GST_ELEMENT_CLASS (parent_class)->change_state)
+ return GST_ELEMENT_CLASS (parent_class)->change_state (element);
return GST_STATE_SUCCESS;
}
static gboolean
-gst_qcamsrc_open (GstQCamSrc *qcamsrc)
+gst_qcamsrc_open (GstQCamSrc * qcamsrc)
{
if (qc_open (qcamsrc->qcam)) {
- g_warning("qcamsrc: Cannot open QuickCam.\n");
+ g_warning ("qcamsrc: Cannot open QuickCam.\n");
return FALSE;
}
- GST_FLAG_SET(qcamsrc, GST_QCAMSRC_OPEN);
+ GST_FLAG_SET (qcamsrc, GST_QCAMSRC_OPEN);
return TRUE;
}
static void
-gst_qcamsrc_close (GstQCamSrc *src)
+gst_qcamsrc_close (GstQCamSrc * src)
{
qc_close (src->qcam);
- GST_FLAG_UNSET(src, GST_QCAMSRC_OPEN);
+ GST_FLAG_UNSET (src, GST_QCAMSRC_OPEN);
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- if (!gst_element_register (plugin, "qcamsrc", GST_RANK_NONE, GST_TYPE_QCAMSRC))
+ if (!gst_element_register (plugin, "qcamsrc", GST_RANK_NONE,
+ GST_TYPE_QCAMSRC))
return FALSE;
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "qcamsrc",
- "Read from a QuickCam device",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
-
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "qcamsrc",
+ "Read from a QuickCam device",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
#include <gst/gst.h>
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
/** QuickCam include files */
#include "qcam.h"
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_QCAMSRC))
/* NOTE: per-element flags start with 16 for now */
-typedef enum {
- GST_QCAMSRC_OPEN = GST_ELEMENT_FLAG_LAST,
+ typedef enum
+ {
+ GST_QCAMSRC_OPEN = GST_ELEMENT_FLAG_LAST,
- GST_QCAMSRC_FLAG_LAST = GST_ELEMENT_FLAG_LAST+2,
-} GstQCamSrcFlags;
+ GST_QCAMSRC_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
+ } GstQCamSrcFlags;
-typedef struct _GstQCamSrc GstQCamSrc;
-typedef struct _GstQCamSrcClass GstQCamSrcClass;
+ typedef struct _GstQCamSrc GstQCamSrc;
+ typedef struct _GstQCamSrcClass GstQCamSrcClass;
-struct _GstQCamSrc {
- GstElement element;
+ struct _GstQCamSrc
+ {
+ GstElement element;
- /* pads */
- GstPad *srcpad;
+ /* pads */
+ GstPad *srcpad;
- struct qcam *qcam;
- gboolean autoexposure;
- gint port;
-};
+ struct qcam *qcam;
+ gboolean autoexposure;
+ gint port;
+ };
-struct _GstQCamSrcClass {
- GstElementClass parent_class;
-};
+ struct _GstQCamSrcClass
+ {
+ GstElementClass parent_class;
+ };
-GType gst_qcamsrc_get_type(void);
+ GType gst_qcamsrc_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_QCAMSRC_H__ */
+#endif /* __GST_QCAMSRC_H__ */
#include "qcam.h"
#include "qcam-Linux.h"
-int __inline__ read_lpstatus(const struct qcam *q) { return inb(q->port+1); }
-int read_lpcontrol(const struct qcam *q) { return inb(q->port+2); }
-int read_lpdata(const struct qcam *q) { return inb(q->port); }
-void write_lpdata(const struct qcam *q, int d) { outb(d,q->port); }
-void write_lpcontrol(const struct qcam *q, int d) { outb(d,q->port+2); }
+int __inline__
+read_lpstatus (const struct qcam *q)
+{
+ return inb (q->port + 1);
+}
+
+int
+read_lpcontrol (const struct qcam *q)
+{
+ return inb (q->port + 2);
+}
+
+int
+read_lpdata (const struct qcam *q)
+{
+ return inb (q->port);
+}
-int enable_ports(const struct qcam *q)
+void
+write_lpdata (const struct qcam *q, int d)
{
- if(q->port<0x278) return 1; /* Better safe than sorry */
- if(q->port>0x3bc) return 1;
- return (ioperm(q->port, 3, 1));
+ outb (d, q->port);
}
-int disable_ports(const struct qcam *q)
+void
+write_lpcontrol (const struct qcam *q, int d)
{
- return (ioperm(q->port, 3, 0));
+ outb (d, q->port + 2);
+}
+
+int
+enable_ports (const struct qcam *q)
+{
+ if (q->port < 0x278)
+ return 1; /* Better safe than sorry */
+ if (q->port > 0x3bc)
+ return 1;
+ return (ioperm (q->port, 3, 1));
+}
+
+int
+disable_ports (const struct qcam *q)
+{
+ return (ioperm (q->port, 3, 0));
}
/* Lock port. This is currently sub-optimal, and is begging to be
* multiple processes (eg. qcam) taking "snapshots" can peacefully coexist.
* - Dave Plonka (plonka@carroll1.cc.edu)
*/
-int qc_lock_wait(struct qcam *q, int wait)
+int
+qc_lock_wait (struct qcam *q, int wait)
{
#if 1
static struct flock sfl;
- if (-1 == q->fd) /* we've yet to open the lock file */
- {
- static char lockfile[128];
-
- sprintf(lockfile,"/var/run/LOCK.qcam.0x%x",q->port);
- if (-1 == (q->fd = open(lockfile, O_WRONLY | O_CREAT, 0666)))
- {
- perror("open");
- return 1;
- }
+ if (-1 == q->fd) { /* we've yet to open the lock file */
+ static char lockfile[128];
+ sprintf (lockfile, "/var/run/LOCK.qcam.0x%x", q->port);
+ if (-1 == (q->fd = open (lockfile, O_WRONLY | O_CREAT, 0666))) {
+ perror ("open");
+ return 1;
+ }
#ifdef TESTING
- fprintf(stderr, "%s - %d: %s open(2)ed\n", __FILE__, __LINE__, lockfile);
+ fprintf (stderr, "%s - %d: %s open(2)ed\n", __FILE__, __LINE__, lockfile);
#endif
- /* initialize the l_type memver to lock the file exclusively */
- sfl.l_type = F_WRLCK;
+ /* initialize the l_type memver to lock the file exclusively */
+ sfl.l_type = F_WRLCK;
}
-
#ifdef TESTING
- if (0 != fcntl(q->fd, F_SETLK, &sfl)) /* non-blocking set lock */
+ if (0 != fcntl (q->fd, F_SETLK, &sfl)) /* non-blocking set lock */
#else
- if (0 != fcntl(q->fd, wait? F_SETLKW : F_SETLK, &sfl))
+ if (0 != fcntl (q->fd, wait ? F_SETLKW : F_SETLK, &sfl))
#endif
{
#ifdef TESTING
- perror("fcntl");
- if (EAGAIN != errno || !wait) return 1;
-
- fprintf(stderr, "%s - %d: waiting for exclusive lock on fd %d...\n", __FILE__, __LINE__, q->fd);
+ perror ("fcntl");
+ if (EAGAIN != errno || !wait)
+ return 1;
+
+ fprintf (stderr, "%s - %d: waiting for exclusive lock on fd %d...\n",
+ __FILE__, __LINE__, q->fd);
- if (0 != fcntl(q->fd, F_SETLKW, &sfl)) /* "blocking" set lock */
+ if (0 != fcntl (q->fd, F_SETLKW, &sfl)) /* "blocking" set lock */
#endif
- {
- perror("fcntl");
- return 1;
- }
+ {
+ perror ("fcntl");
+ return 1;
+ }
}
-
#ifdef TESTING
- fprintf(stderr, "%s - %d: fd %d locked exclusively\n", __FILE__, __LINE__, q->fd);
+ fprintf (stderr, "%s - %d: fd %d locked exclusively\n", __FILE__, __LINE__,
+ q->fd);
#endif
#else
char lockfile[128], tmp[128];
struct stat statbuf;
- sprintf(lockfile,"/var/run/LOCK.qcam.0x%x",q->port);
- sprintf(tmp,"%s-%d",lockfile,getpid());
+ sprintf (lockfile, "/var/run/LOCK.qcam.0x%x", q->port);
+ sprintf (tmp, "%s-%d", lockfile, getpid ());
- if ((creat(tmp,0)==-1) ||
- (link(tmp,lockfile)==-1) ||
- (stat(tmp,&statbuf)==-1) ||
- (statbuf.st_nlink==1))
- {
+ if ((creat (tmp, 0) == -1) ||
+ (link (tmp, lockfile) == -1) ||
+ (stat (tmp, &statbuf) == -1) || (statbuf.st_nlink == 1)) {
#ifdef DEBUGQC
- perror("QuickCam Locked");
- if(unlink(tmp)==-1)
- perror("Error unlinking temp file.");
+ perror ("QuickCam Locked");
+ if (unlink (tmp) == -1)
+ perror ("Error unlinking temp file.");
#else
- unlink(tmp);
+ unlink (tmp);
#endif
return 1;
}
-
- unlink(tmp);
- if (chown(lockfile,getuid(),getgid())==-1)
- perror("Chown problems");
+
+ unlink (tmp);
+ if (chown (lockfile, getuid (), getgid ()) == -1)
+ perror ("Chown problems");
#endif
return 0;
}
-int qc_lock(struct qcam *q)
+int
+qc_lock (struct qcam *q)
{
#if 1
- return qc_lock_wait(q, 1 /*wait*/);
+ return qc_lock_wait (q, 1 /*wait */ );
#else
- return qc_lock_wait(q, 0 /*don't wait*/);
+ return qc_lock_wait (q, 0 /*don't wait */ );
#endif
}
/* Unlock port */
-int qc_unlock(struct qcam *q)
+int
+qc_unlock (struct qcam *q)
{
static struct flock sfl;
+
#if 1
- if (-1 == q->fd)
- { /* port was not locked */
- return 1;
+ if (-1 == q->fd) { /* port was not locked */
+ return 1;
}
/* clear the exclusive lock */
sfl.l_type = F_UNLCK;
- if (0 != fcntl(q->fd, F_SETLK, &sfl))
- {
- perror("fcntl");
- return 1;
+ if (0 != fcntl (q->fd, F_SETLK, &sfl)) {
+ perror ("fcntl");
+ return 1;
}
-
#ifdef TESTING
- fprintf(stderr, "%s - %d: fd %d unlocked\n", __FILE__, __LINE__, q->fd);
+ fprintf (stderr, "%s - %d: fd %d unlocked\n", __FILE__, __LINE__, q->fd);
#endif
#else
char lockfile[128];
- sprintf(lockfile,"/var/run/LOCK.qcam.0x%x",q->port);
- unlink(lockfile); /* What would I do with an error? */
+ sprintf (lockfile, "/var/run/LOCK.qcam.0x%x", q->port);
+ unlink (lockfile); /* What would I do with an error? */
#endif
return 0;
/* Probe for camera. Returns 0 if found, 1 if not found, sets
q->port.*/
-int qc_probe(struct qcam *q)
+int
+qc_probe (struct qcam *q)
{
- int ioports[]={0x378, 0x278, 0x3bc,0};
- int i=0;
+ int ioports[] = { 0x378, 0x278, 0x3bc, 0 };
+ int i = 0;
/* Attempt to get permission to access IO ports. Must be root */
- while(ioports[i]!=0) {
- q->port=ioports[i++];
+ while (ioports[i] != 0) {
+ q->port = ioports[i++];
- if (qc_open(q)) {
- perror("Can't get I/O permission");
- exit(1);
+ if (qc_open (q)) {
+ perror ("Can't get I/O permission");
+ exit (1);
}
- if(qc_detect(q)) {
- fprintf(stderr,"QuickCam detected at 0x%x\n",q->port);
- qc_close(q);
- return(0);
- }
- else
- qc_close(q);
+ if (qc_detect (q)) {
+ fprintf (stderr, "QuickCam detected at 0x%x\n", q->port);
+ qc_close (q);
+ return (0);
+ } else
+ qc_close (q);
}
return 1;
to run. This seems to help, but if anyone has a good
speed-independent pause routine, please tell me. -- Scott */
-void qc_wait(int val)
+void
+qc_wait (int val)
{
int i;
-
- while(val--)
- for(i=0;i<50000;i++);
+
+ while (val--)
+ for (i = 0; i < 50000; i++);
}
OTHER DEALINGS IN THE SOFTWARE.
******************************************************************/
-
-
/* Prototypes for static functions. Externally visible functions
* should be prototyped in qcam.h */
-static int qc_waithand(const struct qcam *q, int val);
-static int qc_command(const struct qcam *q, int command);
-static int qc_readparam(const struct qcam *q);
-static int qc_setscanmode(struct qcam *q);
-static int qc_readbytes(const struct qcam *q, char buffer[]);
+static int qc_waithand (const struct qcam *q, int val);
+static int qc_command (const struct qcam *q, int command);
+static int qc_readparam (const struct qcam *q);
+static int qc_setscanmode (struct qcam *q);
+static int qc_readbytes (const struct qcam *q, char buffer[]);
/* The next several functions are used for controlling the qcam
* structure. They aren't used inside this library, but they should
/* Gets/sets the brightness. */
-int qc_getbrightness(const struct qcam *q)
+int
+qc_getbrightness (const struct qcam *q)
{
return q->brightness;
}
-int qc_setbrightness(struct qcam *q, int val)
+int
+qc_setbrightness (struct qcam *q, int val)
{
if (val >= 0 && val <= 255) {
- q->brightness=val;
+ q->brightness = val;
return 0;
}
return 1;
/* Gets/sets the contrast */
-int qc_getcontrast(const struct qcam *q)
+int
+qc_getcontrast (const struct qcam *q)
{
return q->contrast;
}
-int qc_setcontrast(struct qcam *q, int val)
+int
+qc_setcontrast (struct qcam *q, int val)
{
if (val >= 0 && val <= 255) {
- q->contrast=val;
+ q->contrast = val;
return 0;
}
return 1;
/* Gets/sets the white balance */
-int qc_getwhitebal(const struct qcam *q)
+int
+qc_getwhitebal (const struct qcam *q)
{
return q->whitebal;
}
-int qc_setwhitebal(struct qcam *q, int val)
+int
+qc_setwhitebal (struct qcam *q, int val)
{
if (val >= 0 && val <= 255) {
- q->whitebal=val;
+ q->whitebal = val;
return 0;
}
return 1;
/* Gets/sets the resolution */
-void qc_getresolution(const struct qcam *q, int *x, int *y)
+void
+qc_getresolution (const struct qcam *q, int *x, int *y)
{
- *x=q->width;
- *y=q->height;
+ *x = q->width;
+ *y = q->height;
}
-int qc_setresolution(struct qcam *q, int x, int y)
+int
+qc_setresolution (struct qcam *q, int x, int y)
{
if (x >= 0 && x <= 336 && y >= 0 && y <= 243) {
- q->width=x;
- q->height=y;
+ q->width = x;
+ q->height = y;
return 0;
}
return 1;
}
-int qc_getheight(const struct qcam *q)
+int
+qc_getheight (const struct qcam *q)
{
return q->height;
}
-int qc_setheight(struct qcam *q, int y)
+int
+qc_setheight (struct qcam *q, int y)
{
if (y >= 0 && y <= 243) {
- q->height=y;
+ q->height = y;
return 0;
}
return 1;
}
-int qc_getwidth(const struct qcam *q)
+int
+qc_getwidth (const struct qcam *q)
{
return q->width;
}
-int qc_setwidth(struct qcam *q, int x)
+int
+qc_setwidth (struct qcam *q, int x)
{
if (x >= 0 && x <= 336) {
- q->width=x;
+ q->width = x;
return 0;
}
return 1;
/* Gets/sets the bit depth */
-int qc_getbitdepth(const struct qcam *q)
+int
+qc_getbitdepth (const struct qcam *q)
{
return q->bpp;
}
-int qc_setbitdepth(struct qcam *q, int val)
+int
+qc_setbitdepth (struct qcam *q, int val)
{
if (val == 4 || val == 6) {
- q->bpp=val;
- return qc_setscanmode(q);
+ q->bpp = val;
+ return qc_setscanmode (q);
}
return 1;
}
-int qc_gettop(const struct qcam *q)
+int
+qc_gettop (const struct qcam *q)
{
return q->top;
}
-int qc_settop(struct qcam *q, int val)
+int
+qc_settop (struct qcam *q, int val)
{
if (val >= 1 && val <= 243) {
q->top = val;
return 1;
}
-int qc_getleft(const struct qcam *q)
+int
+qc_getleft (const struct qcam *q)
{
return q->left;
}
-int qc_setleft(struct qcam *q, int val)
+int
+qc_setleft (struct qcam *q, int val)
{
if (val % 2 == 0 && val >= 2 && val <= 336) {
q->left = val;
return 1;
}
-int qc_gettransfer_scale(const struct qcam *q)
+int
+qc_gettransfer_scale (const struct qcam *q)
{
return q->transfer_scale;
}
-int qc_settransfer_scale(struct qcam *q, int val)
+int
+qc_settransfer_scale (struct qcam *q, int val)
{
if (val == 1 || val == 2 || val == 4) {
q->transfer_scale = val;
- return qc_setscanmode(q);
+ return qc_setscanmode (q);
}
return 1;
}
int
-qc_calibrate(struct qcam *q)
+qc_calibrate (struct qcam *q)
/* bugfix by Hanno Mueller hmueller@kabel.de, Mai 21 96 */
/* The white balance is an individiual value for each */
/* quickcam. Run calibration once, write the value down */
/* recalibrate your camera again. */
{
int value;
+
#ifdef DEBUG
int count = 0;
#endif
- qc_command(q, 27); /* AutoAdjustOffset */
- qc_command(q, 0); /* Dummy Parameter, ignored by the camera */
+ qc_command (q, 27); /* AutoAdjustOffset */
+ qc_command (q, 0); /* Dummy Parameter, ignored by the camera */
/* GetOffset (33) will read 255 until autocalibration */
/* is finished. After that, a value of 1-254 will be */
/* returned. */
do {
- qc_command(q, 33); value = qc_readparam(q);
+ qc_command (q, 33);
+ value = qc_readparam (q);
#ifdef DEBUG
count++;
#endif
q->whitebal = value;
#ifdef DEBUG
- fprintf(stderr, "%d loops to calibrate\n", count);
- fprintf(stderr, "Calibrated to %d\n", value);
+ fprintf (stderr, "%d loops to calibrate\n", count);
+ fprintf (stderr, "Calibrated to %d\n", value);
#endif
return value;
}
int
-qc_forceunidir(struct qcam *q)
+qc_forceunidir (struct qcam *q)
{
q->port_mode = (q->port_mode & ~QC_FORCE_MASK) | QC_FORCE_UNIDIR;
return 0;
/* Initialize the QuickCam driver control structure. This is where
* defaults are set for people who don't have a config file.*/
struct qcam *
-qc_init(void)
+qc_init (void)
{
struct qcam *q;
- q=malloc(sizeof(struct qcam));
+ q = malloc (sizeof (struct qcam));
- q->port=0; /* Port 0 == Autoprobe */
- q->port_mode=(QC_ANY | QC_NOTSET);
- q->width=160;
- q->height=120;
- q->bpp=4;
+ q->port = 0; /* Port 0 == Autoprobe */
+ q->port_mode = (QC_ANY | QC_NOTSET);
+ q->width = 160;
+ q->height = 120;
+ q->bpp = 4;
q->transfer_scale = 2;
- q->contrast=104;
- q->brightness=150;
- q->whitebal=150;
+ q->contrast = 104;
+ q->brightness = 150;
+ q->whitebal = 150;
q->top = 1;
q->left = 14;
q->mode = -1;
- q->fd=-1; /* added initialization of fd member
- * BTW, there doesn't seem to be a place to close this fd...
- * I think we need a qc_free function.
- * - Dave Plonka (plonka@carroll1.cc.edu)
- */
+ q->fd = -1; /* added initialization of fd member
+ * BTW, there doesn't seem to be a place to close this fd...
+ * I think we need a qc_free function.
+ * - Dave Plonka (plonka@carroll1.cc.edu)
+ */
return q;
}
* Returns 0 for success, 1 for opening error, 2 for locking error,
* and 3 for qcam not found */
-int qc_open(struct qcam *q)
+int
+qc_open (struct qcam *q)
{
- if(q->port==0)
- if(qc_probe(q)) {
- fprintf(stderr,"Qcam not found\n");
+ if (q->port == 0)
+ if (qc_probe (q)) {
+ fprintf (stderr, "Qcam not found\n");
return 3;
}
- if(qc_lock(q)) {
- fprintf(stderr,"Cannot lock qcam.\n");
+ if (qc_lock (q)) {
+ fprintf (stderr, "Cannot lock qcam.\n");
return 2;
}
- if(enable_ports(q)) {
- fprintf(stderr,"Cannot open QuickCam -- permission denied.");
+ if (enable_ports (q)) {
+ fprintf (stderr, "Cannot open QuickCam -- permission denied.");
return 1;
} else {
return 0;
/* qc_close closes and unlocks the driver. You *need* to call this,
* or lockfiles will be left behind and everything will be screwed. */
-int qc_close(struct qcam *q)
+int
+qc_close (struct qcam *q)
{
- qc_unlock(q);
+ qc_unlock (q);
- disable_ports(q);
+ disable_ports (q);
return 0;
}
* or arguments to commands, so the name fits, but it still bugs me a
* bit. See the documentation for a list of commands. */
-static int qc_command(const struct qcam *q, int command)
+static int
+qc_command (const struct qcam *q, int command)
{
int n1, n2;
int cmd;
- write_lpdata(q, command);
- write_lpcontrol(q,6);
+ write_lpdata (q, command);
+ write_lpcontrol (q, 6);
- n1 = qc_waithand(q,1);
+ n1 = qc_waithand (q, 1);
- write_lpcontrol(q,0xe);
- n2 = qc_waithand(q,0);
+ write_lpcontrol (q, 0xe);
+ n2 = qc_waithand (q, 0);
cmd = (n1 & 0xf0) | ((n2 & 0xf0) >> 4);
#ifdef DEBUG
if (cmd != command) {
- fprintf(stderr, "Command 0x%02x sent, 0x%02x echoed", command, cmd);
- n2 = read_lpstatus(q);
+ fprintf (stderr, "Command 0x%02x sent, 0x%02x echoed", command, cmd);
+ n2 = read_lpstatus (q);
cmd = (n1 & 0xf0) | ((n2 & 0xf0) >> 4);
- if (cmd != command) fprintf(stderr, " (re-read does not help)\n");
- else fprintf(stderr, " (fixed on re-read)\n");
+ if (cmd != command)
+ fprintf (stderr, " (re-read does not help)\n");
+ else
+ fprintf (stderr, " (fixed on re-read)\n");
}
#endif
return cmd;
}
static int
-qc_readparam(const struct qcam *q)
+qc_readparam (const struct qcam *q)
{
int n1, n2;
int cmd;
- write_lpcontrol(q,6);
- n1 = qc_waithand(q,1);
+ write_lpcontrol (q, 6);
+ n1 = qc_waithand (q, 1);
- write_lpcontrol(q,0xe);
- n2 = qc_waithand(q,0);
+ write_lpcontrol (q, 0xe);
+ n2 = qc_waithand (q, 0);
cmd = (n1 & 0xf0) | ((n2 & 0xf0) >> 4);
return cmd;
/* qc_waithand busy-waits for a handshake signal from the QuickCam.
* Almost all communication with the camera requires handshaking. */
-static int qc_waithand(const struct qcam *q, int val)
+static int
+qc_waithand (const struct qcam *q, int val)
{
int status;
if (val)
- while(! ((status = read_lpstatus(q))&8))
- ;
+ while (!((status = read_lpstatus (q)) & 8));
else
- while (((status = read_lpstatus(q))&8))
- ;
+ while (((status = read_lpstatus (q)) & 8));
return status;
}
* since this data is useful. */
static unsigned int
-qc_waithand2(const struct qcam *q, int val)
+qc_waithand2 (const struct qcam *q, int val)
{
unsigned int status;
+
do {
- status = read_lpdata(q);
- } while ( (status & 1) != val);
+ status = read_lpdata (q);
+ } while ((status & 1) != val);
return status;
}
almost completely safe, while their method screws up my printer if
I plug it in before the camera. */
-int qc_detect(const struct qcam *q)
+int
+qc_detect (const struct qcam *q)
{
- int reg,lastreg;
- int count=0;
+ int reg, lastreg;
+ int count = 0;
int i;
- lastreg=reg=read_lpstatus(q)&0xf0;
+ lastreg = reg = read_lpstatus (q) & 0xf0;
- for(i=0;i<30;i++) {
- reg=read_lpstatus(q)&0xf0;
- if(reg!=lastreg) count++;
- lastreg=reg;
- usleep(10000);
+ for (i = 0; i < 30; i++) {
+ reg = read_lpstatus (q) & 0xf0;
+ if (reg != lastreg)
+ count++;
+ lastreg = reg;
+ usleep (10000);
}
/* Be liberal in what you accept... */
- if(count>3&&count<15)
- return 1; /* found */
- else
- return 0; /* not found */
+ if (count > 3 && count < 15)
+ return 1; /* found */
+ else
+ return 0; /* not found */
}
* check that bi-directional mode is detected right, and then
* implement bi-directional mode in qc_readbyte(). */
-void qc_reset(struct qcam *q)
+void
+qc_reset (struct qcam *q)
{
- switch (q->port_mode & QC_FORCE_MASK)
- {
+ switch (q->port_mode & QC_FORCE_MASK) {
case QC_FORCE_UNIDIR:
q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_UNIDIR;
break;
break;
case QC_ANY:
- write_lpcontrol(q,0x20);
- write_lpdata(q,0x75);
+ write_lpcontrol (q, 0x20);
+ write_lpdata (q, 0x75);
- if (read_lpdata(q) != 0x75) {
+ if (read_lpdata (q) != 0x75) {
q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_BIDIR;
} else {
q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_UNIDIR;
case QC_FORCE_SERIAL:
default:
- fprintf(stderr, "Illegal port_mode %x\n", q->port_mode);
+ fprintf (stderr, "Illegal port_mode %x\n", q->port_mode);
break;
}
- /* usleep(250);*/
- write_lpcontrol(q,0xb);
- usleep(250);
- write_lpcontrol(q,0xe);
- (void)qc_setscanmode(q); /* in case port_mode changed */
+ /* usleep(250); */
+ write_lpcontrol (q, 0xb);
+ usleep (250);
+ write_lpcontrol (q, 0xe);
+ (void) qc_setscanmode (q); /* in case port_mode changed */
}
* returned. If the scan is smaller, then the rest of the image
* returned contains garbage. */
-static int qc_setscanmode(struct qcam *q)
+static int
+qc_setscanmode (struct qcam *q)
{
switch (q->transfer_scale) {
- case 1: q->mode = 0; break;
- case 2: q->mode = 4; break;
- case 4: q->mode = 8; break;
- default: return 1;
+ case 1:
+ q->mode = 0;
+ break;
+ case 2:
+ q->mode = 4;
+ break;
+ case 4:
+ q->mode = 8;
+ break;
+ default:
+ return 1;
}
switch (q->bpp) {
- case 4: break;
- case 6: q->mode+=2; break;
- default:
- fprintf(stderr,"Error: Unsupported bit depth\n");
- return 1;
+ case 4:
+ break;
+ case 6:
+ q->mode += 2;
+ break;
+ default:
+ fprintf (stderr, "Error: Unsupported bit depth\n");
+ return 1;
}
switch (q->port_mode & QC_MODE_MASK) {
- case QC_BIDIR: q->mode += 1; break;
- case QC_NOTSET:
- case QC_UNIDIR: break;
- default: return 1;
+ case QC_BIDIR:
+ q->mode += 1;
+ break;
+ case QC_NOTSET:
+ case QC_UNIDIR:
+ break;
+ default:
+ return 1;
}
return 0;
}
/* Reset the QuickCam and program for brightness, contrast,
* white-balance, and resolution. */
-void qc_set(struct qcam *q)
+void
+qc_set (struct qcam *q)
{
int val;
int val2;
- qc_reset(q);
+ qc_reset (q);
/* Set the brightness. Yes, this is repetitive, but it works.
* Shorter versions seem to fail subtly. Feel free to try :-). */
/* I think the problem was in qc_command, not here -- bls */
- qc_command(q,0xb);
- qc_command(q,q->brightness);
+ qc_command (q, 0xb);
+ qc_command (q, q->brightness);
val = q->height / q->transfer_scale;
- qc_command(q,0x11); qc_command(q, val);
+ qc_command (q, 0x11);
+ qc_command (q, val);
if ((q->port_mode & QC_MODE_MASK) == QC_UNIDIR && q->bpp == 6) {
/* The normal "transfers per line" calculation doesn't seem to work
- as expected here (and yet it works fine in qc_scan). No idea
- why this case is the odd man out. Fortunately, Laird's original
- working version gives me a good way to guess at working values.
- -- bls */
+ as expected here (and yet it works fine in qc_scan). No idea
+ why this case is the odd man out. Fortunately, Laird's original
+ working version gives me a good way to guess at working values.
+ -- bls */
val = q->width;
val2 = q->transfer_scale * 4;
} else {
val = q->width * q->bpp;
- val2 = (((q->port_mode & QC_MODE_MASK) == QC_BIDIR)?24:8) *
+ val2 = (((q->port_mode & QC_MODE_MASK) == QC_BIDIR) ? 24 : 8) *
q->transfer_scale;
}
val = (val + val2 - 1) / val2;
- qc_command(q,0x13); qc_command(q, val);
+ qc_command (q, 0x13);
+ qc_command (q, val);
/* I still don't know what these do! */
/* They're setting top and left -- bls */
- qc_command(q,0xd); qc_command(q,q->top);
- qc_command(q,0xf); qc_command(q,q->left/2);
+ qc_command (q, 0xd);
+ qc_command (q, q->top);
+ qc_command (q, 0xf);
+ qc_command (q, q->left / 2);
- qc_command(q,0x19); qc_command(q,q->contrast);
- qc_command(q,0x1f); qc_command(q,q->whitebal);
+ qc_command (q, 0x19);
+ qc_command (q, q->contrast);
+ qc_command (q, 0x1f);
+ qc_command (q, q->whitebal);
}
the supplied buffer. It returns the number of bytes read,
or -1 on error. */
-static int
-__inline__
-qc_readbytes(const struct qcam *q, char buffer[])
+static int __inline__
+qc_readbytes (const struct qcam *q, char buffer[])
{
int ret;
unsigned int hi, lo;
if (buffer == NULL) {
state = 0;
- return 0;
+ return 0;
}
switch (q->port_mode & QC_MODE_MASK) {
- case QC_BIDIR: /* Bi-directional Port */
- write_lpcontrol(q, 0x26);
- lo = (qc_waithand2(q, 1) >> 1);
- hi = (read_lpstatus(q) >> 3) & 0x1f;
- write_lpcontrol(q, 0x2e);
- lo2 = (qc_waithand2(q, 0) >> 1);
- hi2 = (read_lpstatus(q) >> 3) & 0x1f;
- switch (q->bpp) {
- case 4:
- buffer[0] = lo & 0xf;
- buffer[1] = ((lo & 0x70) >> 4) | ((hi & 1) << 3);
- buffer[2] = (hi & 0x1e) >> 1;
- buffer[3] = lo2 & 0xf;
- buffer[4] = ((lo2 & 0x70) >> 4) | ((hi2 & 1) << 3);
- buffer[5] = (hi2 & 0x1e) >> 1;
- ret = 6;
- break;
- case 6:
- buffer[0] = lo & 0x3f;
- buffer[1] = ((lo & 0x40) >> 6) | (hi << 1);
- buffer[2] = lo2 & 0x3f;
- buffer[3] = ((lo2 & 0x40) >> 6) | (hi2 << 1);
- ret = 4;
- break;
- default:
- fprintf(stderr, "Bad bidir pixel depth %d\n", q->bpp);
- ret = -1;
- break;
- }
- break;
-
- case QC_UNIDIR: /* Unidirectional Port */
- write_lpcontrol(q,6);
- lo = (qc_waithand(q,1) & 0xf0) >> 4;
- write_lpcontrol(q,0xe);
- hi = (qc_waithand(q,0) & 0xf0) >> 4;
-
- switch (q->bpp) {
- case 4:
- buffer[0] = lo;
- buffer[1] = hi;
- ret = 2;
- break;
- case 6:
- switch (state) {
- case 0:
- buffer[0] = (lo << 2) | ((hi & 0xc) >> 2);
- saved_bits = (hi & 3) << 4;
- state = 1; ret = 1; break;
- case 1:
- buffer[0] = lo | saved_bits;
- saved_bits = hi << 2;
- state = 2; ret = 1; break;
- case 2:
- buffer[0] = ((lo & 0xc) >> 2) | saved_bits;
- buffer[1] = ((lo & 3) << 4) | hi;
- state = 0; ret = 2; break;
- default:
- fprintf(stderr, "Unidir 6-bit state %d?\n", state);
- ret = -1;
- break;
- }
- break;
- default:
- fprintf(stderr, "Bad unidir pixel depth %d\n", q->bpp);
- ret = -1;
- break;
- }
- break;
- case QC_SERIAL: /* Serial Interface. Just in case.*/
- default:
- fprintf(stderr,"Mode %x not supported\n",q->port_mode);
- ret=-1;
- break;
+ case QC_BIDIR: /* Bi-directional Port */
+ write_lpcontrol (q, 0x26);
+ lo = (qc_waithand2 (q, 1) >> 1);
+ hi = (read_lpstatus (q) >> 3) & 0x1f;
+ write_lpcontrol (q, 0x2e);
+ lo2 = (qc_waithand2 (q, 0) >> 1);
+ hi2 = (read_lpstatus (q) >> 3) & 0x1f;
+ switch (q->bpp) {
+ case 4:
+ buffer[0] = lo & 0xf;
+ buffer[1] = ((lo & 0x70) >> 4) | ((hi & 1) << 3);
+ buffer[2] = (hi & 0x1e) >> 1;
+ buffer[3] = lo2 & 0xf;
+ buffer[4] = ((lo2 & 0x70) >> 4) | ((hi2 & 1) << 3);
+ buffer[5] = (hi2 & 0x1e) >> 1;
+ ret = 6;
+ break;
+ case 6:
+ buffer[0] = lo & 0x3f;
+ buffer[1] = ((lo & 0x40) >> 6) | (hi << 1);
+ buffer[2] = lo2 & 0x3f;
+ buffer[3] = ((lo2 & 0x40) >> 6) | (hi2 << 1);
+ ret = 4;
+ break;
+ default:
+ fprintf (stderr, "Bad bidir pixel depth %d\n", q->bpp);
+ ret = -1;
+ break;
+ }
+ break;
+
+ case QC_UNIDIR: /* Unidirectional Port */
+ write_lpcontrol (q, 6);
+ lo = (qc_waithand (q, 1) & 0xf0) >> 4;
+ write_lpcontrol (q, 0xe);
+ hi = (qc_waithand (q, 0) & 0xf0) >> 4;
+
+ switch (q->bpp) {
+ case 4:
+ buffer[0] = lo;
+ buffer[1] = hi;
+ ret = 2;
+ break;
+ case 6:
+ switch (state) {
+ case 0:
+ buffer[0] = (lo << 2) | ((hi & 0xc) >> 2);
+ saved_bits = (hi & 3) << 4;
+ state = 1;
+ ret = 1;
+ break;
+ case 1:
+ buffer[0] = lo | saved_bits;
+ saved_bits = hi << 2;
+ state = 2;
+ ret = 1;
+ break;
+ case 2:
+ buffer[0] = ((lo & 0xc) >> 2) | saved_bits;
+ buffer[1] = ((lo & 3) << 4) | hi;
+ state = 0;
+ ret = 2;
+ break;
+ default:
+ fprintf (stderr, "Unidir 6-bit state %d?\n", state);
+ ret = -1;
+ break;
+ }
+ break;
+ default:
+ fprintf (stderr, "Bad unidir pixel depth %d\n", q->bpp);
+ ret = -1;
+ break;
+ }
+ break;
+ case QC_SERIAL: /* Serial Interface. Just in case. */
+ default:
+ fprintf (stderr, "Mode %x not supported\n", q->port_mode);
+ ret = -1;
+ break;
}
return ret;
}
* n=2^(bit depth)-1. Ask me for more details if you don't understand
* this. */
-scanbuf *qc_scan(const struct qcam *q)
+scanbuf *
+qc_scan (const struct qcam * q)
{
unsigned char *ret;
int i, j, k;
char invert;
if (q->mode != -1) {
- qc_command(q, 0x7);
- qc_command(q, q->mode);
+ qc_command (q, 0x7);
+ qc_command (q, q->mode);
} else {
struct qcam bogus_cam;
+
/* We're going through these odd hoops to retain the "const"
- qualification on q. We can't do a qc_setscanmode directly on q,
- so we copy it, do a setscanmode on that, and pass in the newly
- computed mode. -- bls 11/21/96
- */
+ qualification on q. We can't do a qc_setscanmode directly on q,
+ so we copy it, do a setscanmode on that, and pass in the newly
+ computed mode. -- bls 11/21/96
+ */
#ifdef DEBUG
- fprintf(stderr, "Warning! qc->mode not set!\n");
+ fprintf (stderr, "Warning! qc->mode not set!\n");
#endif
bogus_cam = *q;
- (void)qc_setscanmode(&bogus_cam);
- qc_command(q, 0x7);
- qc_command(q, bogus_cam.mode);
+ (void) qc_setscanmode (&bogus_cam);
+ qc_command (q, 0x7);
+ qc_command (q, bogus_cam.mode);
}
if ((q->port_mode & QC_MODE_MASK) == QC_BIDIR) {
- write_lpcontrol(q, 0x2e); /* turn port around */
- write_lpcontrol(q, 0x26);
- (void) qc_waithand(q, 1);
- write_lpcontrol(q, 0x2e);
- (void) qc_waithand(q, 0);
+ write_lpcontrol (q, 0x2e); /* turn port around */
+ write_lpcontrol (q, 0x26);
+ (void) qc_waithand (q, 1);
+ write_lpcontrol (q, 0x2e);
+ (void) qc_waithand (q, 0);
}
/* strange -- should be 15:63 below, but 4bpp is odd */
linestotrans = q->height / q->transfer_scale;
pixels_per_line = q->width / q->transfer_scale;
transperline = q->width * q->bpp;
- divisor = (((q->port_mode & QC_MODE_MASK) == QC_BIDIR)?24:8) *
- q->transfer_scale;
+ divisor = (((q->port_mode & QC_MODE_MASK) == QC_BIDIR) ? 24 : 8) *
+ q->transfer_scale;
transperline = (transperline + divisor - 1) / divisor;
- ret = malloc(linestotrans * pixels_per_line);
- assert(ret);
+ ret = malloc (linestotrans * pixels_per_line);
+ assert (ret);
#ifdef DEBUG
- fprintf(stderr, "%s %d bpp\n%d lines of %d transfers each\n",
- ((q->port_mode & QC_MODE_MASK) == QC_BIDIR)?"Bidir":"Unidir",
- q->bpp, linestotrans, transperline);
+ fprintf (stderr, "%s %d bpp\n%d lines of %d transfers each\n",
+ ((q->port_mode & QC_MODE_MASK) == QC_BIDIR) ? "Bidir" : "Unidir",
+ q->bpp, linestotrans, transperline);
#endif
for (i = 0; i < linestotrans; i++) {
for (pixels_read = j = 0; j < transperline; j++) {
- bytes = qc_readbytes(q, buffer);
- assert(bytes > 0);
+ bytes = qc_readbytes (q, buffer);
+ assert (bytes > 0);
for (k = 0; k < bytes && (pixels_read + k) < pixels_per_line; k++) {
assert (buffer[k] <= invert);
assert (buffer[k] >= 0);
must be 0-15 -- bls */
buffer[k] = 16;
}
- ret[i*pixels_per_line + pixels_read + k] = invert - buffer[k];
+ ret[i * pixels_per_line + pixels_read + k] = invert - buffer[k];
}
pixels_read += bytes;
}
- (void) qc_readbytes(q, 0); /* reset state machine */
+ (void) qc_readbytes (q, 0); /* reset state machine */
}
if ((q->port_mode & QC_MODE_MASK) == QC_BIDIR) {
- write_lpcontrol(q, 2);
- write_lpcontrol(q, 6);
- usleep(3);
- write_lpcontrol(q, 0xe);
+ write_lpcontrol (q, 2);
+ write_lpcontrol (q, 6);
+ usleep (3);
+ write_lpcontrol (q, 0xe);
}
return ret;
void
-qc_dump(const struct qcam *q, char *fname)
+qc_dump (const struct qcam *q, char *fname)
{
FILE *fp;
time_t t;
- if ((fp = fopen(fname, "w")) == 0)
- {
- fprintf(stderr, "Error: cannot open %s\n", fname);
+ if ((fp = fopen (fname, "w")) == 0) {
+ fprintf (stderr, "Error: cannot open %s\n", fname);
return;
}
- fprintf(fp, "# Version 0.9\n");
- time(&t);
- fprintf(fp, "# Created %s", ctime(&t));
- fprintf(fp, "Width %d\nHeight %d\n", q->width, q->height);
- fprintf(fp, "Top %d\nLeft %d\n", q->top, q->left);
- fprintf(fp, "Bpp %d\nContrast %d\n", q->bpp, q->contrast);
- fprintf(fp, "Brightness %d\nWhitebal %d\n", q->brightness, q->whitebal);
- fprintf(fp, "Port 0x%x\nScale %d\n", q->port, q->transfer_scale);
- fclose(fp);
+ fprintf (fp, "# Version 0.9\n");
+ time (&t);
+ fprintf (fp, "# Created %s", ctime (&t));
+ fprintf (fp, "Width %d\nHeight %d\n", q->width, q->height);
+ fprintf (fp, "Top %d\nLeft %d\n", q->top, q->left);
+ fprintf (fp, "Bpp %d\nContrast %d\n", q->bpp, q->contrast);
+ fprintf (fp, "Brightness %d\nWhitebal %d\n", q->brightness, q->whitebal);
+ fprintf (fp, "Port 0x%x\nScale %d\n", q->port, q->transfer_scale);
+ fclose (fp);
}
#include "qcam.h"
#include "qcam-Linux.h"
-int __inline__ read_lpstatus(const struct qcam *q) { return inb(q->port+1); }
-int read_lpcontrol(const struct qcam *q) { return inb(q->port+2); }
-int read_lpdata(const struct qcam *q) { return inb(q->port); }
-void write_lpdata(const struct qcam *q, int d) { outb(d,q->port); }
-void write_lpcontrol(const struct qcam *q, int d) { outb(d,q->port+2); }
+int __inline__
+read_lpstatus (const struct qcam *q)
+{
+ return inb (q->port + 1);
+}
+
+int
+read_lpcontrol (const struct qcam *q)
+{
+ return inb (q->port + 2);
+}
+
+int
+read_lpdata (const struct qcam *q)
+{
+ return inb (q->port);
+}
-int enable_ports(const struct qcam *q)
+void
+write_lpdata (const struct qcam *q, int d)
{
- if(q->port<0x278) return 1; /* Better safe than sorry */
- if(q->port>0x3bc) return 1;
- return (ioperm(q->port, 3, 1));
+ outb (d, q->port);
}
-int disable_ports(const struct qcam *q)
+void
+write_lpcontrol (const struct qcam *q, int d)
{
- return (ioperm(q->port, 3, 0));
+ outb (d, q->port + 2);
+}
+
+int
+enable_ports (const struct qcam *q)
+{
+ if (q->port < 0x278)
+ return 1; /* Better safe than sorry */
+ if (q->port > 0x3bc)
+ return 1;
+ return (ioperm (q->port, 3, 1));
+}
+
+int
+disable_ports (const struct qcam *q)
+{
+ return (ioperm (q->port, 3, 0));
}
/* Lock port. This is currently sub-optimal, and is begging to be
* multiple processes (eg. qcam) taking "snapshots" can peacefully coexist.
* - Dave Plonka (plonka@carroll1.cc.edu)
*/
-int qc_lock_wait(struct qcam *q, int wait)
+int
+qc_lock_wait (struct qcam *q, int wait)
{
#if 1
static struct flock sfl;
- if (-1 == q->fd) /* we've yet to open the lock file */
- {
- static char lockfile[128];
-
- sprintf(lockfile,"/var/run/LOCK.qcam.0x%x",q->port);
- if (-1 == (q->fd = open(lockfile, O_WRONLY | O_CREAT, 0666)))
- {
- perror("open");
- return 1;
- }
+ if (-1 == q->fd) { /* we've yet to open the lock file */
+ static char lockfile[128];
+ sprintf (lockfile, "/var/run/LOCK.qcam.0x%x", q->port);
+ if (-1 == (q->fd = open (lockfile, O_WRONLY | O_CREAT, 0666))) {
+ perror ("open");
+ return 1;
+ }
#ifdef TESTING
- fprintf(stderr, "%s - %d: %s open(2)ed\n", __FILE__, __LINE__, lockfile);
+ fprintf (stderr, "%s - %d: %s open(2)ed\n", __FILE__, __LINE__, lockfile);
#endif
- /* initialize the l_type memver to lock the file exclusively */
- sfl.l_type = F_WRLCK;
+ /* initialize the l_type memver to lock the file exclusively */
+ sfl.l_type = F_WRLCK;
}
-
#ifdef TESTING
- if (0 != fcntl(q->fd, F_SETLK, &sfl)) /* non-blocking set lock */
+ if (0 != fcntl (q->fd, F_SETLK, &sfl)) /* non-blocking set lock */
#else
- if (0 != fcntl(q->fd, wait? F_SETLKW : F_SETLK, &sfl))
+ if (0 != fcntl (q->fd, wait ? F_SETLKW : F_SETLK, &sfl))
#endif
{
#ifdef TESTING
- perror("fcntl");
- if (EAGAIN != errno || !wait) return 1;
-
- fprintf(stderr, "%s - %d: waiting for exclusive lock on fd %d...\n", __FILE__, __LINE__, q->fd);
+ perror ("fcntl");
+ if (EAGAIN != errno || !wait)
+ return 1;
+
+ fprintf (stderr, "%s - %d: waiting for exclusive lock on fd %d...\n",
+ __FILE__, __LINE__, q->fd);
- if (0 != fcntl(q->fd, F_SETLKW, &sfl)) /* "blocking" set lock */
+ if (0 != fcntl (q->fd, F_SETLKW, &sfl)) /* "blocking" set lock */
#endif
- {
- perror("fcntl");
- return 1;
- }
+ {
+ perror ("fcntl");
+ return 1;
+ }
}
-
#ifdef TESTING
- fprintf(stderr, "%s - %d: fd %d locked exclusively\n", __FILE__, __LINE__, q->fd);
+ fprintf (stderr, "%s - %d: fd %d locked exclusively\n", __FILE__, __LINE__,
+ q->fd);
#endif
#else
char lockfile[128], tmp[128];
struct stat statbuf;
- sprintf(lockfile,"/var/run/LOCK.qcam.0x%x",q->port);
- sprintf(tmp,"%s-%d",lockfile,getpid());
+ sprintf (lockfile, "/var/run/LOCK.qcam.0x%x", q->port);
+ sprintf (tmp, "%s-%d", lockfile, getpid ());
- if ((creat(tmp,0)==-1) ||
- (link(tmp,lockfile)==-1) ||
- (stat(tmp,&statbuf)==-1) ||
- (statbuf.st_nlink==1))
- {
+ if ((creat (tmp, 0) == -1) ||
+ (link (tmp, lockfile) == -1) ||
+ (stat (tmp, &statbuf) == -1) || (statbuf.st_nlink == 1)) {
#ifdef DEBUGQC
- perror("QuickCam Locked");
- if(unlink(tmp)==-1)
- perror("Error unlinking temp file.");
+ perror ("QuickCam Locked");
+ if (unlink (tmp) == -1)
+ perror ("Error unlinking temp file.");
#else
- unlink(tmp);
+ unlink (tmp);
#endif
return 1;
}
-
- unlink(tmp);
- if (chown(lockfile,getuid(),getgid())==-1)
- perror("Chown problems");
+
+ unlink (tmp);
+ if (chown (lockfile, getuid (), getgid ()) == -1)
+ perror ("Chown problems");
#endif
return 0;
}
-int qc_lock(struct qcam *q)
+int
+qc_lock (struct qcam *q)
{
#if 1
- return qc_lock_wait(q, 1 /*wait*/);
+ return qc_lock_wait (q, 1 /*wait */ );
#else
- return qc_lock_wait(q, 0 /*don't wait*/);
+ return qc_lock_wait (q, 0 /*don't wait */ );
#endif
}
/* Unlock port */
-int qc_unlock(struct qcam *q)
+int
+qc_unlock (struct qcam *q)
{
static struct flock sfl;
+
#if 1
- if (-1 == q->fd)
- { /* port was not locked */
- return 1;
+ if (-1 == q->fd) { /* port was not locked */
+ return 1;
}
/* clear the exclusive lock */
sfl.l_type = F_UNLCK;
- if (0 != fcntl(q->fd, F_SETLK, &sfl))
- {
- perror("fcntl");
- return 1;
+ if (0 != fcntl (q->fd, F_SETLK, &sfl)) {
+ perror ("fcntl");
+ return 1;
}
-
#ifdef TESTING
- fprintf(stderr, "%s - %d: fd %d unlocked\n", __FILE__, __LINE__, q->fd);
+ fprintf (stderr, "%s - %d: fd %d unlocked\n", __FILE__, __LINE__, q->fd);
#endif
#else
char lockfile[128];
- sprintf(lockfile,"/var/run/LOCK.qcam.0x%x",q->port);
- unlink(lockfile); /* What would I do with an error? */
+ sprintf (lockfile, "/var/run/LOCK.qcam.0x%x", q->port);
+ unlink (lockfile); /* What would I do with an error? */
#endif
return 0;
/* Probe for camera. Returns 0 if found, 1 if not found, sets
q->port.*/
-int qc_probe(struct qcam *q)
+int
+qc_probe (struct qcam *q)
{
- int ioports[]={0x378, 0x278, 0x3bc,0};
- int i=0;
+ int ioports[] = { 0x378, 0x278, 0x3bc, 0 };
+ int i = 0;
/* Attempt to get permission to access IO ports. Must be root */
- while(ioports[i]!=0) {
- q->port=ioports[i++];
+ while (ioports[i] != 0) {
+ q->port = ioports[i++];
- if (qc_open(q)) {
- perror("Can't get I/O permission");
- exit(1);
+ if (qc_open (q)) {
+ perror ("Can't get I/O permission");
+ exit (1);
}
- if(qc_detect(q)) {
- fprintf(stderr,"QuickCam detected at 0x%x\n",q->port);
- qc_close(q);
- return(0);
- }
- else
- qc_close(q);
+ if (qc_detect (q)) {
+ fprintf (stderr, "QuickCam detected at 0x%x\n", q->port);
+ qc_close (q);
+ return (0);
+ } else
+ qc_close (q);
}
return 1;
to run. This seems to help, but if anyone has a good
speed-independent pause routine, please tell me. -- Scott */
-void qc_wait(int val)
+void
+qc_wait (int val)
{
int i;
-
- while(val--)
- for(i=0;i<50000;i++);
+
+ while (val--)
+ for (i = 0; i < 50000; i++);
}
OTHER DEALINGS IN THE SOFTWARE.
******************************************************************/
-
-
#define MAX_HEIGHT 243
#define MAX_WIDTH 336
-struct qcam {
+struct qcam
+{
int width, height;
int bpp;
int mode;
int port_mode;
int transfer_scale;
int top, left;
- int fd; /* lock file descriptor
- * It was, unfortunately, necessary to add this member to the
- * struct qcam to conveniently implement POSIX fcntl-style locking.
- * We need a seperate lock file for each struct qcam, for instance,
- * if the same process (using qcam-lib) is accessing multiple
- * QuickCams on (of course) multiple ports.
- * - Dave Plonka (plonka@carroll1.cc.edu)
- */
+ int fd; /* lock file descriptor
+ * It was, unfortunately, necessary to add this member to the
+ * struct qcam to conveniently implement POSIX fcntl-style locking.
+ * We need a seperate lock file for each struct qcam, for instance,
+ * if the same process (using qcam-lib) is accessing multiple
+ * QuickCams on (of course) multiple ports.
+ * - Dave Plonka (plonka@carroll1.cc.edu)
+ */
};
typedef unsigned char scanbuf;
/* General QuickCam handling routines */
-int qc_getbrightness(const struct qcam *q);
-int qc_setbrightness(struct qcam *q, int val);
-int qc_getcontrast(const struct qcam *q);
-int qc_setcontrast(struct qcam *q, int val);
-int qc_getwhitebal(const struct qcam *q);
-int qc_setwhitebal(struct qcam *q, int val);
-void qc_getresolution(const struct qcam *q, int *x, int *y);
-int qc_setresolution(struct qcam *q, int x, int y);
-int qc_getbitdepth(const struct qcam *q);
-int qc_setbitdepth(struct qcam *q, int val);
-int qc_getheight(const struct qcam *q);
-int qc_setheight(struct qcam *q, int y);
-int qc_getwidth(const struct qcam *q);
-int qc_setwidth(struct qcam *q, int x);
-int qc_gettop(const struct qcam *q);
-int qc_settop(struct qcam *q, int val);
-int qc_getleft(const struct qcam *q);
-int qc_setleft(struct qcam *q, int val);
-int qc_gettransfer_scale(const struct qcam *q);
-int qc_settransfer_scale(struct qcam *q, int val);
-int qc_calibrate(struct qcam *q);
-int qc_forceunidir(struct qcam *q);
-void qc_dump(const struct qcam *q, char *file);
-
-struct qcam *qc_init(void);
-int qc_initfile(struct qcam *q, char *fname);
-int qc_open(struct qcam *q);
-int qc_close(struct qcam *q);
-int qc_detect(const struct qcam *q);
-void qc_reset(struct qcam *q);
-void qc_set(struct qcam *q);
-scanbuf *qc_scan(const struct qcam *q);
-scanbuf *qc_convertscan(struct qcam *q, scanbuf *scan);
-void qc_writepgm(const struct qcam *q, FILE *f, scanbuf *scan);
-void qc_wait(int val);
+int qc_getbrightness (const struct qcam *q);
+int qc_setbrightness (struct qcam *q, int val);
+int qc_getcontrast (const struct qcam *q);
+int qc_setcontrast (struct qcam *q, int val);
+int qc_getwhitebal (const struct qcam *q);
+int qc_setwhitebal (struct qcam *q, int val);
+void qc_getresolution (const struct qcam *q, int *x, int *y);
+int qc_setresolution (struct qcam *q, int x, int y);
+int qc_getbitdepth (const struct qcam *q);
+int qc_setbitdepth (struct qcam *q, int val);
+int qc_getheight (const struct qcam *q);
+int qc_setheight (struct qcam *q, int y);
+int qc_getwidth (const struct qcam *q);
+int qc_setwidth (struct qcam *q, int x);
+int qc_gettop (const struct qcam *q);
+int qc_settop (struct qcam *q, int val);
+int qc_getleft (const struct qcam *q);
+int qc_setleft (struct qcam *q, int val);
+int qc_gettransfer_scale (const struct qcam *q);
+int qc_settransfer_scale (struct qcam *q, int val);
+int qc_calibrate (struct qcam *q);
+int qc_forceunidir (struct qcam *q);
+void qc_dump (const struct qcam *q, char *file);
+
+struct qcam *qc_init (void);
+int qc_initfile (struct qcam *q, char *fname);
+int qc_open (struct qcam *q);
+int qc_close (struct qcam *q);
+int qc_detect (const struct qcam *q);
+void qc_reset (struct qcam *q);
+void qc_set (struct qcam *q);
+scanbuf *qc_scan (const struct qcam *q);
+scanbuf *qc_convertscan (struct qcam *q, scanbuf * scan);
+void qc_writepgm (const struct qcam *q, FILE * f, scanbuf * scan);
+void qc_wait (int val);
/* OS/hardware specific routines */
-int read_lpstatus(const struct qcam *q);
-int read_lpcontrol(const struct qcam *q);
-int read_lpdata(const struct qcam *q);
-void write_lpdata(const struct qcam *q, int d);
-void write_lpcontrol(const struct qcam *q, int d);
-int enable_ports(const struct qcam *q);
-int disable_ports(const struct qcam *q);
-int qc_unlock(struct qcam *q);
-int qc_lock(struct qcam *q);
-void qc_wait(int val);
-int qc_probe(struct qcam *q);
+int read_lpstatus (const struct qcam *q);
+int read_lpcontrol (const struct qcam *q);
+int read_lpdata (const struct qcam *q);
+void write_lpdata (const struct qcam *q, int d);
+void write_lpcontrol (const struct qcam *q, int d);
+int enable_ports (const struct qcam *q);
+int disable_ports (const struct qcam *q);
+int qc_unlock (struct qcam *q);
+int qc_lock (struct qcam *q);
+void qc_wait (int val);
+int qc_probe (struct qcam *q);
/* Image processing routines */
-int fixdark(const struct qcam *q, scanbuf *scan);
-int qc_edge_detect(const struct qcam *q, scanbuf *scan, int tolerance);
+int fixdark (const struct qcam *q, scanbuf * scan);
+int qc_edge_detect (const struct qcam *q, scanbuf * scan, int tolerance);
-#endif /*! _QCAM_H*/
+#endif /*! _QCAM_H */
/* Prototypes for image processing routines */
-int qcip_autoexposure(struct qcam *q, scanbuf *scan);
-int qcip_set_luminance_target(struct qcam *q, int val);
-int qcip_set_luminance_tolerance(struct qcam *q, int val);
-int qcip_set_luminance_std_target(struct qcam *q, int val);
-int qcip_set_luminance_std_tolerance(struct qcam *q, int val);
-int qcip_set_autoexposure_mode(int val);
-void qcip_histogram(struct qcam *q, scanbuf *scan, int *histogram);
-void qcip_display_histogram(struct qcam *q, scanbuf *scan);
+int qcip_autoexposure (struct qcam *q, scanbuf * scan);
+int qcip_set_luminance_target (struct qcam *q, int val);
+int qcip_set_luminance_tolerance (struct qcam *q, int val);
+int qcip_set_luminance_std_target (struct qcam *q, int val);
+int qcip_set_luminance_std_tolerance (struct qcam *q, int val);
+int qcip_set_autoexposure_mode (int val);
+void qcip_histogram (struct qcam *q, scanbuf * scan, int *histogram);
+void qcip_display_histogram (struct qcam *q, scanbuf * scan);
-#endif /*! _QCAMIP_H*/
+#endif /*! _QCAMIP_H */
#include "gstv4l2src.h"
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
/* actually, we can survive without it, but I'll create
* that handling later on. */
return FALSE;
if (!gst_element_register (plugin, "v4l2element",
- GST_RANK_NONE, GST_TYPE_V4L2ELEMENT) ||
+ GST_RANK_NONE, GST_TYPE_V4L2ELEMENT) ||
!gst_element_register (plugin, "v4l2src",
- GST_RANK_NONE, GST_TYPE_V4L2SRC))
+ GST_RANK_NONE, GST_TYPE_V4L2SRC))
return FALSE;
#ifdef ENABLE_NLS
return TRUE;
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "video4linux2",
- "elements for Video 4 Linux 2",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "video4linux2",
+ "elements for Video 4 Linux 2",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
#include "gstv4l2element.h"
static void
-gst_v4l2_color_balance_channel_class_init(GstV4l2ColorBalanceChannelClass *klass);
-static void
-gst_v4l2_color_balance_channel_init (GstV4l2ColorBalanceChannel *channel);
-
-static const GList *
-gst_v4l2_color_balance_list_channels (GstColorBalance *balance);
-static void
-gst_v4l2_color_balance_set_value (GstColorBalance *balance,
- GstColorBalanceChannel *channel,
- gint value);
-static gint
-gst_v4l2_color_balance_get_value (GstColorBalance *balance,
- GstColorBalanceChannel *channel);
+gst_v4l2_color_balance_channel_class_init (GstV4l2ColorBalanceChannelClass *
+ klass);
+static void gst_v4l2_color_balance_channel_init (GstV4l2ColorBalanceChannel *
+ channel);
+
+static const GList *gst_v4l2_color_balance_list_channels (GstColorBalance *
+ balance);
+static void gst_v4l2_color_balance_set_value (GstColorBalance * balance,
+ GstColorBalanceChannel * channel, gint value);
+static gint gst_v4l2_color_balance_get_value (GstColorBalance * balance,
+ GstColorBalanceChannel * channel);
static GstColorBalanceChannelClass *parent_class = NULL;
gst_v4l2_color_balance_channel_type =
g_type_register_static (GST_TYPE_COLOR_BALANCE_CHANNEL,
- "GstV4l2ColorBalanceChannel",
- &v4l2_tuner_channel_info, 0);
+ "GstV4l2ColorBalanceChannel", &v4l2_tuner_channel_info, 0);
}
return gst_v4l2_color_balance_channel_type;
}
static void
-gst_v4l2_color_balance_channel_class_init (GstV4l2ColorBalanceChannelClass *klass)
+gst_v4l2_color_balance_channel_class_init (GstV4l2ColorBalanceChannelClass *
+ klass)
{
parent_class = g_type_class_ref (GST_TYPE_COLOR_BALANCE_CHANNEL);
}
static void
-gst_v4l2_color_balance_channel_init (GstV4l2ColorBalanceChannel *channel)
+gst_v4l2_color_balance_channel_init (GstV4l2ColorBalanceChannel * channel)
{
channel->index = 0;
}
void
-gst_v4l2_color_balance_interface_init (GstColorBalanceClass *klass)
+gst_v4l2_color_balance_interface_init (GstColorBalanceClass * klass)
{
GST_COLOR_BALANCE_TYPE (klass) = GST_COLOR_BALANCE_HARDWARE;
-
+
/* default virtual functions */
klass->list_channels = gst_v4l2_color_balance_list_channels;
klass->set_value = gst_v4l2_color_balance_set_value;
}
static gboolean
-gst_v4l2_color_balance_contains_channel (GstV4l2Element *v4l2element,
- GstV4l2ColorBalanceChannel *v4l2channel)
+gst_v4l2_color_balance_contains_channel (GstV4l2Element * v4l2element,
+ GstV4l2ColorBalanceChannel * v4l2channel)
{
const GList *item;
}
static const GList *
-gst_v4l2_color_balance_list_channels (GstColorBalance *balance)
+gst_v4l2_color_balance_list_channels (GstColorBalance * balance)
{
return GST_V4L2ELEMENT (balance)->colors;
}
static void
-gst_v4l2_color_balance_set_value (GstColorBalance *balance,
- GstColorBalanceChannel *channel,
- gint value)
+gst_v4l2_color_balance_set_value (GstColorBalance * balance,
+ GstColorBalanceChannel * channel, gint value)
{
GstV4l2Element *v4l2element = GST_V4L2ELEMENT (balance);
GstV4l2ColorBalanceChannel *v4l2channel =
- GST_V4L2_COLOR_BALANCE_CHANNEL (channel);
+ GST_V4L2_COLOR_BALANCE_CHANNEL (channel);
/* assert that we're opened and that we're using a known item */
g_return_if_fail (GST_V4L2_IS_OPEN (v4l2element));
g_return_if_fail (gst_v4l2_color_balance_contains_channel (v4l2element,
- v4l2channel));
+ v4l2channel));
gst_v4l2_set_attribute (v4l2element, v4l2channel->index, value);
}
static gint
-gst_v4l2_color_balance_get_value (GstColorBalance *balance,
- GstColorBalanceChannel *channel)
+gst_v4l2_color_balance_get_value (GstColorBalance * balance,
+ GstColorBalanceChannel * channel)
{
GstV4l2Element *v4l2element = GST_V4L2ELEMENT (balance);
GstV4l2ColorBalanceChannel *v4l2channel =
- GST_V4L2_COLOR_BALANCE_CHANNEL (channel);
+ GST_V4L2_COLOR_BALANCE_CHANNEL (channel);
gint value;
/* assert that we're opened and that we're using a known item */
g_return_val_if_fail (GST_V4L2_IS_OPEN (v4l2element), 0);
g_return_val_if_fail (gst_v4l2_color_balance_contains_channel (v4l2element,
- v4l2channel),
- 0);
+ v4l2channel), 0);
if (!gst_v4l2_get_attribute (v4l2element, v4l2channel->index, &value))
return 0;
#include "v4l2_calls.h"
G_BEGIN_DECLS
-
#define GST_TYPE_V4L2_COLOR_BALANCE_CHANNEL \
(gst_v4l2_color_balance_channel_get_type ())
#define GST_V4L2_COLOR_BALANCE_CHANNEL(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_V4L2_COLOR_BALANCE_CHANNEL))
#define GST_IS_V4L2_COLOR_BALANCE_CHANNEL_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_V4L2_COLOR_BALANCE_CHANNEL))
-
-typedef struct _GstV4l2ColorBalanceChannel {
+ typedef struct _GstV4l2ColorBalanceChannel
+{
GstColorBalanceChannel parent;
guint32 index;
} GstV4l2ColorBalanceChannel;
-typedef struct _GstV4l2ColorBalanceChannelClass {
+typedef struct _GstV4l2ColorBalanceChannelClass
+{
GstColorBalanceChannelClass parent;
} GstV4l2ColorBalanceChannelClass;
-GType gst_v4l2_color_balance_channel_get_type (void);
+GType gst_v4l2_color_balance_channel_get_type (void);
-void gst_v4l2_color_balance_interface_init (GstColorBalanceClass *klass);
+void gst_v4l2_color_balance_interface_init (GstColorBalanceClass * klass);
#endif /* __GST_V4L2_COLOR_BALANCE_H__ */
/* elementfactory details */
static GstElementDetails gst_v4l2element_details = {
- "Generic video4linux2 Element",
- "Generic/Video",
- "Generic plugin for handling common video4linux2 calls",
- "Ronald Bultje <rbultje@ronald.bitfreak.net>"
+ "Generic video4linux2 Element",
+ "Generic/Video",
+ "Generic plugin for handling common video4linux2 calls",
+ "Ronald Bultje <rbultje@ronald.bitfreak.net>"
};
/* V4l2Element signals and args */
-enum {
+enum
+{
/* FILL ME */
SIGNAL_OPEN,
SIGNAL_CLOSE,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_DEVICE,
ARG_DEVICE_NAME,
};
-static void gst_v4l2element_class_init (GstV4l2ElementClass *klass);
-static void gst_v4l2element_base_init (GstV4l2ElementClass *klass);
-static void gst_v4l2element_init (GstV4l2Element *v4lelement);
-static void gst_v4l2element_dispose (GObject *object);
-static void gst_v4l2element_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gst_v4l2element_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
+static void gst_v4l2element_class_init (GstV4l2ElementClass * klass);
+static void gst_v4l2element_base_init (GstV4l2ElementClass * klass);
+static void gst_v4l2element_init (GstV4l2Element * v4lelement);
+static void gst_v4l2element_dispose (GObject * object);
+static void gst_v4l2element_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+static void gst_v4l2element_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
static GstElementStateReturn
- gst_v4l2element_change_state (GstElement *element);
+gst_v4l2element_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
static gboolean
-gst_v4l2_iface_supported (GstImplementsInterface *iface,
- GType iface_type)
+gst_v4l2_iface_supported (GstImplementsInterface * iface, GType iface_type)
{
- GstV4l2Element *v4l2element = GST_V4L2ELEMENT (iface);
+ GstV4l2Element *v4l2element = GST_V4L2ELEMENT (iface);
- g_assert (iface_type == GST_TYPE_TUNER ||
- iface_type == GST_TYPE_X_OVERLAY ||
- iface_type == GST_TYPE_COLOR_BALANCE);
+ g_assert (iface_type == GST_TYPE_TUNER ||
+ iface_type == GST_TYPE_X_OVERLAY || iface_type == GST_TYPE_COLOR_BALANCE);
- if (v4l2element->video_fd == -1)
- return FALSE;
+ if (v4l2element->video_fd == -1)
+ return FALSE;
- if (iface_type == GST_TYPE_X_OVERLAY &&
- !GST_V4L2_IS_OVERLAY(v4l2element))
- return FALSE;
+ if (iface_type == GST_TYPE_X_OVERLAY && !GST_V4L2_IS_OVERLAY (v4l2element))
+ return FALSE;
- return TRUE;
+ return TRUE;
}
static void
-gst_v4l2_interface_init (GstImplementsInterfaceClass *klass)
+gst_v4l2_interface_init (GstImplementsInterfaceClass * klass)
{
- /* default virtual functions */
- klass->supported = gst_v4l2_iface_supported;
+ /* default virtual functions */
+ klass->supported = gst_v4l2_iface_supported;
}
static const GList *
-gst_v4l2_probe_get_properties (GstPropertyProbe *probe)
+gst_v4l2_probe_get_properties (GstPropertyProbe * probe)
{
- GObjectClass *klass = G_OBJECT_GET_CLASS (probe);
- static GList *list = NULL;
+ GObjectClass *klass = G_OBJECT_GET_CLASS (probe);
+ static GList *list = NULL;
- if (!list) {
- list = g_list_append (NULL,
- g_object_class_find_property (klass, "device"));
- }
+ if (!list) {
+ list = g_list_append (NULL, g_object_class_find_property (klass, "device"));
+ }
- return list;
+ return list;
}
static gboolean
-gst_v4l2_class_probe_devices (GstV4l2ElementClass *klass,
- gboolean check)
+gst_v4l2_class_probe_devices (GstV4l2ElementClass * klass, gboolean check)
{
- static gboolean init = FALSE;
- static GList *devices = NULL;
-
- if (!init && !check) {
- gchar *dev_base[] = { "/dev/video", "/dev/v4l/video", NULL };
- gint base, n, fd;
-
- while (devices) {
- GList *item = devices;
- gchar *device = item->data;
-
- devices = g_list_remove (devices, item);
- g_free (device);
- }
-
- /* detect /dev entries */
- for (n = 0; n < 64; n++) {
- for (base = 0; dev_base[base] != NULL; base++) {
- struct stat s;
- gchar *device = g_strdup_printf ("%s%d",
- dev_base[base], n);
-
- /* does the /dev/ entry exist at all? */
- if (stat (device, &s) == 0) {
- /* yes: is a device attached? */
- if ((fd = open (device, O_RDONLY)) > 0 ||
- errno == EBUSY) {
- if (fd > 0)
- close (fd);
-
- devices =
- g_list_append (devices,
- device);
- break;
- }
- }
- g_free (device);
- }
- }
-
- init = TRUE;
+ static gboolean init = FALSE;
+ static GList *devices = NULL;
+
+ if (!init && !check) {
+ gchar *dev_base[] = { "/dev/video", "/dev/v4l/video", NULL };
+ gint base, n, fd;
+
+ while (devices) {
+ GList *item = devices;
+ gchar *device = item->data;
+
+ devices = g_list_remove (devices, item);
+ g_free (device);
+ }
+
+ /* detect /dev entries */
+ for (n = 0; n < 64; n++) {
+ for (base = 0; dev_base[base] != NULL; base++) {
+ struct stat s;
+ gchar *device = g_strdup_printf ("%s%d",
+ dev_base[base], n);
+
+ /* does the /dev/ entry exist at all? */
+ if (stat (device, &s) == 0) {
+ /* yes: is a device attached? */
+ if ((fd = open (device, O_RDONLY)) > 0 || errno == EBUSY) {
+ if (fd > 0)
+ close (fd);
+
+ devices = g_list_append (devices, device);
+ break;
+ }
}
+ g_free (device);
+ }
+ }
- klass->devices = devices;
+ init = TRUE;
+ }
- return init;
+ klass->devices = devices;
+
+ return init;
}
static void
-gst_v4l2_probe_probe_property (GstPropertyProbe *probe,
- guint prop_id,
- const GParamSpec *pspec)
+gst_v4l2_probe_probe_property (GstPropertyProbe * probe,
+ guint prop_id, const GParamSpec * pspec)
{
- GstV4l2ElementClass *klass = GST_V4L2ELEMENT_GET_CLASS (probe);
-
- switch (prop_id) {
- case ARG_DEVICE:
- gst_v4l2_class_probe_devices (klass, FALSE);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (probe, prop_id, pspec);
- break;
- }
+ GstV4l2ElementClass *klass = GST_V4L2ELEMENT_GET_CLASS (probe);
+
+ switch (prop_id) {
+ case ARG_DEVICE:
+ gst_v4l2_class_probe_devices (klass, FALSE);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (probe, prop_id, pspec);
+ break;
+ }
}
static gboolean
-gst_v4l2_probe_needs_probe (GstPropertyProbe *probe,
- guint prop_id,
- const GParamSpec *pspec)
+gst_v4l2_probe_needs_probe (GstPropertyProbe * probe,
+ guint prop_id, const GParamSpec * pspec)
{
- GstV4l2ElementClass *klass = GST_V4L2ELEMENT_GET_CLASS (probe);
- gboolean ret = FALSE;
-
- switch (prop_id) {
- case ARG_DEVICE:
- ret = !gst_v4l2_class_probe_devices (klass, TRUE);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (probe, prop_id, pspec);
- break;
- }
+ GstV4l2ElementClass *klass = GST_V4L2ELEMENT_GET_CLASS (probe);
+ gboolean ret = FALSE;
- return ret;
+ switch (prop_id) {
+ case ARG_DEVICE:
+ ret = !gst_v4l2_class_probe_devices (klass, TRUE);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (probe, prop_id, pspec);
+ break;
+ }
+
+ return ret;
}
static GValueArray *
-gst_v4l2_class_list_devices (GstV4l2ElementClass *klass)
+gst_v4l2_class_list_devices (GstV4l2ElementClass * klass)
{
- GValueArray *array;
- GValue value = { 0 };
- GList *item;
+ GValueArray *array;
+ GValue value = { 0 };
+ GList *item;
- if (!klass->devices)
- return NULL;
+ if (!klass->devices)
+ return NULL;
- array = g_value_array_new (g_list_length (klass->devices));
- item = klass->devices;
- g_value_init (&value, G_TYPE_STRING);
- while (item) {
- gchar *device = item->data;
+ array = g_value_array_new (g_list_length (klass->devices));
+ item = klass->devices;
+ g_value_init (&value, G_TYPE_STRING);
+ while (item) {
+ gchar *device = item->data;
- g_value_set_string (&value, device);
- g_value_array_append (array, &value);
+ g_value_set_string (&value, device);
+ g_value_array_append (array, &value);
- item = item->next;
- }
- g_value_unset (&value);
+ item = item->next;
+ }
+ g_value_unset (&value);
- return array;
+ return array;
}
static GValueArray *
-gst_v4l2_probe_get_values (GstPropertyProbe *probe,
- guint prop_id,
- const GParamSpec *pspec)
+gst_v4l2_probe_get_values (GstPropertyProbe * probe,
+ guint prop_id, const GParamSpec * pspec)
{
- GstV4l2ElementClass *klass = GST_V4L2ELEMENT_GET_CLASS (probe);
- GValueArray *array = NULL;
-
- switch (prop_id) {
- case ARG_DEVICE:
- array = gst_v4l2_class_list_devices (klass);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (probe, prop_id, pspec);
- break;
- }
+ GstV4l2ElementClass *klass = GST_V4L2ELEMENT_GET_CLASS (probe);
+ GValueArray *array = NULL;
+
+ switch (prop_id) {
+ case ARG_DEVICE:
+ array = gst_v4l2_class_list_devices (klass);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (probe, prop_id, pspec);
+ break;
+ }
- return array;
+ return array;
}
static void
-gst_v4l2_property_probe_interface_init (GstPropertyProbeInterface *iface)
+gst_v4l2_property_probe_interface_init (GstPropertyProbeInterface * iface)
{
- iface->get_properties = gst_v4l2_probe_get_properties;
- iface->probe_property = gst_v4l2_probe_probe_property;
- iface->needs_probe = gst_v4l2_probe_needs_probe;
- iface->get_values = gst_v4l2_probe_get_values;
+ iface->get_properties = gst_v4l2_probe_get_properties;
+ iface->probe_property = gst_v4l2_probe_probe_property;
+ iface->needs_probe = gst_v4l2_probe_needs_probe;
+ iface->get_values = gst_v4l2_probe_get_values;
}
GType
gst_v4l2element_get_type (void)
{
- static GType v4l2element_type = 0;
-
- if (!v4l2element_type) {
- static const GTypeInfo v4l2element_info = {
- sizeof(GstV4l2ElementClass),
- (GBaseInitFunc) gst_v4l2element_base_init,
- NULL,
- (GClassInitFunc) gst_v4l2element_class_init,
- NULL,
- NULL,
- sizeof(GstV4l2Element),
- 0,
- (GInstanceInitFunc) gst_v4l2element_init,
- NULL
- };
- static const GInterfaceInfo v4l2iface_info = {
- (GInterfaceInitFunc) gst_v4l2_interface_init,
- NULL,
- NULL,
- };
- static const GInterfaceInfo v4l2_tuner_info = {
- (GInterfaceInitFunc) gst_v4l2_tuner_interface_init,
- NULL,
- NULL,
- };
- static const GInterfaceInfo v4l2_xoverlay_info = {
- (GInterfaceInitFunc) gst_v4l2_xoverlay_interface_init,
- NULL,
- NULL,
- };
- static const GInterfaceInfo v4l2_colorbalance_info = {
- (GInterfaceInitFunc) gst_v4l2_color_balance_interface_init,
- NULL,
- NULL,
- };
- static const GInterfaceInfo v4l2_propertyprobe_info = {
- (GInterfaceInitFunc) gst_v4l2_property_probe_interface_init,
- NULL,
- NULL,
- };
-
- v4l2element_type =
- g_type_register_static(GST_TYPE_ELEMENT,
- "GstV4l2Element", &v4l2element_info, 0);
-
- g_type_add_interface_static (v4l2element_type,
- GST_TYPE_IMPLEMENTS_INTERFACE,
- &v4l2iface_info);
- g_type_add_interface_static (v4l2element_type,
- GST_TYPE_TUNER,
- &v4l2_tuner_info);
- g_type_add_interface_static (v4l2element_type,
- GST_TYPE_X_OVERLAY,
- &v4l2_xoverlay_info);
- g_type_add_interface_static (v4l2element_type,
- GST_TYPE_COLOR_BALANCE,
- &v4l2_colorbalance_info);
- g_type_add_interface_static (v4l2element_type,
- GST_TYPE_PROPERTY_PROBE,
- &v4l2_propertyprobe_info);
- }
+ static GType v4l2element_type = 0;
+
+ if (!v4l2element_type) {
+ static const GTypeInfo v4l2element_info = {
+ sizeof (GstV4l2ElementClass),
+ (GBaseInitFunc) gst_v4l2element_base_init,
+ NULL,
+ (GClassInitFunc) gst_v4l2element_class_init,
+ NULL,
+ NULL,
+ sizeof (GstV4l2Element),
+ 0,
+ (GInstanceInitFunc) gst_v4l2element_init,
+ NULL
+ };
+ static const GInterfaceInfo v4l2iface_info = {
+ (GInterfaceInitFunc) gst_v4l2_interface_init,
+ NULL,
+ NULL,
+ };
+ static const GInterfaceInfo v4l2_tuner_info = {
+ (GInterfaceInitFunc) gst_v4l2_tuner_interface_init,
+ NULL,
+ NULL,
+ };
+ static const GInterfaceInfo v4l2_xoverlay_info = {
+ (GInterfaceInitFunc) gst_v4l2_xoverlay_interface_init,
+ NULL,
+ NULL,
+ };
+ static const GInterfaceInfo v4l2_colorbalance_info = {
+ (GInterfaceInitFunc) gst_v4l2_color_balance_interface_init,
+ NULL,
+ NULL,
+ };
+ static const GInterfaceInfo v4l2_propertyprobe_info = {
+ (GInterfaceInitFunc) gst_v4l2_property_probe_interface_init,
+ NULL,
+ NULL,
+ };
+
+ v4l2element_type =
+ g_type_register_static (GST_TYPE_ELEMENT,
+ "GstV4l2Element", &v4l2element_info, 0);
+
+ g_type_add_interface_static (v4l2element_type,
+ GST_TYPE_IMPLEMENTS_INTERFACE, &v4l2iface_info);
+ g_type_add_interface_static (v4l2element_type,
+ GST_TYPE_TUNER, &v4l2_tuner_info);
+ g_type_add_interface_static (v4l2element_type,
+ GST_TYPE_X_OVERLAY, &v4l2_xoverlay_info);
+ g_type_add_interface_static (v4l2element_type,
+ GST_TYPE_COLOR_BALANCE, &v4l2_colorbalance_info);
+ g_type_add_interface_static (v4l2element_type,
+ GST_TYPE_PROPERTY_PROBE, &v4l2_propertyprobe_info);
+ }
- return v4l2element_type;
+ return v4l2element_type;
}
GType
gst_v4l2_device_get_type (void)
{
- static GType v4l2_device_type = 0;
-
- if (v4l2_device_type == 0) {
- static const GFlagsValue values[] = {
- { V4L2_CAP_VIDEO_CAPTURE, "CAPTURE",
- "Device can capture" },
- { V4L2_CAP_VIDEO_OUTPUT, "PLAYBACK",
- "Device can playback" },
- { V4L2_CAP_VIDEO_OVERLAY, "OVERLAY",
- "Device can do overlay" },
- { V4L2_CAP_TUNER, "TUNER",
- "Device has a tuner" },
- { V4L2_CAP_AUDIO, "AUDIO",
- "Device handles audio" },
- { 0, NULL, NULL }
- };
-
- v4l2_device_type =
- g_flags_register_static ("GstV4l2DeviceTypeFlags",
- values);
- }
+ static GType v4l2_device_type = 0;
+
+ if (v4l2_device_type == 0) {
+ static const GFlagsValue values[] = {
+ {V4L2_CAP_VIDEO_CAPTURE, "CAPTURE",
+ "Device can capture"},
+ {V4L2_CAP_VIDEO_OUTPUT, "PLAYBACK",
+ "Device can playback"},
+ {V4L2_CAP_VIDEO_OVERLAY, "OVERLAY",
+ "Device can do overlay"},
+ {V4L2_CAP_TUNER, "TUNER",
+ "Device has a tuner"},
+ {V4L2_CAP_AUDIO, "AUDIO",
+ "Device handles audio"},
+ {0, NULL, NULL}
+ };
+
+ v4l2_device_type =
+ g_flags_register_static ("GstV4l2DeviceTypeFlags", values);
+ }
- return v4l2_device_type;
+ return v4l2_device_type;
}
static void
-gst_v4l2element_base_init (GstV4l2ElementClass *klass)
+gst_v4l2element_base_init (GstV4l2ElementClass * klass)
{
- GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
+ GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
- klass->devices = NULL;
+ klass->devices = NULL;
- gst_element_class_set_details (gstelement_class,
- &gst_v4l2element_details);
+ gst_element_class_set_details (gstelement_class, &gst_v4l2element_details);
}
static void
-gst_v4l2element_class_init (GstV4l2ElementClass *klass)
+gst_v4l2element_class_init (GstV4l2ElementClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
- g_object_class_install_property(gobject_class, ARG_DEVICE,
- g_param_spec_string("device", "Device", "Device location",
- NULL, G_PARAM_READWRITE));
- g_object_class_install_property(gobject_class, ARG_DEVICE_NAME,
- g_param_spec_string("device_name", "Device name",
- "Name of the device", NULL, G_PARAM_READABLE));
- g_object_class_install_property(gobject_class, ARG_FLAGS,
- g_param_spec_flags("flags", "Flags", "Device type flags",
- GST_TYPE_V4L2_DEVICE_FLAGS, 0, G_PARAM_READABLE));
- g_object_class_install_property(gobject_class, ARG_NORM,
- g_param_spec_string("norm", "norm",
- "Norm to use", NULL, G_PARAM_READWRITE));
- g_object_class_install_property(gobject_class, ARG_CHANNEL,
- g_param_spec_string("channel", "channel",
- "input/output to switch to", NULL, G_PARAM_READWRITE));
- g_object_class_install_property(gobject_class, ARG_FREQUENCY,
+ g_object_class_install_property (gobject_class, ARG_DEVICE,
+ g_param_spec_string ("device", "Device", "Device location",
+ NULL, G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, ARG_DEVICE_NAME,
+ g_param_spec_string ("device_name", "Device name",
+ "Name of the device", NULL, G_PARAM_READABLE));
+ g_object_class_install_property (gobject_class, ARG_FLAGS,
+ g_param_spec_flags ("flags", "Flags", "Device type flags",
+ GST_TYPE_V4L2_DEVICE_FLAGS, 0, G_PARAM_READABLE));
+ g_object_class_install_property (gobject_class, ARG_NORM,
+ g_param_spec_string ("norm", "norm",
+ "Norm to use", NULL, G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, ARG_CHANNEL,
+ g_param_spec_string ("channel", "channel",
+ "input/output to switch to", NULL, G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, ARG_FREQUENCY,
g_param_spec_ulong ("frequency", "frequency",
"frequency to tune to", 0, G_MAXULONG, 0, G_PARAM_READWRITE));
/* signals */
gst_v4l2element_signals[SIGNAL_OPEN] =
- g_signal_new("open", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GstV4l2ElementClass, open),
- NULL, NULL, g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
+ g_signal_new ("open", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstV4l2ElementClass, open),
+ NULL, NULL, g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1, G_TYPE_STRING);
gst_v4l2element_signals[SIGNAL_CLOSE] =
- g_signal_new("close", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GstV4l2ElementClass, close),
- NULL, NULL, g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
+ g_signal_new ("close", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstV4l2ElementClass, close),
+ NULL, NULL, g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1, G_TYPE_STRING);
gobject_class->set_property = gst_v4l2element_set_property;
gobject_class->get_property = gst_v4l2element_get_property;
static void
-gst_v4l2element_init (GstV4l2Element *v4l2element)
+gst_v4l2element_init (GstV4l2Element * v4l2element)
{
- /* some default values */
- v4l2element->video_fd = -1;
- v4l2element->buffer = NULL;
- v4l2element->device = g_strdup("/dev/video");
- v4l2element->display = g_strdup(g_getenv("DISPLAY"));
+ /* some default values */
+ v4l2element->video_fd = -1;
+ v4l2element->buffer = NULL;
+ v4l2element->device = g_strdup ("/dev/video");
+ v4l2element->display = g_strdup (g_getenv ("DISPLAY"));
- v4l2element->channels = NULL;
- v4l2element->norms = NULL;
- v4l2element->colors = NULL;
+ v4l2element->channels = NULL;
+ v4l2element->norms = NULL;
+ v4l2element->colors = NULL;
- v4l2element->overlay = gst_v4l2_xoverlay_new(v4l2element);
+ v4l2element->overlay = gst_v4l2_xoverlay_new (v4l2element);
}
static void
-gst_v4l2element_dispose (GObject *object)
+gst_v4l2element_dispose (GObject * object)
{
- GstV4l2Element *v4l2element = GST_V4L2ELEMENT(object);
+ GstV4l2Element *v4l2element = GST_V4L2ELEMENT (object);
if (v4l2element->overlay) {
- gst_v4l2_xoverlay_free(v4l2element);
+ gst_v4l2_xoverlay_free (v4l2element);
}
if (v4l2element->display) {
v4l2element->norm = NULL;
g_free (v4l2element->channel);
v4l2element->channel = NULL;
-
+
if (((GObjectClass *) parent_class)->dispose)
- ((GObjectClass *) parent_class)->dispose(object);
+ ((GObjectClass *) parent_class)->dispose (object);
}
static void
-gst_v4l2element_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+gst_v4l2element_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec)
{
GstV4l2Element *v4l2element;
GstTuner *tuner;
-
+
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_V4L2ELEMENT (object));
v4l2element = GST_V4L2ELEMENT (object);
/* stupid GstInterface */
tuner = (GstTuner *) object;
-
+
switch (prop_id) {
case ARG_DEVICE:
- if (!GST_V4L2_IS_OPEN(v4l2element)) {
+ if (!GST_V4L2_IS_OPEN (v4l2element)) {
if (v4l2element->device)
- g_free(v4l2element->device);
- v4l2element->device = g_value_dup_string(value);
+ g_free (v4l2element->device);
+ v4l2element->device = g_value_dup_string (value);
}
break;
case ARG_NORM:
- if (GST_V4L2_IS_OPEN(v4l2element)) {
+ if (GST_V4L2_IS_OPEN (v4l2element)) {
GstTunerNorm *norm = gst_tuner_get_norm (tuner);
+
if (norm) {
gst_tuner_set_norm (tuner, norm);
}
}
break;
case ARG_CHANNEL:
- if (GST_V4L2_IS_OPEN(v4l2element)) {
+ if (GST_V4L2_IS_OPEN (v4l2element)) {
GstTunerChannel *channel = gst_tuner_get_channel (tuner);
+
if (channel) {
gst_tuner_set_channel (tuner, channel);
}
}
break;
case ARG_FREQUENCY:
- if (GST_V4L2_IS_OPEN(v4l2element)) {
+ if (GST_V4L2_IS_OPEN (v4l2element)) {
GstTunerChannel *channel;
- if (!v4l2element->channel) return;
+
+ if (!v4l2element->channel)
+ return;
channel = gst_tuner_get_channel (tuner);
g_assert (channel);
gst_tuner_set_frequency (tuner, channel, g_value_get_ulong (value));
static void
-gst_v4l2element_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+gst_v4l2element_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec)
{
- GstV4l2Element *v4l2element;
-
- /* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_V4L2ELEMENT(object));
- v4l2element = GST_V4L2ELEMENT(object);
-
- switch (prop_id) {
- case ARG_DEVICE:
- g_value_set_string(value, v4l2element->device);
- break;
- case ARG_DEVICE_NAME: {
- gchar *new = NULL;
- if (GST_V4L2_IS_OPEN(v4l2element))
- new = v4l2element->vcap.card;
- g_value_set_string(value, new);
- break;
- }
- case ARG_FLAGS: {
- guint flags = 0;
- if (GST_V4L2_IS_OPEN(v4l2element)) {
- flags |= v4l2element->vcap.capabilities &
- 30007;
- }
- g_value_set_flags(value, flags);
- break;
- }
- case ARG_NORM:
- g_value_set_string (value, v4l2element->norm);
- break;
- case ARG_CHANNEL:
- g_value_set_string (value, v4l2element->channel);
- break;
- case ARG_FREQUENCY:
- g_value_set_ulong (value, v4l2element->frequency);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
- break;
- }
+ GstV4l2Element *v4l2element;
+
+ /* it's not null if we got it, but it might not be ours */
+ g_return_if_fail (GST_IS_V4L2ELEMENT (object));
+ v4l2element = GST_V4L2ELEMENT (object);
+
+ switch (prop_id) {
+ case ARG_DEVICE:
+ g_value_set_string (value, v4l2element->device);
+ break;
+ case ARG_DEVICE_NAME:{
+ gchar *new = NULL;
+
+ if (GST_V4L2_IS_OPEN (v4l2element))
+ new = v4l2element->vcap.card;
+ g_value_set_string (value, new);
+ break;
+ }
+ case ARG_FLAGS:{
+ guint flags = 0;
+
+ if (GST_V4L2_IS_OPEN (v4l2element)) {
+ flags |= v4l2element->vcap.capabilities & 30007;
+ }
+ g_value_set_flags (value, flags);
+ break;
+ }
+ case ARG_NORM:
+ g_value_set_string (value, v4l2element->norm);
+ break;
+ case ARG_CHANNEL:
+ g_value_set_string (value, v4l2element->channel);
+ break;
+ case ARG_FREQUENCY:
+ g_value_set_ulong (value, v4l2element->frequency);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static GstElementStateReturn
-gst_v4l2element_change_state (GstElement *element)
+gst_v4l2element_change_state (GstElement * element)
{
- GstV4l2Element *v4l2element;
-
- g_return_val_if_fail(GST_IS_V4L2ELEMENT(element), GST_STATE_FAILURE);
-
- v4l2element = GST_V4L2ELEMENT(element);
-
- /* if going down into NULL state, close the device if it's open
- * if going to READY, open the device (and set some options)
- */
- switch (GST_STATE_TRANSITION(element)) {
- case GST_STATE_NULL_TO_READY:
- gst_v4l2_set_display(v4l2element);
-
- if (!gst_v4l2_open(v4l2element))
- return GST_STATE_FAILURE;
-
- gst_v4l2_xoverlay_open(v4l2element);
-
- /* emit a signal! whoopie! */
- g_signal_emit(G_OBJECT(v4l2element),
- gst_v4l2element_signals[SIGNAL_OPEN], 0,
- v4l2element->device);
- break;
- case GST_STATE_READY_TO_NULL:
- gst_v4l2_xoverlay_close(v4l2element);
-
- if (!gst_v4l2_close(v4l2element))
- return GST_STATE_FAILURE;
-
- /* emit yet another signal! wheehee! */
- g_signal_emit(G_OBJECT(v4l2element),
- gst_v4l2element_signals[SIGNAL_CLOSE], 0,
- v4l2element->device);
- break;
- }
+ GstV4l2Element *v4l2element;
+
+ g_return_val_if_fail (GST_IS_V4L2ELEMENT (element), GST_STATE_FAILURE);
+
+ v4l2element = GST_V4L2ELEMENT (element);
+
+ /* if going down into NULL state, close the device if it's open
+ * if going to READY, open the device (and set some options)
+ */
+ switch (GST_STATE_TRANSITION (element)) {
+ case GST_STATE_NULL_TO_READY:
+ gst_v4l2_set_display (v4l2element);
+
+ if (!gst_v4l2_open (v4l2element))
+ return GST_STATE_FAILURE;
+
+ gst_v4l2_xoverlay_open (v4l2element);
+
+ /* emit a signal! whoopie! */
+ g_signal_emit (G_OBJECT (v4l2element),
+ gst_v4l2element_signals[SIGNAL_OPEN], 0, v4l2element->device);
+ break;
+ case GST_STATE_READY_TO_NULL:
+ gst_v4l2_xoverlay_close (v4l2element);
+
+ if (!gst_v4l2_close (v4l2element))
+ return GST_STATE_FAILURE;
+
+ /* emit yet another signal! wheehee! */
+ g_signal_emit (G_OBJECT (v4l2element),
+ gst_v4l2element_signals[SIGNAL_CLOSE], 0, v4l2element->device);
+ break;
+ }
- if (GST_ELEMENT_CLASS(parent_class)->change_state)
- return GST_ELEMENT_CLASS(parent_class)->change_state(element);
+ if (GST_ELEMENT_CLASS (parent_class)->change_state)
+ return GST_ELEMENT_CLASS (parent_class)->change_state (element);
- return GST_STATE_SUCCESS;
+ return GST_STATE_SUCCESS;
}
(G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_V4L2ELEMENT, GstV4l2ElementClass))
-typedef struct _GstV4l2Element GstV4l2Element;
-typedef struct _GstV4l2ElementClass GstV4l2ElementClass;
+typedef struct _GstV4l2Element GstV4l2Element;
+typedef struct _GstV4l2ElementClass GstV4l2ElementClass;
-struct _GstV4l2Element {
- GstElement element;
+struct _GstV4l2Element
+{
+ GstElement element;
- /* the video device */
- char *device;
+ /* the video device */
+ char *device;
- /* the video-device's file descriptor */
- gint video_fd;
+ /* the video-device's file descriptor */
+ gint video_fd;
- /* the video buffer (mmap()'ed) */
- guint8 **buffer;
+ /* the video buffer (mmap()'ed) */
+ guint8 **buffer;
- /* the video-device's capabilities */
- struct v4l2_capability vcap;
+ /* the video-device's capabilities */
+ struct v4l2_capability vcap;
- /* the toys available to us */
- GList *channels;
- GList *norms;
- GList *colors;
+ /* the toys available to us */
+ GList *channels;
+ GList *norms;
+ GList *colors;
- /* X-overlay */
- GstXWindowListener *overlay;
- XID xwindow_id;
+ /* X-overlay */
+ GstXWindowListener *overlay;
+ XID xwindow_id;
- /* properties */
- gchar *norm;
- gchar *channel;
- gulong frequency;
+ /* properties */
+ gchar *norm;
+ gchar *channel;
+ gulong frequency;
- /* caching values */
- gchar *display;
+ /* caching values */
+ gchar *display;
};
-struct _GstV4l2ElementClass {
- GstElementClass parent_class;
+struct _GstV4l2ElementClass
+{
+ GstElementClass parent_class;
- /* probed devices */
- GList *devices;
+ /* probed devices */
+ GList *devices;
- /* signals */
- void (*open) (GstElement *element,
- const gchar *device);
- void (*close) (GstElement *element,
- const gchar *device);
+ /* signals */
+ void (*open) (GstElement * element, const gchar * device);
+ void (*close) (GstElement * element, const gchar * device);
};
/* elementfactory details */
static GstElementDetails gst_v4l2src_details = {
- "Video (video4linux2) Source",
- "Source/Video",
- "Reads frames (compressed or uncompressed) from a video4linux2 device",
- "Ronald Bultje <rbultje@ronald.bitfreak.net>"
+ "Video (video4linux2) Source",
+ "Source/Video",
+ "Reads frames (compressed or uncompressed) from a video4linux2 device",
+ "Ronald Bultje <rbultje@ronald.bitfreak.net>"
};
/* V4l2Src signals and args */
-enum {
- SIGNAL_FRAME_CAPTURE,
- SIGNAL_FRAME_DROP,
- SIGNAL_FRAME_INSERT,
- SIGNAL_FRAME_LOST,
- LAST_SIGNAL
+enum
+{
+ SIGNAL_FRAME_CAPTURE,
+ SIGNAL_FRAME_DROP,
+ SIGNAL_FRAME_INSERT,
+ SIGNAL_FRAME_LOST,
+ LAST_SIGNAL
};
/* arguments */
-enum {
- ARG_0,
- ARG_NUMBUFS,
- ARG_BUFSIZE,
- ARG_USE_FIXED_FPS
+enum
+{
+ ARG_0,
+ ARG_NUMBUFS,
+ ARG_BUFSIZE,
+ ARG_USE_FIXED_FPS
};
guint32 gst_v4l2_formats[] = {
/* from Linux 2.6.0 videodev2.h */
- V4L2_PIX_FMT_RGB332, /* 8 RGB-3-3-2 */
- V4L2_PIX_FMT_RGB555, /* 16 RGB-5-5-5 */
- V4L2_PIX_FMT_RGB565, /* 16 RGB-5-6-5 */
- V4L2_PIX_FMT_RGB555X, /* 16 RGB-5-5-5 BE */
- V4L2_PIX_FMT_RGB565X, /* 16 RGB-5-6-5 BE */
- V4L2_PIX_FMT_BGR24, /* 24 BGR-8-8-8 */
- V4L2_PIX_FMT_RGB24, /* 24 RGB-8-8-8 */
- V4L2_PIX_FMT_BGR32, /* 32 BGR-8-8-8-8 */
- V4L2_PIX_FMT_RGB32, /* 32 RGB-8-8-8-8 */
- V4L2_PIX_FMT_GREY, /* 8 Greyscale */
- V4L2_PIX_FMT_YVU410, /* 9 YVU 4:1:0 */
- V4L2_PIX_FMT_YVU420, /* 12 YVU 4:2:0 */
- V4L2_PIX_FMT_YUYV, /* 16 YUV 4:2:2 */
- V4L2_PIX_FMT_UYVY, /* 16 YUV 4:2:2 */
- V4L2_PIX_FMT_YUV422P, /* 16 YVU422 planar */
- V4L2_PIX_FMT_YUV411P, /* 16 YVU411 planar */
- V4L2_PIX_FMT_Y41P, /* 12 YUV 4:1:1 */
- V4L2_PIX_FMT_NV12, /* 12 Y/CbCr 4:2:0 */
- V4L2_PIX_FMT_NV21, /* 12 Y/CrCb 4:2:0 */
- V4L2_PIX_FMT_YUV410, /* 9 YUV 4:1:0 */
- V4L2_PIX_FMT_YUV420, /* 12 YUV 4:2:0 */
- V4L2_PIX_FMT_YYUV, /* 16 YUV 4:2:2 */
- V4L2_PIX_FMT_HI240, /* 8 8-bit color */
- V4L2_PIX_FMT_MJPEG, /* Motion-JPEG */
- V4L2_PIX_FMT_JPEG, /* JFIF JPEG */
- V4L2_PIX_FMT_DV, /* 1394 */
- V4L2_PIX_FMT_MPEG, /* MPEG */
- V4L2_PIX_FMT_WNVA /* Winnov hw compres */
+ V4L2_PIX_FMT_RGB332, /* 8 RGB-3-3-2 */
+ V4L2_PIX_FMT_RGB555, /* 16 RGB-5-5-5 */
+ V4L2_PIX_FMT_RGB565, /* 16 RGB-5-6-5 */
+ V4L2_PIX_FMT_RGB555X, /* 16 RGB-5-5-5 BE */
+ V4L2_PIX_FMT_RGB565X, /* 16 RGB-5-6-5 BE */
+ V4L2_PIX_FMT_BGR24, /* 24 BGR-8-8-8 */
+ V4L2_PIX_FMT_RGB24, /* 24 RGB-8-8-8 */
+ V4L2_PIX_FMT_BGR32, /* 32 BGR-8-8-8-8 */
+ V4L2_PIX_FMT_RGB32, /* 32 RGB-8-8-8-8 */
+ V4L2_PIX_FMT_GREY, /* 8 Greyscale */
+ V4L2_PIX_FMT_YVU410, /* 9 YVU 4:1:0 */
+ V4L2_PIX_FMT_YVU420, /* 12 YVU 4:2:0 */
+ V4L2_PIX_FMT_YUYV, /* 16 YUV 4:2:2 */
+ V4L2_PIX_FMT_UYVY, /* 16 YUV 4:2:2 */
+ V4L2_PIX_FMT_YUV422P, /* 16 YVU422 planar */
+ V4L2_PIX_FMT_YUV411P, /* 16 YVU411 planar */
+ V4L2_PIX_FMT_Y41P, /* 12 YUV 4:1:1 */
+ V4L2_PIX_FMT_NV12, /* 12 Y/CbCr 4:2:0 */
+ V4L2_PIX_FMT_NV21, /* 12 Y/CrCb 4:2:0 */
+ V4L2_PIX_FMT_YUV410, /* 9 YUV 4:1:0 */
+ V4L2_PIX_FMT_YUV420, /* 12 YUV 4:2:0 */
+ V4L2_PIX_FMT_YYUV, /* 16 YUV 4:2:2 */
+ V4L2_PIX_FMT_HI240, /* 8 8-bit color */
+ V4L2_PIX_FMT_MJPEG, /* Motion-JPEG */
+ V4L2_PIX_FMT_JPEG, /* JFIF JPEG */
+ V4L2_PIX_FMT_DV, /* 1394 */
+ V4L2_PIX_FMT_MPEG, /* MPEG */
+ V4L2_PIX_FMT_WNVA /* Winnov hw compres */
};
+
#define GST_V4L2_FORMAT_COUNT (G_N_ELEMENTS (gst_v4l2_formats))
GST_FORMATS_FUNCTION (GstPad *, gst_v4l2src_get_formats,
- GST_FORMAT_TIME, GST_FORMAT_DEFAULT);
+ GST_FORMAT_TIME, GST_FORMAT_DEFAULT);
GST_QUERY_TYPE_FUNCTION (GstPad *, gst_v4l2src_get_query_types,
- GST_QUERY_POSITION);
+ GST_QUERY_POSITION);
/* init functions */
-static void gst_v4l2src_class_init (gpointer g_class,
- gpointer class_data);
-static void gst_v4l2src_base_init (gpointer g_class);
-static void gst_v4l2src_init (GTypeInstance * instance,
- gpointer g_class);
+static void gst_v4l2src_class_init (gpointer g_class, gpointer class_data);
+static void gst_v4l2src_base_init (gpointer g_class);
+static void gst_v4l2src_init (GTypeInstance * instance, gpointer g_class);
/* signal functions */
-static void gst_v4l2src_open (GstElement *element,
- const gchar *device);
-static void gst_v4l2src_close (GstElement *element,
- const gchar *device);
+static void gst_v4l2src_open (GstElement * element, const gchar * device);
+static void gst_v4l2src_close (GstElement * element, const gchar * device);
/* pad/buffer functions */
-static const GstCaps * gst_v4l2src_get_all_caps (void);
-static GstPadLinkReturn gst_v4l2src_link (GstPad *pad,
- const GstCaps *caps);
-static GstCaps * gst_v4l2src_getcaps (GstPad *pad);
-static GstCaps * gst_v4l2src_fixate (GstPad * pad,
- const GstCaps * caps);
-static GstData * gst_v4l2src_get (GstPad *pad);
-static gboolean gst_v4l2src_src_convert (GstPad *pad,
- GstFormat src_format,
- gint64 src_value,
- GstFormat *dest_format,
- gint64 *dest_value);
-static gboolean gst_v4l2src_src_query (GstPad *pad,
- GstQueryType type,
- GstFormat *format,
- gint64 *value);
+static const GstCaps *gst_v4l2src_get_all_caps (void);
+static GstPadLinkReturn gst_v4l2src_link (GstPad * pad, const GstCaps * caps);
+static GstCaps *gst_v4l2src_getcaps (GstPad * pad);
+static GstCaps *gst_v4l2src_fixate (GstPad * pad, const GstCaps * caps);
+static GstData *gst_v4l2src_get (GstPad * pad);
+static gboolean gst_v4l2src_src_convert (GstPad * pad,
+ GstFormat src_format,
+ gint64 src_value, GstFormat * dest_format, gint64 * dest_value);
+static gboolean gst_v4l2src_src_query (GstPad * pad,
+ GstQueryType type, GstFormat * format, gint64 * value);
/* get/set params */
-static void gst_v4l2src_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gst_v4l2src_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
+static void gst_v4l2src_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+static void gst_v4l2src_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
/* state handling */
-static GstElementStateReturn
- gst_v4l2src_change_state (GstElement *element);
+static GstElementStateReturn gst_v4l2src_change_state (GstElement * element);
/* set_clock function for A/V sync */
-static void gst_v4l2src_set_clock (GstElement *element,
- GstClock *clock);
+static void gst_v4l2src_set_clock (GstElement * element, GstClock * clock);
static GstElementClass *parent_class = NULL;
static guint gst_v4l2src_signals[LAST_SIGNAL] = { 0 };
gst_v4l2src_init,
NULL
};
- v4l2src_type = g_type_register_static(GST_TYPE_V4L2ELEMENT,
+ v4l2src_type = g_type_register_static (GST_TYPE_V4L2ELEMENT,
"GstV4l2Src", &v4l2src_info, 0);
GST_DEBUG_CATEGORY_INIT (v4l2src_debug, "v4l2src", 0, "v4l2src element");
}
{
GstPadTemplate *template;
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
-
+
gst_element_class_set_details (gstelement_class, &gst_v4l2src_details);
template = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
gobject_class->set_property = gst_v4l2src_set_property;
gobject_class->get_property = gst_v4l2src_get_property;
- g_object_class_install_property(gobject_class, ARG_NUMBUFS,
- g_param_spec_int("num_buffers","num_buffers","num_buffers",
- G_MININT,G_MAXINT,0,G_PARAM_READWRITE));
- g_object_class_install_property(gobject_class, ARG_BUFSIZE,
- g_param_spec_int("buffer_size","buffer_size","buffer_size",
- G_MININT,G_MAXINT,0,G_PARAM_READABLE));
+ g_object_class_install_property (gobject_class, ARG_NUMBUFS,
+ g_param_spec_int ("num_buffers", "num_buffers", "num_buffers",
+ G_MININT, G_MAXINT, 0, G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, ARG_BUFSIZE,
+ g_param_spec_int ("buffer_size", "buffer_size", "buffer_size",
+ G_MININT, G_MAXINT, 0, G_PARAM_READABLE));
- g_object_class_install_property(gobject_class, ARG_USE_FIXED_FPS,
- g_param_spec_boolean("use_fixed_fps", "Use Fixed FPS",
- "Drop/Insert frames to reach a certain FPS (TRUE) "
- "or adapt FPS to suit the number of frabbed frames",
- TRUE, G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, ARG_USE_FIXED_FPS,
+ g_param_spec_boolean ("use_fixed_fps", "Use Fixed FPS",
+ "Drop/Insert frames to reach a certain FPS (TRUE) "
+ "or adapt FPS to suit the number of frabbed frames",
+ TRUE, G_PARAM_READWRITE));
/* signals */
gst_v4l2src_signals[SIGNAL_FRAME_CAPTURE] =
- g_signal_new("frame-capture", G_TYPE_FROM_CLASS (g_class), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GstV4l2SrcClass, frame_capture),
- NULL, NULL, g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ g_signal_new ("frame-capture", G_TYPE_FROM_CLASS (g_class),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstV4l2SrcClass, frame_capture), NULL,
+ NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
gst_v4l2src_signals[SIGNAL_FRAME_DROP] =
- g_signal_new("frame-drop", G_TYPE_FROM_CLASS (g_class), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GstV4l2SrcClass, frame_drop),
- NULL, NULL, g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ g_signal_new ("frame-drop", G_TYPE_FROM_CLASS (g_class),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstV4l2SrcClass, frame_drop), NULL,
+ NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
gst_v4l2src_signals[SIGNAL_FRAME_INSERT] =
- g_signal_new("frame_insert", G_TYPE_FROM_CLASS (g_class), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GstV4l2SrcClass, frame_insert),
- NULL, NULL, g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ g_signal_new ("frame_insert", G_TYPE_FROM_CLASS (g_class),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstV4l2SrcClass, frame_insert), NULL,
+ NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
gst_v4l2src_signals[SIGNAL_FRAME_LOST] =
- g_signal_new("frame-lost", G_TYPE_FROM_CLASS (g_class), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GstV4l2SrcClass, frame_lost),
- NULL, NULL, g_cclosure_marshal_VOID__INT,
- G_TYPE_NONE, 1, G_TYPE_INT);
+ g_signal_new ("frame-lost", G_TYPE_FROM_CLASS (g_class),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstV4l2SrcClass, frame_lost), NULL,
+ NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
gstelement_class->change_state = gst_v4l2src_change_state;
static void
-gst_v4l2src_init (GTypeInstance *instance, gpointer g_class)
+gst_v4l2src_init (GTypeInstance * instance, gpointer g_class)
{
GstV4l2Src *v4l2src = GST_V4L2SRC (instance);
-
- GST_FLAG_SET(GST_ELEMENT(v4l2src), GST_ELEMENT_THREAD_SUGGESTED);
- v4l2src->srcpad = gst_pad_new_from_template(
- gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (v4l2src), "src"), "src");
- gst_element_add_pad(GST_ELEMENT(v4l2src), v4l2src->srcpad);
+ GST_FLAG_SET (GST_ELEMENT (v4l2src), GST_ELEMENT_THREAD_SUGGESTED);
+
+ v4l2src->srcpad =
+ gst_pad_new_from_template (gst_element_class_get_pad_template
+ (GST_ELEMENT_GET_CLASS (v4l2src), "src"), "src");
+ gst_element_add_pad (GST_ELEMENT (v4l2src), v4l2src->srcpad);
- gst_pad_set_get_function(v4l2src->srcpad, gst_v4l2src_get);
- gst_pad_set_link_function(v4l2src->srcpad, gst_v4l2src_link);
+ gst_pad_set_get_function (v4l2src->srcpad, gst_v4l2src_get);
+ gst_pad_set_link_function (v4l2src->srcpad, gst_v4l2src_link);
gst_pad_set_getcaps_function (v4l2src->srcpad, gst_v4l2src_getcaps);
gst_pad_set_fixate_function (v4l2src->srcpad, gst_v4l2src_fixate);
gst_pad_set_convert_function (v4l2src->srcpad, gst_v4l2src_src_convert);
gst_pad_set_formats_function (v4l2src->srcpad, gst_v4l2src_get_formats);
gst_pad_set_query_function (v4l2src->srcpad, gst_v4l2src_src_query);
- gst_pad_set_query_type_function (v4l2src->srcpad, gst_v4l2src_get_query_types);
+ gst_pad_set_query_type_function (v4l2src->srcpad,
+ gst_v4l2src_get_query_types);
v4l2src->breq.count = 0;
static void
-gst_v4l2src_open (GstElement *element,
- const gchar *device)
+gst_v4l2src_open (GstElement * element, const gchar * device)
{
gst_v4l2src_fill_format_list (GST_V4L2SRC (element));
}
static void
-gst_v4l2src_close (GstElement *element,
- const gchar *device)
+gst_v4l2src_close (GstElement * element, const gchar * device)
{
gst_v4l2src_clear_format_list (GST_V4L2SRC (element));
}
static gfloat
-gst_v4l2src_get_fps (GstV4l2Src *v4l2src)
+gst_v4l2src_get_fps (GstV4l2Src * v4l2src)
{
- v4l2_std_id norm;
- const GList *item;
-
- if (!v4l2src->use_fixed_fps &&
- v4l2src->clock != NULL &&
- v4l2src->handled > 0) {
- /* try to get time from clock master and calculate fps */
- GstClockTime time = gst_clock_get_time(v4l2src->clock) -
- v4l2src->substract_time;
- return v4l2src->handled * GST_SECOND / time;
- }
+ v4l2_std_id norm;
+ const GList *item;
+
+ if (!v4l2src->use_fixed_fps && v4l2src->clock != NULL && v4l2src->handled > 0) {
+ /* try to get time from clock master and calculate fps */
+ GstClockTime time = gst_clock_get_time (v4l2src->clock) -
+ v4l2src->substract_time;
+ return v4l2src->handled * GST_SECOND / time;
+ }
- /* if that failed ... */
-
- if (!GST_V4L2_IS_OPEN(GST_V4L2ELEMENT(v4l2src)))
- return 0.;
-
- if (!gst_v4l2_get_norm(GST_V4L2ELEMENT(v4l2src), &norm))
- return 0.;
- for (item = GST_V4L2ELEMENT(v4l2src)->norms;
- item != NULL; item = item->next) {
- GstV4l2TunerNorm *v4l2norm = item->data;
- if (v4l2norm->index == norm)
- return GST_TUNER_NORM(v4l2norm)->fps;
- }
+ /* if that failed ... */
- return 0.;
+ if (!GST_V4L2_IS_OPEN (GST_V4L2ELEMENT (v4l2src)))
+ return 0.;
+
+ if (!gst_v4l2_get_norm (GST_V4L2ELEMENT (v4l2src), &norm))
+ return 0.;
+ for (item = GST_V4L2ELEMENT (v4l2src)->norms; item != NULL; item = item->next) {
+ GstV4l2TunerNorm *v4l2norm = item->data;
+
+ if (v4l2norm->index == norm)
+ return GST_TUNER_NORM (v4l2norm)->fps;
+ }
+
+ return 0.;
}
static gboolean
-gst_v4l2src_src_convert (GstPad *pad,
- GstFormat src_format,
- gint64 src_value,
- GstFormat *dest_format,
- gint64 *dest_value)
+gst_v4l2src_src_convert (GstPad * pad,
+ GstFormat src_format,
+ gint64 src_value, GstFormat * dest_format, gint64 * dest_value)
{
- GstV4l2Src *v4l2src;
- gdouble fps;
-
- v4l2src = GST_V4L2SRC (gst_pad_get_parent (pad));
-
- if ((fps = gst_v4l2src_get_fps(v4l2src)) == 0)
- return FALSE;
-
- switch (src_format) {
- case GST_FORMAT_TIME:
- switch (*dest_format) {
- case GST_FORMAT_DEFAULT:
- *dest_value = src_value * fps / GST_SECOND;
- break;
- default:
- return FALSE;
- }
- break;
-
- case GST_FORMAT_DEFAULT:
- switch (*dest_format) {
- case GST_FORMAT_TIME:
- *dest_value = src_value * GST_SECOND / fps;
- break;
- default:
- return FALSE;
- }
- break;
-
- default:
- return FALSE;
- }
+ GstV4l2Src *v4l2src;
+ gdouble fps;
+
+ v4l2src = GST_V4L2SRC (gst_pad_get_parent (pad));
- return TRUE;
+ if ((fps = gst_v4l2src_get_fps (v4l2src)) == 0)
+ return FALSE;
+
+ switch (src_format) {
+ case GST_FORMAT_TIME:
+ switch (*dest_format) {
+ case GST_FORMAT_DEFAULT:
+ *dest_value = src_value * fps / GST_SECOND;
+ break;
+ default:
+ return FALSE;
+ }
+ break;
+
+ case GST_FORMAT_DEFAULT:
+ switch (*dest_format) {
+ case GST_FORMAT_TIME:
+ *dest_value = src_value * GST_SECOND / fps;
+ break;
+ default:
+ return FALSE;
+ }
+ break;
+
+ default:
+ return FALSE;
+ }
+
+ return TRUE;
}
static gboolean
-gst_v4l2src_src_query (GstPad *pad,
- GstQueryType type,
- GstFormat *format,
- gint64 *value)
+gst_v4l2src_src_query (GstPad * pad,
+ GstQueryType type, GstFormat * format, gint64 * value)
{
GstV4l2Src *v4l2src = GST_V4L2SRC (gst_pad_get_parent (pad));
gboolean res = TRUE;
gdouble fps;
- if ((fps = gst_v4l2src_get_fps(v4l2src)) == 0)
+ if ((fps = gst_v4l2src_get_fps (v4l2src)) == 0)
return FALSE;
switch (type) {
case GST_QUERY_POSITION:
switch (*format) {
- case GST_FORMAT_TIME:
- *value = v4l2src->handled * GST_SECOND / fps;
- break;
- case GST_FORMAT_DEFAULT:
- *value = v4l2src->handled;
- break;
- default:
- res = FALSE;
- break;
+ case GST_FORMAT_TIME:
+ *value = v4l2src->handled * GST_SECOND / fps;
+ break;
+ case GST_FORMAT_DEFAULT:
+ *value = v4l2src->handled;
+ break;
+ default:
+ res = FALSE;
+ break;
}
break;
default:
GstStructure *structure = NULL;
switch (fourcc) {
- case V4L2_PIX_FMT_MJPEG: /* Motion-JPEG */
- case V4L2_PIX_FMT_JPEG: /* JFIF JPEG */
+ case V4L2_PIX_FMT_MJPEG: /* Motion-JPEG */
+ case V4L2_PIX_FMT_JPEG: /* JFIF JPEG */
structure = gst_structure_new ("video/x-jpeg", NULL);
break;
case V4L2_PIX_FMT_RGB332:
case V4L2_PIX_FMT_RGB24:
case V4L2_PIX_FMT_BGR24:
case V4L2_PIX_FMT_RGB32:
- case V4L2_PIX_FMT_BGR32: {
- guint depth=0, bpp=0;
+ case V4L2_PIX_FMT_BGR32:{
+ guint depth = 0, bpp = 0;
gint endianness = 0;
guint32 r_mask = 0, b_mask = 0, g_mask = 0;
switch (fourcc) {
case V4L2_PIX_FMT_RGB332:
bpp = depth = 8;
- endianness = G_BYTE_ORDER; /* 'like, whatever' */
- r_mask = 0xe0; g_mask = 0x1c; b_mask = 0x03;
+ endianness = G_BYTE_ORDER; /* 'like, whatever' */
+ r_mask = 0xe0;
+ g_mask = 0x1c;
+ b_mask = 0x03;
break;
case V4L2_PIX_FMT_RGB555:
case V4L2_PIX_FMT_RGB555X:
- bpp = 16; depth = 15;
- endianness = fourcc == V4L2_PIX_FMT_RGB555X ? G_BIG_ENDIAN : G_LITTLE_ENDIAN;
+ bpp = 16;
+ depth = 15;
+ endianness =
+ fourcc == V4L2_PIX_FMT_RGB555X ? G_BIG_ENDIAN : G_LITTLE_ENDIAN;
r_mask = 0x7c00;
g_mask = 0x03e0;
b_mask = 0x001f;
case V4L2_PIX_FMT_RGB565:
case V4L2_PIX_FMT_RGB565X:
bpp = depth = 16;
- endianness = fourcc == V4L2_PIX_FMT_RGB565X ? G_BIG_ENDIAN : G_LITTLE_ENDIAN;
+ endianness =
+ fourcc == V4L2_PIX_FMT_RGB565X ? G_BIG_ENDIAN : G_LITTLE_ENDIAN;
r_mask = 0xf800;
g_mask = 0x07e0;
b_mask = 0x001f;
b_mask = 0x00ff0000;
break;
default:
- g_assert_not_reached();
+ g_assert_not_reached ();
break;
}
structure = gst_structure_new ("video/x-raw-rgb",
- "bpp", G_TYPE_INT, bpp,
- "depth", G_TYPE_INT, depth,
- "red_mask", G_TYPE_INT, r_mask,
+ "bpp", G_TYPE_INT, bpp,
+ "depth", G_TYPE_INT, depth,
+ "red_mask", G_TYPE_INT, r_mask,
"green_mask", G_TYPE_INT, g_mask,
- "blue_mask", G_TYPE_INT, b_mask,
- "endianness", G_TYPE_INT, endianness,
- NULL);
+ "blue_mask", G_TYPE_INT, b_mask,
+ "endianness", G_TYPE_INT, endianness, NULL);
break;
}
- case V4L2_PIX_FMT_GREY: /* 8 Greyscale */
- case V4L2_PIX_FMT_YUV422P: /* 16 YVU422 planar */
- case V4L2_PIX_FMT_YUV411P: /* 16 YVU411 planar */
- case V4L2_PIX_FMT_NV12: /* 12 Y/CbCr 4:2:0 */
- case V4L2_PIX_FMT_NV21: /* 12 Y/CrCb 4:2:0 */
- case V4L2_PIX_FMT_YYUV: /* 16 YUV 4:2:2 */
- case V4L2_PIX_FMT_HI240: /* 8 8-bit color */
+ case V4L2_PIX_FMT_GREY: /* 8 Greyscale */
+ case V4L2_PIX_FMT_YUV422P: /* 16 YVU422 planar */
+ case V4L2_PIX_FMT_YUV411P: /* 16 YVU411 planar */
+ case V4L2_PIX_FMT_NV12: /* 12 Y/CbCr 4:2:0 */
+ case V4L2_PIX_FMT_NV21: /* 12 Y/CrCb 4:2:0 */
+ case V4L2_PIX_FMT_YYUV: /* 16 YUV 4:2:2 */
+ case V4L2_PIX_FMT_HI240: /* 8 8-bit color */
/* FIXME: get correct fourccs here */
break;
case V4L2_PIX_FMT_YVU410:
case V4L2_PIX_FMT_YUV410:
- case V4L2_PIX_FMT_YUV420: /* I420/IYUV */
+ case V4L2_PIX_FMT_YUV420: /* I420/IYUV */
case V4L2_PIX_FMT_YUYV:
case V4L2_PIX_FMT_YVU420:
case V4L2_PIX_FMT_UYVY:
- case V4L2_PIX_FMT_Y41P: {
+ case V4L2_PIX_FMT_Y41P:{
guint32 fcc = 0;
switch (fourcc) {
case V4L2_PIX_FMT_YVU410:
- fcc = GST_MAKE_FOURCC('Y','V','U','9');
+ fcc = GST_MAKE_FOURCC ('Y', 'V', 'U', '9');
break;
case V4L2_PIX_FMT_YUV410:
- fcc = GST_MAKE_FOURCC('Y','U','V','9');
+ fcc = GST_MAKE_FOURCC ('Y', 'U', 'V', '9');
break;
case V4L2_PIX_FMT_YUV420:
- fcc = GST_MAKE_FOURCC('I','4','2','0');
+ fcc = GST_MAKE_FOURCC ('I', '4', '2', '0');
break;
case V4L2_PIX_FMT_YUYV:
- fcc = GST_MAKE_FOURCC('Y','U','Y','2');
+ fcc = GST_MAKE_FOURCC ('Y', 'U', 'Y', '2');
break;
case V4L2_PIX_FMT_YVU420:
- fcc = GST_MAKE_FOURCC('Y','V','1','2');
+ fcc = GST_MAKE_FOURCC ('Y', 'V', '1', '2');
break;
case V4L2_PIX_FMT_UYVY:
- fcc = GST_MAKE_FOURCC('U','Y','V','Y');
+ fcc = GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y');
break;
case V4L2_PIX_FMT_Y41P:
- fcc = GST_MAKE_FOURCC('Y','4','1','B');
+ fcc = GST_MAKE_FOURCC ('Y', '4', '1', 'B');
break;
default:
- g_assert_not_reached();
+ g_assert_not_reached ();
break;
}
structure = gst_structure_new ("video/x-raw-yuv",
- "format", GST_TYPE_FOURCC, fcc,
- NULL);
+ "format", GST_TYPE_FOURCC, fcc, NULL);
break;
}
case V4L2_PIX_FMT_DV:
- structure = gst_structure_new ("video/x-dv", "systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
+ structure =
+ gst_structure_new ("video/x-dv", "systemstream", G_TYPE_BOOLEAN, TRUE,
+ NULL);
break;
- case V4L2_PIX_FMT_MPEG: /* MPEG */
+ case V4L2_PIX_FMT_MPEG: /* MPEG */
/* someone figure out the MPEG format used... */
break;
- case V4L2_PIX_FMT_WNVA: /* Winnov hw compres */
+ case V4L2_PIX_FMT_WNVA: /* Winnov hw compres */
break;
default:
GST_DEBUG ("Unknown fourcc 0x%08x " GST_FOURCC_FORMAT,
- fourcc, GST_FOURCC_ARGS(fourcc));
+ fourcc, GST_FOURCC_ARGS (fourcc));
break;
}
#if 0
- gst_caps_set_simple (caps,
- "width", G_TYPE_INT, width,
- "height", G_TYPE_INT, height,
- "framerate", G_TYPE_DOUBLE, fps,
- NULL);
+ gst_caps_set_simple (caps,
+ "width", G_TYPE_INT, width,
+ "height", G_TYPE_INT, height, "framerate", G_TYPE_DOUBLE, fps, NULL);
#endif
return structure;
}
static struct v4l2_fmtdesc *
-gst_v4l2src_get_format_from_fourcc (GstV4l2Src *v4l2src, guint32 fourcc)
-{
+gst_v4l2src_get_format_from_fourcc (GstV4l2Src * v4l2src, guint32 fourcc)
+{
struct v4l2_fmtdesc *fmt;
GSList *walk;
-
+
if (fourcc == 0)
return NULL;
-
+
walk = v4l2src->formats;
while (walk) {
fmt = (struct v4l2_fmtdesc *) walk->data;
if (fmt->pixelformat == fourcc)
return fmt;
/* special case for jpeg */
- if ((fmt->pixelformat == V4L2_PIX_FMT_MJPEG && fourcc == V4L2_PIX_FMT_JPEG) ||
- (fmt->pixelformat == V4L2_PIX_FMT_JPEG && fourcc == V4L2_PIX_FMT_MJPEG)) {
+ if ((fmt->pixelformat == V4L2_PIX_FMT_MJPEG && fourcc == V4L2_PIX_FMT_JPEG)
+ || (fmt->pixelformat == V4L2_PIX_FMT_JPEG
+ && fourcc == V4L2_PIX_FMT_MJPEG)) {
return fmt;
}
walk = g_slist_next (walk);
}
static guint32
-gst_v4l2_fourcc_from_structure (GstStructure *structure)
+gst_v4l2_fourcc_from_structure (GstStructure * structure)
{
guint32 fourcc = 0;
const gchar *mimetype = gst_structure_get_name (structure);
- if (!strcmp(mimetype, "video/x-raw-yuv") ||
- !strcmp(mimetype, "video/x-raw-rgb")) {
- if (!strcmp(mimetype, "video/x-raw-rgb"))
- fourcc = GST_MAKE_FOURCC('R','G','B',' ');
+ if (!strcmp (mimetype, "video/x-raw-yuv") ||
+ !strcmp (mimetype, "video/x-raw-rgb")) {
+ if (!strcmp (mimetype, "video/x-raw-rgb"))
+ fourcc = GST_MAKE_FOURCC ('R', 'G', 'B', ' ');
else
gst_structure_get_fourcc (structure, "format", &fourcc);
switch (fourcc) {
- case GST_MAKE_FOURCC('I','4','2','0'):
- case GST_MAKE_FOURCC('I','Y','U','V'):
+ case GST_MAKE_FOURCC ('I', '4', '2', '0'):
+ case GST_MAKE_FOURCC ('I', 'Y', 'U', 'V'):
fourcc = V4L2_PIX_FMT_YUV420;
break;
- case GST_MAKE_FOURCC('Y','U','Y','2'):
+ case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
fourcc = V4L2_PIX_FMT_YUYV;
break;
- case GST_MAKE_FOURCC('Y','4','1','P'):
+ case GST_MAKE_FOURCC ('Y', '4', '1', 'P'):
fourcc = V4L2_PIX_FMT_Y41P;
break;
- case GST_MAKE_FOURCC('U','Y','V','Y'):
+ case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
fourcc = V4L2_PIX_FMT_UYVY;
break;
- case GST_MAKE_FOURCC('Y','V','1','2'):
+ case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
fourcc = V4L2_PIX_FMT_YVU420;
break;
- case GST_MAKE_FOURCC('R','G','B',' '): {
+ case GST_MAKE_FOURCC ('R', 'G', 'B', ' '):{
gint depth, endianness, r_mask;
gst_structure_get_int (structure, "depth", &depth);
break;
case 15:
fourcc = (endianness == G_LITTLE_ENDIAN) ?
- V4L2_PIX_FMT_RGB555 :
- V4L2_PIX_FMT_RGB555X;
+ V4L2_PIX_FMT_RGB555 : V4L2_PIX_FMT_RGB555X;
break;
case 16:
fourcc = (endianness == G_LITTLE_ENDIAN) ?
- V4L2_PIX_FMT_RGB565 :
- V4L2_PIX_FMT_RGB565X;
+ V4L2_PIX_FMT_RGB565 : V4L2_PIX_FMT_RGB565X;
break;
case 24:
- fourcc = (r_mask == 0xFF) ?
- V4L2_PIX_FMT_BGR24 :
- V4L2_PIX_FMT_RGB24;
+ fourcc = (r_mask == 0xFF) ? V4L2_PIX_FMT_BGR24 : V4L2_PIX_FMT_RGB24;
break;
case 32:
- fourcc = (r_mask == 0xFF) ?
- V4L2_PIX_FMT_BGR32 :
- V4L2_PIX_FMT_RGB32;
+ fourcc = (r_mask == 0xFF) ? V4L2_PIX_FMT_BGR32 : V4L2_PIX_FMT_RGB32;
break;
}
- default:
- break;
+ default:
+ break;
}
- }
+ }
} else if (strcmp (mimetype, "video/x-dv") == 0) {
fourcc = V4L2_PIX_FMT_DV;
} else if (strcmp (mimetype, "video/x-jpeg") == 0) {
}
static struct v4l2_fmtdesc *
-gst_v4l2_caps_to_v4l2fourcc (GstV4l2Src *v4l2src, GstStructure *structure)
+gst_v4l2_caps_to_v4l2fourcc (GstV4l2Src * v4l2src, GstStructure * structure)
{
return gst_v4l2src_get_format_from_fourcc (v4l2src,
gst_v4l2_fourcc_from_structure (structure));
gst_structure_set (structure,
"width", GST_TYPE_INT_RANGE, 1, 4096,
"height", GST_TYPE_INT_RANGE, 1, 4096,
- "framerate", GST_TYPE_DOUBLE_RANGE, (double) 0, G_MAXDOUBLE,
- NULL);
+ "framerate", GST_TYPE_DOUBLE_RANGE, (double) 0, G_MAXDOUBLE, NULL);
gst_caps_append_structure (caps, structure);
}
}
static GstCaps *
-gst_v4l2src_fixate (GstPad *pad, const GstCaps *const_caps)
+gst_v4l2src_fixate (GstPad * pad, const GstCaps * const_caps)
{
gint i;
GstStructure *structure;
caps_str = gst_caps_to_string (caps);
GST_DEBUG_OBJECT (gst_pad_get_parent (pad), "fixating caps %s", caps_str);
g_free (caps_str);
-
+
for (i = 0; i < gst_caps_get_size (caps); i++) {
structure = gst_caps_get_structure (caps, i);
- changed |= gst_caps_structure_fixate_field_nearest_int (structure, "width", G_MAXINT);
+ changed |=
+ gst_caps_structure_fixate_field_nearest_int (structure, "width",
+ G_MAXINT);
}
- if (changed) return caps;
+ if (changed)
+ return caps;
for (i = 0; i < gst_caps_get_size (caps); i++) {
structure = gst_caps_get_structure (caps, i);
- changed |= gst_caps_structure_fixate_field_nearest_int (structure, "height", G_MAXINT);
+ changed |=
+ gst_caps_structure_fixate_field_nearest_int (structure, "height",
+ G_MAXINT);
}
- if (changed) return caps;
+ if (changed)
+ return caps;
gst_caps_free (caps);
return NULL;
}
static GstPadLinkReturn
-gst_v4l2src_link (GstPad *pad, const GstCaps *caps)
+gst_v4l2src_link (GstPad * pad, const GstCaps * caps)
{
GstV4l2Src *v4l2src;
GstV4l2Element *v4l2element;
int w, h;
GstStructure *structure;
- v4l2src = GST_V4L2SRC(gst_pad_get_parent (pad));
- v4l2element = GST_V4L2ELEMENT(v4l2src);
+ v4l2src = GST_V4L2SRC (gst_pad_get_parent (pad));
+ v4l2element = GST_V4L2ELEMENT (v4l2src);
structure = gst_caps_get_structure (caps, 0);
/* clean up if we still haven't cleaned up our previous
* capture session */
- if (GST_V4L2_IS_ACTIVE(v4l2element)) {
- if (!gst_v4l2src_capture_deinit(v4l2src))
- return GST_PAD_LINK_REFUSED;
- } else if (!GST_V4L2_IS_OPEN(v4l2element)) {
- return GST_PAD_LINK_DELAYED;
+ if (GST_V4L2_IS_ACTIVE (v4l2element)) {
+ if (!gst_v4l2src_capture_deinit (v4l2src))
+ return GST_PAD_LINK_REFUSED;
+ } else if (!GST_V4L2_IS_OPEN (v4l2element)) {
+ return GST_PAD_LINK_DELAYED;
}
/* we want our own v4l2 type of fourcc codes */
- if (!(format = gst_v4l2_caps_to_v4l2fourcc(v4l2src, structure))) {
- return GST_PAD_LINK_REFUSED;
+ if (!(format = gst_v4l2_caps_to_v4l2fourcc (v4l2src, structure))) {
+ return GST_PAD_LINK_REFUSED;
}
gst_structure_get_int (structure, "width", &w);
gst_structure_get_int (structure, "height", &h);
/* we found the pixelformat! - try it out */
- if (gst_v4l2src_set_capture(v4l2src, format, w, h)) {
- if (gst_v4l2src_capture_init(v4l2src)) {
- return GST_PAD_LINK_OK;
- }
+ if (gst_v4l2src_set_capture (v4l2src, format, w, h)) {
+ if (gst_v4l2src_capture_init (v4l2src)) {
+ return GST_PAD_LINK_OK;
+ }
}
return GST_PAD_LINK_REFUSED;
static GstCaps *
-gst_v4l2src_getcaps (GstPad *pad)
+gst_v4l2src_getcaps (GstPad * pad)
{
- GstV4l2Src *v4l2src = GST_V4L2SRC(gst_pad_get_parent (pad));
+ GstV4l2Src *v4l2src = GST_V4L2SRC (gst_pad_get_parent (pad));
GstCaps *caps;
struct v4l2_fmtdesc *format;
int min_w, max_w, min_h, max_h;
GSList *walk;
GstStructure *structure;
- if (!GST_V4L2_IS_OPEN(GST_V4L2ELEMENT(v4l2src))) {
- return gst_caps_new_any ();
+ if (!GST_V4L2_IS_OPEN (GST_V4L2ELEMENT (v4l2src))) {
+ return gst_caps_new_any ();
}
/* build our own capslist */
- caps = gst_caps_new_empty();
+ caps = gst_caps_new_empty ();
walk = v4l2src->formats;
while (walk) {
format = (struct v4l2_fmtdesc *) walk->data;
walk = g_slist_next (walk);
/* get size delimiters */
- if (!gst_v4l2src_get_size_limits(v4l2src, format,
- &min_w, &max_w, &min_h, &max_h)) {
+ if (!gst_v4l2src_get_size_limits (v4l2src, format,
+ &min_w, &max_w, &min_h, &max_h)) {
continue;
}
gst_structure_set (structure,
"width", GST_TYPE_INT_RANGE, min_w, max_w,
"height", GST_TYPE_INT_RANGE, min_h, max_h,
- "framerate", GST_TYPE_DOUBLE_RANGE, (double) 0, G_MAXDOUBLE,
- NULL);
+ "framerate", GST_TYPE_DOUBLE_RANGE, (double) 0, G_MAXDOUBLE, NULL);
gst_caps_append_structure (caps, structure);
}
return caps;
}
-static GstData*
-gst_v4l2src_get (GstPad *pad)
+static GstData *
+gst_v4l2src_get (GstPad * pad)
{
GstV4l2Src *v4l2src;
GstBuffer *buf;
v4l2src = GST_V4L2SRC (gst_pad_get_parent (pad));
- if (v4l2src->use_fixed_fps &&
- (fps = gst_v4l2src_get_fps(v4l2src)) == 0) {
- GST_ELEMENT_ERROR (v4l2src, RESOURCE, SETTINGS, (NULL), ("could not get frame rate for element"));
+ if (v4l2src->use_fixed_fps && (fps = gst_v4l2src_get_fps (v4l2src)) == 0) {
+ GST_ELEMENT_ERROR (v4l2src, RESOURCE, SETTINGS, (NULL),
+ ("could not get frame rate for element"));
return NULL;
}
v4l2src->need_writes--;
} else {
GstClockTime time;
+
/* grab a frame from the device */
- num = gst_v4l2src_grab_frame(v4l2src);
+ num = gst_v4l2src_grab_frame (v4l2src);
if (num == -1)
return NULL;
/* to check if v4l2 sets the correct time */
- time = GST_TIMEVAL_TO_TIME(v4l2src->pool->buffers[num].buffer.timestamp);
+ time = GST_TIMEVAL_TO_TIME (v4l2src->pool->buffers[num].buffer.timestamp);
if (v4l2src->clock && v4l2src->use_fixed_fps && time != 0) {
gboolean have_frame = FALSE;
/* first check whether we lost any frames according to the device */
if (v4l2src->last_seq != 0) {
- if (v4l2src->pool->buffers[num].buffer.sequence - v4l2src->last_seq > 1) {
- v4l2src->need_writes = v4l2src->pool->buffers[num].buffer.sequence - v4l2src->last_seq;
- g_signal_emit(G_OBJECT(v4l2src), gst_v4l2src_signals[SIGNAL_FRAME_LOST], 0,
+ if (v4l2src->pool->buffers[num].buffer.sequence - v4l2src->last_seq >
+ 1) {
+ v4l2src->need_writes =
+ v4l2src->pool->buffers[num].buffer.sequence - v4l2src->last_seq;
+ g_signal_emit (G_OBJECT (v4l2src),
+ gst_v4l2src_signals[SIGNAL_FRAME_LOST], 0,
v4l2src->need_writes - 1);
}
}
* timeframe. This means that if time - begin_time = X sec,
* we want to have written X*fps frames. If we've written
* more - drop, if we've written less - dup... */
- if (v4l2src->handled * (GST_SECOND/fps) - time > 1.5 * (GST_SECOND/fps)) {
+ if (v4l2src->handled * (GST_SECOND / fps) - time >
+ 1.5 * (GST_SECOND / fps)) {
/* yo dude, we've got too many frames here! Drop! DROP! */
- v4l2src->need_writes--; /* -= (v4l2src->handled - (time / fps)); */
- g_signal_emit(G_OBJECT(v4l2src), gst_v4l2src_signals[SIGNAL_FRAME_DROP], 0);
- } else if (v4l2src->handled * (GST_SECOND/fps) - time < -1.5 * (GST_SECOND/fps)) {
+ v4l2src->need_writes--; /* -= (v4l2src->handled - (time / fps)); */
+ g_signal_emit (G_OBJECT (v4l2src),
+ gst_v4l2src_signals[SIGNAL_FRAME_DROP], 0);
+ } else if (v4l2src->handled * (GST_SECOND / fps) - time <
+ -1.5 * (GST_SECOND / fps)) {
/* this means we're lagging far behind */
- v4l2src->need_writes++; /* += ((time / fps) - v4l2src->handled); */
- g_signal_emit(G_OBJECT(v4l2src), gst_v4l2src_signals[SIGNAL_FRAME_INSERT], 0);
+ v4l2src->need_writes++; /* += ((time / fps) - v4l2src->handled); */
+ g_signal_emit (G_OBJECT (v4l2src),
+ gst_v4l2src_signals[SIGNAL_FRAME_INSERT], 0);
}
if (v4l2src->need_writes > 0) {
have_frame = TRUE;
v4l2src->need_writes--;
} else {
- if (!gst_v4l2src_queue_frame(v4l2src, num))
+ if (!gst_v4l2src_queue_frame (v4l2src, num))
return NULL;
- num = gst_v4l2src_grab_frame(v4l2src);
+ num = gst_v4l2src_grab_frame (v4l2src);
if (num == -1)
return NULL;
}
}
g_assert (num != -1);
- GST_LOG_OBJECT (v4l2src, "buffer %d needs %d writes", num, v4l2src->need_writes + 1);
- i = v4l2src->pool->buffers[num].buffer.bytesused > 0 ?
- v4l2src->pool->buffers[num].buffer.bytesused :
- v4l2src->pool->buffers[num].length;
+ GST_LOG_OBJECT (v4l2src, "buffer %d needs %d writes", num,
+ v4l2src->need_writes + 1);
+ i = v4l2src->pool->buffers[num].buffer.bytesused >
+ 0 ? v4l2src->pool->buffers[num].buffer.bytesused : v4l2src->pool->
+ buffers[num].length;
/* check if this is the last buffer in the queue. If so do a memcpy to put it back asap
to avoid framedrops and deadlocks because of stupid elements */
if (gst_atomic_int_read (&v4l2src->pool->refcount) == v4l2src->breq.count) {
GST_LOG_OBJECT (v4l2src, "using memcpy'd buffer");
buf = gst_buffer_new_and_alloc (i);
memcpy (GST_BUFFER_DATA (buf), v4l2src->pool->buffers[num].start, i);
- if (!gst_v4l2src_queue_frame(v4l2src, num)) {
+ if (!gst_v4l2src_queue_frame (v4l2src, num)) {
gst_data_unref (GST_DATA (buf));
return NULL;
}
GST_BUFFER_DURATION (buf) = GST_SECOND / fps;
} else {
/* calculate time based on our own clock */
- GST_BUFFER_TIMESTAMP(buf) = GST_TIMEVAL_TO_TIME(v4l2src->pool->buffers[num].buffer.timestamp) -
+ GST_BUFFER_TIMESTAMP (buf) =
+ GST_TIMEVAL_TO_TIME (v4l2src->pool->buffers[num].buffer.timestamp) -
v4l2src->substract_time;
}
if (v4l2src->need_writes > 0) {
}
v4l2src->handled++;
- g_signal_emit(G_OBJECT(v4l2src), gst_v4l2src_signals[SIGNAL_FRAME_CAPTURE], 0);
+ g_signal_emit (G_OBJECT (v4l2src), gst_v4l2src_signals[SIGNAL_FRAME_CAPTURE],
+ 0);
return GST_DATA (buf);
}
static void
-gst_v4l2src_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+gst_v4l2src_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec)
{
- GstV4l2Src *v4l2src;
-
- g_return_if_fail(GST_IS_V4L2SRC(object));
- v4l2src = GST_V4L2SRC(object);
-
- switch (prop_id) {
- case ARG_NUMBUFS:
- if (!GST_V4L2_IS_ACTIVE(GST_V4L2ELEMENT(v4l2src))) {
- v4l2src->breq.count = g_value_get_int(value);
- }
- break;
-
- case ARG_USE_FIXED_FPS:
- if (!GST_V4L2_IS_ACTIVE(GST_V4L2ELEMENT(v4l2src))) {
- v4l2src->use_fixed_fps = g_value_get_boolean(value);
- }
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ GstV4l2Src *v4l2src;
+
+ g_return_if_fail (GST_IS_V4L2SRC (object));
+ v4l2src = GST_V4L2SRC (object);
+
+ switch (prop_id) {
+ case ARG_NUMBUFS:
+ if (!GST_V4L2_IS_ACTIVE (GST_V4L2ELEMENT (v4l2src))) {
+ v4l2src->breq.count = g_value_get_int (value);
+ }
+ break;
+
+ case ARG_USE_FIXED_FPS:
+ if (!GST_V4L2_IS_ACTIVE (GST_V4L2ELEMENT (v4l2src))) {
+ v4l2src->use_fixed_fps = g_value_get_boolean (value);
+ }
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
-gst_v4l2src_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+gst_v4l2src_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec)
{
- GstV4l2Src *v4l2src;
+ GstV4l2Src *v4l2src;
- g_return_if_fail(GST_IS_V4L2SRC(object));
- v4l2src = GST_V4L2SRC(object);
+ g_return_if_fail (GST_IS_V4L2SRC (object));
+ v4l2src = GST_V4L2SRC (object);
- switch (prop_id) {
- case ARG_NUMBUFS:
- g_value_set_int(value, v4l2src->breq.count);
- break;
+ switch (prop_id) {
+ case ARG_NUMBUFS:
+ g_value_set_int (value, v4l2src->breq.count);
+ break;
- case ARG_BUFSIZE:
- g_value_set_int(value, v4l2src->format.fmt.pix.sizeimage);
- break;
+ case ARG_BUFSIZE:
+ g_value_set_int (value, v4l2src->format.fmt.pix.sizeimage);
+ break;
- case ARG_USE_FIXED_FPS:
- g_value_set_boolean(value, v4l2src->use_fixed_fps);
- break;
+ case ARG_USE_FIXED_FPS:
+ g_value_set_boolean (value, v4l2src->use_fixed_fps);
+ break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static GstElementStateReturn
-gst_v4l2src_change_state (GstElement *element)
+gst_v4l2src_change_state (GstElement * element)
{
- GstV4l2Src *v4l2src;
- gint transition = GST_STATE_TRANSITION (element);
- GstElementStateReturn parent_return;
- GTimeVal time;
-
- g_return_val_if_fail(GST_IS_V4L2SRC(element), GST_STATE_FAILURE);
- v4l2src = GST_V4L2SRC(element);
-
- if (GST_ELEMENT_CLASS (parent_class)->change_state) {
- parent_return = GST_ELEMENT_CLASS (parent_class)->change_state (element);
- if (parent_return != GST_STATE_SUCCESS)
- return parent_return;
- }
+ GstV4l2Src *v4l2src;
+ gint transition = GST_STATE_TRANSITION (element);
+ GstElementStateReturn parent_return;
+ GTimeVal time;
- switch (transition) {
- case GST_STATE_NULL_TO_READY:
- if (!gst_v4l2src_get_capture(v4l2src))
- return GST_STATE_FAILURE;
- break;
- case GST_STATE_READY_TO_PAUSED:
- v4l2src->handled = 0;
- v4l2src->need_writes = 0;
- v4l2src->substract_time = 0;
- /* buffer setup moved to capsnego */
- break;
- case GST_STATE_PAUSED_TO_PLAYING:
- /* queue all buffer, start streaming capture */
- if (!gst_v4l2src_capture_start(v4l2src))
- return GST_STATE_FAILURE;
- g_get_current_time(&time);
- v4l2src->substract_time = GST_TIMEVAL_TO_TIME(time) -
- v4l2src->substract_time;
- v4l2src->last_seq = 0;
- break;
- case GST_STATE_PLAYING_TO_PAUSED:
- g_get_current_time(&time);
- v4l2src->substract_time = GST_TIMEVAL_TO_TIME(time) -
- v4l2src->substract_time;
- /* de-queue all queued buffers */
- if (!gst_v4l2src_capture_stop(v4l2src))
- return GST_STATE_FAILURE;
- break;
- case GST_STATE_PAUSED_TO_READY:
- /* stop capturing, unmap all buffers */
- if (!gst_v4l2src_capture_deinit(v4l2src))
- return GST_STATE_FAILURE;
- break;
- case GST_STATE_READY_TO_NULL:
- break;
- }
+ g_return_val_if_fail (GST_IS_V4L2SRC (element), GST_STATE_FAILURE);
+ v4l2src = GST_V4L2SRC (element);
+
+ if (GST_ELEMENT_CLASS (parent_class)->change_state) {
+ parent_return = GST_ELEMENT_CLASS (parent_class)->change_state (element);
+ if (parent_return != GST_STATE_SUCCESS)
+ return parent_return;
+ }
- return GST_STATE_SUCCESS;
+ switch (transition) {
+ case GST_STATE_NULL_TO_READY:
+ if (!gst_v4l2src_get_capture (v4l2src))
+ return GST_STATE_FAILURE;
+ break;
+ case GST_STATE_READY_TO_PAUSED:
+ v4l2src->handled = 0;
+ v4l2src->need_writes = 0;
+ v4l2src->substract_time = 0;
+ /* buffer setup moved to capsnego */
+ break;
+ case GST_STATE_PAUSED_TO_PLAYING:
+ /* queue all buffer, start streaming capture */
+ if (!gst_v4l2src_capture_start (v4l2src))
+ return GST_STATE_FAILURE;
+ g_get_current_time (&time);
+ v4l2src->substract_time = GST_TIMEVAL_TO_TIME (time) -
+ v4l2src->substract_time;
+ v4l2src->last_seq = 0;
+ break;
+ case GST_STATE_PLAYING_TO_PAUSED:
+ g_get_current_time (&time);
+ v4l2src->substract_time = GST_TIMEVAL_TO_TIME (time) -
+ v4l2src->substract_time;
+ /* de-queue all queued buffers */
+ if (!gst_v4l2src_capture_stop (v4l2src))
+ return GST_STATE_FAILURE;
+ break;
+ case GST_STATE_PAUSED_TO_READY:
+ /* stop capturing, unmap all buffers */
+ if (!gst_v4l2src_capture_deinit (v4l2src))
+ return GST_STATE_FAILURE;
+ break;
+ case GST_STATE_READY_TO_NULL:
+ break;
+ }
+
+ return GST_STATE_SUCCESS;
}
static void
-gst_v4l2src_set_clock (GstElement *element,
- GstClock *clock)
+gst_v4l2src_set_clock (GstElement * element, GstClock * clock)
{
- GST_V4L2SRC(element)->clock = clock;
+ GST_V4L2SRC (element)->clock = clock;
}
-
#define GST_IS_V4L2SRC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_V4L2SRC))
-typedef struct _GstV4l2BufferPool GstV4l2BufferPool;
-typedef struct _GstV4l2Buffer GstV4l2Buffer;
-typedef struct _GstV4l2Src GstV4l2Src;
-typedef struct _GstV4l2SrcClass GstV4l2SrcClass;
+typedef struct _GstV4l2BufferPool GstV4l2BufferPool;
+typedef struct _GstV4l2Buffer GstV4l2Buffer;
+typedef struct _GstV4l2Src GstV4l2Src;
+typedef struct _GstV4l2SrcClass GstV4l2SrcClass;
/* global info */
-struct _GstV4l2BufferPool {
- GstAtomicInt refcount; /* number of users: 1 for every buffer, 1 for element */
- gint video_fd;
- guint buffer_count;
- GstV4l2Buffer * buffers;
+struct _GstV4l2BufferPool
+{
+ GstAtomicInt refcount; /* number of users: 1 for every buffer, 1 for element */
+ gint video_fd;
+ guint buffer_count;
+ GstV4l2Buffer *buffers;
};
-struct _GstV4l2Buffer {
- struct v4l2_buffer buffer;
- guint8 * start;
- guint length;
- GstAtomicInt refcount; /* add 1 if in use by element, add 1 if in use by GstBuffer */
- GstV4l2BufferPool * pool;
+struct _GstV4l2Buffer
+{
+ struct v4l2_buffer buffer;
+ guint8 *start;
+ guint length;
+ GstAtomicInt refcount; /* add 1 if in use by element, add 1 if in use by GstBuffer */
+ GstV4l2BufferPool *pool;
};
-struct _GstV4l2Src {
- GstV4l2Element v4l2element;
+struct _GstV4l2Src
+{
+ GstV4l2Element v4l2element;
- /* pads */
- GstPad *srcpad;
+ /* pads */
+ GstPad *srcpad;
- /* internal lists */
- GSList *formats; /* list of available capture formats */
+ /* internal lists */
+ GSList *formats; /* list of available capture formats */
- /* buffers */
- GstV4l2BufferPool *pool;
+ /* buffers */
+ GstV4l2BufferPool *pool;
- struct v4l2_requestbuffers breq;
- struct v4l2_format format;
+ struct v4l2_requestbuffers breq;
+ struct v4l2_format format;
- /* True if we want to stop */
- gboolean quit;
+ /* True if we want to stop */
+ gboolean quit;
- /* A/V sync... frame counter and internal cache */
- gulong handled;
- gint need_writes;
- GstBuffer *cached_buffer;
- gulong last_seq;
+ /* A/V sync... frame counter and internal cache */
+ gulong handled;
+ gint need_writes;
+ GstBuffer *cached_buffer;
+ gulong last_seq;
- /* clock */
- GstClock *clock;
-
- /* time to substract from clock time to get back to timestamp */
- GstClockTime substract_time;
+ /* clock */
+ GstClock *clock;
- /* how are we going to push buffers? */
- gboolean use_fixed_fps;
+ /* time to substract from clock time to get back to timestamp */
+ GstClockTime substract_time;
+
+ /* how are we going to push buffers? */
+ gboolean use_fixed_fps;
};
-struct _GstV4l2SrcClass {
- GstV4l2ElementClass parent_class;
+struct _GstV4l2SrcClass
+{
+ GstV4l2ElementClass parent_class;
- void (*frame_capture) (GObject *object);
- void (*frame_drop) (GObject *object);
- void (*frame_insert) (GObject *object);
- void (*frame_lost) (GObject *object,
- gint num_lost);
+ void (*frame_capture) (GObject * object);
+ void (*frame_drop) (GObject * object);
+ void (*frame_insert) (GObject * object);
+ void (*frame_lost) (GObject * object, gint num_lost);
};
-GType gst_v4l2src_get_type(void);
+GType gst_v4l2src_get_type (void);
#endif /* __GST_V4L2SRC_H__ */
#include "gstv4l2element.h"
#include "v4l2_calls.h"
-static void gst_v4l2_tuner_channel_class_init (GstV4l2TunerChannelClass *klass);
-static void gst_v4l2_tuner_channel_init (GstV4l2TunerChannel *channel);
+static void gst_v4l2_tuner_channel_class_init (GstV4l2TunerChannelClass *
+ klass);
+static void gst_v4l2_tuner_channel_init (GstV4l2TunerChannel * channel);
-static void gst_v4l2_tuner_norm_class_init (GstV4l2TunerNormClass *klass);
-static void gst_v4l2_tuner_norm_init (GstV4l2TunerNorm *norm);
+static void gst_v4l2_tuner_norm_class_init (GstV4l2TunerNormClass * klass);
+static void gst_v4l2_tuner_norm_init (GstV4l2TunerNorm * norm);
-static const GList *
- gst_v4l2_tuner_list_channels (GstTuner *mixer);
-static void gst_v4l2_tuner_set_channel (GstTuner *mixer,
- GstTunerChannel *channel);
-static GstTunerChannel *
- gst_v4l2_tuner_get_channel (GstTuner *mixer);
+static const GList *gst_v4l2_tuner_list_channels (GstTuner * mixer);
+static void gst_v4l2_tuner_set_channel (GstTuner * mixer,
+ GstTunerChannel * channel);
+static GstTunerChannel *gst_v4l2_tuner_get_channel (GstTuner * mixer);
-static const GList *
- gst_v4l2_tuner_list_norms (GstTuner *mixer);
-static void gst_v4l2_tuner_set_norm (GstTuner *mixer,
- GstTunerNorm *norm);
-static GstTunerNorm *
- gst_v4l2_tuner_get_norm (GstTuner *mixer);
+static const GList *gst_v4l2_tuner_list_norms (GstTuner * mixer);
+static void gst_v4l2_tuner_set_norm (GstTuner * mixer, GstTunerNorm * norm);
+static GstTunerNorm *gst_v4l2_tuner_get_norm (GstTuner * mixer);
-static void gst_v4l2_tuner_set_frequency (GstTuner *mixer,
- GstTunerChannel *channel,
- gulong frequency);
-static gulong gst_v4l2_tuner_get_frequency (GstTuner *mixer,
- GstTunerChannel *channel);
-static gint gst_v4l2_tuner_signal_strength (GstTuner *mixer,
- GstTunerChannel *channel);
+static void gst_v4l2_tuner_set_frequency (GstTuner * mixer,
+ GstTunerChannel * channel, gulong frequency);
+static gulong gst_v4l2_tuner_get_frequency (GstTuner * mixer,
+ GstTunerChannel * channel);
+static gint gst_v4l2_tuner_signal_strength (GstTuner * mixer,
+ GstTunerChannel * channel);
static GstTunerNormClass *norm_parent_class = NULL;
static GstTunerChannelClass *channel_parent_class = NULL;
gst_v4l2_tuner_channel_type =
g_type_register_static (GST_TYPE_TUNER_CHANNEL,
- "GstV4l2TunerChannel",
- &v4l2_tuner_channel_info, 0);
+ "GstV4l2TunerChannel", &v4l2_tuner_channel_info, 0);
}
return gst_v4l2_tuner_channel_type;
}
static void
-gst_v4l2_tuner_channel_class_init (GstV4l2TunerChannelClass *klass)
+gst_v4l2_tuner_channel_class_init (GstV4l2TunerChannelClass * klass)
{
channel_parent_class = g_type_class_ref (GST_TYPE_TUNER_CHANNEL);
}
static void
-gst_v4l2_tuner_channel_init (GstV4l2TunerChannel *channel)
+gst_v4l2_tuner_channel_init (GstV4l2TunerChannel * channel)
{
channel->index = 0;
channel->tuner = 0;
gst_v4l2_tuner_norm_type =
g_type_register_static (GST_TYPE_TUNER_NORM,
- "GstV4l2TunerNorm",
- &v4l2_tuner_norm_info, 0);
+ "GstV4l2TunerNorm", &v4l2_tuner_norm_info, 0);
}
return gst_v4l2_tuner_norm_type;
}
static void
-gst_v4l2_tuner_norm_class_init (GstV4l2TunerNormClass *klass)
+gst_v4l2_tuner_norm_class_init (GstV4l2TunerNormClass * klass)
{
norm_parent_class = g_type_class_ref (GST_TYPE_TUNER_NORM);
}
static void
-gst_v4l2_tuner_norm_init (GstV4l2TunerNorm *norm)
+gst_v4l2_tuner_norm_init (GstV4l2TunerNorm * norm)
{
norm->index = 0;
}
void
-gst_v4l2_tuner_interface_init (GstTunerClass *klass)
+gst_v4l2_tuner_interface_init (GstTunerClass * klass)
{
/* default virtual functions */
klass->list_channels = gst_v4l2_tuner_list_channels;
}
static gboolean
-gst_v4l2_tuner_is_sink (GstV4l2Element *v4l2element)
+gst_v4l2_tuner_is_sink (GstV4l2Element * v4l2element)
{
const GList *pads = gst_element_get_pad_list (GST_ELEMENT (v4l2element));
GstPadDirection dir = GST_PAD_UNKNOWN;
}
static gboolean
-gst_v4l2_tuner_contains_channel (GstV4l2Element *v4l2element,
- GstV4l2TunerChannel *v4l2channel)
+gst_v4l2_tuner_contains_channel (GstV4l2Element * v4l2element,
+ GstV4l2TunerChannel * v4l2channel)
{
const GList *item;
}
static const GList *
-gst_v4l2_tuner_list_channels (GstTuner *mixer)
+gst_v4l2_tuner_list_channels (GstTuner * mixer)
{
/* ... or output, if we're a sink... */
return GST_V4L2ELEMENT (mixer)->channels;
}
static void
-gst_v4l2_tuner_set_channel (GstTuner *mixer,
- GstTunerChannel *channel)
+gst_v4l2_tuner_set_channel (GstTuner * mixer, GstTunerChannel * channel)
{
GstV4l2Element *v4l2element = GST_V4L2ELEMENT (mixer);
GstV4l2TunerChannel *v4l2channel = GST_V4L2_TUNER_CHANNEL (channel);
g_return_if_fail (gst_v4l2_tuner_contains_channel (v4l2element, v4l2channel));
/* ... or output, if we're a sink... */
- if (gst_v4l2_tuner_is_sink (v4l2element) ?
+ if (gst_v4l2_tuner_is_sink (v4l2element) ?
gst_v4l2_set_output (v4l2element, v4l2channel->index) :
gst_v4l2_set_input (v4l2element, v4l2channel->index)) {
gst_tuner_channel_changed (mixer, channel);
}
static GstTunerChannel *
-gst_v4l2_tuner_get_channel (GstTuner *mixer)
+gst_v4l2_tuner_get_channel (GstTuner * mixer)
{
GstV4l2Element *v4l2element = GST_V4L2ELEMENT (mixer);
GList *item;
}
static gboolean
-gst_v4l2_tuner_contains_norm (GstV4l2Element *v4l2element,
- GstV4l2TunerNorm *v4l2norm)
+gst_v4l2_tuner_contains_norm (GstV4l2Element * v4l2element,
+ GstV4l2TunerNorm * v4l2norm)
{
const GList *item;
}
static const GList *
-gst_v4l2_tuner_list_norms (GstTuner *mixer)
+gst_v4l2_tuner_list_norms (GstTuner * mixer)
{
return GST_V4L2ELEMENT (mixer)->norms;
}
static void
-gst_v4l2_tuner_set_norm (GstTuner *mixer,
- GstTunerNorm *norm)
+gst_v4l2_tuner_set_norm (GstTuner * mixer, GstTunerNorm * norm)
{
GstV4l2Element *v4l2element = GST_V4L2ELEMENT (mixer);
GstV4l2TunerNorm *v4l2norm = GST_V4L2_TUNER_NORM (norm);
if (gst_v4l2_set_norm (v4l2element, v4l2norm->index)) {
gst_tuner_norm_changed (mixer, norm);
- g_object_notify (G_OBJECT (v4l2element), "norm");
+ g_object_notify (G_OBJECT (v4l2element), "norm");
}
}
static GstTunerNorm *
-gst_v4l2_tuner_get_norm (GstTuner *mixer)
+gst_v4l2_tuner_get_norm (GstTuner * mixer)
{
GstV4l2Element *v4l2element = GST_V4L2ELEMENT (mixer);
GList *item;
}
static void
-gst_v4l2_tuner_set_frequency (GstTuner *mixer,
- GstTunerChannel *channel,
- gulong frequency)
+gst_v4l2_tuner_set_frequency (GstTuner * mixer,
+ GstTunerChannel * channel, gulong frequency)
{
GstV4l2Element *v4l2element = GST_V4L2ELEMENT (mixer);
GstV4l2TunerChannel *v4l2channel = GST_V4L2_TUNER_CHANNEL (channel);
/* assert that we're opened and that we're using a known item */
g_return_if_fail (GST_V4L2_IS_OPEN (v4l2element));
g_return_if_fail (GST_TUNER_CHANNEL_HAS_FLAG (channel,
- GST_TUNER_CHANNEL_FREQUENCY));
+ GST_TUNER_CHANNEL_FREQUENCY));
g_return_if_fail (gst_v4l2_tuner_contains_channel (v4l2element, v4l2channel));
gst_v4l2_get_input (v4l2element, &chan);
GST_TUNER_CHANNEL_HAS_FLAG (channel, GST_TUNER_CHANNEL_FREQUENCY)) {
if (gst_v4l2_set_frequency (v4l2element, v4l2channel->tuner, frequency)) {
gst_tuner_frequency_changed (mixer, channel, frequency);
- g_object_notify (G_OBJECT (v4l2element), "frequency");
+ g_object_notify (G_OBJECT (v4l2element), "frequency");
}
}
}
static gulong
-gst_v4l2_tuner_get_frequency (GstTuner *mixer,
- GstTunerChannel *channel)
+gst_v4l2_tuner_get_frequency (GstTuner * mixer, GstTunerChannel * channel)
{
GstV4l2Element *v4l2element = GST_V4L2ELEMENT (mixer);
GstV4l2TunerChannel *v4l2channel = GST_V4L2_TUNER_CHANNEL (channel);
/* assert that we're opened and that we're using a known item */
g_return_val_if_fail (GST_V4L2_IS_OPEN (v4l2element), 0);
g_return_val_if_fail (GST_TUNER_CHANNEL_HAS_FLAG (channel,
- GST_TUNER_CHANNEL_FREQUENCY), 0);
+ GST_TUNER_CHANNEL_FREQUENCY), 0);
g_return_val_if_fail (gst_v4l2_tuner_contains_channel (v4l2element,
- v4l2channel), 0);
+ v4l2channel), 0);
gst_v4l2_get_input (v4l2element, &chan);
if (chan == GST_V4L2_TUNER_CHANNEL (channel)->index &&
}
static gint
-gst_v4l2_tuner_signal_strength (GstTuner *mixer,
- GstTunerChannel *channel)
+gst_v4l2_tuner_signal_strength (GstTuner * mixer, GstTunerChannel * channel)
{
GstV4l2Element *v4l2element = GST_V4L2ELEMENT (mixer);
GstV4l2TunerChannel *v4l2channel = GST_V4L2_TUNER_CHANNEL (channel);
/* assert that we're opened and that we're using a known item */
g_return_val_if_fail (GST_V4L2_IS_OPEN (v4l2element), 0);
g_return_val_if_fail (GST_TUNER_CHANNEL_HAS_FLAG (channel,
- GST_TUNER_CHANNEL_FREQUENCY), 0);
+ GST_TUNER_CHANNEL_FREQUENCY), 0);
g_return_val_if_fail (gst_v4l2_tuner_contains_channel (v4l2element,
- v4l2channel), 0);
+ v4l2channel), 0);
gst_v4l2_get_input (v4l2element, &chan);
if (chan == GST_V4L2_TUNER_CHANNEL (channel)->index &&
#include "gstv4l2element.h"
G_BEGIN_DECLS
-
#define GST_TYPE_V4L2_TUNER_CHANNEL \
(gst_v4l2_tuner_channel_get_type ())
#define GST_V4L2_TUNER_CHANNEL(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_V4L2_TUNER_CHANNEL))
#define GST_IS_V4L2_TUNER_CHANNEL_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_V4L2_TUNER_CHANNEL))
-
-typedef struct _GstV4l2TunerChannel {
+ typedef struct _GstV4l2TunerChannel
+{
GstTunerChannel parent;
- guint32 index;
- guint32 tuner;
- guint32 audio;
+ guint32 index;
+ guint32 tuner;
+ guint32 audio;
} GstV4l2TunerChannel;
-typedef struct _GstV4l2TunerChannelClass {
+typedef struct _GstV4l2TunerChannelClass
+{
GstTunerChannelClass parent;
} GstV4l2TunerChannelClass;
#define GST_IS_V4L2_TUNER_NORM_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_V4L2_TUNER_NORM))
-typedef struct _GstV4l2TunerNorm {
+typedef struct _GstV4l2TunerNorm
+{
GstTunerNorm parent;
- v4l2_std_id index;
+ v4l2_std_id index;
} GstV4l2TunerNorm;
-typedef struct _GstV4l2TunerNormClass {
+typedef struct _GstV4l2TunerNormClass
+{
GstTunerNormClass parent;
} GstV4l2TunerNormClass;
-GType gst_v4l2_tuner_channel_get_type (void);
-GType gst_v4l2_tuner_norm_get_type (void);
+GType gst_v4l2_tuner_channel_get_type (void);
+GType gst_v4l2_tuner_norm_get_type (void);
-void gst_v4l2_tuner_interface_init (GstTunerClass *klass);
+void gst_v4l2_tuner_interface_init (GstTunerClass * klass);
#endif /* __GST_V4L2_TUNER_H__ */
#include "gstv4l2element.h"
#include "v4l2_calls.h"
-static void gst_v4l2_xoverlay_set_xwindow_id (GstXOverlay *overlay,
- XID xwindow_id);
+static void gst_v4l2_xoverlay_set_xwindow_id (GstXOverlay * overlay,
+ XID xwindow_id);
void
-gst_v4l2_xoverlay_interface_init (GstXOverlayClass *klass)
+gst_v4l2_xoverlay_interface_init (GstXOverlayClass * klass)
{
/* default virtual functions */
klass->set_xwindow_id = gst_v4l2_xoverlay_set_xwindow_id;
}
GstXWindowListener *
-gst_v4l2_xoverlay_new (GstV4l2Element *v4l2element)
+gst_v4l2_xoverlay_new (GstV4l2Element * v4l2element)
{
- GstXWindowListener *xwin =
- gst_x_window_listener_new (NULL,
- (MapWindowFunc) gst_v4l2_enable_overlay,
- (SetWindowFunc) gst_v4l2_set_window,
- (gpointer) v4l2element);
+ GstXWindowListener *xwin = gst_x_window_listener_new (NULL,
+ (MapWindowFunc) gst_v4l2_enable_overlay,
+ (SetWindowFunc) gst_v4l2_set_window,
+ (gpointer) v4l2element);
v4l2element->overlay = xwin;
v4l2element->xwindow_id = 0;
}
void
-gst_v4l2_xoverlay_free (GstV4l2Element *v4l2element)
+gst_v4l2_xoverlay_free (GstV4l2Element * v4l2element)
{
gst_v4l2_xoverlay_close (v4l2element);
g_object_unref (G_OBJECT (v4l2element->overlay));
}
void
-gst_v4l2_xoverlay_open (GstV4l2Element *v4l2element)
+gst_v4l2_xoverlay_open (GstV4l2Element * v4l2element)
{
GstXWindowListener *xwin = v4l2element->overlay;
xwin->display_name = g_strdup (v4l2element->display);
if (v4l2element->xwindow_id != 0 &&
- xwin->display_name &&
- xwin->display_name[0] == ':') {
+ xwin->display_name && xwin->display_name[0] == ':') {
gst_x_window_listener_set_xid (xwin, v4l2element->xwindow_id);
}
}
}
void
-gst_v4l2_xoverlay_close (GstV4l2Element *v4l2element)
+gst_v4l2_xoverlay_close (GstV4l2Element * v4l2element)
{
GstXWindowListener *xwin = v4l2element->overlay;
if (xwin != NULL) {
if (v4l2element->xwindow_id != 0 &&
- xwin->display_name &&
- xwin->display_name[0] == ':') {
+ xwin->display_name && xwin->display_name[0] == ':') {
gst_x_window_listener_set_xid (xwin, 0);
}
}
static void
-gst_v4l2_xoverlay_set_xwindow_id (GstXOverlay *overlay,
- XID xwindow_id)
+gst_v4l2_xoverlay_set_xwindow_id (GstXOverlay * overlay, XID xwindow_id)
{
GstV4l2Element *v4l2element = GST_V4L2ELEMENT (overlay);
GstXWindowListener *xwin = v4l2element->overlay;
if (gst_element_get_state (GST_ELEMENT (v4l2element)) != GST_STATE_NULL &&
v4l2element->xwindow_id != 0 &&
- xwin != NULL &&
- xwin->display_name &&
- xwin->display_name[0] == ':') {
+ xwin != NULL && xwin->display_name && xwin->display_name[0] == ':') {
gst_x_window_listener_set_xid (xwin, 0);
}
if (gst_element_get_state (GST_ELEMENT (v4l2element)) != GST_STATE_NULL &&
v4l2element->xwindow_id != 0 &&
- xwin != NULL &&
- xwin->display_name &&
- xwin->display_name[0] == ':') {
+ xwin != NULL && xwin->display_name && xwin->display_name[0] == ':') {
gst_x_window_listener_set_xid (xwin, v4l2element->xwindow_id);
}
}
#include "gstv4l2element.h"
-G_BEGIN_DECLS
+G_BEGIN_DECLS void gst_v4l2_xoverlay_interface_init (GstXOverlayClass * klass);
-void gst_v4l2_xoverlay_interface_init (GstXOverlayClass *klass);
-
-GstXWindowListener *
- gst_v4l2_xoverlay_new (GstV4l2Element *v4l2element);
-void gst_v4l2_xoverlay_free (GstV4l2Element *v4l2element);
+GstXWindowListener *gst_v4l2_xoverlay_new (GstV4l2Element * v4l2element);
+void gst_v4l2_xoverlay_free (GstV4l2Element * v4l2element);
/* signal handlers */
-void gst_v4l2_xoverlay_open (GstV4l2Element *v4l2element);
-void gst_v4l2_xoverlay_close (GstV4l2Element *v4l2element);
+void gst_v4l2_xoverlay_open (GstV4l2Element * v4l2element);
+void gst_v4l2_xoverlay_close (GstV4l2Element * v4l2element);
#endif /* __GST_V4L2_X_OVERLAY_H__ */
******************************************************/
gboolean
-gst_v4l2_set_display (GstV4l2Element *v4l2element)
+gst_v4l2_set_display (GstV4l2Element * v4l2element)
{
- gchar *buff;
-
- if (v4l2element->display)
- g_free(v4l2element->display);
- v4l2element->display = g_strdup(g_getenv("DISPLAY"));
-
- DEBUG("trying to set overlay to '%s'", v4l2element->display);
-
- /* start v4l-conf */
- buff = g_strdup_printf("v4l-conf -q -c %s -d %s",
- v4l2element->device, v4l2element->display);
-
- switch (system(buff)) {
- case -1:
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, FAILED,
- (_("Could not start v4l-conf.")),
- GST_ERROR_SYSTEM);
- g_free(buff);
- return FALSE;
- case 0:
- break;
- default:
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, FAILED,
- (_("Executing v4l-conf failed.")),
- GST_ERROR_SYSTEM);
- g_free(buff);
- return FALSE;
- }
-
- g_free(buff);
- return TRUE;
+ gchar *buff;
+
+ if (v4l2element->display)
+ g_free (v4l2element->display);
+ v4l2element->display = g_strdup (g_getenv ("DISPLAY"));
+
+ DEBUG ("trying to set overlay to '%s'", v4l2element->display);
+
+ /* start v4l-conf */
+ buff = g_strdup_printf ("v4l-conf -q -c %s -d %s",
+ v4l2element->device, v4l2element->display);
+
+ switch (system (buff)) {
+ case -1:
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, FAILED,
+ (_("Could not start v4l-conf.")), GST_ERROR_SYSTEM);
+ g_free (buff);
+ return FALSE;
+ case 0:
+ break;
+ default:
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, FAILED,
+ (_("Executing v4l-conf failed.")), GST_ERROR_SYSTEM);
+ g_free (buff);
+ return FALSE;
+ }
+
+ g_free (buff);
+ return TRUE;
}
******************************************************/
gboolean
-gst_v4l2_set_window (GstElement *element,
- gint x,
- gint y,
- gint w,
- gint h,
- struct v4l2_clip *clips,
- gint num_clips)
+gst_v4l2_set_window (GstElement * element,
+ gint x, gint y, gint w, gint h, struct v4l2_clip * clips, gint num_clips)
{
- struct v4l2_format fmt;
- GstV4l2Element *v4l2element = GST_V4L2ELEMENT(element);
-
- DEBUG("trying to set video window to %dx%d,%d,%d", x,y,w,h);
- GST_V4L2_CHECK_OVERLAY(v4l2element);
- GST_V4L2_CHECK_OPEN(v4l2element);
-
- fmt.type = V4L2_CAP_VIDEO_OVERLAY;
- fmt.fmt.win.clipcount = 0;
- fmt.fmt.win.w.left = x;
- fmt.fmt.win.w.top = y;
- fmt.fmt.win.w.width = w;
- fmt.fmt.win.w.height = h;
- fmt.fmt.win.clips = clips;
- fmt.fmt.win.clipcount = num_clips;
- fmt.fmt.win.bitmap = NULL;
-
- if (ioctl(v4l2element->video_fd, VIDIOC_S_FMT, &fmt) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, TOO_LAZY, (NULL),
- ("Failed to set the video window: %s", g_strerror (errno)));
- return FALSE;
- }
-
- return TRUE;
+ struct v4l2_format fmt;
+ GstV4l2Element *v4l2element = GST_V4L2ELEMENT (element);
+
+ DEBUG ("trying to set video window to %dx%d,%d,%d", x, y, w, h);
+ GST_V4L2_CHECK_OVERLAY (v4l2element);
+ GST_V4L2_CHECK_OPEN (v4l2element);
+
+ fmt.type = V4L2_CAP_VIDEO_OVERLAY;
+ fmt.fmt.win.clipcount = 0;
+ fmt.fmt.win.w.left = x;
+ fmt.fmt.win.w.top = y;
+ fmt.fmt.win.w.width = w;
+ fmt.fmt.win.w.height = h;
+ fmt.fmt.win.clips = clips;
+ fmt.fmt.win.clipcount = num_clips;
+ fmt.fmt.win.bitmap = NULL;
+
+ if (ioctl (v4l2element->video_fd, VIDIOC_S_FMT, &fmt) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, TOO_LAZY, (NULL),
+ ("Failed to set the video window: %s", g_strerror (errno)));
+ return FALSE;
+ }
+
+ return TRUE;
}
******************************************************/
gboolean
-gst_v4l2_enable_overlay (GstV4l2Element *v4l2element,
- gboolean enable)
+gst_v4l2_enable_overlay (GstV4l2Element * v4l2element, gboolean enable)
{
- gint doit = enable?1:0;
+ gint doit = enable ? 1 : 0;
- DEBUG("trying to %s overlay display", enable?"enable":"disable");
- GST_V4L2_CHECK_OPEN(v4l2element);
- GST_V4L2_CHECK_OVERLAY(v4l2element);
+ DEBUG ("trying to %s overlay display", enable ? "enable" : "disable");
+ GST_V4L2_CHECK_OPEN (v4l2element);
+ GST_V4L2_CHECK_OVERLAY (v4l2element);
- if (ioctl(v4l2element->video_fd, VIDIOC_OVERLAY, &doit) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, TOO_LAZY, (NULL),
- ("Failed to %s overlay display: %s",
- enable?"enable":"disable", g_strerror (errno)));
- return FALSE;
- }
+ if (ioctl (v4l2element->video_fd, VIDIOC_OVERLAY, &doit) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, TOO_LAZY, (NULL),
+ ("Failed to %s overlay display: %s",
+ enable ? "enable" : "disable", g_strerror (errno)));
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
******************************************************/
static gboolean
-gst_v4l2_get_capabilities (GstV4l2Element *v4l2element)
+gst_v4l2_get_capabilities (GstV4l2Element * v4l2element)
{
- DEBUG("getting capabilities");
- GST_V4L2_CHECK_OPEN(v4l2element);
-
- if (ioctl(v4l2element->video_fd, VIDIOC_QUERYCAP, &(v4l2element->vcap)) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Error getting %s capabilities: %s",
- v4l2element->device, g_strerror(errno)));
- return FALSE;
- }
+ DEBUG ("getting capabilities");
+ GST_V4L2_CHECK_OPEN (v4l2element);
+
+ if (ioctl (v4l2element->video_fd, VIDIOC_QUERYCAP, &(v4l2element->vcap)) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Error getting %s capabilities: %s",
+ v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
******************************************************/
static gboolean
-gst_v4l2_fill_lists (GstV4l2Element *v4l2element)
+gst_v4l2_fill_lists (GstV4l2Element * v4l2element)
{
- gint n;
- const GList *pads =
- gst_element_get_pad_list (GST_ELEMENT (v4l2element));
- GstPadDirection dir = GST_PAD_UNKNOWN;
-
- DEBUG("getting enumerations");
- GST_V4L2_CHECK_OPEN(v4l2element);
-
- /* sinks have outputs, all others have inputs */
- if (pads && g_list_length ((GList *) pads) == 1)
- dir = GST_PAD_DIRECTION (GST_PAD (pads->data));
-
- if (dir != GST_PAD_SINK) {
- /* and now, the inputs */
- for (n=0;;n++) {
- struct v4l2_input input;
- GstV4l2TunerChannel *v4l2channel;
- GstTunerChannel *channel;
-
- input.index = n;
- if (ioctl(v4l2element->video_fd, VIDIOC_ENUMINPUT,
- &input) < 0) {
- if (errno == EINVAL)
- break; /* end of enumeration */
- else {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to get %d in input enumeration for %s: %s",
- n, v4l2element->device,
- g_strerror (errno)));
- return FALSE;
- }
- }
-
- v4l2channel =
- g_object_new(GST_TYPE_V4L2_TUNER_CHANNEL, NULL);
- channel = GST_TUNER_CHANNEL(v4l2channel);
- channel->label = g_strdup(input.name);
- channel->flags = GST_TUNER_CHANNEL_INPUT;
- v4l2channel->index = n;
- if (input.type == V4L2_INPUT_TYPE_TUNER) {
- struct v4l2_tuner vtun;
-
- v4l2channel->tuner = input.tuner;
- channel->flags |= GST_TUNER_CHANNEL_FREQUENCY;
-
- vtun.index = input.tuner;
- if (ioctl(v4l2element->video_fd, VIDIOC_G_TUNER,
- &vtun) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to get tuner %d settings on %s: %s",
- input.tuner,
- v4l2element->device,
- g_strerror (errno)));
- g_object_unref(G_OBJECT(channel));
- return FALSE;
- }
- channel->min_frequency = vtun.rangelow;
- channel->max_frequency = vtun.rangehigh;
- channel->min_signal = 0;
- channel->max_signal = 0xffff;
- }
- if (input.audioset) {
- /* we take the first. We don't care for
- * the others for now */
- while (!(input.audioset &
- (1<<v4l2channel->audio)))
- v4l2channel->audio++;
- channel->flags |= GST_TUNER_CHANNEL_AUDIO;
- }
-
- v4l2element->channels =
- g_list_append(v4l2element->channels,
- (gpointer) channel);
- }
- } else {
- /* outputs */
- for (n=0;;n++) {
- struct v4l2_output output;
- GstV4l2TunerChannel *v4l2channel;
- GstTunerChannel *channel;
-
- output.index = n;
- if (ioctl(v4l2element->video_fd, VIDIOC_ENUMOUTPUT,
- &output) < 0) {
- if (errno == EINVAL)
- break; /* end of enumeration */
- else {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to get %d in output enumeration for %s: %s",
- n, v4l2element->device,
- g_strerror (errno)));
- return FALSE;
- }
- }
-
- v4l2channel = g_object_new(GST_TYPE_V4L2_TUNER_CHANNEL, NULL);
- channel = GST_TUNER_CHANNEL(v4l2channel);
- channel->label = g_strdup(output.name);
- channel->flags = GST_TUNER_CHANNEL_OUTPUT;
- v4l2channel->index = n;
- if (output.audioset) {
- /* we take the first. We don't care for
- * the others for now */
- while (!(output.audioset &
- (1<<v4l2channel->audio)))
- v4l2channel->audio++;
- channel->flags |= GST_TUNER_CHANNEL_AUDIO;
- }
-
- v4l2element->channels =
- g_list_append(v4l2element->channels,
- (gpointer) channel);
- }
+ gint n;
+ const GList *pads = gst_element_get_pad_list (GST_ELEMENT (v4l2element));
+ GstPadDirection dir = GST_PAD_UNKNOWN;
+
+ DEBUG ("getting enumerations");
+ GST_V4L2_CHECK_OPEN (v4l2element);
+
+ /* sinks have outputs, all others have inputs */
+ if (pads && g_list_length ((GList *) pads) == 1)
+ dir = GST_PAD_DIRECTION (GST_PAD (pads->data));
+
+ if (dir != GST_PAD_SINK) {
+ /* and now, the inputs */
+ for (n = 0;; n++) {
+ struct v4l2_input input;
+ GstV4l2TunerChannel *v4l2channel;
+ GstTunerChannel *channel;
+
+ input.index = n;
+ if (ioctl (v4l2element->video_fd, VIDIOC_ENUMINPUT, &input) < 0) {
+ if (errno == EINVAL)
+ break; /* end of enumeration */
+ else {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to get %d in input enumeration for %s: %s",
+ n, v4l2element->device, g_strerror (errno)));
+ return FALSE;
}
-
- /* norms... */
- for (n=0;;n++) {
- struct v4l2_standard standard;
- GstV4l2TunerNorm *v4l2norm;
- GstTunerNorm *norm;
-
- standard.index = n;
- if (ioctl(v4l2element->video_fd, VIDIOC_ENUMSTD, &standard) < 0) {
- if (errno == EINVAL)
- break; /* end of enumeration */
- else {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to get %d in norm enumeration for %s: %s",
- n, v4l2element->device,
- g_strerror (errno)));
- return FALSE;
- }
- }
-
- v4l2norm = g_object_new(GST_TYPE_V4L2_TUNER_NORM, NULL);
- norm = GST_TUNER_NORM (v4l2norm);
- norm->label = g_strdup(standard.name);
- norm->fps = (gfloat) standard.frameperiod.denominator /
- standard.frameperiod.numerator;
- v4l2norm->index = standard.id;
-
- v4l2element->norms = g_list_append(v4l2element->norms,
- (gpointer) norm);
+ }
+
+ v4l2channel = g_object_new (GST_TYPE_V4L2_TUNER_CHANNEL, NULL);
+ channel = GST_TUNER_CHANNEL (v4l2channel);
+ channel->label = g_strdup (input.name);
+ channel->flags = GST_TUNER_CHANNEL_INPUT;
+ v4l2channel->index = n;
+ if (input.type == V4L2_INPUT_TYPE_TUNER) {
+ struct v4l2_tuner vtun;
+
+ v4l2channel->tuner = input.tuner;
+ channel->flags |= GST_TUNER_CHANNEL_FREQUENCY;
+
+ vtun.index = input.tuner;
+ if (ioctl (v4l2element->video_fd, VIDIOC_G_TUNER, &vtun) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to get tuner %d settings on %s: %s",
+ input.tuner, v4l2element->device, g_strerror (errno)));
+ g_object_unref (G_OBJECT (channel));
+ return FALSE;
+ }
+ channel->min_frequency = vtun.rangelow;
+ channel->max_frequency = vtun.rangehigh;
+ channel->min_signal = 0;
+ channel->max_signal = 0xffff;
+ }
+ if (input.audioset) {
+ /* we take the first. We don't care for
+ * the others for now */
+ while (!(input.audioset & (1 << v4l2channel->audio)))
+ v4l2channel->audio++;
+ channel->flags |= GST_TUNER_CHANNEL_AUDIO;
+ }
+
+ v4l2element->channels =
+ g_list_append (v4l2element->channels, (gpointer) channel);
+ }
+ } else {
+ /* outputs */
+ for (n = 0;; n++) {
+ struct v4l2_output output;
+ GstV4l2TunerChannel *v4l2channel;
+ GstTunerChannel *channel;
+
+ output.index = n;
+ if (ioctl (v4l2element->video_fd, VIDIOC_ENUMOUTPUT, &output) < 0) {
+ if (errno == EINVAL)
+ break; /* end of enumeration */
+ else {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to get %d in output enumeration for %s: %s",
+ n, v4l2element->device, g_strerror (errno)));
+ return FALSE;
}
+ }
+
+ v4l2channel = g_object_new (GST_TYPE_V4L2_TUNER_CHANNEL, NULL);
+ channel = GST_TUNER_CHANNEL (v4l2channel);
+ channel->label = g_strdup (output.name);
+ channel->flags = GST_TUNER_CHANNEL_OUTPUT;
+ v4l2channel->index = n;
+ if (output.audioset) {
+ /* we take the first. We don't care for
+ * the others for now */
+ while (!(output.audioset & (1 << v4l2channel->audio)))
+ v4l2channel->audio++;
+ channel->flags |= GST_TUNER_CHANNEL_AUDIO;
+ }
+
+ v4l2element->channels =
+ g_list_append (v4l2element->channels, (gpointer) channel);
+ }
+ }
- /* and lastly, controls+menus (if appropriate) */
- for (n=V4L2_CID_BASE;;n++) {
- struct v4l2_queryctrl control;
- GstV4l2ColorBalanceChannel *v4l2channel;
- GstColorBalanceChannel *channel;
-
- /* hacky... */
- if (n == V4L2_CID_LASTP1)
- n = V4L2_CID_PRIVATE_BASE;
-
- control.id = n;
- if (ioctl(v4l2element->video_fd, VIDIOC_QUERYCTRL, &control) < 0) {
- if (errno == EINVAL) {
- if (n < V4L2_CID_PRIVATE_BASE)
- continue;
- else
- break;
- } else {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to get %d in control enumeration for %s: %s",
- n, v4l2element->device,
- g_strerror (errno)));
- return FALSE;
- }
- }
- if (control.flags & V4L2_CTRL_FLAG_DISABLED)
- continue;
-
- switch (n) {
- case V4L2_CID_BRIGHTNESS:
- case V4L2_CID_CONTRAST:
- case V4L2_CID_SATURATION:
- case V4L2_CID_HUE:
- case V4L2_CID_BLACK_LEVEL:
- case V4L2_CID_AUTO_WHITE_BALANCE:
- case V4L2_CID_DO_WHITE_BALANCE:
- case V4L2_CID_RED_BALANCE:
- case V4L2_CID_BLUE_BALANCE:
- case V4L2_CID_GAMMA:
- case V4L2_CID_EXPOSURE:
- case V4L2_CID_AUTOGAIN:
- case V4L2_CID_GAIN:
- /* we only handle these for now */
- break;
- default:
- DEBUG("ControlID %s (%d) unhandled, FIXME",
- control.name, n);
- control.id++;
- break;
- }
- if (n != control.id)
- continue;
-
- v4l2channel = g_object_new(GST_TYPE_V4L2_COLOR_BALANCE_CHANNEL,
- NULL);
- channel = GST_COLOR_BALANCE_CHANNEL(v4l2channel);
- channel->label = g_strdup(control.name);
- v4l2channel->index = n;
+ /* norms... */
+ for (n = 0;; n++) {
+ struct v4l2_standard standard;
+ GstV4l2TunerNorm *v4l2norm;
+ GstTunerNorm *norm;
+
+ standard.index = n;
+ if (ioctl (v4l2element->video_fd, VIDIOC_ENUMSTD, &standard) < 0) {
+ if (errno == EINVAL)
+ break; /* end of enumeration */
+ else {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to get %d in norm enumeration for %s: %s",
+ n, v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
+ }
+
+ v4l2norm = g_object_new (GST_TYPE_V4L2_TUNER_NORM, NULL);
+ norm = GST_TUNER_NORM (v4l2norm);
+ norm->label = g_strdup (standard.name);
+ norm->fps = (gfloat) standard.frameperiod.denominator /
+ standard.frameperiod.numerator;
+ v4l2norm->index = standard.id;
+
+ v4l2element->norms = g_list_append (v4l2element->norms, (gpointer) norm);
+ }
+
+ /* and lastly, controls+menus (if appropriate) */
+ for (n = V4L2_CID_BASE;; n++) {
+ struct v4l2_queryctrl control;
+ GstV4l2ColorBalanceChannel *v4l2channel;
+ GstColorBalanceChannel *channel;
+
+ /* hacky... */
+ if (n == V4L2_CID_LASTP1)
+ n = V4L2_CID_PRIVATE_BASE;
+
+ control.id = n;
+ if (ioctl (v4l2element->video_fd, VIDIOC_QUERYCTRL, &control) < 0) {
+ if (errno == EINVAL) {
+ if (n < V4L2_CID_PRIVATE_BASE)
+ continue;
+ else
+ break;
+ } else {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to get %d in control enumeration for %s: %s",
+ n, v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
+ }
+ if (control.flags & V4L2_CTRL_FLAG_DISABLED)
+ continue;
+
+ switch (n) {
+ case V4L2_CID_BRIGHTNESS:
+ case V4L2_CID_CONTRAST:
+ case V4L2_CID_SATURATION:
+ case V4L2_CID_HUE:
+ case V4L2_CID_BLACK_LEVEL:
+ case V4L2_CID_AUTO_WHITE_BALANCE:
+ case V4L2_CID_DO_WHITE_BALANCE:
+ case V4L2_CID_RED_BALANCE:
+ case V4L2_CID_BLUE_BALANCE:
+ case V4L2_CID_GAMMA:
+ case V4L2_CID_EXPOSURE:
+ case V4L2_CID_AUTOGAIN:
+ case V4L2_CID_GAIN:
+ /* we only handle these for now */
+ break;
+ default:
+ DEBUG ("ControlID %s (%d) unhandled, FIXME", control.name, n);
+ control.id++;
+ break;
+ }
+ if (n != control.id)
+ continue;
+
+ v4l2channel = g_object_new (GST_TYPE_V4L2_COLOR_BALANCE_CHANNEL, NULL);
+ channel = GST_COLOR_BALANCE_CHANNEL (v4l2channel);
+ channel->label = g_strdup (control.name);
+ v4l2channel->index = n;
#if 0
- if (control.type == V4L2_CTRL_TYPE_MENU) {
- struct v4l2_querymenu menu, *mptr;
- int i;
- menu.id = n;
- for (i=0;;i++) {
- menu.index = i;
- if (ioctl(v4l2element->video_fd, VIDIOC_QUERYMENU, &menu) < 0) {
- if (errno == EINVAL)
- break; /* end of enumeration */
- else {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to get %d in menu enumeration for %s: %s",
- n, v4l2element->device,
- g_strerror (errno)));
- return FALSE;
- }
- }
- mptr = g_malloc(sizeof(menu));
- memcpy(mptr, &menu, sizeof(menu));
- menus = g_list_append(menus, mptr);
- }
- }
- v4l2element->menus = g_list_append(v4l2element->menus, menus);
+ if (control.type == V4L2_CTRL_TYPE_MENU) {
+ struct v4l2_querymenu menu, *mptr;
+ int i;
+
+ menu.id = n;
+ for (i = 0;; i++) {
+ menu.index = i;
+ if (ioctl (v4l2element->video_fd, VIDIOC_QUERYMENU, &menu) < 0) {
+ if (errno == EINVAL)
+ break; /* end of enumeration */
+ else {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to get %d in menu enumeration for %s: %s",
+ n, v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
+ }
+ mptr = g_malloc (sizeof (menu));
+ memcpy (mptr, &menu, sizeof (menu));
+ menus = g_list_append (menus, mptr);
+ }
+ }
+ v4l2element->menus = g_list_append (v4l2element->menus, menus);
#endif
- switch (control.type) {
- case V4L2_CTRL_TYPE_INTEGER:
- channel->min_value = control.minimum;
- channel->max_value = control.maximum;
- break;
- case V4L2_CTRL_TYPE_BOOLEAN:
- channel->min_value = FALSE;
- channel->max_value = TRUE;
- break;
- default:
- channel->min_value =
- channel->max_value = 0;
- break;
- }
-
- v4l2element->colors = g_list_append(v4l2element->colors,
- (gpointer) channel);
- }
+ switch (control.type) {
+ case V4L2_CTRL_TYPE_INTEGER:
+ channel->min_value = control.minimum;
+ channel->max_value = control.maximum;
+ break;
+ case V4L2_CTRL_TYPE_BOOLEAN:
+ channel->min_value = FALSE;
+ channel->max_value = TRUE;
+ break;
+ default:
+ channel->min_value = channel->max_value = 0;
+ break;
+ }
- return TRUE;
+ v4l2element->colors = g_list_append (v4l2element->colors,
+ (gpointer) channel);
+ }
+
+ return TRUE;
}
static void
-gst_v4l2_empty_lists (GstV4l2Element *v4l2element)
+gst_v4l2_empty_lists (GstV4l2Element * v4l2element)
{
- DEBUG("deleting enumerations");
+ DEBUG ("deleting enumerations");
- g_list_foreach (v4l2element->channels, (GFunc) g_object_unref, NULL);
- g_list_free (v4l2element->channels);
- v4l2element->channels = NULL;
+ g_list_foreach (v4l2element->channels, (GFunc) g_object_unref, NULL);
+ g_list_free (v4l2element->channels);
+ v4l2element->channels = NULL;
- g_list_foreach (v4l2element->norms, (GFunc) g_object_unref, NULL);
- g_list_free (v4l2element->norms);
- v4l2element->norms = NULL;
+ g_list_foreach (v4l2element->norms, (GFunc) g_object_unref, NULL);
+ g_list_free (v4l2element->norms);
+ v4l2element->norms = NULL;
- g_list_foreach (v4l2element->colors, (GFunc) g_object_unref, NULL);
- g_list_free (v4l2element->colors);
- v4l2element->colors = NULL;
+ g_list_foreach (v4l2element->colors, (GFunc) g_object_unref, NULL);
+ g_list_free (v4l2element->colors);
+ v4l2element->colors = NULL;
}
/* FIXME: move this stuff to gstv4l2tuner.c? */
static void
-gst_v4l2_set_defaults (GstV4l2Element *v4l2element)
+gst_v4l2_set_defaults (GstV4l2Element * v4l2element)
{
GstTunerNorm *norm = NULL;
GstTunerChannel *channel = NULL;
GstTuner *tuner = GST_TUNER (v4l2element);
-
+
if (v4l2element->norm)
norm = gst_tuner_find_norm_by_name (tuner, v4l2element->norm);
if (norm) {
norm = GST_TUNER_NORM (gst_tuner_get_norm (GST_TUNER (v4l2element)));
v4l2element->norm = g_strdup (norm->label);
gst_tuner_norm_changed (tuner, norm);
- g_object_notify (G_OBJECT (v4l2element), "norm");
+ g_object_notify (G_OBJECT (v4l2element), "norm");
}
-
- if (v4l2element->channel)
+
+ if (v4l2element->channel)
channel = gst_tuner_find_channel_by_name (tuner, v4l2element->channel);
if (channel) {
gst_tuner_set_channel (tuner, channel);
} else {
- channel = GST_TUNER_CHANNEL (gst_tuner_get_channel (GST_TUNER (v4l2element)));
+ channel =
+ GST_TUNER_CHANNEL (gst_tuner_get_channel (GST_TUNER (v4l2element)));
v4l2element->channel = g_strdup (channel->label);
gst_tuner_channel_changed (tuner, channel);
- g_object_notify (G_OBJECT (v4l2element), "channel");
+ g_object_notify (G_OBJECT (v4l2element), "channel");
}
if (v4l2element->frequency != 0) {
gst_tuner_set_frequency (tuner, channel, v4l2element->frequency);
******************************************************/
gboolean
-gst_v4l2_open (GstV4l2Element *v4l2element)
+gst_v4l2_open (GstV4l2Element * v4l2element)
{
- DEBUG("Trying to open device %s", v4l2element->device);
- GST_V4L2_CHECK_NOT_OPEN(v4l2element);
- GST_V4L2_CHECK_NOT_ACTIVE(v4l2element);
-
- /* be sure we have a device */
- if (!v4l2element->device)
- v4l2element->device = g_strdup("/dev/video");
-
- /* open the device */
- v4l2element->video_fd = open(v4l2element->device, O_RDWR);
- if (!GST_V4L2_IS_OPEN(v4l2element)) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, OPEN_READ_WRITE,
- (_("Could not open device \"%s\" for reading and writing."), v4l2element->device),
- GST_ERROR_SYSTEM);
- goto error;
- }
+ DEBUG ("Trying to open device %s", v4l2element->device);
+ GST_V4L2_CHECK_NOT_OPEN (v4l2element);
+ GST_V4L2_CHECK_NOT_ACTIVE (v4l2element);
+
+ /* be sure we have a device */
+ if (!v4l2element->device)
+ v4l2element->device = g_strdup ("/dev/video");
+
+ /* open the device */
+ v4l2element->video_fd = open (v4l2element->device, O_RDWR);
+ if (!GST_V4L2_IS_OPEN (v4l2element)) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, OPEN_READ_WRITE,
+ (_("Could not open device \"%s\" for reading and writing."),
+ v4l2element->device), GST_ERROR_SYSTEM);
+ goto error;
+ }
- /* get capabilities */
- if (!gst_v4l2_get_capabilities(v4l2element)) {
- goto error;
- }
+ /* get capabilities */
+ if (!gst_v4l2_get_capabilities (v4l2element)) {
+ goto error;
+ }
- /* do we need to be a capture device? */
- if (GST_IS_V4L2SRC(v4l2element) &&
- !(v4l2element->vcap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, NOT_FOUND,
- (_("Device \"%s\" is not a capture device."), v4l2element->device),
- ("Capabilities: 0x%x", v4l2element->vcap.capabilities));
- goto error;
- }
+ /* do we need to be a capture device? */
+ if (GST_IS_V4L2SRC (v4l2element) &&
+ !(v4l2element->vcap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, NOT_FOUND,
+ (_("Device \"%s\" is not a capture device."), v4l2element->device),
+ ("Capabilities: 0x%x", v4l2element->vcap.capabilities));
+ goto error;
+ }
- /* create enumerations */
- if (!gst_v4l2_fill_lists(v4l2element))
- goto error;
+ /* create enumerations */
+ if (!gst_v4l2_fill_lists (v4l2element))
+ goto error;
- /* set defaults */
- gst_v4l2_set_defaults (v4l2element);
+ /* set defaults */
+ gst_v4l2_set_defaults (v4l2element);
- GST_INFO_OBJECT (v4l2element, "Opened device '%s' (%s) successfully\n",
- v4l2element->vcap.card, v4l2element->device);
+ GST_INFO_OBJECT (v4l2element, "Opened device '%s' (%s) successfully\n",
+ v4l2element->vcap.card, v4l2element->device);
- return TRUE;
+ return TRUE;
error:
- if (GST_V4L2_IS_OPEN(v4l2element)) {
- /* close device */
- close(v4l2element->video_fd);
- v4l2element->video_fd = -1;
- }
- /* empty lists */
- gst_v4l2_empty_lists(v4l2element);
+ if (GST_V4L2_IS_OPEN (v4l2element)) {
+ /* close device */
+ close (v4l2element->video_fd);
+ v4l2element->video_fd = -1;
+ }
+ /* empty lists */
+ gst_v4l2_empty_lists (v4l2element);
- return FALSE;
+ return FALSE;
}
******************************************************/
gboolean
-gst_v4l2_close (GstV4l2Element *v4l2element)
+gst_v4l2_close (GstV4l2Element * v4l2element)
{
- DEBUG("Trying to close %s", v4l2element->device);
- GST_V4L2_CHECK_OPEN(v4l2element);
- GST_V4L2_CHECK_NOT_ACTIVE(v4l2element);
+ DEBUG ("Trying to close %s", v4l2element->device);
+ GST_V4L2_CHECK_OPEN (v4l2element);
+ GST_V4L2_CHECK_NOT_ACTIVE (v4l2element);
- /* close device */
- close(v4l2element->video_fd);
- v4l2element->video_fd = -1;
+ /* close device */
+ close (v4l2element->video_fd);
+ v4l2element->video_fd = -1;
- /* empty lists */
- gst_v4l2_empty_lists(v4l2element);
+ /* empty lists */
+ gst_v4l2_empty_lists (v4l2element);
- return TRUE;
+ return TRUE;
}
******************************************************/
gboolean
-gst_v4l2_get_norm (GstV4l2Element *v4l2element,
- v4l2_std_id *norm)
+gst_v4l2_get_norm (GstV4l2Element * v4l2element, v4l2_std_id * norm)
{
- DEBUG("getting norm");
- GST_V4L2_CHECK_OPEN(v4l2element);
-
- if (ioctl(v4l2element->video_fd, VIDIOC_G_STD, norm) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to get the current norm for device %s: %s",
- v4l2element->device, g_strerror(errno)));
- return FALSE;
- }
+ DEBUG ("getting norm");
+ GST_V4L2_CHECK_OPEN (v4l2element);
+
+ if (ioctl (v4l2element->video_fd, VIDIOC_G_STD, norm) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to get the current norm for device %s: %s",
+ v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
******************************************************/
gboolean
-gst_v4l2_set_norm (GstV4l2Element *v4l2element,
- v4l2_std_id norm)
+gst_v4l2_set_norm (GstV4l2Element * v4l2element, v4l2_std_id norm)
{
- DEBUG("trying to set norm to %llx", norm);
- GST_V4L2_CHECK_OPEN(v4l2element);
- GST_V4L2_CHECK_NOT_ACTIVE(v4l2element);
-
- if (ioctl(v4l2element->video_fd, VIDIOC_S_STD, &norm) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to set norm 0x%llx for device %s: %s",
- norm, v4l2element->device, g_strerror(errno)));
- return FALSE;
- }
+ DEBUG ("trying to set norm to %llx", norm);
+ GST_V4L2_CHECK_OPEN (v4l2element);
+ GST_V4L2_CHECK_NOT_ACTIVE (v4l2element);
+
+ if (ioctl (v4l2element->video_fd, VIDIOC_S_STD, &norm) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to set norm 0x%llx for device %s: %s",
+ norm, v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
******************************************************/
gboolean
-gst_v4l2_get_input (GstV4l2Element *v4l2element,
- gint *input)
+gst_v4l2_get_input (GstV4l2Element * v4l2element, gint * input)
{
- gint n;
+ gint n;
- DEBUG("trying to get input");
- GST_V4L2_CHECK_OPEN(v4l2element);
+ DEBUG ("trying to get input");
+ GST_V4L2_CHECK_OPEN (v4l2element);
- if (ioctl(v4l2element->video_fd, VIDIOC_G_INPUT, &n) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to get current input on device %s: %s",
- v4l2element->device, g_strerror(errno)));
- return FALSE;
- }
+ if (ioctl (v4l2element->video_fd, VIDIOC_G_INPUT, &n) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to get current input on device %s: %s",
+ v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
- *input = n;
+ *input = n;
- return TRUE;
+ return TRUE;
}
******************************************************/
gboolean
-gst_v4l2_set_input (GstV4l2Element *v4l2element,
- gint input)
+gst_v4l2_set_input (GstV4l2Element * v4l2element, gint input)
{
- DEBUG("trying to set input to %d", input);
- GST_V4L2_CHECK_OPEN(v4l2element);
- GST_V4L2_CHECK_NOT_ACTIVE(v4l2element);
-
- if (ioctl(v4l2element->video_fd, VIDIOC_S_INPUT, &input) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to set input %d on device %s: %s",
- input, v4l2element->device, g_strerror(errno)));
- return FALSE;
- }
+ DEBUG ("trying to set input to %d", input);
+ GST_V4L2_CHECK_OPEN (v4l2element);
+ GST_V4L2_CHECK_NOT_ACTIVE (v4l2element);
+
+ if (ioctl (v4l2element->video_fd, VIDIOC_S_INPUT, &input) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to set input %d on device %s: %s",
+ input, v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
******************************************************/
gboolean
-gst_v4l2_get_output (GstV4l2Element *v4l2element,
- gint *output)
+gst_v4l2_get_output (GstV4l2Element * v4l2element, gint * output)
{
- gint n;
+ gint n;
- DEBUG("trying to get output");
- GST_V4L2_CHECK_OPEN(v4l2element);
+ DEBUG ("trying to get output");
+ GST_V4L2_CHECK_OPEN (v4l2element);
- if (ioctl(v4l2element->video_fd, VIDIOC_G_OUTPUT, &n) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to get current output on device %s: %s",
- v4l2element->device, g_strerror(errno)));
- return FALSE;
- }
+ if (ioctl (v4l2element->video_fd, VIDIOC_G_OUTPUT, &n) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to get current output on device %s: %s",
+ v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
- *output = n;
+ *output = n;
- return TRUE;
+ return TRUE;
}
******************************************************/
gboolean
-gst_v4l2_set_output (GstV4l2Element *v4l2element,
- gint output)
+gst_v4l2_set_output (GstV4l2Element * v4l2element, gint output)
{
- DEBUG("trying to set output to %d", output);
- GST_V4L2_CHECK_OPEN(v4l2element);
- GST_V4L2_CHECK_NOT_ACTIVE(v4l2element);
-
- if (ioctl(v4l2element->video_fd, VIDIOC_S_OUTPUT, &output) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to set output %d on device %s: %s",
- output, v4l2element->device, g_strerror(errno)));
- return FALSE;
- }
+ DEBUG ("trying to set output to %d", output);
+ GST_V4L2_CHECK_OPEN (v4l2element);
+ GST_V4L2_CHECK_NOT_ACTIVE (v4l2element);
+
+ if (ioctl (v4l2element->video_fd, VIDIOC_S_OUTPUT, &output) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to set output %d on device %s: %s",
+ output, v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
******************************************************/
gboolean
-gst_v4l2_get_frequency (GstV4l2Element *v4l2element,
- gint tunernum,
- gulong *frequency)
+gst_v4l2_get_frequency (GstV4l2Element * v4l2element,
+ gint tunernum, gulong * frequency)
{
- struct v4l2_frequency freq;
+ struct v4l2_frequency freq;
- DEBUG("getting current tuner frequency");
- GST_V4L2_CHECK_OPEN(v4l2element);
+ DEBUG ("getting current tuner frequency");
+ GST_V4L2_CHECK_OPEN (v4l2element);
- freq.tuner = tunernum;
- if (ioctl(v4l2element->video_fd, VIDIOC_G_FREQUENCY, &freq) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to get current tuner frequency for device %s: %s",
- v4l2element->device, g_strerror(errno)));
- return FALSE;
- }
+ freq.tuner = tunernum;
+ if (ioctl (v4l2element->video_fd, VIDIOC_G_FREQUENCY, &freq) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to get current tuner frequency for device %s: %s",
+ v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
- *frequency = freq.frequency;
+ *frequency = freq.frequency;
- return TRUE;
+ return TRUE;
}
******************************************************/
gboolean
-gst_v4l2_set_frequency (GstV4l2Element *v4l2element,
- gint tunernum,
- gulong frequency)
+gst_v4l2_set_frequency (GstV4l2Element * v4l2element,
+ gint tunernum, gulong frequency)
{
- struct v4l2_frequency freq;
-
- DEBUG("setting current tuner frequency to %lu", frequency);
- GST_V4L2_CHECK_OPEN(v4l2element);
- GST_V4L2_CHECK_NOT_ACTIVE(v4l2element);
-
- freq.tuner = tunernum;
- /* fill in type - ignore error */
- ioctl(v4l2element->video_fd, VIDIOC_G_FREQUENCY, &freq);
- freq.frequency = frequency;
-
- if (ioctl(v4l2element->video_fd, VIDIOC_S_FREQUENCY, &freq) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to set tuner frequency to %lu for device %s: %s",
- frequency, v4l2element->device, g_strerror(errno)));
- return FALSE;
- }
+ struct v4l2_frequency freq;
+
+ DEBUG ("setting current tuner frequency to %lu", frequency);
+ GST_V4L2_CHECK_OPEN (v4l2element);
+ GST_V4L2_CHECK_NOT_ACTIVE (v4l2element);
+
+ freq.tuner = tunernum;
+ /* fill in type - ignore error */
+ ioctl (v4l2element->video_fd, VIDIOC_G_FREQUENCY, &freq);
+ freq.frequency = frequency;
+
+ if (ioctl (v4l2element->video_fd, VIDIOC_S_FREQUENCY, &freq) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to set tuner frequency to %lu for device %s: %s",
+ frequency, v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
******************************************************/
gboolean
-gst_v4l2_signal_strength (GstV4l2Element *v4l2element,
- gint tunernum,
- gulong *signal_strength)
+gst_v4l2_signal_strength (GstV4l2Element * v4l2element,
+ gint tunernum, gulong * signal_strength)
{
- struct v4l2_tuner tuner;
+ struct v4l2_tuner tuner;
- DEBUG("trying to get signal strength");
- GST_V4L2_CHECK_OPEN(v4l2element);
+ DEBUG ("trying to get signal strength");
+ GST_V4L2_CHECK_OPEN (v4l2element);
- tuner.index = tunernum;
- if (ioctl(v4l2element->video_fd, VIDIOC_G_TUNER, &tuner) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to get signal strength for device %s: %s",
- v4l2element->device, g_strerror(errno)));
- return FALSE;
- }
+ tuner.index = tunernum;
+ if (ioctl (v4l2element->video_fd, VIDIOC_G_TUNER, &tuner) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to get signal strength for device %s: %s",
+ v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
- *signal_strength = tuner.signal;
+ *signal_strength = tuner.signal;
- return TRUE;
+ return TRUE;
}
******************************************************/
gboolean
-gst_v4l2_get_attribute (GstV4l2Element *v4l2element,
- int attribute_num,
- int *value)
+gst_v4l2_get_attribute (GstV4l2Element * v4l2element,
+ int attribute_num, int *value)
{
- struct v4l2_control control;
+ struct v4l2_control control;
- GST_V4L2_CHECK_OPEN(v4l2element);
+ GST_V4L2_CHECK_OPEN (v4l2element);
- DEBUG("getting value of attribute %d", attribute_num);
+ DEBUG ("getting value of attribute %d", attribute_num);
- control.id = attribute_num;
+ control.id = attribute_num;
- if (ioctl(v4l2element->video_fd, VIDIOC_G_CTRL, &control) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to get value for control %d on device %s: %s",
- attribute_num, v4l2element->device, g_strerror(errno)));
- return FALSE;
- }
+ if (ioctl (v4l2element->video_fd, VIDIOC_G_CTRL, &control) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to get value for control %d on device %s: %s",
+ attribute_num, v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
- *value = control.value;
+ *value = control.value;
- return TRUE;
+ return TRUE;
}
******************************************************/
gboolean
-gst_v4l2_set_attribute (GstV4l2Element *v4l2element,
- int attribute_num,
- const int value)
+gst_v4l2_set_attribute (GstV4l2Element * v4l2element,
+ int attribute_num, const int value)
{
- struct v4l2_control control;
+ struct v4l2_control control;
- GST_V4L2_CHECK_OPEN(v4l2element);
+ GST_V4L2_CHECK_OPEN (v4l2element);
- DEBUG("setting value of attribute %d to %d", attribute_num, value);
+ DEBUG ("setting value of attribute %d to %d", attribute_num, value);
- control.id = attribute_num;
- control.value = value;
+ control.id = attribute_num;
+ control.value = value;
- if (ioctl(v4l2element->video_fd, VIDIOC_S_CTRL, &control) < 0) {
- GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
- ("Failed to set value %d for control %d on device %s: %s",
- value, attribute_num, v4l2element->device, g_strerror(errno)));
- return FALSE;
- }
+ if (ioctl (v4l2element->video_fd, VIDIOC_S_CTRL, &control) < 0) {
+ GST_ELEMENT_ERROR (v4l2element, RESOURCE, SETTINGS, (NULL),
+ ("Failed to set value %d for control %d on device %s: %s",
+ value, attribute_num, v4l2element->device, g_strerror (errno)));
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
-
/* open/close the device */
-gboolean gst_v4l2_open (GstV4l2Element *v4l2element);
-gboolean gst_v4l2_close (GstV4l2Element *v4l2element);
+gboolean gst_v4l2_open (GstV4l2Element * v4l2element);
+gboolean gst_v4l2_close (GstV4l2Element * v4l2element);
/* norm/input/output */
-gboolean gst_v4l2_get_norm (GstV4l2Element *v4l2element,
- v4l2_std_id *norm);
-gboolean gst_v4l2_set_norm (GstV4l2Element *v4l2element,
- v4l2_std_id norm);
-gboolean gst_v4l2_get_input (GstV4l2Element *v4l2element,
- gint *input);
-gboolean gst_v4l2_set_input (GstV4l2Element *v4l2element,
- gint input);
-gboolean gst_v4l2_get_output (GstV4l2Element *v4l2element,
- gint *output);
-gboolean gst_v4l2_set_output (GstV4l2Element *v4l2element,
- gint output);
+gboolean gst_v4l2_get_norm (GstV4l2Element * v4l2element, v4l2_std_id * norm);
+gboolean gst_v4l2_set_norm (GstV4l2Element * v4l2element, v4l2_std_id norm);
+gboolean gst_v4l2_get_input (GstV4l2Element * v4l2element, gint * input);
+gboolean gst_v4l2_set_input (GstV4l2Element * v4l2element, gint input);
+gboolean gst_v4l2_get_output (GstV4l2Element * v4l2element, gint * output);
+gboolean gst_v4l2_set_output (GstV4l2Element * v4l2element, gint output);
/* frequency control */
-gboolean gst_v4l2_get_frequency (GstV4l2Element *v4l2element,
- gint tunernum,
- gulong *frequency);
-gboolean gst_v4l2_set_frequency (GstV4l2Element *v4l2element,
- gint tunernum,
- gulong frequency);
-gboolean gst_v4l2_signal_strength (GstV4l2Element *v4l2element,
- gint tunernum,
- gulong *signal);
+gboolean gst_v4l2_get_frequency (GstV4l2Element * v4l2element,
+ gint tunernum, gulong * frequency);
+gboolean gst_v4l2_set_frequency (GstV4l2Element * v4l2element,
+ gint tunernum, gulong frequency);
+gboolean gst_v4l2_signal_strength (GstV4l2Element * v4l2element,
+ gint tunernum, gulong * signal);
/* attribute control */
-gboolean gst_v4l2_get_attribute (GstV4l2Element *v4l2element,
- int attribute,
- int *value);
-gboolean gst_v4l2_set_attribute (GstV4l2Element *v4l2element,
- int attribute,
- const int value);
+gboolean gst_v4l2_get_attribute (GstV4l2Element * v4l2element,
+ int attribute, int *value);
+gboolean gst_v4l2_set_attribute (GstV4l2Element * v4l2element,
+ int attribute, const int value);
/* overlay */
-gboolean gst_v4l2_set_display (GstV4l2Element *v4l2element);
-gboolean gst_v4l2_set_window (GstElement *element,
- gint x, gint y,
- gint w, gint h,
- struct v4l2_clip *clips,
- gint num_clips);
-gboolean gst_v4l2_enable_overlay (GstV4l2Element *v4l2element,
- gboolean enable);
+gboolean gst_v4l2_set_display (GstV4l2Element * v4l2element);
+gboolean gst_v4l2_set_window (GstElement * element,
+ gint x, gint y, gint w, gint h, struct v4l2_clip *clips, gint num_clips);
+gboolean gst_v4l2_enable_overlay (GstV4l2Element * v4l2element,
+ gboolean enable);
#endif /* __V4L2_CALLS_H__ */
******************************************************/
gboolean
-gst_v4l2src_fill_format_list (GstV4l2Src *v4l2src)
+gst_v4l2src_fill_format_list (GstV4l2Src * v4l2src)
{
gint n;
struct v4l2_fmtdesc *format;
GST_DEBUG_OBJECT (v4l2src, "getting src format enumerations");
/* format enumeration */
- for (n=0;;n++) {
+ for (n = 0;; n++) {
format = g_new (struct v4l2_fmtdesc, 1);
+
format->index = n;
format->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- if (ioctl(GST_V4L2ELEMENT(v4l2src)->video_fd, VIDIOC_ENUM_FMT, format) < 0) {
+ if (ioctl (GST_V4L2ELEMENT (v4l2src)->video_fd, VIDIOC_ENUM_FMT,
+ format) < 0) {
if (errno == EINVAL) {
- break; /* end of enumeration */
+ break; /* end of enumeration */
} else {
GST_ELEMENT_ERROR (v4l2src, RESOURCE, SETTINGS, (NULL),
("failed to get number %d in pixelformat enumeration for %s: %s",
- n, GST_V4L2ELEMENT(v4l2src)->device, g_strerror (errno)));
+ n, GST_V4L2ELEMENT (v4l2src)->device, g_strerror (errno)));
g_free (format);
return FALSE;
}
}
- GST_LOG_OBJECT (v4l2src, "got format"GST_FOURCC_FORMAT,
+ GST_LOG_OBJECT (v4l2src, "got format" GST_FOURCC_FORMAT,
GST_FOURCC_ARGS (format->pixelformat));
v4l2src->formats = g_slist_prepend (v4l2src->formats, format);
}
******************************************************/
gboolean
-gst_v4l2src_clear_format_list (GstV4l2Src *v4l2src)
+gst_v4l2src_clear_format_list (GstV4l2Src * v4l2src)
{
g_slist_foreach (v4l2src->formats, (GFunc) g_free, NULL);
g_slist_free (v4l2src->formats);
******************************************************/
gboolean
-gst_v4l2src_queue_frame (GstV4l2Src *v4l2src,
- guint i)
+gst_v4l2src_queue_frame (GstV4l2Src * v4l2src, guint i)
{
GST_LOG_OBJECT (v4l2src, "queueing frame %u", i);
- if (ioctl(GST_V4L2ELEMENT(v4l2src)->video_fd, VIDIOC_QBUF, &v4l2src->pool->buffers[i].buffer) < 0) {
+ if (ioctl (GST_V4L2ELEMENT (v4l2src)->video_fd, VIDIOC_QBUF,
+ &v4l2src->pool->buffers[i].buffer) < 0) {
GST_ELEMENT_ERROR (v4l2src, RESOURCE, WRITE,
- (_("Could not write to device \"%s\"."), GST_V4L2ELEMENT(v4l2src)->device),
- ("Error queueing buffer %u on device %s", i, g_strerror(errno)));
+ (_("Could not write to device \"%s\"."),
+ GST_V4L2ELEMENT (v4l2src)->device),
+ ("Error queueing buffer %u on device %s", i, g_strerror (errno)));
return FALSE;
}
******************************************************/
gint
-gst_v4l2src_grab_frame (GstV4l2Src *v4l2src)
+gst_v4l2src_grab_frame (GstV4l2Src * v4l2src)
{
struct v4l2_buffer buffer;
-
+
buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- while (ioctl(GST_V4L2ELEMENT(v4l2src)->video_fd, VIDIOC_DQBUF, &buffer) < 0) {
+ while (ioctl (GST_V4L2ELEMENT (v4l2src)->video_fd, VIDIOC_DQBUF, &buffer) < 0) {
/* if the sync() got interrupted, we can retry */
if (errno != EINTR) {
- GST_ELEMENT_ERROR (v4l2src, RESOURCE, SYNC, (NULL), ("could not sync on a buffer on device %s: %s",
- GST_V4L2ELEMENT(v4l2src)->device, g_strerror (errno)));
+ GST_ELEMENT_ERROR (v4l2src, RESOURCE, SYNC, (NULL),
+ ("could not sync on a buffer on device %s: %s",
+ GST_V4L2ELEMENT (v4l2src)->device, g_strerror (errno)));
return -1;
}
GST_DEBUG_OBJECT (v4l2src, "grab got interrupted");
******************************************************/
gboolean
-gst_v4l2src_get_capture (GstV4l2Src *v4l2src)
+gst_v4l2src_get_capture (GstV4l2Src * v4l2src)
{
- DEBUG("Getting capture format");
+ DEBUG ("Getting capture format");
- GST_V4L2_CHECK_OPEN(GST_V4L2ELEMENT(v4l2src));
+ GST_V4L2_CHECK_OPEN (GST_V4L2ELEMENT (v4l2src));
- v4l2src->format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- if (ioctl(GST_V4L2ELEMENT(v4l2src)->video_fd, VIDIOC_G_FMT, &v4l2src->format) < 0) {
- GST_ELEMENT_ERROR (v4l2src, RESOURCE, SETTINGS, (NULL),
- ("failed to get pixelformat for device %s: %s",
- GST_V4L2ELEMENT(v4l2src)->device, g_strerror (errno)));
- return FALSE;
- }
+ v4l2src->format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ if (ioctl (GST_V4L2ELEMENT (v4l2src)->video_fd, VIDIOC_G_FMT,
+ &v4l2src->format) < 0) {
+ GST_ELEMENT_ERROR (v4l2src, RESOURCE, SETTINGS, (NULL),
+ ("failed to get pixelformat for device %s: %s",
+ GST_V4L2ELEMENT (v4l2src)->device, g_strerror (errno)));
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
******************************************************/
gboolean
-gst_v4l2src_set_capture (GstV4l2Src *v4l2src,
- struct v4l2_fmtdesc *fmt,
- gint width,
- gint height)
+gst_v4l2src_set_capture (GstV4l2Src * v4l2src,
+ struct v4l2_fmtdesc * fmt, gint width, gint height)
{
- DEBUG("Setting capture format to %dx%d, format %s",
- width, height, fmt->description);
-
- GST_V4L2_CHECK_OPEN(GST_V4L2ELEMENT(v4l2src));
- GST_V4L2_CHECK_NOT_ACTIVE(GST_V4L2ELEMENT(v4l2src));
-
- memset(&v4l2src->format, 0, sizeof(struct v4l2_format));
- v4l2src->format.fmt.pix.width = width;
- v4l2src->format.fmt.pix.height = height;
- v4l2src->format.fmt.pix.pixelformat = fmt->pixelformat;
- v4l2src->format.fmt.pix.field = V4L2_FIELD_INTERLACED;
- v4l2src->format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-
- if (ioctl(GST_V4L2ELEMENT(v4l2src)->video_fd, VIDIOC_S_FMT, &v4l2src->format) < 0) {
- GST_ELEMENT_ERROR (v4l2src, RESOURCE, SETTINGS, (NULL),
- ("failed to set pixelformat to %s @ %dx%d for device %s: %s",
- fmt->description, width, height, GST_V4L2ELEMENT(v4l2src)->device, g_strerror (errno)));
- return FALSE;
- }
-
- /* update internal info */
- return gst_v4l2src_get_capture(v4l2src);
+ DEBUG ("Setting capture format to %dx%d, format %s",
+ width, height, fmt->description);
+
+ GST_V4L2_CHECK_OPEN (GST_V4L2ELEMENT (v4l2src));
+ GST_V4L2_CHECK_NOT_ACTIVE (GST_V4L2ELEMENT (v4l2src));
+
+ memset (&v4l2src->format, 0, sizeof (struct v4l2_format));
+ v4l2src->format.fmt.pix.width = width;
+ v4l2src->format.fmt.pix.height = height;
+ v4l2src->format.fmt.pix.pixelformat = fmt->pixelformat;
+ v4l2src->format.fmt.pix.field = V4L2_FIELD_INTERLACED;
+ v4l2src->format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+
+ if (ioctl (GST_V4L2ELEMENT (v4l2src)->video_fd, VIDIOC_S_FMT,
+ &v4l2src->format) < 0) {
+ GST_ELEMENT_ERROR (v4l2src, RESOURCE, SETTINGS, (NULL),
+ ("failed to set pixelformat to %s @ %dx%d for device %s: %s",
+ fmt->description, width, height, GST_V4L2ELEMENT (v4l2src)->device,
+ g_strerror (errno)));
+ return FALSE;
+ }
+
+ /* update internal info */
+ return gst_v4l2src_get_capture (v4l2src);
}
******************************************************/
gboolean
-gst_v4l2src_capture_init (GstV4l2Src *v4l2src)
+gst_v4l2src_capture_init (GstV4l2Src * v4l2src)
{
gint n;
guint buffers;
GST_DEBUG_OBJECT (v4l2src, "initting the capture system");
- GST_V4L2_CHECK_OPEN(GST_V4L2ELEMENT(v4l2src));
- GST_V4L2_CHECK_NOT_ACTIVE(GST_V4L2ELEMENT(v4l2src));
+ GST_V4L2_CHECK_OPEN (GST_V4L2ELEMENT (v4l2src));
+ GST_V4L2_CHECK_NOT_ACTIVE (GST_V4L2ELEMENT (v4l2src));
/* request buffer info */
buffers = v4l2src->breq.count;
}
v4l2src->breq.type = v4l2src->format.type;
v4l2src->breq.memory = V4L2_MEMORY_MMAP;
- if (ioctl(GST_V4L2ELEMENT(v4l2src)->video_fd, VIDIOC_REQBUFS, &v4l2src->breq) < 0) {
+ if (ioctl (GST_V4L2ELEMENT (v4l2src)->video_fd, VIDIOC_REQBUFS,
+ &v4l2src->breq) < 0) {
GST_ELEMENT_ERROR (v4l2src, RESOURCE, READ,
- (_("Could not get buffers from device \"%s\"."), GST_V4L2ELEMENT(v4l2src)->device),
- ("error requesting %d buffers: %s", v4l2src->breq.count, g_strerror (errno)));
+ (_("Could not get buffers from device \"%s\"."),
+ GST_V4L2ELEMENT (v4l2src)->device),
+ ("error requesting %d buffers: %s", v4l2src->breq.count,
+ g_strerror (errno)));
return FALSE;
}
if (v4l2src->breq.count < GST_V4L2_MIN_BUFFERS) {
GST_ELEMENT_ERROR (v4l2src, RESOURCE, READ,
- (_("Could not get enough buffers from device \"%s\"."), GST_V4L2ELEMENT(v4l2src)->device),
- ("we received %d, we want at least %d", v4l2src->breq.count, GST_V4L2_MIN_BUFFERS));
+ (_("Could not get enough buffers from device \"%s\"."),
+ GST_V4L2ELEMENT (v4l2src)->device),
+ ("we received %d, we want at least %d", v4l2src->breq.count,
+ GST_V4L2_MIN_BUFFERS));
v4l2src->breq.count = buffers;
return FALSE;
}
if (v4l2src->breq.count != buffers)
g_object_notify (G_OBJECT (v4l2src), "num_buffers");
- GST_INFO_OBJECT (v4l2src, "Got %d buffers ("GST_FOURCC_FORMAT") of size %d KB\n",
- v4l2src->breq.count, GST_FOURCC_ARGS (v4l2src->format.fmt.pix.pixelformat),
+ GST_INFO_OBJECT (v4l2src,
+ "Got %d buffers (" GST_FOURCC_FORMAT ") of size %d KB\n",
+ v4l2src->breq.count,
+ GST_FOURCC_ARGS (v4l2src->format.fmt.pix.pixelformat),
v4l2src->format.fmt.pix.sizeimage / 1024);
/* Map the buffers */
buffer->pool = v4l2src->pool;
buffer->buffer.index = n;
buffer->buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- if (ioctl(GST_V4L2ELEMENT(v4l2src)->video_fd, VIDIOC_QUERYBUF, &buffer->buffer) < 0) {
- GST_ELEMENT_ERROR (v4l2src, RESOURCE, READ, (NULL),
- ("Could not get buffer properties of buffer %d: %s", n, g_strerror (errno)));
- gst_v4l2src_capture_deinit(v4l2src);
+ if (ioctl (GST_V4L2ELEMENT (v4l2src)->video_fd, VIDIOC_QUERYBUF,
+ &buffer->buffer) < 0) {
+ GST_ELEMENT_ERROR (v4l2src, RESOURCE, READ, (NULL),
+ ("Could not get buffer properties of buffer %d: %s", n,
+ g_strerror (errno)));
+ gst_v4l2src_capture_deinit (v4l2src);
return FALSE;
}
- buffer->start = mmap (0, buffer->buffer.length, PROT_READ|PROT_WRITE, MAP_SHARED,
- GST_V4L2ELEMENT(v4l2src)->video_fd, buffer->buffer.m.offset);
+ buffer->start =
+ mmap (0, buffer->buffer.length, PROT_READ | PROT_WRITE, MAP_SHARED,
+ GST_V4L2ELEMENT (v4l2src)->video_fd, buffer->buffer.m.offset);
if (buffer->start == MAP_FAILED) {
- GST_ELEMENT_ERROR (v4l2src, RESOURCE, READ, (NULL),
- ("Could not mmap video buffer %d: %s", n, g_strerror (errno)));
+ GST_ELEMENT_ERROR (v4l2src, RESOURCE, READ, (NULL),
+ ("Could not mmap video buffer %d: %s", n, g_strerror (errno)));
buffer->start = 0;
gst_v4l2src_capture_deinit (v4l2src);
return FALSE;
}
buffer->length = buffer->buffer.length;
- if (!gst_v4l2src_queue_frame(v4l2src, n)) {
+ if (!gst_v4l2src_queue_frame (v4l2src, n)) {
gst_v4l2src_capture_deinit (v4l2src);
return FALSE;
}
}
- GST_V4L2_SET_ACTIVE(GST_V4L2ELEMENT (v4l2src));
+ GST_V4L2_SET_ACTIVE (GST_V4L2ELEMENT (v4l2src));
return TRUE;
}
******************************************************/
gboolean
-gst_v4l2src_capture_start (GstV4l2Src *v4l2src)
+gst_v4l2src_capture_start (GstV4l2Src * v4l2src)
{
gint type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
GST_DEBUG_OBJECT (v4l2src, "starting the capturing");
-
- GST_V4L2_CHECK_OPEN(GST_V4L2ELEMENT(v4l2src));
- if (!GST_V4L2_IS_ACTIVE (GST_V4L2ELEMENT(v4l2src))) {
+
+ GST_V4L2_CHECK_OPEN (GST_V4L2ELEMENT (v4l2src));
+ if (!GST_V4L2_IS_ACTIVE (GST_V4L2ELEMENT (v4l2src))) {
gst_pad_renegotiate (v4l2src->srcpad);
}
- GST_V4L2_CHECK_ACTIVE(GST_V4L2ELEMENT(v4l2src));
+ GST_V4L2_CHECK_ACTIVE (GST_V4L2ELEMENT (v4l2src));
v4l2src->quit = FALSE;
- if (ioctl(GST_V4L2ELEMENT(v4l2src)->video_fd, VIDIOC_STREAMON, &type) < 0) {
+ if (ioctl (GST_V4L2ELEMENT (v4l2src)->video_fd, VIDIOC_STREAMON, &type) < 0) {
GST_ELEMENT_ERROR (v4l2src, RESOURCE, OPEN_READ, (NULL),
- ("Error starting streaming capture from device %s: %s",
- GST_V4L2ELEMENT(v4l2src)->device, g_strerror(errno)));
+ ("Error starting streaming capture from device %s: %s",
+ GST_V4L2ELEMENT (v4l2src)->device, g_strerror (errno)));
return FALSE;
}
******************************************************/
gboolean
-gst_v4l2src_capture_stop (GstV4l2Src *v4l2src)
+gst_v4l2src_capture_stop (GstV4l2Src * v4l2src)
{
gint type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
GST_DEBUG_OBJECT (v4l2src, "stopping capturing");
- GST_V4L2_CHECK_OPEN(GST_V4L2ELEMENT(v4l2src));
- GST_V4L2_CHECK_ACTIVE(GST_V4L2ELEMENT(v4l2src));
+ GST_V4L2_CHECK_OPEN (GST_V4L2ELEMENT (v4l2src));
+ GST_V4L2_CHECK_ACTIVE (GST_V4L2ELEMENT (v4l2src));
/* we actually need to sync on all queued buffers but not
* on the non-queued ones */
- if (ioctl(GST_V4L2ELEMENT(v4l2src)->video_fd, VIDIOC_STREAMOFF, &type) < 0) {
+ if (ioctl (GST_V4L2ELEMENT (v4l2src)->video_fd, VIDIOC_STREAMOFF, &type) < 0) {
GST_ELEMENT_ERROR (v4l2src, RESOURCE, CLOSE, (NULL),
- ("Error stopping streaming capture from device %s: %s",
- GST_V4L2ELEMENT(v4l2src)->device, g_strerror (errno)));
+ ("Error stopping streaming capture from device %s: %s",
+ GST_V4L2ELEMENT (v4l2src)->device, g_strerror (errno)));
return FALSE;
}
/* make an optional pending wait stop */
v4l2src->quit = TRUE;
-
+
return TRUE;
}
static void
-gst_v4l2src_buffer_pool_free (GstV4l2BufferPool *pool, gboolean do_close)
+gst_v4l2src_buffer_pool_free (GstV4l2BufferPool * pool, gboolean do_close)
{
guint i;
}
void
-gst_v4l2src_free_buffer (GstBuffer *buffer)
+gst_v4l2src_free_buffer (GstBuffer * buffer)
{
GstV4l2Buffer *buf = (GstV4l2Buffer *) GST_BUFFER_PRIVATE (buffer);
-
+
GST_LOG ("freeing buffer %p (nr. %d)", buffer, buf->buffer.index);
-
+
if (!gst_atomic_int_dec_and_test (&buf->refcount)) {
/* we're still in use, add to queue again
note: this might fail because the device is already stopped (race) */
- if (ioctl(buf->pool->video_fd, VIDIOC_QBUF, &buf->buffer) < 0)
+ if (ioctl (buf->pool->video_fd, VIDIOC_QBUF, &buf->buffer) < 0)
GST_INFO ("readding to queue failed, assuming video device is stopped");
}
if (gst_atomic_int_dec_and_test (&buf->pool->refcount)) {
******************************************************/
gboolean
-gst_v4l2src_capture_deinit (GstV4l2Src *v4l2src)
+gst_v4l2src_capture_deinit (GstV4l2Src * v4l2src)
{
gint i, dequeue = 0;
-
+
GST_DEBUG_OBJECT (v4l2src, "deinitting capture system");
-
- GST_V4L2_CHECK_OPEN(GST_V4L2ELEMENT(v4l2src));
- GST_V4L2_CHECK_ACTIVE(GST_V4L2ELEMENT(v4l2src));
+
+ GST_V4L2_CHECK_OPEN (GST_V4L2ELEMENT (v4l2src));
+ GST_V4L2_CHECK_ACTIVE (GST_V4L2ELEMENT (v4l2src));
/* free the buffers */
for (i = 0; i < v4l2src->breq.count; i++) {
}
for (i = 0; i < dequeue; i++) {
struct v4l2_buffer buffer;
- buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- if (ioctl(GST_V4L2ELEMENT(v4l2src)->video_fd, VIDIOC_DQBUF, &buffer) < 0)
- GST_WARNING_OBJECT (v4l2src, "Could not dequeue buffer on uninitialization");
+
+ buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ if (ioctl (GST_V4L2ELEMENT (v4l2src)->video_fd, VIDIOC_DQBUF, &buffer) < 0)
+ GST_WARNING_OBJECT (v4l2src,
+ "Could not dequeue buffer on uninitialization");
}
if (gst_atomic_int_dec_and_test (&v4l2src->pool->refcount)) {
/* we're last thing that used all this */
gst_v4l2src_buffer_pool_free (v4l2src->pool, FALSE);
}
v4l2src->pool = NULL;
-
+
GST_V4L2_SET_INACTIVE (GST_V4L2ELEMENT (v4l2src));
return TRUE;
}
*/
gboolean
-gst_v4l2src_get_size_limits (GstV4l2Src *v4l2src,
- struct v4l2_fmtdesc *format,
- gint *min_w, gint *max_w,
- gint *min_h, gint *max_h)
+gst_v4l2src_get_size_limits (GstV4l2Src * v4l2src,
+ struct v4l2_fmtdesc * format,
+ gint * min_w, gint * max_w, gint * min_h, gint * max_h)
{
- struct v4l2_format fmt;
-
- GST_LOG_OBJECT (v4l2src, "getting size limits with format " GST_FOURCC_FORMAT,
- GST_FOURCC_ARGS (format->pixelformat));
-
- /* get size delimiters */
- memset(&fmt, 0, sizeof(fmt));
- fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- fmt.fmt.pix.width = 0;
- fmt.fmt.pix.height = 0;
- fmt.fmt.pix.pixelformat = format->pixelformat;
- fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
- if (ioctl(GST_V4L2ELEMENT(v4l2src)->video_fd,
- VIDIOC_TRY_FMT, &fmt) < 0) {
- return FALSE;
- }
-
- if (min_w)
- *min_w = fmt.fmt.pix.width;
- if (min_h)
- *min_h = fmt.fmt.pix.height;
- GST_LOG_OBJECT (v4l2src, "got min size %dx%d", fmt.fmt.pix.width, fmt.fmt.pix.height);
-
- fmt.fmt.pix.width = G_MAXINT;
- fmt.fmt.pix.height = 576;
- if (ioctl(GST_V4L2ELEMENT(v4l2src)->video_fd,
- VIDIOC_TRY_FMT, &fmt) < 0) {
- return FALSE;
- }
-
- if (max_w)
- *max_w = fmt.fmt.pix.width;
- if (max_h)
- *max_h = fmt.fmt.pix.height;
- GST_LOG_OBJECT (v4l2src, "got max size %dx%d", fmt.fmt.pix.width, fmt.fmt.pix.height);
-
- return TRUE;
+ struct v4l2_format fmt;
+
+ GST_LOG_OBJECT (v4l2src, "getting size limits with format " GST_FOURCC_FORMAT,
+ GST_FOURCC_ARGS (format->pixelformat));
+
+ /* get size delimiters */
+ memset (&fmt, 0, sizeof (fmt));
+ fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ fmt.fmt.pix.width = 0;
+ fmt.fmt.pix.height = 0;
+ fmt.fmt.pix.pixelformat = format->pixelformat;
+ fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
+ if (ioctl (GST_V4L2ELEMENT (v4l2src)->video_fd, VIDIOC_TRY_FMT, &fmt) < 0) {
+ return FALSE;
+ }
+
+ if (min_w)
+ *min_w = fmt.fmt.pix.width;
+ if (min_h)
+ *min_h = fmt.fmt.pix.height;
+ GST_LOG_OBJECT (v4l2src, "got min size %dx%d", fmt.fmt.pix.width,
+ fmt.fmt.pix.height);
+
+ fmt.fmt.pix.width = G_MAXINT;
+ fmt.fmt.pix.height = 576;
+ if (ioctl (GST_V4L2ELEMENT (v4l2src)->video_fd, VIDIOC_TRY_FMT, &fmt) < 0) {
+ return FALSE;
+ }
+
+ if (max_w)
+ *max_w = fmt.fmt.pix.width;
+ if (max_h)
+ *max_h = fmt.fmt.pix.height;
+ GST_LOG_OBJECT (v4l2src, "got max size %dx%d", fmt.fmt.pix.width,
+ fmt.fmt.pix.height);
+
+ return TRUE;
}
#include "v4l2_calls.h"
-gboolean gst_v4l2src_get_capture (GstV4l2Src *v4l2src);
-gboolean gst_v4l2src_set_capture (GstV4l2Src *v4l2src,
- struct v4l2_fmtdesc *fmt,
- gint width,
- gint height);
-gboolean gst_v4l2src_capture_init (GstV4l2Src *v4l2src);
-gboolean gst_v4l2src_capture_start (GstV4l2Src *v4l2src);
-gint gst_v4l2src_grab_frame (GstV4l2Src *v4l2src);
-guint8 * gst_v4l2src_get_buffer (GstV4l2Src *v4l2src,
- gint num);
-gboolean gst_v4l2src_queue_frame (GstV4l2Src *v4l2src,
- guint i);
-gboolean gst_v4l2src_capture_stop (GstV4l2Src *v4l2src);
-gboolean gst_v4l2src_capture_deinit (GstV4l2Src *v4l2src);
-
-gboolean gst_v4l2src_fill_format_list (GstV4l2Src *v4l2src);
-gboolean gst_v4l2src_clear_format_list (GstV4l2Src *v4l2src);
+gboolean gst_v4l2src_get_capture (GstV4l2Src * v4l2src);
+gboolean gst_v4l2src_set_capture (GstV4l2Src * v4l2src,
+ struct v4l2_fmtdesc *fmt, gint width, gint height);
+gboolean gst_v4l2src_capture_init (GstV4l2Src * v4l2src);
+gboolean gst_v4l2src_capture_start (GstV4l2Src * v4l2src);
+gint gst_v4l2src_grab_frame (GstV4l2Src * v4l2src);
+guint8 *gst_v4l2src_get_buffer (GstV4l2Src * v4l2src, gint num);
+gboolean gst_v4l2src_queue_frame (GstV4l2Src * v4l2src, guint i);
+gboolean gst_v4l2src_capture_stop (GstV4l2Src * v4l2src);
+gboolean gst_v4l2src_capture_deinit (GstV4l2Src * v4l2src);
+
+gboolean gst_v4l2src_fill_format_list (GstV4l2Src * v4l2src);
+gboolean gst_v4l2src_clear_format_list (GstV4l2Src * v4l2src);
/* hacky */
-gboolean gst_v4l2src_get_size_limits (GstV4l2Src *v4l2src,
- struct v4l2_fmtdesc *fmt,
- gint *min_w, gint *max_w,
- gint *min_h, gint *max_h);
+gboolean gst_v4l2src_get_size_limits (GstV4l2Src * v4l2src,
+ struct v4l2_fmtdesc *fmt,
+ gint * min_w, gint * max_w, gint * min_h, gint * max_h);
+
+void gst_v4l2src_free_buffer (GstBuffer * buffer);
-void gst_v4l2src_free_buffer (GstBuffer *buffer);
-
#endif /* __V4L2SRC_CALLS_H__ */
#include <vcdsrc.h>
-static GstElementDetails vcdsrc_details = GST_ELEMENT_DETAILS (
- "VCD Source",
- "Source/File",
- "Asynchronous read from VCD disk",
- "Erik Walthinsen <omega@cse.ogi.edu>"
-);
+static GstElementDetails vcdsrc_details = GST_ELEMENT_DETAILS ("VCD Source",
+ "Source/File",
+ "Asynchronous read from VCD disk",
+ "Erik Walthinsen <omega@cse.ogi.edu>");
/* VCDSrc signals and args */
-enum {
+enum
+{
/* FILL ME */
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_LOCATION,
ARG_TRACK,
ARG_MAX_ERRORS,
};
-static void vcdsrc_base_init (gpointer g_class);
-static void vcdsrc_class_init (VCDSrcClass *klass);
-static void vcdsrc_init (VCDSrc *vcdsrc);
-static void vcdsrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void vcdsrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+static void vcdsrc_base_init (gpointer g_class);
+static void vcdsrc_class_init (VCDSrcClass * klass);
+static void vcdsrc_init (VCDSrc * vcdsrc);
+static void vcdsrc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void vcdsrc_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+
+static GstData *vcdsrc_get (GstPad * pad);
-static GstData * vcdsrc_get (GstPad *pad);
/*static GstBuffer * vcdsrc_get_region (GstPad *pad,gulong offset,gulong size); */
-static GstElementStateReturn vcdsrc_change_state (GstElement *element);
+static GstElementStateReturn vcdsrc_change_state (GstElement * element);
-static void vcdsrc_recalculate(VCDSrc *vcdsrc);
+static void vcdsrc_recalculate (VCDSrc * vcdsrc);
static GstElementClass *parent_class = NULL;
+
/*static guint vcdsrc_signals[LAST_SIGNAL] = { 0 }; */
GType
if (!vcdsrc_type) {
static const GTypeInfo vcdsrc_info = {
- sizeof(VCDSrcClass),
+ sizeof (VCDSrcClass),
vcdsrc_base_init,
NULL,
- (GClassInitFunc)vcdsrc_class_init,
+ (GClassInitFunc) vcdsrc_class_init,
NULL,
NULL,
- sizeof(VCDSrc),
+ sizeof (VCDSrc),
0,
- (GInstanceInitFunc)vcdsrc_init,
+ (GInstanceInitFunc) vcdsrc_init,
};
- vcdsrc_type = g_type_register_static(GST_TYPE_ELEMENT, "VCDSrc", &vcdsrc_info, 0);
+ vcdsrc_type =
+ g_type_register_static (GST_TYPE_ELEMENT, "VCDSrc", &vcdsrc_info, 0);
}
return vcdsrc_type;
}
vcdsrc_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
+
gst_element_class_set_details (element_class, &vcdsrc_details);
}
static void
-vcdsrc_class_init (VCDSrcClass *klass)
+vcdsrc_class_init (VCDSrcClass * 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_peek_parent (klass);
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_LOCATION,
- g_param_spec_string("location","location","location",
- NULL, G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_TRACK,
- g_param_spec_int("track","track","track",
- G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_BYTESPERREAD,
- g_param_spec_int("bytesperread","bytesperread","bytesperread",
- G_MININT,G_MAXINT,0,G_PARAM_READABLE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_OFFSET,
- g_param_spec_int("offset","offset","offset",
- G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); /* CHECKME */
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_MAX_ERRORS,
- g_param_spec_int("max-errors","","", 0,G_MAXINT,16,G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATION, g_param_spec_string ("location", "location", "location", NULL, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TRACK, g_param_spec_int ("track", "track", "track", G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BYTESPERREAD, g_param_spec_int ("bytesperread", "bytesperread", "bytesperread", G_MININT, G_MAXINT, 0, G_PARAM_READABLE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_OFFSET, g_param_spec_int ("offset", "offset", "offset", G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MAX_ERRORS,
+ g_param_spec_int ("max-errors", "", "", 0, G_MAXINT, 16,
+ G_PARAM_READWRITE));
gobject_class->set_property = vcdsrc_set_property;
gobject_class->get_property = vcdsrc_get_property;
}
static void
-vcdsrc_init (VCDSrc *vcdsrc)
+vcdsrc_init (VCDSrc * vcdsrc)
{
- vcdsrc->srcpad = gst_pad_new("src",GST_PAD_SRC);
+ vcdsrc->srcpad = gst_pad_new ("src", GST_PAD_SRC);
gst_pad_set_get_function (vcdsrc->srcpad, vcdsrc_get);
/* gst_pad_set_get_region_function (vcdsrc->srcpad, vcdsrc_getregion); */
- gst_element_add_pad(GST_ELEMENT(vcdsrc),vcdsrc->srcpad);
+ gst_element_add_pad (GST_ELEMENT (vcdsrc), vcdsrc->srcpad);
vcdsrc->device = g_strdup ("/dev/cdrom");
vcdsrc->track = 2;
static void
-vcdsrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+vcdsrc_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
{
VCDSrc *src;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_VCDSRC(object));
- src = VCDSRC(object);
+ g_return_if_fail (GST_IS_VCDSRC (object));
+ src = VCDSRC (object);
switch (prop_id) {
case ARG_LOCATION:
/* the element must be stopped in order to do this */
/* g_return_if_fail(!GST_FLAG_IS_SET(src,GST_STATE_RUNNING)); */
- if (src->device) g_free(src->device);
+ if (src->device)
+ g_free (src->device);
/* clear the filename if we get a NULL (is that possible?) */
if (g_value_get_string (value) == NULL)
- src->device = NULL;
+ src->device = NULL;
/* otherwise set the new filename */
else
- src->device = g_strdup(g_value_get_string (value));
+ src->device = g_strdup (g_value_get_string (value));
break;
case ARG_TRACK:
src->track = g_value_get_int (value);
- vcdsrc_recalculate(src);
+ vcdsrc_recalculate (src);
break;
/* case ARG_BYTESPERREAD:
src->bytes_per_read = g_value_get_int (value);
}
static void
-vcdsrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+vcdsrc_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
{
VCDSrc *src;
/* it's not null if we got it, but it might not be ours */
- g_return_if_fail(GST_IS_VCDSRC(object));
- src = VCDSRC(object);
+ g_return_if_fail (GST_IS_VCDSRC (object));
+ src = VCDSRC (object);
switch (prop_id) {
case ARG_LOCATION:
}
static GstData *
-vcdsrc_get (GstPad *pad)
+vcdsrc_get (GstPad * pad)
{
VCDSrc *vcdsrc;
GstBuffer *buf;
/* fprintf(stderr,"in vcdsrc_push\n"); */
- g_return_val_if_fail(pad != NULL, NULL);
- g_return_val_if_fail(GST_IS_PAD(pad), NULL);
+ g_return_val_if_fail (pad != NULL, NULL);
+ g_return_val_if_fail (GST_IS_PAD (pad), NULL);
vcdsrc = VCDSRC (GST_OBJECT_PARENT (pad));
g_return_val_if_fail (GST_FLAG_IS_SET (vcdsrc, VCDSRC_OPEN), NULL);
/* create the buffer */
/* FIXME: should eventually use a bufferpool for this */
- buf = gst_buffer_new();
- g_return_val_if_fail(buf != NULL, NULL);
+ buf = gst_buffer_new ();
+ g_return_val_if_fail (buf != NULL, NULL);
/* allocate the space for the buffer data */
- GST_BUFFER_DATA(buf) = g_malloc(vcdsrc->bytes_per_read);
- memset(GST_BUFFER_DATA(buf),0,vcdsrc->bytes_per_read);
- g_return_val_if_fail(GST_BUFFER_DATA(buf) != NULL, NULL);
+ GST_BUFFER_DATA (buf) = g_malloc (vcdsrc->bytes_per_read);
+ memset (GST_BUFFER_DATA (buf), 0, vcdsrc->bytes_per_read);
+ g_return_val_if_fail (GST_BUFFER_DATA (buf) != NULL, NULL);
- msf = (struct cdrom_msf *)GST_BUFFER_DATA(buf);
+ msf = (struct cdrom_msf *) GST_BUFFER_DATA (buf);
- read_sector:
+read_sector:
/* read it in from the device */
offset = vcdsrc->trackoffset + vcdsrc->curoffset;
/*gst_info("msf is %d:%d:%d\n",msf->cdmsf_min0,msf->cdmsf_sec0, */
/* msf->cdmsf_frame0); */
- if (ioctl(vcdsrc->fd,CDROMREADRAW,msf)) {
- if (++error_count > vcdsrc->max_errors)
- {
- gst_element_set_eos (GST_ELEMENT (vcdsrc));
- return GST_DATA (gst_event_new (GST_EVENT_EOS));
- }
+ if (ioctl (vcdsrc->fd, CDROMREADRAW, msf)) {
+ if (++error_count > vcdsrc->max_errors) {
+ gst_element_set_eos (GST_ELEMENT (vcdsrc));
+ return GST_DATA (gst_event_new (GST_EVENT_EOS));
+ }
fprintf (stderr, "%s while reading raw data from cdrom at %d:%d:%d\n",
- strerror (errno),
- msf->cdmsf_min0, msf->cdmsf_sec0, msf->cdmsf_frame0);
+ strerror (errno), msf->cdmsf_min0, msf->cdmsf_sec0, msf->cdmsf_frame0);
vcdsrc->curoffset += 1;
/* Or we can return a zero-filled buffer. Which is better? */
}
- GST_BUFFER_OFFSET(buf) = vcdsrc->curoffset;
- GST_BUFFER_SIZE(buf) = vcdsrc->bytes_per_read;
+ GST_BUFFER_OFFSET (buf) = vcdsrc->curoffset;
+ GST_BUFFER_SIZE (buf) = vcdsrc->bytes_per_read;
vcdsrc->curoffset += 1;
return GST_DATA (buf);
/* open the file, necessary to go to RUNNING state */
static gboolean
-vcdsrc_open_file(VCDSrc *src)
+vcdsrc_open_file (VCDSrc * src)
{
int i;
- g_return_val_if_fail(!GST_FLAG_IS_SET(src,VCDSRC_OPEN), FALSE);
+ g_return_val_if_fail (!GST_FLAG_IS_SET (src, VCDSRC_OPEN), FALSE);
/* open the device */
- src->fd = open(src->device,O_RDONLY);
+ src->fd = open (src->device, O_RDONLY);
if (src->fd < 0) {
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL), GST_ERROR_SYSTEM);
return FALSE;
}
/* read the table of contents */
- if (ioctl(src->fd,CDROMREADTOCHDR,&src->tochdr)) {
- perror("reading toc of VCD\n");
+ if (ioctl (src->fd, CDROMREADTOCHDR, &src->tochdr)) {
+ perror ("reading toc of VCD\n");
/* FIXME */
/* exit(1); */
}
src->tracks = g_new (struct cdrom_tocentry, src->numtracks);
/* read each track entry */
- for (i=0;i<src->numtracks;i++) {
- src->tracks[i].cdte_track = i+1;
+ for (i = 0; i < src->numtracks; i++) {
+ src->tracks[i].cdte_track = i + 1;
src->tracks[i].cdte_format = CDROM_MSF;
- if (ioctl(src->fd,CDROMREADTOCENTRY, &src->tracks[i])) {
- perror("reading tocentry");
+ if (ioctl (src->fd, CDROMREADTOCENTRY, &src->tracks[i])) {
+ perror ("reading tocentry");
/* FIXME */
/* exit(1);*/
}
- fprintf(stderr,"VCDSrc: track begins at %d:%d:%d\n",
- src->tracks[i].cdte_addr.msf.minute,
- src->tracks[i].cdte_addr.msf.second,
- src->tracks[i].cdte_addr.msf.frame);
+ fprintf (stderr, "VCDSrc: track begins at %d:%d:%d\n",
+ src->tracks[i].cdte_addr.msf.minute,
+ src->tracks[i].cdte_addr.msf.second,
+ src->tracks[i].cdte_addr.msf.frame);
}
src->trackoffset =
-(((src->tracks[src->track-1].cdte_addr.msf.minute * 60) +
- src->tracks[src->track-1].cdte_addr.msf.second) * 75) +
- src->tracks[src->track-1].cdte_addr.msf.frame;
- fprintf(stderr,"VCDSrc: track offset is %ld\n",src->trackoffset);
+ (((src->tracks[src->track - 1].cdte_addr.msf.minute * 60) +
+ src->tracks[src->track - 1].cdte_addr.msf.second) * 75) +
+ src->tracks[src->track - 1].cdte_addr.msf.frame;
+ fprintf (stderr, "VCDSrc: track offset is %ld\n", src->trackoffset);
- GST_FLAG_SET(src,VCDSRC_OPEN);
+ GST_FLAG_SET (src, VCDSRC_OPEN);
return TRUE;
}
/* close the file */
static void
-vcdsrc_close_file (VCDSrc *src)
+vcdsrc_close_file (VCDSrc * src)
{
- g_return_if_fail(GST_FLAG_IS_SET(src,VCDSRC_OPEN));
+ g_return_if_fail (GST_FLAG_IS_SET (src, VCDSRC_OPEN));
/* close the file */
- close(src->fd);
+ close (src->fd);
/* zero out a lot of our state */
src->fd = 0;
src->curoffset = 0;
src->seq = 0;
- GST_FLAG_UNSET(src,VCDSRC_OPEN);
+ GST_FLAG_UNSET (src, VCDSRC_OPEN);
}
static GstElementStateReturn
-vcdsrc_change_state (GstElement *element)
+vcdsrc_change_state (GstElement * element)
{
- g_return_val_if_fail(GST_IS_VCDSRC(element), GST_STATE_FAILURE);
+ g_return_val_if_fail (GST_IS_VCDSRC (element), GST_STATE_FAILURE);
/* if going down into NULL state, close the file if it's open */
- if (GST_STATE_PENDING(element) == GST_STATE_NULL) {
- if (GST_FLAG_IS_SET(element,VCDSRC_OPEN))
- vcdsrc_close_file(VCDSRC(element));
- /* otherwise (READY or higher) we need to open the sound card */
+ if (GST_STATE_PENDING (element) == GST_STATE_NULL) {
+ if (GST_FLAG_IS_SET (element, VCDSRC_OPEN))
+ vcdsrc_close_file (VCDSRC (element));
+ /* otherwise (READY or higher) we need to open the sound card */
} else {
- if (!GST_FLAG_IS_SET(element,VCDSRC_OPEN)) {
- if (!vcdsrc_open_file(VCDSRC(element)))
- return GST_STATE_FAILURE;
+ if (!GST_FLAG_IS_SET (element, VCDSRC_OPEN)) {
+ if (!vcdsrc_open_file (VCDSRC (element)))
+ return GST_STATE_FAILURE;
}
}
- if (GST_ELEMENT_CLASS(parent_class)->change_state)
- return GST_ELEMENT_CLASS(parent_class)->change_state(element);
+ if (GST_ELEMENT_CLASS (parent_class)->change_state)
+ return GST_ELEMENT_CLASS (parent_class)->change_state (element);
return GST_STATE_SUCCESS;
}
static void
-vcdsrc_recalculate (VCDSrc *vcdsrc)
+vcdsrc_recalculate (VCDSrc * vcdsrc)
{
- if (GST_FLAG_IS_SET(vcdsrc,VCDSRC_OPEN)) {
+ if (GST_FLAG_IS_SET (vcdsrc, VCDSRC_OPEN)) {
/* calculate track offset (beginning of track) */
vcdsrc->trackoffset =
-(((vcdsrc->tracks[vcdsrc->track-1].cdte_addr.msf.minute * 60) +
- vcdsrc->tracks[vcdsrc->track-1].cdte_addr.msf.second) * 75) +
- vcdsrc->tracks[vcdsrc->track-1].cdte_addr.msf.frame;
- fprintf(stderr,"VCDSrc: track offset is %ld\n",vcdsrc->trackoffset);
+ (((vcdsrc->tracks[vcdsrc->track - 1].cdte_addr.msf.minute * 60) +
+ vcdsrc->tracks[vcdsrc->track - 1].cdte_addr.msf.second) * 75) +
+ vcdsrc->tracks[vcdsrc->track - 1].cdte_addr.msf.frame;
+ fprintf (stderr, "VCDSrc: track offset is %ld\n", vcdsrc->trackoffset);
}
}
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
- return gst_element_register (plugin, "vcdsrc", GST_RANK_NONE, GST_TYPE_VCDSRC);
+ return gst_element_register (plugin, "vcdsrc", GST_RANK_NONE,
+ GST_TYPE_VCDSRC);
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "vcdsrc",
- "Asynchronous read from VCD disk",
- plugin_init,
- VERSION,
- GST_LICENSE,
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "vcdsrc",
+ "Asynchronous read from VCD disk",
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define VCD_BYTES_PER_SECTOR 2352
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VCDSRC))
/* NOTE: per-element flags start with 16 for now */
-typedef enum {
- VCDSRC_OPEN = GST_ELEMENT_FLAG_LAST,
+ typedef enum
+ {
+ VCDSRC_OPEN = GST_ELEMENT_FLAG_LAST,
- VCDSRC_FLAG_LAST = GST_ELEMENT_FLAG_LAST+2,
-} VCDSrcFlags;
+ VCDSRC_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
+ } VCDSrcFlags;
-typedef struct _VCDSrc VCDSrc;
-typedef struct _VCDSrcClass VCDSrcClass;
+ typedef struct _VCDSrc VCDSrc;
+ typedef struct _VCDSrcClass VCDSrcClass;
-struct _VCDSrc {
- GstElement element;
- /* pads */
- GstPad *srcpad;
+ struct _VCDSrc
+ {
+ GstElement element;
+ /* pads */
+ GstPad *srcpad;
- /* device */
- gchar *device;
- /* track number */
- gint track;
- /* fd */
- gint fd;
+ /* device */
+ gchar *device;
+ /* track number */
+ gint track;
+ /* fd */
+ gint fd;
- struct cdrom_tochdr tochdr;
- gint numtracks;
- struct cdrom_tocentry *tracks;
+ struct cdrom_tochdr tochdr;
+ gint numtracks;
+ struct cdrom_tocentry *tracks;
- /* current time offset */
- gulong trackoffset;
- gulong frameoffset;
+ /* current time offset */
+ gulong trackoffset;
+ gulong frameoffset;
- gulong curoffset; /* current offset in file */
- gulong bytes_per_read; /* bytes per read */
+ gulong curoffset; /* current offset in file */
+ gulong bytes_per_read; /* bytes per read */
- gulong seq; /* buffer sequence number */
- int max_errors;
-};
+ gulong seq; /* buffer sequence number */
+ int max_errors;
+ };
-struct _VCDSrcClass {
- GstElementClass parent_class;
-};
+ struct _VCDSrcClass
+ {
+ GstElementClass parent_class;
+ };
-GType vcdsrc_get_type(void);
+ GType vcdsrc_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __VCDSRC_H__ */
+#endif /* __VCDSRC_H__ */