[gst-cvs] gnonlin: gnlobject: Give hints as to likelyhood of branches.

Edward Hervey bilboed at kemper.freedesktop.org
Sun Apr 19 01:14:14 PDT 2009


Module: gnonlin
Branch: master
Commit: 04198df8eb02b20c59da158e5384682db5cf06e9
URL:    http://cgit.freedesktop.org/gstreamer/gnonlin/commit/?id=04198df8eb02b20c59da158e5384682db5cf06e9

Author: Edward Hervey <bilboed at bilboed.com>
Date:   Sun Apr 19 09:34:44 2009 +0200

gnlobject: Give hints as to likelyhood of branches.

---

 gnl/gnlobject.c |   70 +++++++++++++++++++++++++++++++++---------------------
 1 files changed, 43 insertions(+), 27 deletions(-)

diff --git a/gnl/gnlobject.c b/gnl/gnlobject.c
index 0c764c0..85547ab 100644
--- a/gnl/gnlobject.c
+++ b/gnl/gnlobject.c
@@ -226,7 +226,8 @@ gnl_object_to_media_time (GnlObject * object, GstClockTime otime,
       GST_TIME_ARGS (object->media_start), GST_TIME_ARGS (object->media_stop));
 
   /* limit check */
-  if ((otime < object->start) || (otime >= object->stop)) {
+  if G_UNLIKELY
+    ((otime < object->start) || (otime >= object->stop)) {
     GST_DEBUG_OBJECT (object, "ObjectTime is outside object start/stop times");
     if (otime < object->start) {
       *mtime =
@@ -241,9 +242,10 @@ gnl_object_to_media_time (GnlObject * object, GstClockTime otime,
         *mtime = object->stop;
     }
     return FALSE;
-  }
+    }
 
-  if (object->media_start == GST_CLOCK_TIME_NONE) {
+  if G_UNLIKELY
+    (object->media_start == GST_CLOCK_TIME_NONE) {
     /* no time shifting, for live sources ? */
     *mtime = otime;
   } else {
@@ -286,16 +288,19 @@ gnl_media_to_object_time (GnlObject * object, GstClockTime mtime,
 
 
   /* limit check */
-  if (object->media_start == GST_CLOCK_TIME_NONE)
-    return gnl_object_to_media_time (object, mtime, otime);
+  if G_UNLIKELY
+    (object->media_start == GST_CLOCK_TIME_NONE)
+        return gnl_object_to_media_time (object, mtime, otime);
 
-  if (mtime < object->media_start) {
+  if G_UNLIKELY
+    (mtime < object->media_start) {
     GST_DEBUG_OBJECT (object,
         "media time is before media_start, forcing to start");
     *otime = object->start;
     return FALSE;
-  } else if ((object->media_stop != GST_CLOCK_TIME_NONE)
-      && (mtime >= object->media_stop)) {
+  } else if G_UNLIKELY
+    ((object->media_stop != GST_CLOCK_TIME_NONE)
+        && (mtime >= object->media_stop)) {
     GST_DEBUG_OBJECT (object,
         "media time is at or after media_stop, forcing to stop");
     *otime = object->stop;
@@ -403,8 +408,9 @@ translate_incoming_seek (GnlObject * object, GstEvent * event)
       GST_TIME_FORMAT " -- %" GST_TIME_FORMAT, rate, format, flags, curtype,
       stoptype, GST_TIME_ARGS (cur), GST_TIME_ARGS (stop));
 
-  if (format != GST_FORMAT_TIME)
-    goto invalid_format;
+  if G_UNLIKELY
+    (format != GST_FORMAT_TIME)
+        goto invalid_format;
 
   /* convert rate */
   nrate = rate * object->rate;
@@ -412,8 +418,10 @@ translate_incoming_seek (GnlObject * object, GstEvent * event)
 
   /* convert cur */
   ncurtype = GST_SEEK_TYPE_SET;
-  if ((curtype == GST_SEEK_TYPE_SET)
-      && (gnl_object_to_media_time (object, cur, &ncur))) {
+  if G_LIKELY
+    ((curtype == GST_SEEK_TYPE_SET)
+        && (gnl_object_to_media_time (object, cur, &ncur))) {
+    /* cur is TYPE_SET and value is valid */
     if (ncur > G_MAXINT64)
       GST_WARNING_OBJECT (object, "return value too big...");
     GST_LOG_OBJECT (object, "Setting cur to %" GST_TIME_FORMAT,
@@ -428,8 +436,9 @@ translate_incoming_seek (GnlObject * object, GstEvent * event)
   }
 
   /* convert stop, we also need to limit it to object->stop */
-  if ((stoptype == GST_SEEK_TYPE_SET)
-      && (gnl_object_to_media_time (object, stop, &nstop))) {
+  if G_LIKELY
+    ((stoptype == GST_SEEK_TYPE_SET)
+        && (gnl_object_to_media_time (object, stop, &nstop))) {
     if (nstop > G_MAXINT64)
       GST_WARNING_OBJECT (object, "return value too big...");
     GST_LOG_OBJECT (object, "Setting stop to %" GST_TIME_FORMAT,
@@ -445,7 +454,8 @@ translate_incoming_seek (GnlObject * object, GstEvent * event)
 
 
   /* add accurate seekflags */
-  if (!(flags & GST_SEEK_FLAG_ACCURATE)) {
+  if G_UNLIKELY
+    (!(flags & GST_SEEK_FLAG_ACCURATE)) {
     GST_DEBUG_OBJECT (object, "Adding GST_SEEK_FLAG_ACCURATE");
     flags |= GST_SEEK_FLAG_ACCURATE;
   } else {
@@ -503,16 +513,18 @@ translate_outgoing_new_segment (GnlObject * object, GstEvent * event)
       GST_TIME_FORMAT, GST_TIME_ARGS (start), GST_TIME_ARGS (stop),
       GST_TIME_ARGS (stream));
 
-  if (format != GST_FORMAT_TIME) {
+  if G_UNLIKELY
+    (format != GST_FORMAT_TIME) {
     GST_WARNING_OBJECT (object,
         "Can't translate newsegments with format != GST_FORMAT_TIME");
     return event;
-  }
+    }
 
   gnl_media_to_object_time (object, stream, &nstream);
 
-  if (nstream > G_MAXINT64)
-    GST_WARNING_OBJECT (object, "Return value too big...");
+  if G_UNLIKELY
+    (nstream > G_MAXINT64)
+        GST_WARNING_OBJECT (object, "Return value too big...");
 
   GST_DEBUG_OBJECT (object,
       "Sending NEWSEGMENT %" GST_TIME_FORMAT " -- %" GST_TIME_FORMAT " // %"
@@ -535,11 +547,12 @@ internalpad_event_function (GstPad * internal, GstEvent * event)
 
   GST_DEBUG_OBJECT (internal, "event:%s", GST_EVENT_TYPE_NAME (event));
 
-  if (!(priv->eventfunc)) {
+  if G_UNLIKELY
+    (!(priv->eventfunc)) {
     GST_WARNING_OBJECT (internal,
         "priv->eventfunc == NULL !! What is going on ?");
     return FALSE;
-  }
+    }
 
   switch (priv->dir) {
     case GST_PAD_SRC:
@@ -578,17 +591,19 @@ translate_incoming_position_query (GnlObject * object, GstQuery * query)
   gint64 cur, cur2;
 
   gst_query_parse_position (query, &format, &cur);
-  if (format != GST_FORMAT_TIME) {
+  if G_UNLIKELY
+    (format != GST_FORMAT_TIME) {
     GST_WARNING_OBJECT (object,
         "position query is in a format different from time, returning without modifying values");
     goto beach;
-  }
+    }
 
-  if (!(gnl_media_to_object_time (object, (guint64) cur, (guint64 *) & cur2))) {
+  if G_UNLIKELY
+    (!(gnl_media_to_object_time (object, (guint64) cur, (guint64 *) & cur2))) {
     GST_WARNING_OBJECT (object,
         "Couldn't get object time for %" GST_TIME_FORMAT, GST_TIME_ARGS (cur));
     goto beach;
-  }
+    }
 
   gst_query_set_position (query, GST_FORMAT_TIME, cur2);
 
@@ -603,11 +618,12 @@ translate_incoming_duration_query (GnlObject * object, GstQuery * query)
   gint64 cur;
 
   gst_query_parse_duration (query, &format, &cur);
-  if (format != GST_FORMAT_TIME) {
+  if G_UNLIKELY
+    (format != GST_FORMAT_TIME) {
     GST_WARNING_OBJECT (object,
         "We can only handle duration queries in GST_FORMAT_TIME");
     return FALSE;
-  }
+    }
 
   gst_query_set_duration (query, GST_FORMAT_TIME, object->duration);
 





More information about the Gstreamer-commits mailing list