summaryrefslogtreecommitdiffstats
path: root/gst/goom
diff options
context:
space:
mode:
authorJan Schmidt <thaytan@mad.scientist.com>2005-11-22 22:21:37 +0000
committerJan Schmidt <thaytan@mad.scientist.com>2005-11-22 22:21:37 +0000
commit11c39abc9a99d5fcb0070988ffe0d773d9780875 (patch)
treec92b2175e0a98b9de7e969cb851c9dc8f0db59fb /gst/goom
parentdad9986cb4646c0090a9c8408c1a1d9e00869ae2 (diff)
More fractional framerate conversions
Original commit message from CVS: * ext/cairo/gsttextoverlay.c: (gst_text_overlay_init), (gst_text_overlay_setcaps), (gst_text_overlay_collected): * ext/cairo/gsttextoverlay.h: * ext/gdk_pixbuf/gstgdkpixbuf.c: (gst_gdk_pixbuf_sink_link): * ext/gdk_pixbuf/gstgdkpixbuf.h: * ext/libpng/gstpngdec.c: (gst_pngdec_init), (gst_pngdec_caps_create_and_set): * ext/libpng/gstpngdec.h: * ext/libpng/gstpngenc.c: (gst_pngenc_setcaps): * gst/alpha/gstalphacolor.c: (gst_alpha_color_set_caps): * gst/avi/gstavimux.c: (gst_avimux_init), (gst_avimux_vidsinkconnect): * gst/flx/gstflxdec.c: (gst_flxdec_chain): * gst/goom/gstgoom.c: (gst_goom_init), (gst_goom_src_setcaps), (gst_goom_src_negotiate), (gst_goom_chain): * gst/goom/gstgoom.h: * gst/matroska/matroska-demux.c: (gst_matroska_demux_video_caps): * gst/matroska/matroska-mux.c: (gst_matroska_mux_video_pad_setcaps): * sys/osxvideo/osxvideosink.h: * sys/osxvideo/osxvideosink.m: More fractional framerate conversions
Diffstat (limited to 'gst/goom')
-rw-r--r--gst/goom/gstgoom.c29
-rw-r--r--gst/goom/gstgoom.h3
2 files changed, 24 insertions, 8 deletions
diff --git a/gst/goom/gstgoom.c b/gst/goom/gstgoom.c
index 75f754dc..99173dab 100644
--- a/gst/goom/gstgoom.c
+++ b/gst/goom/gstgoom.c
@@ -174,7 +174,8 @@ gst_goom_init (GstGoom * goom)
goom->width = 320;
goom->height = 200;
- goom->fps = 25.; /* desired frame rate */
+ goom->fps_n = 25; /* desired frame rate */
+ goom->fps_d = 1; /* desired frame rate */
goom->channels = 0;
goom->sample_rate = 0;
goom->audio_basetime = GST_CLOCK_TIME_NONE;
@@ -221,14 +222,22 @@ gst_goom_src_setcaps (GstPad * pad, GstCaps * caps)
{
GstGoom *goom;
GstStructure *structure;
+ const GValue *fps;
goom = GST_GOOM (GST_PAD_PARENT (pad));
structure = gst_caps_get_structure (caps, 0);
- gst_structure_get_int (structure, "width", &goom->width);
- gst_structure_get_int (structure, "height", &goom->height);
- gst_structure_get_double (structure, "framerate", &goom->fps);
+ if (!gst_structure_get_int (structure, "width", &goom->width) ||
+ !gst_structure_get_int (structure, "height", &goom->height))
+ return FALSE;
+
+ fps = gst_structure_get_value (structure, "framerate");
+ if (fps == NULL || !GST_VALUE_HOLDS_FRACTION (fps))
+ return FALSE;
+
+ goom->fps_n = gst_value_get_fraction_numerator (fps);
+ goom->fps_d = gst_value_get_fraction_denominator (fps);
goom_set_resolution (goom->width, goom->height);
@@ -241,6 +250,7 @@ gst_goom_src_negotiate (GstGoom * goom)
GstCaps *othercaps, *target, *intersect;
GstStructure *structure;
const GstCaps *templ;
+ GValue fps = { 0 };
templ = gst_pad_get_pad_template_caps (goom->srcpad);
@@ -262,7 +272,11 @@ gst_goom_src_negotiate (GstGoom * goom)
structure = gst_caps_get_structure (target, 0);
gst_structure_fixate_field_nearest_int (structure, "width", 320);
gst_structure_fixate_field_nearest_int (structure, "height", 240);
- gst_structure_fixate_field_nearest_double (structure, "framerate", 30.0);
+
+ g_value_init (&fps, GST_TYPE_FRACTION);
+ gst_value_set_fraction (&fps, 30, 1);
+ gst_structure_fixate_field_nearest_fraction (structure, "framerate", &fps);
+ g_value_unset (&fps);
gst_pad_set_caps (goom->srcpad, target);
gst_caps_unref (target);
@@ -326,7 +340,7 @@ gst_goom_chain (GstPad * pad, GstBuffer * bufin)
goom->audio_basetime = 0;
bytesperread = GOOM_SAMPLES * goom->channels * sizeof (gint16);
- samples_per_frame = goom->sample_rate / goom->fps;
+ samples_per_frame = goom->sample_rate * goom->fps_d / goom->fps_n;
data = (gint16 *) GST_BUFFER_DATA (bufin);
gst_adapter_push (goom->adapter, bufin);
@@ -351,7 +365,8 @@ gst_goom_chain (GstPad * pad, GstBuffer * bufin)
GstClockTimeDiff frame_duration;
gint i;
- frame_duration = GST_SECOND / goom->fps;
+ frame_duration = gst_util_clock_time_scale (GST_SECOND, goom->fps_d,
+ goom->fps_n);
data = (const guint16 *) gst_adapter_peek (goom->adapter, bytesperread);
if (goom->channels == 2) {
diff --git a/gst/goom/gstgoom.h b/gst/goom/gstgoom.h
index ca5f5ce7..ea17c743 100644
--- a/gst/goom/gstgoom.h
+++ b/gst/goom/gstgoom.h
@@ -53,7 +53,8 @@ struct _GstGoom
guint64 samples_consumed;
/* video state */
- gdouble fps;
+ gint fps_n;
+ gint fps_d;
gint width;
gint height;
gint channels;