summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2010-10-06 16:43:27 +0200
committerWim Taymans <wim.taymans@collabora.co.uk>2010-10-06 16:43:27 +0200
commit393ad5c764d2c5e52b71e24dbf9d793d6678a27c (patch)
tree14f9d152194c32aa57e263150a493d3785c5f716
parentb20c1252b6c99aeb70a043115cbe8c1b32172ca9 (diff)
ffcodecmap: avoid setting large framerates
When the framerate is bigger than 1000/1, set it to 0/1 instead. This avoids letting the videosink do QoS on these very small frame durations.
-rw-r--r--ext/ffmpeg/gstffmpegcodecmap.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/ext/ffmpeg/gstffmpegcodecmap.c b/ext/ffmpeg/gstffmpegcodecmap.c
index a4293a2..45581a5 100644
--- a/ext/ffmpeg/gstffmpegcodecmap.c
+++ b/ext/ffmpeg/gstffmpegcodecmap.c
@@ -195,12 +195,23 @@ gst_ff_vid_caps_new (AVCodecContext * context, enum CodecID codec_id,
/* fixed, non probing context */
if (context != NULL && context->width != -1) {
+ gint num, denom;
+
caps = gst_caps_new_simple (mimetype,
"width", G_TYPE_INT, context->width,
- "height", G_TYPE_INT, context->height,
- "framerate", GST_TYPE_FRACTION,
- context->time_base.den / context->ticks_per_frame,
- context->time_base.num, NULL);
+ "height", G_TYPE_INT, context->height, NULL);
+
+ num = context->time_base.den / context->ticks_per_frame;
+ denom = context->time_base.num;
+
+ if (gst_util_fraction_compare (num, denom, 1000, 1) > 0) {
+ GST_LOG ("excessive framerate: %d/%d, -> 0/1", num, denom);
+ num = 0;
+ denom = 1;
+ }
+ GST_LOG ("setting framerate: %d/%d", num, denom);
+ gst_caps_set_simple (caps,
+ "framerate", GST_TYPE_FRACTION, num, denom, NULL);
} else {
/* so we are after restricted caps in this case */
switch (codec_id) {