summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJan Schmidt <thaytan@mad.scientist.com>2005-11-22 16:08:37 +0000
committerJan Schmidt <thaytan@mad.scientist.com>2005-11-22 16:08:37 +0000
commit0e82871285a50bf546192d24daeb0d088f3f40d1 (patch)
tree9d2cfcd5e957ac70713563e5b9457eb7df8b2bf4 /sys
parent08cd3b973fefc94f774b2dc30297a8543691a46a (diff)
Convert elements to use fractions for their framerate.
Original commit message from CVS: * ext/libvisual/visual.c: (gst_visual_src_setcaps), (get_buffer), (gst_visual_chain): * ext/ogg/gstogmparse.c: (gst_ogm_parse_chain): * ext/theora/theoradec.c: (theora_handle_type_packet): * ext/theora/theoraenc.c: (theora_enc_sink_setcaps), (theora_enc_chain): * gst-libs/gst/riff/riff-media.c: (gst_riff_create_video_caps): * gst-libs/gst/video/video.c: (gst_video_frame_rate): * gst-libs/gst/video/video.h: * gst/ffmpegcolorspace/avcodec.h: * gst/ffmpegcolorspace/gstffmpegcodecmap.c: (gst_ffmpeg_caps_to_pixfmt): * gst/ffmpegcolorspace/gstffmpegcolorspace.c: (gst_ffmpegcsp_set_caps): * gst/videorate/gstvideorate.c: (gst_videorate_transformcaps), (gst_videorate_setcaps), (gst_videorate_blank_data), (gst_videorate_chain): * gst/videotestsrc/gstvideotestsrc.c: (gst_videotestsrc_src_fixate), (gst_videotestsrc_getcaps), (gst_videotestsrc_parse_caps), (gst_videotestsrc_setcaps), (gst_videotestsrc_event), (gst_videotestsrc_create): * gst/videotestsrc/gstvideotestsrc.h: * sys/ximage/ximagesink.c: (gst_ximagesink_xcontext_get), (gst_ximagesink_setcaps), (gst_ximagesink_change_state), (gst_ximagesink_get_times), (gst_ximagesink_init): * sys/ximage/ximagesink.h: * sys/xvimage/xvimagesink.c: (gst_xvimagesink_get_xv_support), (gst_xvimagesink_setcaps), (gst_xvimagesink_change_state), (gst_xvimagesink_get_times), (gst_xvimagesink_init): * sys/xvimage/xvimagesink.h: Convert elements to use fractions for their framerate. V4L elements to come later tonight.
Diffstat (limited to 'sys')
-rw-r--r--sys/ximage/ximagesink.c22
-rw-r--r--sys/ximage/ximagesink.h5
-rw-r--r--sys/xvimage/xvimagesink.c27
-rw-r--r--sys/xvimage/xvimagesink.h3
4 files changed, 36 insertions, 21 deletions
diff --git a/sys/ximage/ximagesink.c b/sys/ximage/ximagesink.c
index f9679b2d..d468f4a1 100644
--- a/sys/ximage/ximagesink.c
+++ b/sys/ximage/ximagesink.c
@@ -64,7 +64,7 @@ GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/x-raw-rgb, "
- "framerate = (double) [ 0.0, MAX ], "
+ "framerate = (fraction) [ 0, MAX ], "
"width = (int) [ 1, MAX ], " "height = (int) [ 1, MAX ]")
);
@@ -968,7 +968,7 @@ gst_ximagesink_xcontext_get (GstXImageSink * ximagesink)
"blue_mask", G_TYPE_INT, xcontext->visual->blue_mask,
"width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
"height", GST_TYPE_INT_RANGE, 1, G_MAXINT,
- "framerate", GST_TYPE_DOUBLE_RANGE, 0.0, G_MAXDOUBLE, NULL);
+ "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
if (ximagesink->par) {
int nom, den;
@@ -1076,7 +1076,7 @@ gst_ximagesink_setcaps (GstBaseSink * bsink, GstCaps * caps)
GstCaps *intersection;
const GValue *par;
gint new_width, new_height;
- gdouble fps;
+ const GValue *fps;
ximagesink = GST_XIMAGESINK (bsink);
@@ -1101,7 +1101,8 @@ gst_ximagesink_setcaps (GstBaseSink * bsink, GstCaps * caps)
ret &= gst_structure_get_int (structure, "width", &new_width);
ret &= gst_structure_get_int (structure, "height", &new_height);
- ret &= gst_structure_get_double (structure, "framerate", &fps);
+ fps = gst_structure_get_value (structure, "framerate");
+ ret &= (fps != NULL);
if (!ret)
return FALSE;
@@ -1122,7 +1123,8 @@ gst_ximagesink_setcaps (GstBaseSink * bsink, GstCaps * caps)
GST_VIDEO_SINK_WIDTH (ximagesink) = new_width;
GST_VIDEO_SINK_HEIGHT (ximagesink) = new_height;
- ximagesink->framerate = fps;
+ ximagesink->fps_n = gst_value_get_fraction_numerator (fps);
+ ximagesink->fps_d = gst_value_get_fraction_denominator (fps);
/* Notify application to set xwindow id now */
if (!ximagesink->xwindow) {
@@ -1199,7 +1201,8 @@ gst_ximagesink_change_state (GstElement * element, GstStateChange transition)
case GST_STATE_CHANGE_PAUSED_TO_READY:
if (ximagesink->xwindow)
gst_ximagesink_xwindow_clear (ximagesink, ximagesink->xwindow);
- ximagesink->framerate = 0;
+ ximagesink->fps_n = 0;
+ ximagesink->fps_d = 1;
GST_VIDEO_SINK_WIDTH (ximagesink) = 0;
GST_VIDEO_SINK_HEIGHT (ximagesink) = 0;
break;
@@ -1247,8 +1250,8 @@ gst_ximagesink_get_times (GstBaseSink * bsink, GstBuffer * buf,
if (GST_BUFFER_DURATION_IS_VALID (buf)) {
*end = *start + GST_BUFFER_DURATION (buf);
} else {
- if (ximagesink->framerate > 0) {
- *end = *start + GST_SECOND / ximagesink->framerate;
+ if (ximagesink->fps_n > 0) {
+ *end = *start + (GST_SECOND * ximagesink->fps_d) / ximagesink->fps_n;
}
}
}
@@ -1736,7 +1739,8 @@ gst_ximagesink_init (GstXImageSink * ximagesink)
ximagesink->event_thread = NULL;
ximagesink->running = FALSE;
- ximagesink->framerate = 0;
+ ximagesink->fps_n = 0;
+ ximagesink->fps_d = 1;
ximagesink->x_lock = g_mutex_new ();
ximagesink->flow_lock = g_mutex_new ();
diff --git a/sys/ximage/ximagesink.h b/sys/ximage/ximagesink.h
index b5c35adc..58a38ac1 100644
--- a/sys/ximage/ximagesink.h
+++ b/sys/ximage/ximagesink.h
@@ -125,7 +125,10 @@ struct _GstXImageSink {
GThread *event_thread;
gboolean running;
- gdouble framerate;
+ /* Framerate numerator and denominator */
+ gint fps_n;
+ gint fps_d;
+
GMutex *x_lock;
GMutex *flow_lock;
diff --git a/sys/xvimage/xvimagesink.c b/sys/xvimage/xvimagesink.c
index 8fa63a80..102bd112 100644
--- a/sys/xvimage/xvimagesink.c
+++ b/sys/xvimage/xvimagesink.c
@@ -70,11 +70,11 @@ static GstStaticPadTemplate gst_xvimagesink_sink_template_factory =
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/x-raw-rgb, "
- "framerate = (double) [ 0.0, MAX ], "
+ "framerate = (fraction) [ 0, MAX ], "
"width = (int) [ 1, MAX ], "
"height = (int) [ 1, MAX ]; "
"video/x-raw-yuv, "
- "framerate = (double) [ 0.0, MAX ], "
+ "framerate = (fraction) [ 0, MAX ], "
"width = (int) [ 1, MAX ], " "height = (int) [ 1, MAX ]")
);
@@ -998,7 +998,7 @@ gst_xvimagesink_get_xv_support (GstXvImageSink * xvimagesink,
"red_mask", G_TYPE_INT, formats[i].blue_mask,
"width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
"height", GST_TYPE_INT_RANGE, 1, G_MAXINT,
- "framerate", GST_TYPE_DOUBLE_RANGE, 0.0, G_MAXDOUBLE, NULL);
+ "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
break;
}
case XvYUV:
@@ -1006,7 +1006,7 @@ gst_xvimagesink_get_xv_support (GstXvImageSink * xvimagesink,
"format", GST_TYPE_FOURCC, formats[i].id,
"width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
"height", GST_TYPE_INT_RANGE, 1, G_MAXINT,
- "framerate", GST_TYPE_DOUBLE_RANGE, 0.0, G_MAXDOUBLE, NULL);
+ "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
break;
default:
g_assert_not_reached ();
@@ -1415,6 +1415,7 @@ gst_xvimagesink_setcaps (GstBaseSink * bsink, GstCaps * caps)
gint display_par_n, display_par_d; /* display's PAR */
GValue display_ratio = { 0, }; /* display w/h ratio */
const GValue *caps_par;
+ const GValue *fps;
gint num, den;
xvimagesink = GST_XVIMAGESINK (bsink);
@@ -1435,11 +1436,15 @@ gst_xvimagesink_setcaps (GstBaseSink * bsink, GstCaps * caps)
structure = gst_caps_get_structure (caps, 0);
ret = gst_structure_get_int (structure, "width", &video_width);
ret &= gst_structure_get_int (structure, "height", &video_height);
- ret &= gst_structure_get_double (structure, "framerate",
- &xvimagesink->framerate);
+ fps = gst_structure_get_value (structure, "framerate");
+ ret &= (fps != NULL);
+
if (!ret)
return FALSE;
+ xvimagesink->fps_n = gst_value_get_fraction_numerator (fps);
+ xvimagesink->fps_d = gst_value_get_fraction_denominator (fps);
+
xvimagesink->video_width = video_width;
xvimagesink->video_height = video_height;
im_format = gst_xvimagesink_get_format_from_caps (xvimagesink, caps);
@@ -1581,7 +1586,8 @@ gst_xvimagesink_change_state (GstElement * element, GstStateChange transition)
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
break;
case GST_STATE_CHANGE_PAUSED_TO_READY:
- xvimagesink->framerate = 0;
+ xvimagesink->fps_n = 0;
+ xvimagesink->fps_d = 1;
GST_VIDEO_SINK_WIDTH (xvimagesink) = 0;
GST_VIDEO_SINK_HEIGHT (xvimagesink) = 0;
break;
@@ -1625,8 +1631,8 @@ gst_xvimagesink_get_times (GstBaseSink * bsink, GstBuffer * buf,
if (GST_BUFFER_DURATION_IS_VALID (buf)) {
*end = *start + GST_BUFFER_DURATION (buf);
} else {
- if (xvimagesink->framerate > 0) {
- *end = *start + GST_SECOND / xvimagesink->framerate;
+ if (xvimagesink->fps_n > 0) {
+ *end = *start + (GST_SECOND * xvimagesink->fps_d) / xvimagesink->fps_n;
}
}
}
@@ -2147,7 +2153,8 @@ gst_xvimagesink_init (GstXvImageSink * xvimagesink)
xvimagesink->contrast = xvimagesink->brightness = 0;
xvimagesink->cb_changed = FALSE;
- xvimagesink->framerate = 0;
+ xvimagesink->fps_n = 0;
+ xvimagesink->fps_d = 0;
xvimagesink->video_width = 0;
xvimagesink->video_height = 0;
diff --git a/sys/xvimage/xvimagesink.h b/sys/xvimage/xvimagesink.h
index 41062f20..38ecdaa4 100644
--- a/sys/xvimage/xvimagesink.h
+++ b/sys/xvimage/xvimagesink.h
@@ -136,7 +136,8 @@ struct _GstXvImageSink {
GstXvImageBuffer *xvimage;
GstXvImageBuffer *cur_image;
- gdouble framerate;
+ gint fps_n;
+ gint fps_d;
gint brightness;
gint contrast;