From 1b35856376a04fa72c29c8850324437cb2a38d3c Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Tue, 31 Jan 2006 15:36:13 +0000 Subject: [PATCH] sys/v4l/gstv4lsrc.c (gst_v4lsrc_set_caps): Don't segfault if the caps being set doesn't have a framerate value. Basic... Original commit message from CVS: 2006-01-31 Andy Wingo * sys/v4l/gstv4lsrc.c (gst_v4lsrc_set_caps): Don't segfault if the caps being set doesn't have a framerate value. Basically a stopgap measure. * ext/ogg/gstoggmux.c (GST_BUFFER_END_TIME): New macro. Not technically correct enough to put into core though. (gst_ogg_mux_dequeue_page): Use END_TIME instead of TIMESTAMP + DURATION. Fixes theoraenc ! oggmux. * sys/v4l/gstv4lsrc.c (gst_v4lsrc_fixate): Fixate to the nearest fraction, not double. --- ChangeLog | 18 +++++++++++++-- docs/libs/tmpl/gstcolorbalance.sgml | 9 -------- ext/ogg/gstoggmux.c | 17 ++++++++++----- sys/v4l/gstv4lsrc.c | 34 +++++++++++++++-------------- 4 files changed, 46 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index 11790fc811..372762ed47 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,12 +1,26 @@ +2006-01-31 Andy Wingo + + * sys/v4l/gstv4lsrc.c (gst_v4lsrc_set_caps): Don't segfault if the + caps being set doesn't have a framerate value. Basically a stopgap + measure. + + * ext/ogg/gstoggmux.c (GST_BUFFER_END_TIME): New macro. Not + technically correct enough to put into core though. + (gst_ogg_mux_dequeue_page): Use END_TIME instead of TIMESTAMP + + DURATION. Fixes theoraenc ! oggmux. + + * sys/v4l/gstv4lsrc.c (gst_v4lsrc_fixate): Fixate to the nearest + fraction, not double. + 2006-01-31 Sebastien Moutte * win32/vs7: - add vs7 project files created by Sergey Scobich + add vs7 project files created by Sergey Scobich 2006-01-30 Sebastien Moutte * win32/vs8: - add vs8 project files created by Sergey Scobich + add vs8 project files created by Sergey Scobich 2006-01-30 Andy Wingo diff --git a/docs/libs/tmpl/gstcolorbalance.sgml b/docs/libs/tmpl/gstcolorbalance.sgml index ccb0ae227b..7ac9f04e8f 100644 --- a/docs/libs/tmpl/gstcolorbalance.sgml +++ b/docs/libs/tmpl/gstcolorbalance.sgml @@ -23,15 +23,6 @@ interface for adjusting color balance settings - - - - - -@gstcolorbalance: the object which received the signal. -@arg1: -@arg2: - diff --git a/ext/ogg/gstoggmux.c b/ext/ogg/gstoggmux.c index 745ade62d9..320b59316f 100644 --- a/ext/ogg/gstoggmux.c +++ b/ext/ogg/gstoggmux.c @@ -39,6 +39,14 @@ GST_DEBUG_CATEGORY_STATIC (gst_ogg_mux_debug); #define GST_IS_OGG_MUX(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OGG_MUX)) #define GST_IS_OGG_MUX_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OGG_MUX)) +/* This isn't generally what you'd want with an end-time macro, because + technically the end time of a buffer with invalid duration is invalid. But + for sorting ogg pages this is what we want. */ +#define GST_BUFFER_END_TIME(buf) \ + (GST_BUFFER_DURATION_IS_VALID (buf) \ + ? GST_BUFFER_TIMESTAMP (buf) + GST_BUFFER_DURATION (buf) \ + : GST_BUFFER_TIMESTAMP (buf)) + #define GST_GP_FORMAT "[gp %8" G_GINT64_FORMAT "]" typedef struct _GstOggMux GstOggMux; @@ -571,12 +579,12 @@ gst_ogg_mux_dequeue_page (GstOggMux * mux, GstFlowReturn * flowret) if (buf) { /* if no oldest buffer yet, take this one */ if (oldest == GST_CLOCK_TIME_NONE) { - oldest = GST_BUFFER_TIMESTAMP (buf) + GST_BUFFER_DURATION (buf); + oldest = GST_BUFFER_END_TIME (buf); opad = pad; } else { /* if we have an oldest, compare with this one */ - if (GST_BUFFER_TIMESTAMP (buf) + GST_BUFFER_DURATION (buf) < oldest) { - oldest = GST_BUFFER_TIMESTAMP (buf) + GST_BUFFER_DURATION (buf); + if (GST_BUFFER_END_TIME (buf) < oldest) { + oldest = GST_BUFFER_END_TIME (buf); opad = pad; } } @@ -589,8 +597,7 @@ gst_ogg_mux_dequeue_page (GstOggMux * mux, GstFlowReturn * flowret) buf = g_queue_pop_head (opad->pagebuffers); GST_LOG_OBJECT (opad, GST_GP_FORMAT " pushing oldest page (end time %" GST_TIME_FORMAT ")", - GST_BUFFER_OFFSET_END (buf), - GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf) + GST_BUFFER_DURATION (buf))); + GST_BUFFER_OFFSET_END (buf), GST_TIME_ARGS (GST_BUFFER_END_TIME (buf))); *flowret = gst_ogg_mux_push_buffer (mux, buf); ret = TRUE; } diff --git a/sys/v4l/gstv4lsrc.c b/sys/v4l/gstv4lsrc.c index 012e1c01a0..71671292f0 100644 --- a/sys/v4l/gstv4lsrc.c +++ b/sys/v4l/gstv4lsrc.c @@ -236,7 +236,7 @@ gst_v4lsrc_fixate (GstPad * pad, GstCaps * caps) gst_structure_fixate_field_nearest_int (structure, "width", targetwidth); gst_structure_fixate_field_nearest_int (structure, "height", targetheight); - gst_structure_fixate_field_nearest_double (structure, "framerate", 7.5); + gst_structure_fixate_field_nearest_fraction (structure, "framerate", 15, 2); v = gst_structure_get_value (structure, "format"); if (v && G_VALUE_TYPE (v) != GST_TYPE_FOURCC) { @@ -496,26 +496,28 @@ gst_v4lsrc_set_caps (GstBaseSrc * src, GstCaps * caps) gst_structure_get_int (structure, "height", &h); new_fps = gst_structure_get_value (structure, "framerate"); - GST_DEBUG_OBJECT (v4lsrc, "linking with %dx%d at %d/%d fps", w, h, - gst_value_get_fraction_numerator (new_fps), - gst_value_get_fraction_denominator (new_fps)); - /* set framerate if it's not already correct */ if (!gst_v4lsrc_get_fps (v4lsrc, &cur_fps_n, &cur_fps_d)) return FALSE; - if (gst_value_get_fraction_numerator (new_fps) != cur_fps_n || - gst_value_get_fraction_denominator (new_fps) != cur_fps_d) { - int fps_index = (gst_value_get_fraction_numerator (new_fps) * 16) / - (gst_value_get_fraction_denominator (new_fps) * 15); + if (new_fps) { + GST_DEBUG_OBJECT (v4lsrc, "linking with %dx%d at %d/%d fps", w, h, + gst_value_get_fraction_numerator (new_fps), + gst_value_get_fraction_denominator (new_fps)); - GST_DEBUG_OBJECT (v4lsrc, "Trying to set fps index %d", fps_index); - /* set bits 16 to 21 to 0 */ - vwin->flags &= (0x3F00 - 1); - /* set bits 16 to 21 to the index */ - vwin->flags |= fps_index << 16; - if (!gst_v4l_set_window_properties (GST_V4LELEMENT (v4lsrc))) { - return FALSE; + if (gst_value_get_fraction_numerator (new_fps) != cur_fps_n || + gst_value_get_fraction_denominator (new_fps) != cur_fps_d) { + int fps_index = (gst_value_get_fraction_numerator (new_fps) * 16) / + (gst_value_get_fraction_denominator (new_fps) * 15); + + GST_DEBUG_OBJECT (v4lsrc, "Trying to set fps index %d", fps_index); + /* set bits 16 to 21 to 0 */ + vwin->flags &= (0x3F00 - 1); + /* set bits 16 to 21 to the index */ + vwin->flags |= fps_index << 16; + if (!gst_v4l_set_window_properties (GST_V4LELEMENT (v4lsrc))) { + return FALSE; + } } }