don't mix tabs and spaces

Original commit message from CVS:
don't mix tabs and spaces
This commit is contained in:
Thomas Vander Stichele 2004-03-15 19:32:25 +00:00
parent ba50741fd4
commit 9ac53e9a2a
63 changed files with 3872 additions and 3812 deletions

View file

@ -1,3 +1,7 @@
2004-03-15 Thomas Vander Stichele <thomas at apestaart dot org>
* *.c, *.cc: don't mix tabs and spaces
2004-03-15 Thomas Vander Stichele <thomas at apestaart dot org>
* gst-libs/gst/play/play.c: (gst_play_pipeline_setup):

View file

@ -72,7 +72,7 @@ main (gint argc, gchar * argv[])
/* 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 "))
"video/raw", "format", GST_PROPS_FOURCC (GST_STR_FOURCC ("RGB "))
));
if (!res) {
g_print ("could not connect colorspace and xvideosink\n");

View file

@ -15,17 +15,17 @@
/* filter UI data */
struct _filter_ui
{
GtkWidget *window; /* top-level interface window */
GtkWidget *window; /* top-level interface window */
GtkWidget *buttons; /* all of the control buttons */
GtkWidget *parse, *play, *stop; /* control buttons */
GtkWidget *buttons; /* all of the 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 *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 *control; /* the dynamically generated control UI */
GtkWidget *control; /* the dynamically generated control UI */
};
typedef struct _filter_ui _filter_ui_t;
@ -33,13 +33,13 @@ typedef struct _filter_ui _filter_ui_t;
/* 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;
};
@ -75,21 +75,21 @@ gst_bin_find_unconnected_pad (GstBin * bin, GstPadDirection direction,
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 ! */
g_print ("DEBUG: found an unconnected pad !\n");
pad = GST_PAD (pads->data);
}
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 */
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);
@ -157,37 +157,37 @@ ui_control_create (GstElement * element, GtkWidget * control, _filter_ui_t * ui)
gtk_container_add (GTK_CONTAINER (hbox), widget);
gtk_widget_show (widget);
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);
gtk_range_set_value (GTK_RANGE (widget),
(gdouble) ((GParamSpecInt64 *) specs[i])->default_value);
break;
case G_TYPE_INT64:
widget = gtk_hscale_new_with_range (
(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;
case G_TYPE_INT:
widget = gtk_hscale_new_with_range (
(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:
widget = gtk_hscale_new_with_range (
(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);
break;
case G_TYPE_INT:
widget = gtk_hscale_new_with_range (
(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:
widget = gtk_hscale_new_with_range (
(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);
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));
(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);
@ -315,7 +315,7 @@ cb_parse_clicked (GtkButton * button, gpointer * user_data)
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);
error->message);
g_error_free (error);
return;
}
@ -329,7 +329,7 @@ cb_parse_clicked (GtkButton * button, gpointer * user_data)
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);
error->message);
g_error_free (error);
return;
}
@ -340,7 +340,7 @@ cb_parse_clicked (GtkButton * button, gpointer * user_data)
fd->filter = gst_element_factory_make (fd->filter_element, "filter");
if (fd->filter == NULL) {
ui_feedback_add (fd->ui, "Error : could not create element %s\n",
fd->filter_element);
fd->filter_element);
return;
}
@ -359,14 +359,14 @@ cb_parse_clicked (GtkButton * button, gpointer * user_data)
"source");
if (src_pad == NULL) {
ui_feedback_add (fd->ui,
"Error : could not find an unconnected source pad !\n");
"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");
"Error : could not find an unconnected sink pad !\n");
return;
}
gst_element_add_pad (fd->input, src_pad);
@ -417,8 +417,8 @@ init_data (_filter_data_t * fd)
void
create_ui (_filter_ui_t * fui, _filter_data_t * fd)
{
GtkWidget *widget; /* temporary widget */
GtkWidget *vbox; /* temporary vbox */
GtkWidget *widget; /* temporary widget */
GtkWidget *vbox; /* temporary vbox */
g_print ("DEBUG: creating top-level window\n");
fui->window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
@ -480,7 +480,7 @@ create_ui (_filter_ui_t * fui, _filter_data_t * fd)
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",

View file

@ -36,7 +36,7 @@ print_tag (const GstTagList * list, const gchar * tag, gpointer unused)
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));
g_strdup_value_contents (gst_tag_list_get_value_index (list, tag, i));
}
if (i == 0) {

View file

@ -29,21 +29,21 @@ 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));
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));
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));
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;
@ -60,7 +60,8 @@ typedef struct
GstElement *bin;
GstElement *pipeline;
GstIndex *index;
} dyn_link;
}
dyn_link;
static void
dynamic_link (GstPadTemplate * templ, GstPad * newpad, gpointer data)
@ -205,18 +206,18 @@ main (gint argc, gchar * argv[])
GstElement *sink;
struct poptOption options[] = {
{"verbose", 'v', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &verbose, 0,
"Print index entries", NULL},
"Print index entries", NULL},
{"quiet", 'q', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &quiet, 0,
"don't print progress bar", NULL},
"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]);
" 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;
}
@ -225,7 +226,7 @@ main (gint argc, gchar * argv[])
if (index) {
if (verbose)
g_signal_connect (G_OBJECT (index), "entry_added",
G_CALLBACK (entry_added), NULL);
G_CALLBACK (entry_added), NULL);
g_object_set (G_OBJECT (index), "resolver", 1, NULL);
}
@ -284,7 +285,7 @@ main (gint argc, gchar * argv[])
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;

View file

@ -29,7 +29,7 @@ get_position_info (GstElement * cdparanoia)
if (format == GST_FORMAT_TIME) {
position /= GST_SECOND;
g_print ("%s: %lld:%02lld", definition->nick, position / 60,
position % 60);
position % 60);
} else {
g_print ("%s: %lld", definition->nick, position);
}
@ -72,16 +72,16 @@ get_track_info (GstElement * cdparanoia)
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);
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\n", definition->nick, total);
if (format == track_format)
total_tracks = total;
total_tracks = total;
else if (format == GST_FORMAT_TIME)
total_time = total;
total_time = total;
} else
g_print ("failed to get %s total\n", definition->nick);
@ -110,12 +110,12 @@ get_track_info (GstElement * cdparanoia)
/* for the first track (i==0) we wait until we have the
* time of the next track */
if (i > 0) {
gint64 length = time - time_count;
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 {
g_print ("could not get time for track %d\n", i);

View file

@ -47,7 +47,8 @@ typedef struct
{
const gchar *name;
const GstFormat format;
} seek_format;
}
seek_format;
static seek_format seek_formats[] = {
{"tim", GST_FORMAT_TIME},
@ -76,9 +77,9 @@ query_durations ()
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);
g_print ("%s %13lld | ", seek_formats[i].name, value);
} else {
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
}
i++;
}
@ -105,9 +106,9 @@ query_positions ()
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);
g_print ("%s %13lld | ", seek_formats[i].name, value);
} else {
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
}
i++;
}
@ -137,7 +138,7 @@ update_scale (gpointer data)
if (stats) {
if (clock)
g_print ("clock: %13llu (%s)\n", position,
gst_object_get_name (GST_OBJECT (clock)));
gst_object_get_name (GST_OBJECT (clock)));
query_durations ();
query_positions ();
}
@ -184,7 +185,7 @@ stop_seek (GtkWidget * widget, GdkEventButton * event, gpointer user_data)
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);
@ -208,7 +209,7 @@ play_cb (GtkButton * button, gpointer data)
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);
gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
}
}
@ -237,7 +238,7 @@ main (int argc, char **argv)
*play_button, *pause_button, *stop_button, *hscale;
struct poptOption options[] = {
{"stats", 's', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &stats, 0,
"Show element stats", NULL},
"Show element stats", NULL},
POPT_TABLEEND
};

View file

@ -28,7 +28,8 @@ typedef struct
const gchar *padname;
GstPad *target;
GstElement *bin;
} dyn_link;
}
dyn_link;
static GstElement *
gst_element_factory_make_or_warn (gchar * type, gchar * name)
@ -372,7 +373,7 @@ make_avi_pipeline (const gchar * location)
gst_element_set_state (audio_bin, GST_STATE_PAUSED);
setup_dynamic_link (demux, "audio_00", gst_element_get_pad (a_decoder,
"sink"), audio_bin);
"sink"), audio_bin);
seekable = gst_element_get_pad (a_queue, "src");
seekable_pads = g_list_prepend (seekable_pads, seekable);
@ -400,7 +401,7 @@ make_avi_pipeline (const gchar * location)
gst_element_set_state (video_bin, GST_STATE_PAUSED);
setup_dynamic_link (demux, "video_00", gst_element_get_pad (v_decoder,
"sink"), video_bin);
"sink"), video_bin);
seekable = gst_element_get_pad (v_queue, "src");
seekable_pads = g_list_prepend (seekable_pads, seekable);
@ -448,7 +449,7 @@ make_mpeg_pipeline (const gchar * location)
gst_bin_add (GST_BIN (audio_thread), audiosink);
setup_dynamic_link (demux, "audio_00", gst_element_get_pad (a_decoder,
"sink"), audio_bin);
"sink"), audio_bin);
seekable = gst_element_get_pad (a_queue, "src");
seekable_pads = g_list_prepend (seekable_pads, seekable);
@ -470,7 +471,7 @@ make_mpeg_pipeline (const gchar * location)
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);
"sink"), video_bin);
seekable = gst_element_get_pad (v_queue, "src");
seekable_pads = g_list_prepend (seekable_pads, seekable);
@ -519,7 +520,7 @@ make_mpegnt_pipeline (const gchar * location)
gst_bin_add (GST_BIN (audio_thread), audiosink);
setup_dynamic_link (demux, "audio_00", gst_element_get_pad (a_decoder,
"sink"), audio_bin);
"sink"), audio_bin);
seekable = gst_element_get_pad (a_queue, "src");
seekable_pads = g_list_prepend (seekable_pads, seekable);
@ -536,7 +537,7 @@ make_mpegnt_pipeline (const gchar * location)
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);
"sink"), video_bin);
seekable = gst_element_get_pad (v_decoder, "src");
seekable_pads = g_list_prepend (seekable_pads, seekable);
@ -572,7 +573,8 @@ typedef struct
{
const gchar *name;
const GstFormat format;
} seek_format;
}
seek_format;
static seek_format seek_formats[] = {
{"tim", GST_FORMAT_TIME},
@ -599,9 +601,9 @@ query_rates (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);
g_print ("%s %13lld | ", seek_formats[i].name, value);
} else {
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
}
i++;
@ -630,9 +632,9 @@ query_durations ()
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);
g_print ("%s %13lld | ", seek_formats[i].name, value);
} else {
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
}
i++;
}
@ -660,9 +662,9 @@ query_positions ()
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);
g_print ("%s %13lld | ", seek_formats[i].name, value);
} else {
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
}
i++;
}
@ -691,7 +693,7 @@ update_scale (gpointer data)
if (stats) {
g_print ("clock: %13llu (%s)\n", position,
gst_object_get_name (GST_OBJECT (clock)));
gst_object_get_name (GST_OBJECT (clock)));
query_durations ();
query_positions ();
query_rates ();
@ -740,10 +742,10 @@ stop_seek (GtkWidget * widget, GdkEventButton * event, gpointer user_data)
GstPad *seekable = GST_PAD (walk->data);
g_print ("seek to %lld on pad %s:%s\n", real,
GST_DEBUG_PAD_NAME (seekable));
GST_DEBUG_PAD_NAME (seekable));
s_event =
gst_event_new_seek (GST_FORMAT_TIME | GST_SEEK_METHOD_SET |
GST_SEEK_FLAG_FLUSH, real);
gst_event_new_seek (GST_FORMAT_TIME | GST_SEEK_METHOD_SET |
GST_SEEK_FLAG_FLUSH, real);
res = gst_pad_send_event (seekable, s_event);
@ -756,10 +758,10 @@ stop_seek (GtkWidget * widget, GdkEventButton * event, gpointer user_data)
GstElement *seekable = GST_ELEMENT (walk->data);
g_print ("seek to %lld on element %s\n", real,
gst_element_get_name (seekable));
gst_element_get_name (seekable));
s_event =
gst_event_new_seek (GST_FORMAT_TIME | GST_SEEK_METHOD_SET |
GST_SEEK_FLAG_FLUSH, real);
gst_event_new_seek (GST_FORMAT_TIME | GST_SEEK_METHOD_SET |
GST_SEEK_FLAG_FLUSH, real);
res = gst_element_send_event (seekable, s_event);
@ -782,7 +784,7 @@ play_cb (GtkButton * button, gpointer data)
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);
gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
}
}
@ -808,7 +810,8 @@ typedef struct
{
gchar *name;
GstElement *(*func) (const gchar * location);
} Pipeline;
}
Pipeline;
static Pipeline pipelines[] = {
{"mp3", make_mp3_pipeline},
@ -848,7 +851,7 @@ main (int argc, char **argv)
*play_button, *pause_button, *stop_button, *hscale;
struct poptOption options[] = {
{"stats", 's', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &stats, 0,
"Show pad stats", NULL},
"Show pad stats", NULL},
POPT_TABLEEND
};
gint type;

View file

@ -91,7 +91,8 @@ typedef struct
{
const gchar *name;
const GstFormat format;
} seek_format;
}
seek_format;
static seek_format seek_formats[] = {
{"tim", GST_FORMAT_TIME},
@ -118,9 +119,9 @@ query_rates (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);
g_print ("%s %13lld | ", seek_formats[i].name, value);
} else {
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
}
i++;
@ -149,9 +150,9 @@ query_durations ()
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);
g_print ("%s %13lld | ", seek_formats[i].name, value);
} else {
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
}
i++;
}
@ -178,9 +179,9 @@ query_positions ()
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);
g_print ("%s %13lld | ", seek_formats[i].name, value);
} else {
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
g_print ("%s %13.13s | ", seek_formats[i].name, "*NA*");
}
i++;
}
@ -208,7 +209,7 @@ update_scale (gpointer data)
if (stats) {
g_print ("clock: %13llu (%s)\n", position,
gst_object_get_name (GST_OBJECT (clock)));
gst_object_get_name (GST_OBJECT (clock)));
query_durations ();
query_positions ();
query_rates ();
@ -255,7 +256,7 @@ stop_seek (GtkWidget * widget, GdkEventButton * event, gpointer user_data)
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);
@ -279,7 +280,7 @@ play_cb (GtkButton * button, gpointer data)
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);
gtk_timeout_add (UPDATE_INTERVAL, (GtkFunction) update_scale, pipeline);
}
}
@ -309,9 +310,9 @@ main (int argc, char **argv)
gboolean threaded = FALSE;
struct poptOption options[] = {
{"threaded", 't', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &threaded, 0,
"Run the pipeline in a toplevel thread", NULL},
"Run the pipeline in a toplevel thread", NULL},
{"stats", 's', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &stats, 0,
"Show element stats", NULL},
"Show element stats", NULL},
POPT_TABLEEND
};

View file

@ -65,20 +65,20 @@ print_lbs_info (struct probe_context *context, gint stream)
/* get start and end position of this stream */
res = gst_pad_convert (context->pad,
context->ls_format, stream, &format, &value_start);
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);
g_print (" %s: %lld\n", definition->nick, value_end);
}
} else
g_print (" could not get logical stream %s\n", definition->nick);
@ -180,13 +180,13 @@ collect_stream_properties (struct probe_context *context)
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));
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);
if (format == context->ls_format)
context->total_ls = value;
g_print (" total %s: %lld\n", definition->nick, value);
}
}
}

View file

@ -47,7 +47,7 @@ main (gint argc, gchar * argv[])
if (!pipeline) {
if (error)
g_print ("ERROR: pipeline could not be constructed: %s\n",
error->message);
error->message);
else
g_print ("ERROR: pipeline could not be constructed\n");
return -1;
@ -80,18 +80,18 @@ main (gint argc, gchar * argv[])
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");

View file

@ -67,11 +67,11 @@ static GstStaticPadTemplate src_factory = 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) [ 4000, 48000 ], " "channels = (int) [ 1, 6 ]")
"endianness = (int) BYTE_ORDER, "
"signed = (boolean) true, "
"width = (int) 16, "
"depth = (int) 16, "
"rate = (int) [ 4000, 48000 ], " "channels = (int) [ 1, 6 ]")
);
static void gst_a52dec_base_init (gpointer g_class);
@ -108,7 +108,7 @@ gst_a52dec_get_type (void)
};
a52dec_type =
g_type_register_static (GST_TYPE_ELEMENT, "GstA52Dec", &a52dec_info, 0);
g_type_register_static (GST_TYPE_ELEMENT, "GstA52Dec", &a52dec_info, 0);
}
return a52dec_type;
}
@ -137,7 +137,7 @@ gst_a52dec_class_init (GstA52DecClass * klass)
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DRC,
g_param_spec_boolean ("drc", "Dynamic Range Compression",
"Use Dynamic Range Compression", FALSE, G_PARAM_READWRITE));
"Use Dynamic Range Compression", FALSE, G_PARAM_READWRITE));
gobject_class->set_property = gst_a52dec_set_property;
gobject_class->get_property = gst_a52dec_get_property;
@ -151,13 +151,13 @@ gst_a52dec_init (GstA52Dec * a52dec)
/* create the sink and src pads */
a52dec->sinkpad =
gst_pad_new_from_template (gst_element_get_pad_template (GST_ELEMENT
(a52dec), "sink"), "sink");
(a52dec), "sink"), "sink");
gst_element_add_pad (GST_ELEMENT (a52dec), a52dec->sinkpad);
gst_element_set_loop_function ((GstElement *) a52dec, gst_a52dec_loop);
a52dec->srcpad =
gst_pad_new_from_template (gst_element_get_pad_template (GST_ELEMENT
(a52dec), "src"), "src");
(a52dec), "src"), "src");
gst_pad_use_explicit_caps (a52dec->srcpad);
gst_element_add_pad (GST_ELEMENT (a52dec), a52dec->srcpad);
@ -186,87 +186,87 @@ float_to_int (float *_f, int16_t * s16, int flags)
switch (flags) {
case A52_MONO:
for (i = 0; i < 256; i++) {
s16[5 * i] = s16[5 * i + 1] = s16[5 * i + 2] = s16[5 * i + 3] = 0;
s16[5 * i + 4] = convert (f[i]);
s16[5 * i] = s16[5 * i + 1] = s16[5 * i + 2] = s16[5 * i + 3] = 0;
s16[5 * i + 4] = convert (f[i]);
}
break;
case A52_CHANNEL:
case A52_STEREO:
case A52_DOLBY:
for (i = 0; i < 256; i++) {
s16[2 * i] = convert (f[i]);
s16[2 * i + 1] = convert (f[i + 256]);
s16[2 * i] = convert (f[i]);
s16[2 * i + 1] = convert (f[i + 256]);
}
break;
case A52_3F:
for (i = 0; i < 256; i++) {
s16[5 * i] = convert (f[i]);
s16[5 * i + 1] = convert (f[i + 512]);
s16[5 * i + 2] = s16[5 * i + 3] = 0;
s16[5 * i + 4] = convert (f[i + 256]);
s16[5 * i] = convert (f[i]);
s16[5 * i + 1] = convert (f[i + 512]);
s16[5 * i + 2] = s16[5 * i + 3] = 0;
s16[5 * i + 4] = convert (f[i + 256]);
}
break;
case A52_2F2R:
for (i = 0; i < 256; i++) {
s16[4 * i] = convert (f[i]);
s16[4 * i + 1] = convert (f[i + 256]);
s16[4 * i + 2] = convert (f[i + 512]);
s16[4 * i + 3] = convert (f[i + 768]);
s16[4 * i] = convert (f[i]);
s16[4 * i + 1] = convert (f[i + 256]);
s16[4 * i + 2] = convert (f[i + 512]);
s16[4 * i + 3] = convert (f[i + 768]);
}
break;
case A52_3F2R:
for (i = 0; i < 256; i++) {
s16[5 * i] = convert (f[i]);
s16[5 * i + 1] = convert (f[i + 512]);
s16[5 * i + 2] = convert (f[i + 768]);
s16[5 * i + 3] = convert (f[i + 1024]);
s16[5 * i + 4] = convert (f[i + 256]);
s16[5 * i] = convert (f[i]);
s16[5 * i + 1] = convert (f[i + 512]);
s16[5 * i + 2] = convert (f[i + 768]);
s16[5 * i + 3] = convert (f[i + 1024]);
s16[5 * i + 4] = convert (f[i + 256]);
}
break;
case A52_MONO | A52_LFE:
for (i = 0; i < 256; i++) {
s16[6 * i] = s16[6 * i + 1] = s16[6 * i + 2] = s16[6 * i + 3] = 0;
s16[6 * i + 4] = convert (f[i + 256]);
s16[6 * i + 5] = convert (f[i]);
s16[6 * i] = s16[6 * i + 1] = s16[6 * i + 2] = s16[6 * i + 3] = 0;
s16[6 * i + 4] = convert (f[i + 256]);
s16[6 * i + 5] = convert (f[i]);
}
break;
case A52_CHANNEL | A52_LFE:
case A52_STEREO | A52_LFE:
case A52_DOLBY | A52_LFE:
for (i = 0; i < 256; i++) {
s16[6 * i] = convert (f[i + 256]);
s16[6 * i + 1] = convert (f[i + 512]);
s16[6 * i + 2] = s16[6 * i + 3] = s16[6 * i + 4] = 0;
s16[6 * i + 5] = convert (f[i]);
s16[6 * i] = convert (f[i + 256]);
s16[6 * i + 1] = convert (f[i + 512]);
s16[6 * i + 2] = s16[6 * i + 3] = s16[6 * i + 4] = 0;
s16[6 * i + 5] = convert (f[i]);
}
break;
case A52_3F | A52_LFE:
for (i = 0; i < 256; i++) {
s16[6 * i] = convert (f[i + 256]);
s16[6 * i + 1] = convert (f[i + 768]);
s16[6 * i + 2] = s16[6 * i + 3] = 0;
s16[6 * i + 4] = convert (f[i + 512]);
s16[6 * i + 5] = convert (f[i]);
s16[6 * i] = convert (f[i + 256]);
s16[6 * i + 1] = convert (f[i + 768]);
s16[6 * i + 2] = s16[6 * i + 3] = 0;
s16[6 * i + 4] = convert (f[i + 512]);
s16[6 * i + 5] = convert (f[i]);
}
break;
case A52_2F2R | A52_LFE:
for (i = 0; i < 256; i++) {
s16[6 * i] = convert (f[i + 256]);
s16[6 * i + 1] = convert (f[i + 512]);
s16[6 * i + 2] = convert (f[i + 768]);
s16[6 * i + 3] = convert (f[i + 1024]);
s16[6 * i + 4] = 0;
s16[6 * i + 5] = convert (f[i]);
s16[6 * i] = convert (f[i + 256]);
s16[6 * i + 1] = convert (f[i + 512]);
s16[6 * i + 2] = convert (f[i + 768]);
s16[6 * i + 3] = convert (f[i + 1024]);
s16[6 * i + 4] = 0;
s16[6 * i + 5] = convert (f[i]);
}
break;
case A52_3F2R | A52_LFE:
for (i = 0; i < 256; i++) {
s16[6 * i] = convert (f[i + 256]);
s16[6 * i + 1] = convert (f[i + 768]);
s16[6 * i + 2] = convert (f[i + 1024]);
s16[6 * i + 3] = convert (f[i + 1280]);
s16[6 * i + 4] = convert (f[i + 512]);
s16[6 * i + 5] = convert (f[i]);
s16[6 * i] = convert (f[i + 256]);
s16[6 * i + 1] = convert (f[i + 768]);
s16[6 * i + 2] = convert (f[i + 1024]);
s16[6 * i + 3] = convert (f[i + 1280]);
s16[6 * i + 4] = convert (f[i + 512]);
s16[6 * i + 5] = convert (f[i]);
}
break;
}
@ -349,11 +349,11 @@ gst_a52dec_reneg (GstPad * pad, int channels, int rate)
gst_pad_set_explicit_caps (pad,
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,
"channels", G_TYPE_INT, channels, "rate", G_TYPE_INT, rate, NULL));
"endianness", G_TYPE_INT, G_BYTE_ORDER,
"signed", G_TYPE_BOOLEAN, TRUE,
"width", G_TYPE_INT, 16,
"depth", G_TYPE_INT, 16,
"channels", G_TYPE_INT, channels, "rate", G_TYPE_INT, rate, NULL));
}
static void
@ -475,9 +475,9 @@ gst_a52dec_loop (GstElement * element)
if (need_reneg == TRUE) {
GST_DEBUG ("a52dec reneg: sample_rate:%d stream_chans:%d using_chans:%d\n",
a52dec->sample_rate, a52dec->stream_channels, a52dec->using_channels);
a52dec->sample_rate, a52dec->stream_channels, a52dec->using_channels);
gst_a52dec_reneg (a52dec->srcpad,
gst_a52dec_channels (a52dec->using_channels), a52dec->sample_rate);
gst_a52dec_channels (a52dec->using_channels), a52dec->sample_rate);
}
if (a52dec->dynamic_range_compression == FALSE) {
@ -491,7 +491,7 @@ gst_a52dec_loop (GstElement * element)
}
/* push on */
if (gst_a52dec_push (a52dec->srcpad, a52dec->using_channels,
a52dec->samples, timestamp)) {
a52dec->samples, timestamp)) {
g_warning ("a52dec push error\n");
} else {
timestamp += sizeof (int16_t) * 256 * GST_SECOND / a52dec->sample_rate;
@ -513,7 +513,7 @@ gst_a52dec_change_state (GstElement * element)
break;
case GST_STATE_READY_TO_PAUSED:
a52dec->bs = gst_bytestream_new (a52dec->sinkpad);
a52dec->state = a52_init (0); /* mm_accel()); */
a52dec->state = a52_init (0); /* mm_accel()); */
a52dec->samples = a52_samples (a52dec->state);
a52dec->bit_rate = -1;
a52dec->sample_rate = -1;
@ -597,7 +597,7 @@ plugin_init (GstPlugin * plugin)
return FALSE;
if (!gst_element_register (plugin, "a52dec", GST_RANK_PRIMARY,
GST_TYPE_A52DEC))
GST_TYPE_A52DEC))
return FALSE;
return TRUE;

View file

@ -113,7 +113,8 @@ typedef enum
DVDNAVSRC_OPEN = GST_ELEMENT_FLAG_LAST,
DVDNAVSRC_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
} DVDNavSrcFlags;
}
DVDNavSrcFlags;
GType dvdnavsrc_get_type (void);
@ -182,9 +183,10 @@ dvdnavsrc_get_type (void)
0,
(GInstanceInitFunc) dvdnavsrc_init,
};
dvdnavsrc_type =
g_type_register_static (GST_TYPE_ELEMENT, "DVDNavSrc", &dvdnavsrc_info,
0);
g_type_register_static (GST_TYPE_ELEMENT, "DVDNavSrc", &dvdnavsrc_info,
0);
sector_format = gst_format_register ("sector", "DVD sector");
title_format = gst_format_register ("title", "DVD title");
@ -250,24 +252,24 @@ dvdnavsrc_class_init (DVDNavSrcClass * klass)
g_object_class_install_property (gobject_class, ARG_LOCATION,
g_param_spec_string ("location", "location", "location",
NULL, G_PARAM_READWRITE));
NULL, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_TITLE_STRING,
g_param_spec_string ("title_string", "title string", "DVD title string",
NULL, G_PARAM_READABLE));
NULL, G_PARAM_READABLE));
g_object_class_install_property (gobject_class, ARG_TITLE,
g_param_spec_int ("title", "title", "title",
0, 99, 1, G_PARAM_READWRITE));
0, 99, 1, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_CHAPTER,
g_param_spec_int ("chapter", "chapter", "chapter",
0, 99, 1, G_PARAM_READWRITE));
0, 99, 1, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_ANGLE,
g_param_spec_int ("angle", "angle", "angle", 1, 9, 1, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_STREAMINFO,
g_param_spec_boxed ("streaminfo", "streaminfo", "streaminfo",
GST_TYPE_CAPS, G_PARAM_READABLE));
GST_TYPE_CAPS, G_PARAM_READABLE));
g_object_class_install_property (gobject_class, ARG_BUTTONINFO,
g_param_spec_boxed ("buttoninfo", "buttoninfo", "buttoninfo",
GST_TYPE_CAPS, G_PARAM_READABLE));
GST_TYPE_CAPS, G_PARAM_READABLE));
gobject_class->set_property = GST_DEBUG_FUNCPTR (dvdnavsrc_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (dvdnavsrc_get_property);
@ -326,13 +328,13 @@ dvdnavsrc_set_property (GObject * object, guint prop_id, const GValue * value,
/*g_return_if_fail(!GST_FLAG_IS_SET(src,GST_STATE_RUNNING)); */
if (src->location)
g_free (src->location);
g_free (src->location);
/* clear the filename if we get a NULL (is that possible?) */
if (g_value_get_string (value) == NULL)
src->location = g_strdup ("/dev/dvd");
src->location = g_strdup ("/dev/dvd");
/* otherwise set the new filename */
else
src->location = g_strdup (g_value_get_string (value));
src->location = g_strdup (g_value_get_string (value));
break;
case ARG_TITLE:
src->title = g_value_get_int (value);
@ -376,12 +378,12 @@ dvdnavsrc_get_property (GObject * object, guint prop_id, GValue * value,
break;
case ARG_TITLE_STRING:
if (!dvdnavsrc_is_open (src)) {
g_value_set_string (value, "");
g_value_set_string (value, "");
} else if (dvdnav_get_title_string (src->dvdnav, &title_string) !=
DVDNAV_STATUS_OK) {
g_value_set_string (value, "UNKNOWN");
DVDNAV_STATUS_OK) {
g_value_set_string (value, "UNKNOWN");
} else {
g_value_set_string (value, title_string);
g_value_set_string (value, title_string);
}
break;
case ARG_TITLE:
@ -417,7 +419,7 @@ dvdnavsrc_tca_seek (DVDNavSrc * src, int title, int chapter, int angle)
*/
if (dvdnav_get_number_of_titles (src->dvdnav, &titles) != DVDNAV_STATUS_OK) {
fprintf (stderr, "dvdnav_get_number_of_titles error: %s\n",
dvdnav_err_to_string (src->dvdnav));
dvdnav_err_to_string (src->dvdnav));
return FALSE;
}
fprintf (stderr, "There are %d titles on this DVD.\n", titles);
@ -434,7 +436,7 @@ dvdnavsrc_tca_seek (DVDNavSrc * src, int title, int chapter, int angle)
*/
if (dvdnav_title_play (src->dvdnav, title) != DVDNAV_STATUS_OK) {
fprintf (stderr, "dvdnav_title_play error: %s\n",
dvdnav_err_to_string (src->dvdnav));
dvdnav_err_to_string (src->dvdnav));
return FALSE;
}
@ -443,7 +445,7 @@ dvdnavsrc_tca_seek (DVDNavSrc * src, int title, int chapter, int angle)
*/
if (dvdnav_get_number_of_titles (src->dvdnav, &programs) != DVDNAV_STATUS_OK) {
fprintf (stderr, "dvdnav_get_number_of_programs error: %s\n",
dvdnav_err_to_string (src->dvdnav));
dvdnav_err_to_string (src->dvdnav));
return FALSE;
}
fprintf (stderr, "There are %d chapters in this title.\n", programs);
@ -457,9 +459,9 @@ dvdnavsrc_tca_seek (DVDNavSrc * src, int title, int chapter, int angle)
* Make sure the angle number is valid for this title.
*/
if (dvdnav_get_angle_info (src->dvdnav, &curangle,
&angles) != DVDNAV_STATUS_OK) {
&angles) != DVDNAV_STATUS_OK) {
fprintf (stderr, "dvdnav_get_angle_info error: %s\n",
dvdnav_err_to_string (src->dvdnav));
dvdnav_err_to_string (src->dvdnav));
return FALSE;
}
fprintf (stderr, "There are %d angles in this title.\n", angles);
@ -475,19 +477,19 @@ dvdnavsrc_tca_seek (DVDNavSrc * src, int title, int chapter, int angle)
if (src->chapter == 0) {
if (dvdnav_title_play (src->dvdnav, title) != DVDNAV_STATUS_OK) {
fprintf (stderr, "dvdnav_title_play error: %s\n",
dvdnav_err_to_string (src->dvdnav));
dvdnav_err_to_string (src->dvdnav));
return FALSE;
}
} else {
if (dvdnav_part_play (src->dvdnav, title, chapter) != DVDNAV_STATUS_OK) {
fprintf (stderr, "dvdnav_part_play error: %s\n",
dvdnav_err_to_string (src->dvdnav));
dvdnav_err_to_string (src->dvdnav));
return FALSE;
}
}
if (dvdnav_angle_change (src->dvdnav, angle) != DVDNAV_STATUS_OK) {
fprintf (stderr, "dvdnav_angle_change error: %s\n",
dvdnav_err_to_string (src->dvdnav));
dvdnav_err_to_string (src->dvdnav));
return FALSE;
}
@ -529,7 +531,7 @@ dvdnavsrc_update_streaminfo (DVDNavSrc * src)
gst_caps_set_simple (caps, "chapters", G_TYPE_INT, value, NULL);
}
if (dvdnavsrc_query (src->srcpad, GST_QUERY_POSITION, &chapter_format,
&value)) {
&value)) {
gst_caps_set_simple (caps, "chapter", G_TYPE_INT, value, NULL);
}
@ -560,8 +562,8 @@ dvdnavsrc_update_buttoninfo (DVDNavSrc * src)
/* Don't notify if there is no actual change */
if (gst_structure_get_int (gst_caps_get_structure (src->buttoninfo, 0),
"total", &btn_ns)
&& (btn_ns == pci->hli.hl_gi.btn_ns)) {
"total", &btn_ns)
&& (btn_ns == pci->hli.hl_gi.btn_ns)) {
return;
}
}
@ -603,82 +605,82 @@ dvdnavsrc_user_op (DVDNavSrc * src, int op)
fprintf (stderr, "user_op %d\n", op);
/* Magic user_op ids */
switch (op) {
case 0: /* None */
case 0: /* None */
break;
case 1: /* Upper */
case 1: /* Upper */
if (dvdnav_upper_button_select (src->dvdnav, pci) != DVDNAV_STATUS_OK) {
goto naverr;
goto naverr;
}
break;
case 2: /* Lower */
case 2: /* Lower */
if (dvdnav_lower_button_select (src->dvdnav, pci) != DVDNAV_STATUS_OK) {
goto naverr;
goto naverr;
}
break;
case 3: /* Left */
case 3: /* Left */
if (dvdnav_left_button_select (src->dvdnav, pci) != DVDNAV_STATUS_OK) {
goto naverr;
goto naverr;
}
break;
case 4: /* Right */
case 4: /* Right */
if (dvdnav_right_button_select (src->dvdnav, pci) != DVDNAV_STATUS_OK) {
goto naverr;
goto naverr;
}
break;
case 5: /* Activate */
case 5: /* Activate */
if (dvdnav_button_activate (src->dvdnav, pci) != DVDNAV_STATUS_OK) {
goto naverr;
goto naverr;
}
break;
case 6: /* GoUp */
case 6: /* GoUp */
if (dvdnav_go_up (src->dvdnav) != DVDNAV_STATUS_OK) {
goto naverr;
goto naverr;
}
break;
case 7: /* TopPG */
case 7: /* TopPG */
if (dvdnav_top_pg_search (src->dvdnav) != DVDNAV_STATUS_OK) {
goto naverr;
goto naverr;
}
break;
case 8: /* PrevPG */
case 8: /* PrevPG */
if (dvdnav_prev_pg_search (src->dvdnav) != DVDNAV_STATUS_OK) {
goto naverr;
goto naverr;
}
break;
case 9: /* NextPG */
case 9: /* NextPG */
if (dvdnav_next_pg_search (src->dvdnav) != DVDNAV_STATUS_OK) {
goto naverr;
goto naverr;
}
break;
case 10: /* Menu - Title */
case 10: /* Menu - Title */
if (dvdnav_menu_call (src->dvdnav, DVD_MENU_Title) != DVDNAV_STATUS_OK) {
goto naverr;
goto naverr;
}
break;
case 11: /* Menu - Root */
case 11: /* Menu - Root */
if (dvdnav_menu_call (src->dvdnav, DVD_MENU_Root) != DVDNAV_STATUS_OK) {
goto naverr;
goto naverr;
}
break;
case 12: /* Menu - Subpicture */
case 12: /* Menu - Subpicture */
if (dvdnav_menu_call (src->dvdnav,
DVD_MENU_Subpicture) != DVDNAV_STATUS_OK) {
goto naverr;
DVD_MENU_Subpicture) != DVDNAV_STATUS_OK) {
goto naverr;
}
break;
case 13: /* Menu - Audio */
case 13: /* Menu - Audio */
if (dvdnav_menu_call (src->dvdnav, DVD_MENU_Audio) != DVDNAV_STATUS_OK) {
goto naverr;
goto naverr;
}
break;
case 14: /* Menu - Angle */
case 14: /* Menu - Angle */
if (dvdnav_menu_call (src->dvdnav, DVD_MENU_Angle) != DVDNAV_STATUS_OK) {
goto naverr;
goto naverr;
}
break;
case 15: /* Menu - Part */
case 15: /* Menu - Part */
if (dvdnav_menu_call (src->dvdnav, DVD_MENU_Part) != DVDNAV_STATUS_OK) {
goto naverr;
goto naverr;
}
break;
}
@ -779,7 +781,7 @@ dvdnavsrc_print_event (DVDNavSrc * src, guint8 * data, int event, int len)
case DVDNAV_SPU_STREAM_CHANGE:
{
dvdnav_spu_stream_change_event_t *event =
(dvdnav_spu_stream_change_event_t *) data;
(dvdnav_spu_stream_change_event_t *) data;
fprintf (stderr, " physical_wide: %d\n", event->physical_wide);
fprintf (stderr, " physical_letterbox: %d\n", event->physical_letterbox);
fprintf (stderr, " physical_pan_scan: %d\n", event->physical_pan_scan);
@ -789,7 +791,7 @@ dvdnavsrc_print_event (DVDNavSrc * src, guint8 * data, int event, int len)
case DVDNAV_AUDIO_STREAM_CHANGE:
{
dvdnav_audio_stream_change_event_t *event =
(dvdnav_audio_stream_change_event_t *) data;
(dvdnav_audio_stream_change_event_t *) data;
fprintf (stderr, " physical: %d\n", event->physical);
fprintf (stderr, " logical: %d\n", event->logical);
}
@ -800,10 +802,10 @@ dvdnavsrc_print_event (DVDNavSrc * src, guint8 * data, int event, int len)
fprintf (stderr, " old_vtsN: %d\n", event->old_vtsN);
fprintf (stderr, " old_domain: %s\n",
dvdnav_get_read_domain_name (event->old_domain));
dvdnav_get_read_domain_name (event->old_domain));
fprintf (stderr, " new_vtsN: %d\n", event->new_vtsN);
fprintf (stderr, " new_domain: %s\n",
dvdnav_get_read_domain_name (event->new_domain));
dvdnav_get_read_domain_name (event->new_domain));
}
break;
case DVDNAV_CELL_CHANGE:
@ -840,15 +842,15 @@ dvdnavsrc_print_event (DVDNavSrc * src, guint8 * data, int event, int len)
dvdnav_highlight_event_t *event = (dvdnav_highlight_event_t *) data;
fprintf (stderr, " display: %s\n",
event->display == 0 ? "hide" : (event->display ==
1 ? "show" : "unknown")
);
event->display == 0 ? "hide" : (event->display ==
1 ? "show" : "unknown")
);
if (event->display == 1) {
fprintf (stderr, " palette: %08x\n", event->palette);
fprintf (stderr, " coords (%u, %u) - (%u, %u)\n", event->sx, event->sy,
event->ex, event->ey);
fprintf (stderr, " pts: %u\n", event->pts);
fprintf (stderr, " button: %u\n", event->buttonN);
fprintf (stderr, " palette: %08x\n", event->palette);
fprintf (stderr, " coords (%u, %u) - (%u, %u)\n", event->sx, event->sy,
event->ex, event->ey);
fprintf (stderr, " pts: %u\n", event->pts);
fprintf (stderr, " button: %u\n", event->buttonN);
}
}
break;
@ -900,84 +902,84 @@ dvdnavsrc_get (GstPad * pad)
buf = gst_buffer_new_and_alloc (DVD_VIDEO_LB_LEN);
if (!buf) {
GST_ELEMENT_ERROR (src, CORE, TOO_LAZY, (NULL),
("Failed to create a new GstBuffer"));
("Failed to create a new GstBuffer"));
return NULL;
}
data = GST_BUFFER_DATA (buf);
if (dvdnav_get_next_block (src->dvdnav, data, &event, &len) !=
DVDNAV_STATUS_OK) {
DVDNAV_STATUS_OK) {
GST_ELEMENT_ERROR (src, STREAM, DECODE, (NULL),
("dvdnav_get_next_block error: %s\n",
dvdnav_err_to_string (src->dvdnav)));
("dvdnav_get_next_block error: %s\n",
dvdnav_err_to_string (src->dvdnav)));
return NULL;
}
switch (event) {
case DVDNAV_NOP:
break;
break;
case DVDNAV_BLOCK_OK:
g_return_val_if_fail (GST_BUFFER_DATA (buf) != NULL, NULL);
g_return_val_if_fail (GST_BUFFER_SIZE (buf) == DVD_VIDEO_LB_LEN, NULL);
have_buf = TRUE;
break;
g_return_val_if_fail (GST_BUFFER_DATA (buf) != NULL, NULL);
g_return_val_if_fail (GST_BUFFER_SIZE (buf) == DVD_VIDEO_LB_LEN, NULL);
have_buf = TRUE;
break;
case DVDNAV_STILL_FRAME:
/* FIXME: we should pause for event->length seconds before
* dvdnav_still_skip */
dvdnavsrc_print_event (src, data, event, len);
if (dvdnav_still_skip (src->dvdnav) != DVDNAV_STATUS_OK) {
GST_ELEMENT_ERROR (src, STREAM, TOO_LAZY, (NULL),
("dvdnav_still_skip error: %s\n",
dvdnav_err_to_string (src->dvdnav)));
/* FIXME: close the stream??? */
}
break;
/* FIXME: we should pause for event->length seconds before
* dvdnav_still_skip */
dvdnavsrc_print_event (src, data, event, len);
if (dvdnav_still_skip (src->dvdnav) != DVDNAV_STATUS_OK) {
GST_ELEMENT_ERROR (src, STREAM, TOO_LAZY, (NULL),
("dvdnav_still_skip error: %s\n",
dvdnav_err_to_string (src->dvdnav)));
/* FIXME: close the stream??? */
}
break;
case DVDNAV_STOP:
GST_DEBUG ("dvdnavsrc sending eos");
gst_element_set_eos (GST_ELEMENT (src));
dvdnavsrc_close (src);
buf = GST_BUFFER (gst_event_new (GST_EVENT_EOS));
have_buf = TRUE;
break;
GST_DEBUG ("dvdnavsrc sending eos");
gst_element_set_eos (GST_ELEMENT (src));
dvdnavsrc_close (src);
buf = GST_BUFFER (gst_event_new (GST_EVENT_EOS));
have_buf = TRUE;
break;
case DVDNAV_CELL_CHANGE:
dvdnavsrc_update_streaminfo (src);
break;
dvdnavsrc_update_streaminfo (src);
break;
case DVDNAV_NAV_PACKET:
dvdnavsrc_update_buttoninfo (src);
break;
dvdnavsrc_update_buttoninfo (src);
break;
case DVDNAV_WAIT:
/* FIXME: supposed to make sure all the data has made
* it to the sinks before skipping the wait
*/
dvdnavsrc_print_event (src, data, event, len);
dvdnav_wait_skip (src->dvdnav);
break;
/* FIXME: supposed to make sure all the data has made
* it to the sinks before skipping the wait
*/
dvdnavsrc_print_event (src, data, event, len);
dvdnav_wait_skip (src->dvdnav);
break;
case DVDNAV_HOP_CHANNEL:
/* Indicates a time discontinuity, and the downstream should
* flush
*/
dvdnavsrc_print_event (src, data, event, len);
buf = GST_BUFFER (gst_event_new (GST_EVENT_DISCONTINUOUS));
have_buf = TRUE;
break;
/* Indicates a time discontinuity, and the downstream should
* flush
*/
dvdnavsrc_print_event (src, data, event, len);
buf = GST_BUFFER (gst_event_new (GST_EVENT_DISCONTINUOUS));
have_buf = TRUE;
break;
case DVDNAV_HIGHLIGHT:
dvdnavsrc_print_event (src, data, event, len);
break;
dvdnavsrc_print_event (src, data, event, len);
break;
/* SPU_STREAM_CHANGE provides MPEG stream numbers for different
* formats of the video, eg letterbox/pan&scan
*/
/* SPU_STREAM_CHANGE provides MPEG stream numbers for different
* formats of the video, eg letterbox/pan&scan
*/
case DVDNAV_SPU_STREAM_CHANGE:
/* AUDIO_STREAM_CHANGE indicates that the user selected an alternate
* audio stream (from a menu)
*/
/* AUDIO_STREAM_CHANGE indicates that the user selected an alternate
* audio stream (from a menu)
*/
case DVDNAV_AUDIO_STREAM_CHANGE:
/* VTS_CHANGE Indicates a change in VTS (Video Title Set) */
/* VTS_CHANGE Indicates a change in VTS (Video Title Set) */
case DVDNAV_VTS_CHANGE:
case DVDNAV_SPU_CLUT_CHANGE:
default:
dvdnavsrc_print_event (src, data, event, len);
break;
dvdnavsrc_print_event (src, data, event, len);
break;
}
}
return GST_DATA (buf);
@ -994,7 +996,7 @@ dvdnavsrc_open (DVDNavSrc * src)
if (dvdnav_open (&src->dvdnav, (char *) src->location) != DVDNAV_STATUS_OK) {
fprintf (stderr, "dvdnav_open error: %s location: %s\n",
dvdnav_err_to_string (src->dvdnav), src->location);
dvdnav_err_to_string (src->dvdnav), src->location);
return FALSE;
}
@ -1022,9 +1024,9 @@ dvdnavsrc_open (DVDNavSrc * src)
fprintf (stderr, "+XXX\n");
if (dvdnav_get_next_block (src->dvdnav, buf, &event,
&buflen) != DVDNAV_STATUS_OK) {
&buflen) != DVDNAV_STATUS_OK) {
fprintf (stderr, "pre seek dvdnav_get_next_block error: %s\n",
dvdnav_err_to_string (src->dvdnav));
dvdnav_err_to_string (src->dvdnav));
return FALSE;
}
dvdnavsrc_print_event (src, buf, event, buflen);
@ -1035,7 +1037,7 @@ dvdnavsrc_open (DVDNavSrc * src)
}
*/
fprintf (stderr, "pre seek dvdnav_get_next_block error: %s\n",
dvdnav_err_to_string (src->dvdnav));
dvdnav_err_to_string (src->dvdnav));
fprintf (stderr, "-XXX\n");
if (!dvdnavsrc_tca_seek (src, src->title, src->chapter, src->angle))
@ -1056,7 +1058,7 @@ dvdnavsrc_close (DVDNavSrc * src)
if (dvdnav_close (src->dvdnav) != DVDNAV_STATUS_OK) {
fprintf (stderr, "dvdnav_close error: %s\n",
dvdnav_err_to_string (src->dvdnav));
dvdnav_err_to_string (src->dvdnav));
return FALSE;
}
@ -1079,9 +1081,9 @@ dvdnavsrc_change_state (GstElement * element)
break;
case GST_STATE_READY_TO_PAUSED:
if (!dvdnavsrc_is_open (src)) {
if (!dvdnavsrc_open (src)) {
return GST_STATE_FAILURE;
}
if (!dvdnavsrc_open (src)) {
return GST_STATE_FAILURE;
}
}
src->streaminfo = NULL;
break;
@ -1091,9 +1093,9 @@ dvdnavsrc_change_state (GstElement * element)
break;
case GST_STATE_PAUSED_TO_READY:
if (dvdnavsrc_is_open (src)) {
if (!dvdnavsrc_close (src)) {
return GST_STATE_FAILURE;
}
if (!dvdnavsrc_close (src)) {
return GST_STATE_FAILURE;
}
}
break;
case GST_STATE_READY_TO_NULL:
@ -1112,7 +1114,7 @@ dvdnavsrc_get_event_mask (GstPad * pad)
{
static const GstEventMask masks[] = {
{GST_EVENT_SEEK, GST_SEEK_METHOD_SET |
GST_SEEK_METHOD_CUR | GST_SEEK_METHOD_END | GST_SEEK_FLAG_FLUSH},
GST_SEEK_METHOD_CUR | GST_SEEK_METHOD_END | GST_SEEK_FLAG_FLUSH},
/*
{GST_EVENT_SEEK_SEGMENT, GST_SEEK_METHOD_SET |
GST_SEEK_METHOD_CUR |
@ -1183,102 +1185,102 @@ dvdnavsrc_event (GstPad * pad, GstEvent * event)
offset = GST_EVENT_SEEK_OFFSET (event);
switch (format) {
default:
if (format == sector_format) {
switch (GST_EVENT_SEEK_METHOD (event)) {
case GST_SEEK_METHOD_SET:
origin = SEEK_SET;
break;
case GST_SEEK_METHOD_CUR:
origin = SEEK_CUR;
break;
case GST_SEEK_METHOD_END:
origin = SEEK_END;
break;
default:
goto error;
}
if (dvdnav_sector_search (src->dvdnav, offset, origin) !=
DVDNAV_STATUS_OK) {
goto error;
}
} else if (format == title_format) {
if (dvdnav_current_title_info (src->dvdnav, &title, &part) !=
DVDNAV_STATUS_OK) {
goto error;
}
switch (GST_EVENT_SEEK_METHOD (event)) {
case GST_SEEK_METHOD_SET:
new_title = offset;
break;
case GST_SEEK_METHOD_CUR:
new_title = title + offset;
break;
case GST_SEEK_METHOD_END:
if (dvdnav_get_number_of_titles (src->dvdnav, &titles) !=
DVDNAV_STATUS_OK) {
goto error;
}
new_title = titles + offset;
break;
default:
goto error;
}
if (dvdnav_title_play (src->dvdnav, new_title) != DVDNAV_STATUS_OK) {
goto error;
}
} else if (format == chapter_format) {
if (dvdnav_current_title_info (src->dvdnav, &title, &part) !=
DVDNAV_STATUS_OK) {
goto error;
}
switch (GST_EVENT_SEEK_METHOD (event)) {
case GST_SEEK_METHOD_SET:
new_part = offset;
break;
case GST_SEEK_METHOD_CUR:
new_part = part + offset;
break;
case GST_SEEK_METHOD_END:
if (dvdnav_get_number_of_titles (src->dvdnav, &parts) !=
DVDNAV_STATUS_OK) {
goto error;
}
new_part = parts + offset;
break;
default:
goto error;
}
/*if (dvdnav_part_search(src->dvdnav, new_part) != */
if (dvdnav_part_play (src->dvdnav, title, new_part) !=
DVDNAV_STATUS_OK) {
goto error;
}
} else if (format == angle_format) {
if (dvdnav_get_angle_info (src->dvdnav, &angle, &angles) !=
DVDNAV_STATUS_OK) {
goto error;
}
switch (GST_EVENT_SEEK_METHOD (event)) {
case GST_SEEK_METHOD_SET:
new_angle = offset;
break;
case GST_SEEK_METHOD_CUR:
new_angle = angle + offset;
break;
case GST_SEEK_METHOD_END:
new_angle = angles + offset;
break;
default:
goto error;
}
if (dvdnav_angle_change (src->dvdnav, new_angle) !=
DVDNAV_STATUS_OK) {
goto error;
}
} else {
goto error;
}
default:
if (format == sector_format) {
switch (GST_EVENT_SEEK_METHOD (event)) {
case GST_SEEK_METHOD_SET:
origin = SEEK_SET;
break;
case GST_SEEK_METHOD_CUR:
origin = SEEK_CUR;
break;
case GST_SEEK_METHOD_END:
origin = SEEK_END;
break;
default:
goto error;
}
if (dvdnav_sector_search (src->dvdnav, offset, origin) !=
DVDNAV_STATUS_OK) {
goto error;
}
} else if (format == title_format) {
if (dvdnav_current_title_info (src->dvdnav, &title, &part) !=
DVDNAV_STATUS_OK) {
goto error;
}
switch (GST_EVENT_SEEK_METHOD (event)) {
case GST_SEEK_METHOD_SET:
new_title = offset;
break;
case GST_SEEK_METHOD_CUR:
new_title = title + offset;
break;
case GST_SEEK_METHOD_END:
if (dvdnav_get_number_of_titles (src->dvdnav, &titles) !=
DVDNAV_STATUS_OK) {
goto error;
}
new_title = titles + offset;
break;
default:
goto error;
}
if (dvdnav_title_play (src->dvdnav, new_title) != DVDNAV_STATUS_OK) {
goto error;
}
} else if (format == chapter_format) {
if (dvdnav_current_title_info (src->dvdnav, &title, &part) !=
DVDNAV_STATUS_OK) {
goto error;
}
switch (GST_EVENT_SEEK_METHOD (event)) {
case GST_SEEK_METHOD_SET:
new_part = offset;
break;
case GST_SEEK_METHOD_CUR:
new_part = part + offset;
break;
case GST_SEEK_METHOD_END:
if (dvdnav_get_number_of_titles (src->dvdnav, &parts) !=
DVDNAV_STATUS_OK) {
goto error;
}
new_part = parts + offset;
break;
default:
goto error;
}
/*if (dvdnav_part_search(src->dvdnav, new_part) != */
if (dvdnav_part_play (src->dvdnav, title, new_part) !=
DVDNAV_STATUS_OK) {
goto error;
}
} else if (format == angle_format) {
if (dvdnav_get_angle_info (src->dvdnav, &angle, &angles) !=
DVDNAV_STATUS_OK) {
goto error;
}
switch (GST_EVENT_SEEK_METHOD (event)) {
case GST_SEEK_METHOD_SET:
new_angle = offset;
break;
case GST_SEEK_METHOD_CUR:
new_angle = angle + offset;
break;
case GST_SEEK_METHOD_END:
new_angle = angles + offset;
break;
default:
goto error;
}
if (dvdnav_angle_change (src->dvdnav, new_angle) !=
DVDNAV_STATUS_OK) {
goto error;
}
} else {
goto error;
}
}
src->did_seek = TRUE;
src->need_flush = GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH;
@ -1312,10 +1314,10 @@ dvdnavsrc_get_formats (GstPad * pad)
GST_FORMAT_BYTES,
GST_FORMAT_DEFAULT,
*/
0, /* filled later */
0, /* filled later */
0, /* filled later */
0, /* filled later */
0, /* filled later */
0, /* filled later */
0, /* filled later */
0, /* filled later */
0
};
static gboolean format_initialized = FALSE;
@ -1349,48 +1351,48 @@ dvdnavsrc_convert (GstPad * pad,
switch (src_format) {
case GST_FORMAT_TIME:
switch (*dest_format) {
case GST_FORMAT_BYTES:
src_value <<= 2; /* 4 bytes per sample */
case GST_FORMAT_DEFAULT:
*dest_value = src_value * 44100 / GST_SECOND;
break;
default:
if (*dest_format == track_format || *dest_format == sector_format) {
gint sector =
(src_value * 44100) / ((CD_FRAMESIZE_RAW >> 2) * GST_SECOND);
case GST_FORMAT_BYTES:
src_value <<= 2; /* 4 bytes per sample */
case GST_FORMAT_DEFAULT:
*dest_value = src_value * 44100 / GST_SECOND;
break;
default:
if (*dest_format == track_format || *dest_format == sector_format) {
gint sector =
(src_value * 44100) / ((CD_FRAMESIZE_RAW >> 2) * GST_SECOND);
if (*dest_format == sector_format) {
*dest_value = sector;
} else {
*dest_value = cdda_sector_gettrack (src->d, sector) - 1;
}
} else
return FALSE;
break;
if (*dest_format == sector_format) {
*dest_value = sector;
} else {
*dest_value = cdda_sector_gettrack (src->d, sector) - 1;
}
} else
return FALSE;
break;
}
break;
case GST_FORMAT_BYTES:
src_value >>= 2;
case GST_FORMAT_DEFAULT:
switch (*dest_format) {
case GST_FORMAT_BYTES:
*dest_value = src_value * 4;
break;
case GST_FORMAT_TIME:
*dest_value = src_value * GST_SECOND / 44100;
break;
default:
if (*dest_format == track_format || *dest_format == sector_format) {
gint sector = src_value / (CD_FRAMESIZE_RAW >> 2);
case GST_FORMAT_BYTES:
*dest_value = src_value * 4;
break;
case GST_FORMAT_TIME:
*dest_value = src_value * GST_SECOND / 44100;
break;
default:
if (*dest_format == track_format || *dest_format == sector_format) {
gint sector = src_value / (CD_FRAMESIZE_RAW >> 2);
if (*dest_format == track_format) {
*dest_value = cdda_sector_gettrack (src->d, sector) - 1;
} else {
*dest_value = sector;
}
} else
return FALSE;
break;
if (*dest_format == track_format) {
*dest_value = cdda_sector_gettrack (src->d, sector) - 1;
} else {
*dest_value = sector;
}
} else
return FALSE;
break;
}
break;
default:
@ -1398,37 +1400,37 @@ dvdnavsrc_convert (GstPad * pad,
gint sector;
if (src_format == track_format) {
/* some sanity checks */
if (src_value < 0 || src_value > src->d->tracks)
return FALSE;
/* some sanity checks */
if (src_value < 0 || src_value > src->d->tracks)
return FALSE;
sector = cdda_track_firstsector (src->d, src_value + 1);
sector = cdda_track_firstsector (src->d, src_value + 1);
} else if (src_format == sector_format) {
sector = src_value;
sector = src_value;
} else
return FALSE;
return FALSE;
switch (*dest_format) {
case GST_FORMAT_TIME:
*dest_value = ((CD_FRAMESIZE_RAW >> 2) * sector * GST_SECOND) / 44100;
break;
case GST_FORMAT_BYTES:
sector <<= 2;
case GST_FORMAT_DEFAULT:
*dest_value = (CD_FRAMESIZE_RAW >> 2) * sector;
break;
default:
if (*dest_format == sector_format) {
*dest_value = sector;
} else if (*dest_format == track_format) {
/* if we go past the last sector, make sure to report the last track */
if (sector > src->last_sector)
*dest_value = cdda_sector_gettrack (src->d, src->last_sector);
else
*dest_value = cdda_sector_gettrack (src->d, sector) - 1;
} else
return FALSE;
break;
case GST_FORMAT_TIME:
*dest_value = ((CD_FRAMESIZE_RAW >> 2) * sector * GST_SECOND) / 44100;
break;
case GST_FORMAT_BYTES:
sector <<= 2;
case GST_FORMAT_DEFAULT:
*dest_value = (CD_FRAMESIZE_RAW >> 2) * sector;
break;
default:
if (*dest_format == sector_format) {
*dest_value = sector;
} else if (*dest_format == track_format) {
/* if we go past the last sector, make sure to report the last track */
if (sector > src->last_sector)
*dest_value = cdda_sector_gettrack (src->d, src->last_sector);
else
*dest_value = cdda_sector_gettrack (src->d, sector) - 1;
} else
return FALSE;
break;
}
break;
}
@ -1446,6 +1448,7 @@ dvdnavsrc_get_query_types (GstPad * pad)
GST_QUERY_POSITION,
0
};
return src_query_types;
}
@ -1468,58 +1471,58 @@ dvdnavsrc_query (GstPad * pad, GstQueryType type,
switch (type) {
case GST_QUERY_TOTAL:
if (*format == sector_format) {
if (dvdnav_get_position (src->dvdnav, &pos, &len) != DVDNAV_STATUS_OK) {
res = FALSE;
}
*value = len;
if (dvdnav_get_position (src->dvdnav, &pos, &len) != DVDNAV_STATUS_OK) {
res = FALSE;
}
*value = len;
} else if (*format == title_format) {
if (dvdnav_get_number_of_titles (src->dvdnav,
&titles) != DVDNAV_STATUS_OK) {
res = FALSE;
}
*value = titles;
if (dvdnav_get_number_of_titles (src->dvdnav,
&titles) != DVDNAV_STATUS_OK) {
res = FALSE;
}
*value = titles;
} else if (*format == chapter_format) {
if (dvdnav_get_number_of_titles (src->dvdnav,
&parts) != DVDNAV_STATUS_OK) {
res = FALSE;
}
*value = parts;
if (dvdnav_get_number_of_titles (src->dvdnav,
&parts) != DVDNAV_STATUS_OK) {
res = FALSE;
}
*value = parts;
} else if (*format == angle_format) {
if (dvdnav_get_angle_info (src->dvdnav, &angle,
&angles) != DVDNAV_STATUS_OK) {
res = FALSE;
}
*value = angles;
if (dvdnav_get_angle_info (src->dvdnav, &angle,
&angles) != DVDNAV_STATUS_OK) {
res = FALSE;
}
*value = angles;
} else {
res = FALSE;
res = FALSE;
}
break;
case GST_QUERY_POSITION:
if (*format == sector_format) {
if (dvdnav_get_position (src->dvdnav, &pos, &len) != DVDNAV_STATUS_OK) {
res = FALSE;
}
*value = pos;
if (dvdnav_get_position (src->dvdnav, &pos, &len) != DVDNAV_STATUS_OK) {
res = FALSE;
}
*value = pos;
} else if (*format == title_format) {
if (dvdnav_current_title_info (src->dvdnav, &title,
&part) != DVDNAV_STATUS_OK) {
res = FALSE;
}
*value = title;
if (dvdnav_current_title_info (src->dvdnav, &title,
&part) != DVDNAV_STATUS_OK) {
res = FALSE;
}
*value = title;
} else if (*format == chapter_format) {
if (dvdnav_current_title_info (src->dvdnav, &title,
&part) != DVDNAV_STATUS_OK) {
res = FALSE;
}
*value = part;
if (dvdnav_current_title_info (src->dvdnav, &title,
&part) != DVDNAV_STATUS_OK) {
res = FALSE;
}
*value = part;
} else if (*format == angle_format) {
if (dvdnav_get_angle_info (src->dvdnav, &angle,
&angles) != DVDNAV_STATUS_OK) {
res = FALSE;
}
*value = angle;
if (dvdnav_get_angle_info (src->dvdnav, &angle,
&angles) != DVDNAV_STATUS_OK) {
res = FALSE;
}
*value = angle;
} else {
res = FALSE;
res = FALSE;
}
break;
default:
@ -1533,7 +1536,7 @@ static gboolean
plugin_init (GstPlugin * plugin)
{
if (!gst_element_register (plugin, "dvdnavsrc", GST_RANK_NONE,
GST_TYPE_DVDNAVSRC))
GST_TYPE_DVDNAVSRC))
return FALSE;
return TRUE;

View file

@ -148,9 +148,10 @@ dvdreadsrc_get_type (void)
0,
(GInstanceInitFunc) dvdreadsrc_init,
};
dvdreadsrc_type =
g_type_register_static (GST_TYPE_ELEMENT, "DVDReadSrc",
&dvdreadsrc_info, 0);
g_type_register_static (GST_TYPE_ELEMENT, "DVDReadSrc",
&dvdreadsrc_info, 0);
}
return dvdreadsrc_type;
}
@ -176,16 +177,16 @@ dvdreadsrc_class_init (DVDReadSrcClass * klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATION,
g_param_spec_string ("location", "location", "location",
NULL, G_PARAM_READWRITE));
NULL, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TITLE,
g_param_spec_int ("title", "title", "title",
0, G_MAXINT, 0, G_PARAM_READWRITE));
0, G_MAXINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_CHAPTER,
g_param_spec_int ("chapter", "chapter", "chapter",
0, G_MAXINT, 0, G_PARAM_READWRITE));
0, G_MAXINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ANGLE,
g_param_spec_int ("angle", "angle", "angle",
0, G_MAXINT, 0, G_PARAM_READWRITE));
0, G_MAXINT, 0, G_PARAM_READWRITE));
gobject_class->set_property = GST_DEBUG_FUNCPTR (dvdreadsrc_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (dvdreadsrc_get_property);
@ -239,13 +240,13 @@ dvdreadsrc_set_property (GObject * object, guint prop_id, const GValue * value,
/*g_return_if_fail(!GST_FLAG_IS_SET(src,GST_STATE_RUNNING)); */
if (priv->location)
g_free (priv->location);
g_free (priv->location);
/* clear the filename if we get a NULL (is that possible?) */
if (g_value_get_string (value) == NULL)
priv->location = g_strdup ("/dev/dvd");
priv->location = g_strdup ("/dev/dvd");
/* otherwise set the new filename */
else
priv->location = g_strdup (g_value_get_string (value));
priv->location = g_strdup (g_value_get_string (value));
break;
case ARG_TITLE:
priv->title = g_value_get_int (value) - 1;
@ -399,7 +400,7 @@ _seek (DVDReadSrcPrivate * priv, int title, int chapter, int angle)
ifoOpen (priv->dvd, priv->tt_srpt->title[title].title_set_nr);
if (!priv->vts_file) {
fprintf (stderr, "Can't open the title %d info file.\n",
priv->tt_srpt->title[title].title_set_nr);
priv->tt_srpt->title[title].title_set_nr);
ifoClose (priv->vmg_file);
DVDClose (priv->dvd);
return -1;
@ -426,7 +427,7 @@ _seek (DVDReadSrcPrivate * priv, int title, int chapter, int angle)
DVD_READ_TITLE_VOBS);
if (!priv->dvd_title) {
fprintf (stderr, "Can't open title VOBS (VTS_%02d_1.VOB).\n",
priv->tt_srpt->title[title].title_set_nr);
priv->tt_srpt->title[title].title_set_nr);
ifoClose (priv->vts_file);
ifoClose (priv->vmg_file);
DVDClose (priv->dvd);
@ -460,16 +461,16 @@ dvdreadsrc_loop (GstElement * element)
/* Check if we're entering an angle block. */
if (priv->cur_pgc->cell_playback[priv->cur_cell].block_type
== BLOCK_TYPE_ANGLE_BLOCK) {
== BLOCK_TYPE_ANGLE_BLOCK) {
int i;
priv->cur_cell += priv->angle;
for (i = 0;; ++i) {
if (priv->cur_pgc->cell_playback[priv->cur_cell + i].block_mode
== BLOCK_MODE_LAST_CELL) {
priv->next_cell = priv->cur_cell + i + 1;
break;
}
if (priv->cur_pgc->cell_playback[priv->cur_cell + i].block_mode
== BLOCK_MODE_LAST_CELL) {
priv->next_cell = priv->cur_cell + i + 1;
break;
}
}
} else {
priv->next_cell = priv->cur_cell + 1;
@ -480,9 +481,9 @@ dvdreadsrc_loop (GstElement * element)
* We loop until we're out of this cell.
*/
for (priv->cur_pack =
priv->cur_pgc->cell_playback[priv->cur_cell].first_sector;
priv->cur_pack <
priv->cur_pgc->cell_playback[priv->cur_cell].last_sector;) {
priv->cur_pgc->cell_playback[priv->cur_cell].first_sector;
priv->cur_pack <
priv->cur_pgc->cell_playback[priv->cur_cell].last_sector;) {
dsi_t dsi_pack;
unsigned int next_vobu, next_ilvu_start, cur_output_size;
@ -501,20 +502,20 @@ dvdreadsrc_loop (GstElement * element)
g_return_if_fail (GST_BUFFER_DATA (buf) != NULL);
/**
/**
* Read NAV packet.
*/
len = DVDReadBlocks (priv->dvd_title, priv->cur_pack, 1, data);
if (len == 0) {
fprintf (stderr, "Read failed for block %d\n", priv->cur_pack);
_close (priv);
gst_element_set_eos (GST_ELEMENT (dvdreadsrc));
return;
fprintf (stderr, "Read failed for block %d\n", priv->cur_pack);
_close (priv);
gst_element_set_eos (GST_ELEMENT (dvdreadsrc));
return;
}
assert (is_nav_pack (data));
/**
/**
* Parse the contained dsi packet.
*/
navRead_DSI (&dsi_pack, &(data[DSI_START_BYTE]));
@ -522,16 +523,16 @@ dvdreadsrc_loop (GstElement * element)
/*navPrint_DSI(&dsi_pack); */
/**
/**
* Determine where we go next. These values are the ones we mostly
* care about.
*/
next_ilvu_start = priv->cur_pack
+ dsi_pack.sml_agli.data[priv->angle].address;
+ dsi_pack.sml_agli.data[priv->angle].address;
cur_output_size = dsi_pack.dsi_gi.vobu_ea;
/**
/**
* If we're not at the end of this cell, we can determine the next
* VOBU to display using the VOBU_SRI information section of the
* DSI. Using this value correctly follows the current angle,
@ -542,25 +543,25 @@ dvdreadsrc_loop (GstElement * element)
* force the code above to go to the next cell in the program.
*/
if (dsi_pack.vobu_sri.next_vobu != SRI_END_OF_CELL) {
next_vobu = priv->cur_pack + (dsi_pack.vobu_sri.next_vobu & 0x7fffffff);
next_vobu = priv->cur_pack + (dsi_pack.vobu_sri.next_vobu & 0x7fffffff);
} else {
next_vobu = priv->cur_pack + cur_output_size + 1;
next_vobu = priv->cur_pack + cur_output_size + 1;
}
assert (cur_output_size < 1024);
priv->cur_pack++;
/**
/**
* Read in and output cursize packs.
*/
len = DVDReadBlocks (priv->dvd_title, priv->cur_pack,
cur_output_size, data);
cur_output_size, data);
if (len != cur_output_size) {
fprintf (stderr, "Read failed for %d blocks at %d\n",
cur_output_size, priv->cur_pack);
_close (priv);
gst_element_set_eos (GST_ELEMENT (dvdreadsrc));
return;
fprintf (stderr, "Read failed for %d blocks at %d\n",
cur_output_size, priv->cur_pack);
_close (priv);
gst_element_set_eos (GST_ELEMENT (dvdreadsrc));
return;
}
GST_BUFFER_SIZE (buf) = cur_output_size * DVD_VIDEO_LB_LEN;
@ -591,59 +592,59 @@ _read (DVDReadSrcPrivate * priv, int angle, int new_seek, GstBuffer * buf)
/* Check if we're entering an angle block. */
if (priv->cur_pgc->cell_playback[priv->cur_cell].block_type
== BLOCK_TYPE_ANGLE_BLOCK) {
== BLOCK_TYPE_ANGLE_BLOCK) {
int i;
priv->cur_cell += angle;
for (i = 0;; ++i) {
if (priv->cur_pgc->cell_playback[priv->cur_cell + i].block_mode
== BLOCK_MODE_LAST_CELL) {
priv->next_cell = priv->cur_cell + i + 1;
break;
}
if (priv->cur_pgc->cell_playback[priv->cur_cell + i].block_mode
== BLOCK_MODE_LAST_CELL) {
priv->next_cell = priv->cur_cell + i + 1;
break;
}
}
} else {
priv->next_cell = priv->cur_cell + 1;
}
/**
/**
* We loop until we're out of this cell.
*/
if (priv->new_cell) {
priv->cur_pack =
priv->cur_pgc->cell_playback[priv->cur_cell].first_sector;
priv->cur_pgc->cell_playback[priv->cur_cell].first_sector;
priv->new_cell = FALSE;
}
if (priv->cur_pack <
priv->cur_pgc->cell_playback[priv->cur_cell].last_sector;) {
priv->cur_pgc->cell_playback[priv->cur_cell].last_sector;) {
dsi_t dsi_pack;
unsigned int next_vobu, next_ilvu_start, cur_output_size;
int len;
/**
/**
* Read NAV packet.
*/
len = DVDReadBlocks (priv->title, priv->cur_pack, 1, data);
if (len == 0) {
fprintf (stderr, "Read failed for block %d\n", priv->cur_pack);
_close (priv);
return -1;
fprintf (stderr, "Read failed for block %d\n", priv->cur_pack);
_close (priv);
return -1;
}
assert (is_nav_pack (data));
/**
/**
* Parse the contained dsi packet.
*/
navRead_DSI (&dsi_pack, &(data[DSI_START_BYTE]), sizeof (dsi_t));
assert (priv->cur_pack == dsi_pack.dsi_gi.nv_pck_lbn);
/**
/**
* Determine where we go next. These values are the ones we mostly
* care about.
*/
@ -651,7 +652,7 @@ _read (DVDReadSrcPrivate * priv, int angle, int new_seek, GstBuffer * buf)
cur_output_size = dsi_pack.dsi_gi.vobu_ea;
/**
/**
* If we're not at the end of this cell, we can determine the next
* VOBU to display using the VOBU_SRI information section of the
* DSI. Using this value correctly follows the current angle,
@ -662,23 +663,23 @@ _read (DVDReadSrcPrivate * priv, int angle, int new_seek, GstBuffer * buf)
* force the code above to go to the next cell in the program.
*/
if (dsi_pack.vobu_sri.next_vobu != SRI_END_OF_CELL) {
next_vobu = priv->cur_pack + (dsi_pack.vobu_sri.next_vobu & 0x7fffffff);
next_vobu = priv->cur_pack + (dsi_pack.vobu_sri.next_vobu & 0x7fffffff);
} else {
next_vobu = priv->cur_pack + cur_output_size + 1;
next_vobu = priv->cur_pack + cur_output_size + 1;
}
assert (cur_output_size < 1024);
priv->cur_pack++;
/**
/**
* Read in and output cursize packs.
*/
len = DVDReadBlocks (priv->title, priv->cur_pack, cur_output_size, data);
if (len != cur_output_size) {
fprintf (stderr, "Read failed for %d blocks at %d\n",
cur_output_size, priv->cur_pack);
_close (priv);
return -1;
fprintf (stderr, "Read failed for %d blocks at %d\n",
cur_output_size, priv->cur_pack);
_close (priv);
return -1;
}
GST_BUFFER_SIZE (buf) = cur_output_size * DVD_VIDEO_LB_LEN;
@ -776,7 +777,7 @@ dvdreadsrc_change_state (GstElement * element)
} else {
if (!GST_FLAG_IS_SET (element, DVDREADSRC_OPEN)) {
if (!dvdreadsrc_open_file (DVDREADSRC (element)))
return GST_STATE_FAILURE;
return GST_STATE_FAILURE;
}
}
@ -791,7 +792,7 @@ static gboolean
plugin_init (GstPlugin * plugin)
{
if (!gst_element_register (plugin, "dvdreadsrc", GST_RANK_NONE,
GST_TYPE_DVDREADSRC))
GST_TYPE_DVDREADSRC))
return FALSE;
return TRUE;

View file

@ -36,12 +36,12 @@ 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, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000 }, "
"channels = (int) [ 1, 2 ]")
"endianness = (int) BYTE_ORDER, "
"signed = (boolean) true, "
"width = (int) 16, "
"depth = (int) 16, "
"rate = (int) { 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000 }, "
"channels = (int) [ 1, 2 ]")
);
static GstStaticPadTemplate gst_lame_src_template =
@ -49,10 +49,10 @@ GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/mpeg, "
"mpegversion = (int) 1, "
"layer = (int) 3, "
"rate = (int) { 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000 }, "
"channels = (int) [ 1, 2 ]")
"mpegversion = (int) 1, "
"layer = (int) 3, "
"rate = (int) { 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000 }, "
"channels = (int) [ 1, 2 ]")
);
/********** Define useful types for non-programmatic interfaces **********/
@ -69,6 +69,7 @@ gst_lame_mode_get_type (void)
{4, "4", "Auto"},
{0, NULL, NULL},
};
if (!lame_mode_type) {
lame_mode_type = g_enum_register_static ("GstLameMode", lame_modes);
}
@ -93,6 +94,7 @@ gst_lame_quality_get_type (void)
{9, "9", "9 - Worst"},
{0, NULL, NULL},
};
if (!lame_quality_type) {
lame_quality_type = g_enum_register_static ("GstLameQuality", lame_quality);
}
@ -110,6 +112,7 @@ gst_lame_padding_get_type (void)
{2, "2", "Adjust Padding"},
{0, NULL, NULL},
};
if (!lame_padding_type) {
lame_padding_type = g_enum_register_static ("GstLamePadding", lame_padding);
}
@ -200,9 +203,9 @@ gst_lame_get_type (void)
};
gst_lame_type =
g_type_register_static (GST_TYPE_ELEMENT, "GstLame", &gst_lame_info, 0);
g_type_register_static (GST_TYPE_ELEMENT, "GstLame", &gst_lame_info, 0);
g_type_add_interface_static (gst_lame_type, GST_TYPE_TAG_SETTER,
&tag_setter_info);
&tag_setter_info);
}
return gst_lame_type;
@ -233,104 +236,104 @@ gst_lame_class_init (GstLameClass * klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BITRATE,
g_param_spec_int ("bitrate", "Bitrate (kb/s)", "Bitrate in kbit/sec",
8, 320, 128, G_PARAM_READWRITE));
8, 320, 128, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass),
ARG_COMPRESSION_RATIO, g_param_spec_float ("compression_ratio",
"Compression Ratio",
"choose bitrate to achive selected compression ratio", 1.0, 200.0,
11.0, G_PARAM_READWRITE));
"Compression Ratio",
"choose bitrate to achive selected compression ratio", 1.0, 200.0,
11.0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_QUALITY,
g_param_spec_enum ("quality", "Quality", "Encoding Quality",
GST_TYPE_LAME_QUALITY, 5, G_PARAM_READWRITE));
GST_TYPE_LAME_QUALITY, 5, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MODE,
g_param_spec_enum ("mode", "Mode", "Encoding mode", GST_TYPE_LAME_MODE, 0,
G_PARAM_READWRITE));
G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FORCE_MS,
g_param_spec_boolean ("force_ms", "Force ms",
"Force ms_stereo on all frames", TRUE, G_PARAM_READWRITE));
"Force ms_stereo on all frames", TRUE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FREE_FORMAT,
g_param_spec_boolean ("free_format", "Free format",
"Produce a free format bitstream", TRUE, G_PARAM_READWRITE));
"Produce a free format bitstream", TRUE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_COPYRIGHT,
g_param_spec_boolean ("copyright", "Copyright", "Mark as copyright", TRUE,
G_PARAM_READWRITE));
G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ORIGINAL,
g_param_spec_boolean ("original", "Original", "Mark as non-original",
TRUE, G_PARAM_READWRITE));
TRUE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ERROR_PROTECTION,
g_param_spec_boolean ("error_protection", "Error protection",
"Adds 16 bit checksum to every frame", TRUE, G_PARAM_READWRITE));
"Adds 16 bit checksum to every frame", TRUE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PADDING_TYPE,
g_param_spec_enum ("padding_type", "Padding type", "Padding type",
GST_TYPE_LAME_PADDING, 0, G_PARAM_READWRITE));
GST_TYPE_LAME_PADDING, 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_EXTENSION,
g_param_spec_boolean ("extension", "Extension", "Extension", TRUE,
G_PARAM_READWRITE));
G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_STRICT_ISO,
g_param_spec_boolean ("strict_iso", "Strict ISO",
"Comply as much as possible to ISO MPEG spec", TRUE,
G_PARAM_READWRITE));
"Comply as much as possible to ISO MPEG spec", TRUE,
G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass),
ARG_DISABLE_RESERVOIR, g_param_spec_boolean ("disable_reservoir",
"Disable reservoir", "Disable the bit reservoir", TRUE,
G_PARAM_READWRITE));
"Disable reservoir", "Disable the bit reservoir", TRUE,
G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VBR,
g_param_spec_boolean ("vbr", "VBR", "Use variable bitrate", TRUE,
G_PARAM_READWRITE));
G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VBR_MEAN_BITRATE,
g_param_spec_int ("vbr_mean_bitrate", "VBR mean bitrate",
"Specify mean bitrate", 0, G_MAXINT, 0, G_PARAM_READWRITE));
"Specify mean bitrate", 0, G_MAXINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VBR_MIN_BITRATE,
g_param_spec_int ("vbr_min_bitrate", "VBR min bitrate",
"Specify min bitrate", 0, G_MAXINT, 0, G_PARAM_READWRITE));
"Specify min bitrate", 0, G_MAXINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VBR_MAX_BITRATE,
g_param_spec_int ("vbr_max_bitrate", "VBR max bitrate",
"Specify max bitrate", 0, G_MAXINT, 0, G_PARAM_READWRITE));
"Specify max bitrate", 0, G_MAXINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VBR_HARD_MIN,
g_param_spec_int ("vbr_hard_min", "VBR hard min",
"Specify hard min bitrate", 0, G_MAXINT, 0, G_PARAM_READWRITE));
"Specify hard min bitrate", 0, G_MAXINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOWPASS_FREQ,
g_param_spec_int ("lowpass_freq", "Lowpass freq",
"frequency(kHz), lowpass filter cutoff above freq", 0, 50000, 0,
G_PARAM_READWRITE));
"frequency(kHz), lowpass filter cutoff above freq", 0, 50000, 0,
G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOWPASS_WIDTH,
g_param_spec_int ("lowpass_width", "Lowpass width",
"frequency(kHz) - default 15% of lowpass freq", 0, G_MAXINT, 0,
G_PARAM_READWRITE));
"frequency(kHz) - default 15% of lowpass freq", 0, G_MAXINT, 0,
G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_HIGHPASS_FREQ,
g_param_spec_int ("highpass_freq", "Highpass freq",
"frequency(kHz), highpass filter cutoff below freq", 0, 50000, 0,
G_PARAM_READWRITE));
"frequency(kHz), highpass filter cutoff below freq", 0, 50000, 0,
G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_HIGHPASS_WIDTH,
g_param_spec_int ("highpass_width", "Highpass width",
"frequency(kHz) - default 15% of highpass freq", 0, G_MAXINT, 0,
G_PARAM_READWRITE));
"frequency(kHz) - default 15% of highpass freq", 0, G_MAXINT, 0,
G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ATH_ONLY,
g_param_spec_boolean ("ath_only", "ATH only",
"Ignore GPSYCHO completely, use ATH only", TRUE, G_PARAM_READWRITE));
"Ignore GPSYCHO completely, use ATH only", TRUE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ATH_SHORT,
g_param_spec_boolean ("ath_short", "ATH short",
"Ignore GPSYCHO for short blocks, use ATH only", TRUE,
G_PARAM_READWRITE));
"Ignore GPSYCHO for short blocks, use ATH only", TRUE,
G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NO_ATH,
g_param_spec_boolean ("no_ath", "No ath",
"turns ATH down to a flat noise floor", TRUE, G_PARAM_READWRITE));
"turns ATH down to a flat noise floor", TRUE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ATH_LOWER,
g_param_spec_int ("ath_lower", "ATH lower", "lowers ATH by x dB",
G_MININT, G_MAXINT, 0, G_PARAM_READWRITE));
G_MININT, G_MAXINT, 0, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_CWLIMIT,
g_param_spec_int ("cwlimit", "Cwlimit",
"Compute tonality up to freq (in kHz) default 8.8717", 0, 50000, 0,
G_PARAM_READWRITE));
"Compute tonality up to freq (in kHz) default 8.8717", 0, 50000, 0,
G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ALLOW_DIFF_SHORT,
g_param_spec_boolean ("allow_diff_short", "Allow diff short",
"Allow diff short", TRUE, G_PARAM_READWRITE));
"Allow diff short", TRUE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NO_SHORT_BLOCKS,
g_param_spec_boolean ("no_short_blocks", "No short blocks",
"Do not use short blocks", TRUE, G_PARAM_READWRITE));
"Do not use short blocks", TRUE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_EMPHASIS,
g_param_spec_boolean ("emphasis", "Emphasis", "Emphasis", TRUE,
G_PARAM_READWRITE));
G_PARAM_READWRITE));
gobject_class->set_property = gst_lame_set_property;
gobject_class->get_property = gst_lame_get_property;
@ -354,7 +357,7 @@ gst_lame_sink_link (GstPad * pad, const GstCaps * caps)
if (!gst_lame_setup (lame)) {
GST_ELEMENT_ERROR (lame, CORE, NEGOTIATION, (NULL),
("could not initialize encoder (wrong parameters?)"));
("could not initialize encoder (wrong parameters?)"));
return GST_PAD_LINK_REFUSED;
}
@ -480,16 +483,16 @@ add_one_tag (const GstTagList * list, const gchar * tag, gpointer user_data)
guint ivalue;
if (!gst_tag_list_get_uint (list, tag, &ivalue)) {
GST_DEBUG ("Error reading \"%s\" tag value\n", tag);
return;
GST_DEBUG ("Error reading \"%s\" tag value\n", tag);
return;
}
value = g_strdup_printf ("%u", ivalue);
break;
}
case G_TYPE_STRING:
if (!gst_tag_list_get_string (list, tag, &value)) {
GST_DEBUG ("Error reading \"%s\" tag value\n", tag);
return;
GST_DEBUG ("Error reading \"%s\" tag value\n", tag);
return;
};
break;
default:
@ -757,27 +760,27 @@ gst_lame_chain (GstPad * pad, GstData * _data)
if (GST_IS_EVENT (buf)) {
switch (GST_EVENT_TYPE (buf)) {
case GST_EVENT_EOS:
eos = TRUE;
eos = TRUE;
case GST_EVENT_FLUSH:
mp3_buffer_size = 7200;
mp3_data = g_malloc (mp3_buffer_size);
mp3_buffer_size = 7200;
mp3_data = g_malloc (mp3_buffer_size);
mp3_size = lame_encode_flush (lame->lgf, mp3_data, mp3_buffer_size);
gst_event_unref (GST_EVENT (buf));
break;
mp3_size = lame_encode_flush (lame->lgf, mp3_data, mp3_buffer_size);
gst_event_unref (GST_EVENT (buf));
break;
case GST_EVENT_TAG:
if (lame->tags) {
gst_tag_list_insert (lame->tags,
gst_event_tag_get_list (GST_EVENT (buf)),
gst_tag_setter_get_merge_mode (GST_TAG_SETTER (lame)));
} else {
g_assert_not_reached ();
}
// gst_pad_event_default (pad, GST_EVENT (buf));
break;
if (lame->tags) {
gst_tag_list_insert (lame->tags,
gst_event_tag_get_list (GST_EVENT (buf)),
gst_tag_setter_get_merge_mode (GST_TAG_SETTER (lame)));
} else {
g_assert_not_reached ();
}
// gst_pad_event_default (pad, GST_EVENT (buf));
break;
default:
gst_pad_event_default (pad, GST_EVENT (buf));
break;
gst_pad_event_default (pad, GST_EVENT (buf));
break;
}
} else {
gint64 duration;
@ -785,37 +788,37 @@ gst_lame_chain (GstPad * pad, GstData * _data)
if (!lame->initialized) {
gst_buffer_unref (buf);
GST_ELEMENT_ERROR (lame, CORE, NEGOTIATION, (NULL),
("encoder not initialized (input is not audio?)"));
("encoder not initialized (input is not audio?)"));
return;
}
/* allocate space for output */
mp3_buffer_size =
((GST_BUFFER_SIZE (buf) / (2 + lame->num_channels)) * 1.25) + 7200;
((GST_BUFFER_SIZE (buf) / (2 + lame->num_channels)) * 1.25) + 7200;
mp3_data = g_malloc (mp3_buffer_size);
if (lame->num_channels == 2) {
mp3_size = lame_encode_buffer_interleaved (lame->lgf,
(short int *) (GST_BUFFER_DATA (buf)),
GST_BUFFER_SIZE (buf) / 4, mp3_data, mp3_buffer_size);
(short int *) (GST_BUFFER_DATA (buf)),
GST_BUFFER_SIZE (buf) / 4, mp3_data, mp3_buffer_size);
} else {
mp3_size = lame_encode_buffer (lame->lgf,
(short int *) (GST_BUFFER_DATA (buf)),
(short int *) (GST_BUFFER_DATA (buf)),
GST_BUFFER_SIZE (buf) / 2, mp3_data, mp3_buffer_size);
(short int *) (GST_BUFFER_DATA (buf)),
(short int *) (GST_BUFFER_DATA (buf)),
GST_BUFFER_SIZE (buf) / 2, mp3_data, mp3_buffer_size);
}
GST_DEBUG ("encoded %d bytes of audio to %d bytes of mp3",
GST_BUFFER_SIZE (buf), mp3_size);
GST_BUFFER_SIZE (buf), mp3_size);
duration = (GST_SECOND * GST_BUFFER_SIZE (buf) /
(2 * lame->samplerate * lame->num_channels));
(2 * lame->samplerate * lame->num_channels));
if (GST_BUFFER_DURATION (buf) != GST_CLOCK_TIME_NONE &&
GST_BUFFER_DURATION (buf) != duration)
GST_BUFFER_DURATION (buf) != duration)
GST_DEBUG ("mad: incoming buffer had incorrect duration %lld, "
"outgoing buffer will have correct duration %lld",
GST_BUFFER_DURATION (buf), duration);
"outgoing buffer will have correct duration %lld",
GST_BUFFER_DURATION (buf), duration);
if (lame->last_ts == GST_CLOCK_TIME_NONE) {
lame->last_ts = GST_BUFFER_TIMESTAMP (buf);
@ -908,7 +911,7 @@ gst_lame_setup (GstLame * lame)
lame->initialized = TRUE;
/* FIXME: it would be nice to print out the mode here */
GST_INFO ("lame encoder initialized (%d kbit/s, %d Hz, %d channels)",
lame->bitrate, lame->samplerate, lame->num_channels);
lame->bitrate, lame->samplerate, lame->num_channels);
}
GST_DEBUG_OBJECT (lame, "done with setup");
@ -933,8 +936,8 @@ gst_lame_change_state (GstElement * element)
break;
case GST_STATE_READY_TO_NULL:
if (lame->initialized) {
lame_close (lame->lgf);
lame->initialized = FALSE;
lame_close (lame->lgf);
lame->initialized = FALSE;
}
break;
default:

View file

@ -47,7 +47,8 @@ typedef enum
GST_ID3_TAG_STATE_SEEKING_TO_NORMAL,
GST_ID3_TAG_STATE_NORMAL_START,
GST_ID3_TAG_STATE_NORMAL,
} GstID3TagState;
}
GstID3TagState;
typedef enum
{
@ -55,7 +56,8 @@ typedef enum
GST_ID3_TAG_PARSE_TAG,
GST_ID3_TAG_PARSE_WRITE,
GST_ID3_TAG_PARSE_PARSE
} GstID3ParseMode;
}
GstID3ParseMode;
struct _GstID3Tag
{
@ -181,14 +183,14 @@ gst_id3_tag_get_type (void)
};
id3_tag_type =
g_type_register_static (GST_TYPE_ELEMENT, "GstID3Tag", &id3_tag_info,
0);
g_type_register_static (GST_TYPE_ELEMENT, "GstID3Tag", &id3_tag_info,
0);
g_type_add_interface_static (id3_tag_type, GST_TYPE_TAG_SETTER,
&tag_setter_info);
&tag_setter_info);
GST_DEBUG_CATEGORY_INIT (gst_id3_tag_debug, "id3tag", 0,
"id3 tag reader / setter");
"id3 tag reader / setter");
}
return id3_tag_type;
}
@ -219,16 +221,16 @@ gst_id3_tag_class_init (GstID3TagClass * klass)
g_object_class_install_property (gobject_class, ARG_V1_TAG,
g_param_spec_boolean ("v1-tag", "add version 1 tag",
"Add version 1 tag at end of file", FALSE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
"Add version 1 tag at end of file", FALSE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
g_object_class_install_property (gobject_class, ARG_V2_TAG,
g_param_spec_boolean ("v2-tag", "add version 2 tag",
"Add version 2 tag at start of file", TRUE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
"Add version 2 tag at start of file", TRUE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
g_object_class_install_property (gobject_class, ARG_PREFER_V1,
g_param_spec_boolean ("prefer-v1", "prefer version 1 tag",
"Prefer tags from tag at end of file", FALSE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
"Prefer tags from tag at end of file", FALSE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_id3_tag_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_id3_tag_get_property);
@ -351,6 +353,7 @@ gst_id3_tag_get_event_masks (GstPad * pad)
{GST_EVENT_SEEK, GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH},
{0,}
};
return gst_id3_tag_src_event_masks;
}
static const GstQueryType *
@ -361,6 +364,7 @@ gst_id3_tag_get_query_types (GstPad * pad)
GST_QUERY_POSITION,
0
};
return gst_id3_tag_src_query_types;
}
@ -376,37 +380,37 @@ gst_id3_tag_src_query (GstPad * pad, GstQueryType type,
switch (type) {
case GST_QUERY_TOTAL:{
switch (*format) {
case GST_FORMAT_BYTES:
if (GST_PAD_PEER (tag->sinkpad) &&
tag->state == GST_ID3_TAG_STATE_NORMAL &&
gst_pad_query (GST_PAD_PEER (tag->sinkpad), GST_QUERY_TOTAL,
format, value)) {
*value -= tag->v2tag_size + tag->v1tag_size;
*value += tag->v2tag_size_new + tag->v1tag_size_new;
res = TRUE;
}
break;
default:
break;
case GST_FORMAT_BYTES:
if (GST_PAD_PEER (tag->sinkpad) &&
tag->state == GST_ID3_TAG_STATE_NORMAL &&
gst_pad_query (GST_PAD_PEER (tag->sinkpad), GST_QUERY_TOTAL,
format, value)) {
*value -= tag->v2tag_size + tag->v1tag_size;
*value += tag->v2tag_size_new + tag->v1tag_size_new;
res = TRUE;
}
break;
default:
break;
}
break;
}
case GST_QUERY_POSITION:
switch (*format) {
case GST_FORMAT_BYTES:
if (GST_PAD_PEER (tag->sinkpad) &&
gst_pad_query (GST_PAD_PEER (tag->sinkpad), GST_QUERY_POSITION,
format, value)) {
if (tag->state == GST_ID3_TAG_STATE_NORMAL) {
*value -= tag->v2tag_size + tag->v2tag_size_new;
} else {
*value = 0;
}
res = TRUE;
}
break;
default:
break;
case GST_FORMAT_BYTES:
if (GST_PAD_PEER (tag->sinkpad) &&
gst_pad_query (GST_PAD_PEER (tag->sinkpad), GST_QUERY_POSITION,
format, value)) {
if (tag->state == GST_ID3_TAG_STATE_NORMAL) {
*value -= tag->v2tag_size + tag->v2tag_size_new;
} else {
*value = 0;
}
res = TRUE;
}
break;
default:
break;
}
break;
default:
@ -425,30 +429,30 @@ gst_id3_tag_src_event (GstPad * pad, GstEvent * event)
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_SEEK:
if (GST_EVENT_SEEK_FORMAT (event) == GST_FORMAT_BYTES &&
tag->state == GST_ID3_TAG_STATE_NORMAL &&
GST_PAD_PEER (tag->sinkpad)) {
GstEvent *new;
gint diff = 0;
tag->state == GST_ID3_TAG_STATE_NORMAL &&
GST_PAD_PEER (tag->sinkpad)) {
GstEvent *new;
gint diff = 0;
switch (GST_EVENT_SEEK_METHOD (event)) {
case GST_SEEK_METHOD_SET:
diff = tag->v2tag_size_new - tag->v2tag_size;
break;
case GST_SEEK_METHOD_CUR:
break;
case GST_SEEK_METHOD_END:
diff =
GST_EVENT_SEEK_OFFSET (event) ? tag->v1tag_size_new -
tag->v1tag_size : 0;
break;
default:
g_assert_not_reached ();
break;
}
new = gst_event_new_seek (GST_EVENT_SEEK_TYPE (event),
GST_EVENT_SEEK_OFFSET (event) + diff);
gst_event_unref (event);
return gst_pad_send_event (GST_PAD_PEER (tag->sinkpad), new);
switch (GST_EVENT_SEEK_METHOD (event)) {
case GST_SEEK_METHOD_SET:
diff = tag->v2tag_size_new - tag->v2tag_size;
break;
case GST_SEEK_METHOD_CUR:
break;
case GST_SEEK_METHOD_END:
diff =
GST_EVENT_SEEK_OFFSET (event) ? tag->v1tag_size_new -
tag->v1tag_size : 0;
break;
default:
g_assert_not_reached ();
break;
}
new = gst_event_new_seek (GST_EVENT_SEEK_TYPE (event),
GST_EVENT_SEEK_OFFSET (event) + diff);
gst_event_unref (event);
return gst_pad_send_event (GST_PAD_PEER (tag->sinkpad), new);
}
break;
default:
@ -492,87 +496,87 @@ gst_mad_id3_to_tag_list (const struct id3_tag * tag)
g_assert (ucs4);
if (strcmp (id, ID3_FRAME_GENRE) == 0)
ucs4 = id3_genre_name (ucs4);
ucs4 = id3_genre_name (ucs4);
utf8 = id3_ucs4_utf8duplicate (ucs4);
if (utf8 == 0)
continue;
continue;
if (!g_utf8_validate (utf8, -1, NULL)) {
g_warning ("converted string is not valid utf-8");
free (utf8);
continue;
g_warning ("converted string is not valid utf-8");
free (utf8);
continue;
}
/* be sure to add non-string tags here */
switch (gst_tag_get_type (tag_name)) {
case G_TYPE_UINT:
{
guint tmp;
gchar *check;
case G_TYPE_UINT:
{
guint tmp;
gchar *check;
tmp = strtoul (utf8, &check, 10);
tmp = strtoul (utf8, &check, 10);
if (strcmp (tag_name, GST_TAG_DATE) == 0) {
GDate *d;
if (strcmp (tag_name, GST_TAG_DATE) == 0) {
GDate *d;
if (*check != '\0')
break;
if (tmp == 0)
break;
d = g_date_new_dmy (1, 1, tmp);
tmp = g_date_get_julian (d);
g_date_free (d);
} else if (strcmp (tag_name, GST_TAG_TRACK_NUMBER) == 0) {
if (*check == '/') {
guint total;
if (*check != '\0')
break;
if (tmp == 0)
break;
d = g_date_new_dmy (1, 1, tmp);
tmp = g_date_get_julian (d);
g_date_free (d);
} else if (strcmp (tag_name, GST_TAG_TRACK_NUMBER) == 0) {
if (*check == '/') {
guint total;
check++;
total = strtoul (check, &check, 10);
if (*check != '\0')
break;
check++;
total = strtoul (check, &check, 10);
if (*check != '\0')
break;
gst_tag_list_add (tag_list, GST_TAG_MERGE_APPEND,
GST_TAG_TRACK_COUNT, total, NULL);
}
} else if (strcmp (tag_name, GST_TAG_ALBUM_VOLUME_NUMBER) == 0) {
if (*check == '/') {
guint total;
gst_tag_list_add (tag_list, GST_TAG_MERGE_APPEND,
GST_TAG_TRACK_COUNT, total, NULL);
}
} else if (strcmp (tag_name, GST_TAG_ALBUM_VOLUME_NUMBER) == 0) {
if (*check == '/') {
guint total;
check++;
total = strtoul (check, &check, 10);
if (*check != '\0')
break;
check++;
total = strtoul (check, &check, 10);
if (*check != '\0')
break;
gst_tag_list_add (tag_list, GST_TAG_MERGE_APPEND,
GST_TAG_ALBUM_VOLUME_COUNT, total, NULL);
}
}
gst_tag_list_add (tag_list, GST_TAG_MERGE_APPEND,
GST_TAG_ALBUM_VOLUME_COUNT, total, NULL);
}
}
if (*check != '\0')
break;
gst_tag_list_add (tag_list, GST_TAG_MERGE_APPEND, tag_name, tmp,
NULL);
break;
}
case G_TYPE_UINT64:
{
guint64 tmp;
if (*check != '\0')
break;
gst_tag_list_add (tag_list, GST_TAG_MERGE_APPEND, tag_name, tmp,
NULL);
break;
}
case G_TYPE_UINT64:
{
guint64 tmp;
g_assert ((strcmp (tag_name, GST_TAG_DURATION) == 0));
tmp = strtoul (utf8, NULL, 10);
if (tmp == 0) {
break;
}
gst_tag_list_add (tag_list, GST_TAG_MERGE_APPEND,
GST_TAG_DURATION, tmp * 1000 * 1000, NULL);
break;
}
default:
g_assert (gst_tag_get_type (tag_name) == G_TYPE_STRING);
gst_tag_list_add (tag_list, GST_TAG_MERGE_APPEND, tag_name, utf8,
NULL);
break;
g_assert ((strcmp (tag_name, GST_TAG_DURATION) == 0));
tmp = strtoul (utf8, NULL, 10);
if (tmp == 0) {
break;
}
gst_tag_list_add (tag_list, GST_TAG_MERGE_APPEND,
GST_TAG_DURATION, tmp * 1000 * 1000, NULL);
break;
}
default:
g_assert (gst_tag_get_type (tag_name) == G_TYPE_STRING);
gst_tag_list_add (tag_list, GST_TAG_MERGE_APPEND, tag_name, utf8,
NULL);
break;
}
free (utf8);
}
@ -633,8 +637,8 @@ tag_list_to_id3_tag_foreach (const GstTagList * list, const gchar * tag_name,
gchar *str;
if (gst_tag_get_type (tag_name) != G_TYPE_STRING) {
GST_WARNING ("unhandled GStreamer tag %s", tag_name);
return;
GST_WARNING ("unhandled GStreamer tag %s", tag_name);
return;
}
g_assert (gst_tag_list_get_string_index (list, tag_name, values, &str));
put = g_utf8_to_ucs4_fast (str, -1, NULL);
@ -671,7 +675,7 @@ gst_id3_tag_get_tag_to_render (GstID3Tag * tag)
}
if (ret && gst_tag_setter_get_list (GST_TAG_SETTER (tag))) {
gst_tag_list_insert (ret, gst_tag_setter_get_list (GST_TAG_SETTER (tag)),
gst_tag_setter_get_merge_mode (GST_TAG_SETTER (tag)));
gst_tag_setter_get_merge_mode (GST_TAG_SETTER (tag)));
} else if (gst_tag_setter_get_list (GST_TAG_SETTER (tag))) {
ret = gst_tag_list_copy (gst_tag_setter_get_list (GST_TAG_SETTER (tag)));
}
@ -685,83 +689,83 @@ gst_id3_tag_handle_event (GstPad * pad, GstEvent * event)
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_DISCONTINUOUS:
switch (tag->state) {
case GST_ID3_TAG_STATE_READING_V2_TAG:{
guint64 value;
case GST_ID3_TAG_STATE_READING_V2_TAG:{
guint64 value;
gst_event_discont_get_value (event, GST_FORMAT_BYTES, &value);
if (value !=
(tag->buffer ? GST_BUFFER_OFFSET (tag->buffer) +
GST_BUFFER_SIZE (tag->buffer)
: 0))
GST_ELEMENT_ERROR (tag, CORE, EVENT, (NULL),
("Seek during ID3v2 tag reading"));
gst_data_unref (GST_DATA (event));
break;
}
case GST_ID3_TAG_STATE_SEEKING_TO_V1_TAG:
/* just assume it's the right seek for now */
gst_id3_tag_set_state (tag, GST_ID3_TAG_STATE_READING_V1_TAG);
break;
case GST_ID3_TAG_STATE_READING_V1_TAG:
GST_ELEMENT_ERROR (tag, CORE, EVENT, (NULL),
("Seek during ID3v1 tag reading"));
gst_data_unref (GST_DATA (event));
break;
case GST_ID3_TAG_STATE_SEEKING_TO_NORMAL:
/* just assume it's the right seek for now */
gst_id3_tag_set_state (tag, GST_ID3_TAG_STATE_NORMAL_START);
break;
case GST_ID3_TAG_STATE_NORMAL_START:
GST_ERROR_OBJECT (tag, "tag event not sent, FIXME");
gst_id3_tag_set_state (tag, GST_ID3_TAG_STATE_NORMAL);
/* fall through */
case GST_ID3_TAG_STATE_NORMAL:{
gint64 value;
GstEvent *new;
gst_event_discont_get_value (event, GST_FORMAT_BYTES, &value);
if (value !=
(tag->buffer ? GST_BUFFER_OFFSET (tag->buffer) +
GST_BUFFER_SIZE (tag->buffer)
: 0))
GST_ELEMENT_ERROR (tag, CORE, EVENT, (NULL),
("Seek during ID3v2 tag reading"));
gst_data_unref (GST_DATA (event));
break;
}
case GST_ID3_TAG_STATE_SEEKING_TO_V1_TAG:
/* just assume it's the right seek for now */
gst_id3_tag_set_state (tag, GST_ID3_TAG_STATE_READING_V1_TAG);
break;
case GST_ID3_TAG_STATE_READING_V1_TAG:
GST_ELEMENT_ERROR (tag, CORE, EVENT, (NULL),
("Seek during ID3v1 tag reading"));
gst_data_unref (GST_DATA (event));
break;
case GST_ID3_TAG_STATE_SEEKING_TO_NORMAL:
/* just assume it's the right seek for now */
gst_id3_tag_set_state (tag, GST_ID3_TAG_STATE_NORMAL_START);
break;
case GST_ID3_TAG_STATE_NORMAL_START:
GST_ERROR_OBJECT (tag, "tag event not sent, FIXME");
gst_id3_tag_set_state (tag, GST_ID3_TAG_STATE_NORMAL);
/* fall through */
case GST_ID3_TAG_STATE_NORMAL:{
gint64 value;
GstEvent *new;
if (gst_event_discont_get_value (event, GST_FORMAT_BYTES, &value)) {
value += tag->v1tag_size;
new = gst_event_new_discontinuous (GST_FORMAT_BYTES, value, 0);
gst_data_unref (GST_DATA (event));
gst_pad_push (tag->srcpad, GST_DATA (new));
} else {
gst_pad_event_default (pad, event);
}
break;
}
default:
g_assert_not_reached ();
if (gst_event_discont_get_value (event, GST_FORMAT_BYTES, &value)) {
value += tag->v1tag_size;
new = gst_event_new_discontinuous (GST_FORMAT_BYTES, value, 0);
gst_data_unref (GST_DATA (event));
gst_pad_push (tag->srcpad, GST_DATA (new));
} else {
gst_pad_event_default (pad, event);
}
break;
}
default:
g_assert_not_reached ();
}
break;
case GST_EVENT_TAG:
if (tag->event_tags) {
gst_tag_list_insert (tag->event_tags, gst_event_tag_get_list (event),
GST_TAG_MERGE_PREPEND);
gst_tag_list_insert (tag->event_tags, gst_event_tag_get_list (event),
GST_TAG_MERGE_PREPEND);
} else {
tag->event_tags = gst_tag_list_copy (gst_event_tag_get_list (event));
tag->event_tags = gst_tag_list_copy (gst_event_tag_get_list (event));
}
gst_data_unref (GST_DATA (event));
break;
case GST_EVENT_EOS:
if (tag->v1tag_render && !tag->parse_mode) {
GstTagList *merged;
struct id3_tag *id3;
GstTagList *merged;
struct id3_tag *id3;
GST_LOG_OBJECT (tag, "rendering v1 tag after eos event");
merged = gst_id3_tag_get_tag_to_render (tag);
if (merged) {
id3 = gst_mad_tag_list_to_id3_tag (merged);
if (id3) {
GstBuffer *tag_buffer;
GST_LOG_OBJECT (tag, "rendering v1 tag after eos event");
merged = gst_id3_tag_get_tag_to_render (tag);
if (merged) {
id3 = gst_mad_tag_list_to_id3_tag (merged);
if (id3) {
GstBuffer *tag_buffer;
id3_tag_options (id3, ID3_TAG_OPTION_ID3V1, ID3_TAG_OPTION_ID3V1);
tag_buffer = gst_buffer_new_and_alloc (128);
g_assert (128 == id3_tag_render (id3, tag_buffer->data));
gst_pad_push (tag->srcpad, GST_DATA (tag_buffer));
id3_tag_delete (id3);
}
gst_tag_list_free (merged);
}
id3_tag_options (id3, ID3_TAG_OPTION_ID3V1, ID3_TAG_OPTION_ID3V1);
tag_buffer = gst_buffer_new_and_alloc (128);
g_assert (128 == id3_tag_render (id3, tag_buffer->data));
gst_pad_push (tag->srcpad, GST_DATA (tag_buffer));
id3_tag_delete (id3);
}
gst_tag_list_free (merged);
}
}
/* fall through */
default:
@ -775,7 +779,8 @@ typedef struct
guint best_probability;
GstCaps *caps;
GstBuffer *buffer;
} SimpleTypeFind;
}
SimpleTypeFind;
guint8 *
simple_find_peek (gpointer data, gint64 offset, guint size)
{
@ -913,125 +918,125 @@ gst_id3_tag_chain (GstPad * pad, GstData * data)
return;
case GST_ID3_TAG_STATE_READING_V1_TAG:
if (tag->buffer) {
GstBuffer *temp;
GstBuffer *temp;
temp = gst_buffer_merge (tag->buffer, buffer);
gst_data_unref (GST_DATA (tag->buffer));
tag->buffer = temp;
gst_data_unref (GST_DATA (buffer));
temp = gst_buffer_merge (tag->buffer, buffer);
gst_data_unref (GST_DATA (tag->buffer));
tag->buffer = temp;
gst_data_unref (GST_DATA (buffer));
} else {
tag->buffer = buffer;
tag->v1tag_offset = buffer->offset;
tag->buffer = buffer;
tag->v1tag_offset = buffer->offset;
}
if (GST_BUFFER_SIZE (tag->buffer) < 128)
return;
return;
g_assert (tag->v1tag_size == 0);
tag->v1tag_size = id3_tag_query (GST_BUFFER_DATA (tag->buffer),
GST_BUFFER_SIZE (tag->buffer));
GST_BUFFER_SIZE (tag->buffer));
if (tag->v1tag_size == 128) {
GstTagList *newtag;
GstTagList *newtag;
newtag = gst_tag_list_new_from_id3v1 (GST_BUFFER_DATA (tag->buffer));
GST_LOG_OBJECT (tag, "have read ID3v1 tag");
if (newtag) {
if (tag->parsed_tags) {
/* FIXME: use append/prepend here ? */
gst_tag_list_insert (tag->parsed_tags, newtag,
tag->prefer_v1tag ? GST_TAG_MERGE_REPLACE : GST_TAG_MERGE_KEEP);
gst_tag_list_free (newtag);
} else {
tag->parsed_tags = newtag;
}
} else {
GST_WARNING_OBJECT (tag, "detected ID3v1 tag, but couldn't parse it");
}
newtag = gst_tag_list_new_from_id3v1 (GST_BUFFER_DATA (tag->buffer));
GST_LOG_OBJECT (tag, "have read ID3v1 tag");
if (newtag) {
if (tag->parsed_tags) {
/* FIXME: use append/prepend here ? */
gst_tag_list_insert (tag->parsed_tags, newtag,
tag->prefer_v1tag ? GST_TAG_MERGE_REPLACE : GST_TAG_MERGE_KEEP);
gst_tag_list_free (newtag);
} else {
tag->parsed_tags = newtag;
}
} else {
GST_WARNING_OBJECT (tag, "detected ID3v1 tag, but couldn't parse it");
}
} else if (tag->v1tag_size != 0) {
GST_WARNING_OBJECT (tag, "bad non-ID3v1 tag at end of file");
GST_WARNING_OBJECT (tag, "bad non-ID3v1 tag at end of file");
} else {
GST_LOG_OBJECT (tag, "no ID3v1 tag (%" G_GUINT64_FORMAT ")",
GST_BUFFER_OFFSET (tag->buffer));
GST_LOG_OBJECT (tag, "no ID3v1 tag (%" G_GUINT64_FORMAT ")",
GST_BUFFER_OFFSET (tag->buffer));
}
gst_data_unref (GST_DATA (tag->buffer));
tag->buffer = NULL;
if (tag->parse_mode != GST_ID3_TAG_PARSE_TAG) {
/* seek to beginning */
GST_LOG_OBJECT (tag, "seeking back to beginning");
if (gst_pad_send_event (GST_PAD_PEER (tag->sinkpad),
gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_SET |
GST_SEEK_FLAG_FLUSH, tag->v2tag_size))) {
gst_id3_tag_set_state (tag, GST_ID3_TAG_STATE_SEEKING_TO_NORMAL);
} else {
GST_ELEMENT_ERROR (tag, CORE, SEEK, (NULL),
("can't seek back to beginning from reading ID3v1 tag"));
}
/* seek to beginning */
GST_LOG_OBJECT (tag, "seeking back to beginning");
if (gst_pad_send_event (GST_PAD_PEER (tag->sinkpad),
gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_SET |
GST_SEEK_FLAG_FLUSH, tag->v2tag_size))) {
gst_id3_tag_set_state (tag, GST_ID3_TAG_STATE_SEEKING_TO_NORMAL);
} else {
GST_ELEMENT_ERROR (tag, CORE, SEEK, (NULL),
("can't seek back to beginning from reading ID3v1 tag"));
}
} else {
gst_id3_tag_send_tag_event (tag);
/* set eos, we're done parsing tags */
GST_LOG_OBJECT (tag, "setting EOS after reading ID3v1 tag");
gst_id3_tag_set_state (tag, GST_ID3_TAG_STATE_NORMAL);
gst_element_set_eos (GST_ELEMENT (tag));
gst_pad_push (tag->srcpad, GST_DATA (gst_event_new (GST_EVENT_EOS)));
gst_id3_tag_send_tag_event (tag);
/* set eos, we're done parsing tags */
GST_LOG_OBJECT (tag, "setting EOS after reading ID3v1 tag");
gst_id3_tag_set_state (tag, GST_ID3_TAG_STATE_NORMAL);
gst_element_set_eos (GST_ELEMENT (tag));
gst_pad_push (tag->srcpad, GST_DATA (gst_event_new (GST_EVENT_EOS)));
}
return;
case GST_ID3_TAG_STATE_READING_V2_TAG:
if (tag->buffer) {
GstBuffer *temp;
GstBuffer *temp;
temp = gst_buffer_merge (tag->buffer, buffer);
gst_data_unref (GST_DATA (tag->buffer));
tag->buffer = temp;
gst_data_unref (GST_DATA (buffer));
temp = gst_buffer_merge (tag->buffer, buffer);
gst_data_unref (GST_DATA (tag->buffer));
tag->buffer = temp;
gst_data_unref (GST_DATA (buffer));
} else {
tag->buffer = buffer;
tag->buffer = buffer;
}
if (GST_BUFFER_SIZE (tag->buffer) < 10)
return;
return;
if (tag->v2tag_size == 0) {
tag->v2tag_size = id3_tag_query (GST_BUFFER_DATA (tag->buffer),
GST_BUFFER_SIZE (tag->buffer));
/* no footers supported */
if (tag->v2tag_size < 0)
tag->v2tag_size = 0;
tag->v2tag_size = id3_tag_query (GST_BUFFER_DATA (tag->buffer),
GST_BUFFER_SIZE (tag->buffer));
/* no footers supported */
if (tag->v2tag_size < 0)
tag->v2tag_size = 0;
}
if (GST_BUFFER_SIZE (tag->buffer) < tag->v2tag_size + ID3_TYPE_FIND_SIZE)
return;
return;
if (tag->v2tag_size != 0) {
struct id3_tag *v2tag;
struct id3_tag *v2tag;
v2tag = id3_tag_parse (GST_BUFFER_DATA (tag->buffer),
GST_BUFFER_SIZE (tag->buffer));
if (v2tag) {
GstTagList *list;
v2tag = id3_tag_parse (GST_BUFFER_DATA (tag->buffer),
GST_BUFFER_SIZE (tag->buffer));
if (v2tag) {
GstTagList *list;
list = gst_mad_id3_to_tag_list (v2tag);
id3_tag_delete (v2tag);
GST_LOG_OBJECT (tag, "parsed ID3v2 tag");
/* no other tag parsed yet */
g_assert (tag->parsed_tags == NULL);
tag->parsed_tags = list;
} else {
GST_WARNING_OBJECT (tag, "detected ID3v2 tag, but couldn't parse it");
}
list = gst_mad_id3_to_tag_list (v2tag);
id3_tag_delete (v2tag);
GST_LOG_OBJECT (tag, "parsed ID3v2 tag");
/* no other tag parsed yet */
g_assert (tag->parsed_tags == NULL);
tag->parsed_tags = list;
} else {
GST_WARNING_OBJECT (tag, "detected ID3v2 tag, but couldn't parse it");
}
}
/* caps nego and typefinding */
GST_LOG_OBJECT (tag,
"removing first %ld bytes, because they're the ID3v2 tag",
tag->v2tag_size);
"removing first %ld bytes, because they're the ID3v2 tag",
tag->v2tag_size);
buffer =
gst_buffer_create_sub (tag->buffer, tag->v2tag_size,
GST_BUFFER_SIZE (tag->buffer) - tag->v2tag_size);
gst_buffer_create_sub (tag->buffer, tag->v2tag_size,
GST_BUFFER_SIZE (tag->buffer) - tag->v2tag_size);
gst_data_unref (GST_DATA (tag->buffer));
tag->buffer = NULL;
if (tag->found_caps == NULL)
if (!gst_id3_tag_do_caps_nego (tag, buffer))
return;
if (!gst_id3_tag_do_caps_nego (tag, buffer))
return;
/* seek to ID3v1 tag */
if (gst_pad_send_event (GST_PAD_PEER (tag->sinkpad),
gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_END |
GST_SEEK_FLAG_FLUSH, -128))) {
gst_id3_tag_set_state (tag, GST_ID3_TAG_STATE_SEEKING_TO_V1_TAG);
gst_data_unref (GST_DATA (buffer));
return;
gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_END |
GST_SEEK_FLAG_FLUSH, -128))) {
gst_id3_tag_set_state (tag, GST_ID3_TAG_STATE_SEEKING_TO_V1_TAG);
gst_data_unref (GST_DATA (buffer));
return;
}
gst_id3_tag_set_state (tag, GST_ID3_TAG_STATE_NORMAL_START);
/* fall through */
@ -1040,53 +1045,53 @@ gst_id3_tag_chain (GstPad * pad, GstData * data)
gst_id3_tag_send_tag_event (tag);
if (tag->parse_mode == GST_ID3_TAG_PARSE_WRITE && tag->v2tag_render) {
struct id3_tag *id3;
GstTagList *merged;
GstBuffer *tag_buffer;
struct id3_tag *id3;
GstTagList *merged;
GstBuffer *tag_buffer;
/* render tag */
tag->v2tag_size_new = 0;
merged = gst_id3_tag_get_tag_to_render (tag);
if (merged) {
id3 = gst_mad_tag_list_to_id3_tag (merged);
if (id3) {
glong estimated;
/* render tag */
tag->v2tag_size_new = 0;
merged = gst_id3_tag_get_tag_to_render (tag);
if (merged) {
id3 = gst_mad_tag_list_to_id3_tag (merged);
if (id3) {
glong estimated;
estimated = id3_tag_render (id3, NULL);
tag_buffer = gst_buffer_new_and_alloc (estimated);
tag->v2tag_size_new =
id3_tag_render (id3, GST_BUFFER_DATA (tag_buffer));
g_assert (estimated >= tag->v2tag_size_new);
GST_BUFFER_SIZE (tag_buffer) = tag->v2tag_size_new;
gst_pad_push (tag->srcpad, GST_DATA (tag_buffer));
id3_tag_delete (id3);
}
gst_tag_list_free (merged);
}
estimated = id3_tag_render (id3, NULL);
tag_buffer = gst_buffer_new_and_alloc (estimated);
tag->v2tag_size_new =
id3_tag_render (id3, GST_BUFFER_DATA (tag_buffer));
g_assert (estimated >= tag->v2tag_size_new);
GST_BUFFER_SIZE (tag_buffer) = tag->v2tag_size_new;
gst_pad_push (tag->srcpad, GST_DATA (tag_buffer));
id3_tag_delete (id3);
}
gst_tag_list_free (merged);
}
}
gst_id3_tag_set_state (tag, GST_ID3_TAG_STATE_NORMAL);
tag->v1tag_size_new = (tag->v1tag_render &&
tag->parse_mode == GST_ID3_TAG_PARSE_WRITE &&
(tag->parsed_tags != NULL ||
gst_tag_setter_get_list (GST_TAG_SETTER (tag)) !=
NULL)) ? 128 : 0;
tag->parse_mode == GST_ID3_TAG_PARSE_WRITE &&
(tag->parsed_tags != NULL ||
gst_tag_setter_get_list (GST_TAG_SETTER (tag)) !=
NULL)) ? 128 : 0;
/* fall through */
case GST_ID3_TAG_STATE_NORMAL:
if (tag->parse_mode == GST_ID3_TAG_PARSE_TAG) {
gst_element_set_eos (GST_ELEMENT (tag));
gst_pad_push (tag->srcpad, GST_DATA (gst_event_new (GST_EVENT_EOS)));
gst_element_set_eos (GST_ELEMENT (tag));
gst_pad_push (tag->srcpad, GST_DATA (gst_event_new (GST_EVENT_EOS)));
} else {
if (buffer->offset >= tag->v1tag_offset) {
gst_data_unref (GST_DATA (buffer));
return;
} else if (buffer->offset + buffer->size > tag->v1tag_offset) {
GstBuffer *sub = gst_buffer_create_sub (buffer, 0,
buffer->size - 128);
if (buffer->offset >= tag->v1tag_offset) {
gst_data_unref (GST_DATA (buffer));
return;
} else if (buffer->offset + buffer->size > tag->v1tag_offset) {
GstBuffer *sub = gst_buffer_create_sub (buffer, 0,
buffer->size - 128);
gst_data_unref (GST_DATA (buffer));
buffer = sub;
}
gst_pad_push (tag->srcpad, GST_DATA (buffer));
gst_data_unref (GST_DATA (buffer));
buffer = sub;
}
gst_pad_push (tag->srcpad, GST_DATA (buffer));
}
return;
}
@ -1117,20 +1122,20 @@ gst_id3_tag_change_state (GstElement * element)
break;
case GST_STATE_PAUSED_TO_READY:
if (tag->parsed_tags) {
gst_tag_list_free (tag->parsed_tags);
tag->parsed_tags = NULL;
gst_tag_list_free (tag->parsed_tags);
tag->parsed_tags = NULL;
}
if (tag->event_tags) {
gst_tag_list_free (tag->event_tags);
tag->event_tags = NULL;
gst_tag_list_free (tag->event_tags);
tag->event_tags = NULL;
}
if (tag->buffer) {
gst_data_unref (GST_DATA (tag->buffer));
tag->buffer = NULL;
gst_data_unref (GST_DATA (tag->buffer));
tag->buffer = NULL;
}
if (tag->found_caps) {
gst_caps_free (tag->found_caps);
tag->found_caps = NULL;
gst_caps_free (tag->found_caps);
tag->found_caps = NULL;
}
tag->parse_mode = GST_ID3_TAG_PARSE_UNKNOWN;
break;
@ -1150,9 +1155,9 @@ plugin_init (GstPlugin * plugin)
return FALSE;
if (!gst_element_register (plugin, "mad", GST_RANK_PRIMARY,
gst_mad_get_type ())
gst_mad_get_type ())
|| !gst_element_register (plugin, "id3tag", GST_RANK_PRIMARY,
gst_id3_tag_get_type ()))
gst_id3_tag_get_type ()))
return FALSE;
return TRUE;

View file

@ -50,12 +50,12 @@ struct _GstMad
struct mad_frame frame;
struct mad_synth synth;
guchar *tempbuffer;
glong tempsize; /* used to keep track of partial buffers */
glong tempsize; /* used to keep track of partial buffers */
gboolean need_sync;
GstClockTime last_ts;
guint64 base_byte_offset;
guint64 bytes_consumed; /* since the base_byte_offset */
guint64 total_samples; /* the number of samples since the sync point */
guint64 bytes_consumed; /* since the base_byte_offset */
guint64 total_samples; /* the number of samples since the sync point */
gboolean restart;
guint64 segment_start;
@ -64,8 +64,8 @@ struct _GstMad
struct mad_header header;
gboolean new_header;
guint framecount;
gint vbr_average; /* average bitrate */
guint64 vbr_rate; /* average * framecount */
gint vbr_average; /* average bitrate */
guint64 vbr_rate; /* average * framecount */
gboolean half;
gboolean ignore_crc;
@ -117,11 +117,11 @@ GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw-int, "
"endianness = (int) " G_STRINGIFY (G_BYTE_ORDER) ", "
"signed = (boolean) true, "
"width = (int) 16, "
"depth = (int) 16, "
"rate = (int) [ 11025, 48000 ], " "channels = (int) [ 1, 2 ]")
"endianness = (int) " G_STRINGIFY (G_BYTE_ORDER) ", "
"signed = (boolean) true, "
"width = (int) 16, "
"depth = (int) 16, "
"rate = (int) [ 11025, 48000 ], " "channels = (int) [ 1, 2 ]")
);
static GstStaticPadTemplate mad_sink_template_factory =
@ -129,7 +129,7 @@ GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/mpeg, "
"mpegversion = (int) 1, " "layer = (int) [ 1, 3 ]")
"mpegversion = (int) 1, " "layer = (int) [ 1, 3 ]")
);
static void gst_mad_base_init (gpointer g_class);
@ -183,8 +183,9 @@ gst_mad_get_type (void)
0,
(GInstanceInitFunc) gst_mad_init,
};
mad_type =
g_type_register_static (GST_TYPE_ELEMENT, "GstMad", &mad_info, 0);
g_type_register_static (GST_TYPE_ELEMENT, "GstMad", &mad_info, 0);
}
return mad_type;
}
@ -201,6 +202,7 @@ gst_mad_layer_get_type (void)
{MAD_LAYER_III, "3", "III"},
{0, NULL, NULL},
};
if (!mad_layer_type) {
mad_layer_type = g_enum_register_static ("GstMadLayer", mad_layer);
}
@ -220,6 +222,7 @@ gst_mad_mode_get_type (void)
{MAD_MODE_STEREO, "3", "Stereo"},
{0, NULL, NULL},
};
if (!mad_mode_type) {
mad_mode_type = g_enum_register_static ("GstMadMode", mad_mode);
}
@ -239,6 +242,7 @@ gst_mad_emphasis_get_type (void)
{MAD_EMPHASIS_RESERVED, "3", "Reserved"},
{0, NULL, NULL},
};
if (!mad_emphasis_type) {
mad_emphasis_type = g_enum_register_static ("GstMadEmphasis", mad_emphasis);
}
@ -281,10 +285,10 @@ gst_mad_class_init (GstMadClass * klass)
* default values and ranges need to be selected right */
g_object_class_install_property (gobject_class, ARG_HALF,
g_param_spec_boolean ("half", "Half", "Generate PCM at 1/2 sample rate",
FALSE, G_PARAM_READWRITE));
FALSE, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_IGNORE_CRC,
g_param_spec_boolean ("ignore_crc", "Ignore CRC", "Ignore CRC errors",
FALSE, G_PARAM_READWRITE));
FALSE, G_PARAM_READWRITE));
/* register tags */
#define GST_TAG_LAYER "layer"
@ -409,6 +413,7 @@ gst_mad_get_event_masks (GstPad * pad)
{GST_EVENT_SEEK, GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH},
{0,}
};
return gst_mad_src_event_masks;
}
@ -427,22 +432,22 @@ gst_mad_convert_sink (GstPad * pad, GstFormat src_format, gint64 src_value,
switch (src_format) {
case GST_FORMAT_BYTES:
switch (*dest_format) {
case GST_FORMAT_TIME:
/* multiply by 8 because vbr is in bits/second */
*dest_value = src_value * 8 * GST_SECOND / mad->vbr_average;
break;
default:
res = FALSE;
case GST_FORMAT_TIME:
/* multiply by 8 because vbr is in bits/second */
*dest_value = src_value * 8 * GST_SECOND / mad->vbr_average;
break;
default:
res = FALSE;
}
break;
case GST_FORMAT_TIME:
switch (*dest_format) {
case GST_FORMAT_BYTES:
/* multiply by 8 because vbr is in bits/second */
*dest_value = src_value * mad->vbr_average / (8 * GST_SECOND);
break;
default:
res = FALSE;
case GST_FORMAT_BYTES:
/* multiply by 8 because vbr is in bits/second */
*dest_value = src_value * mad->vbr_average / (8 * GST_SECOND);
break;
default:
res = FALSE;
}
break;
default:
@ -467,49 +472,49 @@ gst_mad_convert_src (GstPad * pad, GstFormat src_format, gint64 src_value,
switch (src_format) {
case GST_FORMAT_BYTES:
switch (*dest_format) {
case GST_FORMAT_DEFAULT:
if (bytes_per_sample == 0)
return FALSE;
*dest_value = src_value / bytes_per_sample;
break;
case GST_FORMAT_TIME:
{
gint byterate = bytes_per_sample * mad->frame.header.samplerate;
case GST_FORMAT_DEFAULT:
if (bytes_per_sample == 0)
return FALSE;
*dest_value = src_value / bytes_per_sample;
break;
case GST_FORMAT_TIME:
{
gint byterate = bytes_per_sample * mad->frame.header.samplerate;
if (byterate == 0)
return FALSE;
*dest_value = src_value * GST_SECOND / byterate;
break;
}
default:
res = FALSE;
if (byterate == 0)
return FALSE;
*dest_value = src_value * GST_SECOND / byterate;
break;
}
default:
res = FALSE;
}
break;
case GST_FORMAT_DEFAULT:
switch (*dest_format) {
case GST_FORMAT_BYTES:
*dest_value = src_value * bytes_per_sample;
break;
case GST_FORMAT_TIME:
if (mad->frame.header.samplerate == 0)
return FALSE;
*dest_value = src_value * GST_SECOND / mad->frame.header.samplerate;
break;
default:
res = FALSE;
case GST_FORMAT_BYTES:
*dest_value = src_value * bytes_per_sample;
break;
case GST_FORMAT_TIME:
if (mad->frame.header.samplerate == 0)
return FALSE;
*dest_value = src_value * GST_SECOND / mad->frame.header.samplerate;
break;
default:
res = FALSE;
}
break;
case GST_FORMAT_TIME:
switch (*dest_format) {
case GST_FORMAT_BYTES:
scale = bytes_per_sample;
/* fallthrough */
case GST_FORMAT_DEFAULT:
*dest_value =
src_value * scale * mad->frame.header.samplerate / GST_SECOND;
break;
default:
res = FALSE;
case GST_FORMAT_BYTES:
scale = bytes_per_sample;
/* fallthrough */
case GST_FORMAT_DEFAULT:
*dest_value =
src_value * scale * mad->frame.header.samplerate / GST_SECOND;
break;
default:
res = FALSE;
}
break;
default:
@ -526,6 +531,7 @@ gst_mad_get_query_types (GstPad * pad)
GST_QUERY_POSITION,
0
};
return gst_mad_src_query_types;
}
@ -542,53 +548,53 @@ gst_mad_src_query (GstPad * pad, GstQueryType type,
case GST_QUERY_TOTAL:
{
switch (*format) {
case GST_FORMAT_BYTES:
case GST_FORMAT_DEFAULT:
case GST_FORMAT_TIME:
{
gint64 peer_value;
const GstFormat *peer_formats;
case GST_FORMAT_BYTES:
case GST_FORMAT_DEFAULT:
case GST_FORMAT_TIME:
{
gint64 peer_value;
const GstFormat *peer_formats;
res = FALSE;
res = FALSE;
peer_formats = gst_pad_get_formats (GST_PAD_PEER (mad->sinkpad));
peer_formats = gst_pad_get_formats (GST_PAD_PEER (mad->sinkpad));
while (peer_formats && *peer_formats && !res) {
while (peer_formats && *peer_formats && !res) {
GstFormat peer_format = *peer_formats;
GstFormat peer_format = *peer_formats;
/* do the probe */
if (gst_pad_query (GST_PAD_PEER (mad->sinkpad), GST_QUERY_TOTAL,
&peer_format, &peer_value)) {
GstFormat conv_format;
/* do the probe */
if (gst_pad_query (GST_PAD_PEER (mad->sinkpad), GST_QUERY_TOTAL,
&peer_format, &peer_value)) {
GstFormat conv_format;
/* convert to TIME */
conv_format = GST_FORMAT_TIME;
res = gst_pad_convert (mad->sinkpad,
peer_format, peer_value, &conv_format, value);
/* and to final format */
res &= gst_pad_convert (pad,
GST_FORMAT_TIME, *value, format, value);
}
peer_formats++;
}
break;
}
default:
res = FALSE;
break;
/* convert to TIME */
conv_format = GST_FORMAT_TIME;
res = gst_pad_convert (mad->sinkpad,
peer_format, peer_value, &conv_format, value);
/* and to final format */
res &= gst_pad_convert (pad,
GST_FORMAT_TIME, *value, format, value);
}
peer_formats++;
}
break;
}
default:
res = FALSE;
break;
}
break;
}
case GST_QUERY_POSITION:
switch (*format) {
default:
{
/* we only know about our samples, convert to requested format */
res &= gst_pad_convert (pad,
GST_FORMAT_DEFAULT, mad->total_samples, format, value);
break;
}
default:
{
/* we only know about our samples, convert to requested format */
res &= gst_pad_convert (pad,
GST_FORMAT_DEFAULT, mad->total_samples, format, value);
break;
}
}
break;
default:
@ -630,20 +636,20 @@ index_seek (GstMad * mad, GstPad * pad, GstEvent * event)
/* lookup succeeded, create the seek */
GST_DEBUG ("index %s %" G_GINT64_FORMAT
" -> %s %" G_GINT64_FORMAT,
gst_format_get_details (GST_EVENT_SEEK_FORMAT (event))->nick,
GST_EVENT_SEEK_OFFSET (event),
gst_format_get_details (*try_formats)->nick, value);
" -> %s %" G_GINT64_FORMAT,
gst_format_get_details (GST_EVENT_SEEK_FORMAT (event))->nick,
GST_EVENT_SEEK_OFFSET (event),
gst_format_get_details (*try_formats)->nick, value);
seek_event = gst_event_new_seek (*try_formats |
GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, value);
GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, value);
if (gst_pad_send_event (GST_PAD_PEER (mad->sinkpad), seek_event)) {
/* seek worked, we're done, loop will exit */
mad->restart = TRUE;
g_assert (GST_EVENT_SEEK_FORMAT (event) == GST_FORMAT_TIME);
mad->segment_start = GST_EVENT_SEEK_OFFSET (event);
return TRUE;
/* seek worked, we're done, loop will exit */
mad->restart = TRUE;
g_assert (GST_EVENT_SEEK_FORMAT (event) == GST_FORMAT_TIME);
mad->segment_start = GST_EVENT_SEEK_OFFSET (event);
return TRUE;
}
}
try_formats++;
@ -665,8 +671,8 @@ normal_seek (GstMad * mad, GstPad * pad, GstEvent * event)
/* 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)) {
GST_EVENT_SEEK_FORMAT (event), GST_EVENT_SEEK_OFFSET (event),
&format, &src_offset)) {
/* didn't work, probably unsupported seek format then */
return FALSE;
}
@ -687,16 +693,16 @@ normal_seek (GstMad * mad, GstPad * pad, GstEvent * event)
/* try to convert requested format to one we can seek with on the sinkpad */
if (gst_pad_convert (mad->sinkpad, GST_FORMAT_TIME, src_offset,
&format, &desired_offset)) {
&format, &desired_offset)) {
GstEvent *seek_event;
/* conversion succeeded, create the seek */
seek_event = gst_event_new_seek (format | GST_SEEK_METHOD_SET | flush,
desired_offset);
desired_offset);
/* do the seek */
if (gst_pad_send_event (GST_PAD_PEER (mad->sinkpad), seek_event)) {
/* seek worked, we're done, loop will exit */
res = TRUE;
/* seek worked, we're done, loop will exit */
res = TRUE;
}
}
/* at this point, either the seek worked or res == FALSE */
@ -722,16 +728,16 @@ gst_mad_src_event (GstPad * pad, GstEvent * event)
case GST_EVENT_SEEK_SEGMENT:
gst_event_ref (event);
if (gst_pad_send_event (GST_PAD_PEER (mad->sinkpad), event)) {
/* seek worked, we're done, loop will exit */
res = TRUE;
/* seek worked, we're done, loop will exit */
res = TRUE;
}
break;
/* the all-formats seek logic */
case GST_EVENT_SEEK:
if (mad->index)
res = index_seek (mad, pad, event);
res = index_seek (mad, pad, event);
else
res = normal_seek (mad, pad, event);
res = normal_seek (mad, pad, event);
break;
default:
@ -846,16 +852,16 @@ G_STMT_START{ \
GEnumValue *emphasis;
mode =
g_enum_get_value (g_type_class_ref (GST_TYPE_MAD_MODE),
mad->header.mode);
g_enum_get_value (g_type_class_ref (GST_TYPE_MAD_MODE),
mad->header.mode);
emphasis =
g_enum_get_value (g_type_class_ref (GST_TYPE_MAD_EMPHASIS),
mad->header.emphasis);
g_enum_get_value (g_type_class_ref (GST_TYPE_MAD_EMPHASIS),
mad->header.emphasis);
list = gst_tag_list_new ();
gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
GST_TAG_LAYER, mad->header.layer,
GST_TAG_MODE, mode->value_nick,
GST_TAG_EMPHASIS, emphasis->value_nick, NULL);
GST_TAG_LAYER, mad->header.layer,
GST_TAG_MODE, mode->value_nick,
GST_TAG_EMPHASIS, emphasis->value_nick, NULL);
gst_element_found_tags (GST_ELEMENT (mad), list);
gst_tag_list_free (list);
}
@ -878,42 +884,42 @@ gst_mad_handle_event (GstPad * pad, GstBuffer * buffer)
mad->total_samples = 0;
for (i = 0; i < n; i++) {
const GstFormat *formats;
const GstFormat *formats;
formats = gst_pad_get_formats (pad);
formats = gst_pad_get_formats (pad);
if (gst_formats_contains (formats, GST_EVENT_DISCONT_OFFSET (event,
i).format)) {
gint64 value = GST_EVENT_DISCONT_OFFSET (event, i).value;
gint64 time;
GstFormat format;
GstEvent *discont;
if (gst_formats_contains (formats, GST_EVENT_DISCONT_OFFSET (event,
i).format)) {
gint64 value = GST_EVENT_DISCONT_OFFSET (event, i).value;
gint64 time;
GstFormat format;
GstEvent *discont;
/* see how long the input bytes take */
format = GST_FORMAT_TIME;
if (!gst_pad_convert (pad,
GST_EVENT_DISCONT_OFFSET (event, i).format,
value, &format, &time)) {
time = 0;
}
/* see how long the input bytes take */
format = GST_FORMAT_TIME;
if (!gst_pad_convert (pad,
GST_EVENT_DISCONT_OFFSET (event, i).format,
value, &format, &time)) {
time = 0;
}
/* for now, this is the best we can do to get the total number
* of samples */
format = GST_FORMAT_DEFAULT;
if (!gst_pad_convert (mad->srcpad,
GST_FORMAT_TIME, time, &format, &mad->total_samples)) {
mad->total_samples = 0;
}
/* for now, this is the best we can do to get the total number
* of samples */
format = GST_FORMAT_DEFAULT;
if (!gst_pad_convert (mad->srcpad,
GST_FORMAT_TIME, time, &format, &mad->total_samples)) {
mad->total_samples = 0;
}
gst_event_unref (event);
gst_event_unref (event);
if (GST_PAD_IS_USABLE (mad->srcpad)) {
discont = gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME,
time, NULL);
gst_pad_push (mad->srcpad, GST_DATA (discont));
}
break;
}
if (GST_PAD_IS_USABLE (mad->srcpad)) {
discont = gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME,
time, NULL);
gst_pad_push (mad->srcpad, GST_DATA (discont));
}
break;
}
}
mad->tempsize = 0;
/* we don't need to restart when we get here */
@ -1025,14 +1031,14 @@ mpg123_parse_xing_header (struct mad_header *header,
if (xflags & XING_FRAMES_FLAG) {
if (ptr >= (buf + bufsize - 4))
return 0;
return 0;
xframes = BE_32 (ptr);
lprintf ("xframes: %d\n", xframes);
ptr += 4;
}
if (xflags & XING_BYTES_FLAG) {
if (ptr >= (buf + bufsize - 4))
return 0;
return 0;
xbytes = BE_32 (ptr);
lprintf ("xbytes: %d\n", xbytes);
ptr += 4;
@ -1040,10 +1046,10 @@ mpg123_parse_xing_header (struct mad_header *header,
if (xflags & XING_TOC_FLAG) {
lprintf ("toc found\n");
if (ptr >= (buf + bufsize - XING_TOC_LENGTH))
return 0;
return 0;
for (i = 0; i < XING_TOC_LENGTH; i++) {
xtoc[i] = *(ptr + i);
lprintf ("%d ", xtoc[i]);
xtoc[i] = *(ptr + i);
lprintf ("%d ", xtoc[i]);
}
lprintf ("\n");
ptr += XING_TOC_LENGTH;
@ -1052,7 +1058,7 @@ mpg123_parse_xing_header (struct mad_header *header,
xvbr_scale = -1;
if (xflags & XING_VBR_SCALE_FLAG) {
if (ptr >= (buf + bufsize - 4))
return 0;
return 0;
xvbr_scale = BE_32 (ptr);
lprintf ("xvbr_scale: %d\n", xvbr_scale);
}
@ -1060,24 +1066,24 @@ mpg123_parse_xing_header (struct mad_header *header,
/* 1 kbit = 1000 bits ! (and not 1024 bits) */
if (xflags & (XING_FRAMES_FLAG | XING_BYTES_FLAG)) {
if (header->layer == MAD_LAYER_I) {
frame_duration = 384.0 / (double) header->samplerate;
frame_duration = 384.0 / (double) header->samplerate;
} else {
int slots_per_frame;
int slots_per_frame;
slots_per_frame = ((header->layer == MAD_LAYER_III)
&& !lsf_bit) ? 72 : 144;
frame_duration = slots_per_frame * 8.0 / (double) header->samplerate;
slots_per_frame = ((header->layer == MAD_LAYER_III)
&& !lsf_bit) ? 72 : 144;
frame_duration = slots_per_frame * 8.0 / (double) header->samplerate;
}
abr = ((double) xbytes * 8.0) / ((double) xframes * frame_duration);
lprintf ("abr: %d bps\n", abr);
if (bitrate != NULL) {
*bitrate = abr;
*bitrate = abr;
}
if (time != NULL) {
*time = (double) xframes *frame_duration;
*time = (double) xframes *frame_duration;
lprintf ("stream_length: %d s, %d min %d s\n", *time,
*time / 60, *time % 60);
lprintf ("stream_length: %d s, %d min %d s\n", *time,
*time / 60, *time % 60);
}
} else {
/* it's a stupid Xing header */
@ -1169,89 +1175,89 @@ gst_mad_chain (GstPad * pad, GstData * _data)
mad_stream_buffer (&mad->stream, mad_input_buffer, mad->tempsize);
if (mad_frame_decode (&mad->frame, &mad->stream) == -1) {
/* not enough data, need to wait for next buffer? */
if (mad->stream.error == MAD_ERROR_BUFLEN) {
break;
}
if (!MAD_RECOVERABLE (mad->stream.error)) {
GST_ELEMENT_ERROR (mad, STREAM, DECODE, (NULL), (NULL));
return;
} else if (mad->stream.error == MAD_ERROR_LOSTSYNC) {
/* lost sync, force a resync */
signed long tagsize;
/* not enough data, need to wait for next buffer? */
if (mad->stream.error == MAD_ERROR_BUFLEN) {
break;
}
if (!MAD_RECOVERABLE (mad->stream.error)) {
GST_ELEMENT_ERROR (mad, STREAM, DECODE, (NULL), (NULL));
return;
} else if (mad->stream.error == MAD_ERROR_LOSTSYNC) {
/* lost sync, force a resync */
signed long tagsize;
tagsize = id3_tag_query (mad->stream.this_frame,
mad->stream.bufend - mad->stream.this_frame);
tagsize = id3_tag_query (mad->stream.this_frame,
mad->stream.bufend - mad->stream.this_frame);
if (tagsize > mad->tempsize) {
GST_INFO ("mad: got partial id3 tag in buffer, skipping");
} else if (tagsize > 0) {
struct id3_tag *tag;
id3_byte_t const *data;
if (tagsize > mad->tempsize) {
GST_INFO ("mad: got partial id3 tag in buffer, skipping");
} else if (tagsize > 0) {
struct id3_tag *tag;
id3_byte_t const *data;
GST_INFO ("mad: got ID3 tag size %ld", tagsize);
GST_INFO ("mad: got ID3 tag size %ld", tagsize);
data = mad->stream.this_frame;
data = mad->stream.this_frame;
/* mad has moved the pointer to the next frame over the start of the
* id3 tags, so we need to flush one byte less than the tagsize */
mad_stream_skip (&mad->stream, tagsize - 1);
/* mad has moved the pointer to the next frame over the start of the
* id3 tags, so we need to flush one byte less than the tagsize */
mad_stream_skip (&mad->stream, tagsize - 1);
tag = id3_tag_parse (data, tagsize);
if (tag) {
GstTagList *list;
tag = id3_tag_parse (data, tagsize);
if (tag) {
GstTagList *list;
list = gst_mad_id3_to_tag_list (tag);
id3_tag_delete (tag);
GST_DEBUG_OBJECT (mad, "found tag");
gst_element_found_tags (GST_ELEMENT (mad), list);
if (mad->tags) {
gst_tag_list_insert (mad->tags, list, GST_TAG_MERGE_PREPEND);
} else {
mad->tags = gst_tag_list_copy (list);
}
if (GST_PAD_IS_USABLE (mad->srcpad)) {
gst_pad_push (mad->srcpad, GST_DATA (gst_event_new_tag (list)));
} else {
gst_tag_list_free (list);
}
}
}
}
list = gst_mad_id3_to_tag_list (tag);
id3_tag_delete (tag);
GST_DEBUG_OBJECT (mad, "found tag");
gst_element_found_tags (GST_ELEMENT (mad), list);
if (mad->tags) {
gst_tag_list_insert (mad->tags, list, GST_TAG_MERGE_PREPEND);
} else {
mad->tags = gst_tag_list_copy (list);
}
if (GST_PAD_IS_USABLE (mad->srcpad)) {
gst_pad_push (mad->srcpad, GST_DATA (gst_event_new_tag (list)));
} else {
gst_tag_list_free (list);
}
}
}
}
mad_frame_mute (&mad->frame);
mad_synth_mute (&mad->synth);
mad_stream_sync (&mad->stream);
/* recoverable errors pass */
goto next;
mad_frame_mute (&mad->frame);
mad_synth_mute (&mad->synth);
mad_stream_sync (&mad->stream);
/* recoverable errors pass */
goto next;
}
if (mad->check_for_xing) {
int bitrate, time;
GstTagList *list;
int frame_len = mad->stream.next_frame - mad->stream.this_frame;
int bitrate, time;
GstTagList *list;
int frame_len = mad->stream.next_frame - mad->stream.this_frame;
/* Assume Xing headers can only be the first frame in a mp3 file */
if (mpg123_parse_xing_header (&mad->frame.header,
mad->stream.this_frame, frame_len, &bitrate, &time)) {
list = gst_tag_list_new ();
gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
GST_TAG_DURATION, (gint64) time * 1000 * 1000 * 1000,
GST_TAG_BITRATE, bitrate, NULL);
gst_element_found_tags (GST_ELEMENT (mad), list);
if (GST_PAD_IS_USABLE (mad->srcpad)) {
gst_pad_push (mad->srcpad, GST_DATA (gst_event_new_tag (list)));
} else {
gst_tag_list_free (list);
}
}
/* Assume Xing headers can only be the first frame in a mp3 file */
if (mpg123_parse_xing_header (&mad->frame.header,
mad->stream.this_frame, frame_len, &bitrate, &time)) {
list = gst_tag_list_new ();
gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
GST_TAG_DURATION, (gint64) time * 1000 * 1000 * 1000,
GST_TAG_BITRATE, bitrate, NULL);
gst_element_found_tags (GST_ELEMENT (mad), list);
if (GST_PAD_IS_USABLE (mad->srcpad)) {
gst_pad_push (mad->srcpad, GST_DATA (gst_event_new_tag (list)));
} else {
gst_tag_list_free (list);
}
}
mad->check_for_xing = FALSE;
goto next;
mad->check_for_xing = FALSE;
goto next;
}
nchannels = MAD_NCHANNELS (&mad->frame.header);
nsamples = MAD_NSBSAMPLES (&mad->frame.header) *
(mad->stream.options & MAD_OPTION_HALFSAMPLERATE ? 16 : 32);
(mad->stream.options & MAD_OPTION_HALFSAMPLERATE ? 16 : 32);
#if MAD_VERSION_MINOR <= 12
rate = mad->header.sfreq;
@ -1262,91 +1268,91 @@ gst_mad_chain (GstPad * pad, GstData * _data)
gst_mad_update_info (mad);
if (mad->channels != nchannels || mad->rate != rate) {
GstCaps *caps;
GstCaps *caps;
if (mad->stream.options & MAD_OPTION_HALFSAMPLERATE)
rate >>= 1;
if (mad->stream.options & MAD_OPTION_HALFSAMPLERATE)
rate >>= 1;
/* we set the caps even when the pad is not connected so they
* can be gotten for streaminfo */
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, rate, "channels", G_TYPE_INT, nchannels, NULL);
/* we set the caps even when the pad is not connected so they
* can be gotten for streaminfo */
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, rate, "channels", G_TYPE_INT, nchannels, NULL);
gst_pad_set_explicit_caps (mad->srcpad, caps);
gst_caps_free (caps);
mad->channels = nchannels;
mad->rate = rate;
gst_pad_set_explicit_caps (mad->srcpad, caps);
gst_caps_free (caps);
mad->channels = nchannels;
mad->rate = rate;
}
if (mad->frame.header.samplerate == 0) {
g_warning
("mad->frame.header.samplerate is 0; timestamps cannot be calculated");
time_offset = GST_CLOCK_TIME_NONE;
time_duration = GST_CLOCK_TIME_NONE;
g_warning
("mad->frame.header.samplerate is 0; timestamps cannot be calculated");
time_offset = GST_CLOCK_TIME_NONE;
time_duration = GST_CLOCK_TIME_NONE;
} else {
/* if we have a pending timestamp, we can use it now to calculate the sample offset */
if (GST_CLOCK_TIME_IS_VALID (mad->last_ts)) {
GstFormat format = GST_FORMAT_DEFAULT;
/* if we have a pending timestamp, we can use it now to calculate the sample offset */
if (GST_CLOCK_TIME_IS_VALID (mad->last_ts)) {
GstFormat format = GST_FORMAT_DEFAULT;
gst_pad_convert (mad->srcpad, GST_FORMAT_TIME, mad->last_ts, &format,
&mad->total_samples);
mad->last_ts = GST_CLOCK_TIME_NONE;
}
time_offset = mad->total_samples * GST_SECOND
/ mad->frame.header.samplerate;
time_duration = (nsamples * GST_SECOND / mad->frame.header.samplerate);
gst_pad_convert (mad->srcpad, GST_FORMAT_TIME, mad->last_ts, &format,
&mad->total_samples);
mad->last_ts = GST_CLOCK_TIME_NONE;
}
time_offset = mad->total_samples * GST_SECOND
/ mad->frame.header.samplerate;
time_duration = (nsamples * GST_SECOND / mad->frame.header.samplerate);
}
if (mad->index) {
guint64 x_bytes = mad->base_byte_offset + mad->bytes_consumed;
guint64 x_bytes = mad->base_byte_offset + mad->bytes_consumed;
gst_index_add_association (mad->index, mad->index_id, 0,
GST_FORMAT_BYTES, x_bytes, GST_FORMAT_TIME, time_offset, NULL);
gst_index_add_association (mad->index, mad->index_id, 0,
GST_FORMAT_BYTES, x_bytes, GST_FORMAT_TIME, time_offset, NULL);
}
if (GST_PAD_IS_USABLE (mad->srcpad) &&
mad->segment_start <= (time_offset ==
GST_CLOCK_TIME_NONE ? 0 : time_offset)) {
mad->segment_start <= (time_offset ==
GST_CLOCK_TIME_NONE ? 0 : time_offset)) {
/* for sample accurate seeking, calculate how many samples
to skip and send the remaining pcm samples */
/* for sample accurate seeking, calculate how many samples
to skip and send the remaining pcm samples */
GstBuffer *outbuffer;
gint16 *outdata;
mad_fixed_t const *left_ch, *right_ch;
GstBuffer *outbuffer;
gint16 *outdata;
mad_fixed_t const *left_ch, *right_ch;
mad_synth_frame (&mad->synth, &mad->frame);
left_ch = mad->synth.pcm.samples[0];
right_ch = mad->synth.pcm.samples[1];
mad_synth_frame (&mad->synth, &mad->frame);
left_ch = mad->synth.pcm.samples[0];
right_ch = mad->synth.pcm.samples[1];
outbuffer = gst_buffer_new_and_alloc (nsamples * nchannels * 2);
outdata = (gint16 *) GST_BUFFER_DATA (outbuffer);
outbuffer = gst_buffer_new_and_alloc (nsamples * nchannels * 2);
outdata = (gint16 *) GST_BUFFER_DATA (outbuffer);
GST_BUFFER_TIMESTAMP (outbuffer) = time_offset;
GST_BUFFER_DURATION (outbuffer) = time_duration;
GST_BUFFER_OFFSET (outbuffer) = mad->total_samples;
GST_BUFFER_TIMESTAMP (outbuffer) = time_offset;
GST_BUFFER_DURATION (outbuffer) = time_duration;
GST_BUFFER_OFFSET (outbuffer) = mad->total_samples;
/* output sample(s) in 16-bit signed native-endian PCM */
if (nchannels == 1) {
gint count = nsamples;
/* output sample(s) in 16-bit signed native-endian PCM */
if (nchannels == 1) {
gint count = nsamples;
while (count--) {
*outdata++ = scale (*left_ch++) & 0xffff;
}
} else {
gint count = nsamples;
while (count--) {
*outdata++ = scale (*left_ch++) & 0xffff;
}
} else {
gint count = nsamples;
while (count--) {
*outdata++ = scale (*left_ch++) & 0xffff;
*outdata++ = scale (*right_ch++) & 0xffff;
}
}
while (count--) {
*outdata++ = scale (*left_ch++) & 0xffff;
*outdata++ = scale (*right_ch++) & 0xffff;
}
}
gst_pad_push (mad->srcpad, GST_DATA (outbuffer));
gst_pad_push (mad->srcpad, GST_DATA (outbuffer));
}
mad->total_samples += nsamples;
@ -1354,14 +1360,14 @@ gst_mad_chain (GstPad * pad, GstData * _data)
/* we have a queued timestamp on the incoming buffer that we should
* use for the next frame */
if (new_pts) {
mad->last_ts = timestamp;
new_pts = FALSE;
mad->base_byte_offset = GST_BUFFER_OFFSET (buffer);
mad->bytes_consumed = 0;
mad->last_ts = timestamp;
new_pts = FALSE;
mad->base_byte_offset = GST_BUFFER_OFFSET (buffer);
mad->bytes_consumed = 0;
}
if (gst_mad_check_restart (mad)) {
goto end;
goto end;
}
next:
@ -1408,9 +1414,9 @@ gst_mad_change_state (GstElement * element)
mad->frame.header.samplerate = 0;
mad->last_ts = GST_CLOCK_TIME_NONE;
if (mad->ignore_crc)
options |= MAD_OPTION_IGNORECRC;
options |= MAD_OPTION_IGNORECRC;
if (mad->half)
options |= MAD_OPTION_HALFSAMPLERATE;
options |= MAD_OPTION_HALFSAMPLERATE;
mad_stream_options (&mad->stream, options);
break;
}
@ -1425,8 +1431,8 @@ gst_mad_change_state (GstElement * element)
mad_stream_finish (&mad->stream);
mad->restart = TRUE;
if (mad->tags) {
gst_tag_list_free (mad->tags);
mad->tags = NULL;
gst_tag_list_free (mad->tags);
mad->tags = NULL;
}
break;
case GST_STATE_READY_TO_NULL:

View file

@ -67,13 +67,13 @@ GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/x-raw-yuv, "
"format = (fourcc) { YV12, I420 }, "
"width = (int) [ 16, 4096 ], "
"height = (int) [ 16, 4096 ], "
"pixel_width = (int) [ 1, 255 ], "
"pixel_height = (int) [ 1, 255 ], "
"framerate = (double) { 23.976024, 24.0, "
"25.0, 29.970030, 30.0, 50.0, 59.940060, 60.0 }")
"format = (fourcc) { YV12, I420 }, "
"width = (int) [ 16, 4096 ], "
"height = (int) [ 16, 4096 ], "
"pixel_width = (int) [ 1, 255 ], "
"pixel_height = (int) [ 1, 255 ], "
"framerate = (double) { 23.976024, 24.0, "
"25.0, 29.970030, 30.0, 50.0, 59.940060, 60.0 }")
);
#ifdef enable_user_data
@ -89,7 +89,7 @@ GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/mpeg, "
"mpegversion = (int) [ 1, 2 ], " "systemstream = (boolean) false")
"mpegversion = (int) [ 1, 2 ], " "systemstream = (boolean) false")
);
static void gst_mpeg2dec_base_init (gpointer g_class);
@ -143,9 +143,10 @@ gst_mpeg2dec_get_type (void)
0,
(GInstanceInitFunc) gst_mpeg2dec_init,
};
mpeg2dec_type =
g_type_register_static (GST_TYPE_ELEMENT, "GstMpeg2dec", &mpeg2dec_info,
0);
g_type_register_static (GST_TYPE_ELEMENT, "GstMpeg2dec", &mpeg2dec_info,
0);
}
return mpeg2dec_type;
}
@ -400,9 +401,9 @@ gst_mpeg2dec_flush_decoder (GstMpeg2dec * mpeg2dec)
do {
state = mpeg2_parse (mpeg2dec->decoder);
if (state == STATE_END) {
if (info->discard_fbuf && info->discard_fbuf->id) {
gst_buffer_unref ((GstBuffer *) info->discard_fbuf->id);
}
if (info->discard_fbuf && info->discard_fbuf->id) {
gst_buffer_unref ((GstBuffer *) info->discard_fbuf->id);
}
}
}
while (state != STATE_BUFFER && state != -1);
@ -427,20 +428,20 @@ gst_mpeg2dec_chain (GstPad * pad, GstData * _data)
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_DISCONTINUOUS:
{
GST_DEBUG ("discont");
mpeg2dec->next_time = 0;
mpeg2dec->discont_state = MPEG2DEC_DISC_NEW_PICTURE;
gst_mpeg2dec_flush_decoder (mpeg2dec);
gst_pad_event_default (pad, event);
return;
GST_DEBUG ("discont");
mpeg2dec->next_time = 0;
mpeg2dec->discont_state = MPEG2DEC_DISC_NEW_PICTURE;
gst_mpeg2dec_flush_decoder (mpeg2dec);
gst_pad_event_default (pad, event);
return;
}
case GST_EVENT_EOS:
if (mpeg2dec->index && mpeg2dec->closed) {
gst_index_commit (mpeg2dec->index, mpeg2dec->index_id);
}
if (mpeg2dec->index && mpeg2dec->closed) {
gst_index_commit (mpeg2dec->index, mpeg2dec->index_id);
}
default:
gst_pad_event_default (pad, event);
return;
gst_pad_event_default (pad, event);
return;
}
}
@ -455,11 +456,11 @@ gst_mpeg2dec_chain (GstPad * pad, GstData * _data)
gint64 mpeg_pts = GSTTIME_TO_MPEGTIME (pts);
GST_DEBUG ("have pts: %" G_GINT64_FORMAT " (%" G_GINT64_FORMAT ")",
mpeg_pts, MPEGTIME_TO_GSTTIME (mpeg_pts));
mpeg_pts, MPEGTIME_TO_GSTTIME (mpeg_pts));
#if MPEG2_RELEASE >= MPEG2_VERSION(0,4,0)
mpeg2_tag_picture (mpeg2dec->decoder, mpeg_pts & 0xffffffff,
mpeg_pts >> 32);
mpeg_pts >> 32);
#else
mpeg2_pts (mpeg2dec->decoder, mpeg_pts);
#endif
@ -480,186 +481,186 @@ gst_mpeg2dec_chain (GstPad * pad, GstData * _data)
switch (state) {
case STATE_SEQUENCE:
{
mpeg2dec->width = info->sequence->width;
mpeg2dec->height = info->sequence->height;
mpeg2dec->pixel_width = info->sequence->pixel_width;
mpeg2dec->pixel_height = info->sequence->pixel_height;
mpeg2dec->total_frames = 0;
mpeg2dec->frame_period =
info->sequence->frame_period * GST_USECOND / 27;
mpeg2dec->width = info->sequence->width;
mpeg2dec->height = info->sequence->height;
mpeg2dec->pixel_width = info->sequence->pixel_width;
mpeg2dec->pixel_height = info->sequence->pixel_height;
mpeg2dec->total_frames = 0;
mpeg2dec->frame_period =
info->sequence->frame_period * GST_USECOND / 27;
GST_DEBUG ("sequence flags: %d, frame period: %d",
info->sequence->flags, info->sequence->frame_period);
GST_DEBUG ("profile: %02x, colour_primaries: %d",
info->sequence->profile_level_id, info->sequence->colour_primaries);
GST_DEBUG ("transfer chars: %d, matrix coef: %d",
info->sequence->transfer_characteristics,
info->sequence->matrix_coefficients);
GST_DEBUG ("sequence flags: %d, frame period: %d",
info->sequence->flags, info->sequence->frame_period);
GST_DEBUG ("profile: %02x, colour_primaries: %d",
info->sequence->profile_level_id, info->sequence->colour_primaries);
GST_DEBUG ("transfer chars: %d, matrix coef: %d",
info->sequence->transfer_characteristics,
info->sequence->matrix_coefficients);
if (!gst_mpeg2dec_negotiate_format (mpeg2dec)) {
GST_ELEMENT_ERROR (mpeg2dec, CORE, NEGOTIATION, (NULL), (NULL));
goto exit;
}
if (!gst_mpeg2dec_negotiate_format (mpeg2dec)) {
GST_ELEMENT_ERROR (mpeg2dec, CORE, NEGOTIATION, (NULL), (NULL));
goto exit;
}
if (!mpeg2dec->have_fbuf) {
/* alloc 3 buffers */
gst_mpeg2dec_alloc_buffer (mpeg2dec, info, GST_BUFFER_OFFSET (buf));
gst_mpeg2dec_alloc_buffer (mpeg2dec, info, GST_BUFFER_OFFSET (buf));
gst_mpeg2dec_alloc_buffer (mpeg2dec, info, GST_BUFFER_OFFSET (buf));
mpeg2dec->have_fbuf = TRUE;
}
if (!mpeg2dec->have_fbuf) {
/* alloc 3 buffers */
gst_mpeg2dec_alloc_buffer (mpeg2dec, info, GST_BUFFER_OFFSET (buf));
gst_mpeg2dec_alloc_buffer (mpeg2dec, info, GST_BUFFER_OFFSET (buf));
gst_mpeg2dec_alloc_buffer (mpeg2dec, info, GST_BUFFER_OFFSET (buf));
mpeg2dec->have_fbuf = TRUE;
}
mpeg2dec->need_sequence = FALSE;
if (mpeg2dec->pending_event) {
done =
GST_EVENT_SEEK_FLAGS (mpeg2dec->
pending_event) & GST_SEEK_FLAG_FLUSH;
mpeg2dec->need_sequence = FALSE;
if (mpeg2dec->pending_event) {
done =
GST_EVENT_SEEK_FLAGS (mpeg2dec->
pending_event) & GST_SEEK_FLAG_FLUSH;
gst_mpeg2dec_src_event (mpeg2dec->srcpad, mpeg2dec->pending_event);
mpeg2dec->pending_event = NULL;
}
break;
gst_mpeg2dec_src_event (mpeg2dec->srcpad, mpeg2dec->pending_event);
mpeg2dec->pending_event = NULL;
}
break;
}
case STATE_SEQUENCE_REPEATED:
GST_DEBUG ("sequence repeated");
GST_DEBUG ("sequence repeated");
case STATE_GOP:
break;
break;
case STATE_PICTURE:
{
gboolean key_frame = FALSE;
GstBuffer *outbuf;
gboolean key_frame = FALSE;
GstBuffer *outbuf;
if (info->current_picture) {
key_frame =
(info->current_picture->flags & PIC_MASK_CODING_TYPE) ==
PIC_FLAG_CODING_TYPE_I;
}
outbuf =
gst_mpeg2dec_alloc_buffer (mpeg2dec, info, GST_BUFFER_OFFSET (buf));
if (info->current_picture) {
key_frame =
(info->current_picture->flags & PIC_MASK_CODING_TYPE) ==
PIC_FLAG_CODING_TYPE_I;
}
outbuf =
gst_mpeg2dec_alloc_buffer (mpeg2dec, info, GST_BUFFER_OFFSET (buf));
GST_DEBUG ("picture %d, %p, %" G_GINT64_FORMAT ", %" G_GINT64_FORMAT,
key_frame, outbuf, GST_BUFFER_OFFSET (outbuf), pts);
GST_DEBUG ("picture %d, %p, %" G_GINT64_FORMAT ", %" G_GINT64_FORMAT,
key_frame, outbuf, GST_BUFFER_OFFSET (outbuf), pts);
if (mpeg2dec->discont_state == MPEG2DEC_DISC_NEW_PICTURE && key_frame)
mpeg2dec->discont_state = MPEG2DEC_DISC_NEW_KEYFRAME;
if (mpeg2dec->discont_state == MPEG2DEC_DISC_NEW_PICTURE && key_frame)
mpeg2dec->discont_state = MPEG2DEC_DISC_NEW_KEYFRAME;
if (!GST_PAD_IS_USABLE (mpeg2dec->srcpad))
mpeg2_skip (mpeg2dec->decoder, 1);
else
mpeg2_skip (mpeg2dec->decoder, 0);
if (!GST_PAD_IS_USABLE (mpeg2dec->srcpad))
mpeg2_skip (mpeg2dec->decoder, 1);
else
mpeg2_skip (mpeg2dec->decoder, 0);
break;
break;
}
case STATE_SLICE_1ST:
GST_DEBUG ("slice 1st");
break;
GST_DEBUG ("slice 1st");
break;
case STATE_PICTURE_2ND:
GST_DEBUG ("picture second");
break;
GST_DEBUG ("picture second");
break;
case STATE_SLICE:
slice = TRUE;
slice = TRUE;
#if MPEG2_RELEASE >= MPEG2_VERSION (0, 4, 0)
case STATE_INVALID_END:
#endif
case STATE_END:
{
GstBuffer *outbuf = NULL;
gboolean skip = FALSE;
GstBuffer *outbuf = NULL;
gboolean skip = FALSE;
if (!slice) {
mpeg2dec->need_sequence = TRUE;
}
GST_DEBUG ("picture end %p %p %p %p", info->display_fbuf,
info->display_picture, info->current_picture,
(info->display_fbuf ? info->display_fbuf->id : NULL));
if (!slice) {
mpeg2dec->need_sequence = TRUE;
}
GST_DEBUG ("picture end %p %p %p %p", info->display_fbuf,
info->display_picture, info->current_picture,
(info->display_fbuf ? info->display_fbuf->id : NULL));
if (info->display_fbuf && info->display_fbuf->id) {
const mpeg2_picture_t *picture;
gboolean key_frame = FALSE;
if (info->display_fbuf && info->display_fbuf->id) {
const mpeg2_picture_t *picture;
gboolean key_frame = FALSE;
outbuf = (GstBuffer *) info->display_fbuf->id;
picture = info->display_picture;
outbuf = (GstBuffer *) info->display_fbuf->id;
picture = info->display_picture;
key_frame =
(picture->flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_I;
GST_DEBUG ("picture keyfame %d", key_frame);
key_frame =
(picture->flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_I;
GST_DEBUG ("picture keyfame %d", key_frame);
if (key_frame) {
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_KEY_UNIT);
}
if (mpeg2dec->discont_state == MPEG2DEC_DISC_NEW_KEYFRAME
&& key_frame)
mpeg2dec->discont_state = MPEG2DEC_DISC_NONE;
if (key_frame) {
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_KEY_UNIT);
}
if (mpeg2dec->discont_state == MPEG2DEC_DISC_NEW_KEYFRAME
&& key_frame)
mpeg2dec->discont_state = MPEG2DEC_DISC_NONE;
#if MPEG2_RELEASE < MPEG2_VERSION(0,4,0)
if (picture->flags & PIC_FLAG_PTS) {
GstClockTime time = MPEGTIME_TO_GSTTIME (picture->pts);
if (picture->flags & PIC_FLAG_PTS) {
GstClockTime time = MPEGTIME_TO_GSTTIME (picture->pts);
#else
if (picture->flags & PIC_FLAG_TAGS) {
GstClockTime time =
MPEGTIME_TO_GSTTIME ((guint64) picture->tag2 << 32 | picture->
tag);
if (picture->flags & PIC_FLAG_TAGS) {
GstClockTime time =
MPEGTIME_TO_GSTTIME ((guint64) picture->tag2 << 32 | picture->
tag);
#endif
GST_DEBUG ("picture had pts %" G_GINT64_FORMAT, time);
GST_BUFFER_TIMESTAMP (outbuf) = mpeg2dec->next_time = time;
} else {
GST_DEBUG ("picture didn't have pts using %" G_GINT64_FORMAT,
mpeg2dec->next_time);
GST_BUFFER_TIMESTAMP (outbuf) = mpeg2dec->next_time;
}
GST_DEBUG ("picture had pts %" G_GINT64_FORMAT, time);
GST_BUFFER_TIMESTAMP (outbuf) = mpeg2dec->next_time = time;
} else {
GST_DEBUG ("picture didn't have pts using %" G_GINT64_FORMAT,
mpeg2dec->next_time);
GST_BUFFER_TIMESTAMP (outbuf) = mpeg2dec->next_time;
}
mpeg2dec->next_time +=
(mpeg2dec->frame_period * picture->nb_fields) >> 1;
mpeg2dec->next_time +=
(mpeg2dec->frame_period * picture->nb_fields) >> 1;
GST_DEBUG ("picture: %s %s fields:%d off:%" G_GINT64_FORMAT " ts:%"
G_GINT64_FORMAT,
(picture->flags & PIC_FLAG_TOP_FIELD_FIRST ? "tff " : " "),
(picture->flags & PIC_FLAG_PROGRESSIVE_FRAME ? "prog" : " "),
picture->nb_fields, GST_BUFFER_OFFSET (outbuf),
GST_BUFFER_TIMESTAMP (outbuf));
GST_DEBUG ("picture: %s %s fields:%d off:%" G_GINT64_FORMAT " ts:%"
G_GINT64_FORMAT,
(picture->flags & PIC_FLAG_TOP_FIELD_FIRST ? "tff " : " "),
(picture->flags & PIC_FLAG_PROGRESSIVE_FRAME ? "prog" : " "),
picture->nb_fields, GST_BUFFER_OFFSET (outbuf),
GST_BUFFER_TIMESTAMP (outbuf));
if (mpeg2dec->index) {
gst_index_add_association (mpeg2dec->index, mpeg2dec->index_id,
(key_frame ? GST_ASSOCIATION_FLAG_KEY_UNIT : 0),
GST_FORMAT_BYTES, GST_BUFFER_OFFSET (outbuf),
GST_FORMAT_TIME, GST_BUFFER_TIMESTAMP (outbuf), 0);
}
if (mpeg2dec->index) {
gst_index_add_association (mpeg2dec->index, mpeg2dec->index_id,
(key_frame ? GST_ASSOCIATION_FLAG_KEY_UNIT : 0),
GST_FORMAT_BYTES, GST_BUFFER_OFFSET (outbuf),
GST_FORMAT_TIME, GST_BUFFER_TIMESTAMP (outbuf), 0);
}
if (picture->flags & PIC_FLAG_SKIP ||
!GST_PAD_IS_USABLE (mpeg2dec->srcpad) ||
mpeg2dec->discont_state != MPEG2DEC_DISC_NONE ||
mpeg2dec->next_time < mpeg2dec->segment_start || skip) {
gst_buffer_unref (outbuf);
} else {
/* TODO set correct offset here based on frame number */
GST_BUFFER_DURATION (outbuf) = mpeg2dec->frame_period;
gst_pad_push (mpeg2dec->srcpad, GST_DATA (outbuf));
}
}
if (info->discard_fbuf && info->discard_fbuf->id) {
gst_buffer_unref ((GstBuffer *) info->discard_fbuf->id);
}
break;
if (picture->flags & PIC_FLAG_SKIP ||
!GST_PAD_IS_USABLE (mpeg2dec->srcpad) ||
mpeg2dec->discont_state != MPEG2DEC_DISC_NONE ||
mpeg2dec->next_time < mpeg2dec->segment_start || skip) {
gst_buffer_unref (outbuf);
} else {
/* TODO set correct offset here based on frame number */
GST_BUFFER_DURATION (outbuf) = mpeg2dec->frame_period;
gst_pad_push (mpeg2dec->srcpad, GST_DATA (outbuf));
}
}
if (info->discard_fbuf && info->discard_fbuf->id) {
gst_buffer_unref ((GstBuffer *) info->discard_fbuf->id);
}
break;
}
/* need more data */
/* need more data */
case STATE_BUFFER:
case -1:
done = TRUE;
break;
/* error */
done = TRUE;
break;
/* error */
case STATE_INVALID:
g_warning ("mpeg2dec: decoding error");
/* it looks like setting a new frame in libmpeg2 avoids a crash */
/* FIXME figure out how this screws up sync and buffer leakage */
gst_mpeg2dec_alloc_buffer (mpeg2dec, info, GST_BUFFER_OFFSET (buf));
break;
g_warning ("mpeg2dec: decoding error");
/* it looks like setting a new frame in libmpeg2 avoids a crash */
/* FIXME figure out how this screws up sync and buffer leakage */
gst_mpeg2dec_alloc_buffer (mpeg2dec, info, GST_BUFFER_OFFSET (buf));
break;
default:
g_warning ("%s: unhandled state %d, FIXME",
gst_element_get_name (GST_ELEMENT (mpeg2dec)), state);
break;
g_warning ("%s: unhandled state %d, FIXME",
gst_element_get_name (GST_ELEMENT (mpeg2dec)), state);
break;
}
/*
@ -668,11 +669,11 @@ gst_mpeg2dec_chain (GstPad * pad, GstData * _data)
#ifdef enable_user_data
if (info->user_data_len > 0) {
if (GST_PAD_IS_USABLE (mpeg2dec->userdatapad)) {
GstBuffer *udbuf = gst_buffer_new_and_alloc (info->user_data_len);
GstBuffer *udbuf = gst_buffer_new_and_alloc (info->user_data_len);
memcpy (GST_BUFFER_DATA (udbuf), info->user_data, info->user_data_len);
memcpy (GST_BUFFER_DATA (udbuf), info->user_data, info->user_data_len);
gst_pad_push (mpeg2dec->userdatapad, GST_DATA (udbuf));
gst_pad_push (mpeg2dec->userdatapad, GST_DATA (udbuf));
}
}
#endif
@ -689,6 +690,7 @@ gst_mpeg2dec_get_sink_formats (GstPad * pad)
GST_FORMAT_TIME,
0
};
return formats;
}
@ -710,24 +712,24 @@ gst_mpeg2dec_convert_sink (GstPad * pad, GstFormat src_format, gint64 src_value,
switch (src_format) {
case GST_FORMAT_BYTES:
switch (*dest_format) {
case GST_FORMAT_TIME:
if (info->sequence && info->sequence->byte_rate) {
*dest_value = GST_SECOND * src_value / info->sequence->byte_rate;
break;
}
default:
res = FALSE;
case GST_FORMAT_TIME:
if (info->sequence && info->sequence->byte_rate) {
*dest_value = GST_SECOND * src_value / info->sequence->byte_rate;
break;
}
default:
res = FALSE;
}
break;
case GST_FORMAT_TIME:
switch (*dest_format) {
case GST_FORMAT_BYTES:
if (info->sequence && info->sequence->byte_rate) {
*dest_value = src_value * info->sequence->byte_rate / GST_SECOND;
break;
}
default:
res = FALSE;
case GST_FORMAT_BYTES:
if (info->sequence && info->sequence->byte_rate) {
*dest_value = src_value * info->sequence->byte_rate / GST_SECOND;
break;
}
default:
res = FALSE;
}
break;
default:
@ -745,6 +747,7 @@ gst_mpeg2dec_get_src_formats (GstPad * pad)
GST_FORMAT_DEFAULT,
0
};
return formats;
}
@ -767,35 +770,35 @@ gst_mpeg2dec_convert_src (GstPad * pad, GstFormat src_format, gint64 src_value,
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:
scale = 6 * (mpeg2dec->width * mpeg2dec->height >> 2);
case GST_FORMAT_DEFAULT:
if (info->sequence && mpeg2dec->frame_period) {
*dest_value = src_value * scale / mpeg2dec->frame_period;
break;
}
default:
res = FALSE;
case GST_FORMAT_BYTES:
scale = 6 * (mpeg2dec->width * mpeg2dec->height >> 2);
case GST_FORMAT_DEFAULT:
if (info->sequence && mpeg2dec->frame_period) {
*dest_value = src_value * scale / mpeg2dec->frame_period;
break;
}
default:
res = FALSE;
}
break;
case GST_FORMAT_DEFAULT:
switch (*dest_format) {
case GST_FORMAT_TIME:
*dest_value = src_value * mpeg2dec->frame_period;
break;
case GST_FORMAT_BYTES:
*dest_value =
src_value * 6 * ((mpeg2dec->width * mpeg2dec->height) >> 2);
break;
default:
res = FALSE;
case GST_FORMAT_TIME:
*dest_value = src_value * mpeg2dec->frame_period;
break;
case GST_FORMAT_BYTES:
*dest_value =
src_value * 6 * ((mpeg2dec->width * mpeg2dec->height) >> 2);
break;
default:
res = FALSE;
}
break;
default:
@ -812,6 +815,7 @@ gst_mpeg2dec_get_src_query_types (GstPad * pad)
GST_QUERY_POSITION,
0
};
return types;
}
@ -829,52 +833,52 @@ gst_mpeg2dec_src_query (GstPad * pad, GstQueryType type,
case GST_QUERY_TOTAL:
{
switch (*format) {
case GST_FORMAT_TIME:
case GST_FORMAT_BYTES:
case GST_FORMAT_DEFAULT:
{
res = FALSE;
case GST_FORMAT_TIME:
case GST_FORMAT_BYTES:
case GST_FORMAT_DEFAULT:
{
res = FALSE;
/* get our peer formats */
formats = gst_pad_get_formats (GST_PAD_PEER (mpeg2dec->sinkpad));
/* get our peer formats */
formats = gst_pad_get_formats (GST_PAD_PEER (mpeg2dec->sinkpad));
/* while we did not exhaust our seek formats without result */
while (formats && *formats) {
GstFormat peer_format;
gint64 peer_value;
/* while we did not exhaust our seek formats without result */
while (formats && *formats) {
GstFormat peer_format;
gint64 peer_value;
peer_format = *formats;
peer_format = *formats;
/* do the probe */
if (gst_pad_query (GST_PAD_PEER (mpeg2dec->sinkpad),
GST_QUERY_TOTAL, &peer_format, &peer_value)) {
GstFormat conv_format;
/* do the probe */
if (gst_pad_query (GST_PAD_PEER (mpeg2dec->sinkpad),
GST_QUERY_TOTAL, &peer_format, &peer_value)) {
GstFormat conv_format;
/* convert to TIME */
conv_format = GST_FORMAT_TIME;
res = gst_pad_convert (mpeg2dec->sinkpad,
peer_format, peer_value, &conv_format, value);
/* and to final format */
res &= gst_pad_convert (pad,
GST_FORMAT_TIME, *value, format, value);
}
formats++;
}
break;
}
default:
res = FALSE;
break;
/* convert to TIME */
conv_format = GST_FORMAT_TIME;
res = gst_pad_convert (mpeg2dec->sinkpad,
peer_format, peer_value, &conv_format, value);
/* and to final format */
res &= gst_pad_convert (pad,
GST_FORMAT_TIME, *value, format, value);
}
formats++;
}
break;
}
default:
res = FALSE;
break;
}
break;
}
case GST_QUERY_POSITION:
{
switch (*format) {
default:
res = gst_pad_convert (pad,
GST_FORMAT_TIME, mpeg2dec->next_time, format, value);
break;
default:
res = gst_pad_convert (pad,
GST_FORMAT_TIME, mpeg2dec->next_time, format, value);
break;
}
break;
}
@ -895,6 +899,7 @@ gst_mpeg2dec_get_src_event_masks (GstPad * pad)
{GST_EVENT_NAVIGATION, GST_EVENT_FLAG_NONE},
{0,}
};
return masks;
}
@ -927,25 +932,25 @@ index_seek (GstPad * pad, GstEvent * event)
gint64 value;
if (gst_index_entry_assoc_map (entry, *try_formats, &value)) {
GstEvent *seek_event;
GstEvent *seek_event;
GST_CAT_DEBUG (GST_CAT_SEEK, "index %s %" G_GINT64_FORMAT
" -> %s %" G_GINT64_FORMAT,
gst_format_get_details (GST_EVENT_SEEK_FORMAT (event))->nick,
GST_EVENT_SEEK_OFFSET (event),
gst_format_get_details (*try_formats)->nick, value);
GST_CAT_DEBUG (GST_CAT_SEEK, "index %s %" G_GINT64_FORMAT
" -> %s %" G_GINT64_FORMAT,
gst_format_get_details (GST_EVENT_SEEK_FORMAT (event))->nick,
GST_EVENT_SEEK_OFFSET (event),
gst_format_get_details (*try_formats)->nick, value);
/* lookup succeeded, create the seek */
seek_event =
gst_event_new_seek (*try_formats | GST_SEEK_METHOD_SET |
GST_SEEK_FLAG_FLUSH, value);
/* do the seekk */
if (gst_pad_send_event (GST_PAD_PEER (mpeg2dec->sinkpad), seek_event)) {
/* seek worked, we're done, loop will exit */
gst_mpeg2dec_flush_decoder (mpeg2dec);
mpeg2dec->segment_start = GST_EVENT_SEEK_OFFSET (event);
return TRUE;
}
/* lookup succeeded, create the seek */
seek_event =
gst_event_new_seek (*try_formats | GST_SEEK_METHOD_SET |
GST_SEEK_FLAG_FLUSH, value);
/* do the seekk */
if (gst_pad_send_event (GST_PAD_PEER (mpeg2dec->sinkpad), seek_event)) {
/* seek worked, we're done, loop will exit */
gst_mpeg2dec_flush_decoder (mpeg2dec);
mpeg2dec->segment_start = GST_EVENT_SEEK_OFFSET (event);
return TRUE;
}
}
try_formats++;
}
@ -970,8 +975,8 @@ normal_seek (GstPad * pad, GstEvent * event)
/* 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)) {
GST_EVENT_SEEK_FORMAT (event), GST_EVENT_SEEK_OFFSET (event),
&format, &src_offset)) {
/* didn't work, probably unsupported seek format then */
return res;
}
@ -990,19 +995,19 @@ normal_seek (GstPad * pad, GstEvent * event)
/* try to convert requested format to one we can seek with on the sinkpad */
if (gst_pad_convert (mpeg2dec->sinkpad, GST_FORMAT_TIME, src_offset,
&format, &desired_offset)) {
&format, &desired_offset)) {
GstEvent *seek_event;
/* conversion succeeded, create the seek */
seek_event =
gst_event_new_seek (format | GST_SEEK_METHOD_SET | flush,
desired_offset);
gst_event_new_seek (format | GST_SEEK_METHOD_SET | flush,
desired_offset);
/* do the seekk */
if (gst_pad_send_event (GST_PAD_PEER (mpeg2dec->sinkpad), seek_event)) {
/* seek worked, we're done, loop will exit */
mpeg2dec->segment_start = GST_EVENT_SEEK_OFFSET (event);
res = TRUE;
break;
/* seek worked, we're done, loop will exit */
mpeg2dec->segment_start = GST_EVENT_SEEK_OFFSET (event);
res = TRUE;
break;
}
}
peer_formats++;
@ -1032,16 +1037,16 @@ gst_mpeg2dec_src_event (GstPad * pad, GstEvent * event)
/* the all-formats seek logic */
case GST_EVENT_SEEK:
if (mpeg2dec->need_sequence) {
mpeg2dec->pending_event = event;
return TRUE;
mpeg2dec->pending_event = event;
return TRUE;
} else {
if (mpeg2dec->index)
res = index_seek (pad, event);
else
res = normal_seek (pad, event);
if (mpeg2dec->index)
res = index_seek (pad, event);
else
res = normal_seek (pad, event);
if (res)
mpeg2dec->discont_state = MPEG2DEC_DISC_NEW_PICTURE;
if (res)
mpeg2dec->discont_state = MPEG2DEC_DISC_NEW_PICTURE;
}
break;
case GST_EVENT_NAVIGATION:
@ -1131,7 +1136,7 @@ static gboolean
plugin_init (GstPlugin * plugin)
{
if (!gst_element_register (plugin, "mpeg2dec", GST_RANK_PRIMARY,
GST_TYPE_MPEG2DEC))
GST_TYPE_MPEG2DEC))
return FALSE;
return TRUE;

View file

@ -61,11 +61,11 @@ static GstStaticPadTemplate src_templ = 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, false }, "
"width = (int) { 8, 16 }, "
"depth = (int) { 8, 16 }, "
"rate = (int) [ 8000, 48000 ], " "channels = (int) [ 1, 2 ]")
"endianness = (int) BYTE_ORDER, "
"signed = (boolean) { true, false }, "
"width = (int) { 8, 16 }, "
"depth = (int) { 8, 16 }, "
"rate = (int) [ 8000, 48000 ], " "channels = (int) [ 1, 2 ]")
);
enum
@ -85,6 +85,7 @@ gst_sid_clock_get_type (void)
{SIDTUNE_CLOCK_NTSC, "1", "NTSC"},
{0, NULL, NULL},
};
if (!sid_clock_type) {
sid_clock_type = g_enum_register_static ("GstSidClock", sid_clock);
}
@ -102,6 +103,7 @@ gst_sid_memory_get_type (void)
{MPU_PLAYSID_ENVIRONMENT, "34", "Playsid Environment"},
{0, NULL, NULL},
};
if (!sid_memory_type) {
sid_memory_type = g_enum_register_static ("GstSidMemory", sid_memory);
}
@ -146,9 +148,10 @@ gst_siddec_get_type (void)
(GInstanceInitFunc) gst_siddec_init,
NULL
};
siddec_type =
g_type_register_static (GST_TYPE_ELEMENT, "GstSidDec", &siddec_info,
(GTypeFlags) 0);
g_type_register_static (GST_TYPE_ELEMENT, "GstSidDec", &siddec_info,
(GTypeFlags) 0);
}
return siddec_type;
@ -186,33 +189,33 @@ gst_siddec_class_init (GstSidDec * klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TUNE,
g_param_spec_int ("tune", "tune", "tune",
1, 100, 1, (GParamFlags) G_PARAM_READWRITE));
1, 100, 1, (GParamFlags) G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_CLOCK,
g_param_spec_enum ("clock", "clock", "clock",
GST_TYPE_SID_CLOCK, SIDTUNE_CLOCK_PAL,
(GParamFlags) G_PARAM_READWRITE));
GST_TYPE_SID_CLOCK, SIDTUNE_CLOCK_PAL,
(GParamFlags) G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MEMORY,
g_param_spec_enum ("memory", "memory", "memory", GST_TYPE_SID_MEMORY,
MPU_PLAYSID_ENVIRONMENT, (GParamFlags) G_PARAM_READWRITE));
MPU_PLAYSID_ENVIRONMENT, (GParamFlags) G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FILTER,
g_param_spec_boolean ("filter", "filter", "filter", TRUE,
(GParamFlags) G_PARAM_READWRITE));
(GParamFlags) G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MEASURED_VOLUME,
g_param_spec_boolean ("measured_volume", "measured_volume",
"measured_volume", TRUE, (GParamFlags) G_PARAM_READWRITE));
"measured_volume", TRUE, (GParamFlags) G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MOS8580,
g_param_spec_boolean ("mos8580", "mos8580", "mos8580", TRUE,
(GParamFlags) G_PARAM_READWRITE));
(GParamFlags) G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FORCE_SPEED,
g_param_spec_boolean ("force_speed", "force_speed", "force_speed", TRUE,
(GParamFlags) G_PARAM_READWRITE));
(GParamFlags) G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BLOCKSIZE,
g_param_spec_ulong ("blocksize", "Block size",
"Size in bytes to output per buffer", 1, G_MAXULONG,
DEFAULT_BLOCKSIZE, (GParamFlags) G_PARAM_READWRITE));
"Size in bytes to output per buffer", 1, G_MAXULONG,
DEFAULT_BLOCKSIZE, (GParamFlags) G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_METADATA,
g_param_spec_boxed ("metadata", "Metadata", "Metadata", GST_TYPE_CAPS,
(GParamFlags) G_PARAM_READABLE));
(GParamFlags) G_PARAM_READABLE));
gobject_class->set_property = gst_siddec_set_property;
gobject_class->get_property = gst_siddec_get_property;
@ -242,24 +245,24 @@ gst_siddec_init (GstSidDec * siddec)
siddec->tune = new sidTune (0);
siddec->config = (emuConfig *) g_malloc (sizeof (emuConfig));
siddec->config->frequency = 44100; // frequency
siddec->config->bitsPerSample = SIDEMU_16BIT; // bits per sample
siddec->config->sampleFormat = SIDEMU_SIGNED_PCM; // sample fomat
siddec->config->channels = SIDEMU_STEREO; // channels
siddec->config->frequency = 44100; // frequency
siddec->config->bitsPerSample = SIDEMU_16BIT; // bits per sample
siddec->config->sampleFormat = SIDEMU_SIGNED_PCM; // sample fomat
siddec->config->channels = SIDEMU_STEREO; // channels
siddec->config->sidChips = 0; // -
siddec->config->volumeControl = SIDEMU_NONE; // volume control
siddec->config->mos8580 = TRUE; // mos8580
siddec->config->measuredVolume = TRUE; // measure volume
siddec->config->emulateFilter = TRUE; // emulate filter
siddec->config->filterFs = SIDEMU_DEFAULTFILTERFS; // filter Fs
siddec->config->filterFm = SIDEMU_DEFAULTFILTERFM; // filter Fm
siddec->config->filterFt = SIDEMU_DEFAULTFILTERFT; // filter Ft
siddec->config->memoryMode = MPU_PLAYSID_ENVIRONMENT; // memory mode
siddec->config->clockSpeed = SIDTUNE_CLOCK_PAL; // clock speed
siddec->config->forceSongSpeed = TRUE; // force song speed
siddec->config->digiPlayerScans = 0; // digi player scans
siddec->config->autoPanning = SIDEMU_NONE; // auto panning
siddec->config->sidChips = 0; // -
siddec->config->volumeControl = SIDEMU_NONE; // volume control
siddec->config->mos8580 = TRUE; // mos8580
siddec->config->measuredVolume = TRUE; // measure volume
siddec->config->emulateFilter = TRUE; // emulate filter
siddec->config->filterFs = SIDEMU_DEFAULTFILTERFS; // filter Fs
siddec->config->filterFm = SIDEMU_DEFAULTFILTERFM; // filter Fm
siddec->config->filterFt = SIDEMU_DEFAULTFILTERFT; // filter Ft
siddec->config->memoryMode = MPU_PLAYSID_ENVIRONMENT; // memory mode
siddec->config->clockSpeed = SIDTUNE_CLOCK_PAL; // clock speed
siddec->config->forceSongSpeed = TRUE; // force song speed
siddec->config->digiPlayerScans = 0; // digi player scans
siddec->config->autoPanning = SIDEMU_NONE; // auto panning
siddec->engine->setConfig (*siddec->config);
siddec->engine->setDefaultFilterStrength ();
@ -289,18 +292,18 @@ update_metadata (GstSidDec * siddec)
}
if (info.authorString) {
entry =
gst_props_entry_new ("Composer", G_TYPE_STRING (info.authorString));
gst_props_entry_new ("Composer", G_TYPE_STRING (info.authorString));
gst_props_add_entry (props, entry);
}
if (info.copyrightString) {
entry =
gst_props_entry_new ("Copyright",
G_TYPE_STRING (info.copyrightString));
gst_props_entry_new ("Copyright",
G_TYPE_STRING (info.copyrightString));
gst_props_add_entry (props, entry);
}
siddec->metadata = gst_caps_new ("sid_metadata",
"application/x-gst-metadata", props);
"application/x-gst-metadata", props);
g_object_notify (G_OBJECT (siddec), "metadata");
}
@ -357,13 +360,13 @@ siddec_negotiate (GstSidDec * siddec)
if (!GST_PAD_CAPS (siddec->srcpad)) {
if (!gst_pad_try_set_caps (siddec->srcpad,
gst_caps_new_simple ("audio/x-raw-int",
"endianness", G_TYPE_INT, G_BYTE_ORDER,
"signed", G_TYPE_BOOLEAN, sign,
"width", G_TYPE_INT, siddec->config->bitsPerSample,
"depth", G_TYPE_INT, siddec->config->bitsPerSample,
"rate", G_TYPE_INT, siddec->config->frequency,
"channels", G_TYPE_INT, siddec->config->channels, NULL))) {
gst_caps_new_simple ("audio/x-raw-int",
"endianness", G_TYPE_INT, G_BYTE_ORDER,
"signed", G_TYPE_BOOLEAN, sign,
"width", G_TYPE_INT, siddec->config->bitsPerSample,
"depth", G_TYPE_INT, siddec->config->bitsPerSample,
"rate", G_TYPE_INT, siddec->config->frequency,
"channels", G_TYPE_INT, siddec->config->channels, NULL))) {
return FALSE;
}
}
@ -389,24 +392,24 @@ gst_siddec_loop (GstElement * element)
GstEvent *event = GST_EVENT (data);
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS:
siddec->state = SID_STATE_LOAD_TUNE;
break;
case GST_EVENT_DISCONTINUOUS:
break;
default:
// bail out, we're not going to do anything
gst_event_unref (event);
gst_pad_send_event (siddec->srcpad, gst_event_new (GST_EVENT_EOS));
gst_element_set_eos (element);
return;
case GST_EVENT_EOS:
siddec->state = SID_STATE_LOAD_TUNE;
break;
case GST_EVENT_DISCONTINUOUS:
break;
default:
// bail out, we're not going to do anything
gst_event_unref (event);
gst_pad_send_event (siddec->srcpad, gst_event_new (GST_EVENT_EOS));
gst_element_set_eos (element);
return;
}
gst_event_unref (event);
} else {
GstBuffer *buf = GST_BUFFER (data);
memcpy (siddec->tune_buffer + siddec->tune_len, GST_BUFFER_DATA (buf),
GST_BUFFER_SIZE (buf));
GST_BUFFER_SIZE (buf));
siddec->tune_len += GST_BUFFER_SIZE (buf);
gst_buffer_unref (buf);
@ -425,7 +428,7 @@ gst_siddec_loop (GstElement * element)
}
if (!sidEmuInitializeSong (*siddec->engine, *siddec->tune,
siddec->tune_number)) {
siddec->tune_number)) {
GST_ELEMENT_ERROR (siddec, LIBRARY, TOO_LAZY, (NULL), (NULL));
return;
}
@ -440,7 +443,7 @@ gst_siddec_loop (GstElement * element)
out = gst_buffer_new_and_alloc (siddec->blocksize);
sidEmuFillBuffer (*siddec->engine, *siddec->tune,
GST_BUFFER_DATA (out), GST_BUFFER_SIZE (out));
GST_BUFFER_DATA (out), GST_BUFFER_SIZE (out));
/* get offset in samples */
format = GST_FORMAT_DEFAULT;
@ -479,49 +482,49 @@ gst_siddec_src_convert (GstPad * pad, GstFormat src_format, gint64 src_value,
switch (src_format) {
case GST_FORMAT_BYTES:
switch (*dest_format) {
case GST_FORMAT_DEFAULT:
if (bytes_per_sample == 0)
return FALSE;
*dest_value = src_value / bytes_per_sample;
break;
case GST_FORMAT_TIME:
{
gint byterate = bytes_per_sample * siddec->config->frequency;
case GST_FORMAT_DEFAULT:
if (bytes_per_sample == 0)
return FALSE;
*dest_value = src_value / bytes_per_sample;
break;
case GST_FORMAT_TIME:
{
gint byterate = bytes_per_sample * siddec->config->frequency;
if (byterate == 0)
return FALSE;
*dest_value = src_value * GST_SECOND / byterate;
break;
}
default:
res = FALSE;
if (byterate == 0)
return FALSE;
*dest_value = src_value * GST_SECOND / byterate;
break;
}
default:
res = FALSE;
}
break;
case GST_FORMAT_DEFAULT:
switch (*dest_format) {
case GST_FORMAT_BYTES:
*dest_value = src_value * bytes_per_sample;
break;
case GST_FORMAT_TIME:
if (siddec->config->frequency == 0)
return FALSE;
*dest_value = src_value * GST_SECOND / siddec->config->frequency;
break;
default:
res = FALSE;
case GST_FORMAT_BYTES:
*dest_value = src_value * bytes_per_sample;
break;
case GST_FORMAT_TIME:
if (siddec->config->frequency == 0)
return FALSE;
*dest_value = src_value * GST_SECOND / siddec->config->frequency;
break;
default:
res = FALSE;
}
break;
case GST_FORMAT_TIME:
switch (*dest_format) {
case GST_FORMAT_BYTES:
scale = bytes_per_sample;
/* fallthrough */
case GST_FORMAT_DEFAULT:
*dest_value =
src_value * scale * siddec->config->frequency / GST_SECOND;
break;
default:
res = FALSE;
case GST_FORMAT_BYTES:
scale = bytes_per_sample;
/* fallthrough */
case GST_FORMAT_DEFAULT:
*dest_value =
src_value * scale * siddec->config->frequency / GST_SECOND;
break;
default:
res = FALSE;
}
break;
default:
@ -544,7 +547,7 @@ gst_siddec_src_query (GstPad * pad, GstQueryType type,
case GST_QUERY_POSITION:
/* we only know about our bytes, convert to requested format */
res &= gst_pad_convert (pad,
GST_FORMAT_BYTES, siddec->total_bytes, format, value);
GST_FORMAT_BYTES, siddec->total_bytes, format, value);
break;
default:
res = FALSE;

View file

@ -46,7 +46,7 @@ gst_audio_frame_byte_size (GstPad * pad)
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));
GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad));
return 0;
}
@ -94,7 +94,7 @@ gst_audio_frame_rate (GstPad * pad)
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));
GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad));
return 0;
} else {
structure = gst_caps_get_structure (caps, 0);
@ -127,7 +127,7 @@ gst_audio_length (GstPad * pad, GstBuffer * buf)
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));
GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad));
length = 0.0;
} else {
structure = gst_caps_get_structure (caps, 0);
@ -160,7 +160,7 @@ gst_audio_highest_sample_value (GstPad * pad)
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));
GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad));
}
structure = gst_caps_get_structure (caps, 0);
@ -218,19 +218,19 @@ _gst_audio_structure_set_list (GstStructure * structure,
switch (type) {
case G_TYPE_INT:
i = va_arg (varargs, int);
i = va_arg (varargs, int);
g_value_init (&list_value, G_TYPE_INT);
g_value_set_int (&list_value, i);
break;
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;
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_warning
("_gst_audio_structure_set_list: LIST of given type not implemented.");
}
g_array_append_val (array, list_value);
@ -244,24 +244,24 @@ 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);
NULL);
if (flag & GST_AUDIO_FIELD_CHANNELS)
gst_structure_set (structure, "channels", GST_TYPE_INT_RANGE, 1, G_MAXINT,
NULL);
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);
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);
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);
FALSE, NULL);
if (flag & GST_AUDIO_FIELD_BUFFER_FRAMES)
gst_structure_set (structure, "buffer-frames", GST_TYPE_INT_RANGE, 1,
G_MAXINT, NULL);
G_MAXINT, NULL);
}
static gboolean

View file

@ -57,8 +57,9 @@ gst_audio_clock_get_type (void)
(GInstanceInitFunc) gst_audio_clock_init,
NULL
};
clock_type = g_type_register_static (GST_TYPE_SYSTEM_CLOCK, "GstAudioClock",
&clock_info, 0);
&clock_info, 0);
}
return clock_type;
}
@ -162,7 +163,7 @@ gst_audio_clock_update_time (GstAudioClock * aclock, GstClockTime time)
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? */
}
}

View file

@ -73,8 +73,9 @@ gst_audiofilter_get_type (void)
0,
gst_audiofilter_init,
};
audiofilter_type = g_type_register_static (GST_TYPE_ELEMENT,
"GstAudiofilter", &audiofilter_info, G_TYPE_FLAG_ABSTRACT);
"GstAudiofilter", &audiofilter_info, G_TYPE_FLAG_ABSTRACT);
}
return audiofilter_type;
}
@ -141,7 +142,7 @@ gst_audiofilter_link (GstPad * pad, const GstCaps * caps)
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);
gst_structure_get_int (structure, "channels", &audiofilter->channels);
} else if (strcmp (gst_structure_get_name (structure), "audio/x-raw-float")
== 0) {
@ -236,7 +237,7 @@ gst_audiofilter_chain (GstPad * pad, GstData * data)
(audiofilter_class->filter) (audiofilter, outbuf, inbuf);
} else {
memcpy (GST_BUFFER_DATA (outbuf), GST_BUFFER_DATA (inbuf),
GST_BUFFER_SIZE (inbuf));
GST_BUFFER_SIZE (inbuf));
(audiofilter_class->filter_inplace) (audiofilter, outbuf);
}
@ -290,11 +291,11 @@ gst_audiofilter_class_add_pad_templates (GstAudiofilterClass *
gst_element_class_add_pad_template (element_class,
gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
gst_caps_copy (caps)));
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_caps_copy (caps)));
}
static gboolean

View file

@ -107,8 +107,9 @@ gst_audiofilter_template_get_type (void)
0,
NULL,
};
audiofilter_template_type = g_type_register_static (GST_TYPE_AUDIOFILTER,
"GstAudiofilterTemplate", &audiofilter_template_info, 0);
"GstAudiofilterTemplate", &audiofilter_template_info, 0);
}
return audiofilter_template_type;
}
@ -147,8 +148,8 @@ gst_audiofilter_template_class_init (gpointer g_class, gpointer class_data)
#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));
GST_TYPE_AUDIOTEMPLATE_METHOD, GST_AUDIOTEMPLATE_METHOD_1,
G_PARAM_READWRITE));
#endif
gobject_class->set_property = gst_audiofilter_template_set_property;

View file

@ -56,9 +56,9 @@ gst_color_balance_get_type (void)
};
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;
@ -71,12 +71,12 @@ gst_color_balance_class_init (GstColorBalanceClass * klass)
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;
}

View file

@ -60,8 +60,8 @@ gst_color_balance_channel_get_type (void)
};
gst_color_balance_channel_type =
g_type_register_static (G_TYPE_OBJECT,
"GstColorBalanceChannel", &color_balance_channel_info, 0);
g_type_register_static (G_TYPE_OBJECT,
"GstColorBalanceChannel", &color_balance_channel_info, 0);
}
return gst_color_balance_channel_type;
@ -78,7 +78,7 @@ gst_color_balance_channel_class_init (GstColorBalanceChannelClass * klass)
g_signal_new ("value-changed", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstColorBalanceChannelClass,
value_changed),
value_changed),
NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
object_klass->dispose = gst_color_balance_channel_dispose;

View file

@ -31,7 +31,7 @@
#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 */
@ -63,13 +63,13 @@ gst_bin_find_unconnected_pad (GstBin * bin, GstPadDirection direction)
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 ! */
pad = GST_PAD (pads->data);
}
if (GST_PAD_PEER (GST_PAD (pads->data)) == NULL) {
/* found it ! */
pad = GST_PAD (pads->data);
}
}
if (pad)
break; /* found one already */
break; /* found one already */
pads = g_list_next (pads);
}
elements = g_list_next (elements);
@ -149,7 +149,7 @@ gst_gconf_render_bin_from_description (const gchar * description)
g_free (desc);
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;
}
@ -308,7 +308,7 @@ gst_gconf_get_default_visualization_element (void)
if (!ret)
g_warning
("No GConf default visualization plugin key and goom doesn't work");
("No GConf default visualization plugin key and goom doesn't work");
else
g_print ("GConf visualization plugin not found, using goom\n");
}

View file

@ -45,17 +45,17 @@
/* 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 */
@ -80,13 +80,13 @@ idctrow (blk)
/* shortcut */
if (!((x1 = blk[4] << 11) | (x2 = blk[6]) | (x3 = blk[2]) |
(x4 = blk[1]) | (x5 = blk[7]) | (x6 = blk[5]) | (x7 = blk[3]))) {
(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;
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);
@ -143,10 +143,10 @@ idctcol (blk)
/* 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]))) {
(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];
blk[8 * 5] = blk[8 * 6] = blk[8 * 7] = iclp[(blk[8 * 0] + 32) >> 6];
return;
}

View file

@ -66,7 +66,7 @@ gst_idct_init_float_idct ()
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));
scale * cos ((PI / 8.0) * freq * (time + 0.5));
}
}
@ -85,7 +85,7 @@ gst_idct_float_idct (block)
partial_product = 0.0;
for (k = 0; k < 8; k++)
partial_product += gst_idct_float_c[k][j] * block[8 * i + k];
partial_product += gst_idct_float_c[k][j] * block[8 * i + k];
tmp[8 * i + j] = partial_product;
}
@ -98,7 +98,7 @@ gst_idct_float_idct (block)
partial_product = 0.0;
for (k = 0; k < 8; k++)
partial_product += gst_idct_float_c[k][i] * tmp[8 * k + j];
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);

View file

@ -52,10 +52,10 @@ main (int argc, char **argv)
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 */
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;
@ -96,9 +96,9 @@ main (int argc, char **argv)
/* clip */
for (i = 0; i < DCTSIZE2; i++) {
if (refcoefs[i] < -2048)
refcoefs[i] = -2048;
refcoefs[i] = -2048;
else if (refcoefs[i] > 2047)
refcoefs[i] = 2047;
refcoefs[i] = 2047;
}
/* perform reference IDCT */
@ -107,17 +107,17 @@ main (int argc, char **argv)
/* clip */
for (i = 0; i < DCTSIZE2; i++) {
if (refout[i] < -256)
refout[i] = -256;
refout[i] = -256;
else if (refout[i] > 255)
refout[i] = 255;
refout[i] = 255;
}
/* perform test 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];
}
for (i = 0; i < DCTSIZE; i++) {
testout[i * DCTSIZE + j] = refcoefs[j * DCTSIZE + i];
}
}
} else {
memcpy (testout, refcoefs, sizeof (DCTELEM) * DCTSIZE2);
@ -135,9 +135,9 @@ main (int argc, char **argv)
/* clip */
for (i = 0; i < DCTSIZE2; i++) {
if (testout[i] < -256)
testout[i] = -256;
testout[i] = -256;
else if (testout[i] > 255)
testout[i] = 255;
testout[i] = 255;
}
/* accumulate error stats */
@ -147,9 +147,9 @@ main (int argc, char **argv)
sumerrs[i] += err;
sumsqerrs[i] += err * err;
if (err < 0)
err = -err;
err = -err;
if (maxerr[i] < err)
maxerr[i] = err;
maxerr[i] = err;
}
if (curiter % 100 == 99) {
@ -290,7 +290,7 @@ dct_init (void)
for (b = 0; b < 8; b++) {
tmp = cos ((double) ((a + a + 1) * b) * (3.14159265358979323846 / 16.0));
if (b == 0)
tmp /= sqrt (2.0);
tmp /= sqrt (2.0);
coslu[a][b] = tmp * 0.5;
}
}
@ -307,11 +307,11 @@ ref_fdct (DCTELEM block[8][8])
for (u = 0; u < 8; u++) {
tmp = 0.0;
for (y = 0; y < 8; y++) {
tmp2 = 0.0;
for (x = 0; x < 8; x++) {
tmp2 += (double) block[y][x] * coslu[x][u];
}
tmp += coslu[y][v] * tmp2;
tmp2 = 0.0;
for (x = 0; x < 8; x++) {
tmp2 += (double) block[y][x] * coslu[x][u];
}
tmp += coslu[y][v] * tmp2;
}
res[v][u] = tmp;
}
@ -321,9 +321,9 @@ ref_fdct (DCTELEM block[8][8])
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);
x = (int) (tmp + 0.5);
}
block[v][u] = (DCTELEM) x;
}
@ -342,11 +342,11 @@ ref_idct (DCTELEM block[8][8])
for (x = 0; x < 8; x++) {
tmp = 0.0;
for (v = 0; v < 8; v++) {
tmp2 = 0.0;
for (u = 0; u < 8; u++) {
tmp2 += (double) block[v][u] * coslu[x][u];
}
tmp += coslu[y][v] * tmp2;
tmp2 = 0.0;
for (u = 0; u < 8; u++) {
tmp2 += (double) block[v][u] * coslu[x][u];
}
tmp += coslu[y][v] * tmp2;
}
res[y][x] = tmp;
}
@ -356,9 +356,9 @@ ref_idct (DCTELEM block[8][8])
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);
x = (int) (tmp + 0.5);
}
block[v][u] = (DCTELEM) x;
}

View file

@ -51,7 +51,7 @@
*/
#if DCTSIZE != 8
Sorry, this code only copes with 8 x8 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
@ -93,7 +93,7 @@ Sorry, this code only copes with 8 x8 DCTs. /* deliberate syntax err */
#define PASS1_BITS 2
#else
#define CONST_BITS 13
#define PASS1_BITS 1 /* lose a little precision to avoid overflow */
#define PASS1_BITS 1 /* lose a little precision to avoid overflow */
#endif
#define ONE ((INT32) 1)
#define CONST_SCALE (ONE << CONST_BITS)
@ -106,18 +106,18 @@ Sorry, this code only copes with 8 x8 DCTs. /* deliberate syntax err */
* (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_0_541196100 ((INT32) 4433) /* FIX(0.541196100) */
#define FIX_0_765366865 ((INT32) 6270) /* FIX(0.765366865) */
#define FIX_0_899976223 ((INT32) 7373) /* FIX(0.899976223) */
#define FIX_1_175875602 ((INT32) 9633) /* FIX(1.175875602) */
#define FIX_1_501321110 ((INT32) 12299) /* FIX(1.501321110) */
#define FIX_1_847759065 ((INT32) 15137) /* FIX(1.847759065) */
#define FIX_1_961570560 ((INT32) 16069) /* FIX(1.961570560) */
#define FIX_2_053119869 ((INT32) 16819) /* FIX(2.053119869) */
#define FIX_2_562915447 ((INT32) 20995) /* FIX(2.562915447) */
#define FIX_3_072711026 ((INT32) 25172) /* FIX(3.072711026) */
#define FIX_0_298631336 ((INT32) 2446) /* FIX(0.298631336) */
#define FIX_0_390180644 ((INT32) 3196) /* FIX(0.390180644) */
#define FIX_0_541196100 ((INT32) 4433) /* FIX(0.541196100) */
#define FIX_0_765366865 ((INT32) 6270) /* FIX(0.765366865) */
#define FIX_0_899976223 ((INT32) 7373) /* FIX(0.899976223) */
#define FIX_1_175875602 ((INT32) 9633) /* FIX(1.175875602) */
#define FIX_1_501321110 ((INT32) 12299) /* FIX(1.501321110) */
#define FIX_1_847759065 ((INT32) 15137) /* FIX(1.847759065) */
#define FIX_1_961570560 ((INT32) 16069) /* FIX(1.961570560) */
#define FIX_2_053119869 ((INT32) 16819) /* FIX(2.053119869) */
#define FIX_2_562915447 ((INT32) 20995) /* FIX(2.562915447) */
#define FIX_3_072711026 ((INT32) 25172) /* FIX(3.072711026) */
#else
#define FIX_0_298631336 FIX(0.298631336)
#define FIX_0_390180644 FIX(0.390180644)
@ -148,14 +148,14 @@ Sorry, this code only copes with 8 x8 DCTs. /* deliberate syntax err */
* 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 */
#ifdef SHORTxSHORT_32 /* may work if 'int' is 32 bits */
#define MULTIPLY(var,const) (((INT16) (var)) * ((INT16) (const)))
#endif
#ifdef SHORTxLCONST_32 /* known to work with Microsoft C 6.0 */
#ifdef SHORTxLCONST_32 /* known to work with Microsoft C 6.0 */
#define MULTIPLY(var,const) (((INT16) (var)) * ((INT32) (const)))
#endif
#endif
#ifndef MULTIPLY /* default definition */
#ifndef MULTIPLY /* default definition */
#define MULTIPLY(var,const) ((var) * (const))
#endif
/*
@ -186,7 +186,7 @@ gst_idct_int_idct (DCTBLOCK data)
*/
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);
@ -199,7 +199,7 @@ gst_idct_int_idct (DCTBLOCK data)
dataptr[6] = dcval;
dataptr[7] = dcval;
dataptr += DCTSIZE; /* advance pointer to next row */
dataptr += DCTSIZE; /* advance pointer to next row */
continue;
}
@ -234,16 +234,16 @@ gst_idct_int_idct (DCTBLOCK data)
z2 = tmp1 + tmp2;
z3 = tmp0 + tmp2;
z4 = tmp1 + tmp3;
z5 = MULTIPLY (z3 + z4, FIX_1_175875602); /* sqrt(2) * 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) */
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;
@ -264,7 +264,7 @@ gst_idct_int_idct (DCTBLOCK data)
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 */
dataptr += DCTSIZE; /* advance pointer to next row */
}
/* Pass 2: process columns. */
@ -283,8 +283,8 @@ gst_idct_int_idct (DCTBLOCK data)
#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) {
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);
@ -297,7 +297,7 @@ gst_idct_int_idct (DCTBLOCK data)
dataptr[DCTSIZE * 6] = dcval;
dataptr[DCTSIZE * 7] = dcval;
dataptr++; /* advance pointer to next column */
dataptr++; /* advance pointer to next column */
continue;
}
#endif
@ -313,11 +313,11 @@ gst_idct_int_idct (DCTBLOCK data)
tmp3 = z1 + MULTIPLY (z2, FIX_0_765366865);
tmp0 =
((INT32) dataptr[DCTSIZE * 0] +
(INT32) dataptr[DCTSIZE * 4]) << CONST_BITS;
((INT32) dataptr[DCTSIZE * 0] +
(INT32) dataptr[DCTSIZE * 4]) << CONST_BITS;
tmp1 =
((INT32) dataptr[DCTSIZE * 0] -
(INT32) dataptr[DCTSIZE * 4]) << CONST_BITS;
((INT32) dataptr[DCTSIZE * 0] -
(INT32) dataptr[DCTSIZE * 4]) << CONST_BITS;
tmp10 = tmp0 + tmp3;
tmp13 = tmp0 - tmp3;
@ -337,16 +337,16 @@ gst_idct_int_idct (DCTBLOCK data)
z2 = tmp1 + tmp2;
z3 = tmp0 + tmp2;
z4 = tmp1 + tmp3;
z5 = MULTIPLY (z3 + z4, FIX_1_175875602); /* sqrt(2) * 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) */
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;
@ -359,22 +359,22 @@ gst_idct_int_idct (DCTBLOCK data)
/* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
dataptr[DCTSIZE * 0] = (DCTELEM) DESCALE (tmp10 + tmp3,
CONST_BITS + PASS1_BITS + 3);
CONST_BITS + PASS1_BITS + 3);
dataptr[DCTSIZE * 7] = (DCTELEM) DESCALE (tmp10 - tmp3,
CONST_BITS + PASS1_BITS + 3);
CONST_BITS + PASS1_BITS + 3);
dataptr[DCTSIZE * 1] = (DCTELEM) DESCALE (tmp11 + tmp2,
CONST_BITS + PASS1_BITS + 3);
CONST_BITS + PASS1_BITS + 3);
dataptr[DCTSIZE * 6] = (DCTELEM) DESCALE (tmp11 - tmp2,
CONST_BITS + PASS1_BITS + 3);
CONST_BITS + PASS1_BITS + 3);
dataptr[DCTSIZE * 2] = (DCTELEM) DESCALE (tmp12 + tmp1,
CONST_BITS + PASS1_BITS + 3);
CONST_BITS + PASS1_BITS + 3);
dataptr[DCTSIZE * 5] = (DCTELEM) DESCALE (tmp12 - tmp1,
CONST_BITS + PASS1_BITS + 3);
CONST_BITS + PASS1_BITS + 3);
dataptr[DCTSIZE * 3] = (DCTELEM) DESCALE (tmp13 + tmp0,
CONST_BITS + PASS1_BITS + 3);
CONST_BITS + PASS1_BITS + 3);
dataptr[DCTSIZE * 4] = (DCTELEM) DESCALE (tmp13 - tmp0,
CONST_BITS + PASS1_BITS + 3);
CONST_BITS + PASS1_BITS + 3);
dataptr++; /* advance pointer to next column */
dataptr++; /* advance pointer to next column */
}
}

View file

@ -117,15 +117,15 @@ qword ptr equ mword ptr */
#endif
#include <mmx.h>
#define BITS_INV_ACC 4 /*; 4 or 5 for IEEE */
#define BITS_INV_ACC 4 /*; 4 or 5 for IEEE */
/* 5 yields higher accuracy, but lessens dynamic range on the input matrix */
#define SHIFT_INV_ROW (16 - BITS_INV_ACC)
#define SHIFT_INV_COL (1 + BITS_INV_ACC +14 ) /* changed from Intel's val) */
#define SHIFT_INV_COL (1 + BITS_INV_ACC +14 ) /* changed from Intel's val) */
/*#define SHIFT_INV_COL (1 + BITS_INV_ACC ) */
#define RND_INV_ROW (1 << (SHIFT_INV_ROW-1))
#define RND_INV_COL (1 << (SHIFT_INV_COL-1))
#define RND_INV_CORR (RND_INV_COL - 1) /*; correction -1.0 and round */
#define RND_INV_CORR (RND_INV_COL - 1) /*; correction -1.0 and round */
/*#define RND_INV_ROW (1024 * (6 - BITS_INV_ACC)) //; 1 << (SHIFT_INV_ROW-1) */
/*#define RND_INV_COL (16 * (BITS_INV_ACC - 3)) //; 1 << (SHIFT_INV_COL-1) */
@ -158,12 +158,12 @@ const static long r_inv_row[2] = { RND_INV_ROW, RND_INV_ROW };
/*const static short ocos_4_16[4] = {23170, 23170, 23170, 23170 }; //cos * (2<<15) + 0.5 */
/*concatenated table, for forward DCT transformation */
const static short tg_all_16[] = { 13036, 13036, 13036, 13036, /* tg * (2<<16) + 0.5 */
27146, 27146, 27146, 27146, /*tg * (2<<16) + 0.5 */
-21746, -21746, -21746, -21746, /* tg * (2<<16) + 0.5 */
-19195, -19195, -19195, -19195, /*cos * (2<<16) + 0.5 */
const static short tg_all_16[] = { 13036, 13036, 13036, 13036, /* tg * (2<<16) + 0.5 */
27146, 27146, 27146, 27146, /*tg * (2<<16) + 0.5 */
-21746, -21746, -21746, -21746, /* tg * (2<<16) + 0.5 */
-19195, -19195, -19195, -19195, /*cos * (2<<16) + 0.5 */
23170, 23170, 23170, 23170
}; /*cos * (2<<15) + 0.5 */
}; /*cos * (2<<15) + 0.5 */
#define tg_1_16 (tg_all_16 + 0)
@ -233,51 +233,51 @@ IF _MMX ; MMX code
;=============================================================================
/*; Table for rows 0,4 - constants are multiplied by cos_4_16 */
const short tab_i_04[] = { 16384, 16384, 16384, -16384, /* ; movq-> w06 w04 w02 w00 */
21407, 8867, 8867, -21407, /* w07 w05 w03 w01 */
16384, -16384, 16384, 16384, /*; w14 w12 w10 w08 */
-8867, 21407, -21407, -8867, /*; w15 w13 w11 w09 */
22725, 12873, 19266, -22725, /*; w22 w20 w18 w16 */
19266, 4520, -4520, -12873, /*; w23 w21 w19 w17 */
12873, 4520, 4520, 19266, /*; w30 w28 w26 w24 */
const short tab_i_04[] = { 16384, 16384, 16384, -16384, /* ; movq-> w06 w04 w02 w00 */
21407, 8867, 8867, -21407, /* w07 w05 w03 w01 */
16384, -16384, 16384, 16384, /*; w14 w12 w10 w08 */
-8867, 21407, -21407, -8867, /*; w15 w13 w11 w09 */
22725, 12873, 19266, -22725, /*; w22 w20 w18 w16 */
19266, 4520, -4520, -12873, /*; w23 w21 w19 w17 */
12873, 4520, 4520, 19266, /*; w30 w28 w26 w24 */
-22725, 19266, -12873, -22725
}; /*w31 w29 w27 w25 */
}; /*w31 w29 w27 w25 */
/*; Table for rows 1,7 - constants are multiplied by cos_1_16 */
const short tab_i_17[] = { 22725, 22725, 22725, -22725, /* ; movq-> w06 w04 w02 w00 */
29692, 12299, 12299, -29692, /* ; w07 w05 w03 w01 */
22725, -22725, 22725, 22725, /*; w14 w12 w10 w08 */
-12299, 29692, -29692, -12299, /*; w15 w13 w11 w09 */
31521, 17855, 26722, -31521, /*; w22 w20 w18 w16 */
26722, 6270, -6270, -17855, /*; w23 w21 w19 w17 */
17855, 6270, 6270, 26722, /*; w30 w28 w26 w24 */
const short tab_i_17[] = { 22725, 22725, 22725, -22725, /* ; movq-> w06 w04 w02 w00 */
29692, 12299, 12299, -29692, /* ; w07 w05 w03 w01 */
22725, -22725, 22725, 22725, /*; w14 w12 w10 w08 */
-12299, 29692, -29692, -12299, /*; w15 w13 w11 w09 */
31521, 17855, 26722, -31521, /*; w22 w20 w18 w16 */
26722, 6270, -6270, -17855, /*; w23 w21 w19 w17 */
17855, 6270, 6270, 26722, /*; w30 w28 w26 w24 */
-31521, 26722, -17855, -31521
}; /* w31 w29 w27 w25 */
}; /* w31 w29 w27 w25 */
/*; Table for rows 2,6 - constants are multiplied by cos_2_16 */
const short tab_i_26[] = { 21407, 21407, 21407, -21407, /* ; movq-> w06 w04 w02 w00 */
27969, 11585, 11585, -27969, /* ; w07 w05 w03 w01 */
21407, -21407, 21407, 21407, /* ; w14 w12 w10 w08 */
-11585, 27969, -27969, -11585, /* ;w15 w13 w11 w09 */
29692, 16819, 25172, -29692, /* ;w22 w20 w18 w16 */
25172, 5906, -5906, -16819, /* ;w23 w21 w19 w17 */
16819, 5906, 5906, 25172, /* ;w30 w28 w26 w24 */
const short tab_i_26[] = { 21407, 21407, 21407, -21407, /* ; movq-> w06 w04 w02 w00 */
27969, 11585, 11585, -27969, /* ; w07 w05 w03 w01 */
21407, -21407, 21407, 21407, /* ; w14 w12 w10 w08 */
-11585, 27969, -27969, -11585, /* ;w15 w13 w11 w09 */
29692, 16819, 25172, -29692, /* ;w22 w20 w18 w16 */
25172, 5906, -5906, -16819, /* ;w23 w21 w19 w17 */
16819, 5906, 5906, 25172, /* ;w30 w28 w26 w24 */
-29692, 25172, -16819, -29692
}; /* ;w31 w29 w27 w25 */
}; /* ;w31 w29 w27 w25 */
/*; Table for rows 3,5 - constants are multiplied by cos_3_16 */
const short tab_i_35[] = { 19266, 19266, 19266, -19266, /*; movq-> w06 w04 w02 w00 */
25172, 10426, 10426, -25172, /*; w07 w05 w03 w01 */
19266, -19266, 19266, 19266, /*; w14 w12 w10 w08 */
-10426, 25172, -25172, -10426, /*; w15 w13 w11 w09 */
26722, 15137, 22654, -26722, /*; w22 w20 w18 w16 */
22654, 5315, -5315, -15137, /*; w23 w21 w19 w17 */
15137, 5315, 5315, 22654, /*; w30 w28 w26 w24 */
const short tab_i_35[] = { 19266, 19266, 19266, -19266, /*; movq-> w06 w04 w02 w00 */
25172, 10426, 10426, -25172, /*; w07 w05 w03 w01 */
19266, -19266, 19266, 19266, /*; w14 w12 w10 w08 */
-10426, 25172, -25172, -10426, /*; w15 w13 w11 w09 */
26722, 15137, 22654, -26722, /*; w22 w20 w18 w16 */
22654, 5315, -5315, -15137, /*; w23 w21 w19 w17 */
15137, 5315, 5315, 22654, /*; w30 w28 w26 w24 */
-26722, 22654, -15137, -26722
}; /*; w31 w29 w27 w25 */
}; /*; w31 w29 w27 w25 */
*/
/* CONCATENATED TABLE, rows 0,1,2,3,4,5,6,7 (in order ) */
@ -286,109 +286,109 @@ const short tab_i_35[] = { 19266, 19266, 19266, -19266, /*; movq-> w06 w04 w02
/* */
static const short tab_i_01234567[] = {
/*row0, this row is required */
16384, 16384, 16384, -16384, /* ; movq-> w06 w04 w02 w00 */
21407, 8867, 8867, -21407, /* w07 w05 w03 w01 */
16384, -16384, 16384, 16384, /*; w14 w12 w10 w08 */
-8867, 21407, -21407, -8867, /*; w15 w13 w11 w09 */
22725, 12873, 19266, -22725, /*; w22 w20 w18 w16 */
19266, 4520, -4520, -12873, /*; w23 w21 w19 w17 */
12873, 4520, 4520, 19266, /*; w30 w28 w26 w24 */
-22725, 19266, -12873, -22725, /*w31 w29 w27 w25 */
16384, 16384, 16384, -16384, /* ; movq-> w06 w04 w02 w00 */
21407, 8867, 8867, -21407, /* w07 w05 w03 w01 */
16384, -16384, 16384, 16384, /*; w14 w12 w10 w08 */
-8867, 21407, -21407, -8867, /*; w15 w13 w11 w09 */
22725, 12873, 19266, -22725, /*; w22 w20 w18 w16 */
19266, 4520, -4520, -12873, /*; w23 w21 w19 w17 */
12873, 4520, 4520, 19266, /*; w30 w28 w26 w24 */
-22725, 19266, -12873, -22725, /*w31 w29 w27 w25 */
/* the rest of these rows (1-7), aren't used ! */
/*row1 */
22725, 22725, 22725, -22725, /* ; movq-> w06 w04 w02 w00 */
29692, 12299, 12299, -29692, /* ; w07 w05 w03 w01 */
22725, -22725, 22725, 22725, /*; w14 w12 w10 w08 */
-12299, 29692, -29692, -12299, /*; w15 w13 w11 w09 */
31521, 17855, 26722, -31521, /*; w22 w20 w18 w16 */
26722, 6270, -6270, -17855, /*; w23 w21 w19 w17 */
17855, 6270, 6270, 26722, /*; w30 w28 w26 w24 */
-31521, 26722, -17855, -31521, /* w31 w29 w27 w25 */
22725, 22725, 22725, -22725, /* ; movq-> w06 w04 w02 w00 */
29692, 12299, 12299, -29692, /* ; w07 w05 w03 w01 */
22725, -22725, 22725, 22725, /*; w14 w12 w10 w08 */
-12299, 29692, -29692, -12299, /*; w15 w13 w11 w09 */
31521, 17855, 26722, -31521, /*; w22 w20 w18 w16 */
26722, 6270, -6270, -17855, /*; w23 w21 w19 w17 */
17855, 6270, 6270, 26722, /*; w30 w28 w26 w24 */
-31521, 26722, -17855, -31521, /* w31 w29 w27 w25 */
/*row2 */
21407, 21407, 21407, -21407, /* ; movq-> w06 w04 w02 w00 */
27969, 11585, 11585, -27969, /* ; w07 w05 w03 w01 */
21407, -21407, 21407, 21407, /* ; w14 w12 w10 w08 */
-11585, 27969, -27969, -11585, /* ;w15 w13 w11 w09 */
29692, 16819, 25172, -29692, /* ;w22 w20 w18 w16 */
25172, 5906, -5906, -16819, /* ;w23 w21 w19 w17 */
16819, 5906, 5906, 25172, /* ;w30 w28 w26 w24 */
-29692, 25172, -16819, -29692, /* ;w31 w29 w27 w25 */
21407, 21407, 21407, -21407, /* ; movq-> w06 w04 w02 w00 */
27969, 11585, 11585, -27969, /* ; w07 w05 w03 w01 */
21407, -21407, 21407, 21407, /* ; w14 w12 w10 w08 */
-11585, 27969, -27969, -11585, /* ;w15 w13 w11 w09 */
29692, 16819, 25172, -29692, /* ;w22 w20 w18 w16 */
25172, 5906, -5906, -16819, /* ;w23 w21 w19 w17 */
16819, 5906, 5906, 25172, /* ;w30 w28 w26 w24 */
-29692, 25172, -16819, -29692, /* ;w31 w29 w27 w25 */
/*row3 */
19266, 19266, 19266, -19266, /*; movq-> w06 w04 w02 w00 */
25172, 10426, 10426, -25172, /*; w07 w05 w03 w01 */
19266, -19266, 19266, 19266, /*; w14 w12 w10 w08 */
-10426, 25172, -25172, -10426, /*; w15 w13 w11 w09 */
26722, 15137, 22654, -26722, /*; w22 w20 w18 w16 */
22654, 5315, -5315, -15137, /*; w23 w21 w19 w17 */
15137, 5315, 5315, 22654, /*; w30 w28 w26 w24 */
-26722, 22654, -15137, -26722, /*; w31 w29 w27 w25 */
19266, 19266, 19266, -19266, /*; movq-> w06 w04 w02 w00 */
25172, 10426, 10426, -25172, /*; w07 w05 w03 w01 */
19266, -19266, 19266, 19266, /*; w14 w12 w10 w08 */
-10426, 25172, -25172, -10426, /*; w15 w13 w11 w09 */
26722, 15137, 22654, -26722, /*; w22 w20 w18 w16 */
22654, 5315, -5315, -15137, /*; w23 w21 w19 w17 */
15137, 5315, 5315, 22654, /*; w30 w28 w26 w24 */
-26722, 22654, -15137, -26722, /*; w31 w29 w27 w25 */
/*row4 */
16384, 16384, 16384, -16384, /* ; movq-> w06 w04 w02 w00 */
21407, 8867, 8867, -21407, /* w07 w05 w03 w01 */
16384, -16384, 16384, 16384, /*; w14 w12 w10 w08 */
-8867, 21407, -21407, -8867, /*; w15 w13 w11 w09 */
22725, 12873, 19266, -22725, /*; w22 w20 w18 w16 */
19266, 4520, -4520, -12873, /*; w23 w21 w19 w17 */
12873, 4520, 4520, 19266, /*; w30 w28 w26 w24 */
-22725, 19266, -12873, -22725, /*w31 w29 w27 w25 */
16384, 16384, 16384, -16384, /* ; movq-> w06 w04 w02 w00 */
21407, 8867, 8867, -21407, /* w07 w05 w03 w01 */
16384, -16384, 16384, 16384, /*; w14 w12 w10 w08 */
-8867, 21407, -21407, -8867, /*; w15 w13 w11 w09 */
22725, 12873, 19266, -22725, /*; w22 w20 w18 w16 */
19266, 4520, -4520, -12873, /*; w23 w21 w19 w17 */
12873, 4520, 4520, 19266, /*; w30 w28 w26 w24 */
-22725, 19266, -12873, -22725, /*w31 w29 w27 w25 */
/*row5 */
19266, 19266, 19266, -19266, /*; movq-> w06 w04 w02 w00 */
25172, 10426, 10426, -25172, /*; w07 w05 w03 w01 */
19266, -19266, 19266, 19266, /*; w14 w12 w10 w08 */
-10426, 25172, -25172, -10426, /*; w15 w13 w11 w09 */
26722, 15137, 22654, -26722, /*; w22 w20 w18 w16 */
22654, 5315, -5315, -15137, /*; w23 w21 w19 w17 */
15137, 5315, 5315, 22654, /*; w30 w28 w26 w24 */
-26722, 22654, -15137, -26722, /*; w31 w29 w27 w25 */
19266, 19266, 19266, -19266, /*; movq-> w06 w04 w02 w00 */
25172, 10426, 10426, -25172, /*; w07 w05 w03 w01 */
19266, -19266, 19266, 19266, /*; w14 w12 w10 w08 */
-10426, 25172, -25172, -10426, /*; w15 w13 w11 w09 */
26722, 15137, 22654, -26722, /*; w22 w20 w18 w16 */
22654, 5315, -5315, -15137, /*; w23 w21 w19 w17 */
15137, 5315, 5315, 22654, /*; w30 w28 w26 w24 */
-26722, 22654, -15137, -26722, /*; w31 w29 w27 w25 */
/*row6 */
21407, 21407, 21407, -21407, /* ; movq-> w06 w04 w02 w00 */
27969, 11585, 11585, -27969, /* ; w07 w05 w03 w01 */
21407, -21407, 21407, 21407, /* ; w14 w12 w10 w08 */
-11585, 27969, -27969, -11585, /* ;w15 w13 w11 w09 */
29692, 16819, 25172, -29692, /* ;w22 w20 w18 w16 */
25172, 5906, -5906, -16819, /* ;w23 w21 w19 w17 */
16819, 5906, 5906, 25172, /* ;w30 w28 w26 w24 */
-29692, 25172, -16819, -29692, /* ;w31 w29 w27 w25 */
21407, 21407, 21407, -21407, /* ; movq-> w06 w04 w02 w00 */
27969, 11585, 11585, -27969, /* ; w07 w05 w03 w01 */
21407, -21407, 21407, 21407, /* ; w14 w12 w10 w08 */
-11585, 27969, -27969, -11585, /* ;w15 w13 w11 w09 */
29692, 16819, 25172, -29692, /* ;w22 w20 w18 w16 */
25172, 5906, -5906, -16819, /* ;w23 w21 w19 w17 */
16819, 5906, 5906, 25172, /* ;w30 w28 w26 w24 */
-29692, 25172, -16819, -29692, /* ;w31 w29 w27 w25 */
/*row7 */
22725, 22725, 22725, -22725, /* ; movq-> w06 w04 w02 w00 */
29692, 12299, 12299, -29692, /* ; w07 w05 w03 w01 */
22725, -22725, 22725, 22725, /*; w14 w12 w10 w08 */
-12299, 29692, -29692, -12299, /*; w15 w13 w11 w09 */
31521, 17855, 26722, -31521, /*; w22 w20 w18 w16 */
26722, 6270, -6270, -17855, /*; w23 w21 w19 w17 */
17855, 6270, 6270, 26722, /*; w30 w28 w26 w24 */
22725, 22725, 22725, -22725, /* ; movq-> w06 w04 w02 w00 */
29692, 12299, 12299, -29692, /* ; w07 w05 w03 w01 */
22725, -22725, 22725, 22725, /*; w14 w12 w10 w08 */
-12299, 29692, -29692, -12299, /*; w15 w13 w11 w09 */
31521, 17855, 26722, -31521, /*; w22 w20 w18 w16 */
26722, 6270, -6270, -17855, /*; w23 w21 w19 w17 */
17855, 6270, 6270, 26722, /*; w30 w28 w26 w24 */
-31521, 26722, -17855, -31521
}; /* w31 w29 w27 w25 */
}; /* w31 w29 w27 w25 */
#define INP eax /* pointer to (short *blk) */
#define OUT ecx /* pointer to output (temporary store space qwTemp[]) */
#define TABLE ebx /* pointer to tab_i_01234567[] */
#define INP eax /* pointer to (short *blk) */
#define OUT ecx /* pointer to output (temporary store space qwTemp[]) */
#define TABLE ebx /* pointer to tab_i_01234567[] */
#define round_inv_row edx
#define round_inv_col edx
#define ROW_STRIDE 8 /* for 8x8 matrix transposer */
#define ROW_STRIDE 8 /* for 8x8 matrix transposer */
/* private variables and functions */
/*temporary storage space, 8x8 of shorts */
__inline static void idct_mmx32_rows (short *blk); /* transform rows */
__inline static void idct_mmx32_cols (short *blk); /* transform "columns" */
__inline static void idct_mmx32_rows (short *blk); /* transform rows */
__inline static void idct_mmx32_cols (short *blk); /* transform "columns" */
/* the "column" transform actually transforms rows, it is */
/* identical to the row-transform except for the ROUNDING */
/* and SHIFTING coefficients. */
/* the "column" transform actually transforms rows, it is */
/* identical to the row-transform except for the ROUNDING */
/* and SHIFTING coefficients. */
static void
idct_mmx32_rows (short *blk)
{ /* transform all 8 rows of 8x8 iDCT block */
{ /* transform all 8 rows of 8x8 iDCT block */
int x;
short qwTemp[64];
short *out = &qwTemp[0];
@ -402,58 +402,58 @@ idct_mmx32_rows (short *blk)
/* */
/* 2) transpose the matrix (which was stored in qwTemp[]) */
/* qwTemp[] -> [8x8 matrix transpose] -> blk[] */
for (x = 0; x < 8; x++) { /* transform one row per iteration */
movq_m2r (*(inptr), mm0); /* 0 ; x3 x2 x1 x0 */
movq_m2r (*(inptr + 4), mm1); /* 1 ; x7 x6 x5 x4 */
movq_r2r (mm0, mm2); /* 2 ; x3 x2 x1 x0 */
movq_m2r (*(tab_i_01234567), mm3); /* 3 ; w06 w04 w02 w00 */
punpcklwd_r2r (mm1, mm0); /* x5 x1 x4 x0 */
for (x = 0; x < 8; x++) { /* transform one row per iteration */
movq_m2r (*(inptr), mm0); /* 0 ; x3 x2 x1 x0 */
movq_m2r (*(inptr + 4), mm1); /* 1 ; x7 x6 x5 x4 */
movq_r2r (mm0, mm2); /* 2 ; x3 x2 x1 x0 */
movq_m2r (*(tab_i_01234567), mm3); /* 3 ; w06 w04 w02 w00 */
punpcklwd_r2r (mm1, mm0); /* x5 x1 x4 x0 */
/* ---------- */
movq_r2r (mm0, mm5); /* 5 ; x5 x1 x4 x0 */
punpckldq_r2r (mm0, mm0); /* x4 x0 x4 x0 */
movq_m2r (*(tab_i_01234567 + 4), mm4); /* 4 ; w07 w05 w03 w01 */
punpckhwd_r2r (mm1, mm2); /* 1 ; x7 x3 x6 x2 */
pmaddwd_r2r (mm0, mm3); /* x4*w06+x0*w04 x4*w02+x0*w00 */
movq_r2r (mm2, mm6); /* 6 ; x7 x3 x6 x2 */
movq_m2r (*(tab_i_01234567 + 16), mm1); /* 1 ; w22 w20 w18 w16 */
punpckldq_r2r (mm2, mm2); /* x6 x2 x6 x2 */
pmaddwd_r2r (mm2, mm4); /* x6*w07+x2*w05 x6*w03+x2*w01 */
punpckhdq_r2r (mm5, mm5); /* x5 x1 x5 x1 */
pmaddwd_m2r (*(tab_i_01234567 + 8), mm0); /* x4*w14+x0*w12 x4*w10+x0*w08 */
punpckhdq_r2r (mm6, mm6); /* x7 x3 x7 x3 */
movq_m2r (*(tab_i_01234567 + 20), mm7); /* 7 ; w23 w21 w19 w17 */
pmaddwd_r2r (mm5, mm1); /* x5*w22+x1*w20 x5*w18+x1*w16 */
paddd_m2r (*(r_inv_row), mm3); /* +rounder */
pmaddwd_r2r (mm6, mm7); /* x7*w23+x3*w21 x7*w19+x3*w17 */
pmaddwd_m2r (*(tab_i_01234567 + 12), mm2); /* x6*w15+x2*w13 x6*w11+x2*w09 */
paddd_r2r (mm4, mm3); /* 4 ; a1=sum(even1) a0=sum(even0) */
pmaddwd_m2r (*(tab_i_01234567 + 24), mm5); /* x5*w30+x1*w28 x5*w26+x1*w24 */
movq_r2r (mm3, mm4); /* 4 ; a1 a0 */
pmaddwd_m2r (*(tab_i_01234567 + 28), mm6); /* x7*w31+x3*w29 x7*w27+x3*w25 */
paddd_r2r (mm7, mm1); /* 7 ; b1=sum(odd1) b0=sum(odd0) */
paddd_m2r (*(r_inv_row), mm0); /* +rounder */
psubd_r2r (mm1, mm3); /* a1-b1 a0-b0 */
psrad_i2r (SHIFT_INV_ROW, mm3); /* y6=a1-b1 y7=a0-b0 */
paddd_r2r (mm4, mm1); /* 4 ; a1+b1 a0+b0 */
paddd_r2r (mm2, mm0); /* 2 ; a3=sum(even3) a2=sum(even2) */
psrad_i2r (SHIFT_INV_ROW, mm1); /* y1=a1+b1 y0=a0+b0 */
paddd_r2r (mm6, mm5); /* 6 ; b3=sum(odd3) b2=sum(odd2) */
movq_r2r (mm0, mm4); /* 4 ; a3 a2 */
paddd_r2r (mm5, mm0); /* a3+b3 a2+b2 */
psubd_r2r (mm5, mm4); /* 5 ; a3-b3 a2-b2 */
psrad_i2r (SHIFT_INV_ROW, mm4); /* y4=a3-b3 y5=a2-b2 */
psrad_i2r (SHIFT_INV_ROW, mm0); /* y3=a3+b3 y2=a2+b2 */
packssdw_r2r (mm3, mm4); /* 3 ; y6 y7 y4 y5 */
packssdw_r2r (mm0, mm1); /* 0 ; y3 y2 y1 y0 */
movq_r2r (mm4, mm7); /* 7 ; y6 y7 y4 y5 */
psrld_i2r (16, mm4); /* 0 y6 0 y4 */
movq_r2m (mm1, *(out)); /* 1 ; save y3 y2 y1 y0 */
pslld_i2r (16, mm7); /* y7 0 y5 0 */
por_r2r (mm4, mm7); /* 4 ; y7 y6 y5 y4 */
/* ---------- */
movq_r2r (mm0, mm5); /* 5 ; x5 x1 x4 x0 */
punpckldq_r2r (mm0, mm0); /* x4 x0 x4 x0 */
movq_m2r (*(tab_i_01234567 + 4), mm4); /* 4 ; w07 w05 w03 w01 */
punpckhwd_r2r (mm1, mm2); /* 1 ; x7 x3 x6 x2 */
pmaddwd_r2r (mm0, mm3); /* x4*w06+x0*w04 x4*w02+x0*w00 */
movq_r2r (mm2, mm6); /* 6 ; x7 x3 x6 x2 */
movq_m2r (*(tab_i_01234567 + 16), mm1); /* 1 ; w22 w20 w18 w16 */
punpckldq_r2r (mm2, mm2); /* x6 x2 x6 x2 */
pmaddwd_r2r (mm2, mm4); /* x6*w07+x2*w05 x6*w03+x2*w01 */
punpckhdq_r2r (mm5, mm5); /* x5 x1 x5 x1 */
pmaddwd_m2r (*(tab_i_01234567 + 8), mm0); /* x4*w14+x0*w12 x4*w10+x0*w08 */
punpckhdq_r2r (mm6, mm6); /* x7 x3 x7 x3 */
movq_m2r (*(tab_i_01234567 + 20), mm7); /* 7 ; w23 w21 w19 w17 */
pmaddwd_r2r (mm5, mm1); /* x5*w22+x1*w20 x5*w18+x1*w16 */
paddd_m2r (*(r_inv_row), mm3); /* +rounder */
pmaddwd_r2r (mm6, mm7); /* x7*w23+x3*w21 x7*w19+x3*w17 */
pmaddwd_m2r (*(tab_i_01234567 + 12), mm2); /* x6*w15+x2*w13 x6*w11+x2*w09 */
paddd_r2r (mm4, mm3); /* 4 ; a1=sum(even1) a0=sum(even0) */
pmaddwd_m2r (*(tab_i_01234567 + 24), mm5); /* x5*w30+x1*w28 x5*w26+x1*w24 */
movq_r2r (mm3, mm4); /* 4 ; a1 a0 */
pmaddwd_m2r (*(tab_i_01234567 + 28), mm6); /* x7*w31+x3*w29 x7*w27+x3*w25 */
paddd_r2r (mm7, mm1); /* 7 ; b1=sum(odd1) b0=sum(odd0) */
paddd_m2r (*(r_inv_row), mm0); /* +rounder */
psubd_r2r (mm1, mm3); /* a1-b1 a0-b0 */
psrad_i2r (SHIFT_INV_ROW, mm3); /* y6=a1-b1 y7=a0-b0 */
paddd_r2r (mm4, mm1); /* 4 ; a1+b1 a0+b0 */
paddd_r2r (mm2, mm0); /* 2 ; a3=sum(even3) a2=sum(even2) */
psrad_i2r (SHIFT_INV_ROW, mm1); /* y1=a1+b1 y0=a0+b0 */
paddd_r2r (mm6, mm5); /* 6 ; b3=sum(odd3) b2=sum(odd2) */
movq_r2r (mm0, mm4); /* 4 ; a3 a2 */
paddd_r2r (mm5, mm0); /* a3+b3 a2+b2 */
psubd_r2r (mm5, mm4); /* 5 ; a3-b3 a2-b2 */
psrad_i2r (SHIFT_INV_ROW, mm4); /* y4=a3-b3 y5=a2-b2 */
psrad_i2r (SHIFT_INV_ROW, mm0); /* y3=a3+b3 y2=a2+b2 */
packssdw_r2r (mm3, mm4); /* 3 ; y6 y7 y4 y5 */
packssdw_r2r (mm0, mm1); /* 0 ; y3 y2 y1 y0 */
movq_r2r (mm4, mm7); /* 7 ; y6 y7 y4 y5 */
psrld_i2r (16, mm4); /* 0 y6 0 y4 */
movq_r2m (mm1, *(out)); /* 1 ; save y3 y2 y1 y0 */
pslld_i2r (16, mm7); /* y7 0 y5 0 */
por_r2r (mm4, mm7); /* 4 ; y7 y6 y5 y4 */
/* begin processing row 1 */
movq_r2m (mm7, *(out + 4)); /* 7 ; save y7 y6 y5 y4 */
/* begin processing row 1 */
movq_r2m (mm7, *(out + 4)); /* 7 ; save y7 y6 y5 y4 */
inptr += 8;
out += 8;
}
@ -477,31 +477,31 @@ idct_mmx32_rows (short *blk)
out = &qwTemp[0];
movq_m2r (*(out + ROW_STRIDE * 0), mm0);
movq_m2r (*(out + ROW_STRIDE * 1), mm1);
movq_r2r (mm0, mm4); /* mm4 = copy of row1[A B C D] */
movq_r2r (mm0, mm4); /* mm4 = copy of row1[A B C D] */
movq_m2r (*(out + ROW_STRIDE * 2), mm2);
punpcklwd_r2r (mm1, mm0); /* mm0 = [ 0 4 1 5] */
punpcklwd_r2r (mm1, mm0); /* mm0 = [ 0 4 1 5] */
movq_m2r (*(out + ROW_STRIDE * 3), mm3);
punpckhwd_r2r (mm1, mm4); /* mm4 = [ 2 6 3 7] */
punpckhwd_r2r (mm1, mm4); /* mm4 = [ 2 6 3 7] */
movq_r2r (mm2, mm6);
punpcklwd_r2r (mm3, mm2); /* mm2 = [ 8 12 9 13] */
punpckhwd_r2r (mm3, mm6); /* mm6 = 10 14 11 15] */
movq_r2r (mm0, mm1); /* mm1 = [ 0 4 1 5] */
punpcklwd_r2r (mm3, mm2); /* mm2 = [ 8 12 9 13] */
punpckhwd_r2r (mm3, mm6); /* mm6 = 10 14 11 15] */
movq_r2r (mm0, mm1); /* mm1 = [ 0 4 1 5] */
inptr = blk;
punpckldq_r2r (mm2, mm0); /* final result mm0 = row1 [0 4 8 12] */
movq_r2r (mm4, mm3); /* mm3 = [ 2 6 3 7] */
punpckhdq_r2r (mm2, mm1); /* mm1 = final result mm1 = row2 [1 5 9 13] */
movq_r2m (mm0, *(inptr + ROW_STRIDE * 0)); /* store row 1 */
punpckldq_r2r (mm6, mm4); /* final result mm4 = row3 [2 6 10 14] */
punpckldq_r2r (mm2, mm0); /* final result mm0 = row1 [0 4 8 12] */
movq_r2r (mm4, mm3); /* mm3 = [ 2 6 3 7] */
punpckhdq_r2r (mm2, mm1); /* mm1 = final result mm1 = row2 [1 5 9 13] */
movq_r2m (mm0, *(inptr + ROW_STRIDE * 0)); /* store row 1 */
punpckldq_r2r (mm6, mm4); /* final result mm4 = row3 [2 6 10 14] */
/* begin reading next quadrant (lower-right) */
movq_m2r (*(out + ROW_STRIDE * 4 + 4), mm0);
punpckhdq_r2r (mm6, mm3); /* final result mm3 = row4 [3 7 11 15] */
movq_r2m (mm4, *(inptr + ROW_STRIDE * 2)); /* store row 3 */
movq_r2r (mm0, mm4); /* mm4 = copy of row1[A B C D] */
movq_r2m (mm1, *(inptr + ROW_STRIDE * 1)); /* store row 2 */
punpckhdq_r2r (mm6, mm3); /* final result mm3 = row4 [3 7 11 15] */
movq_r2m (mm4, *(inptr + ROW_STRIDE * 2)); /* store row 3 */
movq_r2r (mm0, mm4); /* mm4 = copy of row1[A B C D] */
movq_r2m (mm1, *(inptr + ROW_STRIDE * 1)); /* store row 2 */
movq_m2r (*(out + ROW_STRIDE * 5 + 4), mm1);
movq_r2m (mm3, *(inptr + ROW_STRIDE * 3)); /* store row 4 */
punpcklwd_r2r (mm1, mm0); /* mm0 = [ 0 4 1 5] */
movq_r2m (mm3, *(inptr + ROW_STRIDE * 3)); /* store row 4 */
punpcklwd_r2r (mm1, mm0); /* mm0 = [ 0 4 1 5] */
/* 2) transpose lower-right quadrant */
@ -512,28 +512,28 @@ idct_mmx32_rows (short *blk)
movq_m2r (*(out + ROW_STRIDE * 6 + 4), mm2);
/* punpcklwd mm0, mm1; // mm0 = [ 0 4 1 5] */
punpckhwd_r2r (mm1, mm4); /* mm4 = [ 2 6 3 7] */
punpckhwd_r2r (mm1, mm4); /* mm4 = [ 2 6 3 7] */
movq_m2r (*(out + ROW_STRIDE * 7 + 4), mm3);
movq_r2r (mm2, mm6);
punpcklwd_r2r (mm3, mm2); /* mm2 = [ 8 12 9 13] */
movq_r2r (mm0, mm1); /* mm1 = [ 0 4 1 5] */
punpckhwd_r2r (mm3, mm6); /* mm6 = 10 14 11 15] */
movq_r2r (mm4, mm3); /* mm3 = [ 2 6 3 7] */
punpckldq_r2r (mm2, mm0); /* final result mm0 = row1 [0 4 8 12] */
punpckhdq_r2r (mm2, mm1); /* mm1 = final result mm1 = row2 [1 5 9 13] */
; /* slot */
movq_r2m (mm0, *(inptr + ROW_STRIDE * 4 + 4)); /* store row 1 */
punpckldq_r2r (mm6, mm4); /* final result mm4 = row3 [2 6 10 14] */
punpcklwd_r2r (mm3, mm2); /* mm2 = [ 8 12 9 13] */
movq_r2r (mm0, mm1); /* mm1 = [ 0 4 1 5] */
punpckhwd_r2r (mm3, mm6); /* mm6 = 10 14 11 15] */
movq_r2r (mm4, mm3); /* mm3 = [ 2 6 3 7] */
punpckldq_r2r (mm2, mm0); /* final result mm0 = row1 [0 4 8 12] */
punpckhdq_r2r (mm2, mm1); /* mm1 = final result mm1 = row2 [1 5 9 13] */
; /* slot */
movq_r2m (mm0, *(inptr + ROW_STRIDE * 4 + 4)); /* store row 1 */
punpckldq_r2r (mm6, mm4); /* final result mm4 = row3 [2 6 10 14] */
movq_m2r (*(out + ROW_STRIDE * 4), mm0);
punpckhdq_r2r (mm6, mm3); /* final result mm3 = row4 [3 7 11 15] */
movq_r2m (mm4, *(inptr + ROW_STRIDE * 6 + 4)); /* store row 3 */
movq_r2r (mm0, mm4); /* mm4 = copy of row1[A B C D] */
movq_r2m (mm1, *(inptr + ROW_STRIDE * 5 + 4)); /* store row 2 */
; /* slot */
punpckhdq_r2r (mm6, mm3); /* final result mm3 = row4 [3 7 11 15] */
movq_r2m (mm4, *(inptr + ROW_STRIDE * 6 + 4)); /* store row 3 */
movq_r2r (mm0, mm4); /* mm4 = copy of row1[A B C D] */
movq_r2m (mm1, *(inptr + ROW_STRIDE * 5 + 4)); /* store row 2 */
; /* slot */
movq_m2r (*(out + ROW_STRIDE * 5), mm1);
; /* slot */
movq_r2m (mm3, *(inptr + ROW_STRIDE * 7 + 4)); /* store row 4 */
punpcklwd_r2r (mm1, mm0); /* mm0 = [ 0 4 1 5] */
; /* slot */
movq_r2m (mm3, *(inptr + ROW_STRIDE * 7 + 4)); /* store row 4 */
punpcklwd_r2r (mm1, mm0); /* mm0 = [ 0 4 1 5] */
/* 3) transpose lower-left */
/* movq mm0, qword ptr [OUT + ROW_STRIDE * 4 ] */
@ -543,28 +543,28 @@ idct_mmx32_rows (short *blk)
movq_m2r (*(out + ROW_STRIDE * 6), mm2);
/* punpcklwd mm0, mm1; // mm0 = [ 0 4 1 5] */
punpckhwd_r2r (mm1, mm4); /* mm4 = [ 2 6 3 7] */
punpckhwd_r2r (mm1, mm4); /* mm4 = [ 2 6 3 7] */
movq_m2r (*(out + ROW_STRIDE * 7), mm3);
movq_r2r (mm2, mm6);
punpcklwd_r2r (mm3, mm2); /* mm2 = [ 8 12 9 13] */
movq_r2r (mm0, mm1); /* mm1 = [ 0 4 1 5] */
punpckhwd_r2r (mm3, mm6); /* mm6 = 10 14 11 15] */
movq_r2r (mm4, mm3); /* mm3 = [ 2 6 3 7] */
punpckldq_r2r (mm2, mm0); /* final result mm0 = row1 [0 4 8 12] */
punpckhdq_r2r (mm2, mm1); /* mm1 = final result mm1 = row2 [1 5 9 13] */
; /*slot */
movq_r2m (mm0, *(inptr + ROW_STRIDE * 0 + 4)); /* store row 1 */
punpckldq_r2r (mm6, mm4); /* final result mm4 = row3 [2 6 10 14] */
punpcklwd_r2r (mm3, mm2); /* mm2 = [ 8 12 9 13] */
movq_r2r (mm0, mm1); /* mm1 = [ 0 4 1 5] */
punpckhwd_r2r (mm3, mm6); /* mm6 = 10 14 11 15] */
movq_r2r (mm4, mm3); /* mm3 = [ 2 6 3 7] */
punpckldq_r2r (mm2, mm0); /* final result mm0 = row1 [0 4 8 12] */
punpckhdq_r2r (mm2, mm1); /* mm1 = final result mm1 = row2 [1 5 9 13] */
; /*slot */
movq_r2m (mm0, *(inptr + ROW_STRIDE * 0 + 4)); /* store row 1 */
punpckldq_r2r (mm6, mm4); /* final result mm4 = row3 [2 6 10 14] */
/* begin reading next quadrant (upper-right) */
movq_m2r (*(out + ROW_STRIDE * 0 + 4), mm0);
punpckhdq_r2r (mm6, mm3); /* final result mm3 = row4 [3 7 11 15] */
movq_r2m (mm4, *(inptr + ROW_STRIDE * 2 + 4)); /* store row 3 */
movq_r2r (mm0, mm4); /* mm4 = copy of row1[A B C D] */
movq_r2m (mm1, *(inptr + ROW_STRIDE * 1 + 4)); /* store row 2 */
punpckhdq_r2r (mm6, mm3); /* final result mm3 = row4 [3 7 11 15] */
movq_r2m (mm4, *(inptr + ROW_STRIDE * 2 + 4)); /* store row 3 */
movq_r2r (mm0, mm4); /* mm4 = copy of row1[A B C D] */
movq_r2m (mm1, *(inptr + ROW_STRIDE * 1 + 4)); /* store row 2 */
movq_m2r (*(out + ROW_STRIDE * 1 + 4), mm1);
movq_r2m (mm3, *(inptr + ROW_STRIDE * 3 + 4)); /* store row 4 */
punpcklwd_r2r (mm1, mm0); /* mm0 = [ 0 4 1 5] */
movq_r2m (mm3, *(inptr + ROW_STRIDE * 3 + 4)); /* store row 4 */
punpcklwd_r2r (mm1, mm0); /* mm0 = [ 0 4 1 5] */
/* 2) transpose lower-right quadrant */
@ -575,28 +575,28 @@ idct_mmx32_rows (short *blk)
movq_m2r (*(out + ROW_STRIDE * 2 + 4), mm2);
/* punpcklwd mm0, mm1; // mm0 = [ 0 4 1 5] */
punpckhwd_r2r (mm1, mm4); /* mm4 = [ 2 6 3 7] */
punpckhwd_r2r (mm1, mm4); /* mm4 = [ 2 6 3 7] */
movq_m2r (*(out + ROW_STRIDE * 3 + 4), mm3);
movq_r2r (mm2, mm6);
punpcklwd_r2r (mm3, mm2); /* mm2 = [ 8 12 9 13] */
movq_r2r (mm0, mm1); /* mm1 = [ 0 4 1 5] */
punpckhwd_r2r (mm3, mm6); /* mm6 = 10 14 11 15] */
movq_r2r (mm4, mm3); /* mm3 = [ 2 6 3 7] */
punpckldq_r2r (mm2, mm0); /* final result mm0 = row1 [0 4 8 12] */
punpckhdq_r2r (mm2, mm1); /* mm1 = final result mm1 = row2 [1 5 9 13] */
; /* slot */
movq_r2m (mm0, *(inptr + ROW_STRIDE * 4)); /* store row 1 */
punpckldq_r2r (mm6, mm4); /* final result mm4 = row3 [2 6 10 14] */
movq_r2m (mm1, *(inptr + ROW_STRIDE * 5)); /* store row 2 */
punpckhdq_r2r (mm6, mm3); /* final result mm3 = row4 [3 7 11 15] */
movq_r2m (mm4, *(inptr + ROW_STRIDE * 6)); /* store row 3 */
; /* slot */
movq_r2m (mm3, *(inptr + ROW_STRIDE * 7)); /* store row 4 */
; /* slot */
punpcklwd_r2r (mm3, mm2); /* mm2 = [ 8 12 9 13] */
movq_r2r (mm0, mm1); /* mm1 = [ 0 4 1 5] */
punpckhwd_r2r (mm3, mm6); /* mm6 = 10 14 11 15] */
movq_r2r (mm4, mm3); /* mm3 = [ 2 6 3 7] */
punpckldq_r2r (mm2, mm0); /* final result mm0 = row1 [0 4 8 12] */
punpckhdq_r2r (mm2, mm1); /* mm1 = final result mm1 = row2 [1 5 9 13] */
; /* slot */
movq_r2m (mm0, *(inptr + ROW_STRIDE * 4)); /* store row 1 */
punpckldq_r2r (mm6, mm4); /* final result mm4 = row3 [2 6 10 14] */
movq_r2m (mm1, *(inptr + ROW_STRIDE * 5)); /* store row 2 */
punpckhdq_r2r (mm6, mm3); /* final result mm3 = row4 [3 7 11 15] */
movq_r2m (mm4, *(inptr + ROW_STRIDE * 6)); /* store row 3 */
; /* slot */
movq_r2m (mm3, *(inptr + ROW_STRIDE * 7)); /* store row 4 */
; /* slot */
}
static void
idct_mmx32_cols (short *blk)
{ /* transform all 8 cols of 8x8 iDCT block */
{ /* transform all 8 cols of 8x8 iDCT block */
int x;
short *inptr = blk;
@ -612,58 +612,58 @@ idct_mmx32_cols (short *blk)
/* */
/* 2) transpose the matrix (which was stored in qwTemp[]) */
/* qwTemp[] -> [8x8 matrix transpose] -> blk[] */
for (x = 0; x < 8; x++) { /* transform one row per iteration */
movq_m2r (*(inptr), mm0); /* 0 ; x3 x2 x1 x0 */
movq_m2r (*(inptr + 4), mm1); /* 1 ; x7 x6 x5 x4 */
movq_r2r (mm0, mm2); /* 2 ; x3 x2 x1 x0 */
movq_m2r (*(tab_i_01234567), mm3); /* 3 ; w06 w04 w02 w00 */
punpcklwd_r2r (mm1, mm0); /* x5 x1 x4 x0 */
for (x = 0; x < 8; x++) { /* transform one row per iteration */
movq_m2r (*(inptr), mm0); /* 0 ; x3 x2 x1 x0 */
movq_m2r (*(inptr + 4), mm1); /* 1 ; x7 x6 x5 x4 */
movq_r2r (mm0, mm2); /* 2 ; x3 x2 x1 x0 */
movq_m2r (*(tab_i_01234567), mm3); /* 3 ; w06 w04 w02 w00 */
punpcklwd_r2r (mm1, mm0); /* x5 x1 x4 x0 */
/* ---------- */
movq_r2r (mm0, mm5); /* 5 ; x5 x1 x4 x0 */
punpckldq_r2r (mm0, mm0); /* x4 x0 x4 x0 */
movq_m2r (*(tab_i_01234567 + 4), mm4); /* 4 ; w07 w05 w03 w01 */
punpckhwd_r2r (mm1, mm2); /* 1 ; x7 x3 x6 x2 */
pmaddwd_r2r (mm0, mm3); /* x4*w06+x0*w04 x4*w02+x0*w00 */
movq_r2r (mm2, mm6); /* 6 ; x7 x3 x6 x2 */
movq_m2r (*(tab_i_01234567 + 16), mm1); /* 1 ; w22 w20 w18 w16 */
punpckldq_r2r (mm2, mm2); /* x6 x2 x6 x2 */
pmaddwd_r2r (mm2, mm4); /* x6*w07+x2*w05 x6*w03+x2*w01 */
punpckhdq_r2r (mm5, mm5); /* x5 x1 x5 x1 */
pmaddwd_m2r (*(tab_i_01234567 + 8), mm0); /* x4*w14+x0*w12 x4*w10+x0*w08 */
punpckhdq_r2r (mm6, mm6); /* x7 x3 x7 x3 */
movq_m2r (*(tab_i_01234567 + 20), mm7); /* 7 ; w23 w21 w19 w17 */
pmaddwd_r2r (mm5, mm1); /* x5*w22+x1*w20 x5*w18+x1*w16 */
paddd_m2r (*(r_inv_col), mm3); /* +rounder */
pmaddwd_r2r (mm6, mm7); /* x7*w23+x3*w21 x7*w19+x3*w17 */
pmaddwd_m2r (*(tab_i_01234567 + 12), mm2); /* x6*w15+x2*w13 x6*w11+x2*w09 */
paddd_r2r (mm4, mm3); /* 4 ; a1=sum(even1) a0=sum(even0) */
pmaddwd_m2r (*(tab_i_01234567 + 24), mm5); /* x5*w30+x1*w28 x5*w26+x1*w24 */
movq_r2r (mm3, mm4); /* 4 ; a1 a0 */
pmaddwd_m2r (*(tab_i_01234567 + 28), mm6); /* x7*w31+x3*w29 x7*w27+x3*w25 */
paddd_r2r (mm7, mm1); /* 7 ; b1=sum(odd1) b0=sum(odd0) */
paddd_m2r (*(r_inv_col), mm0); /* +rounder */
psubd_r2r (mm1, mm3); /* a1-b1 a0-b0 */
psrad_i2r (SHIFT_INV_COL, mm3); /* y6=a1-b1 y7=a0-b0 */
paddd_r2r (mm4, mm1); /* 4 ; a1+b1 a0+b0 */
paddd_r2r (mm2, mm0); /* 2 ; a3=sum(even3) a2=sum(even2) */
psrad_i2r (SHIFT_INV_COL, mm1); /* y1=a1+b1 y0=a0+b0 */
paddd_r2r (mm6, mm5); /* 6 ; b3=sum(odd3) b2=sum(odd2) */
movq_r2r (mm0, mm4); /* 4 ; a3 a2 */
paddd_r2r (mm5, mm0); /* a3+b3 a2+b2 */
psubd_r2r (mm5, mm4); /* 5 ; a3-b3 a2-b2 */
psrad_i2r (SHIFT_INV_COL, mm4); /* y4=a3-b3 y5=a2-b2 */
psrad_i2r (SHIFT_INV_COL, mm0); /* y3=a3+b3 y2=a2+b2 */
packssdw_r2r (mm3, mm4); /* 3 ; y6 y7 y4 y5 */
packssdw_r2r (mm0, mm1); /* 0 ; y3 y2 y1 y0 */
movq_r2r (mm4, mm7); /* 7 ; y6 y7 y4 y5 */
psrld_i2r (16, mm4); /* 0 y6 0 y4 */
movq_r2m (mm1, *(inptr)); /* 1 ; save y3 y2 y1 y0 */
pslld_i2r (16, mm7); /* y7 0 y5 0 */
por_r2r (mm4, mm7); /* 4 ; y7 y6 y5 y4 */
movq_r2r (mm0, mm5); /* 5 ; x5 x1 x4 x0 */
punpckldq_r2r (mm0, mm0); /* x4 x0 x4 x0 */
movq_m2r (*(tab_i_01234567 + 4), mm4); /* 4 ; w07 w05 w03 w01 */
punpckhwd_r2r (mm1, mm2); /* 1 ; x7 x3 x6 x2 */
pmaddwd_r2r (mm0, mm3); /* x4*w06+x0*w04 x4*w02+x0*w00 */
movq_r2r (mm2, mm6); /* 6 ; x7 x3 x6 x2 */
movq_m2r (*(tab_i_01234567 + 16), mm1); /* 1 ; w22 w20 w18 w16 */
punpckldq_r2r (mm2, mm2); /* x6 x2 x6 x2 */
pmaddwd_r2r (mm2, mm4); /* x6*w07+x2*w05 x6*w03+x2*w01 */
punpckhdq_r2r (mm5, mm5); /* x5 x1 x5 x1 */
pmaddwd_m2r (*(tab_i_01234567 + 8), mm0); /* x4*w14+x0*w12 x4*w10+x0*w08 */
punpckhdq_r2r (mm6, mm6); /* x7 x3 x7 x3 */
movq_m2r (*(tab_i_01234567 + 20), mm7); /* 7 ; w23 w21 w19 w17 */
pmaddwd_r2r (mm5, mm1); /* x5*w22+x1*w20 x5*w18+x1*w16 */
paddd_m2r (*(r_inv_col), mm3); /* +rounder */
pmaddwd_r2r (mm6, mm7); /* x7*w23+x3*w21 x7*w19+x3*w17 */
pmaddwd_m2r (*(tab_i_01234567 + 12), mm2); /* x6*w15+x2*w13 x6*w11+x2*w09 */
paddd_r2r (mm4, mm3); /* 4 ; a1=sum(even1) a0=sum(even0) */
pmaddwd_m2r (*(tab_i_01234567 + 24), mm5); /* x5*w30+x1*w28 x5*w26+x1*w24 */
movq_r2r (mm3, mm4); /* 4 ; a1 a0 */
pmaddwd_m2r (*(tab_i_01234567 + 28), mm6); /* x7*w31+x3*w29 x7*w27+x3*w25 */
paddd_r2r (mm7, mm1); /* 7 ; b1=sum(odd1) b0=sum(odd0) */
paddd_m2r (*(r_inv_col), mm0); /* +rounder */
psubd_r2r (mm1, mm3); /* a1-b1 a0-b0 */
psrad_i2r (SHIFT_INV_COL, mm3); /* y6=a1-b1 y7=a0-b0 */
paddd_r2r (mm4, mm1); /* 4 ; a1+b1 a0+b0 */
paddd_r2r (mm2, mm0); /* 2 ; a3=sum(even3) a2=sum(even2) */
psrad_i2r (SHIFT_INV_COL, mm1); /* y1=a1+b1 y0=a0+b0 */
paddd_r2r (mm6, mm5); /* 6 ; b3=sum(odd3) b2=sum(odd2) */
movq_r2r (mm0, mm4); /* 4 ; a3 a2 */
paddd_r2r (mm5, mm0); /* a3+b3 a2+b2 */
psubd_r2r (mm5, mm4); /* 5 ; a3-b3 a2-b2 */
psrad_i2r (SHIFT_INV_COL, mm4); /* y4=a3-b3 y5=a2-b2 */
psrad_i2r (SHIFT_INV_COL, mm0); /* y3=a3+b3 y2=a2+b2 */
packssdw_r2r (mm3, mm4); /* 3 ; y6 y7 y4 y5 */
packssdw_r2r (mm0, mm1); /* 0 ; y3 y2 y1 y0 */
movq_r2r (mm4, mm7); /* 7 ; y6 y7 y4 y5 */
psrld_i2r (16, mm4); /* 0 y6 0 y4 */
movq_r2m (mm1, *(inptr)); /* 1 ; save y3 y2 y1 y0 */
pslld_i2r (16, mm7); /* y7 0 y5 0 */
por_r2r (mm4, mm7); /* 4 ; y7 y6 y5 y4 */
/* begin processing row 1 */
movq_r2m (mm7, *(inptr + 4)); /* 7 ; save y7 y6 y5 y4 */
/* begin processing row 1 */
movq_r2m (mm7, *(inptr + 4)); /* 7 ; save y7 y6 y5 y4 */
inptr += 8;
}
@ -679,10 +679,12 @@ gst_idct_mmx32_idct (short *blk)
{
/* 1) iDCT row transformation */
idct_mmx32_rows (blk); /* 1) transform iDCT row, and transpose */
idct_mmx32_rows (blk); /* 1) transform iDCT row, and transpose */
/* 2) iDCT column transformation */
idct_mmx32_cols (blk); /* 2) transform iDCT row, and transpose */
emms (); /* restore processor state */
idct_mmx32_cols (blk); /* 2) transform iDCT row, and transpose */
emms (); /* restore processor state */
/* all done */
}
}

View file

@ -104,11 +104,11 @@ have_type_callback (GstElement * typefind, guint probability, GstCaps * type,
/* FIXME: signal error */
g_warning ("Couldn't create id3tag");
if (!gst_element_link_many (priv->source, priv->decontainer, priv->typefind,
NULL));
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
@ -139,8 +139,8 @@ deep_notify_callback (GObject * object, GstObject * origin,
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));
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 */
}
@ -151,7 +151,8 @@ typedef struct
{
guint meta;
guint encoded;
} TagFlagScore;
}
TagFlagScore;
static void
tag_flag_score (const GstTagList * list, const gchar * tag, gpointer user_data)
@ -323,7 +324,7 @@ gmi_seek_to_track (GstMediaInfo * info, long track)
res = gst_pad_send_event (info->priv->decoder_pad, event);
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 */
@ -350,37 +351,37 @@ gmi_set_mime (GstMediaInfo * info, const char *mime)
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);
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);
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);
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);
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);
g_strdup_printf
("%s name=source ! modplug name=decoder ! audio/x-raw-int ! fakesink name=sink",
priv->source_name);
else
return FALSE;
@ -409,7 +410,7 @@ gmi_set_mime (GstMediaInfo * info, const char *mime)
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));
decoder_pad))), gst_pad_get_name (priv->decoder_pad));
/* attach notify handler */
g_signal_connect (G_OBJECT (info->priv->pipeline), "deep_notify",
@ -557,21 +558,21 @@ gmip_find_stream_post (GstMediaInfoPriv * priv)
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:
break;
default:
/* separation is necessary because track_format doesn't resolve to
* int */
if (format == track_format) {
stream->length_tracks = value;
GST_DEBUG (" total %s: %lld", definition->nick, value);
} else
GST_DEBUG ("unhandled format %s", definition->nick);
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:
break;
default:
/* separation is necessary because track_format doesn't resolve to
* int */
if (format == track_format) {
stream->length_tracks = value;
GST_DEBUG (" total %s: %lld", definition->nick, value);
} else
GST_DEBUG ("unhandled format %s", definition->nick);
}
} else
GST_DEBUG ("query didn't return result for %s", definition->nick);
@ -597,7 +598,7 @@ gmip_find_stream_post (GstMediaInfoPriv * priv)
stream->bitrate = (long) (bits / seconds);
}
GST_DEBUG ("moving to STATE_METADATA\n");
priv->state = GST_MEDIA_INFO_STATE_METADATA; /* metadata of first track */
priv->state = GST_MEDIA_INFO_STATE_METADATA; /* metadata of first track */
return TRUE;
}
@ -694,23 +695,23 @@ gmip_find_track_streaminfo_post (GstMediaInfoPriv * priv)
gboolean res;
res = gst_pad_query (priv->decoder_pad, GST_QUERY_POSITION,
&track_format, &value_start);
&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);
track_format, track_num, &format, &value_start);
res &= gst_pad_convert (priv->decoder_pad,
track_format, track_num + 1, &format, &value_end);
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 */
/* 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 */
gst_tag_list_add (priv->streaminfo, GST_TAG_MERGE_REPLACE,
GST_TAG_DURATION, (int) (value_end / 1E6), NULL);
gst_tag_list_add (priv->streaminfo, GST_TAG_MERGE_REPLACE,
GST_TAG_DURATION, (int) (value_end / 1E6), NULL);
}
}
}

View file

@ -18,7 +18,7 @@ print_tag (const GstTagList * list, const gchar * tag, gpointer unused)
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));
g_strdup_value_contents (gst_tag_list_get_value_index (list, tag, i));
}
if (i == 0) {

View file

@ -113,8 +113,9 @@ gst_media_info_get_type (void)
(GInstanceInitFunc) gst_media_info_instance_init,
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;
}
@ -192,7 +193,7 @@ gst_media_info_new (GError ** error)
info->priv->error = NULL;
} else {
g_warning ("Error creating GstMediaInfo object.\n%s",
info->priv->error->message);
info->priv->error->message);
g_error_free (info->priv->error);
}
}
@ -222,7 +223,7 @@ gst_media_info_read_with_idler (GstMediaInfo * info, const char *location,
{
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;
}
@ -251,9 +252,9 @@ gst_media_info_read_idler (GstMediaInfo * info, GstMediaInfoStream ** streamp,
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;
*error = g_error_new (GST_MEDIA_INFO_ERROR, 0,
"No source set on media info.");
return FALSE;
}
/* need to find type */
@ -266,26 +267,26 @@ gst_media_info_read_idler (GstMediaInfo * info, GstMediaInfoStream ** streamp,
GST_LOG ("STATE_TYPEFIND");
if ((priv->type == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline))) {
GST_DEBUG ("iterating while in STATE_TYPEFIND");
GMI_DEBUG ("?");
return TRUE;
GST_DEBUG ("iterating while in STATE_TYPEFIND");
GMI_DEBUG ("?");
return TRUE;
}
if (priv->type == NULL) {
g_warning ("Couldn't find type\n");
return FALSE;
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)));
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;
/* 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);
@ -298,12 +299,12 @@ gst_media_info_read_idler (GstMediaInfo * info, GstMediaInfoStream ** streamp,
{
GST_LOG ("STATE_STREAM");
if ((priv->format == NULL) && gst_bin_iterate (GST_BIN (priv->pipeline))) {
GMI_DEBUG ("?");
return TRUE;
GMI_DEBUG ("?");
return TRUE;
}
if (priv->format == NULL) {
g_warning ("Couldn't find format\n");
return FALSE;
g_warning ("Couldn't find format\n");
return FALSE;
}
/* do state transition; stream -> first track metadata */
priv->current_track_num = 0;
@ -316,21 +317,21 @@ gst_media_info_read_idler (GstMediaInfo * info, GstMediaInfoStream ** streamp,
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++;
return TRUE;
gst_bin_iterate (GST_BIN (priv->pipeline)) &&
priv->metadata_iters < MAX_METADATA_ITERS) {
GMI_DEBUG ("?");
priv->metadata_iters++;
return TRUE;
}
if (priv->metadata_iters == MAX_METADATA_ITERS)
g_print ("iterated a few times, didn't find metadata\n");
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");
/* this is not a permanent failure */
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;
return FALSE;
GST_DEBUG ("METADATA: going to STREAMINFO\n");
priv->state = GST_MEDIA_INFO_STATE_STREAMINFO;
return gmip_find_track_streaminfo_pre (priv);
@ -338,50 +339,50 @@ gst_media_info_read_idler (GstMediaInfo * info, GstMediaInfoStream ** streamp,
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) {
/* this is not a permanent failure */
GST_DEBUG ("Couldn't find streaminfo");
/* this is not a permanent failure */
GST_DEBUG ("Couldn't find streaminfo");
} else
GST_DEBUG ("found streaminfo of track %ld", priv->current_track_num);
GST_DEBUG ("found streaminfo of track %ld", priv->current_track_num);
if (!gmip_find_track_streaminfo_post (priv))
return FALSE;
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;
GMI_DEBUG ("?");
return TRUE;
}
if (priv->format == NULL) {
g_warning ("Couldn't find format\n");
return FALSE;
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;
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)) {
g_free (priv->current_track);
return FALSE;
}
priv->state = GST_MEDIA_INFO_STATE_METADATA;
return TRUE;
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;
}
priv->state = GST_MEDIA_INFO_STATE_METADATA;
return TRUE;
}
priv->state = GST_MEDIA_INFO_STATE_DONE;
gmi_clear_decoder (info);

View file

@ -57,9 +57,9 @@ gst_mixer_get_type (void)
};
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;
@ -72,26 +72,26 @@ gst_mixer_class_init (GstMixerClass * klass)
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;
}

View file

@ -61,8 +61,8 @@ gst_mixer_track_get_type (void)
};
gst_mixer_track_type =
g_type_register_static (G_TYPE_OBJECT,
"GstMixerTrack", &mixer_track_info, 0);
g_type_register_static (G_TYPE_OBJECT,
"GstMixerTrack", &mixer_track_info, 0);
}
return gst_mixer_track_type;
@ -79,21 +79,21 @@ gst_mixer_track_class_init (GstMixerTrackClass * klass)
g_signal_new ("record_toggled", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstMixerTrackClass,
record_toggled),
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),
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),
volume_changed),
NULL, NULL, g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1, G_TYPE_POINTER);

View file

@ -46,7 +46,7 @@ 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;
@ -75,7 +75,7 @@ gst_navigation_send_key_event (GstNavigation * navigation, const char *event,
{
gst_navigation_send_event (navigation,
gst_structure_new ("application/x-gst-navigation", "event", G_TYPE_STRING,
event, "key", G_TYPE_STRING, key, NULL));
event, "key", G_TYPE_STRING, key, NULL));
}
void
@ -84,6 +84,6 @@ gst_navigation_send_mouse_event (GstNavigation * navigation, const char *event,
{
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));
event, "button", G_TYPE_INT, button, "pointer_x", G_TYPE_DOUBLE, x,
"pointer_y", G_TYPE_DOUBLE, y, NULL));
}

View file

@ -45,8 +45,8 @@ struct _GstPlayPrivate
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;
@ -171,7 +171,7 @@ gst_play_pipeline_setup (GstPlay * play, GError ** error)
/* Make sure we convert audio to the needed format */
GST_PLAY_MAKE_OR_ERROR (audioconvert, "audioconvert", "audioconvert",
error);
error);
g_hash_table_insert (play->priv->elements, "audioconvert", audioconvert);
/* Duplicate audio signal to audio sink and visualization thread */
@ -183,7 +183,7 @@ gst_play_pipeline_setup (GstPlay * play, GError ** error)
g_hash_table_insert (play->priv->elements, "tee", tee);
gst_bin_add_many (GST_BIN (work_thread), source, autoplugger, audioconvert,
tee, NULL);
tee, NULL);
if (!gst_element_link_many (source, autoplugger, audioconvert, tee, NULL))
GST_PLAY_ERROR_RETURN (error, "Could not link source thread elements");
@ -194,13 +194,13 @@ gst_play_pipeline_setup (GstPlay * play, GError ** error)
identity_cs = gst_element_factory_make ("ffcolorspace", "identity_cs");
if (!GST_IS_ELEMENT (identity_cs)) {
identity_cs =
gst_element_factory_make ("ffmpegcolorspace", "identity_cs");
gst_element_factory_make ("ffmpegcolorspace", "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;
}
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);
@ -232,11 +232,11 @@ gst_play_pipeline_setup (GstPlay * play, GError ** error)
if (!GST_IS_ELEMENT (vis_cs)) {
vis_cs = gst_element_factory_make ("ffmpegcolorspace", "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;
}
vis_cs = gst_element_factory_make ("colorspace", "vis_cs");
if (!GST_IS_ELEMENT (vis_cs)) {
gst_play_error_plugin ("colorspace", error);
return FALSE;
}
}
}
@ -245,9 +245,9 @@ gst_play_pipeline_setup (GstPlay * play, GError ** error)
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");
"Could not link visualisation thread elements");
gst_element_add_ghost_pad (vis_bin, gst_element_get_pad (vis_cs, "src"),
"src");
"src");
}
/* Creating our video output bin */
{
@ -267,18 +267,18 @@ gst_play_pipeline_setup (GstPlay * play, GError ** error)
if (!GST_IS_ELEMENT (video_cs)) {
video_cs = gst_element_factory_make ("ffmpegcolorspace", "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;
}
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);
error);
g_hash_table_insert (play->priv->elements, "video_balance", video_balance);
/* Colorspace conversion */
@ -286,11 +286,11 @@ gst_play_pipeline_setup (GstPlay * play, GError ** error)
if (!GST_IS_ELEMENT (balance_cs)) {
balance_cs = gst_element_factory_make ("ffmpegcolorspace", "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;
}
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);
@ -299,38 +299,38 @@ gst_play_pipeline_setup (GstPlay * play, GError ** error)
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);
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);
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)");
"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)");
"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)");
"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)");
"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)");
"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)");
"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");
"sink"), "sink");
if (!gst_element_link (identity_cs, video_thread))
GST_PLAY_ERROR_RETURN (error,
"Could not link video output thread elements");
"Could not link video output thread elements");
}
/* Creating our audio output bin
{ queue ! fakesink } */
@ -347,19 +347,19 @@ gst_play_pipeline_setup (GstPlay * play, GError ** error)
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);
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);
NULL);
if (!gst_element_link_many (audio_queue, volume, audio_sink, NULL))
GST_PLAY_ERROR_RETURN (error,
"Could not link audio output thread elements");
"Could not link audio output thread elements");
gst_element_add_ghost_pad (audio_thread, gst_element_get_pad (audio_queue,
"sink"), "sink");
"sink"), "sink");
gst_pad_link (tee_pad2, gst_element_get_pad (audio_queue, "sink"));
}
@ -408,7 +408,7 @@ gst_play_tick_callback (GstPlay * play)
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;
@ -443,15 +443,15 @@ gst_play_get_length_callback (GstPlay * play)
/* Audio first and then Video */
if (GST_IS_ELEMENT (audio_sink_element))
q = gst_element_query (audio_sink_element, GST_QUERY_TOTAL, &format,
&value);
&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;
}
@ -487,7 +487,7 @@ gst_play_video_fixate (GstPad * pad, const GstCaps * caps, gpointer user_data)
return newcaps;
}
if (gst_caps_structure_fixate_field_nearest_double (structure, "framerate",
30.0)) {
30.0)) {
return newcaps;
}
@ -545,7 +545,7 @@ gst_play_state_change (GstElement * element, GstElementState old,
}
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;
@ -555,7 +555,7 @@ gst_play_state_change (GstElement * element, GstElementState old,
}
play->priv->length_id = g_timeout_add (TICK_INTERVAL_MSEC,
(GSourceFunc) gst_play_get_length_callback, play);
(GSourceFunc) gst_play_get_length_callback, play);
} else {
if (play->priv->tick_id) {
g_source_remove (play->priv->tick_id);
@ -632,7 +632,7 @@ gst_play_init (GstPlay * play)
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);
}
}
@ -793,10 +793,10 @@ gst_play_seek_to_time (GstPlay * play, gint64 time_nanos)
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) {
@ -804,11 +804,11 @@ gst_play_seek_to_time (GstPlay * play, gint64 time_nanos)
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);
}
}
@ -907,10 +907,10 @@ gst_play_set_video_sink (GstPlay * play, GstElement * video_sink)
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);
}
}
@ -966,7 +966,7 @@ gst_play_set_audio_sink (GstPlay * play, GstElement * audio_sink)
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)));
@ -1114,7 +1114,7 @@ gst_play_connect_visualization (GstPlay * play, gboolean connect)
/* 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);
@ -1168,64 +1168,64 @@ gst_play_get_sink_element (GstPlay * play,
if (GST_IS_BIN (element)) {
element = gst_play_get_sink_element (play, element, sink_type);
if (GST_IS_ELEMENT (element))
return element;
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;
/* 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);
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),
"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;
}
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);
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;
}
}
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);
pads = g_list_next (pads);
}
if ((!has_src) && (has_correct_type))
return element;
return element;
}
elements = g_list_next (elements);
@ -1247,7 +1247,7 @@ gst_play_new (GError ** error)
play->priv->error = NULL;
} else {
g_warning ("Error creating GstPlay object.\n%s",
play->priv->error->message);
play->priv->error->message);
g_error_free (play->priv->error);
}
}
@ -1280,7 +1280,7 @@ gst_play_get_type (void)
};
play_type = g_type_register_static (GST_TYPE_PIPELINE, "GstPlay",
&play_info, 0);
&play_info, 0);
}
return play_type;

View file

@ -56,8 +56,8 @@ gst_property_probe_get_type (void)
};
gst_property_probe_type =
g_type_register_static (G_TYPE_INTERFACE,
"GstPropertyProbe", &gst_property_probe_info, 0);
g_type_register_static (G_TYPE_INTERFACE,
"GstPropertyProbe", &gst_property_probe_info, 0);
}
return gst_property_probe_type;
@ -70,10 +70,10 @@ gst_property_probe_iface_init (GstPropertyProbeInterface * iface)
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;
}

View file

@ -108,7 +108,8 @@ static union
{
int i[4];
float f[4];
} av_tmp __attribute__ ((__aligned__ (16)));
}
av_tmp __attribute__ ((__aligned__ (16)));
void
conv_double_short_altivec (double *dest, short *src, int n)
@ -122,7 +123,7 @@ conv_double_short_altivec (double *dest, short *src, int n)
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];

View file

@ -100,33 +100,33 @@ gst_resample_reinit (gst_resample_t * r)
switch (r->method) {
default:
case GST_RESAMPLE_NEAREST:
r->scale = gst_resample_nearest_s16;
break;
r->scale = gst_resample_nearest_s16;
break;
case GST_RESAMPLE_BILINEAR:
r->scale = gst_resample_bilinear_s16;
break;
r->scale = gst_resample_bilinear_s16;
break;
case GST_RESAMPLE_SINC_SLOW:
r->scale = gst_resample_sinc_s16;
break;
r->scale = gst_resample_sinc_s16;
break;
case GST_RESAMPLE_SINC:
r->scale = gst_resample_sinc_ft_s16;
break;
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;
r->scale = gst_resample_nearest_float;
break;
case GST_RESAMPLE_BILINEAR:
r->scale = gst_resample_bilinear_float;
break;
r->scale = gst_resample_bilinear_float;
break;
case GST_RESAMPLE_SINC_SLOW:
r->scale = gst_resample_sinc_float;
break;
r->scale = gst_resample_sinc_float;
break;
case GST_RESAMPLE_SINC:
r->scale = gst_resample_sinc_ft_float;
break;
r->scale = gst_resample_sinc_ft_float;
break;
}
} else {
fprintf (stderr, "gst_resample: Unexpected format \"%d\"\n", r->format);
@ -170,9 +170,9 @@ gst_resample_scale (gst_resample_t * r, void *i_buf, unsigned int i_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);
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);
r->i_start, r->i_end, r->o_start);
}
if ((r->filter_length + r->i_samples) * sizeof (double) * 2 > r->buffer_len) {
@ -191,20 +191,20 @@ gst_resample_scale (gst_resample_t * r, void *i_buf, unsigned int i_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);
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);
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);
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->filter_length * sizeof (double) * 2, r->i_buf, r->i_samples,
sizeof (double) * 2);
}
}
@ -358,15 +358,15 @@ gst_resample_sinc_slow_s16 (gst_resample_t * r)
c0 = 0;
c1 = 0;
for (j = 0; j < r->filter_length; j++) {
weight = (x == 0) ? 1 : (sinx / x);
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;
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);
@ -494,7 +494,7 @@ gst_resample_sinc_ft_s16 (gst_resample_t * r)
double scale;
int n = 4;
scale = r->i_inc; /* cutoff at 22050 */
scale = r->i_inc; /* cutoff at 22050 */
/*scale = 1.0; // cutoff at 24000 */
/*scale = r->i_inc * 0.5; // cutoff at 11025 */
@ -546,7 +546,7 @@ gst_resample_sinc_ft_s16 (gst_resample_t * r)
}
#else
functable_fir2 (ft,
&c0, &c1, x, n, ptr + (start + r->filter_length) * 2, r->filter_length);
&c0, &c1, x, n, ptr + (start + r->filter_length) * 2, r->filter_length);
c0 *= scale;
c1 *= scale;
#endif
@ -566,7 +566,7 @@ gst_resample_sinc_ft_s16 (gst_resample_t * r)
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));
2 * sizeof (double));
}
}
@ -711,15 +711,15 @@ gst_resample_sinc_slow_float (gst_resample_t * r)
c0 = 0;
c1 = 0;
for (j = 0; j < r->filter_length; j++) {
weight = (x == 0) ? 1 : (sinx / x);
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;
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;
@ -806,7 +806,7 @@ gst_resample_sinc_ft_float (gst_resample_t * r)
double scale;
int n = 4;
scale = r->i_inc; /* cutoff at 22050 */
scale = r->i_inc; /* cutoff at 22050 */
/*scale = 1.0; // cutoff at 24000 */
/*scale = r->i_inc * 0.5; // cutoff at 11025 */
@ -858,7 +858,7 @@ gst_resample_sinc_ft_float (gst_resample_t * r)
}
#else
functable_fir2 (ft,
&c0, &c1, x, n, ptr + (start + r->filter_length) * 2, r->filter_length);
&c0, &c1, x, n, ptr + (start + r->filter_length) * 2, r->filter_length);
c0 *= scale;
c1 *= scale;
#endif
@ -878,7 +878,7 @@ gst_resample_sinc_ft_float (gst_resample_t * r)
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));
2 * sizeof (double));
}
}

View file

@ -123,7 +123,7 @@ test_res1 (void)
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);
o_buf[2 * i + 0], o_buf[2 * i + 1], f, o_buf[2 * i + 0] - f);
}
sum10k = 0;
@ -206,7 +206,7 @@ test_res3 (void)
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);
functable_window_std (NULL, t->scale2 * x);
f2 = functable_eval (t, x);
fprintf (out, "%d %g %g %g\n", i, f1, f2, f2 - f1);
}
@ -224,7 +224,7 @@ sinc_poly (double x)
return 1 - x2 * INV3FAC + x2 * x2 * INV5FAC - x2 * x2 * x2 * INV7FAC;
/*+ x2 * x2 * x2 * x2 * INV9FAC */
/*- x2 * x2 * x2 * x2 * x2 * INV11FAC; */
/*- x2 * x2 * x2 * x2 * x2 * INV11FAC; */
}
void

View file

@ -35,175 +35,175 @@ gst_riff_create_video_caps (guint32 codec_fcc,
switch (codec_fcc) {
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'):
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);
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'):
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'):
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'):
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'):
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'):
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'):
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'):
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'):
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'):
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'):
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'):
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'):
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'):
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'):
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'):
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);
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'):
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'):
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'):
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'):
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;
}
@ -213,17 +213,17 @@ gst_riff_create_video_caps (guint32 codec_fcc,
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;
@ -236,75 +236,75 @@ gst_riff_create_audio_caps (guint16 codec_id,
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);
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);
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:
@ -314,12 +314,12 @@ gst_riff_create_audio_caps (guint16 codec_id,
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;
@ -336,13 +336,13 @@ gst_riff_create_iavs_caps (guint32 codec_fcc,
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);
"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;
}

View file

@ -61,8 +61,8 @@ gst_riff_read_get_type (void)
};
gst_riff_read_type =
g_type_register_static (GST_TYPE_ELEMENT, "GstRiffRead",
&gst_riff_read_info, 0);
g_type_register_static (GST_TYPE_ELEMENT, "GstRiffRead",
&gst_riff_read_info, 0);
}
return gst_riff_read_type;
@ -94,16 +94,16 @@ gst_riff_read_change_state (GstElement * 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:
@ -165,7 +165,7 @@ gst_riff_peek_head (GstRiffRead * riff,
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;
@ -257,7 +257,7 @@ gst_riff_read_seek (GstRiffRead * riff, guint64 offset)
} 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;
}
}
@ -341,7 +341,7 @@ gst_riff_read_skip (GstRiffRead * riff)
/* 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);
@ -407,7 +407,7 @@ gst_riff_read_strh (GstRiffRead * riff, gst_riff_strh ** header)
}
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;
}
@ -474,7 +474,7 @@ gst_riff_read_strf_vids (GstRiffRead * riff, gst_riff_strf_vids ** header)
}
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;
}
@ -498,7 +498,7 @@ gst_riff_read_strf_vids (GstRiffRead * riff, gst_riff_strf_vids ** header)
/* 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);
}
@ -541,7 +541,7 @@ gst_riff_read_strf_auds (GstRiffRead * riff, gst_riff_strf_auds ** header)
}
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;
}
@ -564,7 +564,7 @@ gst_riff_read_strf_auds (GstRiffRead * riff, gst_riff_strf_auds ** header)
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);
@ -590,7 +590,7 @@ gst_riff_read_strf_iavs (GstRiffRead * riff, gst_riff_strf_iavs ** header)
}
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;
}
@ -694,102 +694,103 @@ gst_riff_read_info (GstRiffRead * riff)
/* 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);
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);
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 {
@ -804,10 +805,10 @@ gst_riff_read_info (GstRiffRead * riff)
/* let the world know about this wonderful thing */
for (padlist = gst_element_get_pad_list (element);
padlist != NULL; padlist = padlist->next) {
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_ref (event);
gst_pad_push (GST_PAD (padlist->data), GST_DATA (event));
}
}
gst_event_unref (event);

View file

@ -60,9 +60,9 @@ gst_tuner_get_type (void)
};
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;
@ -75,32 +75,32 @@ gst_tuner_class_init (GstTunerClass * klass)
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;
}
@ -262,7 +262,7 @@ gst_tuner_set_frequency (GstTuner * tuner,
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);
@ -286,7 +286,7 @@ 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);
@ -315,7 +315,7 @@ 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);

View file

@ -60,8 +60,8 @@ gst_tuner_channel_get_type (void)
};
gst_tuner_channel_type =
g_type_register_static (G_TYPE_OBJECT,
"GstTunerChannel", &tuner_channel_info, 0);
g_type_register_static (G_TYPE_OBJECT,
"GstTunerChannel", &tuner_channel_info, 0);
}
return gst_tuner_channel_type;
@ -78,13 +78,13 @@ gst_tuner_channel_class_init (GstTunerChannelClass * klass)
g_signal_new ("frequency-changed", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstTunerChannelClass,
frequency_changed),
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),
signal_changed),
NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
object_klass->dispose = gst_tuner_channel_dispose;

View file

@ -59,8 +59,8 @@ gst_tuner_norm_get_type (void)
};
gst_tuner_norm_type =
g_type_register_static (G_TYPE_OBJECT,
"GstTunerNorm", &tuner_norm_info, 0);
g_type_register_static (G_TYPE_OBJECT,
"GstTunerNorm", &tuner_norm_info, 0);
}
return gst_tuner_norm_type;

View file

@ -83,7 +83,7 @@ gst_videosink_get_type (void)
};
videosink_type = g_type_register_static (GST_TYPE_ELEMENT,
"GstVideoSink", &videosink_info, 0);
"GstVideoSink", &videosink_info, 0);
}
return videosink_type;

View file

@ -37,14 +37,14 @@ gst_video_frame_rate (GstPad * pad)
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)) {
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.;
}
@ -69,7 +69,7 @@ gst_video_get_size (GstPad * pad, gint * width, gint * height)
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;
}
@ -79,7 +79,7 @@ gst_video_get_size (GstPad * pad, gint * width, gint * height)
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;
}

View file

@ -55,9 +55,9 @@ gst_x_overlay_get_type (void)
};
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;
@ -76,16 +76,16 @@ gst_x_overlay_base_init (gpointer g_class)
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);
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);
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;
}
@ -155,7 +155,7 @@ gst_x_overlay_get_desired_size (GstXOverlay * overlay, guint * width,
/* 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);
height ? height : &height_tmp);
} else {
if (width)
*width = 0;

View file

@ -57,8 +57,8 @@ gst_x_window_listener_get_type (void)
};
x_window_listener_type =
g_type_register_static (G_TYPE_OBJECT,
"GstXWindowListener", &x_window_listener_info, 0);
g_type_register_static (G_TYPE_OBJECT,
"GstXWindowListener", &x_window_listener_info, 0);
}
return x_window_listener_type;
@ -183,7 +183,7 @@ gst_xwin_refresh (gpointer data)
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) {
@ -307,17 +307,17 @@ gst_xwin_window (GstXWindowListener * xwin)
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;
@ -331,9 +331,9 @@ gst_xwin_window (GstXWindowListener * xwin)
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;
@ -355,7 +355,7 @@ gst_xwin_configure (GstXWindowListener * xwin)
* 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);
@ -473,89 +473,89 @@ gst_xwin_thread (gpointer data)
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 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 UnmapNotify:
xwin->ov_map = FALSE;
xwin->ov_conf = TRUE;
gst_xwin_configure (xwin);
break;
case ConfigureNotify:
gst_xwin_resize (xwin);
break;
case ConfigureNotify:
gst_xwin_resize (xwin);
break;
default:
/* nothing */
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 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;
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;
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;
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;
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;
case ConfigureNotify:
if (!xwin->ov_refresh) {
gst_xwin_resize (xwin);
}
break;
default:
/* nothing */
break;
default:
/* nothing */
break;
}
}
}

View file

@ -100,7 +100,7 @@ GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/ac3, "
"channels = (int) [ 1, 6 ], " "rate = (int) [ 32000, 48000 ]")
"channels = (int) [ 1, 6 ], " "rate = (int) [ 32000, 48000 ]")
);
static GstStaticPadTemplate gst_ac3parse_sink_template =
@ -142,9 +142,10 @@ ac3parse_get_type (void)
0,
(GInstanceInitFunc) gst_ac3parse_init,
};
ac3parse_type =
g_type_register_static (GST_TYPE_ELEMENT, "GstAc3Parse", &ac3parse_info,
0);
g_type_register_static (GST_TYPE_ELEMENT, "GstAc3Parse", &ac3parse_info,
0);
}
return ac3parse_type;
}
@ -166,7 +167,7 @@ gst_ac3parse_class_init (gpointer g_class)
gst_static_pad_template_get (&gst_ac3parse_sink_template));
gst_element_class_set_details (gstelement_class, &ac3parse_details);
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);
@ -250,7 +251,7 @@ gst_ac3parse_chain (GstPad * pad, GstData * _data)
skipped++;
if (skipped) {
fprintf (stderr, "ac3parse: **** now at %ld skipped %d bytes (FIXME?)\n",
offset, skipped);
offset, skipped);
}
/* construct the header word */
header = GUINT16_TO_BE (*((guint16 *) (data + offset)));
@ -263,99 +264,99 @@ gst_ac3parse_chain (GstPad * pad, GstData * _data)
/* get the bits we're interested in */
rate = (data[offset + 4] >> 6) & 0x3;
switch (rate) {
case 0x0: /* 00b */
sample_rate = 48000;
break;
case 0x1: /* 01b */
sample_rate = 44100;
break;
case 0x2: /* 10b */
sample_rate = 32000;
break;
case 0x3: /* 11b */
default:
/* reserved. if this happens, we're screwed */
g_assert (0);
break;
case 0x0: /* 00b */
sample_rate = 48000;
break;
case 0x1: /* 01b */
sample_rate = 44100;
break;
case 0x2: /* 10b */
sample_rate = 32000;
break;
case 0x3: /* 11b */
default:
/* reserved. if this happens, we're screwed */
g_assert (0);
break;
}
fsize = data[offset + 4] & 0x3f;
/* calculate the bpf of the frame */
bpf = frmsizecod_tbl[fsize].frm_size[rate] * 2;
/* calculate number of channels */
channeldata = data[offset + 6]; /* skip bsid/bsmod */
channeldata = data[offset + 6]; /* skip bsid/bsmod */
acmod = (channeldata >> 5) & 0x7;
switch (acmod) {
case 0x1: /* 001b = 1 channel */
channels = 1;
break;
case 0x0: /* 000b = 2 independent channels */
case 0x2: /* 010b = 2x front (stereo) */
channels = 2;
break;
case 0x3: /* 011b = 3 front */
case 0x4: /* 100b = 2 front, 1 rear */
channels = 3;
break;
case 0x5: /* 101b = 3 front, 1 rear */
case 0x6: /* 110b = 2 front, 2 rear */
channels = 4;
break;
case 0x7: /* 111b = 3 front, 2 rear */
channels = 5;
break;
default:
/* whaaaaaaaaaaaaaa!!!!!!!!!!! */
g_assert (0);
case 0x1: /* 001b = 1 channel */
channels = 1;
break;
case 0x0: /* 000b = 2 independent channels */
case 0x2: /* 010b = 2x front (stereo) */
channels = 2;
break;
case 0x3: /* 011b = 3 front */
case 0x4: /* 100b = 2 front, 1 rear */
channels = 3;
break;
case 0x5: /* 101b = 3 front, 1 rear */
case 0x6: /* 110b = 2 front, 2 rear */
channels = 4;
break;
case 0x7: /* 111b = 3 front, 2 rear */
channels = 5;
break;
default:
/* whaaaaaaaaaaaaaa!!!!!!!!!!! */
g_assert (0);
}
/* fetch LFE bit (subwoofer) */
mask = 0x10;
if (acmod & 0x1 && acmod != 0x1) /* 3 front speakers? */
mask >>= 2;
if (acmod & 0x4) /* surround channel? */
mask >>= 2;
if (acmod == 0x2) /* 2/0 mode? */
mask >>= 2;
if (channeldata & mask) /* LFE: do we have a subwoofer channel? */
channels++;
if (acmod & 0x1 && acmod != 0x1) /* 3 front speakers? */
mask >>= 2;
if (acmod & 0x4) /* surround channel? */
mask >>= 2;
if (acmod == 0x2) /* 2/0 mode? */
mask >>= 2;
if (channeldata & mask) /* LFE: do we have a subwoofer channel? */
channels++;
/* if we don't have the whole frame... */
if ((size - offset) < bpf) {
GST_DEBUG ("ac3parse: partial buffer needed %ld < %d ", size - offset,
bpf);
break;
GST_DEBUG ("ac3parse: partial buffer needed %ld < %d ", size - offset,
bpf);
break;
} else {
gboolean need_capsnego = FALSE;
gboolean need_capsnego = FALSE;
outbuf = gst_buffer_create_sub (ac3parse->partialbuf, offset, bpf);
outbuf = gst_buffer_create_sub (ac3parse->partialbuf, offset, bpf);
/* make sure our properties still match */
if (channels > 0 && ac3parse->channels != channels) {
ac3parse->channels = channels;
need_capsnego = TRUE;
}
if (sample_rate > 0 && ac3parse->sample_rate != sample_rate) {
ac3parse->sample_rate = sample_rate;
need_capsnego = TRUE;
}
if (need_capsnego) {
GstCaps *newcaps;
/* make sure our properties still match */
if (channels > 0 && ac3parse->channels != channels) {
ac3parse->channels = channels;
need_capsnego = TRUE;
}
if (sample_rate > 0 && ac3parse->sample_rate != sample_rate) {
ac3parse->sample_rate = sample_rate;
need_capsnego = TRUE;
}
if (need_capsnego) {
GstCaps *newcaps;
newcaps = gst_caps_new_simple ("audio/x-ac3",
"channels", G_TYPE_INT, channels,
"rate", G_TYPE_INT, sample_rate, NULL);
gst_pad_set_explicit_caps (ac3parse->srcpad, newcaps);
}
newcaps = gst_caps_new_simple ("audio/x-ac3",
"channels", G_TYPE_INT, channels,
"rate", G_TYPE_INT, sample_rate, NULL);
gst_pad_set_explicit_caps (ac3parse->srcpad, newcaps);
}
offset += bpf;
if (ac3parse->skip == 0 && GST_PAD_IS_LINKED (ac3parse->srcpad)) {
GST_DEBUG ("ac3parse: pushing buffer of %d bytes",
GST_BUFFER_SIZE (outbuf));
gst_pad_push (ac3parse->srcpad, GST_DATA (outbuf));
} else {
GST_DEBUG ("ac3parse: skipping buffer of %d bytes",
GST_BUFFER_SIZE (outbuf));
gst_buffer_unref (outbuf);
ac3parse->skip--;
}
offset += bpf;
if (ac3parse->skip == 0 && GST_PAD_IS_LINKED (ac3parse->srcpad)) {
GST_DEBUG ("ac3parse: pushing buffer of %d bytes",
GST_BUFFER_SIZE (outbuf));
gst_pad_push (ac3parse->srcpad, GST_DATA (outbuf));
} else {
GST_DEBUG ("ac3parse: skipping buffer of %d bytes",
GST_BUFFER_SIZE (outbuf));
gst_buffer_unref (outbuf);
ac3parse->skip--;
}
}
} else {
offset++;
@ -368,7 +369,7 @@ gst_ac3parse_chain (GstPad * pad, GstData * _data)
gint remainder = (size - offset);
GST_DEBUG ("ac3parse: partial buffer needed %d for trailing bytes",
remainder);
remainder);
outbuf = gst_buffer_create_sub (ac3parse->partialbuf, offset, remainder);
gst_buffer_unref (ac3parse->partialbuf);
@ -436,7 +437,7 @@ static gboolean
plugin_init (GstPlugin * plugin)
{
if (!gst_element_register (plugin, "ac3parse", GST_RANK_SECONDARY,
GST_TYPE_AC3PARSE)) {
GST_TYPE_AC3PARSE)) {
return FALSE;
}

View file

@ -23,7 +23,7 @@
#endif
#include <gst/riff/riff-ids.h>
#include "gstasfdemux.h"
#include "gstasfmux.h" /* for the type registering */
#include "gstasfmux.h" /* for the type registering */
#include "asfheaders.h"
/* elementfactory information */
@ -98,9 +98,10 @@ asf_demux_get_type (void)
0,
(GInstanceInitFunc) gst_asf_demux_init,
};
asf_demux_type =
g_type_register_static (GST_TYPE_ELEMENT, "GstASFDemux",
&asf_demux_info, 0);
g_type_register_static (GST_TYPE_ELEMENT, "GstASFDemux",
&asf_demux_info, 0);
}
return asf_demux_type;
}
@ -123,7 +124,7 @@ gst_asf_demux_base_init (gpointer g_class)
GST_MAKE_FOURCC ('M', 'P', '4', '3'),
GST_MAKE_FOURCC ('D', 'I', 'V', '3'),
GST_MAKE_FOURCC ('D', 'X', '5', '0'),
0 /* end */
0 /* end */
};
gint aud_list[] = {
GST_RIFF_WAVE_FORMAT_MPEGL3,
@ -134,7 +135,7 @@ gst_asf_demux_base_init (gpointer g_class)
GST_RIFF_WAVE_FORMAT_DIVX_WMAV1,
GST_RIFF_WAVE_FORMAT_DIVX_WMAV2,
GST_RIFF_WAVE_FORMAT_WMAV9,
-1 /* end */
-1 /* end */
};
audcaps = gst_caps_new_empty ();
@ -223,8 +224,8 @@ gst_asf_demux_send_event (GstElement * element, GstEvent * event)
* failed on this pad */
gst_event_ref (event);
if (gst_asf_demux_handle_src_event (pad, event)) {
gst_event_unref (event);
return TRUE;
gst_event_unref (event);
return TRUE;
}
}
@ -398,7 +399,7 @@ _read_obj_data (GstASFDemux * asf_demux, asf_obj_data * object)
return (_read_guid (asf_demux, &object->file_id) &&
_read_uint64 (asf_demux, &object->packets) &&
_read_uint8 (asf_demux, &object->unknown1) &&
/*_read_uint8 (asf_demux, &object->unknown2) && */
/*_read_uint8 (asf_demux, &object->unknown2) && */
_read_uint8 (asf_demux, &object->correction));
}
@ -596,7 +597,7 @@ gst_asf_demux_process_segment (GstASFDemux * asf_demux,
/* It's uncompressed with replic data */
if (replic_size < 8) {
GST_ELEMENT_ERROR (asf_demux, STREAM, DEMUX, (NULL),
("The payload has replicated data but the size is less than 8"));
("The payload has replicated data but the size is less than 8"));
return FALSE;
}
_read_replicated_data (asf_demux, &replicated_data_header);
@ -646,9 +647,9 @@ gst_asf_demux_process_segment (GstASFDemux * asf_demux,
segment_info.segment_size = segment_info.chunk_size;
if (segment_info.chunk_size > packet_info->size_left) {
GST_ELEMENT_ERROR (asf_demux, STREAM, DEMUX, (NULL),
("Payload chunk overruns packet size."));
return FALSE;
GST_ELEMENT_ERROR (asf_demux, STREAM, DEMUX, (NULL),
("Payload chunk overruns packet size."));
return FALSE;
}
gst_asf_demux_process_chunk (asf_demux, packet_info, &segment_info);
@ -712,13 +713,13 @@ gst_asf_demux_process_data (GstASFDemux * asf_demux, guint64 * obj_size)
packet_info.multiple = flags & 0x01;
sequence = _read_var_length (asf_demux, (flags >> 1) & 0x03, &rsize);
packet_info.padsize =
_read_var_length (asf_demux, (flags >> 3) & 0x03, &rsize);
_read_var_length (asf_demux, (flags >> 3) & 0x03, &rsize);
packet_length = _read_var_length (asf_demux, (flags >> 5) & 0x03, &rsize);
if (packet_length == 0)
packet_length = asf_demux->packet_size;
GST_DEBUG ("Multiple = %u, Sequence = %u, Padsize = %u, Packet length = %u",
packet_info.multiple, sequence, packet_info.padsize, packet_length);
packet_info.multiple, sequence, packet_info.padsize, packet_length);
/* Read the property flags */
packet_info.replicsizetype = property & 0x03;
@ -749,7 +750,7 @@ gst_asf_demux_process_data (GstASFDemux * asf_demux, guint64 * obj_size)
for (segment = 0; segment < segments; segment++) {
if (!gst_asf_demux_process_segment (asf_demux, &packet_info))
return FALSE;
return FALSE;
}
/* Skip the padding */
@ -798,80 +799,80 @@ gst_asf_demux_process_stream (GstASFDemux * asf_demux, guint64 * obj_size)
size = audio_object.size;
GST_INFO ("Object is an audio stream with %u bytes of additional data.",
size);
size);
if (!gst_asf_demux_add_audio_stream (asf_demux, &audio_object, id))
return FALSE;
return FALSE;
switch (correction) {
case ASF_CORRECTION_ON:
GST_INFO ("Using error correction");
case ASF_CORRECTION_ON:
GST_INFO ("Using error correction");
_read_stream_correction (asf_demux, &correction_object);
asf_demux->span = correction_object.span;
_read_stream_correction (asf_demux, &correction_object);
asf_demux->span = correction_object.span;
GST_DEBUG ("Descrambling: ps:%d cs:%d ds:%d s:%d sd:%d",
correction_object.packet_size, correction_object.chunk_size,
correction_object.data_size, (guint) correction_object.span,
(guint) correction_object.silence_data);
GST_DEBUG ("Descrambling: ps:%d cs:%d ds:%d s:%d sd:%d",
correction_object.packet_size, correction_object.chunk_size,
correction_object.data_size, (guint) correction_object.span,
(guint) correction_object.silence_data);
if (asf_demux->span > 1) {
if (!correction_object.chunk_size
|| ((correction_object.packet_size /
correction_object.chunk_size) <= 1))
/* Disable descrambling */
asf_demux->span = 0;
} else {
/* Descambling is enabled */
asf_demux->ds_packet_size = correction_object.packet_size;
asf_demux->ds_chunk_size = correction_object.chunk_size;
}
if (asf_demux->span > 1) {
if (!correction_object.chunk_size
|| ((correction_object.packet_size /
correction_object.chunk_size) <= 1))
/* Disable descrambling */
asf_demux->span = 0;
} else {
/* Descambling is enabled */
asf_demux->ds_packet_size = correction_object.packet_size;
asf_demux->ds_chunk_size = correction_object.chunk_size;
}
/* Now skip the rest of the silence data */
if (correction_object.data_size > 1)
gst_bytestream_flush (asf_demux->bs,
correction_object.data_size - 1);
/* Now skip the rest of the silence data */
if (correction_object.data_size > 1)
gst_bytestream_flush (asf_demux->bs,
correction_object.data_size - 1);
break;
case ASF_CORRECTION_OFF:
GST_INFO ("Error correction off");
gst_bytestream_flush (asf_demux->bs, object.stream_specific_size);
break;
default:
GST_ELEMENT_ERROR (asf_demux, STREAM, DEMUX, (NULL),
("Audio stream using unknown error correction"));
return FALSE;
break;
case ASF_CORRECTION_OFF:
GST_INFO ("Error correction off");
gst_bytestream_flush (asf_demux->bs, object.stream_specific_size);
break;
default:
GST_ELEMENT_ERROR (asf_demux, STREAM, DEMUX, (NULL),
("Audio stream using unknown error correction"));
return FALSE;
}
break;
case ASF_STREAM_VIDEO:
_read_stream_video (asf_demux, &video_object);
size = video_object.size - 40; /* Byte order gets offset by single byte */
size = video_object.size - 40; /* Byte order gets offset by single byte */
GST_INFO ("Object is a video stream with %u bytes of additional data.",
size);
size);
_read_stream_video_format (asf_demux, &video_format_object);
if (!gst_asf_demux_add_video_stream (asf_demux, &video_format_object, id))
return FALSE;
return FALSE;
/* Read any additional information */
if (size) {
got_bytes = gst_bytestream_read (asf_demux->bs, &buf, size);
/* There is additional data */
while (got_bytes < size) {
guint32 remaining;
GstEvent *event;
got_bytes = gst_bytestream_read (asf_demux->bs, &buf, size);
/* There is additional data */
while (got_bytes < size) {
guint32 remaining;
GstEvent *event;
gst_bytestream_get_status (asf_demux->bs, &remaining, &event);
gst_event_unref (event);
gst_bytestream_get_status (asf_demux->bs, &remaining, &event);
gst_event_unref (event);
got_bytes = gst_bytestream_read (asf_demux->bs, &buf, size);
}
got_bytes = gst_bytestream_read (asf_demux->bs, &buf, size);
}
}
break;
default:
GST_ELEMENT_ERROR (asf_demux, STREAM, WRONG_TYPE, (NULL),
("unknown asf stream (id %08x)", (guint) stream_id));
("unknown asf stream (id %08x)", (guint) stream_id));
return FALSE;
}
@ -906,8 +907,8 @@ _read_object_header (GstASFDemux * asf_demux, guint32 * obj_id,
if (*obj_id == ASF_OBJ_UNDEFINED) {
GST_WARNING_OBJECT (asf_demux,
"Could not identify object (0x%08x/0x%08x/0x%08x/0x%08x) with size=%llu",
guid.v1, guid.v2, guid.v3, guid.v4, *obj_size);
"Could not identify object (0x%08x/0x%08x/0x%08x/0x%08x) with size=%llu",
guid.v1, guid.v2, guid.v3, guid.v4, *obj_size);
return TRUE;
}
@ -923,9 +924,9 @@ gst_asf_demux_process_object (GstASFDemux * asf_demux)
if (!_read_object_header (asf_demux, &obj_id, &obj_size)) {
GST_DEBUG (" ***** Error reading object at filepos %" G_GUINT64_FORMAT
" (EOS?)\n", /**filepos*/ gst_bytestream_tell (asf_demux->bs));
" (EOS?)\n", /**filepos*/ gst_bytestream_tell (asf_demux->bs));
gst_asf_demux_handle_sink_event (asf_demux, gst_event_new (GST_EVENT_EOS),
0);
0);
return FALSE;
}
@ -1019,8 +1020,8 @@ gst_asf_demux_descramble_segment (GstASFDemux * asf_demux,
col = off % asf_demux->span;
idx = row + col * asf_demux->ds_packet_size / asf_demux->ds_chunk_size;
sub_buffer =
gst_buffer_create_sub (scrambled_buffer, idx * asf_demux->ds_chunk_size,
asf_demux->ds_chunk_size);
gst_buffer_create_sub (scrambled_buffer, idx * asf_demux->ds_chunk_size,
asf_demux->ds_chunk_size);
if (!offset) {
descrambled_buffer = sub_buffer;
} else {
@ -1048,7 +1049,7 @@ gst_asf_demux_process_chunk (GstASFDemux * asf_demux,
GstBuffer *buffer;
if (!(stream =
gst_asf_demux_get_stream (asf_demux, segment_info->stream_number)))
gst_asf_demux_get_stream (asf_demux, segment_info->stream_number)))
return FALSE;
GST_DEBUG ("Processing chunk of size %u (fo = %d)", segment_info->chunk_size,
@ -1060,28 +1061,28 @@ gst_asf_demux_process_chunk (GstASFDemux * asf_demux,
asf_demux->pts = segment_info->frag_timestamp - asf_demux->preroll;
got_bytes = gst_bytestream_peek (bs, &buffer, segment_info->chunk_size);
GST_DEBUG ("BUFFER: Copied stream to buffer (%p - %d)", buffer,
GST_BUFFER_REFCOUNT_VALUE (buffer));
GST_BUFFER_REFCOUNT_VALUE (buffer));
stream->payload = buffer;
} else {
GST_DEBUG
("segment_info->sequence = %d, stream->sequence = %d, segment_info->frag_offset = %d, stream->frag_offset = %d",
segment_info->sequence, stream->sequence, segment_info->frag_offset,
stream->frag_offset);
("segment_info->sequence = %d, stream->sequence = %d, segment_info->frag_offset = %d, stream->frag_offset = %d",
segment_info->sequence, stream->sequence, segment_info->frag_offset,
stream->frag_offset);
if (segment_info->sequence == stream->sequence
&& segment_info->frag_offset == stream->frag_offset) {
&& segment_info->frag_offset == stream->frag_offset) {
GstBuffer *new_buffer;
/* continuing packet */
GST_INFO ("A continuation packet");
got_bytes = gst_bytestream_peek (bs, &buffer, segment_info->chunk_size);
GST_DEBUG ("Copied stream to buffer (%p - %d)", buffer,
GST_BUFFER_REFCOUNT_VALUE (buffer));
GST_BUFFER_REFCOUNT_VALUE (buffer));
new_buffer = gst_buffer_merge (stream->payload, buffer);
GST_DEBUG
("BUFFER: Merged new_buffer (%p - %d) from stream->payload(%p - %d) and buffer (%p - %d)",
new_buffer, GST_BUFFER_REFCOUNT_VALUE (new_buffer), stream->payload,
GST_BUFFER_REFCOUNT_VALUE (stream->payload), buffer,
GST_BUFFER_REFCOUNT_VALUE (buffer));
("BUFFER: Merged new_buffer (%p - %d) from stream->payload(%p - %d) and buffer (%p - %d)",
new_buffer, GST_BUFFER_REFCOUNT_VALUE (new_buffer), stream->payload,
GST_BUFFER_REFCOUNT_VALUE (stream->payload), buffer,
GST_BUFFER_REFCOUNT_VALUE (buffer));
gst_buffer_unref (stream->payload);
gst_buffer_unref (buffer);
stream->payload = new_buffer;
@ -1089,15 +1090,15 @@ gst_asf_demux_process_chunk (GstASFDemux * asf_demux,
/* cannot continue current packet: free it */
stream->frag_offset = 0;
if (segment_info->frag_offset != 0) {
/* cannot create new packet */
GST_DEBUG ("BUFFER: Freeing stream->payload (%p)", stream->payload);
gst_buffer_unref (stream->payload);
gst_bytestream_flush (bs, segment_info->chunk_size);
packet_info->size_left -= segment_info->chunk_size;
return TRUE;
/* cannot create new packet */
GST_DEBUG ("BUFFER: Freeing stream->payload (%p)", stream->payload);
gst_buffer_unref (stream->payload);
gst_bytestream_flush (bs, segment_info->chunk_size);
packet_info->size_left -= segment_info->chunk_size;
return TRUE;
} else {
/* create new packet */
stream->sequence = segment_info->sequence;
/* create new packet */
stream->sequence = segment_info->sequence;
}
}
}
@ -1119,14 +1120,14 @@ gst_asf_demux_process_chunk (GstASFDemux * asf_demux,
if (GST_PAD_IS_USABLE (stream->pad)) {
GST_DEBUG ("New buffer is at: %p size: %u",
GST_BUFFER_DATA (stream->payload), GST_BUFFER_SIZE (stream->payload));
GST_BUFFER_DATA (stream->payload), GST_BUFFER_SIZE (stream->payload));
GST_BUFFER_TIMESTAMP (stream->payload) =
(GST_SECOND / 1000) * asf_demux->pts;
(GST_SECOND / 1000) * asf_demux->pts;
/*!!! Should handle flush events here? */
GST_DEBUG ("Sending strem %d of size %d", stream->id,
segment_info->chunk_size);
segment_info->chunk_size);
GST_INFO ("Pushing pad");
gst_pad_push (stream->pad, GST_DATA (stream->payload));
@ -1163,8 +1164,8 @@ gst_asf_demux_handle_sink_event (GstASFDemux * asf_demux,
gint n;
for (n = 0; n < asf_demux->num_streams; n++) {
stream = &asf_demux->stream[n];
gst_pad_push (stream->pad, GST_DATA (gst_event_ref (event)));
stream = &asf_demux->stream[n];
gst_pad_push (stream->pad, GST_DATA (gst_event_ref (event)));
}
gst_event_unref (event);
gst_bytestream_flush (asf_demux->bs, remaining);
@ -1178,17 +1179,17 @@ gst_asf_demux_handle_sink_event (GstASFDemux * asf_demux,
GstEvent *discont;
for (i = 0; i < asf_demux->num_streams; i++) {
asf_stream_context *stream = &asf_demux->stream[i];
asf_stream_context *stream = &asf_demux->stream[i];
if (GST_PAD_IS_USABLE (stream->pad)) {
GST_DEBUG ("sending discont on %d %" G_GINT64_FORMAT " + %"
G_GINT64_FORMAT " = %" G_GINT64_FORMAT, i, asf_demux->last_seek,
stream->delay, asf_demux->last_seek + stream->delay);
discont =
gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME,
asf_demux->last_seek + stream->delay, NULL);
gst_pad_push (stream->pad, GST_DATA (discont));
}
if (GST_PAD_IS_USABLE (stream->pad)) {
GST_DEBUG ("sending discont on %d %" G_GINT64_FORMAT " + %"
G_GINT64_FORMAT " = %" G_GINT64_FORMAT, i, asf_demux->last_seek,
stream->delay, asf_demux->last_seek + stream->delay);
discont =
gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME,
asf_demux->last_seek + stream->delay, NULL);
gst_pad_push (stream->pad, GST_DATA (discont));
}
}
break;
}
@ -1230,6 +1231,7 @@ gst_asf_demux_get_src_formats (GstPad * pad)
GST_FORMAT_TIME,
0
};
return formats;
}
@ -1257,26 +1259,26 @@ gst_asf_demux_handle_src_query (GstPad * pad,
switch (type) {
case GST_QUERY_TOTAL:
switch (*format) {
case GST_FORMAT_DEFAULT:
*format = GST_FORMAT_TIME;
/* fall through */
case GST_FORMAT_TIME:
*value = (GST_SECOND / 1000) * asf_demux->pts;
break;
default:
res = FALSE;
case GST_FORMAT_DEFAULT:
*format = GST_FORMAT_TIME;
/* fall through */
case GST_FORMAT_TIME:
*value = (GST_SECOND / 1000) * asf_demux->pts;
break;
default:
res = FALSE;
}
break;
case GST_QUERY_POSITION:
switch (*format) {
case GST_FORMAT_DEFAULT:
*format = GST_FORMAT_TIME;
/* fall through */
case GST_FORMAT_TIME:
*value = (GST_SECOND / 1000) * asf_demux->timestamp;
break;
default:
res = FALSE;
case GST_FORMAT_DEFAULT:
*format = GST_FORMAT_TIME;
/* fall through */
case GST_FORMAT_TIME:
*value = (GST_SECOND / 1000) * asf_demux->timestamp;
break;
default:
res = FALSE;
}
default:
res = FALSE;
@ -1317,10 +1319,10 @@ gst_asf_demux_change_state (GstElement * element)
case GST_STATE_PAUSED_TO_READY:
gst_bytestream_destroy (asf_demux->bs);
for (i = 0; i < GST_ASF_DEMUX_NUM_VIDEO_PADS; i++) {
asf_demux->video_PTS[i] = 0;
asf_demux->video_PTS[i] = 0;
}
for (i = 0; i < GST_ASF_DEMUX_NUM_AUDIO_PADS; i++) {
asf_demux->audio_PTS[i] = 0;
asf_demux->audio_PTS[i] = 0;
}
break;
case GST_STATE_READY_TO_NULL:
@ -1343,8 +1345,8 @@ gst_asf_demux_identify_guid (GstASFDemux * asf_demux,
i = 0;
while (guids[i].obj_id != ASF_OBJ_UNDEFINED) {
if (guids[i].guid.v1 == guid->v1 &&
guids[i].guid.v2 == guid->v2 &&
guids[i].guid.v3 == guid->v3 && guids[i].guid.v4 == guid->v4) {
guids[i].guid.v2 == guid->v2 &&
guids[i].guid.v3 == guid->v3 && guids[i].guid.v4 == guid->v4) {
return guids[i].obj_id;
}
i++;
@ -1366,106 +1368,106 @@ gst_asf_demux_audio_caps (guint16 codec_id,
flags2 = 0;
switch (codec_id) {
case GST_RIFF_WAVE_FORMAT_MPEGL3: /* mp3 */
case GST_RIFF_WAVE_FORMAT_MPEGL3: /* mp3 */
caps = gst_caps_from_string ("audio/mpeg, mpegversion = (int) 1, "
"layer = (int) 3");
"layer = (int) 3");
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_from_string ("audio/mpeg, mpegversion = (int) 1, "
"layer = (int) 2");
"layer = (int) 2");
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 */ {
caps = gst_caps_from_string ("audio/x-raw-int, "
"endianness = (int) LITTLE_ENDIAN,"
"signed = (boolean) { true, false }, "
"width = (int) { 8, 16 }, " "depth = (int) { 8, 16 }");
"endianness = (int) LITTLE_ENDIAN,"
"signed = (boolean) { true, false }, "
"width = (int) { 8, 16 }, " "depth = (int) { 8, 16 }");
if (audio != NULL) {
gint ba = audio->block_align;
gint ch = audio->channels;
gint ws = audio->word_size;
gint ba = audio->block_align;
gint ch = audio->channels;
gint ws = audio->word_size;
gst_caps_set_simple (caps,
"width", G_TYPE_INT, (int) (ba * 8 / ch),
"depth", G_TYPE_INT, ws, "signed", G_TYPE_BOOLEAN, (ws != 8), NULL);
gst_caps_set_simple (caps,
"width", G_TYPE_INT, (int) (ba * 8 / ch),
"depth", G_TYPE_INT, ws, "signed", G_TYPE_BOOLEAN, (ws != 8), NULL);
}
if (codec_name)
*codec_name = g_strdup ("PCM WAV");
*codec_name = g_strdup ("PCM WAV");
}
break;
case GST_RIFF_WAVE_FORMAT_VORBIS1: /* vorbis mode 1 */
case GST_RIFF_WAVE_FORMAT_VORBIS2: /* vorbis mode 2 */
case GST_RIFF_WAVE_FORMAT_VORBIS3: /* vorbis mode 3 */
case GST_RIFF_WAVE_FORMAT_VORBIS1PLUS: /* vorbis mode 1+ */
case GST_RIFF_WAVE_FORMAT_VORBIS2PLUS: /* vorbis mode 2+ */
case GST_RIFF_WAVE_FORMAT_VORBIS3PLUS: /* vorbis mode 3+ */
case GST_RIFF_WAVE_FORMAT_VORBIS1: /* vorbis mode 1 */
case GST_RIFF_WAVE_FORMAT_VORBIS2: /* vorbis mode 2 */
case GST_RIFF_WAVE_FORMAT_VORBIS3: /* vorbis mode 3 */
case GST_RIFF_WAVE_FORMAT_VORBIS1PLUS: /* vorbis mode 1+ */
case GST_RIFF_WAVE_FORMAT_VORBIS2PLUS: /* vorbis mode 2+ */
case GST_RIFF_WAVE_FORMAT_VORBIS3PLUS: /* vorbis mode 3+ */
caps = gst_caps_from_string ("audio/x-vorbis");
if (codec_name)
*codec_name = g_strdup ("Vorbis");
*codec_name = g_strdup ("Vorbis");
break;
case GST_RIFF_WAVE_FORMAT_A52:
caps = gst_caps_from_string ("audio/x-ac3");
if (codec_name)
*codec_name = g_strdup ("AC3");
*codec_name = g_strdup ("AC3");
break;
case GST_RIFF_WAVE_FORMAT_DIVX_WMAV1:
/* get flags1 and flags2 ripped from ffmpeg (wmadec.c) */
if (audio && audio->size >= 4) {
flags1 = extradata[0] | (extradata[1] << 8);
flags2 = extradata[2] | (extradata[3] << 8);
flags1 = extradata[0] | (extradata[1] << 8);
flags2 = extradata[2] | (extradata[3] << 8);
}
caps = gst_caps_from_string ("audio/x-wma, "
"wmaversion = (int) 1, "
"flags1 = (int) [ MIN, MAX ], "
"flags2 = (int) [ MIN, MAX ], "
"block_align = (int) [ 0, MAX ], " "bitrate = (int) [ 0, MAX ]");
"wmaversion = (int) 1, "
"flags1 = (int) [ MIN, MAX ], "
"flags2 = (int) [ MIN, MAX ], "
"block_align = (int) [ 0, MAX ], " "bitrate = (int) [ 0, MAX ]");
if (audio != NULL) {
gst_caps_set_simple (caps,
"flags1", G_TYPE_INT, flags1,
"flags2", G_TYPE_INT, flags2,
"block_align", G_TYPE_INT, audio->block_align,
"bitrate", G_TYPE_INT, audio->byte_rate * 8, NULL);
gst_caps_set_simple (caps,
"flags1", G_TYPE_INT, flags1,
"flags2", G_TYPE_INT, flags2,
"block_align", G_TYPE_INT, audio->block_align,
"bitrate", G_TYPE_INT, audio->byte_rate * 8, NULL);
}
if (codec_name)
*codec_name = g_strdup ("Microsoft WMA V1");
*codec_name = g_strdup ("Microsoft WMA V1");
break;
case GST_RIFF_WAVE_FORMAT_DIVX_WMAV2:
/* get flags1 and flags2 ripped from ffmpeg (wmadec.c) */
if (audio && audio->size >= 6) {
flags1 = extradata[0] | (extradata[1] << 8) |
(extradata[2] << 16) | (extradata[3] << 24);
flags2 = extradata[4] | (extradata[5] << 8);
flags1 = extradata[0] | (extradata[1] << 8) |
(extradata[2] << 16) | (extradata[3] << 24);
flags2 = extradata[4] | (extradata[5] << 8);
}
caps = gst_caps_from_string ("audio/x-wma, "
"wmaversion = (int) 2, "
"flags1 = (int) [ MIN, MAX ], "
"flags2 = (int) [ MIN, MAX ], "
"block_align = (int) [ 0, MAX ], " "bitrate = (int) [ 0, MAX ]");
"wmaversion = (int) 2, "
"flags1 = (int) [ MIN, MAX ], "
"flags2 = (int) [ MIN, MAX ], "
"block_align = (int) [ 0, MAX ], " "bitrate = (int) [ 0, MAX ]");
if (audio != NULL) {
gst_caps_set_simple (caps,
"flags1", G_TYPE_INT, flags1,
"flags2", G_TYPE_INT, flags2,
"block_align", G_TYPE_INT, audio->block_align,
"bitrate", G_TYPE_INT, audio->byte_rate * 8, NULL);
gst_caps_set_simple (caps,
"flags1", G_TYPE_INT, flags1,
"flags2", G_TYPE_INT, flags2,
"block_align", G_TYPE_INT, audio->block_align,
"bitrate", G_TYPE_INT, audio->byte_rate * 8, NULL);
}
if (codec_name)
*codec_name = g_strdup ("Microsoft WMA V2");
*codec_name = g_strdup ("Microsoft WMA V2");
break;
case GST_RIFF_WAVE_FORMAT_WMAV9:
caps = gst_caps_from_string ("audio/x-wma, " "wmaversion = (int) 9");
if (codec_name)
*codec_name = g_strdup ("Microsoft WMA V9");
*codec_name = g_strdup ("Microsoft WMA V9");
break;
default:
@ -1476,12 +1478,12 @@ gst_asf_demux_audio_caps (guint16 codec_id,
if (audio != NULL) {
gst_caps_set_simple (caps,
"rate", G_TYPE_INT, audio->sample_rate,
"channels", G_TYPE_INT, audio->channels, NULL);
"rate", G_TYPE_INT, audio->sample_rate,
"channels", G_TYPE_INT, audio->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;
@ -1513,14 +1515,14 @@ gst_asf_demux_add_audio_stream (GstASFDemux * asf_demux,
guint8 *extradata;
GST_WARNING_OBJECT (asf_demux,
"asfdemux: Audio header contains %d bytes of surplus data", size_left);
"asfdemux: Audio header contains %d bytes of surplus data", size_left);
gst_bytestream_peek_bytes (asf_demux->bs, &extradata, size_left);
caps = gst_asf_demux_audio_caps (audio->codec_tag, audio, extradata,
&codec_name);
&codec_name);
gst_bytestream_flush (asf_demux->bs, size_left);
} else {
caps = gst_asf_demux_audio_caps (audio->codec_tag, audio, NULL,
&codec_name);
&codec_name);
}
/* Informing about that audio format we just added */
@ -1554,109 +1556,109 @@ gst_asf_demux_video_caps (guint32 codec_fcc,
switch (codec_fcc) {
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");
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'):
caps = gst_caps_new_simple ("video/x-jpeg", NULL);
if (codec_name)
*codec_name = g_strdup ("Motion JPEG");
*codec_name = g_strdup ("Motion JPEG");
case GST_MAKE_FOURCC ('J', 'P', 'E', 'G'):
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");
case GST_MAKE_FOURCC ('P', 'I', 'X', 'L'):
case GST_MAKE_FOURCC ('V', 'I', 'X', 'L'):
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 ('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'):
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'):
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 ('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'):
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'):
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 ('D', 'I', 'V', '3'):
case GST_MAKE_FOURCC ('D', 'I', 'V', '4'):
case GST_MAKE_FOURCC ('D', 'I', 'V', '5'):
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', 'X'):
case GST_MAKE_FOURCC ('d', 'i', 'v', 'x'):
case GST_MAKE_FOURCC ('D', 'X', '5', '0'):
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;
default:
GST_WARNING ("asfdemux: unknown video format " GST_FOURCC_FORMAT
"(0x%08x)", GST_FOURCC_ARGS (codec_fcc), codec_fcc);
"(0x%08x)", GST_FOURCC_ARGS (codec_fcc), codec_fcc);
return NULL;
break;
}
if (video != NULL) {
gst_caps_set_simple (caps,
"width", G_TYPE_INT, video->width,
"height", G_TYPE_INT, video->height,
"framerate", G_TYPE_DOUBLE, (double) 25, NULL);
"width", G_TYPE_INT, video->width,
"height", G_TYPE_INT, video->height,
"framerate", G_TYPE_DOUBLE, (double) 25, NULL);
} else {
gst_caps_set_simple (caps,
"width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
"height", GST_TYPE_INT_RANGE, 1, G_MAXINT,
"framerate", GST_TYPE_DOUBLE_RANGE, 25.0, G_MAXDOUBLE, NULL);
"width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
"height", GST_TYPE_INT_RANGE, 1, G_MAXINT,
"framerate", GST_TYPE_DOUBLE_RANGE, 25.0, G_MAXDOUBLE, NULL);
}
return caps;
@ -1735,9 +1737,9 @@ plugin_init (GstPlugin * plugin)
/* create an elementfactory for the asf_demux element */
if (!gst_element_register (plugin, "asfdemux", GST_RANK_PRIMARY,
GST_TYPE_ASF_DEMUX)
GST_TYPE_ASF_DEMUX)
|| !gst_element_register (plugin, "asfmux", GST_RANK_NONE,
GST_TYPE_ASFMUX))
GST_TYPE_ASFMUX))
return FALSE;
GST_DEBUG_CATEGORY_INIT (asf_debug, "asfdemux", 0, "asf demuxer element");

View file

@ -80,40 +80,40 @@ static GstStaticPadTemplate gst_asfmux_videosink_template =
GST_PAD_SINK,
GST_PAD_REQUEST,
GST_STATIC_CAPS ("video/x-raw-yuv, "
"format = (fourcc) { YUY2, I420 }, "
"width = (int) [ 1, MAX], "
"height = (int) [ 1, MAX]; "
"video/x-jpeg, "
"width = (int) [ 1, MAX], "
"height = (int) [ 1, MAX]; "
"video/x-divx, "
"divxversion = (int) [ 3, 5 ], "
"width = (int) [ 1, MAX], "
"height = (int) [ 1, MAX]; "
"video/x-xvid, "
"width = (int) [ 1, MAX], "
"height = (int) [ 1, MAX]; "
"video/x-3ivx, "
"width = (int) [ 1, MAX], "
"height = (int) [ 1, MAX]; "
"video/x-msmpeg, "
"msmpegversion = (int) [ 41, 43 ], "
"width = (int) [ 1, MAX], "
"height = (int) [ 1, MAX]; "
"video/mpeg, "
"mpegversion = (int) 1,"
"systemstream = (boolean) false,"
"width = (int) [ 1, MAX], "
"height = (int) [ 1, MAX]; "
"video/x-h263, "
"width = (int) [ 1, MAX], "
"height = (int) [ 1, MAX]; "
"video/x-dv, "
"systemstream = (boolean) false,"
"width = (int) 720,"
"height = (int) { 576, 480 };"
"video/x-huffyuv, "
"width = (int) [ 1, MAX], " "height = (int) [ 1, MAX]")
"format = (fourcc) { YUY2, I420 }, "
"width = (int) [ 1, MAX], "
"height = (int) [ 1, MAX]; "
"video/x-jpeg, "
"width = (int) [ 1, MAX], "
"height = (int) [ 1, MAX]; "
"video/x-divx, "
"divxversion = (int) [ 3, 5 ], "
"width = (int) [ 1, MAX], "
"height = (int) [ 1, MAX]; "
"video/x-xvid, "
"width = (int) [ 1, MAX], "
"height = (int) [ 1, MAX]; "
"video/x-3ivx, "
"width = (int) [ 1, MAX], "
"height = (int) [ 1, MAX]; "
"video/x-msmpeg, "
"msmpegversion = (int) [ 41, 43 ], "
"width = (int) [ 1, MAX], "
"height = (int) [ 1, MAX]; "
"video/mpeg, "
"mpegversion = (int) 1,"
"systemstream = (boolean) false,"
"width = (int) [ 1, MAX], "
"height = (int) [ 1, MAX]; "
"video/x-h263, "
"width = (int) [ 1, MAX], "
"height = (int) [ 1, MAX]; "
"video/x-dv, "
"systemstream = (boolean) false,"
"width = (int) 720,"
"height = (int) { 576, 480 };"
"video/x-huffyuv, "
"width = (int) [ 1, MAX], " "height = (int) [ 1, MAX]")
);
static GstStaticPadTemplate gst_asfmux_audiosink_template =
@ -121,22 +121,22 @@ static GstStaticPadTemplate gst_asfmux_audiosink_template =
GST_PAD_SINK,
GST_PAD_REQUEST,
GST_STATIC_CAPS ("audio/x-raw-int, "
"endianness = (int) LITTLE_ENDIAN, "
"signed = (boolean) { true, false }, "
"width = (int) { 8, 16 }, "
"depth = (int) { 8, 16 }, "
"rate = (int) [ 1000, 96000 ], "
"channels = (int) [ 1, 2]; "
"audio/mpeg, "
"mpegversion = (int) 1, "
"layer = (int) { 1, 3 }, "
"rate = (int) [ 1000, 96000 ], "
"channels = (int) [ 1, 2]; "
"audio/x-vorbis, "
"rate = (int) [ 1000, 96000 ], "
"channels = (int) [ 1, 2]; "
"audio/x-ac3, "
"rate = (int) [ 1000, 96000 ], " "channels = (int) [ 1, 2]")
"endianness = (int) LITTLE_ENDIAN, "
"signed = (boolean) { true, false }, "
"width = (int) { 8, 16 }, "
"depth = (int) { 8, 16 }, "
"rate = (int) [ 1000, 96000 ], "
"channels = (int) [ 1, 2]; "
"audio/mpeg, "
"mpegversion = (int) 1, "
"layer = (int) { 1, 3 }, "
"rate = (int) [ 1000, 96000 ], "
"channels = (int) [ 1, 2]; "
"audio/x-vorbis, "
"rate = (int) [ 1000, 96000 ], "
"channels = (int) [ 1, 2]; "
"audio/x-ac3, "
"rate = (int) [ 1000, 96000 ], " "channels = (int) [ 1, 2]")
);
#define GST_ASF_PACKET_SIZE 3200
@ -174,8 +174,9 @@ gst_asfmux_get_type (void)
0,
(GInstanceInitFunc) gst_asfmux_init,
};
asfmux_type = g_type_register_static (GST_TYPE_ELEMENT,
"GstAsfMux", &asfmux_info, 0);
"GstAsfMux", &asfmux_info, 0);
}
return asfmux_type;
}
@ -283,7 +284,7 @@ gst_asfmux_vidsink_link (GstPad * pad, const GstCaps * caps)
stream->header.video.stream.height = h;
stream->header.video.stream.unknown = 2;
stream->header.video.stream.size = 40;
stream->bitrate = 0; /* TODO */
stream->bitrate = 0; /* TODO */
mimetype = gst_structure_get_name (structure);
if (!strcmp (mimetype, "video/x-raw-yuv")) {
@ -296,13 +297,13 @@ gst_asfmux_vidsink_link (GstPad * pad, const GstCaps * caps)
stream->header.video.format.tag = format;
switch (format) {
case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
stream->header.video.format.depth = 16;
stream->header.video.format.planes = 1;
break;
stream->header.video.format.depth = 16;
stream->header.video.format.planes = 1;
break;
case GST_MAKE_FOURCC ('I', '4', '2', '0'):
stream->header.video.format.depth = 12;
stream->header.video.format.planes = 3;
break;
stream->header.video.format.depth = 12;
stream->header.video.format.planes = 3;
break;
}
goto done;
@ -321,18 +322,18 @@ gst_asfmux_vidsink_link (GstPad * pad, const GstCaps * caps)
gst_structure_get_int (structure, "divxversion", &divxversion);
switch (divxversion) {
case 3:
stream->header.video.format.tag =
GST_MAKE_FOURCC ('D', 'I', 'V', '3');
break;
case 4:
stream->header.video.format.tag =
GST_MAKE_FOURCC ('D', 'I', 'V', 'X');
break;
case 5:
stream->header.video.format.tag =
GST_MAKE_FOURCC ('D', 'X', '5', '0');
break;
case 3:
stream->header.video.format.tag =
GST_MAKE_FOURCC ('D', 'I', 'V', '3');
break;
case 4:
stream->header.video.format.tag =
GST_MAKE_FOURCC ('D', 'I', 'V', 'X');
break;
case 5:
stream->header.video.format.tag =
GST_MAKE_FOURCC ('D', 'X', '5', '0');
break;
}
} else if (!strcmp (mimetype, "video/x-xvid")) {
stream->header.video.format.tag = GST_MAKE_FOURCC ('X', 'V', 'I', 'D');
@ -343,18 +344,18 @@ gst_asfmux_vidsink_link (GstPad * pad, const GstCaps * caps)
gst_structure_get_int (structure, "msmpegversion", &msmpegversion);
switch (msmpegversion) {
case 41:
stream->header.video.format.tag =
GST_MAKE_FOURCC ('M', 'P', 'G', '4');
break;
case 42:
stream->header.video.format.tag =
GST_MAKE_FOURCC ('M', 'P', '4', '2');
break;
case 43:
stream->header.video.format.tag =
GST_MAKE_FOURCC ('M', 'P', '4', '3');
break;
case 41:
stream->header.video.format.tag =
GST_MAKE_FOURCC ('M', 'P', 'G', '4');
break;
case 42:
stream->header.video.format.tag =
GST_MAKE_FOURCC ('M', 'P', '4', '2');
break;
case 43:
stream->header.video.format.tag =
GST_MAKE_FOURCC ('M', 'P', '4', '3');
break;
}
} else if (!strcmp (mimetype, "video/x-dv")) {
stream->header.video.format.tag = GST_MAKE_FOURCC ('D', 'V', 'S', 'D');
@ -441,7 +442,7 @@ gst_asfmux_audsink_link (GstPad * pad, const GstCaps * caps)
stream->header.audio.block_align /= 8;
stream->header.audio.block_align *= stream->header.audio.channels;
stream->header.audio.byte_rate = stream->header.audio.block_align *
stream->header.audio.sample_rate;
stream->header.audio.sample_rate;
goto done;
} else {
stream->header.audio.codec_tag = 0;
@ -451,13 +452,13 @@ gst_asfmux_audsink_link (GstPad * pad, const GstCaps * caps)
gst_structure_get_int (structure, "layer", &layer);
switch (layer) {
case 3:
stream->header.audio.codec_tag = GST_RIFF_WAVE_FORMAT_MPEGL3;
break;
case 1:
case 2:
stream->header.audio.codec_tag = GST_RIFF_WAVE_FORMAT_MPEGL12;
break;
case 3:
stream->header.audio.codec_tag = GST_RIFF_WAVE_FORMAT_MPEGL3;
break;
case 1:
case 2:
stream->header.audio.codec_tag = GST_RIFF_WAVE_FORMAT_MPEGL12;
break;
}
} else if (!strcmp (mimetype, "audio/x-vorbis")) {
stream->header.audio.codec_tag = GST_RIFF_WAVE_FORMAT_VORBIS3;
@ -606,7 +607,7 @@ static gboolean
gst_asfmux_is_stream (GstAsfMux * asfmux)
{
/* this is for RTP */
return FALSE; /*!gst_asfmux_can_seek (asfmux) */
return FALSE; /*!gst_asfmux_can_seek (asfmux) */
}
/* handle events (search) */
@ -625,13 +626,13 @@ gst_asfmux_handle_event (GstPad * pad, GstEvent * event)
case GST_EVENT_EOS:
/* is this allright? */
for (n = 0; n < asfmux->num_outputs; n++) {
if (asfmux->output[n].pad == pad) {
asfmux->output[n].eos = TRUE;
break;
}
if (asfmux->output[n].pad == pad) {
asfmux->output[n].eos = TRUE;
break;
}
}
if (n == asfmux->num_outputs) {
g_warning ("Unknown pad for EOS!");
g_warning ("Unknown pad for EOS!");
}
break;
default:
@ -652,14 +653,14 @@ gst_asfmux_fill_queue (GstAsfMux * asfmux)
GstAsfMuxStream *stream = &asfmux->output[n];
while (stream->queue == NULL &&
stream->pad != NULL &&
stream->connected == TRUE &&
GST_PAD_IS_USABLE (stream->pad) && stream->eos == FALSE) {
stream->pad != NULL &&
stream->connected == TRUE &&
GST_PAD_IS_USABLE (stream->pad) && stream->eos == FALSE) {
buffer = GST_BUFFER (gst_pad_pull (stream->pad));
if (GST_IS_EVENT (buffer)) {
gst_asfmux_handle_event (stream->pad, GST_EVENT (buffer));
gst_asfmux_handle_event (stream->pad, GST_EVENT (buffer));
} else {
stream->queue = buffer;
stream->queue = buffer;
}
}
}
@ -878,7 +879,7 @@ gst_asfmux_file_start (GstAsfMux * asfmux, guint64 file_size, guint64 data_size)
GST_BUFFER_SIZE (header) = 0;
if (asfmux->packet != NULL) {
duration = GST_BUFFER_DURATION (asfmux->packet) +
GST_BUFFER_TIMESTAMP (asfmux->packet);
GST_BUFFER_TIMESTAMP (asfmux->packet);
} else {
duration = 0;
}
@ -893,8 +894,8 @@ gst_asfmux_file_start (GstAsfMux * asfmux, guint64 file_size, guint64 data_size)
gst_asfmux_put_le64 (header, ~0);
/* number of chunks in header */
gst_asfmux_put_le32 (header, 3 + /*has_title + */ asfmux->num_outputs);
gst_asfmux_put_byte (header, 1); /* ??? */
gst_asfmux_put_byte (header, 2); /* ??? */
gst_asfmux_put_byte (header, 1); /* ??? */
gst_asfmux_put_byte (header, 2); /* ??? */
/* file header */
header_offset = GST_BUFFER_SIZE (header);
@ -902,14 +903,14 @@ gst_asfmux_file_start (GstAsfMux * asfmux, guint64 file_size, guint64 data_size)
gst_asfmux_put_guid (header, asf_object_guids, ASF_OBJ_UNDEFINED);
gst_asfmux_put_le64 (header, file_size);
gst_asfmux_put_time (header, 0);
gst_asfmux_put_le64 (header, asfmux->num_packets); /* number of packets */
gst_asfmux_put_le64 (header, duration / (GST_SECOND / 10000000)); /* end time stamp (in 100ns units) */
gst_asfmux_put_le64 (header, duration / (GST_SECOND / 10000000)); /* duration (in 100ns units) */
gst_asfmux_put_le64 (header, 0); /* start time stamp */
gst_asfmux_put_le32 (header, gst_asfmux_can_seek (asfmux) ? 0x02 : 0x01); /* seekable or streamable */
gst_asfmux_put_le32 (header, GST_ASF_PACKET_SIZE); /* packet size */
gst_asfmux_put_le32 (header, GST_ASF_PACKET_SIZE); /* packet size */
gst_asfmux_put_le32 (header, bitrate); /* Nominal data rate in bps */
gst_asfmux_put_le64 (header, asfmux->num_packets); /* number of packets */
gst_asfmux_put_le64 (header, duration / (GST_SECOND / 10000000)); /* end time stamp (in 100ns units) */
gst_asfmux_put_le64 (header, duration / (GST_SECOND / 10000000)); /* duration (in 100ns units) */
gst_asfmux_put_le64 (header, 0); /* start time stamp */
gst_asfmux_put_le32 (header, gst_asfmux_can_seek (asfmux) ? 0x02 : 0x01); /* seekable or streamable */
gst_asfmux_put_le32 (header, GST_ASF_PACKET_SIZE); /* packet size */
gst_asfmux_put_le32 (header, GST_ASF_PACKET_SIZE); /* packet size */
gst_asfmux_put_le32 (header, bitrate); /* Nominal data rate in bps */
gst_asfmux_end_header (header, header_pos);
/* unknown headers */
@ -923,12 +924,12 @@ gst_asfmux_file_start (GstAsfMux * asfmux, guint64 file_size, guint64 data_size)
#if 0
if (has_title) {
header_pos =
gst_asfmux_put_header (header, asf_object_guids, ASF_OBJ_COMMENT);
gst_asfmux_put_header (header, asf_object_guids, ASF_OBJ_COMMENT);
gst_asfmux_put_le16 (header, 2 * (strlen (title) + 1));
gst_asfmux_put_le16 (header, 2 * (strlen (author) + 1));
gst_asfmux_put_le16 (header, 2 * (strlen (copyright) + 1));
gst_asfmux_put_le16 (header, 2 * (strlen (comment) + 1));
gst_asfmux_put_le16 (header, 0); /* rating */
gst_asfmux_put_le16 (header, 0); /* rating */
gst_asfmux_put_string (header, title);
gst_asfmux_put_string (header, author);
gst_asfmux_put_string (header, copyright);
@ -944,37 +945,37 @@ gst_asfmux_file_start (GstAsfMux * asfmux, guint64 file_size, guint64 data_size)
stream->seqnum = 0;
header_pos =
gst_asfmux_put_header (header, asf_object_guids, ASF_OBJ_STREAM);
gst_asfmux_put_header (header, asf_object_guids, ASF_OBJ_STREAM);
switch (stream->type) {
case ASF_STREAM_AUDIO:
obj_size = 18;
gst_asfmux_put_guid (header, asf_stream_guids, ASF_STREAM_AUDIO);
gst_asfmux_put_guid (header, asf_correction_guids, ASF_CORRECTION_OFF);
break;
obj_size = 18;
gst_asfmux_put_guid (header, asf_stream_guids, ASF_STREAM_AUDIO);
gst_asfmux_put_guid (header, asf_correction_guids, ASF_CORRECTION_OFF);
break;
case ASF_STREAM_VIDEO:
obj_size = 11 + 40;
gst_asfmux_put_guid (header, asf_stream_guids, ASF_STREAM_VIDEO);
gst_asfmux_put_guid (header, asf_correction_guids, ASF_CORRECTION_OFF);
break;
obj_size = 11 + 40;
gst_asfmux_put_guid (header, asf_stream_guids, ASF_STREAM_VIDEO);
gst_asfmux_put_guid (header, asf_correction_guids, ASF_CORRECTION_OFF);
break;
default:
g_assert (0);
g_assert (0);
}
gst_asfmux_put_le64 (header, 0); /* offset */
gst_asfmux_put_le32 (header, obj_size); /* wav header len */
gst_asfmux_put_le32 (header, 0); /* additional data len */
gst_asfmux_put_le16 (header, n + 1); /* stream number */
gst_asfmux_put_le32 (header, 0); /* ??? */
gst_asfmux_put_le64 (header, 0); /* offset */
gst_asfmux_put_le32 (header, obj_size); /* wav header len */
gst_asfmux_put_le32 (header, 0); /* additional data len */
gst_asfmux_put_le16 (header, n + 1); /* stream number */
gst_asfmux_put_le32 (header, 0); /* ??? */
switch (stream->type) {
case ASF_STREAM_AUDIO:
gst_asfmux_put_wav_header (header, &stream->header.audio);
break;
gst_asfmux_put_wav_header (header, &stream->header.audio);
break;
case ASF_STREAM_VIDEO:
gst_asfmux_put_vid_header (header, &stream->header.video.stream);
gst_asfmux_put_bmp_header (header, &stream->header.video.format);
break;
gst_asfmux_put_vid_header (header, &stream->header.video.stream);
gst_asfmux_put_bmp_header (header, &stream->header.video.format);
break;
}
gst_asfmux_end_header (header, header_pos);
@ -993,20 +994,20 @@ gst_asfmux_file_start (GstAsfMux * asfmux, guint64 file_size, guint64 data_size)
/* Isn't this wrong? This is UTF16! */
gst_asfmux_put_le16 (header, strlen (codec) + 1);
gst_asfmux_put_string (header, codec);
gst_asfmux_put_le16 (header, 0); /* no parameters */
gst_asfmux_put_le16 (header, 0); /* no parameters */
/* id */
switch (stream->type) {
case ASF_STREAM_AUDIO:
gst_asfmux_put_le16 (header, 2);
gst_asfmux_put_le16 (header, stream->header.audio.codec_tag);
break;
gst_asfmux_put_le16 (header, 2);
gst_asfmux_put_le16 (header, stream->header.audio.codec_tag);
break;
case ASF_STREAM_VIDEO:
gst_asfmux_put_le16 (header, 4);
gst_asfmux_put_le32 (header, stream->header.video.format.tag);
break;
gst_asfmux_put_le16 (header, 4);
gst_asfmux_put_le32 (header, stream->header.video.format.tag);
break;
default:
g_assert (0);
g_assert (0);
}
}
gst_asfmux_end_header (header, header_pos);
@ -1034,9 +1035,9 @@ gst_asfmux_file_start (GstAsfMux * asfmux, guint64 file_size, guint64 data_size)
gst_asfmux_put_guid (header, asf_object_guids, ASF_OBJ_DATA);
gst_asfmux_put_le64 (header, data_size);
gst_asfmux_put_guid (header, asf_object_guids, ASF_OBJ_UNDEFINED);
gst_asfmux_put_le64 (header, asfmux->num_packets); /* nb packets */
gst_asfmux_put_byte (header, 1); /* ??? */
gst_asfmux_put_byte (header, 1); /* ??? */
gst_asfmux_put_le64 (header, asfmux->num_packets); /* nb packets */
gst_asfmux_put_byte (header, 1); /* ??? */
gst_asfmux_put_byte (header, 1); /* ??? */
gst_pad_push (asfmux->srcpad, GST_DATA (header));
asfmux->write_header = FALSE;
@ -1050,7 +1051,7 @@ gst_asfmux_file_stop (GstAsfMux * asfmux)
GstBuffer *footer = gst_buffer_new_and_alloc (16);
GST_BUFFER_SIZE (footer) = 0;
gst_asfmux_put_chunk (footer, asfmux, 0x4524, 0, 0); /* end of stream */
gst_asfmux_put_chunk (footer, asfmux, 0x4524, 0, 0); /* end of stream */
gst_pad_push (asfmux->srcpad, GST_DATA (footer));
} else if (gst_asfmux_can_seek (asfmux)) {
/* rewrite an updated header */
@ -1063,7 +1064,7 @@ gst_asfmux_file_stop (GstAsfMux * asfmux)
gst_pad_push (asfmux->srcpad, GST_DATA (event));
gst_asfmux_file_start (asfmux, filesize, filesize - asfmux->data_offset);
event =
gst_event_new_seek (GST_SEEK_METHOD_SET | GST_FORMAT_BYTES, filesize);
gst_event_new_seek (GST_SEEK_METHOD_SET | GST_FORMAT_BYTES, filesize);
gst_pad_push (asfmux->srcpad, GST_DATA (event));
}
@ -1086,7 +1087,7 @@ gst_asfmux_packet_header (GstAsfMux * asfmux)
gst_asfmux_put_byte (header, 0x82);
gst_asfmux_put_le16 (header, 0);
flags = 0x01; /* nb segments present */
flags = 0x01; /* nb segments present */
if (padsize > 0) {
if (padsize < 256) {
flags |= 0x08;
@ -1094,7 +1095,7 @@ gst_asfmux_packet_header (GstAsfMux * asfmux)
flags |= 0x10;
}
}
gst_asfmux_put_byte (header, flags); /* flags */
gst_asfmux_put_byte (header, flags); /* flags */
gst_asfmux_put_byte (header, 0x5d);
if (flags & 0x10) {
gst_asfmux_put_le16 (header, padsize - 2);
@ -1122,12 +1123,12 @@ gst_asfmux_frame_header (GstAsfMux * asfmux,
GST_BUFFER_DURATION (asfmux->packet) =
time - GST_BUFFER_TIMESTAMP (asfmux->packet);
gst_asfmux_put_byte (asfmux->packet, (stream->index + 1) | 0x80); //(key ? 0x80 : 0));
gst_asfmux_put_byte (asfmux->packet, (stream->index + 1) | 0x80); //(key ? 0x80 : 0));
gst_asfmux_put_byte (asfmux->packet, stream->seqnum);
gst_asfmux_put_le32 (asfmux->packet, position);
gst_asfmux_put_byte (asfmux->packet, 0x08);
gst_asfmux_put_le32 (asfmux->packet, total);
gst_asfmux_put_le32 (asfmux->packet, time / (GST_SECOND / 1000)); /* time in ms */
gst_asfmux_put_le32 (asfmux->packet, time / (GST_SECOND / 1000)); /* time in ms */
gst_asfmux_put_le16 (asfmux->packet, length);
}
@ -1148,7 +1149,7 @@ gst_asfmux_packet_flush (GstAsfMux * asfmux)
header = gst_asfmux_packet_header (asfmux);
header_size = GST_BUFFER_SIZE (header);
if (!gst_asfmux_can_seek (asfmux)) {
header_size -= 12; /* hack... bah */
header_size -= 12; /* hack... bah */
}
/* Clear out the padding bytes */
@ -1192,10 +1193,10 @@ gst_asfmux_write_buffer (GstAsfMux * asfmux,
/* write frame header plus data in this packet */
gst_asfmux_frame_header (asfmux, stream, position, to_write, size,
GST_BUFFER_TIMESTAMP (buffer),
GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_KEY_UNIT));
GST_BUFFER_TIMESTAMP (buffer),
GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_KEY_UNIT));
gst_asfmux_frame_buffer (asfmux, GST_BUFFER_DATA (buffer) + position,
to_write);
to_write);
position += to_write;
}
@ -1213,9 +1214,9 @@ gst_asfmux_do_one_buffer (GstAsfMux * asfmux)
for (n = 0; n < asfmux->num_outputs; n++) {
if (asfmux->output[n].queue != NULL) {
if (chosen == -1 ||
GST_BUFFER_TIMESTAMP (asfmux->output[n].queue) <
GST_BUFFER_TIMESTAMP (asfmux->output[chosen].queue)) {
chosen = n;
GST_BUFFER_TIMESTAMP (asfmux->output[n].queue) <
GST_BUFFER_TIMESTAMP (asfmux->output[chosen].queue)) {
chosen = n;
}
}
}
@ -1275,7 +1276,7 @@ gst_asfmux_change_state (GstElement * element)
switch (transition) {
case GST_STATE_PAUSED_TO_PLAYING:
for (n = 0; n < asfmux->num_outputs; n++) {
asfmux->output[n].eos = FALSE;
asfmux->output[n].eos = FALSE;
}
break;
}

View file

@ -36,9 +36,9 @@ 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 ]")
"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",
@ -98,8 +98,9 @@ gst_mp3parse_get_type (void)
0,
(GInstanceInitFunc) gst_mp3parse_init,
};
mp3parse_type = g_type_register_static (GST_TYPE_ELEMENT,
"GstMPEGAudioParse", &mp3parse_info, 0);
"GstMPEGAudioParse", &mp3parse_info, 0);
}
return mp3parse_type;
}
@ -238,8 +239,8 @@ gst_mp3parse_class_init (GstMPEGAudioParseClass * 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);
@ -354,89 +355,89 @@ gst_mp3parse_chain (GstPad * pad, GstData * _data)
* the frames are not independently coded.
********************************************************************************/
if (mp3parse->in_flush) {
guint32 header2;
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 */
(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 ((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);
break;
GST_DEBUG ("mp3parse: partial buffer needed %ld < %d ", (size - offset),
bpf);
break;
} else {
guint bitrate, layer, rate, channels;
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);
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);
gst_pad_set_explicit_caps (mp3parse->srcpad, caps);
mp3parse->channels = channels;
mp3parse->layer = layer;
mp3parse->rate = rate;
mp3parse->bit_rate = bitrate;
}
mp3parse->channels = channels;
mp3parse->layer = layer;
mp3parse->rate = rate;
mp3parse->bit_rate = bitrate;
}
outbuf = gst_buffer_create_sub (mp3parse->partialbuf, offset, bpf);
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));
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;
offset += bpf;
if (mp3parse->skip == 0) {
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);
mp3parse->skip--;
}
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?)");
GST_DEBUG ("mp3parse: *** wrong header, skipping byte (FIXME?)");
}
}
/* if we have processed this block and there are still */
@ -445,7 +446,7 @@ gst_mp3parse_chain (GstPad * pad, GstData * _data)
glong remainder = (size - offset);
GST_DEBUG ("mp3parse: partial buffer needed %ld for trailing bytes",
remainder);
remainder);
outbuf = gst_buffer_create_sub (mp3parse->partialbuf, offset, remainder);
gst_buffer_unref (mp3parse->partialbuf);
@ -462,7 +463,7 @@ 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;
}

View file

@ -53,8 +53,9 @@ gst_mpeg_clock_get_type (void)
(GInstanceInitFunc) gst_mpeg_clock_init,
NULL
};
clock_type = g_type_register_static (GST_TYPE_SYSTEM_CLOCK, "GstMPEGClock",
&clock_info, 0);
&clock_info, 0);
}
return clock_type;
}

View file

@ -53,7 +53,7 @@ static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/mpeg, "
"mpegversion = (int) { 1, 2 }, " "systemstream = (boolean) TRUE")
"mpegversion = (int) { 1, 2 }, " "systemstream = (boolean) TRUE")
);
static GstStaticPadTemplate audio_factory =
@ -61,7 +61,7 @@ GST_STATIC_PAD_TEMPLATE ("audio_%02d",
GST_PAD_SRC,
GST_PAD_SOMETIMES,
GST_STATIC_CAPS ("audio/mpeg, "
"mpegversion = (int) 1, " "layer = (int) { 1, 2 }")
"mpegversion = (int) 1, " "layer = (int) { 1, 2 }")
);
static GstStaticPadTemplate video_src_factory =
@ -69,7 +69,7 @@ GST_STATIC_PAD_TEMPLATE ("video_%02d",
GST_PAD_SRC,
GST_PAD_SOMETIMES,
GST_STATIC_CAPS ("video/mpeg, "
"mpegversion = (int) { 1, 2 }, " "systemstream = (boolean) FALSE")
"mpegversion = (int) { 1, 2 }, " "systemstream = (boolean) FALSE")
);
static GstStaticPadTemplate private1_factory =
@ -90,11 +90,11 @@ GST_STATIC_PAD_TEMPLATE ("pcm_stream_%02d",
GST_PAD_SRC,
GST_PAD_SOMETIMES,
GST_STATIC_CAPS ("audio/x-raw-int, "
"endianness = (int) BIG_ENDIAN, "
"signed = (boolean) TRUE, "
"width = (int) { 16, 20, 24 }, "
"depth = (int) { 16, 20, 24 }, "
"rate = (int) { 48000, 96000 }, " "channels = (int) [ 1, 8 ]")
"endianness = (int) BIG_ENDIAN, "
"signed = (boolean) TRUE, "
"width = (int) { 16, 20, 24 }, "
"depth = (int) { 16, 20, 24 }, "
"rate = (int) { 48000, 96000 }, " "channels = (int) [ 1, 8 ]")
);
static GstStaticPadTemplate subtitle_factory =
@ -153,9 +153,10 @@ mpeg_demux_get_type (void)
0,
(GInstanceInitFunc) gst_mpeg_demux_init,
};
mpeg_demux_type =
g_type_register_static (GST_TYPE_MPEG_PARSE, "GstMPEGDemux",
&mpeg_demux_info, 0);
g_type_register_static (GST_TYPE_MPEG_PARSE, "GstMPEGDemux",
&mpeg_demux_info, 0);
}
return mpeg_demux_type;
}
@ -264,8 +265,8 @@ gst_mpeg_demux_send_data (GstMPEGParse * mpeg_parse, GstData * data,
switch (GST_EVENT_TYPE (event)) {
default:
gst_pad_event_default (mpeg_parse->sinkpad, event);
break;
gst_pad_event_default (mpeg_parse->sinkpad, event);
break;
}
}
}
@ -280,20 +281,20 @@ gst_mpeg_demux_handle_discont (GstMPEGParse * mpeg_parse)
for (i = 0; i < NUM_VIDEO_STREAMS; i++) {
if (mpeg_demux->video_stream[i] &&
GST_PAD_IS_USABLE (mpeg_demux->video_stream[i]->pad)) {
GST_PAD_IS_USABLE (mpeg_demux->video_stream[i]->pad)) {
GstEvent *discont;
discont = gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME,
current_time, NULL);
current_time, NULL);
gst_pad_push (mpeg_demux->video_stream[i]->pad, GST_DATA (discont));
}
if (mpeg_demux->audio_stream[i] &&
GST_PAD_IS_USABLE (mpeg_demux->audio_stream[i]->pad)) {
GST_PAD_IS_USABLE (mpeg_demux->audio_stream[i]->pad)) {
GstEvent *discont;
discont = gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME,
current_time, NULL);
current_time, NULL);
gst_pad_push (mpeg_demux->audio_stream[i]->pad, GST_DATA (discont));
}
@ -322,11 +323,11 @@ _demux_get_writer_id (GstIndex * index, GstPad * pad)
if (!gst_index_get_writer_id (index, GST_OBJECT (pad), &id)) {
GST_CAT_WARNING_OBJECT (GST_CAT_SEEK, index,
"can't get index id for %s:%s", GST_DEBUG_PAD_NAME (pad));
"can't get index id for %s:%s", GST_DEBUG_PAD_NAME (pad));
return -1;
} else {
GST_CAT_LOG_OBJECT (GST_CAT_SEEK, index,
"got index id %d for %s:%s", id, GST_DEBUG_PAD_NAME (pad));
"got index id %d for %s:%s", id, GST_DEBUG_PAD_NAME (pad));
return id;
}
}
@ -377,14 +378,14 @@ gst_mpeg_demux_parse_syshead (GstMPEGParse * mpeg_parse, GstBuffer * buffer)
stream_id = *buf++;
if (!(stream_id & 0x80)) {
GST_DEBUG ("error in system header length");
return FALSE;
GST_DEBUG ("error in system header length");
return FALSE;
}
/* check marker bits */
if ((*buf & 0xC0) != 0xC0) {
GST_DEBUG ("expecting placeholder bit values '11' after stream id\n");
return FALSE;
GST_DEBUG ("expecting placeholder bit values '11' after stream id\n");
return FALSE;
}
STD_buffer_bound_scale = *buf & 0x20;
@ -392,102 +393,102 @@ gst_mpeg_demux_parse_syshead (GstMPEGParse * mpeg_parse, GstBuffer * buffer)
STD_buffer_size_bound |= *buf++;
if (STD_buffer_bound_scale == 0) {
buf_byte_size_bound = STD_buffer_size_bound * 128;
buf_byte_size_bound = STD_buffer_size_bound * 128;
} else {
buf_byte_size_bound = STD_buffer_size_bound * 1024;
buf_byte_size_bound = STD_buffer_size_bound * 1024;
}
if (stream_id == 0xBD) {
/* private_stream_1 */
name = NULL;
outstream = NULL;
/* private_stream_1 */
name = NULL;
outstream = NULL;
} else if (stream_id == 0xBF) {
/* private_stream_2 */
name = g_strdup_printf ("private_stream_2");
outstream = &mpeg_demux->private_2_stream;
newtemp = gst_static_pad_template_get (&private2_factory);
/* private_stream_2 */
name = g_strdup_printf ("private_stream_2");
outstream = &mpeg_demux->private_2_stream;
newtemp = gst_static_pad_template_get (&private2_factory);
} else if (stream_id >= 0xC0 && stream_id < 0xE0) {
/* Audio */
name = g_strdup_printf ("audio_%02d", stream_id & 0x1F);
outstream = &mpeg_demux->audio_stream[stream_id & 0x1F];
newtemp = gst_static_pad_template_get (&audio_factory);
/* Audio */
name = g_strdup_printf ("audio_%02d", stream_id & 0x1F);
outstream = &mpeg_demux->audio_stream[stream_id & 0x1F];
newtemp = gst_static_pad_template_get (&audio_factory);
} else if (stream_id >= 0xE0 && stream_id < 0xF0) {
/* Video */
name = g_strdup_printf ("video_%02d", stream_id & 0x0F);
outstream = &mpeg_demux->video_stream[stream_id & 0x0F];
newtemp = gst_static_pad_template_get (&video_src_factory);
if (!GST_MPEG_PARSE_IS_MPEG2 (mpeg_demux)) {
caps = gst_caps_new_simple ("video/mpeg",
"mpegversion", G_TYPE_INT, 1,
"systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
} else {
caps = gst_caps_new_simple ("video/mpeg",
"mpegversion", G_TYPE_INT, 2,
"systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
}
/* Video */
name = g_strdup_printf ("video_%02d", stream_id & 0x0F);
outstream = &mpeg_demux->video_stream[stream_id & 0x0F];
newtemp = gst_static_pad_template_get (&video_src_factory);
if (!GST_MPEG_PARSE_IS_MPEG2 (mpeg_demux)) {
caps = gst_caps_new_simple ("video/mpeg",
"mpegversion", G_TYPE_INT, 1,
"systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
} else {
caps = gst_caps_new_simple ("video/mpeg",
"mpegversion", G_TYPE_INT, 2,
"systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
}
} else {
GST_DEBUG ("unknown stream id %d", stream_id);
GST_DEBUG ("unknown stream id %d", stream_id);
}
GST_DEBUG ("stream ID 0x%02X (%s)", stream_id, name);
GST_DEBUG ("STD_buffer_bound_scale %d", STD_buffer_bound_scale);
GST_DEBUG ("STD_buffer_size_bound %d or %d bytes",
STD_buffer_size_bound, buf_byte_size_bound);
STD_buffer_size_bound, buf_byte_size_bound);
/* create the pad and add it to self if it does not yet exist
* this should trigger the NEW_PAD signal, which should be caught by
* the app and used to attach to desired streams.
*/
if (outstream && *outstream == NULL) {
GstPad **outpad;
GstPad **outpad;
*outstream = gst_mpeg_demux_new_stream ();
outpad = &((*outstream)->pad);
*outstream = gst_mpeg_demux_new_stream ();
outpad = &((*outstream)->pad);
*outpad = gst_pad_new_from_template (newtemp, name);
*outpad = gst_pad_new_from_template (newtemp, name);
gst_pad_set_formats_function (*outpad, gst_mpeg_demux_get_src_formats);
gst_pad_set_convert_function (*outpad, gst_mpeg_parse_convert_src);
gst_pad_set_event_mask_function (*outpad,
gst_mpeg_parse_get_src_event_masks);
gst_pad_set_event_function (*outpad, gst_mpeg_demux_handle_src_event);
gst_pad_set_query_type_function (*outpad,
gst_mpeg_parse_get_src_query_types);
gst_pad_set_query_function (*outpad, gst_mpeg_parse_handle_src_query);
if (caps && gst_caps_is_fixed (caps))
gst_pad_use_explicit_caps (*outpad);
gst_pad_set_formats_function (*outpad, gst_mpeg_demux_get_src_formats);
gst_pad_set_convert_function (*outpad, gst_mpeg_parse_convert_src);
gst_pad_set_event_mask_function (*outpad,
gst_mpeg_parse_get_src_event_masks);
gst_pad_set_event_function (*outpad, gst_mpeg_demux_handle_src_event);
gst_pad_set_query_type_function (*outpad,
gst_mpeg_parse_get_src_query_types);
gst_pad_set_query_function (*outpad, gst_mpeg_parse_handle_src_query);
if (caps && gst_caps_is_fixed (caps))
gst_pad_use_explicit_caps (*outpad);
if (caps && gst_caps_is_fixed (caps))
gst_pad_set_explicit_caps (*outpad, caps);
else if (caps)
gst_caps_free (caps);
if (caps && gst_caps_is_fixed (caps))
gst_pad_set_explicit_caps (*outpad, caps);
else if (caps)
gst_caps_free (caps);
gst_element_add_pad (GST_ELEMENT (mpeg_demux), (*outpad));
gst_element_add_pad (GST_ELEMENT (mpeg_demux), (*outpad));
gst_pad_set_element_private (*outpad, *outstream);
gst_pad_set_element_private (*outpad, *outstream);
(*outstream)->size_bound = buf_byte_size_bound;
mpeg_demux->total_size_bound += buf_byte_size_bound;
(*outstream)->size_bound = buf_byte_size_bound;
mpeg_demux->total_size_bound += buf_byte_size_bound;
if (mpeg_demux->index)
(*outstream)->index_id =
_demux_get_writer_id (mpeg_demux->index, *outpad);
if (mpeg_demux->index)
(*outstream)->index_id =
_demux_get_writer_id (mpeg_demux->index, *outpad);
if (GST_PAD_IS_USABLE (*outpad)) {
GstEvent *event;
gint64 time;
if (GST_PAD_IS_USABLE (*outpad)) {
GstEvent *event;
gint64 time;
time = mpeg_parse->current_scr;
time = mpeg_parse->current_scr;
event = gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME,
MPEGTIME_TO_GSTTIME (time), NULL);
event = gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME,
MPEGTIME_TO_GSTTIME (time), NULL);
gst_pad_push (*outpad, GST_DATA (event));
}
gst_pad_push (*outpad, GST_DATA (event));
}
} else {
/* we won't be needing this. */
if (name)
g_free (name);
/* we won't be needing this. */
if (name)
g_free (name);
}
j++;
@ -539,67 +540,67 @@ gst_mpeg_demux_parse_packet (GstMPEGParse * mpeg_parse, GstBuffer * buffer)
/* stuffing bytes */
switch (bits & 0xC0) {
case 0xC0:
if (bits == 0xff) {
GST_DEBUG ("have stuffing byte");
} else {
GST_DEBUG ("expected stuffing byte");
}
headerlen++;
break;
if (bits == 0xff) {
GST_DEBUG ("have stuffing byte");
} else {
GST_DEBUG ("expected stuffing byte");
}
headerlen++;
break;
case 0x40:
GST_DEBUG ("have STD");
GST_DEBUG ("have STD");
STD_buffer_bound_scale = bits & 0x20;
STD_buffer_size_bound = ((guint16) (bits & 0x1F)) << 8;
STD_buffer_size_bound |= *buf++;
STD_buffer_bound_scale = bits & 0x20;
STD_buffer_size_bound = ((guint16) (bits & 0x1F)) << 8;
STD_buffer_size_bound |= *buf++;
headerlen += 2;
break;
headerlen += 2;
break;
case 0x00:
switch (bits & 0x30) {
case 0x20:
/* pts:3 ! 1 ! pts:15 ! 1 | pts:15 ! 1 */
pts = ((guint64) (bits & 0x0E)) << 29;
pts |= ((guint64) * buf++) << 22;
pts |= ((guint64) (*buf++ & 0xFE)) << 14;
pts |= ((guint64) * buf++) << 7;
pts |= ((guint64) (*buf++ & 0xFE)) >> 1;
switch (bits & 0x30) {
case 0x20:
/* pts:3 ! 1 ! pts:15 ! 1 | pts:15 ! 1 */
pts = ((guint64) (bits & 0x0E)) << 29;
pts |= ((guint64) * buf++) << 22;
pts |= ((guint64) (*buf++ & 0xFE)) << 14;
pts |= ((guint64) * buf++) << 7;
pts |= ((guint64) (*buf++ & 0xFE)) >> 1;
GST_DEBUG ("PTS = %" G_GUINT64_FORMAT, pts);
headerlen += 5;
goto done;
case 0x30:
/* pts:3 ! 1 ! pts:15 ! 1 | pts:15 ! 1 */
pts = ((guint64) (bits & 0x0E)) << 29;
pts |= ((guint64) * buf++) << 22;
pts |= ((guint64) (*buf++ & 0xFE)) << 14;
pts |= ((guint64) * buf++) << 7;
pts |= ((guint64) (*buf++ & 0xFE)) >> 1;
GST_DEBUG ("PTS = %" G_GUINT64_FORMAT, pts);
headerlen += 5;
goto done;
case 0x30:
/* pts:3 ! 1 ! pts:15 ! 1 | pts:15 ! 1 */
pts = ((guint64) (bits & 0x0E)) << 29;
pts |= ((guint64) * buf++) << 22;
pts |= ((guint64) (*buf++ & 0xFE)) << 14;
pts |= ((guint64) * buf++) << 7;
pts |= ((guint64) (*buf++ & 0xFE)) >> 1;
/* sync:4 ! pts:3 ! 1 ! pts:15 ! 1 | pts:15 ! 1 */
dts = ((guint64) (*buf++ & 0x0E)) << 29;
dts |= ((guint64) * buf++) << 22;
dts |= ((guint64) (*buf++ & 0xFE)) << 14;
dts |= ((guint64) * buf++) << 7;
dts |= ((guint64) (*buf++ & 0xFE)) >> 1;
/* sync:4 ! pts:3 ! 1 ! pts:15 ! 1 | pts:15 ! 1 */
dts = ((guint64) (*buf++ & 0x0E)) << 29;
dts |= ((guint64) * buf++) << 22;
dts |= ((guint64) (*buf++ & 0xFE)) << 14;
dts |= ((guint64) * buf++) << 7;
dts |= ((guint64) (*buf++ & 0xFE)) >> 1;
GST_DEBUG ("PTS = %" G_GUINT64_FORMAT ", DTS = %" G_GUINT64_FORMAT,
pts, dts);
headerlen += 10;
goto done;
case 0x00:
GST_DEBUG ("have no pts/dts");
GST_DEBUG ("got trailer bits %x", (bits & 0x0f));
if ((bits & 0x0f) != 0xf) {
GST_DEBUG ("not a valid packet time sequence");
return FALSE;
}
headerlen++;
default:
goto done;
}
GST_DEBUG ("PTS = %" G_GUINT64_FORMAT ", DTS = %" G_GUINT64_FORMAT,
pts, dts);
headerlen += 10;
goto done;
case 0x00:
GST_DEBUG ("have no pts/dts");
GST_DEBUG ("got trailer bits %x", (bits & 0x0f));
if ((bits & 0x0f) != 0xf) {
GST_DEBUG ("not a valid packet time sequence");
return FALSE;
}
headerlen++;
default:
goto done;
}
default:
goto done;
goto done;
}
} while (1);
GST_DEBUG ("done with header loop");
@ -618,7 +619,7 @@ done:
if (ps_id_code >= 0x80 && ps_id_code <= 0x87) {
/* make sure it's valid */
GST_DEBUG ("0x%02X: we have a private_stream_1 (AC3) packet, track %d",
id, ps_id_code - 0x80);
id, ps_id_code - 0x80);
outstream = &mpeg_demux->private_1_stream[ps_id_code - 0x80];
/* scrap first 4 bytes (so-called "mystery AC3 tag") */
headerlen += 4;
@ -659,9 +660,9 @@ done:
if (mpeg_demux->index) {
gst_index_add_association (mpeg_demux->index,
(*outstream)->index_id, 0,
GST_FORMAT_BYTES, GST_BUFFER_OFFSET (buffer),
GST_FORMAT_TIME, timestamp, 0);
(*outstream)->index_id, 0,
GST_FORMAT_BYTES, GST_BUFFER_OFFSET (buffer),
GST_FORMAT_TIME, timestamp, 0);
}
} else {
timestamp = GST_CLOCK_TIME_NONE;
@ -678,7 +679,7 @@ done:
GST_BUFFER_OFFSET (outbuf) = GST_BUFFER_OFFSET (buffer) + headerlen + 4;
GST_DEBUG ("pushing buffer of len %d id %d, ts %" G_GINT64_FORMAT,
datalen, id, GST_BUFFER_TIMESTAMP (outbuf));
datalen, id, GST_BUFFER_TIMESTAMP (outbuf));
gst_pad_push (outpad, GST_DATA (outbuf));
}
@ -779,7 +780,7 @@ gst_mpeg_demux_parse_pes (GstMPEGParse * mpeg_parse, GstBuffer * buffer)
if (ps_id_code >= 0x80 && ps_id_code <= 0x87) {
GST_DEBUG ("we have a private_stream_1 (AC3) packet, track %d",
ps_id_code - 0x80);
ps_id_code - 0x80);
outstream = &mpeg_demux->private_1_stream[ps_id_code - 0x80];
/* scrap first 4 bytes (so-called "mystery AC3 tag") */
headerlen += 4;
@ -790,11 +791,11 @@ gst_mpeg_demux_parse_pes (GstMPEGParse * mpeg_parse, GstBuffer * buffer)
/* Check for changes in the sample format. */
if (*outstream != NULL &&
basebuf[headerlen + 9] !=
mpeg_demux->lpcm_sample_info[ps_id_code - 0xA0]) {
/* Change the pad caps. */
gst_mpeg_demux_lpcm_set_caps ((*outstream)->pad,
basebuf[headerlen + 9]);
basebuf[headerlen + 9] !=
mpeg_demux->lpcm_sample_info[ps_id_code - 0xA0]) {
/* Change the pad caps. */
gst_mpeg_demux_lpcm_set_caps ((*outstream)->pad,
basebuf[headerlen + 9]);
}
/* Store the sample info. */
@ -805,7 +806,7 @@ gst_mpeg_demux_parse_pes (GstMPEGParse * mpeg_parse, GstBuffer * buffer)
datalen -= 7;
} else if (ps_id_code >= 0x20 && ps_id_code <= 0x2F) {
GST_DEBUG ("we have a subtitle_stream packet, track %d",
ps_id_code - 0x20);
ps_id_code - 0x20);
outstream = &mpeg_demux->subtitle_stream[ps_id_code - 0x20];
headerlen += 1;
datalen -= 1;
@ -843,22 +844,22 @@ gst_mpeg_demux_parse_pes (GstMPEGParse * mpeg_parse, GstBuffer * buffer)
if (id == 0xBD) {
/* private_stream_1 */
if (ps_id_code >= 0x80 && ps_id_code <= 0x87) {
/* Erase any DVD audio pads. */
gst_mpeg_demux_dvd_audio_clear (mpeg_demux, ps_id_code - 0x80);
/* Erase any DVD audio pads. */
gst_mpeg_demux_dvd_audio_clear (mpeg_demux, ps_id_code - 0x80);
name = g_strdup_printf ("private_stream_1_%d", ps_id_code - 0x80);
newtemp = gst_static_pad_template_get (&private1_factory);
name = g_strdup_printf ("private_stream_1_%d", ps_id_code - 0x80);
newtemp = gst_static_pad_template_get (&private1_factory);
} else if (ps_id_code >= 0xA0 && ps_id_code <= 0xA7) {
/* Erase any DVD audio pads. */
gst_mpeg_demux_dvd_audio_clear (mpeg_demux, ps_id_code - 0xA0);
/* Erase any DVD audio pads. */
gst_mpeg_demux_dvd_audio_clear (mpeg_demux, ps_id_code - 0xA0);
name = g_strdup_printf ("pcm_stream_%d", ps_id_code - 0xA0);
newtemp = gst_static_pad_template_get (&pcm_factory);
name = g_strdup_printf ("pcm_stream_%d", ps_id_code - 0xA0);
newtemp = gst_static_pad_template_get (&pcm_factory);
} else if (ps_id_code >= 0x20 && ps_id_code <= 0x2F) {
name = g_strdup_printf ("subtitle_stream_%d", ps_id_code - 0x20);
newtemp = gst_static_pad_template_get (&subtitle_factory);
name = g_strdup_printf ("subtitle_stream_%d", ps_id_code - 0x20);
newtemp = gst_static_pad_template_get (&subtitle_factory);
} else {
name = g_strdup_printf ("unknown_stream_%d", ps_id_code);
name = g_strdup_printf ("unknown_stream_%d", ps_id_code);
}
} else if (id == 0xBF) {
/* private_stream_2 */
@ -873,13 +874,13 @@ gst_mpeg_demux_parse_pes (GstMPEGParse * mpeg_parse, GstBuffer * buffer)
name = g_strdup_printf ("video_%02d", id - 0xE0);
newtemp = gst_static_pad_template_get (&video_src_factory);
if (!GST_MPEG_PARSE_IS_MPEG2 (mpeg_demux)) {
caps = gst_caps_new_simple ("video/mpeg",
"mpegversion", G_TYPE_INT, 1,
"systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
caps = gst_caps_new_simple ("video/mpeg",
"mpegversion", G_TYPE_INT, 1,
"systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
} else {
caps = gst_caps_new_simple ("video/mpeg",
"mpegversion", G_TYPE_INT, 2,
"systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
caps = gst_caps_new_simple ("video/mpeg",
"mpegversion", G_TYPE_INT, 2,
"systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
}
} else {
/* unknown */
@ -898,25 +899,25 @@ gst_mpeg_demux_parse_pes (GstMPEGParse * mpeg_parse, GstBuffer * buffer)
gst_pad_set_formats_function (*outpad, gst_mpeg_demux_get_src_formats);
gst_pad_set_convert_function (*outpad, gst_mpeg_parse_convert_src);
gst_pad_set_event_mask_function (*outpad,
gst_mpeg_parse_get_src_event_masks);
gst_mpeg_parse_get_src_event_masks);
gst_pad_set_event_function (*outpad, gst_mpeg_demux_handle_src_event);
gst_pad_set_query_type_function (*outpad,
gst_mpeg_parse_get_src_query_types);
gst_mpeg_parse_get_src_query_types);
gst_pad_set_query_function (*outpad, gst_mpeg_parse_handle_src_query);
gst_pad_use_explicit_caps (*outpad);
if (ps_id_code < 0xA0 || ps_id_code > 0xA7) {
gst_pad_set_explicit_caps (*outpad, caps);
gst_pad_set_explicit_caps (*outpad, caps);
} else {
gst_mpeg_demux_lpcm_set_caps (*outpad,
mpeg_demux->lpcm_sample_info[ps_id_code - 0xA0]);
gst_mpeg_demux_lpcm_set_caps (*outpad,
mpeg_demux->lpcm_sample_info[ps_id_code - 0xA0]);
}
gst_pad_set_element_private (*outpad, *outstream);
if (mpeg_demux->index)
(*outstream)->index_id =
_demux_get_writer_id (mpeg_demux->index, *outpad);
(*outstream)->index_id =
_demux_get_writer_id (mpeg_demux->index, *outpad);
} else {
g_warning ("cannot create pad %s, no template for %02x", name, id);
}
@ -935,10 +936,10 @@ gst_mpeg_demux_parse_pes (GstMPEGParse * mpeg_parse, GstBuffer * buffer)
timestamp = MPEGTIME_TO_GSTTIME (pts);
if (mpeg_demux->index) {
gst_index_add_association (mpeg_demux->index,
(*outstream)->index_id, 0,
GST_FORMAT_BYTES, GST_BUFFER_OFFSET (buffer),
GST_FORMAT_TIME, timestamp, 0);
gst_index_add_association (mpeg_demux->index,
(*outstream)->index_id, 0,
GST_FORMAT_BYTES, GST_BUFFER_OFFSET (buffer),
GST_FORMAT_TIME, timestamp, 0);
}
} else {
timestamp = GST_CLOCK_TIME_NONE;
@ -1033,10 +1034,11 @@ const GstFormat *
gst_mpeg_demux_get_src_formats (GstPad * pad)
{
static const GstFormat formats[] = {
GST_FORMAT_TIME, /* we prefer seeking on time */
GST_FORMAT_TIME, /* we prefer seeking on time */
GST_FORMAT_BYTES,
0
};
return formats;
}
@ -1052,19 +1054,19 @@ index_seek (GstPad * pad, GstEvent * event, gint64 * offset)
GST_EVENT_SEEK_FORMAT (event), GST_EVENT_SEEK_OFFSET (event));
if (!entry) {
GST_CAT_WARNING (GST_CAT_SEEK, "%s:%s index %s %" G_GINT64_FORMAT
" -> failed",
GST_DEBUG_PAD_NAME (pad),
gst_format_get_details (GST_EVENT_SEEK_FORMAT (event))->nick,
GST_EVENT_SEEK_OFFSET (event));
" -> failed",
GST_DEBUG_PAD_NAME (pad),
gst_format_get_details (GST_EVENT_SEEK_FORMAT (event))->nick,
GST_EVENT_SEEK_OFFSET (event));
return FALSE;
}
if (gst_index_entry_assoc_map (entry, GST_FORMAT_BYTES, offset)) {
GST_CAT_DEBUG (GST_CAT_SEEK, "%s:%s index %s %" G_GINT64_FORMAT
" -> %" G_GINT64_FORMAT " bytes",
GST_DEBUG_PAD_NAME (pad),
gst_format_get_details (GST_EVENT_SEEK_FORMAT (event))->nick,
GST_EVENT_SEEK_OFFSET (event), *offset);
" -> %" G_GINT64_FORMAT " bytes",
GST_DEBUG_PAD_NAME (pad),
gst_format_get_details (GST_EVENT_SEEK_FORMAT (event))->nick,
GST_EVENT_SEEK_OFFSET (event), *offset);
return TRUE;
}
return FALSE;
@ -1087,12 +1089,12 @@ normal_seek (GstPad * pad, GstEvent * event, gint64 * offset)
*offset = MAX (GST_EVENT_SEEK_OFFSET (event) - adjust, 0);
GST_CAT_DEBUG (GST_CAT_SEEK, "%s:%s guestimate %" G_GINT64_FORMAT
" %s -> %" G_GINT64_FORMAT
" (total_size_bound = %" G_GINT64_FORMAT ")",
GST_DEBUG_PAD_NAME (pad),
GST_EVENT_SEEK_OFFSET (event),
gst_format_get_details (GST_EVENT_SEEK_FORMAT (event))->nick,
*offset, mpeg_demux->total_size_bound);
" %s -> %" G_GINT64_FORMAT
" (total_size_bound = %" G_GINT64_FORMAT ")",
GST_DEBUG_PAD_NAME (pad),
GST_EVENT_SEEK_OFFSET (event),
gst_format_get_details (GST_EVENT_SEEK_FORMAT (event))->nick,
*offset, mpeg_demux->total_size_bound);
}
return res;
@ -1110,23 +1112,23 @@ gst_mpeg_demux_handle_src_event (GstPad * pad, GstEvent * event)
guint64 desired_offset;
if (mpeg_demux->index)
res = index_seek (pad, event, &desired_offset);
res = index_seek (pad, event, &desired_offset);
if (!res)
res = normal_seek (pad, event, &desired_offset);
res = normal_seek (pad, event, &desired_offset);
if (res) {
GstEvent *new_event;
GstEvent *new_event;
new_event =
gst_event_new_seek (GST_EVENT_SEEK_TYPE (event), desired_offset);
res = gst_mpeg_parse_handle_src_event (pad, new_event);
new_event =
gst_event_new_seek (GST_EVENT_SEEK_TYPE (event), desired_offset);
res = gst_mpeg_parse_handle_src_event (pad, new_event);
}
gst_event_unref (event);
break;
}
case GST_EVENT_NAVIGATION:
return gst_pad_send_event (GST_PAD_PEER (GST_MPEG_PARSE (mpeg_demux)->
sinkpad), event);
sinkpad), event);
break;
default:
gst_event_unref (event);

View file

@ -161,9 +161,9 @@ parse_chunk (GstMPEGPacketize * packetize)
if (offset == chunksize) {
chunksize =
gst_bytestream_peek_bytes (bs, (guint8 **) & buf, offset + 4096);
gst_bytestream_peek_bytes (bs, (guint8 **) & buf, offset + 4096);
if (chunksize == 0)
return NULL;
return NULL;
chunksize += offset;
}
}
@ -206,7 +206,7 @@ find_start_code (GstMPEGPacketize * packetize)
chunksize = gst_bytestream_peek_bytes (bs, (guint8 **) & buf, 4096);
if (chunksize == 0)
return FALSE;
return FALSE;
offset = 0;
}
@ -232,46 +232,46 @@ gst_mpeg_packetize_read (GstMPEGPacketize * packetize)
else {
GST_DEBUG ("packetize: have chunk 0x%02X", packetize->id);
if (packetize->type == GST_MPEG_PACKETIZE_SYSTEM) {
if (packetize->resync) {
if (packetize->id != PACK_START_CODE) {
gst_bytestream_flush_fast (packetize->bs, 4);
continue;
}
if (packetize->resync) {
if (packetize->id != PACK_START_CODE) {
gst_bytestream_flush_fast (packetize->bs, 4);
continue;
}
packetize->resync = FALSE;
}
switch (packetize->id) {
case PACK_START_CODE:
outbuf = parse_packhead (packetize);
if (!outbuf)
got_event = TRUE;
break;
case SYS_HEADER_START_CODE:
outbuf = parse_generic (packetize);
if (!outbuf)
got_event = TRUE;
break;
case ISO11172_END_START_CODE:
outbuf = parse_end (packetize);
if (!outbuf)
got_event = TRUE;
break;
default:
if (packetize->MPEG2 && ((packetize->id < 0xBD)
|| (packetize->id > 0xFE))) {
gst_bytestream_flush (packetize->bs, 4);
g_warning ("packetize: ******** unknown id 0x%02X",
packetize->id);
} else {
outbuf = parse_generic (packetize);
if (!outbuf)
got_event = TRUE;
}
}
packetize->resync = FALSE;
}
switch (packetize->id) {
case PACK_START_CODE:
outbuf = parse_packhead (packetize);
if (!outbuf)
got_event = TRUE;
break;
case SYS_HEADER_START_CODE:
outbuf = parse_generic (packetize);
if (!outbuf)
got_event = TRUE;
break;
case ISO11172_END_START_CODE:
outbuf = parse_end (packetize);
if (!outbuf)
got_event = TRUE;
break;
default:
if (packetize->MPEG2 && ((packetize->id < 0xBD)
|| (packetize->id > 0xFE))) {
gst_bytestream_flush (packetize->bs, 4);
g_warning ("packetize: ******** unknown id 0x%02X",
packetize->id);
} else {
outbuf = parse_generic (packetize);
if (!outbuf)
got_event = TRUE;
}
}
} else if (packetize->type == GST_MPEG_PACKETIZE_VIDEO) {
outbuf = parse_chunk (packetize);
outbuf = parse_chunk (packetize);
} else {
g_assert_not_reached ();
g_assert_not_reached ();
}
}
@ -284,10 +284,10 @@ gst_mpeg_packetize_read (GstMPEGPacketize * packetize)
etype = event ? GST_EVENT_TYPE (event) : GST_EVENT_EOS;
switch (etype) {
case GST_EVENT_DISCONTINUOUS:
GST_DEBUG ("packetize: discont\n");
gst_bytestream_flush_fast (packetize->bs, remaining);
break;
case GST_EVENT_DISCONTINUOUS:
GST_DEBUG ("packetize: discont\n");
gst_bytestream_flush_fast (packetize->bs, remaining);
break;
}
return GST_DATA (event);

View file

@ -61,14 +61,14 @@ static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/mpeg, "
"mpegversion = (int) [ 1, 2 ], " "systemstream = (boolean) TRUE")
"mpegversion = (int) [ 1, 2 ], " "systemstream = (boolean) TRUE")
);
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/mpeg, "
"mpegversion = (int) [ 1, 2 ], " "systemstream = (boolean) TRUE")
"mpegversion = (int) [ 1, 2 ], " "systemstream = (boolean) TRUE")
);
static void gst_mpeg_parse_class_init (GstMPEGParseClass * klass);
@ -116,9 +116,10 @@ gst_mpeg_parse_get_type (void)
0,
(GInstanceInitFunc) gst_mpeg_parse_init,
};
mpeg_parse_type =
g_type_register_static (GST_TYPE_ELEMENT, "GstMPEGParse",
&mpeg_parse_info, 0);
g_type_register_static (GST_TYPE_ELEMENT, "GstMPEGParse",
&mpeg_parse_info, 0);
}
return mpeg_parse_type;
}
@ -144,11 +145,11 @@ gst_mpeg_parse_class_init (GstMPEGParseClass * klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SYNC,
g_param_spec_boolean ("sync", "Sync", "Synchronize on the stream SCR",
FALSE, G_PARAM_READWRITE));
FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MAX_DISCONT,
g_param_spec_int ("max_discont", "Max Discont",
"The maximun allowed SCR discontinuity", 0, G_MAXINT,
DEFAULT_MAX_DISCONT, G_PARAM_READWRITE));
"The maximun allowed SCR discontinuity", 0, G_MAXINT,
DEFAULT_MAX_DISCONT, G_PARAM_READWRITE));
gobject_class->get_property = gst_mpeg_parse_get_property;
gobject_class->set_property = gst_mpeg_parse_set_property;
@ -257,18 +258,18 @@ gst_mpeg_parse_send_data (GstMPEGParse * mpeg_parse, GstData * data,
switch (GST_EVENT_TYPE (event)) {
default:
gst_pad_event_default (mpeg_parse->sinkpad, event);
break;
gst_pad_event_default (mpeg_parse->sinkpad, event);
break;
}
} else {
if (!GST_PAD_CAPS (mpeg_parse->srcpad)) {
gboolean mpeg2 = GST_MPEG_PACKETIZE_IS_MPEG2 (mpeg_parse->packetize);
gst_pad_set_explicit_caps (mpeg_parse->srcpad,
gst_caps_new_simple ("video/mpeg",
"mpegversion", G_TYPE_INT, (mpeg2 ? 2 : 1),
"systemstream", G_TYPE_BOOLEAN, TRUE,
"parsed", G_TYPE_BOOLEAN, TRUE, NULL));
gst_caps_new_simple ("video/mpeg",
"mpegversion", G_TYPE_INT, (mpeg2 ? 2 : 1),
"systemstream", G_TYPE_BOOLEAN, TRUE,
"parsed", G_TYPE_BOOLEAN, TRUE, NULL));
}
GST_BUFFER_TIMESTAMP (data) = time;
@ -325,8 +326,8 @@ gst_mpeg_parse_parse_packhead (GstMPEGParse * mpeg_parse, GstBuffer * buffer)
scr = (scr * 300 + scr_ext % 300) / 300;
GST_DEBUG ("%" G_GINT64_FORMAT " %d, %08x %08x %" G_GINT64_FORMAT " diff: %"
G_GINT64_FORMAT, scr, scr_ext, scr1, scr2, mpeg_parse->bytes_since_scr,
scr - mpeg_parse->current_scr);
G_GINT64_FORMAT, scr, scr_ext, scr1, scr2, mpeg_parse->bytes_since_scr,
scr - mpeg_parse->current_scr);
buf += 6;
new_rate = (GUINT32_FROM_BE ((*(guint32 *) buf)) & 0xfffffc00) >> 10;
@ -365,8 +366,8 @@ gst_mpeg_parse_parse_packhead (GstMPEGParse * mpeg_parse, GstBuffer * buffer)
if (ABS ((gint64) mpeg_parse->next_scr - (gint64) (scr_adj)) >
mpeg_parse->max_discont) {
GST_DEBUG ("discontinuity detected; expected: %" G_GUINT64_FORMAT " got: %"
G_GUINT64_FORMAT " real:%" G_GINT64_FORMAT " adjust:%" G_GINT64_FORMAT,
mpeg_parse->next_scr, scr_adj, scr, mpeg_parse->adjust);
G_GUINT64_FORMAT " real:%" G_GINT64_FORMAT " adjust:%" G_GINT64_FORMAT,
mpeg_parse->next_scr, scr_adj, scr, mpeg_parse->adjust);
mpeg_parse->adjust = mpeg_parse->next_scr - scr;
scr = mpeg_parse->next_scr;
@ -379,9 +380,9 @@ gst_mpeg_parse_parse_packhead (GstMPEGParse * mpeg_parse, GstBuffer * buffer)
if (mpeg_parse->index && GST_INDEX_IS_WRITABLE (mpeg_parse->index)) {
/* update index if any */
gst_index_add_association (mpeg_parse->index, mpeg_parse->index_id,
GST_ASSOCIATION_FLAG_KEY_UNIT,
GST_FORMAT_BYTES, GST_BUFFER_OFFSET (buffer),
GST_FORMAT_TIME, MPEGTIME_TO_GSTTIME (scr), 0);
GST_ASSOCIATION_FLAG_KEY_UNIT,
GST_FORMAT_BYTES, GST_BUFFER_OFFSET (buffer),
GST_FORMAT_TIME, MPEGTIME_TO_GSTTIME (scr), 0);
}
mpeg_parse->current_scr = scr;
@ -420,31 +421,31 @@ gst_mpeg_parse_loop (GstElement * element)
switch (id) {
case 0xb9:
break;
break;
case 0xba:
if (CLASS (mpeg_parse)->parse_packhead) {
CLASS (mpeg_parse)->parse_packhead (mpeg_parse, buffer);
}
break;
if (CLASS (mpeg_parse)->parse_packhead) {
CLASS (mpeg_parse)->parse_packhead (mpeg_parse, buffer);
}
break;
case 0xbb:
if (CLASS (mpeg_parse)->parse_syshead) {
CLASS (mpeg_parse)->parse_syshead (mpeg_parse, buffer);
}
break;
if (CLASS (mpeg_parse)->parse_syshead) {
CLASS (mpeg_parse)->parse_syshead (mpeg_parse, buffer);
}
break;
default:
if (mpeg2 && ((id < 0xBD) || (id > 0xFE))) {
g_warning ("******** unknown id 0x%02X", id);
} else {
if (mpeg2) {
if (CLASS (mpeg_parse)->parse_pes) {
CLASS (mpeg_parse)->parse_pes (mpeg_parse, buffer);
}
} else {
if (CLASS (mpeg_parse)->parse_packet) {
CLASS (mpeg_parse)->parse_packet (mpeg_parse, buffer);
}
}
}
if (mpeg2 && ((id < 0xBD) || (id > 0xFE))) {
g_warning ("******** unknown id 0x%02X", id);
} else {
if (mpeg2) {
if (CLASS (mpeg_parse)->parse_pes) {
CLASS (mpeg_parse)->parse_pes (mpeg_parse, buffer);
}
} else {
if (CLASS (mpeg_parse)->parse_packet) {
CLASS (mpeg_parse)->parse_packet (mpeg_parse, buffer);
}
}
}
}
}
@ -455,14 +456,14 @@ gst_mpeg_parse_loop (GstElement * element)
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_DISCONTINUOUS:
GST_DEBUG ("event: %d\n", GST_EVENT_TYPE (data));
GST_DEBUG ("event: %d\n", GST_EVENT_TYPE (data));
mpeg_parse->discont_pending = TRUE;
mpeg_parse->packetize->resync = TRUE;
gst_event_unref (event);
return;
mpeg_parse->discont_pending = TRUE;
mpeg_parse->packetize->resync = TRUE;
gst_event_unref (event);
return;
default:
break;
break;
}
if (CLASS (mpeg_parse)->send_data)
CLASS (mpeg_parse)->send_data (mpeg_parse, data, time);
@ -474,18 +475,18 @@ gst_mpeg_parse_loop (GstElement * element)
/* we're not sending data as long as no new SCR was found */
if (mpeg_parse->discont_pending) {
if (!mpeg_parse->scr_pending) {
if (mpeg_parse->clock && mpeg_parse->sync) {
gst_element_set_time (GST_ELEMENT (mpeg_parse),
MPEGTIME_TO_GSTTIME (mpeg_parse->current_scr));
}
if (CLASS (mpeg_parse)->handle_discont) {
CLASS (mpeg_parse)->handle_discont (mpeg_parse);
}
mpeg_parse->discont_pending = FALSE;
if (mpeg_parse->clock && mpeg_parse->sync) {
gst_element_set_time (GST_ELEMENT (mpeg_parse),
MPEGTIME_TO_GSTTIME (mpeg_parse->current_scr));
}
if (CLASS (mpeg_parse)->handle_discont) {
CLASS (mpeg_parse)->handle_discont (mpeg_parse);
}
mpeg_parse->discont_pending = FALSE;
} else {
GST_DEBUG ("waiting for SCR");
gst_buffer_unref (GST_BUFFER (data));
return;
GST_DEBUG ("waiting for SCR");
gst_buffer_unref (GST_BUFFER (data));
return;
}
}
@ -496,12 +497,12 @@ gst_mpeg_parse_loop (GstElement * element)
gboolean mpeg2 = GST_MPEG_PACKETIZE_IS_MPEG2 (mpeg_parse->packetize);
if (gst_pad_try_set_caps (mpeg_parse->sinkpad,
gst_caps_new_simple ("video/mpeg",
"mpegversion", G_TYPE_INT, (mpeg2 ? 2 : 1),
"systemstream", G_TYPE_BOOLEAN, TRUE,
"parsed", G_TYPE_BOOLEAN, TRUE, NULL)) < 0) {
GST_ELEMENT_ERROR (mpeg_parse, CORE, NEGOTIATION, (NULL), (NULL));
return;
gst_caps_new_simple ("video/mpeg",
"mpegversion", G_TYPE_INT, (mpeg2 ? 2 : 1),
"systemstream", G_TYPE_BOOLEAN, TRUE,
"parsed", G_TYPE_BOOLEAN, TRUE, NULL)) < 0) {
GST_ELEMENT_ERROR (mpeg_parse, CORE, NEGOTIATION, (NULL), (NULL));
return;
}
}
@ -521,25 +522,25 @@ gst_mpeg_parse_loop (GstElement * element)
br = mpeg_parse->mux_rate * 50;
if (br) {
if (GST_MPEG_PACKETIZE_IS_MPEG2 (mpeg_parse->packetize)) {
/*
* The mpeg spec says something like this, but that doesn't really work:
*
* mpeg_parse->next_scr = (scr * br + bss * CLOCK_FREQ) / (CLOCK_FREQ + br);
*/
mpeg_parse->next_scr = scr + (bss * CLOCK_FREQ) / br;
} else {
/* we are interpolating the scr here */
mpeg_parse->next_scr = scr + (bss * CLOCK_FREQ) / br;
}
if (GST_MPEG_PACKETIZE_IS_MPEG2 (mpeg_parse->packetize)) {
/*
* The mpeg spec says something like this, but that doesn't really work:
*
* mpeg_parse->next_scr = (scr * br + bss * CLOCK_FREQ) / (CLOCK_FREQ + br);
*/
mpeg_parse->next_scr = scr + (bss * CLOCK_FREQ) / br;
} else {
/* we are interpolating the scr here */
mpeg_parse->next_scr = scr + (bss * CLOCK_FREQ) / br;
}
} else {
/* no bitrate known */
mpeg_parse->next_scr = scr;
/* no bitrate known */
mpeg_parse->next_scr = scr;
}
GST_DEBUG ("size: %" G_GINT64_FORMAT ", total since SCR: %"
G_GINT64_FORMAT ", next SCR: %" G_GINT64_FORMAT, size, bss,
mpeg_parse->next_scr);
G_GINT64_FORMAT ", next SCR: %" G_GINT64_FORMAT, size, bss,
mpeg_parse->next_scr);
}
}
}
@ -552,6 +553,7 @@ gst_mpeg_parse_get_src_formats (GstPad * pad)
GST_FORMAT_TIME,
0
};
return formats;
}
@ -565,27 +567,27 @@ gst_mpeg_parse_convert_src (GstPad * pad, GstFormat src_format,
switch (src_format) {
case GST_FORMAT_BYTES:
switch (*dest_format) {
case GST_FORMAT_DEFAULT:
*dest_format = GST_FORMAT_TIME;
case GST_FORMAT_TIME:
if (mpeg_parse->mux_rate == 0)
res = FALSE;
else
*dest_value = src_value * GST_SECOND / (mpeg_parse->mux_rate * 50);
break;
default:
res = FALSE;
case GST_FORMAT_DEFAULT:
*dest_format = GST_FORMAT_TIME;
case GST_FORMAT_TIME:
if (mpeg_parse->mux_rate == 0)
res = FALSE;
else
*dest_value = src_value * GST_SECOND / (mpeg_parse->mux_rate * 50);
break;
default:
res = FALSE;
}
break;
case GST_FORMAT_TIME:
switch (*dest_format) {
case GST_FORMAT_DEFAULT:
*dest_format = GST_FORMAT_BYTES;
case GST_FORMAT_BYTES:
*dest_value = mpeg_parse->mux_rate * 50 * src_value / GST_SECOND;
break;
default:
res = FALSE;
case GST_FORMAT_DEFAULT:
*dest_format = GST_FORMAT_BYTES;
case GST_FORMAT_BYTES:
*dest_value = mpeg_parse->mux_rate * 50 * src_value / GST_SECOND;
break;
default:
res = FALSE;
}
break;
default:
@ -603,6 +605,7 @@ gst_mpeg_parse_get_src_query_types (GstPad * pad)
GST_QUERY_POSITION,
0
};
return types;
}
@ -619,29 +622,29 @@ gst_mpeg_parse_handle_src_query (GstPad * pad, GstQueryType type,
case GST_QUERY_TOTAL:
{
switch (*format) {
case GST_FORMAT_DEFAULT:
*format = GST_FORMAT_TIME;
/* fallthrough */
default:
src_format = GST_FORMAT_BYTES;
if (!gst_pad_query (GST_PAD_PEER (mpeg_parse->sinkpad),
GST_QUERY_TOTAL, &src_format, &src_value)) {
res = FALSE;
}
break;
case GST_FORMAT_DEFAULT:
*format = GST_FORMAT_TIME;
/* fallthrough */
default:
src_format = GST_FORMAT_BYTES;
if (!gst_pad_query (GST_PAD_PEER (mpeg_parse->sinkpad),
GST_QUERY_TOTAL, &src_format, &src_value)) {
res = FALSE;
}
break;
}
break;
}
case GST_QUERY_POSITION:
{
switch (*format) {
case GST_FORMAT_DEFAULT:
*format = GST_FORMAT_TIME;
/* fallthrough */
default:
src_format = GST_FORMAT_TIME;
src_value = MPEGTIME_TO_GSTTIME (mpeg_parse->current_scr);
break;
case GST_FORMAT_DEFAULT:
*format = GST_FORMAT_TIME;
/* fallthrough */
default:
src_format = GST_FORMAT_TIME;
src_value = MPEGTIME_TO_GSTTIME (mpeg_parse->current_scr);
break;
}
break;
}
@ -664,6 +667,7 @@ gst_mpeg_parse_get_src_event_masks (GstPad * pad)
{GST_EVENT_SEEK, GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH},
{0,}
};
return masks;
}
@ -686,10 +690,10 @@ index_seek (GstPad * pad, GstEvent * event, guint64 * offset, gint64 * scr)
*scr = GSTTIME_TO_MPEGTIME (time);
}
GST_CAT_DEBUG (GST_CAT_SEEK, "%s:%s index %s %" G_GINT64_FORMAT
" -> %" G_GINT64_FORMAT " bytes, scr=%" G_GINT64_FORMAT,
GST_DEBUG_PAD_NAME (pad),
gst_format_get_details (GST_EVENT_SEEK_FORMAT (event))->nick,
GST_EVENT_SEEK_OFFSET (event), *offset, *scr);
" -> %" G_GINT64_FORMAT " bytes, scr=%" G_GINT64_FORMAT,
GST_DEBUG_PAD_NAME (pad),
gst_format_get_details (GST_EVENT_SEEK_FORMAT (event))->nick,
GST_EVENT_SEEK_OFFSET (event), *offset, *scr);
return TRUE;
}
return FALSE;
@ -733,23 +737,23 @@ gst_mpeg_parse_handle_src_event (GstPad * pad, GstEvent * event)
/* first to to use the index if we have one */
if (mpeg_parse->index)
res = index_seek (pad, event, &desired_offset, &expected_scr);
res = index_seek (pad, event, &desired_offset, &expected_scr);
/* nothing found, try fuzzy seek */
if (!res)
res = normal_seek (pad, event, &desired_offset, &expected_scr);
res = normal_seek (pad, event, &desired_offset, &expected_scr);
if (!res)
break;
break;
GST_DEBUG ("sending seek to %" G_GINT64_FORMAT, desired_offset);
if (gst_bytestream_seek (mpeg_parse->packetize->bs, desired_offset,
GST_SEEK_METHOD_SET)) {
mpeg_parse->discont_pending = TRUE;
mpeg_parse->scr_pending = TRUE;
mpeg_parse->next_scr = expected_scr;
mpeg_parse->current_scr = -1;
mpeg_parse->adjust = 0;
res = TRUE;
GST_SEEK_METHOD_SET)) {
mpeg_parse->discont_pending = TRUE;
mpeg_parse->scr_pending = TRUE;
mpeg_parse->next_scr = expected_scr;
mpeg_parse->current_scr = -1;
mpeg_parse->adjust = 0;
res = TRUE;
}
break;
}
@ -768,9 +772,9 @@ gst_mpeg_parse_change_state (GstElement * element)
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_READY_TO_PAUSED:
if (!mpeg_parse->packetize) {
mpeg_parse->packetize =
gst_mpeg_packetize_new (mpeg_parse->sinkpad,
GST_MPEG_PACKETIZE_SYSTEM);
mpeg_parse->packetize =
gst_mpeg_packetize_new (mpeg_parse->sinkpad,
GST_MPEG_PACKETIZE_SYSTEM);
}
/* initialize parser state */
mpeg_parse->current_scr = 0;
@ -785,8 +789,8 @@ gst_mpeg_parse_change_state (GstElement * element)
break;
case GST_STATE_PAUSED_TO_READY:
if (mpeg_parse->packetize) {
gst_mpeg_packetize_destroy (mpeg_parse->packetize);
mpeg_parse->packetize = NULL;
gst_mpeg_packetize_destroy (mpeg_parse->packetize);
mpeg_parse->packetize = NULL;
}
//gst_caps_replace (&mpeg_parse->streaminfo, NULL);
break;

View file

@ -53,14 +53,14 @@ static GstStaticPadTemplate 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")
"mpegversion = (int) [ 1, 2 ], " "systemstream = (boolean) FALSE")
);
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/mpeg, "
"mpegversion = (int) [ 1, 2 ], " "systemstream = (boolean) FALSE")
"mpegversion = (int) [ 1, 2 ], " "systemstream = (boolean) FALSE")
);
static void gst_rfc2250_enc_class_init (GstRFC2250EncClass * klass);
@ -95,9 +95,10 @@ gst_rfc2250_enc_get_type (void)
0,
(GInstanceInitFunc) gst_rfc2250_enc_init,
};
rfc2250_enc_type =
g_type_register_static (GST_TYPE_ELEMENT, "GstRFC2250Enc",
&rfc2250_enc_info, 0);
g_type_register_static (GST_TYPE_ELEMENT, "GstRFC2250Enc",
&rfc2250_enc_info, 0);
}
return rfc2250_enc_type;
}
@ -127,10 +128,10 @@ gst_rfc2250_enc_class_init (GstRFC2250EncClass * klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BIT_RATE,
g_param_spec_uint ("bit_rate", "bit_rate", "bit_rate",
0, G_MAXUINT, 0, G_PARAM_READABLE));
0, G_MAXUINT, 0, G_PARAM_READABLE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MPEG2,
g_param_spec_boolean ("mpeg2", "mpeg2", "is this an mpeg2 stream",
FALSE, G_PARAM_READABLE));
FALSE, G_PARAM_READABLE));
gobject_class->get_property = gst_rfc2250_enc_get_property;
@ -207,19 +208,19 @@ gst_rfc2250_enc_add_slice (GstRFC2250Enc * enc, GstBuffer * buffer)
gint offset = 0;
while (slice_length > 0) {
GstBuffer *outbuf;
GstBuffer *newbuf;
GstBuffer *outbuf;
GstBuffer *newbuf;
outbuf =
gst_buffer_create_sub (buffer, offset, MIN (enc->remaining,
slice_length));
newbuf = gst_buffer_merge (enc->packet, outbuf);
slice_length -= GST_BUFFER_SIZE (outbuf);
offset += GST_BUFFER_SIZE (outbuf);
gst_buffer_unref (outbuf);
gst_buffer_unref (newbuf);
enc->packet = newbuf;
gst_rfc2250_enc_new_buffer (enc);
outbuf =
gst_buffer_create_sub (buffer, offset, MIN (enc->remaining,
slice_length));
newbuf = gst_buffer_merge (enc->packet, outbuf);
slice_length -= GST_BUFFER_SIZE (outbuf);
offset += GST_BUFFER_SIZE (outbuf);
gst_buffer_unref (outbuf);
gst_buffer_unref (newbuf);
enc->packet = newbuf;
gst_rfc2250_enc_new_buffer (enc);
}
gst_buffer_unref (buffer);
}
@ -246,35 +247,35 @@ gst_rfc2250_enc_loop (GstElement * element)
switch (id) {
case SEQUENCE_START_CODE:
gst_rfc2250_enc_new_buffer (enc);
enc->flags |= ENC_HAVE_SEQ;
break;
gst_rfc2250_enc_new_buffer (enc);
enc->flags |= ENC_HAVE_SEQ;
break;
case GOP_START_CODE:
if (enc->flags & ENC_HAVE_DATA) {
gst_rfc2250_enc_new_buffer (enc);
}
enc->flags |= ENC_HAVE_GOP;
break;
if (enc->flags & ENC_HAVE_DATA) {
gst_rfc2250_enc_new_buffer (enc);
}
enc->flags |= ENC_HAVE_GOP;
break;
case PICTURE_START_CODE:
if (enc->flags & ENC_HAVE_DATA) {
gst_rfc2250_enc_new_buffer (enc);
}
enc->flags |= ENC_HAVE_PIC;
break;
if (enc->flags & ENC_HAVE_DATA) {
gst_rfc2250_enc_new_buffer (enc);
}
enc->flags |= ENC_HAVE_PIC;
break;
case EXT_START_CODE:
case USER_START_CODE:
case SEQUENCE_ERROR_START_CODE:
case SEQUENCE_END_START_CODE:
break;
break;
default:
/* do this here because of the long range */
if (id >= SLICE_MIN_START_CODE && id <= SLICE_MAX_START_CODE) {
enc->flags |= ENC_HAVE_DATA;
gst_rfc2250_enc_add_slice (enc, buffer);
buffer = NULL;
break;
}
break;
/* do this here because of the long range */
if (id >= SLICE_MIN_START_CODE && id <= SLICE_MAX_START_CODE) {
enc->flags |= ENC_HAVE_DATA;
gst_rfc2250_enc_add_slice (enc, buffer);
buffer = NULL;
break;
}
break;
}
if (buffer) {
@ -301,15 +302,15 @@ gst_rfc2250_enc_change_state (GstElement * element)
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY:
if (!rfc2250_enc->packetize) {
rfc2250_enc->packetize =
gst_mpeg_packetize_new (rfc2250_enc->sinkpad,
GST_MPEG_PACKETIZE_VIDEO);
rfc2250_enc->packetize =
gst_mpeg_packetize_new (rfc2250_enc->sinkpad,
GST_MPEG_PACKETIZE_VIDEO);
}
break;
case GST_STATE_READY_TO_NULL:
if (rfc2250_enc->packetize) {
gst_mpeg_packetize_destroy (rfc2250_enc->packetize);
rfc2250_enc->packetize = NULL;
gst_mpeg_packetize_destroy (rfc2250_enc->packetize);
rfc2250_enc->packetize = NULL;
}
break;
default:
@ -336,10 +337,10 @@ gst_rfc2250_enc_get_property (GObject * object, guint prop_id, GValue * value,
break;
case ARG_MPEG2:
if (rfc2250_enc->packetize)
g_value_set_boolean (value,
GST_MPEG_PACKETIZE_IS_MPEG2 (rfc2250_enc->packetize));
g_value_set_boolean (value,
GST_MPEG_PACKETIZE_IS_MPEG2 (rfc2250_enc->packetize));
else
g_value_set_boolean (value, FALSE);
g_value_set_boolean (value, FALSE);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);

View file

@ -169,9 +169,10 @@ gst_rmdemux_get_type (void)
NULL, NULL, sizeof (GstRMDemux), 0,
(GInstanceInitFunc) gst_rmdemux_init,
};
rmdemux_type =
g_type_register_static (GST_TYPE_ELEMENT, "GstRMDemux", &rmdemux_info,
0);
g_type_register_static (GST_TYPE_ELEMENT, "GstRMDemux", &rmdemux_info,
0);
}
return rmdemux_type;
}
@ -322,14 +323,14 @@ gst_rmdemux_loop (GstElement * element)
case RMDEMUX_STATE_HEADER:
{
do {
ret = gst_bytestream_peek_bytes (rmdemux->bs, &data, 16);
if (ret < 16) {
if (!gst_rmdemux_handle_sink_event (rmdemux)) {
return;
}
} else {
break;
}
ret = gst_bytestream_peek_bytes (rmdemux->bs, &data, 16);
if (ret < 16) {
if (!gst_rmdemux_handle_sink_event (rmdemux)) {
return;
}
} else {
break;
}
} while (1);
fourcc = RMDEMUX_FOURCC_GET (data + 0);
@ -341,62 +342,62 @@ gst_rmdemux_loop (GstElement * element)
rlen = MIN (length, 4096);
switch (fourcc) {
case GST_MAKE_FOURCC ('.', 'R', 'M', 'F'):
gst_bytestream_read (rmdemux->bs, &buf, length);
data = GST_BUFFER_DATA (buf);
if (debug)
gst_rmdemux_dump__rmf (rmdemux, data + 8, rlen);
gst_rmdemux_parse__rmf (rmdemux, data + 8, rlen);
break;
case GST_MAKE_FOURCC ('P', 'R', 'O', 'P'):
gst_bytestream_read (rmdemux->bs, &buf, length);
data = GST_BUFFER_DATA (buf);
if (debug)
gst_rmdemux_dump_prop (rmdemux, data + 8, rlen);
gst_rmdemux_parse_prop (rmdemux, data + 8, rlen);
break;
case GST_MAKE_FOURCC ('M', 'D', 'P', 'R'):
gst_bytestream_read (rmdemux->bs, &buf, length);
data = GST_BUFFER_DATA (buf);
if (debug)
gst_rmdemux_dump_mdpr (rmdemux, data + 8, rlen);
gst_rmdemux_parse_mdpr (rmdemux, data + 8, rlen);
break;
case GST_MAKE_FOURCC ('I', 'N', 'D', 'X'):
gst_bytestream_read (rmdemux->bs, &buf, length);
data = GST_BUFFER_DATA (buf);
if (debug)
gst_rmdemux_dump_indx (rmdemux, data + 8, rlen);
gst_rmdemux_parse_indx (rmdemux, data + 8, rlen);
break;
case GST_MAKE_FOURCC ('D', 'A', 'T', 'A'):
rmdemux->data_offset = rmdemux->offset + 10;
if (debug)
gst_rmdemux_dump_data (rmdemux, data + 8, rlen);
gst_rmdemux_parse_data (rmdemux, data + 8, rlen);
break;
case GST_MAKE_FOURCC ('C', 'O', 'N', 'T'):
gst_bytestream_read (rmdemux->bs, &buf, length);
data = GST_BUFFER_DATA (buf);
if (debug)
gst_rmdemux_dump_cont (rmdemux, data + 8, rlen);
gst_rmdemux_parse_cont (rmdemux, data + 8, rlen);
break;
default:
g_print ("unknown fourcc " GST_FOURCC_FORMAT "\n",
GST_FOURCC_ARGS (fourcc));
break;
case GST_MAKE_FOURCC ('.', 'R', 'M', 'F'):
gst_bytestream_read (rmdemux->bs, &buf, length);
data = GST_BUFFER_DATA (buf);
if (debug)
gst_rmdemux_dump__rmf (rmdemux, data + 8, rlen);
gst_rmdemux_parse__rmf (rmdemux, data + 8, rlen);
break;
case GST_MAKE_FOURCC ('P', 'R', 'O', 'P'):
gst_bytestream_read (rmdemux->bs, &buf, length);
data = GST_BUFFER_DATA (buf);
if (debug)
gst_rmdemux_dump_prop (rmdemux, data + 8, rlen);
gst_rmdemux_parse_prop (rmdemux, data + 8, rlen);
break;
case GST_MAKE_FOURCC ('M', 'D', 'P', 'R'):
gst_bytestream_read (rmdemux->bs, &buf, length);
data = GST_BUFFER_DATA (buf);
if (debug)
gst_rmdemux_dump_mdpr (rmdemux, data + 8, rlen);
gst_rmdemux_parse_mdpr (rmdemux, data + 8, rlen);
break;
case GST_MAKE_FOURCC ('I', 'N', 'D', 'X'):
gst_bytestream_read (rmdemux->bs, &buf, length);
data = GST_BUFFER_DATA (buf);
if (debug)
gst_rmdemux_dump_indx (rmdemux, data + 8, rlen);
gst_rmdemux_parse_indx (rmdemux, data + 8, rlen);
break;
case GST_MAKE_FOURCC ('D', 'A', 'T', 'A'):
rmdemux->data_offset = rmdemux->offset + 10;
if (debug)
gst_rmdemux_dump_data (rmdemux, data + 8, rlen);
gst_rmdemux_parse_data (rmdemux, data + 8, rlen);
break;
case GST_MAKE_FOURCC ('C', 'O', 'N', 'T'):
gst_bytestream_read (rmdemux->bs, &buf, length);
data = GST_BUFFER_DATA (buf);
if (debug)
gst_rmdemux_dump_cont (rmdemux, data + 8, rlen);
gst_rmdemux_parse_cont (rmdemux, data + 8, rlen);
break;
default:
g_print ("unknown fourcc " GST_FOURCC_FORMAT "\n",
GST_FOURCC_ARGS (fourcc));
break;
}
rmdemux->offset += length;
if (rmdemux->offset < rmdemux->length) {
ret = gst_bytestream_seek (rmdemux->bs, rmdemux->offset,
GST_SEEK_METHOD_SET);
ret = gst_bytestream_seek (rmdemux->bs, rmdemux->offset,
GST_SEEK_METHOD_SET);
} else {
rmdemux->offset = rmdemux->data_offset + 8;
rmdemux->state = RMDEMUX_STATE_PLAYING;
ret = gst_bytestream_seek (rmdemux->bs, rmdemux->offset,
GST_SEEK_METHOD_SET);
rmdemux->offset = rmdemux->data_offset + 8;
rmdemux->state = RMDEMUX_STATE_PLAYING;
ret = gst_bytestream_seek (rmdemux->bs, rmdemux->offset,
GST_SEEK_METHOD_SET);
}
break;
@ -407,19 +408,19 @@ gst_rmdemux_loop (GstElement * element)
int i;
for (i = 0; i < rmdemux->n_streams; i++) {
GstPad *pad = rmdemux->streams[i]->pad;
GstPad *pad = rmdemux->streams[i]->pad;
if (pad) {
gst_pad_push (pad, GST_DATA (gst_event_new (GST_EVENT_EOS)));
}
if (pad) {
gst_pad_push (pad, GST_DATA (gst_event_new (GST_EVENT_EOS)));
}
}
ret = gst_bytestream_peek_bytes (rmdemux->bs, &data, 1);
if (ret < 1) {
gst_rmdemux_handle_sink_event (rmdemux);
gst_rmdemux_handle_sink_event (rmdemux);
} else {
/* didn't expect this */
g_warning ("expected EOS event");
/* didn't expect this */
g_warning ("expected EOS event");
}
gst_element_set_eos (element);
@ -436,14 +437,14 @@ gst_rmdemux_loop (GstElement * element)
GstBuffer *buffer;
do {
ret = gst_bytestream_peek_bytes (rmdemux->bs, &data, 10);
if (ret < 10) {
if (!gst_rmdemux_handle_sink_event (rmdemux)) {
return;
}
} else {
break;
}
ret = gst_bytestream_peek_bytes (rmdemux->bs, &data, 10);
if (ret < 10) {
if (!gst_rmdemux_handle_sink_event (rmdemux)) {
return;
}
} else {
break;
}
} while (1);
length = RMDEMUX_GUINT32_GET (data + 0);
@ -451,7 +452,7 @@ gst_rmdemux_loop (GstElement * element)
timestamp = RMDEMUX_GUINT32_GET (data + 6);
unknown1 = RMDEMUX_GUINT16_GET (data + 10);
g_print ("length %d stream id %d timestamp %d unknown %d\n",
length, id, timestamp, unknown1);
length, id, timestamp, unknown1);
gst_bytestream_flush (rmdemux->bs, 12);
@ -459,20 +460,20 @@ gst_rmdemux_loop (GstElement * element)
stream = gst_rmdemux_get_stream_by_id (rmdemux, id);
if (stream->pad) {
gst_pad_push (stream->pad, GST_DATA (buffer));
gst_pad_push (stream->pad, GST_DATA (buffer));
}
rmdemux->chunk_index++;
g_print ("chunk_index %d n_chunks %d\n", rmdemux->chunk_index,
rmdemux->n_chunks);
rmdemux->n_chunks);
if (rmdemux->chunk_index < rmdemux->n_chunks) {
rmdemux->offset += length;
ret = gst_bytestream_seek (rmdemux->bs, rmdemux->offset,
GST_SEEK_METHOD_SET);
rmdemux->offset += length;
ret = gst_bytestream_seek (rmdemux->bs, rmdemux->offset,
GST_SEEK_METHOD_SET);
} else {
ret = gst_bytestream_seek (rmdemux->bs, 0, GST_SEEK_METHOD_END);
g_print ("seek to end returned %d\n", ret);
rmdemux->state = RMDEMUX_STATE_SEEKING_EOS;
ret = gst_bytestream_seek (rmdemux->bs, 0, GST_SEEK_METHOD_END);
g_print ("seek to end returned %d\n", ret);
rmdemux->state = RMDEMUX_STATE_SEEKING_EOS;
}
break;
@ -505,24 +506,24 @@ gst_rmdemux_add_stream (GstRMDemux * rmdemux, GstRMDemuxStream * stream)
{
if (stream->subtype == GST_RMDEMUX_STREAM_VIDEO) {
stream->pad =
gst_pad_new_from_template (gst_static_pad_template_get
(&gst_rmdemux_videosrc_template), g_strdup_printf ("video_%02d",
rmdemux->n_video_streams));
gst_pad_new_from_template (gst_static_pad_template_get
(&gst_rmdemux_videosrc_template), g_strdup_printf ("video_%02d",
rmdemux->n_video_streams));
if (stream->caps) {
gst_caps_set_simple (stream->caps,
"width", G_TYPE_INT, stream->width,
"height", G_TYPE_INT, stream->height, NULL);
"width", G_TYPE_INT, stream->width,
"height", G_TYPE_INT, stream->height, NULL);
}
rmdemux->n_video_streams++;
} else if (stream->subtype == GST_RMDEMUX_STREAM_AUDIO) {
stream->pad =
gst_pad_new_from_template (gst_static_pad_template_get
(&gst_rmdemux_audiosrc_template), g_strdup_printf ("audio_%02d",
rmdemux->n_audio_streams));
gst_pad_new_from_template (gst_static_pad_template_get
(&gst_rmdemux_audiosrc_template), g_strdup_printf ("audio_%02d",
rmdemux->n_audio_streams));
stream->caps = gst_caps_new_simple ("audio/a52", NULL);
gst_caps_set_simple (stream->caps,
"rate", G_TYPE_INT, (int) stream->rate,
"channels", G_TYPE_INT, stream->n_channels, NULL);
"rate", G_TYPE_INT, (int) stream->rate,
"channels", G_TYPE_INT, stream->n_channels, NULL);
rmdemux->n_audio_streams++;
} else {
g_print ("not adding stream of type %d\n", stream->subtype);
@ -576,16 +577,16 @@ re_hexdump_bytes (guint8 * ptr, int len, int offset)
g_print ("%08x: ", offset);
for (i = 0; i < 16; i++) {
if (ptr + i >= end) {
g_print (" ");
g_print (" ");
} else {
g_print ("%02x ", ptr[i]);
g_print ("%02x ", ptr[i]);
}
}
for (i = 0; i < 16; i++) {
if (ptr + i >= end) {
g_print (" ");
g_print (" ");
} else {
g_print ("%c", g_ascii_isprint (ptr[i]) ? ptr[i] : '.');
g_print ("%c", g_ascii_isprint (ptr[i]) ? ptr[i] : '.');
}
}
g_print ("\n");
@ -695,7 +696,7 @@ gst_rmdemux_parse_mdpr (GstRMDemux * rmdemux, void *data, int length)
} else {
stream_type = GST_RMDEMUX_STREAM_UNKNOWN;
g_print ("unknown stream type \"%s\",\"%s\"\n", stream1_type_string,
stream2_type_string);
stream2_type_string);
}
g_free (stream1_type_string);
g_free (stream2_type_string);
@ -728,12 +729,12 @@ gst_rmdemux_parse_mdpr (GstRMDemux * rmdemux, void *data, int length)
//re_hexdump_bytes(data + offset,10,offset);
offset += 10;
while (offset < end) {
//re_hexdump_bytes(data + offset,6,offset);
offset += 6;
offset += re_dump_pascal_string (data + offset);
//re_hexdump_bytes(data + offset,5,offset);
offset += 5;
offset += re_dump_pascal_string (data + offset);
//re_hexdump_bytes(data + offset,6,offset);
offset += 6;
offset += re_dump_pascal_string (data + offset);
//re_hexdump_bytes(data + offset,5,offset);
offset += 5;
offset += re_dump_pascal_string (data + offset);
}
}
break;

View file

@ -135,8 +135,9 @@ gst_synaesthesia_get_type (void)
0,
(GInstanceInitFunc) gst_synaesthesia_init,
};
type =
g_type_register_static (GST_TYPE_ELEMENT, "GstSynaesthesia", &info, 0);
g_type_register_static (GST_TYPE_ELEMENT, "GstSynaesthesia", &info, 0);
}
return type;
}
@ -167,13 +168,13 @@ gst_synaesthesia_class_init (GstSynaesthesiaClass * klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_WIDTH,
g_param_spec_int ("width", "Width", "The Width",
1, 2048, 320, G_PARAM_READWRITE));
1, 2048, 320, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_HEIGHT,
g_param_spec_int ("height", "Height", "The height",
1, 2048, 320, G_PARAM_READWRITE));
1, 2048, 320, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FPS,
g_param_spec_float ("fps", "FPS", "Frames per second",
0., G_MAXFLOAT, 25., G_PARAM_READWRITE));
0., G_MAXFLOAT, 25., G_PARAM_READWRITE));
gobject_class->set_property = gst_synaesthesia_set_property;
gobject_class->get_property = gst_synaesthesia_get_property;
@ -202,7 +203,7 @@ gst_synaesthesia_init (GstSynaesthesia * synaesthesia)
/* reset the initial video state */
synaesthesia->width = 320;
synaesthesia->height = 200;
synaesthesia->fps = 25.; /* desired frame rate */
synaesthesia->fps = 25.; /* desired frame rate */
}
@ -236,14 +237,14 @@ gst_synaesthesia_chain (GstPad * pad, GstData * _data)
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_DISCONTINUOUS:
{
gint64 value = 0;
gint64 value = 0;
gst_event_discont_get_value (event, GST_FORMAT_TIME, &value);
synaesthesia->next_time = value;
gst_event_discont_get_value (event, GST_FORMAT_TIME, &value);
synaesthesia->next_time = value;
}
default:
gst_pad_event_default (pad, event);
break;
gst_pad_event_default (pad, event);
break;
}
return;
}
@ -256,7 +257,7 @@ gst_synaesthesia_chain (GstPad * pad, GstData * _data)
if (GST_BUFFER_TIMESTAMP (bufin) < synaesthesia->next_time
|| samples_in < 1024) {
GST_DEBUG ("timestamp is %" G_GUINT64_FORMAT ": want >= %" G_GUINT64_FORMAT,
GST_BUFFER_TIMESTAMP (bufin), synaesthesia->next_time);
GST_BUFFER_TIMESTAMP (bufin), synaesthesia->next_time);
gst_buffer_unref (bufin);
return;
}

View file

@ -53,7 +53,7 @@
#define brTotTargetLow 5000
#define brTotTargetHigh 15000
static int autobrightness = 1; /* Whether to use automatic brightness adjust */
static int autobrightness = 1; /* Whether to use automatic brightness adjust */
static unsigned int brightFactor = 400;
static unsigned char output[syn_width * syn_height * 2];
static guint32 display[syn_width * syn_height];
@ -66,7 +66,7 @@ static double fftout_r[FFT_BUFFER_SIZE];
static double fftmult[FFT_BUFFER_SIZE / 2 + 1];
static double corr_l[FFT_BUFFER_SIZE];
static double corr_r[FFT_BUFFER_SIZE];
static int clarity[FFT_BUFFER_SIZE]; /* Surround sound */
static int clarity[FFT_BUFFER_SIZE]; /* Surround sound */
static double cosTable[FFT_BUFFER_SIZE];
static double negSinTable[FFT_BUFFER_SIZE];
static int bitReverse[FFT_BUFFER_SIZE];
@ -162,7 +162,7 @@ synaescope_coreGo (void)
corr_l[i] = sqrt (aa = (x1 + x2) * (x1 + x2) + (y1 - y2) * (y1 - y2));
corr_r[i] = sqrt (bb = (x1 - x2) * (x1 - x2) + (y1 + y2) * (y1 + y2));
clarity[i] = (int) (
((x1 + x2) * (x1 - x2) + (y1 + y2) * (y1 - y2)) / (aa + bb) * 256);
((x1 + x2) * (x1 - x2) + (y1 + y2) * (y1 - y2)) / (aa + bb) * 256);
}
/* Asger Alstrupt's optimized 32 bit fade */
@ -173,16 +173,16 @@ synaescope_coreGo (void)
/*Bytewize version was: *(ptr++) -= *ptr+(*ptr>>1)>>4; */
if (*ptr) {
if (*ptr & 0xf0f0f0f0) {
*ptr = *ptr - ((*ptr & 0xf0f0f0f0) >> 4) - ((*ptr & 0xe0e0e0e0) >> 5);
*ptr = *ptr - ((*ptr & 0xf0f0f0f0) >> 4) - ((*ptr & 0xe0e0e0e0) >> 5);
} else {
*ptr = (*ptr * 14 >> 4) & 0x0f0f0f0f;
/*Should be 29/32 to be consistent. Who cares. This is totally */
/* hacked anyway. */
/*unsigned char *subptr = (unsigned char*)(ptr++); */
/*subptr[0] = (int)subptr[0] * 29 / 32; */
/*subptr[1] = (int)subptr[0] * 29 / 32; */
/*subptr[2] = (int)subptr[0] * 29 / 32; */
/*subptr[3] = (int)subptr[0] * 29 / 32; */
*ptr = (*ptr * 14 >> 4) & 0x0f0f0f0f;
/*Should be 29/32 to be consistent. Who cares. This is totally */
/* hacked anyway. */
/*unsigned char *subptr = (unsigned char*)(ptr++); */
/*subptr[0] = (int)subptr[0] * 29 / 32; */
/*subptr[1] = (int)subptr[0] * 29 / 32; */
/*subptr[2] = (int)subptr[0] * 29 / 32; */
/*subptr[3] = (int)subptr[0] * 29 / 32; */
}
}
ptr++;
@ -210,38 +210,38 @@ synaescope_coreGo (void)
br1 = br * (clarity[i] + 128) >> 8;
br2 = br * (128 - clarity[i]) >> 8;
if (br1 < 0)
br1 = 0;
br1 = 0;
else if (br1 > 255)
br1 = 255;
br1 = 255;
if (br2 < 0)
br2 = 0;
br2 = 0;
else if (br2 > 255)
br2 = 255;
br2 = 255;
/*unsigned char *p = output+ h*2+(164-((i<<8)>>FFT_BUFFER_SIZE_LOG))*(syn_width*2); */
if (px < 30 || py < 30 || px > syn_width - 30 || py > syn_height - 30) {
addPixel (output, px, py, br1, br2);
for (j = 1; br1 > 0 || br2 > 0;
j++, br1 = scaleDown[br1], br2 = scaleDown[br2]) {
addPixel (output, px + j, py, br1, br2);
addPixel (output, px, py + j, br1, br2);
addPixel (output, px - j, py, br1, br2);
addPixel (output, px, py - j, br1, br2);
}
addPixel (output, px, py, br1, br2);
for (j = 1; br1 > 0 || br2 > 0;
j++, br1 = scaleDown[br1], br2 = scaleDown[br2]) {
addPixel (output, px + j, py, br1, br2);
addPixel (output, px, py + j, br1, br2);
addPixel (output, px - j, py, br1, br2);
addPixel (output, px, py - j, br1, br2);
}
} else {
unsigned char *p = output + px * 2 + py * syn_width * 2, *p1 = p, *p2 =
p, *p3 = p, *p4 = p;
addPixelFast (p, br1, br2);
for (; br1 > 0 || br2 > 0; br1 = scaleDown[br1], br2 = scaleDown[br2]) {
p1 += 2;
addPixelFast (p1, br1, br2);
p2 -= 2;
addPixelFast (p2, br1, br2);
p3 += syn_width * 2;
addPixelFast (p3, br1, br2);
p4 -= syn_width * 2;
addPixelFast (p4, br1, br2);
}
unsigned char *p = output + px * 2 + py * syn_width * 2, *p1 = p, *p2 =
p, *p3 = p, *p4 = p;
addPixelFast (p, br1, br2);
for (; br1 > 0 || br2 > 0; br1 = scaleDown[br1], br2 = scaleDown[br2]) {
p1 += 2;
addPixelFast (p1, br1, br2);
p2 -= 2;
addPixelFast (p2, br1, br2);
p3 += syn_width * 2;
addPixelFast (p3, br1, br2);
p4 -= syn_width * 2;
addPixelFast (p4, br1, br2);
}
}
}
}
@ -253,16 +253,16 @@ synaescope_coreGo (void)
if (brightMax != brightMin) {
brTotTarget -= ((brTotTargetHigh - brTotTargetLow) *
(brightFactor - brightMin)) / (brightMax - brightMin);
(brightFactor - brightMin)) / (brightMax - brightMin);
}
if (brtot < brTotTarget) {
brightFactor += brightInc;
if (brightFactor > brightMax)
brightFactor = brightMax;
brightFactor = brightMax;
} else {
brightFactor -= brightDec;
if (brightFactor < brightMin)
brightFactor = brightMin;
brightFactor = brightMin;
}
/* printf("brtot: %ld\tbrightFactor: %d\tbrTotTarget: %d\n",
brtot, brightFactor, brTotTarget); */
@ -462,7 +462,7 @@ init_synaescope ()
/* intensity - this helps correct for that. */
mult *= log (i + 1) / log (2);
mult *= 3; /* Adhoc parameter, looks about right for me. */
mult *= 3; /* Adhoc parameter, looks about right for me. */
fftmult[i] = mult;
}
@ -496,14 +496,14 @@ synaes_fft (double *x, double *y)
int i;
for (i = j; i < FFT_BUFFER_SIZE; i += n1) {
int l = i + n2;
double xt = x[i] - x[l];
double yt = y[i] - y[l];
int l = i + n2;
double xt = x[i] - x[l];
double yt = y[i] - y[l];
x[i] = (x[i] + x[l]);
y[i] = (y[i] + y[l]);
x[l] = xt * c - yt * s;
y[l] = xt * s + yt * c;
x[i] = (x[i] + x[l]);
y[i] = (y[i] + y[l]);
x[l] = xt * c - yt * s;
y[l] = xt * s + yt * c;
}
}
}