diff --git a/configure.ac b/configure.ac
index 36dc6a7..e8ac029 100644
--- a/configure.ac
+++ b/configure.ac
@@ -308,6 +308,7 @@
 AG_GST_CHECK_PLUGIN(frei0r)
 AG_GST_CHECK_PLUGIN(gaudieffects)
 AG_GST_CHECK_PLUGIN(geometrictransform)
+AG_GST_CHECK_PLUGIN(h263parse)
 AG_GST_CHECK_PLUGIN(h264parse)
 AG_GST_CHECK_PLUGIN(hdvparse)
 AG_GST_CHECK_PLUGIN(id3tag)
@@ -1727,6 +1728,7 @@
 gst/frei0r/Makefile
 gst/gaudieffects/Makefile
 gst/geometrictransform/Makefile
+gst/h263parse/Makefile
 gst/h264parse/Makefile
 gst/hdvparse/Makefile
 gst/id3tag/Makefile
diff --git a/gst/h263parse/Makefile.am b/gst/h263parse/Makefile.am
new file mode 100644
index 0000000..3ea9c20
--- /dev/null
+++ b/gst/h263parse/Makefile.am
@@ -0,0 +1,9 @@
+plugin_LTLIBRARIES = libgsth263parse.la
+
+libgsth263parse_la_SOURCES = h263parse.c gsth263parse.c gstbaseparse.c
+libgsth263parse_la_CFLAGS = $(GST_CFLAGS)
+libgsth263parse_la_LIBADD = $(GST_BASE_LIBS) $(GST_LIBS)
+libgsth263parse_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
+libgsth263parse_la_LIBTOOLFLAGS = --tag=disable-static
+
+noinst_HEADERS = gsth263parse.h gstbaseparse.h
diff --git a/gst/h263parse/gstbaseparse.c b/gst/h263parse/gstbaseparse.c
new file mode 100644
index 0000000..7341194
--- /dev/null
+++ b/gst/h263parse/gstbaseparse.c
@@ -0,0 +1,3525 @@
+/* GStreamer
+ * Copyright (C) 2008 Nokia Corporation. All rights reserved.
+ *   Contact: Stefan Kost <stefan.kost@nokia.com>
+ * Copyright (C) 2008 Sebastian Dröge <sebastian.droege@collabora.co.uk>.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/**
+ * SECTION:gstbaseparse
+ * @short_description: Base class for stream parsers
+ * @see_also: #GstBaseTransform
+ *
+ * This base class is for parser elements that process data and splits it 
+ * into separate audio/video/whatever frames.
+ *
+ * It provides for:
+ * <itemizedlist>
+ *   <listitem><para>One sinkpad and one srcpad</para></listitem>
+ *   <listitem><para>Handles state changes</para></listitem>
+ *   <listitem><para>Does flushing</para></listitem>
+ *   <listitem><para>Push mode</para></listitem>
+ *   <listitem><para>Pull mode</para></listitem>
+ *   <listitem><para>Handles events (NEWSEGMENT/EOS/FLUSH)</para></listitem>
+ *   <listitem><para>Handles seeking in both modes</para></listitem>
+ *   <listitem><para>
+ *        Handles POSITION/DURATION/SEEKING/FORMAT/CONVERT queries
+ *   </para></listitem>
+ * </itemizedlist>
+ *
+ * The purpose of this base class is to provide a basic functionality of
+ * a parser and share a lot of rather complex code.
+ *
+ * Description of the parsing mechanism:
+ * <orderedlist>
+ * <listitem>
+ *   <itemizedlist><title>Set-up phase</title>
+ *   <listitem><para>
+ *     GstBaseParse class calls @set_sink_caps to inform the subclass about
+ *     incoming sinkpad caps. Subclass should set the srcpad caps accordingly.
+ *   </para></listitem>
+ *   <listitem><para>
+ *     GstBaseParse calls @start to inform subclass that data processing is
+ *     about to start now.
+ *   </para></listitem>
+ *   <listitem><para>
+ *      At least in this point subclass needs to tell the GstBaseParse class
+ *      how big data chunks it wants to receive (min_frame_size). It can do 
+ *      this with @gst_base_parse_set_min_frame_size.
+ *   </para></listitem>
+ *   <listitem><para>
+ *      GstBaseParse class sets up appropriate data passing mode (pull/push)
+ *      and starts to process the data.
+ *   </para></listitem>
+ *   </itemizedlist>
+ * </listitem>
+ * <listitem>
+ *   <itemizedlist>
+ *   <title>Parsing phase</title>
+ *     <listitem><para>
+ *       GstBaseParse gathers at least min_frame_size bytes of data either 
+ *       by pulling it from upstream or collecting buffers into internal
+ *       #GstAdapter.
+ *     </para></listitem>
+ *     <listitem><para>
+ *       A buffer of min_frame_size bytes is passed to subclass with
+ *       @check_valid_frame. Subclass checks the contents and returns TRUE
+ *       if the buffer contains a valid frame. It also needs to set the
+ *       @framesize according to the detected frame size. If buffer didn't
+ *       contain a valid frame, this call must return FALSE and optionally
+ *       set the @skipsize value to inform base class that how many bytes
+ *       it needs to skip in order to find a valid frame. The passed buffer
+ *       is read-only.  Note that @check_valid_frame might receive any small
+ *       amount of input data when leftover data is being drained (e.g. at EOS).
+ *     </para></listitem>
+ *     <listitem><para>
+ *       After valid frame is found, it will be passed again to subclass with
+ *       @parse_frame call. Now subclass is responsible for parsing the
+ *       frame contents and setting the caps, buffer timestamp and duration
+ *       (although the latter can also be done by GstBaseParse if it is
+ *       appropriately configured, see below).
+ *     </para></listitem>
+ *     <listitem><para>
+ *       Finally the buffer can be pushed downstream and parsing loop starts
+ *       over again.  Just prior to actually pushing the buffer in question,
+ *       it is passed to @pre_push_buffer which gives subclass yet one
+ *       last chance to examine buffer metadata, or to send some custom (tag)
+ *       events, or to perform custom (segment) filtering.
+ *     </para></listitem>
+ *     <listitem><para>
+ *       During the parsing process GstBaseParseClass will handle both srcpad and
+ *       sinkpad events. They will be passed to subclass if @event or
+ *       @src_event callbacks have been provided.
+ *     </para></listitem>
+ *   </itemizedlist>
+ * </listitem>
+ * <listitem>
+ *   <itemizedlist><title>Shutdown phase</title>
+ *   <listitem><para>
+ *     GstBaseParse class calls @stop to inform the subclass that data
+ *     parsing will be stopped.
+ *   </para></listitem>
+ *   </itemizedlist>
+ * </listitem>
+ * </orderedlist>
+ *
+ * Subclass is responsible for providing pad template caps for
+ * source and sink pads. The pads need to be named "sink" and "src". It also 
+ * needs to set the fixed caps on srcpad, when the format is ensured (e.g. 
+ * when base class calls subclass' @set_sink_caps function).
+ *
+ * This base class uses GST_FORMAT_DEFAULT as a meaning of frames. So,
+ * subclass conversion routine needs to know that conversion from
+ * GST_FORMAT_TIME to GST_FORMAT_DEFAULT must return the
+ * frame number that can be found from the given byte position.
+ *
+ * GstBaseParse uses subclasses conversion methods also for seeking (or otherwise
+ * uses its own default one, see also below).
+ *
+ * Subclass @start and @stop functions will be called to inform the beginning
+ * and end of data processing.
+ *
+ * Things that subclass need to take care of:
+ * <itemizedlist>
+ *   <listitem><para>Provide pad templates</para></listitem>
+ *   <listitem><para>
+ *      Fixate the source pad caps when appropriate
+ *   </para></listitem>
+ *   <listitem><para>
+ *      Inform base class how big data chunks should be retrieved. This is
+ *      done with @gst_base_parse_set_min_frame_size function.
+ *   </para></listitem>
+ *   <listitem><para>
+ *      Examine data chunks passed to subclass with @check_valid_frame
+ *      and tell if they contain a valid frame
+ *   </para></listitem>
+ *   <listitem><para>
+ *      Set the caps and timestamp to frame that is passed to subclass with
+ *      @parse_frame function.
+ *   </para></listitem>
+ *   <listitem><para>Provide conversion functions</para></listitem>
+ *   <listitem><para>
+ *      Update the duration information with @gst_base_parse_set_duration
+ *   </para></listitem>
+ *   <listitem><para>
+ *      Optionally passthrough using @gst_base_parse_set_passthrough
+ *   </para></listitem>
+ *   <listitem><para>
+ *      Configure various baseparse parameters using @gst_base_parse_set_seek and
+ *      @gst_base_parse_set_frame_props.
+ *   </para></listitem>
+ *   <listitem><para>
+ *      In particular, if subclass is unable to determine a duration, but
+ *      parsing (or specs) yields a frames per seconds rate, then this can be
+ *      provided to GstBaseParse to enable it to cater for
+ *      buffer time metadata (which will be taken from upstream as much as possible).
+ *      Internally keeping track of frame durations and respective
+ *      sizes that have been pushed provides GstBaseParse with an estimated bitrate.
+ *      A default @convert (used if not overriden) will then use these
+ *      rates to perform obvious conversions.  These rates are also used to update
+ *      (estimated) duration at regular frame intervals.
+ *   </para></listitem>
+ * </itemizedlist>
+ *
+ */
+
+/* TODO:
+ *  - In push mode provide a queue of adapter-"queued" buffers for upstream
+ *    buffer metadata
+ *  - Queue buffers/events until caps are set
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "gstbaseparse.h"
+
+#define MIN_FRAMES_TO_POST_BITRATE 10
+#define TARGET_DIFFERENCE          (20 * GST_SECOND)
+
+GST_DEBUG_CATEGORY_STATIC (gst_base_parse_debug);
+#define GST_CAT_DEFAULT gst_base_parse_debug
+
+/* Supported formats */
+static GstFormat fmtlist[] = {
+  GST_FORMAT_DEFAULT,
+  GST_FORMAT_BYTES,
+  GST_FORMAT_TIME,
+  0
+};
+
+#define GST_BASE_PARSE_GET_PRIVATE(obj)  \
+    (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GST_TYPE_BASE_PARSE, GstBaseParsePrivate))
+
+struct _GstBaseParsePrivate
+{
+  GstActivateMode pad_mode;
+
+  gint64 duration;
+  GstFormat duration_fmt;
+  gint64 estimated_duration;
+
+  guint min_frame_size;
+  gboolean passthrough;
+  guint fps_num, fps_den;
+  guint update_interval;
+  guint bitrate;
+  guint lead_in, lead_out;
+  GstClockTime lead_in_ts, lead_out_ts;
+  GstBaseParseSeekable seekable;
+
+  gboolean discont;
+  gboolean flushing;
+  gboolean drain;
+
+  gint64 offset;
+  gint64 sync_offset;
+  GstClockTime next_ts;
+  GstClockTime prev_ts;
+  GstClockTime frame_duration;
+  gboolean seen_keyframe;
+  gboolean is_video;
+
+  guint64 framecount;
+  guint64 bytecount;
+  guint64 data_bytecount;
+  guint64 acc_duration;
+  GstClockTime first_frame_ts;
+  gint64 first_frame_offset;
+
+  gboolean post_min_bitrate;
+  gboolean post_avg_bitrate;
+  gboolean post_max_bitrate;
+  guint min_bitrate;
+  guint avg_bitrate;
+  guint max_bitrate;
+  guint posted_avg_bitrate;
+
+  GList *pending_events;
+
+  GstBuffer *cache;
+
+  /* index entry storage, either ours or provided */
+  GstIndex *index;
+  gint index_id;
+  gboolean own_index;
+  /* seek table entries only maintained if upstream is BYTE seekable */
+  gboolean upstream_seekable;
+  gboolean upstream_has_duration;
+  gint64 upstream_size;
+  /* minimum distance between two index entries */
+  GstClockTimeDiff idx_interval;
+  /* ts and offset of last entry added */
+  GstClockTime index_last_ts;
+  guint64 index_last_offset;
+  gboolean index_last_valid;
+
+  /* timestamps currently produced are accurate, e.g. started from 0 onwards */
+  gboolean exact_position;
+  /* seek events are temporarily kept to match them with newsegments */
+  GSList *pending_seeks;
+
+  /* reverse playback */
+  GSList *buffers_pending;
+  GSList *buffers_queued;
+  GstClockTime last_ts;
+  gint64 last_offset;
+};
+
+typedef struct _GstBaseParseSeek
+{
+  GstSegment segment;
+  gboolean accurate;
+  gint64 offset;
+  GstClockTime start_ts;
+} GstBaseParseSeek;
+
+static GstElementClass *parent_class = NULL;
+
+static void gst_base_parse_class_init (GstBaseParseClass * klass);
+static void gst_base_parse_init (GstBaseParse * parse,
+    GstBaseParseClass * klass);
+
+GType
+gst_base_parse_get_type (void)
+{
+  static GType base_parse_type = 0;
+
+  if (!base_parse_type) {
+    static const GTypeInfo base_parse_info = {
+      sizeof (GstBaseParseClass),
+      (GBaseInitFunc) NULL,
+      (GBaseFinalizeFunc) NULL,
+      (GClassInitFunc) gst_base_parse_class_init,
+      NULL,
+      NULL,
+      sizeof (GstBaseParse),
+      0,
+      (GInstanceInitFunc) gst_base_parse_init,
+    };
+
+    base_parse_type = g_type_register_static (GST_TYPE_ELEMENT,
+        "GstH263BaseParseBad", &base_parse_info, G_TYPE_FLAG_ABSTRACT);
+  }
+  return base_parse_type;
+}
+
+static void gst_base_parse_finalize (GObject * object);
+
+static GstStateChangeReturn gst_base_parse_change_state (GstElement * element,
+    GstStateChange transition);
+static void gst_base_parse_reset (GstBaseParse * parse);
+
+static void gst_base_parse_set_index (GstElement * element, GstIndex * index);
+static GstIndex *gst_base_parse_get_index (GstElement * element);
+
+static gboolean gst_base_parse_sink_activate (GstPad * sinkpad);
+static gboolean gst_base_parse_sink_activate_push (GstPad * pad,
+    gboolean active);
+static gboolean gst_base_parse_sink_activate_pull (GstPad * pad,
+    gboolean active);
+static gboolean gst_base_parse_handle_seek (GstBaseParse * parse,
+    GstEvent * event);
+static void gst_base_parse_handle_tag (GstBaseParse * parse, GstEvent * event);
+
+static gboolean gst_base_parse_src_event (GstPad * pad, GstEvent * event);
+static gboolean gst_base_parse_sink_event (GstPad * pad, GstEvent * event);
+static gboolean gst_base_parse_query (GstPad * pad, GstQuery * query);
+static gboolean gst_base_parse_sink_setcaps (GstPad * pad, GstCaps * caps);
+static const GstQueryType *gst_base_parse_get_querytypes (GstPad * pad);
+
+static GstFlowReturn gst_base_parse_chain (GstPad * pad, GstBuffer * buffer);
+static void gst_base_parse_loop (GstPad * pad);
+
+static gboolean gst_base_parse_check_frame (GstBaseParse * parse,
+    GstBuffer * buffer, guint * framesize, gint * skipsize);
+
+static GstFlowReturn gst_base_parse_parse_frame (GstBaseParse * parse,
+    GstBuffer * buffer);
+
+static gboolean gst_base_parse_sink_eventfunc (GstBaseParse * parse,
+    GstEvent * event);
+
+static gboolean gst_base_parse_src_eventfunc (GstBaseParse * parse,
+    GstEvent * event);
+
+static void gst_base_parse_drain (GstBaseParse * parse);
+
+static void gst_base_parse_post_bitrates (GstBaseParse * parse,
+    gboolean post_min, gboolean post_avg, gboolean post_max);
+
+static gint64 gst_base_parse_find_offset (GstBaseParse * parse,
+    GstClockTime time, gboolean before, GstClockTime * _ts);
+static GstFlowReturn gst_base_parse_locate_time (GstBaseParse * parse,
+    GstClockTime * _time, gint64 * _offset);
+
+static GstFlowReturn gst_base_parse_process_fragment (GstBaseParse * parse,
+    gboolean push_only);
+
+static void
+gst_base_parse_clear_queues (GstBaseParse * parse)
+{
+  g_slist_foreach (parse->priv->buffers_queued, (GFunc) gst_buffer_unref, NULL);
+  g_slist_free (parse->priv->buffers_queued);
+  parse->priv->buffers_queued = NULL;
+  g_slist_foreach (parse->priv->buffers_pending, (GFunc) gst_buffer_unref,
+      NULL);
+  g_slist_free (parse->priv->buffers_pending);
+  parse->priv->buffers_pending = NULL;
+}
+
+static void
+gst_base_parse_finalize (GObject * object)
+{
+  GstBaseParse *parse = GST_BASE_PARSE (object);
+  GstEvent **p_ev;
+
+  g_object_unref (parse->adapter);
+
+  if (parse->pending_segment) {
+    p_ev = &parse->pending_segment;
+    gst_event_replace (p_ev, NULL);
+  }
+  if (parse->close_segment) {
+    p_ev = &parse->close_segment;
+    gst_event_replace (p_ev, NULL);
+  }
+
+  if (parse->priv->cache) {
+    gst_buffer_unref (parse->priv->cache);
+    parse->priv->cache = NULL;
+  }
+
+  g_list_foreach (parse->priv->pending_events, (GFunc) gst_mini_object_unref,
+      NULL);
+  g_list_free (parse->priv->pending_events);
+  parse->priv->pending_events = NULL;
+
+  if (parse->priv->index) {
+    gst_object_unref (parse->priv->index);
+    parse->priv->index = NULL;
+  }
+
+  gst_base_parse_clear_queues (parse);
+
+  G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
+gst_base_parse_class_init (GstBaseParseClass * klass)
+{
+  GObjectClass *gobject_class;
+  GstElementClass *gstelement_class;
+
+  gobject_class = G_OBJECT_CLASS (klass);
+  g_type_class_add_private (klass, sizeof (GstBaseParsePrivate));
+  parent_class = g_type_class_peek_parent (klass);
+  gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_base_parse_finalize);
+
+  gstelement_class = (GstElementClass *) klass;
+  gstelement_class->change_state =
+      GST_DEBUG_FUNCPTR (gst_base_parse_change_state);
+  gstelement_class->set_index = GST_DEBUG_FUNCPTR (gst_base_parse_set_index);
+  gstelement_class->get_index = GST_DEBUG_FUNCPTR (gst_base_parse_get_index);
+
+  /* Default handlers */
+  klass->check_valid_frame = gst_base_parse_check_frame;
+  klass->parse_frame = gst_base_parse_parse_frame;
+  klass->src_event = gst_base_parse_src_eventfunc;
+  klass->convert = gst_base_parse_convert_default;
+
+  GST_DEBUG_CATEGORY_INIT (gst_base_parse_debug, "h263baseparse", 0,
+      "baseparse element");
+}
+
+static void
+gst_base_parse_init (GstBaseParse * parse, GstBaseParseClass * bclass)
+{
+  GstPadTemplate *pad_template;
+
+  GST_DEBUG_OBJECT (parse, "gst_base_parse_init");
+
+  parse->priv = GST_BASE_PARSE_GET_PRIVATE (parse);
+
+  pad_template =
+      gst_element_class_get_pad_template (GST_ELEMENT_CLASS (bclass), "sink");
+  g_return_if_fail (pad_template != NULL);
+  parse->sinkpad = gst_pad_new_from_template (pad_template, "sink");
+  gst_pad_set_event_function (parse->sinkpad,
+      GST_DEBUG_FUNCPTR (gst_base_parse_sink_event));
+  gst_pad_set_setcaps_function (parse->sinkpad,
+      GST_DEBUG_FUNCPTR (gst_base_parse_sink_setcaps));
+  gst_pad_set_chain_function (parse->sinkpad,
+      GST_DEBUG_FUNCPTR (gst_base_parse_chain));
+  gst_pad_set_activate_function (parse->sinkpad,
+      GST_DEBUG_FUNCPTR (gst_base_parse_sink_activate));
+  gst_pad_set_activatepush_function (parse->sinkpad,
+      GST_DEBUG_FUNCPTR (gst_base_parse_sink_activate_push));
+  gst_pad_set_activatepull_function (parse->sinkpad,
+      GST_DEBUG_FUNCPTR (gst_base_parse_sink_activate_pull));
+  gst_element_add_pad (GST_ELEMENT (parse), parse->sinkpad);
+
+  GST_DEBUG_OBJECT (parse, "sinkpad created");
+
+  pad_template =
+      gst_element_class_get_pad_template (GST_ELEMENT_CLASS (bclass), "src");
+  g_return_if_fail (pad_template != NULL);
+  parse->srcpad = gst_pad_new_from_template (pad_template, "src");
+  gst_pad_set_event_function (parse->srcpad,
+      GST_DEBUG_FUNCPTR (gst_base_parse_src_event));
+  gst_pad_set_query_type_function (parse->srcpad,
+      GST_DEBUG_FUNCPTR (gst_base_parse_get_querytypes));
+  gst_pad_set_query_function (parse->srcpad,
+      GST_DEBUG_FUNCPTR (gst_base_parse_query));
+  gst_pad_use_fixed_caps (parse->srcpad);
+  gst_element_add_pad (GST_ELEMENT (parse), parse->srcpad);
+  GST_DEBUG_OBJECT (parse, "src created");
+
+  parse->adapter = gst_adapter_new ();
+
+  parse->priv->pad_mode = GST_ACTIVATE_NONE;
+
+  /* init state */
+  gst_base_parse_reset (parse);
+  GST_DEBUG_OBJECT (parse, "init ok");
+}
+
+static void
+gst_base_parse_reset (GstBaseParse * parse)
+{
+  GST_OBJECT_LOCK (parse);
+  gst_segment_init (&parse->segment, GST_FORMAT_TIME);
+  parse->priv->duration = -1;
+  parse->priv->min_frame_size = 1;
+  parse->priv->discont = TRUE;
+  parse->priv->flushing = FALSE;
+  parse->priv->offset = 0;
+  parse->priv->sync_offset = 0;
+  parse->priv->update_interval = 50;
+  parse->priv->fps_num = parse->priv->fps_den = 0;
+  parse->priv->frame_duration = GST_CLOCK_TIME_NONE;
+  parse->priv->lead_in = parse->priv->lead_out = 0;
+  parse->priv->lead_in_ts = parse->priv->lead_out_ts = 0;
+  parse->priv->seekable = GST_BASE_PARSE_SEEK_DEFAULT;
+  parse->priv->bitrate = 0;
+  parse->priv->framecount = 0;
+  parse->priv->bytecount = 0;
+  parse->priv->acc_duration = 0;
+  parse->priv->first_frame_ts = GST_CLOCK_TIME_NONE;
+  parse->priv->first_frame_offset = -1;
+  parse->priv->estimated_duration = -1;
+  parse->priv->next_ts = 0;
+  parse->priv->passthrough = FALSE;
+  parse->priv->post_min_bitrate = TRUE;
+  parse->priv->post_avg_bitrate = TRUE;
+  parse->priv->post_max_bitrate = TRUE;
+  parse->priv->min_bitrate = G_MAXUINT;
+  parse->priv->max_bitrate = 0;
+  parse->priv->avg_bitrate = 0;
+  parse->priv->posted_avg_bitrate = 0;
+
+  parse->priv->index_last_ts = 0;
+  parse->priv->index_last_offset = 0;
+  parse->priv->index_last_valid = TRUE;
+  parse->priv->upstream_seekable = FALSE;
+  parse->priv->upstream_size = 0;
+  parse->priv->upstream_has_duration = FALSE;
+  parse->priv->idx_interval = 0;
+  parse->priv->exact_position = TRUE;
+  parse->priv->seen_keyframe = FALSE;
+
+  parse->priv->last_ts = GST_CLOCK_TIME_NONE;
+  parse->priv->last_offset = 0;
+
+  if (parse->pending_segment) {
+    gst_event_unref (parse->pending_segment);
+    parse->pending_segment = NULL;
+  }
+
+  g_list_foreach (parse->priv->pending_events, (GFunc) gst_mini_object_unref,
+      NULL);
+  g_list_free (parse->priv->pending_events);
+  parse->priv->pending_events = NULL;
+
+  if (parse->priv->cache) {
+    gst_buffer_unref (parse->priv->cache);
+    parse->priv->cache = NULL;
+  }
+
+  g_slist_foreach (parse->priv->pending_seeks, (GFunc) g_free, NULL);
+  g_slist_free (parse->priv->pending_seeks);
+  parse->priv->pending_seeks = NULL;
+
+  GST_OBJECT_UNLOCK (parse);
+}
+
+/**
+ * gst_base_parse_check_frame:
+ * @parse: #GstBaseParse.
+ * @buffer: GstBuffer.
+ * @framesize: This will be set to tell the found frame size in bytes.
+ * @skipsize: Output parameter that tells how much data needs to be skipped
+ *            in order to find the following frame header.
+ *
+ * Default callback for check_valid_frame.
+ * 
+ * Returns: Always TRUE.
+ */
+static gboolean
+gst_base_parse_check_frame (GstBaseParse * parse,
+    GstBuffer * buffer, guint * framesize, gint * skipsize)
+{
+  *framesize = GST_BUFFER_SIZE (buffer);
+  *skipsize = 0;
+  return TRUE;
+}
+
+
+/**
+ * gst_base_parse_parse_frame:
+ * @parse: #GstBaseParse.
+ * @buffer: #GstBuffer.
+ *
+ * Default callback for parse_frame.
+ */
+static GstFlowReturn
+gst_base_parse_parse_frame (GstBaseParse * parse, GstBuffer * buffer)
+{
+  if (!GST_BUFFER_TIMESTAMP_IS_VALID (buffer) &&
+      GST_CLOCK_TIME_IS_VALID (parse->priv->next_ts)) {
+    GST_BUFFER_TIMESTAMP (buffer) = parse->priv->next_ts;
+  }
+  if (!GST_BUFFER_DURATION_IS_VALID (buffer) &&
+      GST_CLOCK_TIME_IS_VALID (parse->priv->frame_duration)) {
+    GST_BUFFER_DURATION (buffer) = parse->priv->frame_duration;
+  }
+  return GST_FLOW_OK;
+}
+
+/**
+ * gst_base_parse_convert:
+ * @parse: #GstBaseParse.
+ * @src_format: #GstFormat describing the source format.
+ * @src_value: Source value to be converted.
+ * @dest_format: #GstFormat defining the converted format.
+ * @dest_value: Pointer where the conversion result will be put.
+ *
+ * Converts using configured "convert" vmethod in #GstBaseParse class.
+ *
+ * Returns: TRUE if conversion was successful.
+ */
+static gboolean
+gst_base_parse_convert (GstBaseParse * parse,
+    GstFormat src_format,
+    gint64 src_value, GstFormat dest_format, gint64 * dest_value)
+{
+  GstBaseParseClass *klass = GST_BASE_PARSE_GET_CLASS (parse);
+  gboolean ret;
+
+  g_return_val_if_fail (dest_value != NULL, FALSE);
+
+  if (!klass->convert)
+    return FALSE;
+
+  ret = klass->convert (parse, src_format, src_value, dest_format, dest_value);
+
+#ifndef GST_DISABLE_GST_DEBUG
+  {
+    if (ret) {
+      if (src_format == GST_FORMAT_TIME && dest_format == GST_FORMAT_BYTES) {
+        GST_LOG_OBJECT (parse,
+            "TIME -> BYTES: %" GST_TIME_FORMAT " -> %" G_GINT64_FORMAT,
+            GST_TIME_ARGS (src_value), *dest_value);
+      } else if (dest_format == GST_FORMAT_TIME &&
+          src_format == GST_FORMAT_BYTES) {
+        GST_LOG_OBJECT (parse,
+            "BYTES -> TIME: %" G_GINT64_FORMAT " -> %" GST_TIME_FORMAT,
+            src_value, GST_TIME_ARGS (*dest_value));
+      } else {
+        GST_LOG_OBJECT (parse,
+            "%s -> %s: %" G_GINT64_FORMAT " -> %" G_GINT64_FORMAT,
+            GST_STR_NULL (gst_format_get_name (src_format)),
+            GST_STR_NULL (gst_format_get_name (dest_format)),
+            src_value, *dest_value);
+      }
+    } else {
+      GST_DEBUG_OBJECT (parse, "conversion failed");
+    }
+  }
+#endif
+
+  return ret;
+}
+
+/**
+ * gst_base_parse_sink_event:
+ * @pad: #GstPad that received the event.
+ * @event: #GstEvent to be handled.
+ *
+ * Handler for sink pad events.
+ *
+ * Returns: TRUE if the event was handled.
+ */
+static gboolean
+gst_base_parse_sink_event (GstPad * pad, GstEvent * event)
+{
+  GstBaseParse *parse;
+  GstBaseParseClass *bclass;
+  gboolean handled = FALSE;
+  gboolean ret = TRUE;
+
+  parse = GST_BASE_PARSE (gst_pad_get_parent (pad));
+  bclass = GST_BASE_PARSE_GET_CLASS (parse);
+
+  GST_DEBUG_OBJECT (parse, "handling event %d, %s", GST_EVENT_TYPE (event),
+      GST_EVENT_TYPE_NAME (event));
+
+  /* Cache all events except EOS, NEWSEGMENT and FLUSH_STOP if we have a
+   * pending segment */
+  if (parse->pending_segment && GST_EVENT_TYPE (event) != GST_EVENT_EOS
+      && GST_EVENT_TYPE (event) != GST_EVENT_NEWSEGMENT
+      && GST_EVENT_TYPE (event) != GST_EVENT_FLUSH_START
+      && GST_EVENT_TYPE (event) != GST_EVENT_FLUSH_STOP) {
+
+    if (GST_EVENT_TYPE (event) == GST_EVENT_TAG)
+      /* See if any bitrate tags were posted */
+      gst_base_parse_handle_tag (parse, event);
+
+    parse->priv->pending_events =
+        g_list_append (parse->priv->pending_events, event);
+    ret = TRUE;
+  } else {
+
+    if (GST_EVENT_TYPE (event) == GST_EVENT_EOS &&
+        parse->priv->framecount < MIN_FRAMES_TO_POST_BITRATE)
+      /* We've not posted bitrate tags yet - do so now */
+      gst_base_parse_post_bitrates (parse, TRUE, TRUE, TRUE);
+
+    if (bclass->event)
+      handled = bclass->event (parse, event);
+
+    if (!handled)
+      handled = gst_base_parse_sink_eventfunc (parse, event);
+
+    if (!handled)
+      ret = gst_pad_event_default (pad, event);
+  }
+
+  gst_object_unref (parse);
+  GST_DEBUG_OBJECT (parse, "event handled");
+  return ret;
+}
+
+
+/**
+ * gst_base_parse_sink_eventfunc:
+ * @parse: #GstBaseParse.
+ * @event: #GstEvent to be handled.
+ *
+ * Element-level event handler function.
+ *
+ * Returns: TRUE if the event was handled and not need forwarding.
+ */
+static gboolean
+gst_base_parse_sink_eventfunc (GstBaseParse * parse, GstEvent * event)
+{
+  gboolean handled = FALSE;
+  GstEvent **eventp;
+
+  switch (GST_EVENT_TYPE (event)) {
+    case GST_EVENT_NEWSEGMENT:
+    {
+      gdouble rate, applied_rate;
+      GstFormat format;
+      gint64 start, stop, pos, next_ts, offset = 0;
+      gboolean update;
+
+      gst_event_parse_new_segment_full (event, &update, &rate, &applied_rate,
+          &format, &start, &stop, &pos);
+
+      GST_DEBUG_OBJECT (parse, "newseg rate %g, applied rate %g, "
+          "format %d, start = %" GST_TIME_FORMAT ", stop = %" GST_TIME_FORMAT
+          ", pos = %" GST_TIME_FORMAT, rate, applied_rate, format,
+          GST_TIME_ARGS (start), GST_TIME_ARGS (stop), GST_TIME_ARGS (pos));
+
+      if (format == GST_FORMAT_BYTES) {
+        GstClockTime seg_start, seg_stop;
+        GstBaseParseSeek *seek = NULL;
+        GSList *node;
+
+        /* stop time is allowed to be open-ended, but not start & pos */
+        seg_stop = GST_CLOCK_TIME_NONE;
+        seg_start = 0;
+        offset = pos;
+
+        GST_OBJECT_LOCK (parse);
+        for (node = parse->priv->pending_seeks; node; node = node->next) {
+          GstBaseParseSeek *tmp = node->data;
+
+          if (tmp->offset == pos) {
+            seek = tmp;
+            break;
+          }
+        }
+        parse->priv->pending_seeks =
+            g_slist_remove (parse->priv->pending_seeks, seek);
+        GST_OBJECT_UNLOCK (parse);
+
+        if (seek) {
+          GST_DEBUG_OBJECT (parse,
+              "Matched newsegment to%s seek: %" GST_SEGMENT_FORMAT,
+              seek->accurate ? " accurate" : "", &seek->segment);
+          seg_start = seek->segment.start;
+          seg_stop = seek->segment.stop;
+          next_ts = seek->start_ts;
+          parse->priv->exact_position = seek->accurate;
+          g_free (seek);
+        } else {
+          /* best attempt convert */
+          /* as these are only estimates, stop is kept open-ended to avoid
+           * premature cutting */
+          gst_base_parse_convert (parse, GST_FORMAT_BYTES, start,
+              GST_FORMAT_TIME, (gint64 *) & seg_start);
+          parse->priv->exact_position = (start == 0);
+          next_ts = seg_start;
+        }
+
+        gst_event_unref (event);
+        event = gst_event_new_new_segment_full (update, rate, applied_rate,
+            GST_FORMAT_TIME, seg_start, seg_stop, seg_start);
+        format = GST_FORMAT_TIME;
+        start = seg_start;
+        stop = seg_stop;
+        GST_DEBUG_OBJECT (parse, "Converted incoming segment to TIME. "
+            "start = %" GST_TIME_FORMAT ", stop = %" GST_TIME_FORMAT,
+            GST_TIME_ARGS (seg_start), GST_TIME_ARGS (seg_stop));
+      } else if (format != GST_FORMAT_TIME) {
+        /* Unknown incoming segment format. Output a default open-ended 
+         * TIME segment */
+        gst_event_unref (event);
+        event = gst_event_new_new_segment_full (update, rate, applied_rate,
+            GST_FORMAT_TIME, 0, GST_CLOCK_TIME_NONE, 0);
+        format = GST_FORMAT_TIME;
+        next_ts = start = 0;
+        stop = GST_CLOCK_TIME_NONE;
+      } else {
+        /* not considered BYTE seekable if it is talking to us in TIME,
+         * whatever else it might claim */
+        parse->priv->upstream_seekable = FALSE;
+        next_ts = start;
+      }
+
+      gst_segment_set_newsegment_full (&parse->segment, update, rate,
+          applied_rate, format, start, stop, start);
+
+      /* save the segment for later, right before we push a new buffer so that
+       * the caps are fixed and the next linked element can receive
+       * the segment. */
+      eventp = &parse->pending_segment;
+      gst_event_replace (eventp, event);
+      gst_event_unref (event);
+      handled = TRUE;
+
+      /* but finish the current segment */
+      GST_DEBUG_OBJECT (parse, "draining current segment");
+      if (parse->segment.rate > 0.0)
+        gst_base_parse_drain (parse);
+      else
+        gst_base_parse_process_fragment (parse, FALSE);
+      gst_adapter_clear (parse->adapter);
+      parse->priv->offset = offset;
+      parse->priv->sync_offset = offset;
+      parse->priv->next_ts = next_ts;
+      parse->priv->last_ts = GST_CLOCK_TIME_NONE;
+      parse->priv->discont = TRUE;
+      parse->priv->seen_keyframe = FALSE;
+      break;
+    }
+
+    case GST_EVENT_FLUSH_START:
+      parse->priv->flushing = TRUE;
+      handled = gst_pad_push_event (parse->srcpad, event);
+      /* Wait for _chain() to exit by taking the srcpad STREAM_LOCK */
+      GST_PAD_STREAM_LOCK (parse->srcpad);
+      GST_PAD_STREAM_UNLOCK (parse->srcpad);
+
+      break;
+
+    case GST_EVENT_FLUSH_STOP:
+      gst_adapter_clear (parse->adapter);
+      gst_base_parse_clear_queues (parse);
+      parse->priv->flushing = FALSE;
+      parse->priv->discont = TRUE;
+      parse->priv->last_ts = GST_CLOCK_TIME_NONE;
+      break;
+
+    case GST_EVENT_EOS:
+      if (parse->segment.rate > 0.0)
+        gst_base_parse_drain (parse);
+      else
+        gst_base_parse_process_fragment (parse, FALSE);
+
+      /* If we STILL have zero frames processed, fire an error */
+      if (parse->priv->framecount == 0) {
+        GST_ELEMENT_ERROR (parse, STREAM, WRONG_TYPE,
+            ("No valid frames found before end of stream"), (NULL));
+      }
+      /* newsegment before eos */
+      if (parse->pending_segment) {
+        gst_pad_push_event (parse->srcpad, parse->pending_segment);
+        parse->pending_segment = NULL;
+      }
+      break;
+
+    default:
+      break;
+  }
+
+  return handled;
+}
+
+
+/**
+ * gst_base_parse_src_event:
+ * @pad: #GstPad that received the event.
+ * @event: #GstEvent that was received.
+ *
+ * Handler for source pad events.
+ *
+ * Returns: TRUE if the event was handled.
+ */
+static gboolean
+gst_base_parse_src_event (GstPad * pad, GstEvent * event)
+{
+  GstBaseParse *parse;
+  GstBaseParseClass *bclass;
+  gboolean handled = FALSE;
+  gboolean ret = TRUE;
+
+  parse = GST_BASE_PARSE (gst_pad_get_parent (pad));
+  bclass = GST_BASE_PARSE_GET_CLASS (parse);
+
+  GST_DEBUG_OBJECT (parse, "event %d, %s", GST_EVENT_TYPE (event),
+      GST_EVENT_TYPE_NAME (event));
+
+  if (bclass->src_event)
+    handled = bclass->src_event (parse, event);
+
+  if (!handled)
+    ret = gst_pad_event_default (pad, event);
+  else
+    gst_event_unref (event);
+
+  gst_object_unref (parse);
+  return ret;
+}
+
+
+/**
+ * gst_base_parse_src_eventfunc:
+ * @parse: #GstBaseParse.
+ * @event: #GstEvent that was received.
+ *
+ * Default srcpad event handler.
+ *
+ * Returns: TRUE if the event was handled and can be dropped.
+ */
+static gboolean
+gst_base_parse_src_eventfunc (GstBaseParse * parse, GstEvent * event)
+{
+  gboolean handled = FALSE;
+
+  switch (GST_EVENT_TYPE (event)) {
+    case GST_EVENT_SEEK:
+    {
+      if (parse->priv->seekable > GST_BASE_PARSE_SEEK_NONE) {
+        handled = gst_base_parse_handle_seek (parse, event);
+      }
+      break;
+    }
+    default:
+      break;
+  }
+  return handled;
+}
+
+
+/**
+ * gst_base_parse_convert_default:
+ * @parse: #GstBaseParse.
+ * @src_format: #GstFormat describing the source format.
+ * @src_value: Source value to be converted.
+ * @dest_format: #GstFormat defining the converted format.
+ * @dest_value: Pointer where the conversion result will be put.
+ *
+ * Default implementation of "convert" vmethod in #GstBaseParse class.
+ *
+ * Returns: TRUE if conversion was successful.
+ */
+gboolean
+gst_base_parse_convert_default (GstBaseParse * parse,
+    GstFormat src_format,
+    gint64 src_value, GstFormat dest_format, gint64 * dest_value)
+{
+  gboolean ret = FALSE;
+  guint64 bytes, duration;
+
+  if (G_UNLIKELY (src_format == dest_format)) {
+    *dest_value = src_value;
+    return TRUE;
+  }
+
+  if (G_UNLIKELY (src_value == -1)) {
+    *dest_value = -1;
+    return TRUE;
+  }
+
+  if (G_UNLIKELY (src_value == 0)) {
+    *dest_value = 0;
+    return TRUE;
+  }
+
+  /* need at least some frames */
+  if (!parse->priv->framecount)
+    return FALSE;
+
+  duration = parse->priv->acc_duration / GST_MSECOND;
+  bytes = parse->priv->bytecount;
+
+  if (G_UNLIKELY (!duration || !bytes))
+    return FALSE;
+
+  if (src_format == GST_FORMAT_BYTES) {
+    if (dest_format == GST_FORMAT_TIME) {
+      /* BYTES -> TIME conversion */
+      GST_DEBUG_OBJECT (parse, "converting bytes -> time");
+      *dest_value = gst_util_uint64_scale (src_value, duration, bytes);
+      *dest_value *= GST_MSECOND;
+      GST_DEBUG_OBJECT (parse, "conversion result: %" G_GINT64_FORMAT " ms",
+          *dest_value / GST_MSECOND);
+      ret = TRUE;
+    }
+  } else if (src_format == GST_FORMAT_TIME) {
+    if (dest_format == GST_FORMAT_BYTES) {
+      GST_DEBUG_OBJECT (parse, "converting time -> bytes");
+      *dest_value = gst_util_uint64_scale (src_value / GST_MSECOND, bytes,
+          duration);
+      GST_DEBUG_OBJECT (parse,
+          "time %" G_GINT64_FORMAT " ms in bytes = %" G_GINT64_FORMAT,
+          src_value / GST_MSECOND, *dest_value);
+      ret = TRUE;
+    }
+  } else if (src_format == GST_FORMAT_DEFAULT) {
+    /* DEFAULT == frame-based */
+    if (dest_format == GST_FORMAT_TIME) {
+      if (parse->priv->fps_den) {
+        *dest_value = gst_util_uint64_scale (src_value,
+            GST_SECOND * parse->priv->fps_den, parse->priv->fps_num);
+        ret = TRUE;
+      }
+    } else if (dest_format == GST_FORMAT_BYTES) {
+    }
+  }
+
+  return ret;
+}
+
+/**
+ * gst_base_parse_update_duration:
+ * @parse: #GstBaseParse.
+ *
+ */
+static void
+gst_base_parse_update_duration (GstBaseParse * aacparse)
+{
+  GstPad *peer;
+  GstBaseParse *parse;
+
+  parse = GST_BASE_PARSE (aacparse);
+
+  peer = gst_pad_get_peer (parse->sinkpad);
+  if (peer) {
+    GstFormat pformat = GST_FORMAT_BYTES;
+    gboolean qres = FALSE;
+    gint64 ptot, dest_value;
+
+    qres = gst_pad_query_duration (peer, &pformat, &ptot);
+    gst_object_unref (GST_OBJECT (peer));
+    if (qres) {
+      if (gst_base_parse_convert (parse, pformat, ptot,
+              GST_FORMAT_TIME, &dest_value))
+        parse->priv->estimated_duration = dest_value;
+    }
+  }
+}
+
+static void
+gst_base_parse_post_bitrates (GstBaseParse * parse, gboolean post_min,
+    gboolean post_avg, gboolean post_max)
+{
+  GstTagList *taglist = gst_tag_list_new ();
+
+  if (post_min && parse->priv->post_min_bitrate)
+    gst_tag_list_add (taglist, GST_TAG_MERGE_REPLACE,
+        GST_TAG_MINIMUM_BITRATE, parse->priv->min_bitrate, NULL);
+
+  if (post_avg && parse->priv->post_avg_bitrate) {
+    parse->priv->posted_avg_bitrate = parse->priv->avg_bitrate;
+    gst_tag_list_add (taglist, GST_TAG_MERGE_REPLACE, GST_TAG_BITRATE,
+        parse->priv->avg_bitrate, NULL);
+  }
+
+  if (post_max && parse->priv->post_max_bitrate)
+    gst_tag_list_add (taglist, GST_TAG_MERGE_REPLACE,
+        GST_TAG_MAXIMUM_BITRATE, parse->priv->max_bitrate, NULL);
+
+  GST_DEBUG_OBJECT (parse, "Updated bitrates. Min: %u, Avg: %u, Max: %u",
+      parse->priv->min_bitrate, parse->priv->avg_bitrate,
+      parse->priv->max_bitrate);
+
+  gst_element_found_tags_for_pad (GST_ELEMENT (parse), parse->srcpad, taglist);
+}
+
+/**
+ * gst_base_parse_update_bitrates:
+ * @parse: #GstBaseParse.
+ * @buffer: Current frame as a #GstBuffer
+ *
+ * Keeps track of the minimum and maximum bitrates, and also maintains a
+ * running average bitrate of the stream so far.
+ */
+static void
+gst_base_parse_update_bitrates (GstBaseParse * parse, GstBuffer * buffer)
+{
+  /* Only update the tag on a 10 kbps delta */
+  static const gint update_threshold = 10000;
+
+  GstBaseParseClass *klass;
+  guint64 data_len, frame_dur;
+  gint overhead = 0, frame_bitrate, old_avg_bitrate;
+  gboolean update_min = FALSE, update_avg = FALSE, update_max = FALSE;
+
+  klass = GST_BASE_PARSE_GET_CLASS (parse);
+
+  if (klass->get_frame_overhead) {
+    overhead = klass->get_frame_overhead (parse, buffer);
+    if (overhead == -1)
+      return;
+  }
+
+  data_len = GST_BUFFER_SIZE (buffer) - overhead;
+  parse->priv->data_bytecount += data_len;
+
+  /* duration should be valid by now,
+   * either set by subclass or maybe based on fps settings */
+  if (GST_BUFFER_DURATION_IS_VALID (buffer) && parse->priv->acc_duration != 0) {
+    /* Calculate duration of a frame from buffer properties */
+    frame_dur = GST_BUFFER_DURATION (buffer);
+    parse->priv->avg_bitrate = (8 * parse->priv->data_bytecount * GST_SECOND) /
+        parse->priv->acc_duration;
+
+  } else {
+    /* No way to figure out frame duration (is this even possible?) */
+    return;
+  }
+
+  /* override if subclass provided bitrate, e.g. metadata based */
+  if (parse->priv->bitrate) {
+    parse->priv->avg_bitrate = parse->priv->bitrate;
+    /* spread this (confirmed) info ASAP */
+    if (parse->priv->posted_avg_bitrate != parse->priv->avg_bitrate)
+      gst_base_parse_post_bitrates (parse, FALSE, TRUE, FALSE);
+  }
+
+  frame_bitrate = (8 * data_len * GST_SECOND) / frame_dur;
+
+  GST_LOG_OBJECT (parse, "frame bitrate %u, avg bitrate %u", frame_bitrate,
+      parse->priv->avg_bitrate);
+
+  if (parse->priv->framecount < MIN_FRAMES_TO_POST_BITRATE) {
+    goto exit;
+  } else if (parse->priv->framecount == MIN_FRAMES_TO_POST_BITRATE) {
+    /* always post all at threshold time */
+    update_min = update_max = update_avg = TRUE;
+  } else {
+    if (frame_bitrate < parse->priv->min_bitrate) {
+      parse->priv->min_bitrate = frame_bitrate;
+      update_min = TRUE;
+    }
+
+    if (frame_bitrate > parse->priv->max_bitrate) {
+      parse->priv->max_bitrate = frame_bitrate;
+      update_max = TRUE;
+    }
+
+    old_avg_bitrate = parse->priv->posted_avg_bitrate;
+    if ((gint) (old_avg_bitrate - parse->priv->avg_bitrate) > update_threshold
+        || (gint) (parse->priv->avg_bitrate - old_avg_bitrate) >
+        update_threshold)
+      update_avg = TRUE;
+  }
+
+  if ((update_min || update_avg || update_max))
+    gst_base_parse_post_bitrates (parse, update_min, update_avg, update_max);
+
+  /* If average bitrate changes that much and no valid (time) duration provided,
+   * then post a new duration message so applications can update their cached
+   * values */
+  if (update_avg && !(parse->priv->duration_fmt == GST_FORMAT_TIME &&
+          GST_CLOCK_TIME_IS_VALID (parse->priv->duration)))
+    gst_element_post_message (GST_ELEMENT (parse),
+        gst_message_new_duration (GST_OBJECT (parse), GST_FORMAT_TIME, -1));
+
+exit:
+  return;
+}
+
+/**
+ * gst_base_parse_add_index_entry:
+ * @parse: #GstBaseParse.
+ * @offset: offset of entry
+ * @ts: timestamp associated with offset
+ * @key: whether entry refers to keyframe
+ * @force: add entry disregarding sanity checks
+ *
+ * Adds an entry to the index associating @offset to @ts.  It is recommended
+ * to only add keyframe entries.  @force allows to bypass checks, such as
+ * whether the stream is (upstream) seekable, another entry is already "close"
+ * to the new entry, etc.
+ *
+ * Returns: #gboolean indicating whether entry was added
+ */
+gboolean
+gst_base_parse_add_index_entry (GstBaseParse * parse, guint64 offset,
+    GstClockTime ts, gboolean key, gboolean force)
+{
+  gboolean ret = FALSE;
+  GstIndexAssociation associations[2];
+
+  GST_LOG_OBJECT (parse, "Adding key=%d index entry %" GST_TIME_FORMAT
+      " @ offset 0x%08" G_GINT64_MODIFIER "x", key, GST_TIME_ARGS (ts), offset);
+
+  if (G_LIKELY (!force)) {
+
+    if (!parse->priv->upstream_seekable) {
+      GST_DEBUG_OBJECT (parse, "upstream not seekable; discarding");
+      goto exit;
+    }
+
+    /* FIXME need better helper data structure that handles these issues
+     * related to ongoing collecting of index entries */
+    if (parse->priv->index_last_offset >= offset) {
+      GST_DEBUG_OBJECT (parse, "already have entries up to offset "
+          "0x%08" G_GINT64_MODIFIER "x", parse->priv->index_last_offset);
+      goto exit;
+    }
+
+    if (GST_CLOCK_DIFF (parse->priv->index_last_ts, ts) <
+        parse->priv->idx_interval) {
+      GST_DEBUG_OBJECT (parse, "entry too close to last time %" GST_TIME_FORMAT,
+          GST_TIME_ARGS (parse->priv->index_last_ts));
+      goto exit;
+    }
+
+    /* if last is not really the last one */
+    if (!parse->priv->index_last_valid) {
+      GstClockTime prev_ts;
+
+      gst_base_parse_find_offset (parse, ts, TRUE, &prev_ts);
+      if (GST_CLOCK_DIFF (prev_ts, ts) < parse->priv->idx_interval) {
+        GST_DEBUG_OBJECT (parse,
+            "entry too close to existing entry %" GST_TIME_FORMAT,
+            GST_TIME_ARGS (prev_ts));
+        parse->priv->index_last_offset = offset;
+        parse->priv->index_last_ts = ts;
+        goto exit;
+      }
+    }
+  }
+
+  associations[0].format = GST_FORMAT_TIME;
+  associations[0].value = ts;
+  associations[1].format = GST_FORMAT_BYTES;
+  associations[1].value = offset;
+
+  /* index might change on-the-fly, although that would be nutty app ... */
+  GST_OBJECT_LOCK (parse);
+  gst_index_add_associationv (parse->priv->index, parse->priv->index_id,
+      (key) ? GST_ASSOCIATION_FLAG_KEY_UNIT : GST_ASSOCIATION_FLAG_NONE,
+      2, (const GstIndexAssociation *) &associations);
+  GST_OBJECT_UNLOCK (parse);
+
+  if (key) {
+    parse->priv->index_last_offset = offset;
+    parse->priv->index_last_ts = ts;
+  }
+
+  ret = TRUE;
+
+exit:
+  return ret;
+}
+
+/* check for seekable upstream, above and beyond a mere query */
+static void
+gst_base_parse_check_seekability (GstBaseParse * parse)
+{
+  GstQuery *query;
+  gboolean seekable = FALSE;
+  gint64 start = -1, stop = -1;
+  guint idx_interval = 0;
+
+  query = gst_query_new_seeking (GST_FORMAT_BYTES);
+  if (!gst_pad_peer_query (parse->sinkpad, query)) {
+    GST_DEBUG_OBJECT (parse, "seeking query failed");
+    goto done;
+  }
+
+  gst_query_parse_seeking (query, NULL, &seekable, &start, &stop);
+
+  /* try harder to query upstream size if we didn't get it the first time */
+  if (seekable && stop == -1) {
+    GstFormat fmt = GST_FORMAT_BYTES;
+
+    GST_DEBUG_OBJECT (parse, "doing duration query to fix up unset stop");
+    gst_pad_query_peer_duration (parse->sinkpad, &fmt, &stop);
+  }
+
+  /* if upstream doesn't know the size, it's likely that it's not seekable in
+   * practice even if it technically may be seekable */
+  if (seekable && (start != 0 || stop <= start)) {
+    GST_DEBUG_OBJECT (parse, "seekable but unknown start/stop -> disable");
+    seekable = FALSE;
+  }
+
+  /* let's not put every single frame into our index */
+  if (seekable) {
+    if (stop < 10 * 1024 * 1024)
+      idx_interval = 100;
+    else if (stop < 100 * 1024 * 1024)
+      idx_interval = 500;
+    else
+      idx_interval = 1000;
+  }
+
+done:
+  gst_query_unref (query);
+
+  GST_DEBUG_OBJECT (parse, "seekable: %d (%" G_GUINT64_FORMAT " - %"
+      G_GUINT64_FORMAT ")", seekable, start, stop);
+  parse->priv->upstream_seekable = seekable;
+  parse->priv->upstream_size = seekable ? stop : 0;
+
+  GST_DEBUG_OBJECT (parse, "idx_interval: %ums", idx_interval);
+  parse->priv->idx_interval = idx_interval * GST_MSECOND;
+}
+
+/* some misc checks on upstream */
+static void
+gst_base_parse_check_upstream (GstBaseParse * parse)
+{
+  GstFormat fmt = GST_FORMAT_TIME;
+  gint64 stop;
+
+  if (gst_pad_query_peer_duration (parse->sinkpad, &fmt, &stop))
+    if (GST_CLOCK_TIME_IS_VALID (stop) && stop) {
+      /* upstream has one, accept it also, and no further updates */
+      gst_base_parse_set_duration (parse, GST_FORMAT_TIME, stop, 0);
+      parse->priv->upstream_has_duration = TRUE;
+    }
+
+  GST_DEBUG_OBJECT (parse, "upstream_has_duration: %d",
+      parse->priv->upstream_has_duration);
+}
+
+/* checks src caps to determine if dealing with audio or video */
+/* TODO maybe forego automagic stuff and let subclass configure it ? */
+static void
+gst_base_parse_check_media (GstBaseParse * parse)
+{
+  GstCaps *caps;
+  GstStructure *s;
+
+  caps = GST_PAD_CAPS (parse->srcpad);
+  if (G_LIKELY (caps) && (s = gst_caps_get_structure (caps, 0))) {
+    parse->priv->is_video =
+        g_str_has_prefix (gst_structure_get_name (s), "video");
+  } else {
+    /* historical default */
+    parse->priv->is_video = FALSE;
+  }
+
+  GST_DEBUG_OBJECT (parse, "media is video == %d", parse->priv->is_video);
+}
+
+/**
+ * gst_base_parse_handle_and_push_buffer:
+ * @parse: #GstBaseParse.
+ * @klass: #GstBaseParseClass.
+ * @buffer: #GstBuffer.
+ *
+ * Parses the frame from given buffer and pushes it forward. Also performs
+ * timestamp handling and checks the segment limits.
+ *
+ * This is called with srcpad STREAM_LOCK held.
+ *
+ * Returns: #GstFlowReturn
+ */
+static GstFlowReturn
+gst_base_parse_handle_and_push_buffer (GstBaseParse * parse,
+    GstBaseParseClass * klass, GstBuffer * buffer)
+{
+  GstFlowReturn ret;
+  gint64 offset;
+
+  if (parse->priv->discont) {
+    GST_DEBUG_OBJECT (parse, "marking DISCONT");
+    GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DISCONT);
+    parse->priv->discont = FALSE;
+  }
+
+  /* some one-time start-up */
+  if (G_UNLIKELY (!parse->priv->framecount)) {
+    gst_base_parse_check_seekability (parse);
+    gst_base_parse_check_upstream (parse);
+  }
+
+  GST_LOG_OBJECT (parse,
+      "parsing frame at offset %" G_GUINT64_FORMAT
+      " (%#" G_GINT64_MODIFIER "x) of size %d",
+      GST_BUFFER_OFFSET (buffer), GST_BUFFER_OFFSET (buffer),
+      GST_BUFFER_SIZE (buffer));
+
+  /* store offset as it might get overwritten */
+  offset = GST_BUFFER_OFFSET (buffer);
+  ret = klass->parse_frame (parse, buffer);
+
+  /* check initial frame to determine if subclass/format can provide ts.
+   * If so, that allows and enables extra seek and duration determining options */
+  if (G_UNLIKELY (parse->priv->first_frame_offset < 0 && ret == GST_FLOW_OK)) {
+    if (GST_BUFFER_TIMESTAMP_IS_VALID (buffer)) {
+      parse->priv->first_frame_offset = offset;
+      parse->priv->first_frame_ts = GST_BUFFER_TIMESTAMP (buffer);
+      GST_DEBUG_OBJECT (parse, "subclass provided ts %" GST_TIME_FORMAT
+          " for first frame at offset %" G_GINT64_FORMAT,
+          GST_TIME_ARGS (parse->priv->first_frame_ts),
+          parse->priv->first_frame_offset);
+      if (!GST_CLOCK_TIME_IS_VALID (parse->priv->duration)) {
+        gint64 off;
+        GstClockTime last_ts = G_MAXINT64;
+
+        GST_DEBUG_OBJECT (parse, "no duration; trying scan to determine");
+        gst_base_parse_locate_time (parse, &last_ts, &off);
+        if (GST_CLOCK_TIME_IS_VALID (last_ts))
+          gst_base_parse_set_duration (parse, GST_FORMAT_TIME, last_ts, 0);
+      }
+    } else {
+      /* disable further checks */
+      parse->priv->first_frame_offset = 0;
+    }
+  }
+
+  /* re-use default handler to add missing metadata as-much-as-possible */
+  gst_base_parse_parse_frame (parse, buffer);
+  if (GST_BUFFER_TIMESTAMP_IS_VALID (buffer) &&
+      GST_BUFFER_DURATION_IS_VALID (buffer)) {
+    parse->priv->next_ts =
+        GST_BUFFER_TIMESTAMP (buffer) + GST_BUFFER_DURATION (buffer);
+  } else {
+    /* we lost track, do not produce bogus time next time around
+     * (probably means parser subclass has given up on parsing as well) */
+    GST_DEBUG_OBJECT (parse, "no next fallback timestamp");
+    parse->priv->next_ts = GST_CLOCK_TIME_NONE;
+  }
+
+  if (parse->priv->upstream_seekable && parse->priv->exact_position &&
+      GST_BUFFER_TIMESTAMP_IS_VALID (buffer))
+    gst_base_parse_add_index_entry (parse, offset,
+        GST_BUFFER_TIMESTAMP (buffer),
+        !GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DELTA_UNIT), FALSE);
+
+  /* First buffers are dropped, this means that the subclass needs more
+   * frames to decide on the format and queues them internally */
+  /* convert internal flow to OK and mark discont for the next buffer. */
+  if (ret == GST_BASE_PARSE_FLOW_DROPPED) {
+    gst_buffer_unref (buffer);
+    return GST_FLOW_OK;
+  } else if (ret != GST_FLOW_OK) {
+    return ret;
+  }
+
+  return gst_base_parse_push_buffer (parse, buffer);
+}
+
+/**
+ * gst_base_parse_push_buffer:
+ * @parse: #GstBaseParse.
+ * @buffer: #GstBuffer.
+ *
+ * Pushes the buffer downstream, sends any pending events and
+ * does some timestamp and segment handling.
+ *
+ * This must be called with srcpad STREAM_LOCK held.
+ *
+ * Returns: #GstFlowReturn
+ */
+GstFlowReturn
+gst_base_parse_push_buffer (GstBaseParse * parse, GstBuffer * buffer)
+{
+  GstFlowReturn ret = GST_FLOW_OK;
+  GstClockTime last_start = GST_CLOCK_TIME_NONE;
+  GstClockTime last_stop = GST_CLOCK_TIME_NONE;
+  GstBaseParseClass *klass = GST_BASE_PARSE_GET_CLASS (parse);
+
+  GST_LOG_OBJECT (parse,
+      "processing buffer of size %d with ts %" GST_TIME_FORMAT
+      ", duration %" GST_TIME_FORMAT, GST_BUFFER_SIZE (buffer),
+      GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)),
+      GST_TIME_ARGS (GST_BUFFER_DURATION (buffer)));
+
+  /* update stats */
+  parse->priv->bytecount += GST_BUFFER_SIZE (buffer);
+  if (!GST_BUFFER_FLAG_IS_SET (buffer, GST_BASE_PARSE_BUFFER_FLAG_NO_FRAME)) {
+    parse->priv->framecount++;
+    if (GST_BUFFER_DURATION_IS_VALID (buffer)) {
+      parse->priv->acc_duration += GST_BUFFER_DURATION (buffer);
+    }
+  }
+  GST_BUFFER_FLAG_UNSET (buffer, GST_BASE_PARSE_BUFFER_FLAG_NO_FRAME);
+  if (parse->priv->update_interval &&
+      (parse->priv->framecount % parse->priv->update_interval) == 0)
+    gst_base_parse_update_duration (parse);
+
+  if (GST_BUFFER_TIMESTAMP_IS_VALID (buffer))
+    last_start = last_stop = GST_BUFFER_TIMESTAMP (buffer);
+  if (last_start != GST_CLOCK_TIME_NONE
+      && GST_BUFFER_DURATION_IS_VALID (buffer))
+    last_stop = last_start + GST_BUFFER_DURATION (buffer);
+
+  /* should have caps by now */
+  g_return_val_if_fail (GST_PAD_CAPS (parse->srcpad), GST_FLOW_ERROR);
+
+  gst_buffer_set_caps (buffer, GST_PAD_CAPS (parse->srcpad));
+
+  /* segment adjustment magic; only if we are running the whole show */
+  if (!parse->priv->passthrough && parse->segment.rate > 0.0 &&
+      (parse->priv->pad_mode == GST_ACTIVATE_PULL ||
+          parse->priv->upstream_seekable)) {
+    /* segment times are typically estimates,
+     * actual frame data might lead subclass to different timestamps,
+     * so override segment start from what is supplied there */
+    if (G_UNLIKELY (parse->pending_segment && !parse->priv->exact_position &&
+            GST_CLOCK_TIME_IS_VALID (last_start))) {
+      gst_event_unref (parse->pending_segment);
+      parse->segment.start =
+          MIN ((guint64) last_start, (guint64) parse->segment.stop);
+      GST_DEBUG_OBJECT (parse,
+          "adjusting pending segment start to %" GST_TIME_FORMAT,
+          GST_TIME_ARGS (parse->segment.start));
+      parse->pending_segment =
+          gst_event_new_new_segment (FALSE, parse->segment.rate,
+          parse->segment.format, parse->segment.start, parse->segment.stop,
+          parse->segment.start);
+    }
+    /* handle gaps, e.g. non-zero start-time, in as much not handled by above */
+    if (GST_CLOCK_TIME_IS_VALID (parse->segment.last_stop) &&
+        GST_CLOCK_TIME_IS_VALID (last_start)) {
+      GstClockTimeDiff diff;
+
+      /* only send newsegments with increasing start times,
+       * otherwise if these go back and forth downstream (sinks) increase
+       * accumulated time and running_time */
+      diff = GST_CLOCK_DIFF (parse->segment.last_stop, last_start);
+      if (G_UNLIKELY (diff > 2 * GST_SECOND && last_start > parse->segment.start
+              && (!GST_CLOCK_TIME_IS_VALID (parse->segment.stop) ||
+                  last_start < parse->segment.stop))) {
+        GST_DEBUG_OBJECT (parse,
+            "Gap of %" G_GINT64_FORMAT " ns detected in stream "
+            "(%" GST_TIME_FORMAT " -> %" GST_TIME_FORMAT "). "
+            "Sending updated NEWSEGMENT events", diff,
+            GST_TIME_ARGS (parse->segment.last_stop),
+            GST_TIME_ARGS (last_start));
+        if (G_UNLIKELY (parse->pending_segment)) {
+          gst_event_unref (parse->pending_segment);
+          parse->segment.start = last_start;
+          parse->pending_segment =
+              gst_event_new_new_segment (FALSE, parse->segment.rate,
+              parse->segment.format, parse->segment.start, parse->segment.stop,
+              parse->segment.start);
+        } else {
+          /* send newsegment events such that the gap is not accounted in
+           * accum time, hence running_time */
+          /* close ahead of gap */
+          gst_pad_push_event (parse->srcpad,
+              gst_event_new_new_segment (TRUE, parse->segment.rate,
+                  parse->segment.format, parse->segment.last_stop,
+                  parse->segment.last_stop, parse->segment.last_stop));
+          /* skip gap */
+          gst_pad_push_event (parse->srcpad,
+              gst_event_new_new_segment (FALSE, parse->segment.rate,
+                  parse->segment.format, last_start, parse->segment.stop,
+                  last_start));
+        }
+        /* align segment view with downstream,
+         * prevents double-counting accum when closing segment */
+        gst_segment_set_newsegment (&parse->segment, FALSE,
+            parse->segment.rate, parse->segment.format, last_start,
+            parse->segment.stop, last_start);
+        parse->segment.last_stop = last_start;
+      }
+    }
+  }
+
+  /* and should then also be linked downstream, so safe to send some events */
+  if (G_UNLIKELY (parse->close_segment)) {
+    /* only set up by loop */
+    GST_DEBUG_OBJECT (parse, "loop sending close segment");
+    gst_pad_push_event (parse->srcpad, parse->close_segment);
+    parse->close_segment = NULL;
+  }
+  if (G_UNLIKELY (parse->pending_segment)) {
+    GST_DEBUG_OBJECT (parse, "%s push pending segment",
+        parse->priv->pad_mode == GST_ACTIVATE_PULL ? "loop" : "chain");
+    gst_pad_push_event (parse->srcpad, parse->pending_segment);
+    parse->pending_segment = NULL;
+
+    /* have caps; check identity */
+    gst_base_parse_check_media (parse);
+  }
+
+  /* update bitrates and optionally post corresponding tags
+   * (following newsegment) */
+  gst_base_parse_update_bitrates (parse, buffer);
+
+  if (G_UNLIKELY (parse->priv->pending_events)) {
+    GList *l;
+
+    for (l = parse->priv->pending_events; l != NULL; l = l->next) {
+      gst_pad_push_event (parse->srcpad, GST_EVENT (l->data));
+    }
+    g_list_free (parse->priv->pending_events);
+    parse->priv->pending_events = NULL;
+  }
+
+  if (klass->pre_push_buffer)
+    ret = klass->pre_push_buffer (parse, buffer);
+  else
+    ret = GST_BASE_PARSE_FLOW_CLIP;
+
+  parse->priv->seen_keyframe |= parse->priv->is_video &&
+      !GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DELTA_UNIT);
+
+  if (ret == GST_BASE_PARSE_FLOW_CLIP) {
+    if (GST_BUFFER_TIMESTAMP_IS_VALID (buffer) &&
+        GST_CLOCK_TIME_IS_VALID (parse->segment.stop) &&
+        GST_BUFFER_TIMESTAMP (buffer) >
+        parse->segment.stop + parse->priv->lead_out_ts) {
+      GST_LOG_OBJECT (parse, "Dropped frame, after segment");
+      ret = GST_FLOW_UNEXPECTED;
+    } else if (GST_BUFFER_TIMESTAMP_IS_VALID (buffer) &&
+        GST_BUFFER_DURATION_IS_VALID (buffer) &&
+        GST_CLOCK_TIME_IS_VALID (parse->segment.start) &&
+        GST_BUFFER_TIMESTAMP (buffer) + GST_BUFFER_DURATION (buffer) +
+        parse->priv->lead_in_ts < parse->segment.start) {
+      if (parse->priv->seen_keyframe) {
+        GST_LOG_OBJECT (parse, "Frame before segment, after keyframe");
+        ret = GST_FLOW_OK;
+      } else {
+        GST_LOG_OBJECT (parse, "Dropped frame, before segment");
+        ret = GST_BASE_PARSE_FLOW_DROPPED;
+      }
+    } else {
+      ret = GST_FLOW_OK;
+    }
+  }
+
+  if (ret == GST_BASE_PARSE_FLOW_DROPPED) {
+    GST_LOG_OBJECT (parse, "frame (%d bytes) dropped",
+        GST_BUFFER_SIZE (buffer));
+    gst_buffer_unref (buffer);
+    ret = GST_FLOW_OK;
+  } else if (ret == GST_FLOW_OK) {
+    if (parse->segment.rate > 0.0) {
+      ret = gst_pad_push (parse->srcpad, buffer);
+      GST_LOG_OBJECT (parse, "frame (%d bytes) pushed: %s",
+          GST_BUFFER_SIZE (buffer), gst_flow_get_name (ret));
+    } else {
+      GST_LOG_OBJECT (parse, "frame (%d bytes) queued for now",
+          GST_BUFFER_SIZE (buffer));
+      parse->priv->buffers_queued =
+          g_slist_prepend (parse->priv->buffers_queued, buffer);
+      ret = GST_FLOW_OK;
+    }
+  } else {
+    gst_buffer_unref (buffer);
+    GST_LOG_OBJECT (parse, "frame (%d bytes) not pushed: %s",
+        GST_BUFFER_SIZE (buffer), gst_flow_get_name (ret));
+    /* if we are not sufficiently in control, let upstream decide on EOS */
+    if (ret == GST_FLOW_UNEXPECTED &&
+        (parse->priv->passthrough ||
+            (parse->priv->pad_mode == GST_ACTIVATE_PUSH &&
+                !parse->priv->upstream_seekable)))
+      ret = GST_FLOW_OK;
+  }
+
+  /* Update current running segment position */
+  if (ret == GST_FLOW_OK && last_stop != GST_CLOCK_TIME_NONE &&
+      parse->segment.last_stop < last_stop)
+    gst_segment_set_last_stop (&parse->segment, GST_FORMAT_TIME, last_stop);
+
+  return ret;
+}
+
+
+/**
+ * gst_base_parse_drain:
+ * @parse: #GstBaseParse.
+ *
+ * Drains the adapter until it is empty. It decreases the min_frame_size to
+ * match the current adapter size and calls chain method until the adapter
+ * is emptied or chain returns with error.
+ */
+static void
+gst_base_parse_drain (GstBaseParse * parse)
+{
+  guint avail;
+
+  GST_DEBUG_OBJECT (parse, "draining");
+  parse->priv->drain = TRUE;
+
+  for (;;) {
+    avail = gst_adapter_available (parse->adapter);
+    if (!avail)
+      break;
+
+    if (gst_base_parse_chain (parse->sinkpad, NULL) != GST_FLOW_OK) {
+      break;
+    }
+
+    /* nothing changed, maybe due to truncated frame; break infinite loop */
+    if (avail == gst_adapter_available (parse->adapter)) {
+      GST_DEBUG_OBJECT (parse, "no change during draining; flushing");
+      gst_adapter_clear (parse->adapter);
+    }
+  }
+
+  parse->priv->drain = FALSE;
+}
+
+/**
+ * gst_base_parse_process_fragment:
+ * @parse: #GstBaseParse.
+ *
+ * Processes a reverse playback (forward) fragment:
+ * - append head of last fragment that was skipped to current fragment data
+ * - drain the resulting current fragment data (i.e. repeated chain)
+ * - add time/duration (if needed) to frames queued by chain
+ * - push queued data
+ */
+static GstFlowReturn
+gst_base_parse_process_fragment (GstBaseParse * parse, gboolean push_only)
+{
+  GstBuffer *buf;
+  GstFlowReturn ret = GST_FLOW_OK;
+  GSList *send = NULL;
+
+  if (push_only)
+    goto push;
+
+  /* restore order */
+  parse->priv->buffers_pending = g_slist_reverse (parse->priv->buffers_pending);
+  while (parse->priv->buffers_pending) {
+    buf = GST_BUFFER_CAST (parse->priv->buffers_pending->data);
+    GST_LOG_OBJECT (parse, "adding pending buffer (size %d)",
+        GST_BUFFER_SIZE (buf));
+    gst_adapter_push (parse->adapter, buf);
+    parse->priv->buffers_pending =
+        g_slist_delete_link (parse->priv->buffers_pending,
+        parse->priv->buffers_pending);
+  }
+
+  /* invalidate so no fall-back timestamping is performed;
+   * ok if taken from subclass or upstream */
+  parse->priv->next_ts = GST_CLOCK_TIME_NONE;
+  /* prevent it hanging around stop all the time */
+  parse->segment.last_stop = GST_CLOCK_TIME_NONE;
+  /* mark next run */
+  parse->priv->discont = TRUE;
+
+  /* chain looks for frames and queues resulting ones (in stead of pushing) */
+  /* initial skipped data is added to buffers_pending */
+  gst_base_parse_drain (parse);
+
+push:
+  /* add metadata (if needed to queued buffers */
+  GST_LOG_OBJECT (parse, "last timestamp: %" GST_TIME_FORMAT,
+      GST_TIME_ARGS (parse->priv->last_ts));
+  while (parse->priv->buffers_queued) {
+    buf = GST_BUFFER_CAST (parse->priv->buffers_queued->data);
+
+    /* no touching if upstream or parsing provided time */
+    if (GST_BUFFER_TIMESTAMP_IS_VALID (buf)) {
+      GST_LOG_OBJECT (parse, "buffer has time %" GST_TIME_FORMAT,
+          GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)));
+    } else if (GST_CLOCK_TIME_IS_VALID (parse->priv->last_ts) &&
+        GST_BUFFER_DURATION_IS_VALID (buf)) {
+      if (G_LIKELY (GST_BUFFER_DURATION (buf) <= parse->priv->last_ts))
+        parse->priv->last_ts -= GST_BUFFER_DURATION (buf);
+      else
+        parse->priv->last_ts = 0;
+      GST_BUFFER_TIMESTAMP (buf) = parse->priv->last_ts;
+      GST_LOG_OBJECT (parse, "applied time %" GST_TIME_FORMAT,
+          GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)));
+    } else {
+      /* no idea, very bad */
+      GST_WARNING_OBJECT (parse, "could not determine time for buffer");
+    }
+
+    /* reverse order for ascending sending */
+    send = g_slist_prepend (send, buf);
+    parse->priv->buffers_queued =
+        g_slist_delete_link (parse->priv->buffers_queued,
+        parse->priv->buffers_queued);
+  }
+
+  /* send buffers */
+  while (send) {
+    buf = GST_BUFFER_CAST (send->data);
+    GST_LOG_OBJECT (parse, "pushing buffer %p, timestamp %"
+        GST_TIME_FORMAT ", duration %" GST_TIME_FORMAT
+        ", offset %" G_GINT64_FORMAT, buf,
+        GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
+        GST_TIME_ARGS (GST_BUFFER_DURATION (buf)), GST_BUFFER_OFFSET (buf));
+
+    if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (parse->priv->last_ts)))
+      parse->priv->last_ts = GST_BUFFER_TIMESTAMP (buf);
+
+    /* iterate output queue an push downstream */
+    ret = gst_pad_push (parse->srcpad, buf);
+    send = g_slist_delete_link (send, send);
+
+    /* clear any leftover if error */
+    if (G_UNLIKELY (ret != GST_FLOW_OK)) {
+      while (send) {
+        buf = GST_BUFFER_CAST (send->data);
+        gst_buffer_unref (buf);
+        send = g_slist_delete_link (send, send);
+      }
+    }
+  }
+
+  /* any trailing unused no longer usable (ideally none) */
+  if (G_UNLIKELY (gst_adapter_available (parse->adapter))) {
+    GST_DEBUG_OBJECT (parse, "discarding %d trailing bytes",
+        gst_adapter_available (parse->adapter));
+    gst_adapter_clear (parse->adapter);
+  }
+
+  return ret;
+}
+
+/* small helper that checks whether we have been trying to resync too long */
+static inline GstFlowReturn
+gst_base_parse_check_sync (GstBaseParse * parse)
+{
+  if (G_UNLIKELY (parse->priv->discont &&
+          parse->priv->offset - parse->priv->sync_offset > 2 * 1024 * 1024)) {
+    GST_ELEMENT_ERROR (parse, STREAM, DECODE,
+        ("Failed to parse stream"), (NULL));
+    return GST_FLOW_ERROR;
+  }
+
+  return GST_FLOW_OK;
+}
+
+
+/**
+ * gst_base_parse_chain:
+ * @pad: #GstPad.
+ * @buffer: #GstBuffer.
+ *
+ * Returns: #GstFlowReturn.
+ */
+static GstFlowReturn
+gst_base_parse_chain (GstPad * pad, GstBuffer * buffer)
+{
+  GstBaseParseClass *bclass;
+  GstBaseParse *parse;
+  GstFlowReturn ret = GST_FLOW_OK;
+  GstBuffer *outbuf = NULL;
+  GstBuffer *tmpbuf = NULL;
+  guint fsize = 0;
+  gint skip = -1;
+  const guint8 *data;
+  guint min_size;
+  GstClockTime timestamp;
+
+  parse = GST_BASE_PARSE (GST_OBJECT_PARENT (pad));
+  bclass = GST_BASE_PARSE_GET_CLASS (parse);
+
+  if (G_LIKELY (buffer)) {
+    GST_LOG_OBJECT (parse, "buffer size: %d, offset = %" G_GINT64_FORMAT,
+        GST_BUFFER_SIZE (buffer), GST_BUFFER_OFFSET (buffer));
+    if (G_UNLIKELY (parse->priv->passthrough)) {
+      buffer = gst_buffer_make_metadata_writable (buffer);
+      return gst_base_parse_push_buffer (parse, buffer);
+    }
+    /* upstream feeding us in reverse playback;
+     * gather each fragment, then process it in single run */
+    if (parse->segment.rate < 0.0) {
+      if (G_UNLIKELY (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DISCONT))) {
+        GST_DEBUG_OBJECT (parse, "buffer starts new reverse playback fragment");
+        ret = gst_base_parse_process_fragment (parse, FALSE);
+      }
+      gst_adapter_push (parse->adapter, buffer);
+      return ret;
+    }
+    gst_adapter_push (parse->adapter, buffer);
+  }
+
+  /* Parse and push as many frames as possible */
+  /* Stop either when adapter is empty or we are flushing */
+  while (!parse->priv->flushing) {
+    tmpbuf = gst_buffer_new ();
+
+    /* Synchronization loop */
+    for (;;) {
+      min_size = parse->priv->min_frame_size;
+
+      if (G_UNLIKELY (parse->priv->drain)) {
+        min_size = gst_adapter_available (parse->adapter);
+        GST_DEBUG_OBJECT (parse, "draining, data left: %d", min_size);
+        if (G_UNLIKELY (!min_size)) {
+          gst_buffer_unref (tmpbuf);
+          goto done;
+        }
+      }
+
+      /* Collect at least min_frame_size bytes */
+      if (gst_adapter_available (parse->adapter) < min_size) {
+        GST_DEBUG_OBJECT (parse, "not enough data available (only %d bytes)",
+            gst_adapter_available (parse->adapter));
+        gst_buffer_unref (tmpbuf);
+        goto done;
+      }
+
+      data = gst_adapter_peek (parse->adapter, min_size);
+      GST_BUFFER_DATA (tmpbuf) = (guint8 *) data;
+      GST_BUFFER_SIZE (tmpbuf) = min_size;
+      GST_BUFFER_OFFSET (tmpbuf) = parse->priv->offset;
+      GST_BUFFER_FLAG_SET (tmpbuf, GST_MINI_OBJECT_FLAG_READONLY);
+
+      if (parse->priv->discont) {
+        GST_DEBUG_OBJECT (parse, "marking DISCONT");
+        GST_BUFFER_FLAG_SET (tmpbuf, GST_BUFFER_FLAG_DISCONT);
+      }
+
+      skip = -1;
+      if (bclass->check_valid_frame (parse, tmpbuf, &fsize, &skip)) {
+        if (gst_adapter_available (parse->adapter) < fsize) {
+          GST_DEBUG_OBJECT (parse,
+              "found valid frame but not enough data available (only %d bytes)",
+              gst_adapter_available (parse->adapter));
+          gst_buffer_unref (tmpbuf);
+          goto done;
+        }
+        break;
+      }
+      if (skip == -1) {
+        /* subclass didn't touch this value. By default we skip 1 byte */
+        skip = 1;
+      }
+      if (skip > 0) {
+        GST_LOG_OBJECT (parse, "finding sync, skipping %d bytes", skip);
+        if (parse->segment.rate < 0.0 && !parse->priv->buffers_queued) {
+          /* reverse playback, and no frames found yet, so we are skipping
+           * the leading part of a fragment, which may form the tail of
+           * fragment coming later, hopefully subclass skips efficiently ... */
+          timestamp = gst_adapter_prev_timestamp (parse->adapter, NULL);
+          outbuf = gst_adapter_take_buffer (parse->adapter, skip);
+          outbuf = gst_buffer_make_metadata_writable (outbuf);
+          GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
+          parse->priv->buffers_pending =
+              g_slist_prepend (parse->priv->buffers_pending, outbuf);
+          outbuf = NULL;
+        } else {
+          gst_adapter_flush (parse->adapter, skip);
+        }
+        parse->priv->offset += skip;
+        if (!parse->priv->discont)
+          parse->priv->sync_offset = parse->priv->offset;
+        parse->priv->discont = TRUE;
+      }
+      /* There is a possibility that subclass set the skip value to zero.
+         This means that it has probably found a frame but wants to ask
+         more data (by increasing the min_size) to be sure of this. */
+      if ((ret = gst_base_parse_check_sync (parse)) != GST_FLOW_OK) {
+        gst_buffer_unref (tmpbuf);
+        goto done;
+      }
+    }
+    gst_buffer_unref (tmpbuf);
+    tmpbuf = NULL;
+
+    if (skip > 0) {
+      /* Subclass found the sync, but still wants to skip some data */
+      GST_LOG_OBJECT (parse, "skipping %d bytes", skip);
+      gst_adapter_flush (parse->adapter, skip);
+      parse->priv->offset += skip;
+    }
+
+    /* Grab lock to prevent a race with FLUSH_START handler */
+    GST_PAD_STREAM_LOCK (parse->srcpad);
+
+    /* FLUSH_START event causes the "flushing" flag to be set. In this
+     * case we can leave the frame pushing loop */
+    if (parse->priv->flushing) {
+      GST_PAD_STREAM_UNLOCK (parse->srcpad);
+      break;
+    }
+
+    /* FIXME: Would it be more efficient to make a subbuffer instead? */
+    outbuf = gst_adapter_take_buffer (parse->adapter, fsize);
+    outbuf = gst_buffer_make_metadata_writable (outbuf);
+
+    /* Subclass may want to know the data offset */
+    GST_BUFFER_OFFSET (outbuf) = parse->priv->offset;
+    parse->priv->offset += fsize;
+    GST_BUFFER_TIMESTAMP (outbuf) = GST_CLOCK_TIME_NONE;
+
+    /* move along with upstream timestamp (if any),
+     * but interpolate in between */
+    timestamp = gst_adapter_prev_timestamp (parse->adapter, NULL);
+    if (GST_CLOCK_TIME_IS_VALID (timestamp) &&
+        (parse->priv->prev_ts != timestamp)) {
+      parse->priv->prev_ts = parse->priv->next_ts = timestamp;
+    }
+
+    ret = gst_base_parse_handle_and_push_buffer (parse, bclass, outbuf);
+    GST_PAD_STREAM_UNLOCK (parse->srcpad);
+
+    if (ret != GST_FLOW_OK) {
+      GST_LOG_OBJECT (parse, "push returned %d", ret);
+      break;
+    }
+  }
+
+done:
+  GST_LOG_OBJECT (parse, "chain leaving");
+  return ret;
+}
+
+/* pull @size bytes at current offset,
+ * i.e. at least try to and possibly return a shorter buffer if near the end */
+static GstFlowReturn
+gst_base_parse_pull_range (GstBaseParse * parse, guint size,
+    GstBuffer ** buffer)
+{
+  GstFlowReturn ret = GST_FLOW_OK;
+
+  g_return_val_if_fail (buffer != NULL, GST_FLOW_ERROR);
+
+  /* Caching here actually makes much less difference than one would expect.
+   * We do it mainly to avoid pulling buffers of 1 byte all the time */
+  if (parse->priv->cache) {
+    gint64 cache_offset = GST_BUFFER_OFFSET (parse->priv->cache);
+    gint cache_size = GST_BUFFER_SIZE (parse->priv->cache);
+
+    if (cache_offset <= parse->priv->offset &&
+        (parse->priv->offset + size) <= (cache_offset + cache_size)) {
+      *buffer = gst_buffer_create_sub (parse->priv->cache,
+          parse->priv->offset - cache_offset, size);
+      GST_BUFFER_OFFSET (*buffer) = parse->priv->offset;
+      return GST_FLOW_OK;
+    }
+    /* not enough data in the cache, free cache and get a new one */
+    gst_buffer_unref (parse->priv->cache);
+    parse->priv->cache = NULL;
+  }
+
+  /* refill the cache */
+  ret =
+      gst_pad_pull_range (parse->sinkpad, parse->priv->offset, MAX (size,
+          64 * 1024), &parse->priv->cache);
+  if (ret != GST_FLOW_OK) {
+    parse->priv->cache = NULL;
+    return ret;
+  }
+
+  if (GST_BUFFER_SIZE (parse->priv->cache) >= size) {
+    *buffer = gst_buffer_create_sub (parse->priv->cache, 0, size);
+    GST_BUFFER_OFFSET (*buffer) = parse->priv->offset;
+    return GST_FLOW_OK;
+  }
+
+  /* Not possible to get enough data, try a last time with
+   * requesting exactly the size we need */
+  gst_buffer_unref (parse->priv->cache);
+  parse->priv->cache = NULL;
+
+  ret = gst_pad_pull_range (parse->sinkpad, parse->priv->offset, size,
+      &parse->priv->cache);
+
+  if (ret != GST_FLOW_OK) {
+    GST_DEBUG_OBJECT (parse, "pull_range returned %d", ret);
+    *buffer = NULL;
+    return ret;
+  }
+
+  if (GST_BUFFER_SIZE (parse->priv->cache) < size) {
+    GST_DEBUG_OBJECT (parse, "Returning short buffer at offset %"
+        G_GUINT64_FORMAT ": wanted %u bytes, got %u bytes", parse->priv->offset,
+        size, GST_BUFFER_SIZE (parse->priv->cache));
+
+    *buffer = parse->priv->cache;
+    parse->priv->cache = NULL;
+
+    return GST_FLOW_OK;
+  }
+
+  *buffer = gst_buffer_create_sub (parse->priv->cache, 0, size);
+  GST_BUFFER_OFFSET (*buffer) = parse->priv->offset;
+
+  return GST_FLOW_OK;
+}
+
+static GstFlowReturn
+gst_base_parse_handle_previous_fragment (GstBaseParse * parse)
+{
+  gint64 offset = 0;
+  GstClockTime ts = 0;
+  GstBuffer *buffer;
+  GstFlowReturn ret;
+
+  GST_DEBUG_OBJECT (parse, "fragment ended; last_ts = %" GST_TIME_FORMAT
+      ", last_offset = %" G_GINT64_FORMAT, GST_TIME_ARGS (parse->priv->last_ts),
+      parse->priv->last_offset);
+
+  if (!parse->priv->last_offset || parse->priv->last_ts <= parse->segment.start) {
+    GST_DEBUG_OBJECT (parse, "past start of segment %" GST_TIME_FORMAT,
+        GST_TIME_ARGS (parse->segment.start));
+    ret = GST_FLOW_UNEXPECTED;
+    goto exit;
+  }
+
+  /* last fragment started at last_offset / last_ts;
+   * seek back 10s capped at 1MB */
+  if (parse->priv->last_ts >= 10 * GST_SECOND)
+    ts = parse->priv->last_ts - 10 * GST_SECOND;
+  /* if we are exact now, we will be more so going backwards */
+  if (parse->priv->exact_position) {
+    offset = gst_base_parse_find_offset (parse, ts, TRUE, NULL);
+  } else {
+    GstFormat dstformat = GST_FORMAT_BYTES;
+
+    if (!gst_pad_query_convert (parse->srcpad, GST_FORMAT_TIME, ts,
+            &dstformat, &offset)) {
+      GST_DEBUG_OBJECT (parse, "conversion failed, only BYTE based");
+    }
+  }
+  offset = CLAMP (offset, parse->priv->last_offset - 1024 * 1024,
+      parse->priv->last_offset - 1024);
+  offset = MAX (0, offset);
+
+  GST_DEBUG_OBJECT (parse, "next fragment from offset %" G_GINT64_FORMAT,
+      offset);
+  parse->priv->offset = offset;
+
+  ret = gst_base_parse_pull_range (parse, parse->priv->last_offset - offset,
+      &buffer);
+  if (ret != GST_FLOW_OK)
+    goto exit;
+
+  /* offset will increase again as fragment is processed/parsed */
+  parse->priv->last_offset = offset;
+
+  gst_adapter_push (parse->adapter, buffer);
+  ret = gst_base_parse_process_fragment (parse, FALSE);
+  if (ret != GST_FLOW_OK)
+    goto exit;
+
+  /* force previous fragment */
+  parse->priv->offset = -1;
+
+exit:
+  return ret;
+}
+
+/* PULL mode:
+ * pull and scan for next frame starting from current offset
+ * ajusts sync, drain and offset going along */
+static GstFlowReturn
+gst_base_parse_scan_frame (GstBaseParse * parse, GstBaseParseClass * klass,
+    GstBuffer ** buf, gboolean full)
+{
+  GstBuffer *buffer, *outbuf;
+  GstFlowReturn ret = GST_FLOW_OK;
+  guint fsize = 0, min_size;
+  gint skip = 0;
+
+  g_return_val_if_fail (buf != NULL, GST_FLOW_ERROR);
+
+  while (TRUE) {
+
+    min_size = parse->priv->min_frame_size;
+
+    ret = gst_base_parse_pull_range (parse, min_size, &buffer);
+    if (ret != GST_FLOW_OK)
+      goto done;
+
+    if (parse->priv->discont) {
+      GST_DEBUG_OBJECT (parse, "marking DISCONT");
+      GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DISCONT);
+    }
+
+    /* if we got a short read, inform subclass we are draining leftover
+     * and no more is to be expected */
+    if (GST_BUFFER_SIZE (buffer) < min_size)
+      parse->priv->drain = TRUE;
+
+    skip = -1;
+    if (klass->check_valid_frame (parse, buffer, &fsize, &skip)) {
+      parse->priv->drain = FALSE;
+      break;
+    }
+    parse->priv->drain = FALSE;
+    if (skip == -1)
+      skip = 1;
+    if (skip > 0) {
+      GST_LOG_OBJECT (parse, "finding sync, skipping %d bytes", skip);
+      if (full && parse->segment.rate < 0.0 && !parse->priv->buffers_queued) {
+        /* reverse playback, and no frames found yet, so we are skipping
+         * the leading part of a fragment, which may form the tail of
+         * fragment coming later, hopefully subclass skips efficiently ... */
+        outbuf = gst_buffer_create_sub (buffer, 0, skip);
+        parse->priv->buffers_pending =
+            g_slist_prepend (parse->priv->buffers_pending, outbuf);
+        outbuf = NULL;
+      }
+      parse->priv->offset += skip;
+      if (!parse->priv->discont)
+        parse->priv->sync_offset = parse->priv->offset;
+      parse->priv->discont = TRUE;
+    }
+    /* skip == 0 should imply subclass set min_size to need more data ... */
+    GST_DEBUG_OBJECT (parse, "finding sync...");
+    gst_buffer_unref (buffer);
+    if ((ret = gst_base_parse_check_sync (parse)) != GST_FLOW_OK) {
+      goto done;
+    }
+  }
+
+  if (fsize <= GST_BUFFER_SIZE (buffer)) {
+    outbuf = gst_buffer_create_sub (buffer, 0, fsize);
+    GST_BUFFER_OFFSET (outbuf) = GST_BUFFER_OFFSET (buffer);
+    GST_BUFFER_TIMESTAMP (outbuf) = GST_CLOCK_TIME_NONE;
+    gst_buffer_unref (buffer);
+  } else {
+    gst_buffer_unref (buffer);
+    ret = gst_base_parse_pull_range (parse, fsize, &outbuf);
+    if (ret != GST_FLOW_OK)
+      goto done;
+    if (GST_BUFFER_SIZE (outbuf) < fsize) {
+      gst_buffer_unref (outbuf);
+      ret = GST_FLOW_UNEXPECTED;
+    }
+  }
+
+  parse->priv->offset += fsize;
+
+  /* Does the subclass want to skip too? */
+  if (skip > 0)
+    parse->priv->offset += skip;
+
+  *buf = outbuf;
+
+done:
+  return ret;
+}
+
+/**
+ * gst_base_parse_loop:
+ * @pad: GstPad
+ *
+ * Loop that is used in pull mode to retrieve data from upstream.
+ */
+static void
+gst_base_parse_loop (GstPad * pad)
+{
+  GstBaseParse *parse;
+  GstBaseParseClass *klass;
+  GstBuffer *outbuf;
+  GstFlowReturn ret = GST_FLOW_OK;
+
+  parse = GST_BASE_PARSE (gst_pad_get_parent (pad));
+  klass = GST_BASE_PARSE_GET_CLASS (parse);
+
+  /* reverse playback:
+   * first fragment (closest to stop time) is handled normally below,
+   * then we pull in fragments going backwards */
+  if (parse->segment.rate < 0.0) {
+    /* check if we jumped back to a previous fragment,
+     * which is a post-first fragment */
+    if (parse->priv->offset < 0) {
+      ret = gst_base_parse_handle_previous_fragment (parse);
+      goto done;
+    }
+  }
+
+  ret = gst_base_parse_scan_frame (parse, klass, &outbuf, TRUE);
+  if (ret != GST_FLOW_OK)
+    goto done;
+
+  /* This always unrefs the outbuf, even if error occurs */
+  ret = gst_base_parse_handle_and_push_buffer (parse, klass, outbuf);
+
+  /* eat expected eos signalling past segment in reverse playback */
+  if (parse->segment.rate < 0.0 && ret == GST_FLOW_UNEXPECTED &&
+      parse->segment.last_stop >= parse->segment.stop) {
+    GST_DEBUG_OBJECT (parse, "downstream has reached end of segment");
+    /* push what was accumulated during loop run */
+    gst_base_parse_process_fragment (parse, TRUE);
+    /* force previous fragment */
+    parse->priv->offset = -1;
+    ret = GST_FLOW_OK;
+  }
+
+done:
+  if (ret == GST_FLOW_UNEXPECTED)
+    goto eos;
+  else if (ret != GST_FLOW_OK)
+    goto pause;
+
+  gst_object_unref (parse);
+  return;
+
+  /* ERRORS */
+eos:
+  {
+    ret = GST_FLOW_UNEXPECTED;
+    GST_DEBUG_OBJECT (parse, "eos");
+    /* fall-through */
+  }
+pause:
+  {
+    gboolean push_eos = FALSE;
+
+    GST_DEBUG_OBJECT (parse, "pausing task, reason %s",
+        gst_flow_get_name (ret));
+    gst_pad_pause_task (parse->sinkpad);
+
+    if (ret == GST_FLOW_UNEXPECTED) {
+      /* handle end-of-stream/segment */
+      if (parse->segment.flags & GST_SEEK_FLAG_SEGMENT) {
+        gint64 stop;
+
+        if ((stop = parse->segment.stop) == -1)
+          stop = parse->segment.duration;
+
+        GST_DEBUG_OBJECT (parse, "sending segment_done");
+
+        gst_element_post_message
+            (GST_ELEMENT_CAST (parse),
+            gst_message_new_segment_done (GST_OBJECT_CAST (parse),
+                GST_FORMAT_TIME, stop));
+      } else {
+        /* If we STILL have zero frames processed, fire an error */
+        if (parse->priv->framecount == 0) {
+          GST_ELEMENT_ERROR (parse, STREAM, WRONG_TYPE,
+              ("No valid frames found before end of stream"), (NULL));
+        }
+        push_eos = TRUE;
+      }
+    } else if (ret == GST_FLOW_NOT_LINKED || ret < GST_FLOW_UNEXPECTED) {
+      /* for fatal errors we post an error message, wrong-state is
+       * not fatal because it happens due to flushes and only means
+       * that we should stop now. */
+      GST_ELEMENT_ERROR (parse, STREAM, FAILED, (NULL),
+          ("streaming stopped, reason %s", gst_flow_get_name (ret)));
+      push_eos = TRUE;
+    }
+    if (push_eos) {
+      /* newsegment before eos */
+      if (parse->pending_segment) {
+        gst_pad_push_event (parse->srcpad, parse->pending_segment);
+        parse->pending_segment = NULL;
+      }
+      gst_pad_push_event (parse->srcpad, gst_event_new_eos ());
+    }
+    gst_object_unref (parse);
+  }
+}
+
+
+/**
+ * gst_base_parse_sink_activate:
+ * @sinkpad: #GstPad to be activated.
+ *
+ * Returns: TRUE if activation succeeded.
+ */
+static gboolean
+gst_base_parse_sink_activate (GstPad * sinkpad)
+{
+  GstBaseParse *parse;
+  gboolean result = TRUE;
+
+  parse = GST_BASE_PARSE (gst_pad_get_parent (sinkpad));
+
+  GST_DEBUG_OBJECT (parse, "sink activate");
+
+  if (gst_pad_check_pull_range (sinkpad)) {
+    GST_DEBUG_OBJECT (parse, "trying to activate in pull mode");
+    result = gst_pad_activate_pull (sinkpad, TRUE);
+  } else {
+    GST_DEBUG_OBJECT (parse, "trying to activate in push mode");
+    result = gst_pad_activate_push (sinkpad, TRUE);
+  }
+
+  GST_DEBUG_OBJECT (parse, "sink activate return %d", result);
+  gst_object_unref (parse);
+  return result;
+}
+
+
+/**
+ * gst_base_parse_activate:
+ * @parse: #GstBaseParse.
+ * @active: TRUE if element will be activated, FALSE if deactivated.
+ *
+ * Returns: TRUE if the operation succeeded.
+ */
+static gboolean
+gst_base_parse_activate (GstBaseParse * parse, gboolean active)
+{
+  GstBaseParseClass *klass;
+  gboolean result = FALSE;
+
+  GST_DEBUG_OBJECT (parse, "activate");
+
+  klass = GST_BASE_PARSE_GET_CLASS (parse);
+
+  if (active) {
+    if (parse->priv->pad_mode == GST_ACTIVATE_NONE && klass->start)
+      result = klass->start (parse);
+  } else {
+    /* We must make sure streaming has finished before resetting things
+     * and calling the ::stop vfunc */
+    GST_PAD_STREAM_LOCK (parse->sinkpad);
+    GST_PAD_STREAM_UNLOCK (parse->sinkpad);
+
+    if (parse->priv->pad_mode != GST_ACTIVATE_NONE && klass->stop)
+      result = klass->stop (parse);
+
+    parse->priv->pad_mode = GST_ACTIVATE_NONE;
+  }
+  GST_DEBUG_OBJECT (parse, "activate: %d", result);
+  return result;
+}
+
+
+/**
+ * gst_base_parse_sink_activate_push:
+ * @pad: #GstPad to be (de)activated.
+ * @active: TRUE when activating, FALSE when deactivating.
+ *
+ * Returns: TRUE if (de)activation succeeded.
+ */
+static gboolean
+gst_base_parse_sink_activate_push (GstPad * pad, gboolean active)
+{
+  gboolean result = TRUE;
+  GstBaseParse *parse;
+
+  parse = GST_BASE_PARSE (gst_pad_get_parent (pad));
+
+  GST_DEBUG_OBJECT (parse, "sink activate push");
+
+  result = gst_base_parse_activate (parse, active);
+
+  if (result)
+    parse->priv->pad_mode = active ? GST_ACTIVATE_PUSH : GST_ACTIVATE_NONE;
+
+  GST_DEBUG_OBJECT (parse, "sink activate push: %d", result);
+
+  gst_object_unref (parse);
+  return result;
+}
+
+
+/**
+ * gst_base_parse_sink_activate_pull:
+ * @sinkpad: #GstPad to be (de)activated.
+ * @active: TRUE when activating, FALSE when deactivating.
+ *
+ * Returns: TRUE if (de)activation succeeded.
+ */
+static gboolean
+gst_base_parse_sink_activate_pull (GstPad * sinkpad, gboolean active)
+{
+  gboolean result = FALSE;
+  GstBaseParse *parse;
+
+  parse = GST_BASE_PARSE (gst_pad_get_parent (sinkpad));
+
+  GST_DEBUG_OBJECT (parse, "activate pull");
+
+  result = gst_base_parse_activate (parse, active);
+
+  if (result) {
+    if (active) {
+      parse->pending_segment = gst_event_new_new_segment (FALSE,
+          parse->segment.rate, parse->segment.format,
+          parse->segment.start, parse->segment.stop, parse->segment.last_stop);
+      result &= gst_pad_start_task (sinkpad,
+          (GstTaskFunction) gst_base_parse_loop, sinkpad);
+    } else {
+      result &= gst_pad_stop_task (sinkpad);
+    }
+  }
+
+  if (result)
+    parse->priv->pad_mode = active ? GST_ACTIVATE_PULL : GST_ACTIVATE_NONE;
+
+  GST_DEBUG_OBJECT (parse, "sink activate pull: %d", result);
+
+  gst_object_unref (parse);
+  return result;
+}
+
+
+/**
+ * gst_base_parse_set_duration:
+ * @parse: #GstBaseParse.
+ * @fmt: #GstFormat.
+ * @duration: duration value.
+ *
+ * Sets the duration of the currently playing media. Subclass can use this
+ * when it is able to determine duration and/or notices a change in the media
+ * duration.  Alternatively, if @interval is non-zero (default), then stream
+ * duration is determined based on estimated bitrate, and updated every @interval
+ * frames. */
+void
+gst_base_parse_set_duration (GstBaseParse * parse,
+    GstFormat fmt, gint64 duration, gint interval)
+{
+  g_return_if_fail (parse != NULL);
+
+  if (parse->priv->upstream_has_duration) {
+    GST_DEBUG_OBJECT (parse, "using upstream duration; discarding update");
+    goto exit;
+  }
+
+  if (duration != parse->priv->duration) {
+    GstMessage *m;
+
+    m = gst_message_new_duration (GST_OBJECT (parse), fmt, duration);
+    gst_element_post_message (GST_ELEMENT (parse), m);
+
+    /* TODO: what about duration tag? */
+  }
+  parse->priv->duration = duration;
+  parse->priv->duration_fmt = fmt;
+  GST_DEBUG_OBJECT (parse, "set duration: %" G_GINT64_FORMAT, duration);
+  if (fmt == GST_FORMAT_TIME && GST_CLOCK_TIME_IS_VALID (duration)) {
+    if (interval != 0) {
+      GST_DEBUG_OBJECT (parse, "valid duration provided, disabling estimate");
+      interval = 0;
+    }
+  }
+  GST_DEBUG_OBJECT (parse, "set update interval: %d", interval);
+  parse->priv->update_interval = interval;
+exit:
+  return;
+}
+
+/**
+ * gst_base_parse_set_seek:
+ * @parse: #GstBaseParse.
+ * @seek: #GstBaseParseSeekable.
+ * @abitrate: average bitrate.
+ *
+ * Sets whether and how the media is seekable (in time).
+ * Also optionally provides average bitrate detected in media (if non-zero),
+ * e.g. based on metadata, as it will be posted to the application.
+ *
+ * By default, announced average bitrate is estimated, and seekability is assumed
+ * possible based on estimated bitrate.
+ */
+void
+gst_base_parse_set_seek (GstBaseParse * parse,
+    GstBaseParseSeekable seek, guint bitrate)
+{
+  parse->priv->seekable = seek;
+  parse->priv->bitrate = bitrate;
+  GST_DEBUG_OBJECT (parse, "seek %d, bitrate %d", seek, bitrate);
+}
+
+
+/**
+ * gst_base_parse_set_min_frame_size:
+ * @parse: #GstBaseParse.
+ * @min_size: Minimum size of the data that this base class should give to
+ *            subclass.
+ *
+ * Subclass can use this function to tell the base class that it needs to
+ * give at least #min_size buffers.
+ */
+void
+gst_base_parse_set_min_frame_size (GstBaseParse * parse, guint min_size)
+{
+  g_return_if_fail (parse != NULL);
+
+  parse->priv->min_frame_size = min_size;
+  GST_LOG_OBJECT (parse, "set frame_min_size: %d", min_size);
+}
+
+/**
+ * gst_base_transform_set_passthrough:
+ * @trans: the #GstBaseParse to set
+ * @passthrough: boolean indicating passthrough mode.
+ *
+ * Set passthrough mode for this parser.  If operating in passthrough,
+ * incoming buffers are pushed through unmodified.
+ */
+void
+gst_base_parse_set_passthrough (GstBaseParse * parse, gboolean passthrough)
+{
+  g_return_if_fail (parse != NULL);
+
+  parse->priv->passthrough = passthrough;
+  GST_LOG_OBJECT (parse, "set passthrough: %d", passthrough);
+}
+
+/**
+ * gst_base_transform_set_frame_props:
+ * @parse: the #GstBaseParse to set
+ * @fps_num: frames per second (numerator).
+ * @fps_den: frames per second (denominator).
+ * @lead_in: frames needed before a segment for subsequent decode
+ * @lead_out: frames needed after a segment
+ *
+ * If frames per second is configured, parser can take care of buffer duration
+ * and timestamping.  When performing segment clipping, or seeking to a specific
+ * location, a corresponding decoder might need an initial @lead_in and a
+ * following @lead_out number of frames to ensure the desired segment is
+ * entirely filled upon decoding.
+ */
+void
+gst_base_parse_set_frame_props (GstBaseParse * parse, guint fps_num,
+    guint fps_den, guint lead_in, guint lead_out)
+{
+  g_return_if_fail (parse != NULL);
+
+  parse->priv->fps_num = fps_num;
+  parse->priv->fps_den = fps_den;
+  if (!fps_num || !fps_den) {
+    GST_DEBUG_OBJECT (parse, "invalid fps (%d/%d), ignoring parameters",
+        fps_num, fps_den);
+    fps_num = fps_den = 0;
+    parse->priv->frame_duration = GST_CLOCK_TIME_NONE;
+    parse->priv->lead_in = parse->priv->lead_out = 0;
+    parse->priv->lead_in_ts = parse->priv->lead_out_ts = 0;
+  } else {
+    parse->priv->frame_duration =
+        gst_util_uint64_scale (GST_SECOND, fps_den, fps_num);
+    parse->priv->lead_in = lead_in;
+    parse->priv->lead_out = lead_out;
+    parse->priv->lead_in_ts =
+        gst_util_uint64_scale (GST_SECOND, fps_den * lead_in, fps_num);
+    parse->priv->lead_out_ts =
+        gst_util_uint64_scale (GST_SECOND, fps_den * lead_out, fps_num);
+  }
+  GST_LOG_OBJECT (parse, "set fps: %d/%d => duration: %" G_GINT64_FORMAT " ms",
+      fps_num, fps_den, parse->priv->frame_duration / GST_MSECOND);
+  GST_LOG_OBJECT (parse, "set lead in: %d frames = %" G_GUINT64_FORMAT " ms, "
+      "lead out: %d frames = %" G_GUINT64_FORMAT " ms",
+      lead_in, parse->priv->lead_in_ts / GST_MSECOND,
+      lead_out, parse->priv->lead_out_ts / GST_MSECOND);
+}
+
+/**
+ * gst_base_transform_get_sync:
+ * @parse: the #GstBaseParse to query
+ *
+ * Returns: TRUE if parser is considered 'in sync'.  That is, frames have been
+ * continuously successfully parsed and pushed.
+ */
+gboolean
+gst_base_parse_get_sync (GstBaseParse * parse)
+{
+  gboolean ret;
+
+  g_return_val_if_fail (parse != NULL, FALSE);
+
+  /* losing sync is pretty much a discont (and vice versa), no ? */
+  ret = !parse->priv->discont;
+
+  GST_DEBUG_OBJECT (parse, "sync: %d", ret);
+  return ret;
+}
+
+/**
+ * gst_base_transform_get_drain:
+ * @parse: the #GstBaseParse to query
+ *
+ * Returns: TRUE if parser is currently 'draining'.  That is, leftover data
+ * (e.g. in FLUSH or EOS situation) is being parsed.
+ */
+gboolean
+gst_base_parse_get_drain (GstBaseParse * parse)
+{
+  gboolean ret;
+
+  g_return_val_if_fail (parse != NULL, FALSE);
+
+  /* losing sync is pretty much a discont (and vice versa), no ? */
+  ret = parse->priv->drain;
+
+  GST_DEBUG_OBJECT (parse, "drain: %d", ret);
+  return ret;
+}
+
+static gboolean
+gst_base_parse_get_duration (GstBaseParse * parse, GstFormat format,
+    GstClockTime * duration)
+{
+  gboolean res = FALSE;
+
+  g_return_val_if_fail (duration != NULL, FALSE);
+
+  *duration = GST_CLOCK_TIME_NONE;
+  if (parse->priv->duration != -1 && format == parse->priv->duration_fmt) {
+    GST_LOG_OBJECT (parse, "using provided duration");
+    *duration = parse->priv->duration;
+    res = TRUE;
+  } else if (parse->priv->duration != -1) {
+    GST_LOG_OBJECT (parse, "converting provided duration");
+    res = gst_base_parse_convert (parse, parse->priv->duration_fmt,
+        parse->priv->duration, format, (gint64 *) duration);
+  } else if (format == GST_FORMAT_TIME && parse->priv->estimated_duration != -1) {
+    GST_LOG_OBJECT (parse, "using estimated duration");
+    *duration = parse->priv->estimated_duration;
+    res = TRUE;
+  }
+
+  GST_LOG_OBJECT (parse, "res: %d, duration %" GST_TIME_FORMAT, res,
+      GST_TIME_ARGS (*duration));
+  return res;
+}
+
+/**
+ * gst_base_parse_get_querytypes:
+ * @pad: GstPad
+ *
+ * Returns: A table of #GstQueryType items describing supported query types.
+ */
+static const GstQueryType *
+gst_base_parse_get_querytypes (GstPad * pad)
+{
+  static const GstQueryType list[] = {
+    GST_QUERY_POSITION,
+    GST_QUERY_DURATION,
+    GST_QUERY_FORMATS,
+    GST_QUERY_SEEKING,
+    GST_QUERY_CONVERT,
+    0
+  };
+
+  return list;
+}
+
+
+/**
+ * gst_base_parse_query:
+ * @pad: #GstPad.
+ * @query: #GstQuery.
+ *
+ * Returns: TRUE on success.
+ */
+static gboolean
+gst_base_parse_query (GstPad * pad, GstQuery * query)
+{
+  GstBaseParse *parse;
+  gboolean res = FALSE;
+
+  parse = GST_BASE_PARSE (GST_PAD_PARENT (pad));
+
+  GST_LOG_OBJECT (parse, "handling query: %" GST_PTR_FORMAT, query);
+
+  switch (GST_QUERY_TYPE (query)) {
+    case GST_QUERY_POSITION:
+    {
+      gint64 dest_value;
+      GstFormat format;
+
+      GST_DEBUG_OBJECT (parse, "position query");
+      gst_query_parse_position (query, &format, NULL);
+
+      GST_OBJECT_LOCK (parse);
+      if (format == GST_FORMAT_BYTES) {
+        dest_value = parse->priv->offset;
+        res = TRUE;
+      } else if (format == parse->segment.format &&
+          GST_CLOCK_TIME_IS_VALID (parse->segment.last_stop)) {
+        dest_value = parse->segment.last_stop;
+        res = TRUE;
+      }
+      GST_OBJECT_UNLOCK (parse);
+
+      if (res)
+        gst_query_set_position (query, format, dest_value);
+      else {
+        res = gst_pad_query_default (pad, query);
+        if (!res) {
+          /* no precise result, upstream no idea either, then best estimate */
+          /* priv->offset is updated in both PUSH/PULL modes */
+          res = gst_base_parse_convert (parse,
+              GST_FORMAT_BYTES, parse->priv->offset, format, &dest_value);
+        }
+      }
+      break;
+    }
+    case GST_QUERY_DURATION:
+    {
+      GstFormat format;
+      GstClockTime duration;
+
+      GST_DEBUG_OBJECT (parse, "duration query");
+      gst_query_parse_duration (query, &format, NULL);
+
+      /* consult upstream */
+      res = gst_pad_query_default (pad, query);
+
+      /* otherwise best estimate from us */
+      if (!res) {
+        res = gst_base_parse_get_duration (parse, format, &duration);
+        if (res)
+          gst_query_set_duration (query, format, duration);
+      }
+      break;
+    }
+    case GST_QUERY_SEEKING:
+    {
+      GstFormat fmt;
+      GstClockTime duration = GST_CLOCK_TIME_NONE;
+      gboolean seekable = FALSE;
+
+      GST_DEBUG_OBJECT (parse, "seeking query");
+      gst_query_parse_seeking (query, &fmt, NULL, NULL, NULL);
+
+      /* consult upstream */
+      res = gst_pad_query_default (pad, query);
+
+      /* we may be able to help if in TIME */
+      if (fmt == GST_FORMAT_TIME &&
+          parse->priv->seekable > GST_BASE_PARSE_SEEK_NONE) {
+        gst_query_parse_seeking (query, &fmt, &seekable, NULL, NULL);
+        /* already OK if upstream takes care */
+        GST_LOG_OBJECT (parse, "upstream handled %d, seekable %d",
+            res, seekable);
+        if (!(res && seekable)) {
+          if (!gst_base_parse_get_duration (parse, GST_FORMAT_TIME, &duration)
+              || duration == -1) {
+            seekable = FALSE;
+          } else {
+            seekable = parse->priv->upstream_seekable;
+            GST_LOG_OBJECT (parse, "already determine upstream seekabled: %d",
+                seekable);
+          }
+          gst_query_set_seeking (query, GST_FORMAT_TIME, seekable, 0, duration);
+          res = TRUE;
+        }
+      }
+      break;
+    }
+    case GST_QUERY_FORMATS:
+      gst_query_set_formatsv (query, 3, fmtlist);
+      res = TRUE;
+      break;
+    case GST_QUERY_CONVERT:
+    {
+      GstFormat src_format, dest_format;
+      gint64 src_value, dest_value;
+
+      gst_query_parse_convert (query, &src_format, &src_value,
+          &dest_format, &dest_value);
+
+      res = gst_base_parse_convert (parse, src_format, src_value,
+          dest_format, &dest_value);
+      if (res) {
+        gst_query_set_convert (query, src_format, src_value,
+            dest_format, dest_value);
+      }
+      break;
+    }
+    default:
+      res = gst_pad_query_default (pad, query);
+      break;
+  }
+  return res;
+}
+
+/* scans for a cluster start from @pos,
+ * return GST_FLOW_OK and frame position/time in @pos/@time if found */
+static GstFlowReturn
+gst_base_parse_find_frame (GstBaseParse * parse, gint64 * pos,
+    GstClockTime * time, GstClockTime * duration)
+{
+  GstBaseParseClass *klass;
+  gint64 orig_offset;
+  gboolean orig_drain, orig_discont;
+  GstFlowReturn ret = GST_FLOW_OK;
+  GstBuffer *buf = NULL;
+
+  g_return_val_if_fail (GST_FLOW_ERROR, pos != NULL);
+  g_return_val_if_fail (GST_FLOW_ERROR, time != NULL);
+  g_return_val_if_fail (GST_FLOW_ERROR, duration != NULL);
+
+  klass = GST_BASE_PARSE_GET_CLASS (parse);
+
+  *time = GST_CLOCK_TIME_NONE;
+  *duration = GST_CLOCK_TIME_NONE;
+
+  /* save state */
+  orig_offset = parse->priv->offset;
+  orig_discont = parse->priv->discont;
+  orig_drain = parse->priv->drain;
+
+  GST_DEBUG_OBJECT (parse, "scanning for frame starting at %" G_GINT64_FORMAT
+      " (%#" G_GINT64_MODIFIER "x)", *pos, *pos);
+
+  /* jump elsewhere and locate next frame */
+  parse->priv->offset = *pos;
+  ret = gst_base_parse_scan_frame (parse, klass, &buf, FALSE);
+  if (ret != GST_FLOW_OK)
+    goto done;
+
+  GST_LOG_OBJECT (parse,
+      "peek parsing frame at offset %" G_GUINT64_FORMAT
+      " (%#" G_GINT64_MODIFIER "x) of size %d",
+      GST_BUFFER_OFFSET (buf), GST_BUFFER_OFFSET (buf), GST_BUFFER_SIZE (buf));
+
+  /* get offset first, subclass parsing might dump other stuff in there */
+  *pos = GST_BUFFER_OFFSET (buf);
+  ret = klass->parse_frame (parse, buf);
+
+  /* but it should provide proper time */
+  *time = GST_BUFFER_TIMESTAMP (buf);
+  *duration = GST_BUFFER_DURATION (buf);
+  gst_buffer_unref (buf);
+
+  GST_LOG_OBJECT (parse,
+      "frame with time %" GST_TIME_FORMAT " at offset %" G_GINT64_FORMAT,
+      GST_TIME_ARGS (*time), *pos);
+
+done:
+  /* restore state */
+  parse->priv->offset = orig_offset;
+  parse->priv->discont = orig_discont;
+  parse->priv->drain = orig_drain;
+
+  return ret;
+}
+
+/* bisect and scan through file for frame starting before @time,
+ * returns OK and @time/@offset if found, NONE and/or error otherwise
+ * If @time == G_MAXINT64, scan for duration ( == last frame) */
+static GstFlowReturn
+gst_base_parse_locate_time (GstBaseParse * parse, GstClockTime * _time,
+    gint64 * _offset)
+{
+  GstFlowReturn ret = GST_FLOW_OK;
+  gint64 lpos, hpos, newpos;
+  GstClockTime time, ltime, htime, newtime, dur;
+  gboolean cont = TRUE;
+  const GstClockTime tolerance = TARGET_DIFFERENCE;
+  const guint chunk = 4 * 1024;
+
+  g_return_val_if_fail (_time != NULL, GST_FLOW_ERROR);
+  g_return_val_if_fail (_offset != NULL, GST_FLOW_ERROR);
+
+  /* TODO also make keyframe aware if useful some day */
+
+  time = *_time;
+
+  /* basic cases */
+  if (time == 0) {
+    *_offset = 0;
+    return GST_FLOW_OK;
+  }
+
+  if (time == -1) {
+    *_offset = -1;
+    return GST_FLOW_OK;
+  }
+
+  /* do not know at first */
+  *_offset = -1;
+  *_time = GST_CLOCK_TIME_NONE;
+
+  /* need initial positions; start and end */
+  lpos = parse->priv->first_frame_offset;
+  ltime = parse->priv->first_frame_ts;
+  htime = parse->priv->duration;
+  hpos = parse->priv->upstream_size;
+
+  /* check preconditions are satisfied;
+   * start and end are needed, except for special case where we scan for
+   * last frame to determine duration */
+  if (parse->priv->pad_mode != GST_ACTIVATE_PULL || !hpos ||
+      !GST_CLOCK_TIME_IS_VALID (ltime) ||
+      (!GST_CLOCK_TIME_IS_VALID (htime) && time != G_MAXINT64)) {
+    return GST_FLOW_OK;
+  }
+
+  /* shortcut cases */
+  if (time < ltime) {
+    goto exit;
+  } else if (time < ltime + tolerance) {
+    *_offset = lpos;
+    *_time = ltime;
+    goto exit;
+  } else if (time >= htime) {
+    *_offset = hpos;
+    *_time = htime;
+    goto exit;
+  }
+
+  while (htime > ltime && cont) {
+    GST_LOG_OBJECT (parse,
+        "lpos: %" G_GUINT64_FORMAT ", ltime: %" GST_TIME_FORMAT, lpos,
+        GST_TIME_ARGS (ltime));
+    GST_LOG_OBJECT (parse,
+        "hpos: %" G_GUINT64_FORMAT ", htime: %" GST_TIME_FORMAT, hpos,
+        GST_TIME_ARGS (htime));
+    if (G_UNLIKELY (time == G_MAXINT64)) {
+      newpos = hpos;
+    } else if (G_LIKELY (hpos > lpos)) {
+      newpos =
+          gst_util_uint64_scale (hpos - lpos, time - ltime, htime - ltime) +
+          lpos - chunk;
+    } else {
+      newpos = lpos;
+      /* we check this case once, but not forever, so break loop */
+      cont = FALSE;
+    }
+
+    /* ensure */
+    newpos = CLAMP (newpos, lpos, hpos);
+    GST_LOG_OBJECT (parse,
+        "estimated _offset for %" GST_TIME_FORMAT ": %" G_GINT64_FORMAT,
+        GST_TIME_ARGS (time), newpos);
+
+    ret = gst_base_parse_find_frame (parse, &newpos, &newtime, &dur);
+    if (ret == GST_FLOW_UNEXPECTED) {
+      /* heuristic HACK */
+      hpos = MAX (lpos, hpos - chunk);
+      continue;
+    } else if (ret != GST_FLOW_OK) {
+      goto exit;
+    }
+
+    if (newtime == -1 || newpos == -1) {
+      GST_DEBUG_OBJECT (parse, "subclass did not provide metadata; aborting");
+      break;
+    }
+
+    if (G_UNLIKELY (time == G_MAXINT64)) {
+      *_offset = newpos;
+      *_time = newtime;
+      if (GST_CLOCK_TIME_IS_VALID (dur))
+        *_time += dur;
+      break;
+    } else if (newtime > time) {
+      /* overshoot */
+      newpos -= newpos == hpos ? chunk : 0;
+      hpos = CLAMP (newpos, lpos, hpos);
+      htime = newtime;
+    } else if (newtime + tolerance > time) {
+      /* close enough undershoot */
+      *_offset = newpos;
+      *_time = newtime;
+      break;
+    } else if (newtime < ltime) {
+      /* so a position beyond lpos resulted in earlier time than ltime ... */
+      GST_DEBUG_OBJECT (parse, "non-ascending time; aborting");
+    } else {
+      /* undershoot too far */
+      newpos += newpos == hpos ? chunk : 0;
+      lpos = CLAMP (newpos, lpos, hpos);
+      ltime = newtime;
+    }
+  }
+
+exit:
+  GST_LOG_OBJECT (parse, "return offset %" G_GINT64_FORMAT ", time %"
+      GST_TIME_FORMAT, *_offset, GST_TIME_ARGS (*_time));
+  return ret;
+}
+
+static gint64
+gst_base_parse_find_offset (GstBaseParse * parse, GstClockTime time,
+    gboolean before, GstClockTime * _ts)
+{
+  gint64 bytes = 0, ts = 0;
+  GstIndexEntry *entry = NULL;
+
+  if (time == GST_CLOCK_TIME_NONE) {
+    ts = time;
+    bytes = -1;
+    goto exit;
+  }
+
+  GST_OBJECT_LOCK (parse);
+  if (parse->priv->index) {
+    /* Let's check if we have an index entry for that time */
+    entry = gst_index_get_assoc_entry (parse->priv->index,
+        parse->priv->index_id,
+        before ? GST_INDEX_LOOKUP_BEFORE : GST_INDEX_LOOKUP_AFTER,
+        GST_ASSOCIATION_FLAG_KEY_UNIT, GST_FORMAT_TIME, time);
+  }
+
+  if (entry) {
+    gst_index_entry_assoc_map (entry, GST_FORMAT_BYTES, &bytes);
+    gst_index_entry_assoc_map (entry, GST_FORMAT_TIME, &ts);
+
+    GST_DEBUG_OBJECT (parse, "found index entry for %" GST_TIME_FORMAT
+        " at %" GST_TIME_FORMAT ", offset %" G_GINT64_FORMAT,
+        GST_TIME_ARGS (time), GST_TIME_ARGS (ts), bytes);
+  } else {
+    GST_DEBUG_OBJECT (parse, "no index entry found for %" GST_TIME_FORMAT,
+        GST_TIME_ARGS (time));
+    if (!before) {
+      bytes = -1;
+      ts = GST_CLOCK_TIME_NONE;
+    }
+  }
+  GST_OBJECT_UNLOCK (parse);
+
+exit:
+  if (_ts)
+    *_ts = ts;
+
+  return bytes;
+}
+
+
+/**
+ * gst_base_parse_handle_seek:
+ * @parse: #GstBaseParse.
+ * @event: #GstEvent.
+ *
+ * Returns: TRUE if seek succeeded.
+ */
+static gboolean
+gst_base_parse_handle_seek (GstBaseParse * parse, GstEvent * event)
+{
+  gdouble rate;
+  GstFormat format;
+  GstSeekFlags flags;
+  GstSeekType cur_type = GST_SEEK_TYPE_NONE, stop_type;
+  gboolean flush, update, res = TRUE, accurate;
+  gint64 cur, stop, seekpos, seekstop;
+  GstSegment seeksegment = { 0, };
+  GstFormat dstformat;
+  GstClockTime start_ts;
+
+  gst_event_parse_seek (event, &rate, &format, &flags,
+      &cur_type, &cur, &stop_type, &stop);
+
+  GST_DEBUG_OBJECT (parse, "seek to format %s, rate %f, "
+      "start type %d at %" GST_TIME_FORMAT ", end type %d at %"
+      GST_TIME_FORMAT, gst_format_get_name (format), rate,
+      cur_type, GST_TIME_ARGS (cur), stop_type, GST_TIME_ARGS (stop));
+
+  /* no negative rates in push mode */
+  if (rate < 0.0 && parse->priv->pad_mode == GST_ACTIVATE_PUSH)
+    goto negative_rate;
+
+  if (cur_type != GST_SEEK_TYPE_SET ||
+      (stop_type != GST_SEEK_TYPE_SET && stop_type != GST_SEEK_TYPE_NONE))
+    goto wrong_type;
+
+  /* For any format other than TIME, see if upstream handles
+   * it directly or fail. For TIME, try upstream, but do it ourselves if
+   * it fails upstream */
+  if (format != GST_FORMAT_TIME) {
+    /* default action delegates to upstream */
+    return FALSE;
+  } else {
+    gst_event_ref (event);
+    if (gst_pad_push_event (parse->sinkpad, event)) {
+      return TRUE;
+    }
+  }
+
+  /* get flush flag */
+  flush = flags & GST_SEEK_FLAG_FLUSH;
+
+  /* copy segment, we need this because we still need the old
+   * segment when we close the current segment. */
+  memcpy (&seeksegment, &parse->segment, sizeof (GstSegment));
+
+  GST_DEBUG_OBJECT (parse, "configuring seek");
+  gst_segment_set_seek (&seeksegment, rate, format, flags,
+      cur_type, cur, stop_type, stop, &update);
+
+  /* accurate seeking implies seek tables are used to obtain position,
+   * and the requested segment is maintained exactly, not adjusted any way */
+  accurate = flags & GST_SEEK_FLAG_ACCURATE;
+
+  /* maybe we can be accurate for (almost) free */
+  gst_base_parse_find_offset (parse, seeksegment.last_stop, TRUE, &start_ts);
+  if (seeksegment.last_stop <= start_ts + TARGET_DIFFERENCE) {
+    GST_DEBUG_OBJECT (parse, "accurate seek possible");
+    accurate = TRUE;
+  }
+  if (accurate) {
+    GstClockTime startpos = seeksegment.last_stop;
+
+    /* accurate requested, so ... seek a bit before target */
+    if (startpos < parse->priv->lead_in_ts)
+      startpos = 0;
+    else
+      startpos -= parse->priv->lead_in_ts;
+    seekpos = gst_base_parse_find_offset (parse, startpos, TRUE, &start_ts);
+    seekstop = gst_base_parse_find_offset (parse, seeksegment.stop, FALSE,
+        NULL);
+  } else {
+    start_ts = seeksegment.last_stop;
+    dstformat = GST_FORMAT_BYTES;
+    if (!gst_pad_query_convert (parse->srcpad, format, seeksegment.last_stop,
+            &dstformat, &seekpos))
+      goto convert_failed;
+    if (!gst_pad_query_convert (parse->srcpad, format, seeksegment.stop,
+            &dstformat, &seekstop))
+      goto convert_failed;
+  }
+
+  GST_DEBUG_OBJECT (parse,
+      "seek position %" G_GINT64_FORMAT " in bytes: %" G_GINT64_FORMAT,
+      start_ts, seekpos);
+  GST_DEBUG_OBJECT (parse,
+      "seek stop %" G_GINT64_FORMAT " in bytes: %" G_GINT64_FORMAT,
+      seeksegment.stop, seekstop);
+
+  if (parse->priv->pad_mode == GST_ACTIVATE_PULL) {
+    gint64 last_stop;
+
+    GST_DEBUG_OBJECT (parse, "seek in PULL mode");
+
+    if (flush) {
+      if (parse->srcpad) {
+        GST_DEBUG_OBJECT (parse, "sending flush start");
+        gst_pad_push_event (parse->srcpad, gst_event_new_flush_start ());
+        /* unlock upstream pull_range */
+        gst_pad_push_event (parse->sinkpad, gst_event_new_flush_start ());
+      }
+    } else {
+      gst_pad_pause_task (parse->sinkpad);
+    }
+
+    /* we should now be able to grab the streaming thread because we stopped it
+     * with the above flush/pause code */
+    GST_PAD_STREAM_LOCK (parse->sinkpad);
+
+    /* save current position */
+    last_stop = parse->segment.last_stop;
+    GST_DEBUG_OBJECT (parse, "stopped streaming at %" G_GINT64_FORMAT,
+        last_stop);
+
+    /* now commit to new position */
+
+    /* prepare for streaming again */
+    if (flush) {
+      GST_DEBUG_OBJECT (parse, "sending flush stop");
+      gst_pad_push_event (parse->srcpad, gst_event_new_flush_stop ());
+      gst_pad_push_event (parse->sinkpad, gst_event_new_flush_stop ());
+      gst_base_parse_clear_queues (parse);
+    } else {
+      if (parse->close_segment)
+        gst_event_unref (parse->close_segment);
+
+      parse->close_segment = gst_event_new_new_segment (TRUE,
+          parse->segment.rate, parse->segment.format,
+          parse->segment.accum, parse->segment.last_stop, parse->segment.accum);
+
+      /* keep track of our last_stop */
+      seeksegment.accum = parse->segment.last_stop;
+
+      GST_DEBUG_OBJECT (parse, "Created close seg format %d, "
+          "start = %" GST_TIME_FORMAT ", stop = %" GST_TIME_FORMAT
+          ", pos = %" GST_TIME_FORMAT, format,
+          GST_TIME_ARGS (parse->segment.accum),
+          GST_TIME_ARGS (parse->segment.last_stop),
+          GST_TIME_ARGS (parse->segment.accum));
+    }
+
+    memcpy (&parse->segment, &seeksegment, sizeof (GstSegment));
+
+    /* store the newsegment event so it can be sent from the streaming thread. */
+    if (parse->pending_segment)
+      gst_event_unref (parse->pending_segment);
+
+    /* This will be sent later in _loop() */
+    parse->pending_segment =
+        gst_event_new_new_segment (FALSE, parse->segment.rate,
+        parse->segment.format, parse->segment.start, parse->segment.stop,
+        parse->segment.start);
+
+    GST_DEBUG_OBJECT (parse, "Created newseg format %d, "
+        "start = %" GST_TIME_FORMAT ", stop = %" GST_TIME_FORMAT
+        ", pos = %" GST_TIME_FORMAT, format,
+        GST_TIME_ARGS (parse->segment.start),
+        GST_TIME_ARGS (parse->segment.stop),
+        GST_TIME_ARGS (parse->segment.start));
+
+    /* one last chance in pull mode to stay accurate;
+     * maybe scan and subclass can find where to go */
+    if (!accurate) {
+      gint64 scanpos;
+      GstClockTime ts = seeksegment.last_stop;
+
+      gst_base_parse_locate_time (parse, &ts, &scanpos);
+      if (scanpos >= 0) {
+        accurate = TRUE;
+        seekpos = scanpos;
+        /* running collected index now consists of several intervals,
+         * so optimized check no longer possible */
+        parse->priv->index_last_valid = FALSE;
+        parse->priv->index_last_offset = 0;
+        parse->priv->index_last_ts = 0;
+      }
+    }
+
+    /* mark discont if we are going to stream from another position. */
+    if (seekpos != parse->priv->offset) {
+      GST_DEBUG_OBJECT (parse,
+          "mark DISCONT, we did a seek to another position");
+      parse->priv->offset = seekpos;
+      parse->priv->last_offset = seekpos;
+      parse->priv->seen_keyframe = FALSE;
+      parse->priv->discont = TRUE;
+      parse->priv->next_ts = start_ts;
+      parse->priv->last_ts = GST_CLOCK_TIME_NONE;
+      parse->priv->sync_offset = seekpos;
+      parse->priv->exact_position = accurate;
+    }
+
+    /* Start streaming thread if paused */
+    gst_pad_start_task (parse->sinkpad,
+        (GstTaskFunction) gst_base_parse_loop, parse->sinkpad);
+
+    GST_PAD_STREAM_UNLOCK (parse->sinkpad);
+  } else {
+    GstEvent *new_event;
+    GstBaseParseSeek *seek;
+
+    /* The only thing we need to do in PUSH-mode is to send the
+       seek event (in bytes) to upstream. Segment / flush handling happens
+       in corresponding src event handlers */
+    GST_DEBUG_OBJECT (parse, "seek in PUSH mode");
+    if (seekstop >= 0 && seekpos <= seekpos)
+      seekstop = seekpos;
+    new_event = gst_event_new_seek (rate, GST_FORMAT_BYTES, flush,
+        GST_SEEK_TYPE_SET, seekpos, stop_type, seekstop);
+
+    /* store segment info so its precise details can be reconstructed when
+     * receiving newsegment;
+     * this matters for all details when accurate seeking,
+     * is most useful to preserve NONE stop time otherwise */
+    seek = g_new0 (GstBaseParseSeek, 1);
+    seek->segment = seeksegment;
+    seek->accurate = accurate;
+    seek->offset = seekpos;
+    seek->start_ts = start_ts;
+    GST_OBJECT_LOCK (parse);
+    /* less optimal, but preserves order */
+    parse->priv->pending_seeks =
+        g_slist_append (parse->priv->pending_seeks, seek);
+    GST_OBJECT_UNLOCK (parse);
+
+    res = gst_pad_push_event (parse->sinkpad, new_event);
+
+    if (!res) {
+      GST_OBJECT_LOCK (parse);
+      parse->priv->pending_seeks =
+          g_slist_remove (parse->priv->pending_seeks, seek);
+      GST_OBJECT_UNLOCK (parse);
+      g_free (seek);
+    }
+  }
+
+done:
+  return res;
+
+  /* ERRORS */
+negative_rate:
+  {
+    GST_DEBUG_OBJECT (parse, "negative playback rates are not supported yet.");
+    res = FALSE;
+    goto done;
+  }
+wrong_type:
+  {
+    GST_DEBUG_OBJECT (parse, "unsupported seek type.");
+    res = FALSE;
+    goto done;
+  }
+convert_failed:
+  {
+    GST_DEBUG_OBJECT (parse, "conversion TIME to BYTES failed.");
+    res = FALSE;
+    goto done;
+  }
+}
+
+/**
+ * gst_base_parse_handle_tag:
+ * @parse: #GstBaseParse.
+ * @event: #GstEvent.
+ *
+ * Checks if bitrates are available from upstream tags so that we don't
+ * override them later
+ */
+static void
+gst_base_parse_handle_tag (GstBaseParse * parse, GstEvent * event)
+{
+  GstTagList *taglist = NULL;
+  guint tmp;
+
+  gst_event_parse_tag (event, &taglist);
+
+  if (gst_tag_list_get_uint (taglist, GST_TAG_MINIMUM_BITRATE, &tmp)) {
+    GST_DEBUG_OBJECT (parse, "upstream min bitrate %d", tmp);
+    parse->priv->post_min_bitrate = FALSE;
+  }
+  if (gst_tag_list_get_uint (taglist, GST_TAG_BITRATE, &tmp)) {
+    GST_DEBUG_OBJECT (parse, "upstream avg bitrate %d", tmp);
+    parse->priv->post_avg_bitrate = FALSE;
+  }
+  if (gst_tag_list_get_uint (taglist, GST_TAG_MAXIMUM_BITRATE, &tmp)) {
+    GST_DEBUG_OBJECT (parse, "upstream max bitrate %d", tmp);
+    parse->priv->post_max_bitrate = FALSE;
+  }
+}
+
+/**
+ * gst_base_parse_sink_setcaps:
+ * @pad: #GstPad.
+ * @caps: #GstCaps.
+ *
+ * Returns: TRUE if caps were accepted.
+ */
+static gboolean
+gst_base_parse_sink_setcaps (GstPad * pad, GstCaps * caps)
+{
+  GstBaseParse *parse;
+  GstBaseParseClass *klass;
+  gboolean res = TRUE;
+
+  parse = GST_BASE_PARSE (GST_PAD_PARENT (pad));
+  klass = GST_BASE_PARSE_GET_CLASS (parse);
+
+  GST_DEBUG_OBJECT (parse, "caps: %" GST_PTR_FORMAT, caps);
+
+  if (klass->set_sink_caps)
+    res = klass->set_sink_caps (parse, caps);
+
+  return res && gst_pad_set_caps (pad, caps);
+}
+
+static void
+gst_base_parse_set_index (GstElement * element, GstIndex * index)
+{
+  GstBaseParse *parse = GST_BASE_PARSE (element);
+
+  GST_OBJECT_LOCK (parse);
+  if (parse->priv->index)
+    gst_object_unref (parse->priv->index);
+  if (index) {
+    parse->priv->index = gst_object_ref (index);
+    gst_index_get_writer_id (index, GST_OBJECT (element),
+        &parse->priv->index_id);
+    parse->priv->own_index = FALSE;
+  } else
+    parse->priv->index = NULL;
+  GST_OBJECT_UNLOCK (parse);
+}
+
+static GstIndex *
+gst_base_parse_get_index (GstElement * element)
+{
+  GstBaseParse *parse = GST_BASE_PARSE (element);
+  GstIndex *result = NULL;
+
+  GST_OBJECT_LOCK (parse);
+  if (parse->priv->index)
+    result = gst_object_ref (parse->priv->index);
+  GST_OBJECT_UNLOCK (parse);
+
+  return result;
+}
+
+static GstStateChangeReturn
+gst_base_parse_change_state (GstElement * element, GstStateChange transition)
+{
+  GstBaseParse *parse;
+  GstStateChangeReturn result;
+
+  parse = GST_BASE_PARSE (element);
+
+  switch (transition) {
+    case GST_STATE_CHANGE_READY_TO_PAUSED:
+      /* If this is our own index destroy it as the
+       * old entries might be wrong for the new stream */
+      if (parse->priv->own_index) {
+        gst_object_unref (parse->priv->index);
+        parse->priv->index = NULL;
+        parse->priv->own_index = FALSE;
+      }
+
+      /* If no index was created, generate one */
+      if (G_UNLIKELY (!parse->priv->index)) {
+        GST_DEBUG_OBJECT (parse, "no index provided creating our own");
+
+        parse->priv->index = gst_index_factory_make ("memindex");
+        gst_index_get_writer_id (parse->priv->index, GST_OBJECT (parse),
+            &parse->priv->index_id);
+        parse->priv->own_index = TRUE;
+      }
+      break;
+    default:
+      break;
+  }
+
+  result = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
+
+  switch (transition) {
+    case GST_STATE_CHANGE_PAUSED_TO_READY:
+      gst_base_parse_reset (parse);
+      break;
+    default:
+      break;
+  }
+
+  return result;
+}
diff --git a/gst/h263parse/gstbaseparse.h b/gst/h263parse/gstbaseparse.h
new file mode 100644
index 0000000..605bf84
--- /dev/null
+++ b/gst/h263parse/gstbaseparse.h
@@ -0,0 +1,290 @@
+/* GStreamer
+ * Copyright (C) 2008 Nokia Corporation. All rights reserved.
+ *
+ * Contact: Stefan Kost <stefan.kost@nokia.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GST_BASE_PARSE_H__
+#define __GST_BASE_PARSE_H__
+
+#include <gst/gst.h>
+#include <gst/base/gstadapter.h>
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_BASE_PARSE		   (gst_base_parse_get_type())
+#define GST_BASE_PARSE(obj)		   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_BASE_PARSE,GstBaseParse))
+#define GST_BASE_PARSE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_BASE_PARSE,GstBaseParseClass))
+#define GST_BASE_PARSE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_BASE_PARSE,GstBaseParseClass))
+#define GST_IS_BASE_PARSE(obj)	   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_BASE_PARSE))
+#define GST_IS_BASE_PARSE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_BASE_PARSE))
+#define GST_BASE_PARSE_CAST(obj)	((GstBaseParse *)(obj))
+
+/**
+ * GST_BASE_PARSE_SINK_NAME:
+ *
+ * the name of the templates for the sink pad
+ */
+#define GST_BASE_PARSE_SINK_NAME	"sink"
+/**
+ * GST_BASE_PARSE_SRC_NAME:
+ *
+ * the name of the templates for the source pad
+ */
+#define GST_BASE_PARSE_SRC_NAME	"src"
+
+/**
+ * GST_BASE_PARSE_SRC_PAD:
+ * @obj: base parse instance
+ *
+ * Gives the pointer to the source #GstPad object of the element.
+ *
+ * Since: 0.10.x
+ */
+#define GST_BASE_PARSE_SRC_PAD(obj)		(GST_BASE_PARSE_CAST (obj)->srcpad)
+
+/**
+ * GST_BASE_PARSE_SINK_PAD:
+ * @obj: base parse instance
+ *
+ * Gives the pointer to the sink #GstPad object of the element.
+ *
+ * Since: 0.10.x
+ */
+#define GST_BASE_PARSE_SINK_PAD(obj)	(GST_BASE_PARSE_CAST (obj)->sinkpad)
+
+/**
+ * GST_BASE_PARSE_SEGMENT:
+ * @obj: base parse instance
+ *
+ * Gives the segment of the element.
+ *
+ * Since: 0.10.x
+ */
+#define GST_BASE_PARSE_SEGMENT(obj)     (GST_BASE_PARSE_CAST (obj)->segment)
+
+/**
+ * GST_BASE_PARSE_FLOW_DROPPED:
+ *
+ * A #GstFlowReturn that can be returned from parse_frame to
+ * indicate that no output buffer was generated, or from pre_push_buffer to
+ * to forego pushing buffer.
+ *
+ * Since: 0.10.x
+ */
+#define GST_BASE_PARSE_FLOW_DROPPED   GST_FLOW_CUSTOM_SUCCESS
+
+/**
+ * GST_BASE_PARSE_FLOW_CLIP:
+ *
+ * A #GstFlowReturn that can be returned from pre_push_buffer to
+ * indicate that regular segment clipping should be performed.
+ *
+ * Since: 0.10.x
+ */
+#define GST_BASE_PARSE_FLOW_CLIP      GST_FLOW_CUSTOM_SUCCESS_1
+
+/**
+ * GST_BASE_PARSE_BUFFER_FLAG_NO_FRAME:
+ *
+ * A #GstBufferFlag that can be set to have this buffer not counted as frame,
+ * e.g. if this frame is dependent on a previous one.  As it is not counted as
+ * a frame, bitrate increases but frame to time conversions are maintained.
+ *
+ * Since: 0.10.x
+ */
+#define GST_BASE_PARSE_BUFFER_FLAG_NO_FRAME     GST_BUFFER_FLAG_LAST
+
+
+/**
+ * GstBaseParseSeekable:
+ * @GST_BASE_PARSE_SEEK_NONE: No seeking possible.
+ * GST_BASE_PARSE_SEEK_DEFAULT: Default seeking possible using estimated bitrate.
+ * GST_BASE_PARSE_SEEK_TABLE: Additional metadata provides more accurate seeking.
+ *
+ * Indicates what level (of quality) of seeking is possible.
+ */
+typedef enum _GstBaseParseSeekable {
+  GST_BASE_PARSE_SEEK_NONE,
+  GST_BASE_PARSE_SEEK_DEFAULT,
+  GST_BASE_PARSE_SEEK_TABLE
+} GstBaseParseSeekable;
+
+typedef struct _GstBaseParse GstBaseParse;
+typedef struct _GstBaseParseClass GstBaseParseClass;
+typedef struct _GstBaseParsePrivate GstBaseParsePrivate;
+
+/**
+ * GstBaseParse:
+ * @element: the parent element.
+ *
+ * The opaque #GstBaseParse data structure.
+ */
+struct _GstBaseParse {
+  GstElement     element;
+  GstAdapter    *adapter;
+
+  /*< protected >*/
+  /* source and sink pads */
+  GstPad         *sinkpad;
+  GstPad         *srcpad;
+
+  /* MT-protected (with STREAM_LOCK) */
+  GstSegment      segment;
+
+  /* Newsegment event to be sent after SEEK */
+  GstEvent       *pending_segment;
+
+  /* Segment event that closes the running segment prior to SEEK */
+  GstEvent       *close_segment;
+
+  /*< private >*/
+  gpointer       _gst_reserved[GST_PADDING_LARGE];
+  GstBaseParsePrivate *priv;
+};
+
+/**
+ * GstBaseParseClass:
+ * @start:          Optional.
+ *                  Called when the element starts processing.
+ *                  Allows opening external resources.
+ * @stop:           Optional.
+ *                  Called when the element stops processing.
+ *                  Allows closing external resources.
+ * @set_sink_caps:  allows the subclass to be notified of the actual caps set.
+ * @check_valid_frame:  Check if the given piece of data contains a valid
+ *                      frame.
+ * @parse_frame:    Parse the already checked frame. Subclass need to
+ *                  set the buffer timestamp, duration, caps and possibly
+ *                  other necessary metadata. This is called with srcpad's
+ *                  STREAM_LOCK held.
+ * @convert:        Optional.
+ *                  Convert between formats.
+ * @find_frame:     Optional.
+ *                  Finds a frame. Gets a position passed and should return
+ *                  TRUE and the offset in bytes where this position is.
+ *                  Will only be called in pull mode and the subclass can pull
+ *                  whatever it wants from upstream. If not implemented,
+ *                  the base class will implement it by calling
+ *                  @check_valid_frame and @parse_frame to find the wanted
+ *                  frame and build a seek table.
+ * @event:          Optional.
+ *                  Event handler on the sink pad. This function should return
+ *                  TRUE if the event was handled and can be dropped.
+ * @src_event:      Optional.
+ *                  Event handler on the source pad. Should return TRUE
+ *                  if the event was handled and can be dropped.
+ *
+ * @get_frame_overhead: Finds the metadata overhead for the given frame. This
+ *                      is used to enable more accurate bitrate computations.
+ *                      If NULL, the per-frame overhead is assumed to be 0. If
+ *                      this returns -1, it is assumed that this frame should
+ *                      be skipped in bitrate calculation.
+ *
+ * @pre_push_buffer: Optional.
+ *                   Called just prior to pushing a frame (after any pending
+ *                   events have been sent) to give subclass a chance to perform
+ *                   additional actions at this time (e.g. tag sending) or to
+ *                   decide whether this buffer should be dropped or no
+ *                   (e.g. custom segment clipping).
+ *
+ * Subclasses can override any of the available virtual methods or not, as
+ * needed. At minimum @check_valid_frame and @parse_frame needs to be
+ * overridden.
+ */
+struct _GstBaseParseClass {
+  GstElementClass parent_class;
+
+  /*< public >*/
+  /* virtual methods for subclasses */
+
+  gboolean      (*start)              (GstBaseParse *parse);
+
+  gboolean      (*stop)               (GstBaseParse *parse);
+
+  gboolean      (*set_sink_caps)      (GstBaseParse *parse,
+                                       GstCaps *caps);
+
+  gboolean      (*check_valid_frame)  (GstBaseParse *parse,
+                                       GstBuffer *buffer,
+                                       guint *framesize,
+                                       gint *skipsize);
+
+  GstFlowReturn (*parse_frame)        (GstBaseParse *parse,
+                                       GstBuffer *buffer);
+
+  gboolean      (*convert)            (GstBaseParse * parse,
+                                       GstFormat src_format,
+                                       gint64 src_value,
+                                       GstFormat dest_format,
+                                       gint64 * dest_value);
+
+  gboolean      (*find_frame)         (GstBaseParse *parse,
+                                       GstFormat src_format,
+                                       gint64 src_value,
+                                       gint64 * dest_value);
+
+  gboolean      (*event)              (GstBaseParse *parse,
+                                       GstEvent *event);
+
+  gboolean      (*src_event)          (GstBaseParse *parse,
+                                       GstEvent *event);
+
+  gint          (*get_frame_overhead) (GstBaseParse *parse,
+                                       GstBuffer *buf);
+
+  GstFlowReturn (*pre_push_buffer)    (GstBaseParse *parse,
+                                       GstBuffer *buf);
+
+  /*< private >*/
+  gpointer       _gst_reserved[GST_PADDING_LARGE];  
+};
+
+GType           gst_base_parse_get_type         (void);
+
+
+GstFlowReturn gst_base_parse_push_buffer (GstBaseParse *parse,
+                                          GstBuffer *buffer);
+
+void gst_base_parse_set_duration (GstBaseParse *parse,
+                                  GstFormat fmt, gint64 duration, gint interval);
+
+void gst_base_parse_set_seek (GstBaseParse * parse,
+                              GstBaseParseSeekable seek, guint bitrate);
+
+void gst_base_parse_set_min_frame_size (GstBaseParse *parse,
+                                        guint min_size);
+void gst_base_parse_set_passthrough (GstBaseParse * parse, gboolean passthrough);
+
+void gst_base_parse_set_frame_props (GstBaseParse * parse, guint fps_num,
+                                     guint fps_den, guint lead_in, guint lead_out);
+
+gboolean gst_base_parse_get_sync (GstBaseParse * parse);
+
+gboolean gst_base_parse_get_drain (GstBaseParse * parse);
+
+gboolean gst_base_parse_convert_default (GstBaseParse * parse,
+                                         GstFormat src_format, gint64 src_value,
+                                         GstFormat dest_format, gint64 * dest_value);
+
+gboolean gst_base_parse_add_index_entry (GstBaseParse * parse, guint64 offset,
+                                         GstClockTime ts, gboolean key, gboolean force);
+
+G_END_DECLS
+
+#endif /* __GST_BASE_PARSE_H__ */
diff --git a/gst/h263parse/gsth263parse.c b/gst/h263parse/gsth263parse.c
new file mode 100644
index 0000000..f09ee65
--- /dev/null
+++ b/gst/h263parse/gsth263parse.c
@@ -0,0 +1,328 @@
+/* GStreamer H.263 Parser
+ * Copyright (C) <2010> Arun Raghavan <arun.raghavan@collabora.co.uk>
+ * Copyright (C) <2010> Edward Hervey <edward.hervey@collabora.co.uk>
+ * Copyright (C) <2010> Collabora Multimedia
+ * Copyright (C) <2010> Nokia Corporation
+ *
+ * Some bits C-c,C-v'ed and s/4/3 from h264parse:
+ *           (C) 2005 Michal Benes <michal.benes@itonis.tv>
+ *           (C) 2008 Wim Taymans <wim.taymans@gmail.com>
+ *           (C) 2009 Mark Nauwelaerts <mnauw users sf net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include <gst/base/gstbytereader.h>
+#include "gsth263parse.h"
+
+GST_DEBUG_CATEGORY (h263_parse_debug);
+
+static GstStaticPadTemplate srctemplate =
+GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC,
+    GST_PAD_ALWAYS,
+    GST_STATIC_CAPS ("video/x-h263, variant = (string) itu, "
+        "parsed = (boolean) true")
+    );
+
+static GstStaticPadTemplate sinktemplate =
+GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK,
+    GST_PAD_ALWAYS,
+    GST_STATIC_CAPS ("video/x-h263, variant = (string) itu, "
+        "parsed = (boolean) false")
+    );
+
+GST_BOILERPLATE (GstH263Parse, gst_h263_parse, GstElement, GST_TYPE_BASE_PARSE);
+
+static gboolean gst_h263_parse_start (GstBaseParse * parse);
+static gboolean gst_h263_parse_stop (GstBaseParse * parse);
+static gboolean gst_h263_parse_sink_event (GstBaseParse * parse,
+    GstEvent * event);
+static gboolean gst_h263_parse_check_valid_frame (GstBaseParse * parse,
+    GstBuffer * buffer, guint * framesize, gint * skipsize);
+static GstFlowReturn gst_h263_parse_parse_frame (GstBaseParse * parse,
+    GstBuffer * buffer);
+static GstCaps *gst_h263_parse_src_getcaps (GstPad * pad);
+
+static void
+gst_h263_parse_base_init (gpointer g_class)
+{
+  GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&srctemplate));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&sinktemplate));
+  gst_element_class_set_details_simple (gstelement_class, "H.263 parser",
+      "Codec/Parser/Video",
+      "Parses H.263 streams",
+      "Arun Raghavan <arun.raghavan@collabora.co.uk>,"
+      "Edward Hervey <edward.hervey@collabora.co.uk>");
+
+  GST_DEBUG_CATEGORY_INIT (h263_parse_debug, "h263parse", 0, "h263 parser");
+}
+
+static void
+gst_h263_parse_class_init (GstH263ParseClass * klass)
+{
+  GstBaseParseClass *parse_class = GST_BASE_PARSE_CLASS (klass);
+
+  /* Override BaseParse vfuncs */
+  parse_class->start = GST_DEBUG_FUNCPTR (gst_h263_parse_start);
+  parse_class->stop = GST_DEBUG_FUNCPTR (gst_h263_parse_stop);
+  parse_class->event = GST_DEBUG_FUNCPTR (gst_h263_parse_sink_event);
+  parse_class->check_valid_frame =
+      GST_DEBUG_FUNCPTR (gst_h263_parse_check_valid_frame);
+  parse_class->parse_frame = GST_DEBUG_FUNCPTR (gst_h263_parse_parse_frame);
+}
+
+static void
+gst_h263_parse_init (GstH263Parse * h263parse, GstH263ParseClass * g_class)
+{
+  gst_pad_set_getcaps_function (GST_BASE_PARSE_SRC_PAD (GST_BASE_PARSE
+          (h263parse)), GST_DEBUG_FUNCPTR (gst_h263_parse_src_getcaps));
+}
+
+static gboolean
+gst_h263_parse_start (GstBaseParse * parse)
+{
+  GstH263Parse *h263parse = GST_H263PARSE (parse);
+
+  GST_DEBUG ("Start");
+
+  h263parse->last_pos = 0;
+  h263parse->psc_pos = -1;
+
+  h263parse->bitrate = 0;
+  h263parse->profile = -1;
+  h263parse->level = -1;
+
+  h263parse->state = PARSING;
+
+  gst_base_parse_set_passthrough (parse, FALSE);
+
+  return TRUE;
+}
+
+static gboolean
+gst_h263_parse_stop (GstBaseParse * parse)
+{
+  GST_DEBUG ("Stop");
+
+  return TRUE;
+}
+
+static gboolean
+gst_h263_parse_sink_event (GstBaseParse * parse, GstEvent * event)
+{
+  GstH263Parse *h263parse;
+  gboolean res = FALSE;
+
+  h263parse = GST_H263PARSE (parse);
+
+  switch (GST_EVENT_TYPE (event)) {
+    case GST_EVENT_TAG:
+    {
+      GstTagList *taglist;
+
+      gst_event_parse_tag (event, &taglist);
+
+      if (gst_tag_list_get_uint (taglist, GST_TAG_BITRATE, &h263parse->bitrate))
+        GST_DEBUG ("Got bitrate tag: %u", h263parse->bitrate);
+
+      break;
+    }
+
+    default:
+      break;
+  }
+
+  return res;
+}
+
+static guint
+find_psc (GstBuffer * buffer, guint skip)
+{
+  GstByteReader br;
+  guint psc_pos = -1, psc;
+
+  gst_byte_reader_init_from_buffer (&br, buffer);
+
+  if (!gst_byte_reader_set_pos (&br, skip))
+    goto out;
+
+  gst_byte_reader_peek_uint24_be (&br, &psc);
+
+  /* Scan for the picture start code (22 bits - 0x0020) */
+  while ((gst_byte_reader_get_remaining (&br) >= 3)) {
+    if (gst_byte_reader_peek_uint24_be (&br, &psc) &&
+        ((psc & 0xffffc0) == 0x000080)) {
+      psc_pos = gst_byte_reader_get_pos (&br);
+      break;
+    } else
+      gst_byte_reader_skip (&br, 1);
+  }
+
+out:
+  return psc_pos;
+}
+
+static gboolean
+gst_h263_parse_check_valid_frame (GstBaseParse * parse, GstBuffer * buffer,
+    guint * framesize, gint * skipsize)
+{
+  GstH263Parse *h263parse;
+  guint psc_pos;
+
+  h263parse = GST_H263PARSE (parse);
+
+  psc_pos = find_psc (buffer, h263parse->last_pos);
+
+  if (psc_pos == -1) {
+    /* PSC not found, need more data */
+    if (GST_BUFFER_SIZE (buffer) > 3)
+      h263parse->last_pos = GST_BUFFER_SIZE (buffer) - 3;
+    goto more;
+  }
+
+  if (h263parse->psc_pos == -1) {
+    /* Found the start of the frame, now try to find the end */
+
+    h263parse->psc_pos = psc_pos;
+    h263parse->last_pos = psc_pos + 3;
+
+    psc_pos = find_psc (buffer, h263parse->last_pos);
+
+    if (psc_pos == -1) {
+      if (gst_base_parse_get_drain (GST_BASE_PARSE (h263parse)))
+        /* FLUSH/EOS, it's okay if we can't find the next frame */
+        psc_pos = GST_BUFFER_SIZE (buffer);
+      else
+        goto more;
+    }
+  }
+
+  /* We should now have a complete frame */
+
+  /* If this is the first frame, parse and set srcpad caps */
+  if (h263parse->state == PARSING) {
+    H263Params *params = NULL;
+    GstFlowReturn res = gst_h263_parse_get_params (h263parse, buffer,
+        &params, FALSE);
+
+    if (res != GST_FLOW_OK || h263parse->state != GOT_HEADER) {
+      GST_WARNING ("Couldn't parse header - setting passthrough mode");
+      gst_base_parse_set_passthrough (parse, TRUE);
+    } else {
+      /* Set srcpad caps since we now have sufficient information to do so */
+      gst_h263_parse_set_src_caps (h263parse, params);
+    }
+
+    if (params)
+      g_free (params);
+  }
+
+  *skipsize = h263parse->psc_pos;
+  *framesize = psc_pos - h263parse->psc_pos;
+
+  h263parse->psc_pos = -1;
+  h263parse->last_pos = 0;
+
+  /* XXX: After getting a keyframe, should we adjust min_frame_size to
+   * something smaller so we don't end up collecting too many non-keyframes? */
+
+  GST_DEBUG ("Found a frame of size %d at pos %d", *framesize, *skipsize);
+
+  return TRUE;
+
+more:
+  /* Ask for 1024 bytes more - this is an arbitrary choice */
+  gst_base_parse_set_min_frame_size (parse, GST_BUFFER_SIZE (buffer) + 1024);
+
+  /* Prevent baseparse from auto-skipping one byte */
+  *skipsize = 0;
+
+  return FALSE;
+}
+
+static GstFlowReturn
+gst_h263_parse_parse_frame (GstBaseParse * parse, GstBuffer * buffer)
+{
+  GstH263Parse *h263parse;
+  GstFlowReturn res;
+  H263Params *params = NULL;
+
+  h263parse = GST_H263PARSE (parse);
+
+  res = gst_h263_parse_get_params (h263parse, buffer, &params, TRUE);
+  if (res != GST_FLOW_OK)
+    goto out;
+
+  if (h263parse->state == PASSTHROUGH || h263parse->state == PARSING) {
+    /* There's a feature we don't support, or we didn't have enough data to
+     * parse the header, which should not be possible. Either way, go into
+     * passthrough mode and let downstream handle it if it can. */
+    GST_WARNING ("Couldn't parse header - setting passthrough mode");
+    gst_base_parse_set_passthrough (parse, TRUE);
+    goto out;
+  }
+
+  /* h263parse->state is now GOT_HEADER */
+
+  gst_buffer_set_caps (buffer,
+      GST_PAD_CAPS (GST_BASE_PARSE_SRC_PAD (GST_BASE_PARSE (h263parse))));
+
+  if (gst_h263_parse_is_delta_unit (params))
+    GST_BUFFER_FLAG_UNSET (buffer, GST_BUFFER_FLAG_DELTA_UNIT);
+  else
+    GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DELTA_UNIT);
+
+out:
+  g_free (params);
+  return res;
+}
+
+static GstCaps *
+gst_h263_parse_src_getcaps (GstPad * pad)
+{
+  GstH263Parse *h263parse;
+  GstCaps *caps;
+
+  h263parse = GST_H263PARSE (GST_PAD_PARENT (pad));
+
+  if (h263parse->state == PARSING)
+    /* Not got more specific caps from headers yet - return template caps */
+    return gst_caps_copy (gst_pad_get_pad_template_caps (pad));
+
+  g_object_get (pad, "caps", &caps, NULL);
+  return caps;
+}
+
+static gboolean
+plugin_init (GstPlugin * plugin)
+{
+  return gst_element_register (plugin, "h263parse",
+      GST_RANK_NONE, GST_TYPE_H263PARSE);
+}
+
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+    GST_VERSION_MINOR,
+    "h263parse",
+    "Element for parsing raw h263 streams",
+    plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
diff --git a/gst/h263parse/gsth263parse.h b/gst/h263parse/gsth263parse.h
new file mode 100644
index 0000000..11ca426
--- /dev/null
+++ b/gst/h263parse/gsth263parse.h
@@ -0,0 +1,94 @@
+/* GStreamer H.263 Parser
+ * Copyright (C) <2010> Arun Raghavan <arun.raghavan@collabora.co.uk>
+ * Copyright (C) <2010> Edward Hervey <edward.hervey@collabora.co.uk>
+ * Copyright (C) <2010> Collabora Multimedia
+ * Copyright (C) <2010> Nokia Corporation
+ *
+ * Some bits C-c,C-v'ed and s/4/3 from h264parse:
+ *           (C) 2005 Michal Benes <michal.benes@itonis.tv>
+ *           (C) 2008 Wim Taymans <wim.taymans@gmail.com>
+ *           (C) 2009 Mark Nauwelaerts <mnauw users sf net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GST_H263_PARSE_H__
+#define __GST_H263_PARSE_H__
+
+#include <gst/gst.h>
+#include <gst/base/gstadapter.h>
+#include "gstbaseparse.h"
+
+GST_DEBUG_CATEGORY_EXTERN (h263_parse_debug);
+#define GST_CAT_DEFAULT h263_parse_debug
+
+G_BEGIN_DECLS
+
+typedef enum
+{
+  PARSING = 0,
+  GOT_HEADER,
+  PASSTHROUGH
+} H263ParseState;
+
+typedef struct _H263Params H263Params;
+
+#define GST_TYPE_H263PARSE \
+  (gst_h263_parse_get_type())
+#define GST_H263PARSE(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_H263PARSE,GstH263Parse))
+#define GST_H263PARSE_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_H263PARSE,GstH263ParseClass))
+#define GST_IS_H263PARSE(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_H263PARSE))
+#define GST_IS_H263PARSE_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_H263PARSE))
+GType gst_h263_parse_get_type (void);
+
+typedef struct _GstH263Parse GstH263Parse;
+typedef struct _GstH263ParseClass GstH263ParseClass;
+
+struct _GstH263Parse
+{
+  GstBaseParse baseparse;
+
+  gint psc_pos;
+  guint last_pos;
+
+  gint profile, level;
+  guint bitrate;
+
+  H263ParseState state;
+};
+
+struct _GstH263ParseClass
+{
+  GstBaseParseClass parent_class;
+};
+
+gboolean gst_h263_parse_is_delta_unit (H263Params * params);
+GstFlowReturn gst_h263_parse_get_params (GstH263Parse * h263parse,
+    GstBuffer * buffer, H263Params ** params_p, gboolean fast);
+void gst_h263_parse_get_framerate (GstCaps * caps, H263Params * params,
+    gint * num, gint * denom);
+void gst_h263_parse_set_src_caps (GstH263Parse * h263parse,
+    H263Params * params);
+gint gst_h263_parse_get_profile (H263Params * params);
+gint gst_h263_parse_get_level (H263Params * params, gint profile,
+    guint bitrate, gint fps_num, gint fps_denom);
+
+G_END_DECLS
+#endif
diff --git a/gst/h263parse/h263parse.c b/gst/h263parse/h263parse.c
new file mode 100644
index 0000000..b46dcda
--- /dev/null
+++ b/gst/h263parse/h263parse.c
@@ -0,0 +1,823 @@
+/* GStreamer H.263 Parser
+ * Copyright (C) <2010> Arun Raghavan <arun.raghavan@collabora.co.uk>
+ * Copyright (C) <2010> Edward Hervey <edward.hervey@collabora.co.uk>
+ * Copyright (C) <2010> Collabora Multimedia
+ * Copyright (C) <2010> Nokia Corporation
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include <gst/base/gstbitreader.h>
+#include "gsth263parse.h"
+
+/* H263 Optional Features */
+typedef enum
+{
+  /* Optional Unrestricted Motion Vector (UMV) mode (see Annex D) */
+  H263_OPTION_UMV_MODE = 1 << 0,
+  /* Optional Syntax-based Arithmetic Coding (SAC) mode (see Annex E) */
+  H263_OPTION_SAC_MODE = 1 << 1,
+  /* Optional Advanced Prediction mode (AP) (see Annex F) */
+  H263_OPTION_AP_MODE = 1 << 2,
+  /* Optional PB-frames mode (see Annex G) */
+  H263_OPTION_PB_MODE = 1 << 3,
+  /* Optional Advanced INTRA Coding (AIC) mode (see Annex I) */
+  H263_OPTION_AIC_MODE = 1 << 4,
+  /* Optional Deblocking Filter (DF) mode (see Annex J) */
+  H263_OPTION_DF_MODE = 1 << 5,
+  /* Optional Slice Structured (SS) mode (see Annex K) */
+  H263_OPTION_SS_MODE = 1 << 6,
+  /* Optional Reference Picture Selection (RPS) mode (see Annex N) */
+  H263_OPTION_RPS_MODE = 1 << 7,
+  /* Optional Independent Segment Decoding (ISD) mode (see Annex R) */
+  H263_OPTION_ISD_MODE = 1 << 8,
+  /* Optional Alternative INTER VLC (AIV) mode (see Annex S) */
+  H263_OPTION_AIV_MODE = 1 << 9,
+  /* Optional Modified Quantization (MQ) mode (see Annex T) */
+  H263_OPTION_MQ_MODE = 1 << 10,
+  /* Optional Reference Picture Resampling (RPR) mode (see Annex P) */
+  H263_OPTION_RPR_MODE = 1 << 11,
+  /* Optional Reduced-Resolution Update (RRU) mode (see Annex Q) */
+  H263_OPTION_RRU_MODE = 1 << 12,
+  /* Optional Enhanced Reference Picture Selection (ERPS) mode (see Annex U) */
+  H263_OPTION_ERPS_MODE = 1 << 13,
+  /* Optional Data Partitioned Slices (DPS) mode (see Annex V) */
+  H263_OPTION_DPS_MODE = 1 << 14
+} H263OptionalFeatures;
+
+/* H263 Picture Types */
+typedef enum
+{
+  PICTURE_I = 0,                /* I-picture (INTRA) Baseline */
+  PICTURE_P,                    /* P-picture (INTER) Baseline */
+  PICTURE_IMPROVED_PB,          /* Improved PB-frame (Annex M) */
+  PICTURE_B,                    /* B-picture (Annex O) */
+  PICTURE_EI,                   /* EI-picture (Annex O) */
+  PICTURE_EP,                   /* EP-picture (Annex O) */
+  PICTURE_RESERVED1,
+  PICTURE_RESERVED2,
+  PICTURE_PB                    /* PB-frame (See Annex G) */
+} H263PictureType;
+
+/* H263 Picture Format */
+typedef enum
+{
+  PICTURE_FMT_FORBIDDEN_0 = 0,
+  PICTURE_FMT_SUB_QCIF,
+  PICTURE_FMT_QCIF,
+  PICTURE_FMT_CIF,
+  PICTURE_FMT_4CIF,
+  PICTURE_FMT_16CIF,
+  PICTURE_FMT_RESERVED1,
+  PICTURE_FMT_EXTENDEDPTYPE
+} H263PictureFormat;
+
+typedef enum
+{
+  UUI_ABSENT = 0,
+  UUI_IS_1,
+  UUI_IS_01,
+} H263UUI;
+
+struct _H263Params
+{
+  guint32 temporal_ref;
+
+  H263OptionalFeatures features;
+
+  gboolean splitscreen;
+  gboolean documentcamera;
+  gboolean fullpicturefreezerelease;
+  gboolean custompcfpresent;
+  H263UUI uui;
+  guint8 sss;
+
+  H263PictureFormat format;
+
+  H263PictureType type;
+
+  guint32 width;
+  guint32 height;
+  guint8 parnum, pardenom;
+  gint32 pcfnum, pcfdenom;
+};
+
+
+gboolean
+gst_h263_parse_is_delta_unit (H263Params * params)
+{
+  return (params->type == PICTURE_I);
+}
+
+/* Reads adapter and tries to populate params. 'fast' mode can be used to
+ * extract a subset of the data (for now, it quits once we have the picture
+ * type. */
+GstFlowReturn
+gst_h263_parse_get_params (GstH263Parse * h263parse, GstBuffer * buffer,
+    H263Params ** params_p, gboolean fast)
+{
+  static const guint8 partable[6][2] = {
+    {1, 0},
+    {1, 1},
+    {12, 11},
+    {10, 11},
+    {16, 11},
+    {40, 33}
+  };
+
+  static const guint16 sizetable[8][2] = {
+    {0, 0},
+    {128, 96},
+    {176, 144},
+    {352, 288},
+    {704, 576},
+    {1408, 1152}
+  };
+
+  static const gchar *source_format_name[] = {
+    "Forbidden",
+    "sub-QCIF",
+    "QCIF",
+    "CIF",
+    "4CIF",
+    "16CIF",
+    "Reserved",
+    "Extended PType"
+  };
+
+  H263Params *params;
+  GstBitReader br;
+  guint8 tr;
+  guint32 psc, temp32;
+  guint8 temp8, pquant;
+  gboolean hasplusptype;
+
+  *params_p = g_new0 (H263Params, 1);
+  params = *params_p;
+
+  /* FIXME: we can optimise a little by checking the value of available
+   * instead of calling using the bit reader's get_bits_* functions. */
+  gst_bit_reader_init_from_buffer (&br, buffer);
+
+  /* Default PCF is CIF PCF = 30000/1001 */
+  params->pcfnum = 30000;
+  params->pcfdenom = 1001;
+
+  GST_DEBUG ("NEW BUFFER");
+  if (!gst_bit_reader_get_bits_uint32 (&br, &psc, 22) ||
+      !gst_bit_reader_get_bits_uint8 (&br, &tr, 8) ||
+      !gst_bit_reader_get_bits_uint8 (&br, &temp8, 8))
+    goto more;
+
+  /* PSC   : Picture Start Code                 22 bits
+   * TR    : Temporal Reference                 8  bits
+   * PTYPE : Type Information                   variable
+   *  bit 1 : Always "1"
+   *  bit 2 : Always "0"
+   *  bit 3 : Split Screen Indicator
+   *  bit 4 : Document Camera Indicator
+   *  bit 6-8 : Source Format
+   *            if 111 : extended PTYPE is present */
+
+  /* 5.1.1 PSC : Picture Start Code (0x0020)    22 bits */
+  /* FIXME : Scan for the PSC instead of assuming it's always present
+   * and at the beginning. */
+  if (G_UNLIKELY (psc != 0x0020)) {
+    GST_WARNING ("Invalid PSC");
+    goto beach;
+  }
+
+  /* 5.1.2 TR : Temporal Reference              8 bits */
+  GST_DEBUG (" Temporal Reference : %d", tr);
+  params->temporal_ref = tr;
+
+  if ((temp8 >> 6) != 0x2) {
+    GST_WARNING ("Invalid PTYPE");
+    goto beach;
+  }
+
+  /* 5.1.3 PTYPE : Type Information             variable length */
+  params->splitscreen = (temp8 & 0x20) == 0x20;
+  params->documentcamera = (temp8 & 0x10) == 0x10;
+  params->fullpicturefreezerelease = (temp8 & 0x08) == 0x08;
+  params->format = temp8 & 0x07;
+
+  hasplusptype = (temp8 & 0x07) == 0x07;
+
+  GST_DEBUG (" Split Screen Indicator : %s",
+      params->splitscreen ? "on" : "off");
+  GST_DEBUG (" Document camera indicator : %s",
+      params->documentcamera ? "on" : "off");
+  GST_DEBUG (" Full Picture Freeze Release : %s",
+      params->fullpicturefreezerelease ? "on" : "off");
+  GST_DEBUG (" Source format 0x%x (%s)", params->format,
+      source_format_name[params->format]);
+
+  if (!hasplusptype) {
+    guint8 ptype2;
+
+    /* Fill in width/height based on format */
+    params->width = sizetable[params->format][0];
+    params->height = sizetable[params->format][1];
+
+    /* Default PAR is 12/11 */
+    params->parnum = 12;
+    params->pardenom = 11;
+
+    /* 5.1.3 : Remainder of PTYPE                5 bits */
+    if (!gst_bit_reader_get_bits_uint8 (&br, &ptype2, 5))
+      goto more;
+
+    params->type = (ptype2 & 0x10) == 0x10;
+    if ((ptype2 & 0x08) == 0x08)
+      params->features |= H263_OPTION_UMV_MODE;
+    if ((ptype2 & 0x04) == 0x04)
+      params->features |= H263_OPTION_SAC_MODE;
+    if ((ptype2 & 0x02) == 0x02)
+      params->features |= H263_OPTION_AP_MODE;
+    if ((ptype2 & 0x01) == 0x01) {
+      params->features |= H263_OPTION_PB_MODE;
+      params->type = PICTURE_PB;
+    }
+
+    GST_DEBUG (" Picture Coding Type : %s",
+        (ptype2 & 0x10) == 0x10 ? "INTER (P-picture)" : "INTRA (I-picture)");
+    GST_DEBUG (" Unrestricted Motion Vector mode (Annex D) : %s",
+        (ptype2 & 0x08) == 0x08 ? "on" : "off");
+    GST_DEBUG (" Syntax-basex Arithmetic Coding mode (Annex E) : %s",
+        (ptype2 & 0x04) == 0x04 ? "on" : "off");
+    GST_DEBUG (" Advanced Prediction mode (Annex F) : %s",
+        (ptype2 & 0x02) == 0x02 ? "on" : "off");
+    GST_DEBUG (" PB Frames mode (Annex G) : %s",
+        (ptype2 & 0x01) == 0x01 ? "on" : "off");
+
+    if (fast)
+      goto done;
+  }
+
+  if (hasplusptype) {
+    guint8 ufep;
+    guint8 cpm;
+    guint32 opptype, mpptype;
+
+    /* 5.1.4 PLUSPTYPE */
+
+    /* 5.1.4.1 UFEP : Update Full Extended PTYPE (3 bits) */
+    if (!gst_bit_reader_get_bits_uint8 (&br, &ufep, 3))
+      goto more;
+    GST_DEBUG (" UFEP 0x%x", ufep);
+
+    if (ufep == 1) {
+      /* 5.1.4.2 OPPTYPE : The Optional Part of PLUSPTYPE (OPPTYPE) (18 bits) */
+      if (!gst_bit_reader_get_bits_uint32 (&br, &opptype, 18))
+        goto more;
+
+      /* Last 4 bits are always "1000" */
+      if ((opptype & 0xf) != 0x8) {
+        GST_WARNING ("Corrupted OPTTYPE");
+        goto beach;
+      }
+      params->format = opptype >> 15;
+      params->custompcfpresent = (opptype & 0x4000) == 0x4000;
+      if (opptype & 0x2000)
+        params->features |= H263_OPTION_UMV_MODE;
+      if (opptype & 0x1000)
+        params->features |= H263_OPTION_SAC_MODE;
+      if (opptype & 0x0800)
+        params->features |= H263_OPTION_AP_MODE;
+      if (opptype & 0x0400)
+        params->features |= H263_OPTION_AIC_MODE;
+      if (opptype & 0x0200)
+        params->features |= H263_OPTION_DF_MODE;
+      if (opptype & 0x0100)
+        params->features |= H263_OPTION_SS_MODE;
+      if (opptype & 0x0080)
+        params->features |= H263_OPTION_RPS_MODE;
+      if (opptype & 0x0040)
+        params->features |= H263_OPTION_ISD_MODE;
+      if (opptype & 0x0020)
+        params->features |= H263_OPTION_AIV_MODE;
+      if (opptype & 0x0010)
+        params->features |= H263_OPTION_MQ_MODE;
+      /* Bit 15 is set to 1 to avoid looking like a start code */
+      if (opptype & 0x0004)
+        params->features |= H263_OPTION_ERPS_MODE;
+      if (opptype & 0x0002)
+        params->features |= H263_OPTION_DPS_MODE;
+    }
+
+    /* 5.1.4.3 MPPTYPE : The mandatory part of PLUSPTYPE (9 bits) */
+    if (!gst_bit_reader_get_bits_uint32 (&br, &mpptype, 9))
+      goto more;
+
+    /* Last 3 bits are always "001" */
+    if ((mpptype & 0x7) != 1) {
+      GST_WARNING ("Corrupted MPPTYPE");
+      goto beach;
+    }
+
+    params->type = mpptype >> 6;
+    GST_DEBUG (" Picture Coding Type : %d", params->type);
+
+    if (fast)
+      goto done;
+
+    if (mpptype & 0x2000)
+      params->features |= H263_OPTION_RPR_MODE;
+    if (mpptype & 0x1000)
+      params->features |= H263_OPTION_RRU_MODE;
+
+    /* 5.1.20 CPM : Continuous Presence Multipoint and Video Multiplex (1 bit) */
+    if (!gst_bit_reader_get_bits_uint8 (&br, &cpm, 1))
+      goto more;
+    GST_DEBUG (" Continuous Presence Multipoint and Video Multiplex : %d", cpm);
+
+    if (cpm) {
+      /* 5.1.21 PSBI : Picture Sub-Bitstream Indicator (2 bits) */
+      guint8 psbi;
+      if (!gst_bit_reader_get_bits_uint8 (&br, &psbi, 2))
+        goto more;
+      GST_DEBUG (" Picture Sub-Bitstream Indicator (PSBI):%d", psbi);
+    }
+
+    if (ufep == 1) {
+      guint32 cpfmt;
+
+      /* 5.1.5 CPFMT : Custom Picture Format (23 bits) */
+      if (!gst_bit_reader_get_bits_uint32 (&br, &cpfmt, 23))
+        goto more;
+      if (!(cpfmt & 0x200)) {
+        GST_WARNING ("Corrupted CPFMT (0x%x)", cpfmt);
+        goto beach;
+      }
+      temp8 = cpfmt >> 19;
+      params->width = (((cpfmt >> 10) & 0x1f) + 1) * 4;
+      params->height = (cpfmt & 0x1f) * 4;
+
+      if (temp8 == 0xf) {
+        guint32 epar;
+        /* 5.1.6 EPAR : Extended Pixel Aspect Ratio (16bits) */
+        if (!gst_bit_reader_get_bits_uint32 (&br, &epar, 16))
+          goto more;
+        params->parnum = epar >> 8;
+        params->pardenom = epar & 0xf;
+      } else {
+        params->parnum = partable[temp8][0];
+        params->pardenom = partable[temp8][1];
+      }
+
+      if (params->custompcfpresent) {
+        /* 5.1.7 CPCFC : Custom Picture Clock Frequency Code (8bits) */
+        /* (we store this as a frame rate) */
+        if (!gst_bit_reader_get_bits_uint8 (&br, &temp8, 8))
+          goto more;
+        GST_DEBUG ("  Custom PCF is present (%d)", (int) temp8);
+        params->pcfnum = gst_util_uint64_scale_int (1800000, 1, temp8 & 0x7f);
+        params->pcfdenom = (temp8 & 0x80) ? 1001 : 1000;
+        /* 5.1.8 ETR : Extended Temp8oral Reference (2bits) */
+        if (!gst_bit_reader_get_bits_uint8 (&br, &temp8, 2))
+          goto more;
+        params->temporal_ref |= temp8 << 8;
+      }
+
+      if (params->features & H263_OPTION_UMV_MODE) {
+        guint8 i;
+        /* 5.1.9 UUI : Unlimited Unrestricted Motion Vectors Indicator (variable length) */
+        if (!gst_bit_reader_get_bits_uint8 (&br, &i, 1))
+          goto more;
+        if (i == 0) {
+          if (!gst_bit_reader_get_bits_uint8 (&br, &i, 1))
+            goto more;
+          if (i != 1) {
+            GST_WARNING ("Corrupted UUI (0%u)", (guint) i);
+            goto beach;
+          }
+          params->uui = UUI_IS_01;
+        } else {
+          params->uui = UUI_IS_1;
+        }
+      }
+
+      if (params->features & H263_OPTION_SS_MODE) {
+        /* 5.1.10 SSS : Slice Structured Submode bits (2bits) */
+        if (!gst_bit_reader_get_bits_uint8 (&br, &params->sss, 2))
+          goto more;
+      }
+
+      /* WE DO NOT SUPPORT optional Temporal, SNR, and Spatial Scalability mode */
+      /* 5.1.11 ELNUM : Enhancement Layer Number (4bits) */
+      /* 5.1.12 RLNUM : Reference Layer Number (4bits) */
+
+      if (params->features & H263_OPTION_RPS_MODE) {
+        /* 5.1.13 RPSMF : Reference Picture Selection Mode Flags (3bits) */
+        /* FIXME : We just swallow the bits */
+        if (!gst_bit_reader_get_bits_uint8 (&br, &temp8, 3))
+          goto more;
+
+        /* 5.1.14 TRPI : Temporal Reference for Prediction Indication (1bit) */
+        if (!gst_bit_reader_get_bits_uint8 (&br, &temp8, 1))
+          goto more;
+
+        if (temp8) {
+          /* 5.1.15 TRP : Temporal Reference for Prediction (10bits) */
+          /* FIXME : We just swallow the bits */
+          if (!gst_bit_reader_get_bits_uint32 (&br, &temp32, 10))
+            goto more;
+        }
+
+        /* 5.1.16 BCI Back-Channel message Indication (variable length) */
+        if (!gst_bit_reader_get_bits_uint8 (&br, &temp8, 1))
+          goto more;
+        if (temp8 == 1) {
+          /* 5.1.17 BCM Back-Channel Message (variable length) */
+          GST_ERROR ("We won't support Back-Channel Message (BCM)");
+          goto beach;
+        } else {
+          if (!gst_bit_reader_get_bits_uint8 (&br, &temp8, 1))
+            goto more;
+          if (temp8 != 1) {
+            GST_WARNING ("Corrupted BCI");
+            goto beach;
+          }
+        }
+      }                         /* END H263_OPTION_RPS_MODE */
+    }
+
+    GST_DEBUG (" Advanced INTRA Coding mode (Annex I) : %s",
+        (params->features & H263_OPTION_AIC_MODE ? "on" : "off"));
+    GST_DEBUG (" Deblocking Filter mode (Annex J) : %s",
+        (params->features & H263_OPTION_DF_MODE ? "on" : "off"));
+    GST_DEBUG (" Slice Structured mode (Annex K) : %s",
+        (params->features & H263_OPTION_SS_MODE ? "on" : "off"));
+    GST_DEBUG (" Reference Picture Selection mode (Annex N) : %s",
+        (params->features & H263_OPTION_RPS_MODE ? "on" : "off"));
+    GST_DEBUG (" Independent Segment Decoding mode (Annex R) : %s",
+        (params->features & H263_OPTION_ISD_MODE ? "on" : "off"));
+    GST_DEBUG (" Alternative INTER VLC mode (Annex S) : %s",
+        (params->features & H263_OPTION_AIV_MODE ? "on" : "off"));
+    GST_DEBUG (" Modified Quantization mode (Annex T) : %s",
+        (params->features & H263_OPTION_MQ_MODE ? "on" : "off"));
+    GST_DEBUG (" Enhanced Reference Picture Selection mode (Annex U) : %s",
+        (params->features & H263_OPTION_ERPS_MODE ? "on" : "off"));
+    GST_DEBUG (" Enhanced Data Partitioned Slices mode (Annex V) : %s",
+        (params->features & H263_OPTION_DPS_MODE ? "on" : "off"));
+
+    /* END ufep == 1 */
+    /* WE DO NOT SUPPORT optional Reference Picture Resampling mode */
+    /* 5.1.18 RPRP : Reference Picture Resampling Parameters (variable length) */
+  }
+
+  /* END hasplusptype */
+  /* 5.1.19 PQUANT : Quantizer Information (5 bits) */
+  if (!gst_bit_reader_get_bits_uint8 (&br, &pquant, 5))
+    goto more;
+  GST_DEBUG (" PQUANT : 0x%x", pquant);
+
+  if (!hasplusptype) {
+    guint8 cpm;
+    /* 5.1.20 CPM : Continuous Presence Multipoint and Video Multiplex (1 bit) */
+    if (!gst_bit_reader_get_bits_uint8 (&br, &cpm, 1))
+      goto more;
+    GST_DEBUG (" Continuous Presence Multipoint and Video Multiplex : %d", cpm);
+
+    if (cpm) {
+      /* 5.1.21 PSBI : Picture Sub-Bitstream Indicator (2 bits) */
+      guint8 psbi;
+      if (!gst_bit_reader_get_bits_uint8 (&br, &psbi, 2))
+        goto more;
+      GST_DEBUG (" Picture Sub-Bitstream Indicator (PSBI):%d", psbi);
+    }
+  }
+
+  if (params->type & (PICTURE_PB | PICTURE_IMPROVED_PB)) {
+    /* 5.1.22 TRb : Temporal Reference for B-pictures in PB-frames (3/5bits) */
+    /* FIXME : We just swallow the bits */
+    if (!gst_bit_reader_get_bits_uint8 (&br, &temp8,
+            params->custompcfpresent ? 5 : 3))
+      goto more;
+
+    /* 5.1.23 DBQUANT : Quantization information for B-pictures in PB-frames (2bits) */
+    if (!gst_bit_reader_get_bits_uint8 (&br, &temp8, 2))
+      goto more;
+  }
+
+  GST_DEBUG (" Framerate defined by the stream is %d/%d",
+      params->pcfnum, params->pcfdenom);
+
+  /* We ignore the PEI and PSUPP - these may occur in any frame, and can be
+   * ignored by decoders that don't support them, except for bits of Annex W */
+
+  /* FIXME: Annex H (Forward Error Correction) requires that we poke into the
+   * stream data. */
+
+  /* FIXME: Annex P (Reference Picture Resampling) can be signaled implicitly
+   * as well as in the header. Should we set the field to false in caps if it
+   * is not specfied by the header? */
+
+  /* FIXME: Annex U (Enhanced Reference Picture Selection) poses a problem - we
+   * have no means of specifying what sub-modes, if any, are used. */
+
+done:
+  h263parse->state = GOT_HEADER;
+more:
+  return GST_FLOW_OK;
+
+beach:
+  h263parse->state = PASSTHROUGH;
+  return GST_FLOW_OK;
+}
+
+gint
+gst_h263_parse_get_profile (H263Params * params)
+{
+  gboolean c, d, d1, d21, d22, e, f, f2, g, h, i, j, k, k0, k1, k2, l, m, n, o,
+      p, q, r, s, t, u, v, w;
+
+  /* FIXME: some parts of Annex C can be discovered, others can not */
+  c = FALSE;
+  d = (params->features & H263_OPTION_UMV_MODE) != 0;
+  /* d1: Annex D.1; d21: Annex D.2 with UUI=1; d22: Annex D.2 with UUI=01 */
+  d1 = (d && params->uui == UUI_ABSENT);
+  d21 = (d && params->uui == UUI_IS_1);
+  d22 = (d && params->uui == UUI_IS_01);
+  e = (params->features & H263_OPTION_SAC_MODE) != 0;
+  /* f:Annex  F.2 or F.3 may be used; f2: only Annex F.2 is used (we have no
+   * way of detecting this right now */
+  f = (params->features & H263_OPTION_AP_MODE) != 0;
+  f2 = FALSE;
+  g = (params->features & H263_OPTION_PB_MODE) != 0;
+  h = FALSE;
+  i = (params->features & H263_OPTION_AIC_MODE) != 0;
+  j = (params->features & H263_OPTION_DF_MODE) != 0;
+  k = (params->features & H263_OPTION_SS_MODE) != 0;
+  /* k0: Annex K without submodes; k1: Annex K with ASO; k2: Annex K with RS */
+  k0 = (k && params->sss == 0x0);
+  k1 = (k && params->sss == 0x2);
+  k2 = (k && params->sss == 0x1);
+  l = FALSE;
+  m = (params->type == PICTURE_IMPROVED_PB);
+  n = (params->features & H263_OPTION_RPS_MODE) != 0;
+  o = FALSE;
+  p = FALSE;
+  q = (params->features & H263_OPTION_RRU_MODE) != 0;
+  r = (params->features & H263_OPTION_ISD_MODE) != 0;
+  s = (params->features & H263_OPTION_AIV_MODE) != 0;
+  t = (params->features & H263_OPTION_MQ_MODE) != 0;
+  u = (params->features & H263_OPTION_ERPS_MODE) != 0;
+  v = (params->features & H263_OPTION_DPS_MODE) != 0;
+  w = FALSE;
+
+  /* FIXME: The use of UUI in Annex D seems to be in contradiction with the
+   * profile definition in Annex X. Afaict, D.2 with UUI not present is not a
+   * meaningful state. */
+
+  /* FIXME: We have no way to distinguish between the use of section F.2 (four
+   * motion vectors per macroblock) and F.3 (overlapped block motion
+   * compensation), so we assume that they are either both present else neither
+   * is. This means if a profile supports only F.2 and not F.3, but we see that
+   * Advanced Prediction mode (Annex F) is used, we assume this profile does
+   * not apply. */
+
+  /* FIXME: We assume there is no error correction (Annex H) to avoid having to
+   * parse the stream to look for its existence. */
+
+  /* FIXME: Profiles 1 and 5-8 need the detection of Annex L.4 which can happen
+   * anywhere in the stream, so we just assume it doesn't exist and hope for
+   * the best. */
+
+  /* FIXME: Annex O support is TBD. */
+
+  /* FIXME: see note for Annex P elsewhere in this file. */
+
+  /* FIXME: Annex W.6.3.{8,11} suffer the same fate as Annex L.4 above. */
+
+  /* FIXME: We have no way of figuring out submodes when Annex U is used. Here
+   * we always assume no submode is used. */
+
+  if (!c && !d && !e && !f && !g && !h && !i && !j && !k && !l && !m && !n &&
+      !o && !p && !q && !r && !s && !t && !u && !v && !w)
+    return 0;
+  if (!c && (!d || d1) && !e && (!f || f2) && !g && !h && !k && !l && !m &&
+      !n && !o && !p && !q && !r && !s && !u && !v && !w)
+    return 1;
+  if (!c && (!d || d1) && !e && !g && !h && !i && !j && !k && !l && !m && !n &&
+      !o && !p && !q && !r && !s && !t && !u && !v && !w)
+    return 2;
+  if (!c && (!d || d1) && !e && (!f || f2) && !g && !h && (!k || k0) && !l &&
+      !m && !n && !o && !p && !q && !r && !s && !u && !v && !w)
+    return 3;
+  if (!c && (!d || d1) && !e && (!f || f2) && !g && !h && (!k || k0) && !l &&
+      !m && !n && !o && !p && !q && !r && !s && !u && !w)
+    return 4;
+  if (!c && (!d || d1 || d21) && !e && !g && !h && !k && !l && !m && !n &&
+      !o && !p && !q && !r && !s && !v && !w)
+    return 5;
+  if (!c && (!d || d1 || d21) && !e && !g && !h && (!k || k0 || k1) && !l &&
+      !m && !n && !o && !p && !q && !r && !s && !v && !w)
+    return 6;
+  if (!c && (!d || d1 || d21) && !e && !g && !h && !k && !l && !m && !n &&
+      !o && !p && !q && !r && !s && !v && !w)
+    return 7;
+  if (!c && (!d || d1 || d21) && !e && !g && !h && (!k || k0 || k1) && !l &&
+      !m && !n && !o && !p && !q && !r && !s && !v && !w)
+    /* FIXME: needs Annex O and Annex P support */
+    return 8;
+
+  return -1;
+}
+
+#define H263_PROFILE_NOT_0_2(profile) \
+  ((profile) != -1 && (profile) != 0 && (profile) != 2)
+
+#define H263_FMT_UPTO_QCIF(params) \
+  ((params)->format == PICTURE_FMT_SUB_QCIF || \
+   (params)->format == PICTURE_FMT_QCIF)
+#define H263_FMT_UPTO_CIF(params) \
+  ((params)->format == PICTURE_FMT_SUB_QCIF || \
+   (params)->format == PICTURE_FMT_QCIF || \
+   (params)->format == PICTURE_FMT_CIF)
+#define H263_FMT_CUSTOM_UPTO_QCIF(params) \
+   ((params)->format == PICTURE_FMT_RESERVED1 && \
+    (params)->height <= 144 && \
+    (params)->width <= 176)
+#define H263_FMT_CUSTOM_UPTO_CIF(params) \
+   ((params)->format == PICTURE_FMT_RESERVED1 && \
+    (params)->height <= 288 && \
+    (params)->width <= 352)
+
+#define GST_FRACTION_LE(f1, f2) \
+  ((gst_value_compare (&(f1), &(f2)) == GST_VALUE_LESS_THAN) || \
+   (gst_value_compare (&(f1), &(f2)) == GST_VALUE_EQUAL))
+
+gint
+gst_h263_parse_get_level (H263Params * params, gint profile,
+    guint bitrate, gint fps_num, gint fps_denom)
+{
+  GValue fps15 = { 0, };
+  GValue fps30 = { 0, };
+  GValue fps50 = { 0, };
+  GValue fps60 = { 0, };
+  GValue fps = { 0, };
+
+  if (bitrate == 0) {
+    GST_DEBUG ("Can't calculate level since bitrate is unknown");
+    return -1;
+  }
+
+  g_value_init (&fps15, GST_TYPE_FRACTION);
+  g_value_init (&fps30, GST_TYPE_FRACTION);
+  g_value_init (&fps50, GST_TYPE_FRACTION);
+  g_value_init (&fps60, GST_TYPE_FRACTION);
+  g_value_init (&fps, GST_TYPE_FRACTION);
+
+  gst_value_set_fraction (&fps15, 15000, 1001);
+  gst_value_set_fraction (&fps30, 30000, 1001);
+  gst_value_set_fraction (&fps50, 50, 1);
+  gst_value_set_fraction (&fps60, 60000, 1001);
+
+  gst_value_set_fraction (&fps, fps_num, fps_denom);
+
+  /* Level 10 */
+  if (H263_FMT_UPTO_QCIF (params) && GST_FRACTION_LE (fps, fps15) &&
+      bitrate <= 64000)
+    return 10;
+
+  /* Level 20 */
+  if (((H263_FMT_UPTO_QCIF (params) && GST_FRACTION_LE (fps, fps30)) ||
+          (params->format == PICTURE_FMT_CIF && GST_FRACTION_LE (fps, fps15)))
+      && bitrate <= 128000)
+    return 20;
+
+  /* Level 30 */
+  if (H263_FMT_UPTO_CIF (params) && GST_FRACTION_LE (fps, fps30) &&
+      bitrate <= 384000)
+    return 30;
+
+  /* Level 40 */
+  if (H263_FMT_UPTO_CIF (params) && GST_FRACTION_LE (fps, fps30) &&
+      bitrate <= 2048000)
+    return 40;
+
+  /* Level 45 */
+  if ((H263_FMT_UPTO_QCIF (params) || (H263_FMT_CUSTOM_UPTO_QCIF (params) &&
+              H263_PROFILE_NOT_0_2 (profile))) &&
+      GST_FRACTION_LE (fps, fps15) &&
+      /* (!h263parse->custompcfpresent || H263_PROFILE_NOT_0_2(profile)) && */
+      bitrate <= 128000)
+    return 45;
+
+  /* Level 50 */
+  if ((H263_FMT_UPTO_CIF (params) || H263_FMT_CUSTOM_UPTO_CIF (params)) &&
+      (GST_FRACTION_LE (fps, fps50) ||
+          (params->width <= 352 && params->height <= 240 &&
+              GST_FRACTION_LE (fps, fps60))) && (bitrate <= 4096000))
+    return 50;
+
+  /* Level 60 */
+  if (((params->width <= 720 && params->height <= 288 &&
+              GST_FRACTION_LE (fps, fps50)) ||
+          (params->width <= 720 && params->height <= 240 &&
+              GST_FRACTION_LE (fps, fps60))) && (bitrate <= 8192000))
+    return 60;
+
+  /* Level 70 */
+  if (((params->width <= 720 && params->height <= 576 &&
+              GST_FRACTION_LE (fps, fps50)) ||
+          (params->width <= 720 && params->height <= 480 &&
+              GST_FRACTION_LE (fps, fps60))) && (bitrate <= 16384000))
+    return 70;
+
+  GST_DEBUG ("Weird - didn't match any profile!");
+  return -1;
+}
+
+void
+gst_h263_parse_get_framerate (GstCaps * sink_caps, H263Params * params,
+    gint * num, gint * denom)
+{
+  GstStructure *st;
+
+  st = gst_caps_get_structure (sink_caps, 0);
+
+  if (gst_structure_get_fraction (st, "framerate", num, denom)) {
+    /* Got it in caps - nothing more to do */
+    GST_DEBUG ("Sink caps override framerate from headers");
+    return;
+  }
+
+  /* Caps didn't have the framerate - get it from params */
+  *num = params->pcfnum;
+  *denom = params->pcfdenom;
+}
+
+void
+gst_h263_parse_set_src_caps (GstH263Parse * h263parse, H263Params * params)
+{
+  GstCaps *caps;
+  gint fr_num, fr_denom;
+
+  g_assert (h263parse->state == PASSTHROUGH || h263parse->state == GOT_HEADER);
+
+  caps = GST_PAD_CAPS (GST_BASE_PARSE_SINK_PAD (GST_BASE_PARSE (h263parse)));
+  if (caps) {
+    caps = gst_caps_copy (caps);
+  } else {
+    caps = gst_caps_new_simple ("video/x-h263",
+        "variant", G_TYPE_STRING, "itu", NULL);
+  }
+  gst_caps_set_simple (caps, "parsed", G_TYPE_BOOLEAN, TRUE, NULL);
+
+  gst_h263_parse_get_framerate (caps, params, &fr_num, &fr_denom);
+  gst_caps_set_simple (caps, "framerate", GST_TYPE_FRACTION, fr_num, fr_denom,
+      NULL);
+
+  if (h263parse->state == GOT_HEADER) {
+    gst_caps_set_simple (caps,
+        "annex-d", G_TYPE_BOOLEAN, (params->features & H263_OPTION_UMV_MODE),
+        "annex-e", G_TYPE_BOOLEAN, (params->features & H263_OPTION_SAC_MODE),
+        "annex-f", G_TYPE_BOOLEAN, (params->features & H263_OPTION_AP_MODE),
+        "annex-g", G_TYPE_BOOLEAN, (params->features & H263_OPTION_PB_MODE),
+        "annex-i", G_TYPE_BOOLEAN, (params->features & H263_OPTION_AIC_MODE),
+        "annex-j", G_TYPE_BOOLEAN, (params->features & H263_OPTION_DF_MODE),
+        "annex-k", G_TYPE_BOOLEAN, (params->features & H263_OPTION_SS_MODE),
+        "annex-m", G_TYPE_BOOLEAN, (params->type == PICTURE_IMPROVED_PB),
+        "annex-n", G_TYPE_BOOLEAN, (params->features & H263_OPTION_RPS_MODE),
+        "annex-q", G_TYPE_BOOLEAN, (params->features & H263_OPTION_RRU_MODE),
+        "annex-r", G_TYPE_BOOLEAN, (params->features & H263_OPTION_ISD_MODE),
+        "annex-s", G_TYPE_BOOLEAN, (params->features & H263_OPTION_AIV_MODE),
+        "annex-t", G_TYPE_BOOLEAN, (params->features & H263_OPTION_MQ_MODE),
+        "annex-u", G_TYPE_BOOLEAN, (params->features & H263_OPTION_ERPS_MODE),
+        "annex-v", G_TYPE_BOOLEAN, (params->features & H263_OPTION_DPS_MODE),
+        NULL);
+
+    h263parse->profile = gst_h263_parse_get_profile (params);
+    if (h263parse->profile != -1)
+      gst_caps_set_simple (caps, "profile", G_TYPE_UINT, h263parse->profile,
+          NULL);
+
+    h263parse->level = gst_h263_parse_get_level (params, h263parse->profile,
+        h263parse->bitrate, fr_num, fr_denom);
+    if (h263parse->level != -1)
+      gst_caps_set_simple (caps, "level", G_TYPE_UINT, h263parse->level, NULL);
+  }
+
+  gst_pad_set_caps (GST_BASE_PARSE_SRC_PAD (GST_BASE_PARSE (h263parse)), caps);
+  gst_caps_unref (caps);
+}
