Add Mediatek patches to gst-plugins-base

- Mediatek patches for VPU encoder/decoder
- Lintian overrides
- Remove gir-related parts, they don't cross compile

Change-Id: I6d242021ccaa67b317af276b35fe43e2485c463e
diff --git a/debian/build-deps b/debian/build-deps
index ee75153..32b2e21 100644
--- a/debian/build-deps
+++ b/debian/build-deps
@@ -26,10 +26,5 @@
 libgtk-3-dev (>= 3.10)
 libglib2.0-doc
 gstreamer@GST_ABI@-doc
-libgirepository1.0-dev (>= 0.9.12-4~)
-gobject-introspection (>= 0.9.12-4~)
-gir1.2-glib-2.0
-gir1.2-freedesktop
-gir1.2-gstreamer-@GST_ABI@
 zlib1g-dev
 libopus-dev (>= 0.9.4)
diff --git a/debian/changelog b/debian/changelog
index 1adaacf..2547b61 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+gst-plugins-base1.0 (1.10.4-1+mtk) mendel-chef; urgency=medium
+
+  * Add patches for MTK support
+
+ -- Coral <coral-support@google.com>  Wed, 07 Aug 2019 10:40:10 -0700
+
 gst-plugins-base1.0 (1.10.4-1) unstable; urgency=medium
 
   * New upstream bugfix release
diff --git a/debian/control b/debian/control
index 93a51b1..1f731af 100644
--- a/debian/control
+++ b/debian/control
@@ -6,8 +6,8 @@
            Sebastien Bacher <seb128@debian.org>,
            Sebastian Dröge <slomo@debian.org>,
            Sjoerd Simons <sjoerd@debian.org>
-Build-Depends: libgstreamer1.0-dev (>= 1.10.0), libasound2-dev (>= 0.9.0) [linux-any] , libgudev-1.0-dev (>= 143) [linux-any], autotools-dev, automake (>= 1.14), autoconf (>= 2.69), libtool (>= 2.2.6), dh-autoreconf, autopoint (>= 0.17), cdbs (>= 0.4.93~), debhelper (>= 9), gnome-pkg-tools (>= 0.7), gtk-doc-tools (>= 1.12), pkg-config (>= 0.11.0), libxv-dev (>= 6.8.2.dfsg.1-3), libxt-dev (>= 6.8.2.dfsg.1-3), libvorbis-dev (>= 1.0.0-2), libcdparanoia-dev (>= 3.10.2) [!hurd-i386], liborc-0.4-dev (>= 1:0.4.24), libpango1.0-dev (>= 1.16.0), libtheora-dev (>= 1.1), libglib2.0-dev (>= 2.40), zlib1g-dev (>= 1:1.1.4), libvisual-0.4-dev (>= 0.4.0), dpkg-dev (>= 1.15.1), iso-codes, libgtk-3-dev (>= 3.10), libglib2.0-doc, gstreamer1.0-doc, libgirepository1.0-dev (>= 0.9.12-4~), gobject-introspection (>= 0.9.12-4~), gir1.2-glib-2.0, gir1.2-freedesktop, gir1.2-gstreamer-1.0, zlib1g-dev, libopus-dev (>= 0.9.4)
-Standards-Version: 3.9.3
+Build-Depends: libgstreamer1.0-dev (>= 1.10.0), libasound2-dev (>= 0.9.0) [linux-any] , libgudev-1.0-dev (>= 143) [linux-any], autotools-dev, automake (>= 1.14), autoconf (>= 2.69), libtool (>= 2.2.6), dh-autoreconf, autopoint (>= 0.17), cdbs (>= 0.4.93~), debhelper (>= 9), gnome-pkg-tools (>= 0.7), gtk-doc-tools (>= 1.12), pkg-config (>= 0.11.0), libxv-dev (>= 6.8.2.dfsg.1-3), libxt-dev (>= 6.8.2.dfsg.1-3), libvorbis-dev (>= 1.0.0-2), libcdparanoia-dev (>= 3.10.2) [!hurd-i386], liborc-0.4-dev (>= 1:0.4.24), libpango1.0-dev (>= 1.16.0), libtheora-dev (>= 1.1), libglib2.0-dev (>= 2.40), zlib1g-dev (>= 1:1.1.4), libvisual-0.4-dev (>= 0.4.0), dpkg-dev (>= 1.15.1), iso-codes, libgtk-3-dev (>= 3.10), libglib2.0-doc, gstreamer1.0-doc, zlib1g-dev, libopus-dev (>= 0.9.4)
+Standards-Version: 3.9.8
 Vcs-Git: git://anonscm.debian.org/pkg-gstreamer/gst-plugins-base1.0.git
 Vcs-Browser: http://anonscm.debian.org/gitweb/?p=pkg-gstreamer/gst-plugins-base1.0.git;a=summary
 Homepage: http://gstreamer.freedesktop.org/modules/gst-plugins-base.html
@@ -81,8 +81,7 @@
          pkg-config,
          libgstreamer1.0-dev (>= 1.10.0),
          libglib2.0-dev,
-         libxml2-dev,
-         gir1.2-gst-plugins-base-1.0 (= ${binary:Version})
+         libxml2-dev
 Description: GStreamer development files for libraries from the "base" set
  GStreamer is a streaming media framework, based on graphs of filters
  which operate on media data.  Applications using this library can do
@@ -199,23 +198,4 @@
  for standard Xlib support and for the Xv extension, as well as the
  plugin for Pango-based text rendering and overlay.
 
-Package: gir1.2-gst-plugins-base-1.0
-Section: introspection
-Architecture: any
-Depends: ${gir:Depends},
-         ${shlibs:Depends},
-         ${misc:Depends}
-Description: GObject introspection data for the GStreamer Plugins Base library
- This package contains introspection data for the GStreamer Plugins Base library.
- .
- GStreamer is a streaming media framework, based on graphs of filters
- which operate on media data.  Applications using this library can do
- anything from real-time sound processing to playing videos, and just
- about anything else media-related.  Its plugin-based architecture means
- that new data types or processing capabilities can be added simply by
- installing new plug-ins.
- .
- It can be used by packages using the GIRepository format to generate
- dynamic bindings.
-
 
diff --git a/debian/gstreamer1.0-alsa.lintian-overrides b/debian/gstreamer1.0-alsa.lintian-overrides
new file mode 100644
index 0000000..71c185a
--- /dev/null
+++ b/debian/gstreamer1.0-alsa.lintian-overrides
@@ -0,0 +1 @@
+gstreamer1.0-alsa: spelling-error-in-readme-debian *
diff --git a/debian/gstreamer1.0-plugins-base-apps.lintian-overrides b/debian/gstreamer1.0-plugins-base-apps.lintian-overrides
new file mode 100644
index 0000000..ec8632a
--- /dev/null
+++ b/debian/gstreamer1.0-plugins-base-apps.lintian-overrides
@@ -0,0 +1,2 @@
+gstreamer1.0-plugins-base-apps: manpage-has-errors-from-man *
+gstreamer1.0-plugins-base-apps: spelling-error-in-readme-debian *
diff --git a/debian/gstreamer1.0-plugins-base-dbg.lintian-overrides b/debian/gstreamer1.0-plugins-base-dbg.lintian-overrides
new file mode 100644
index 0000000..8698f17
--- /dev/null
+++ b/debian/gstreamer1.0-plugins-base-dbg.lintian-overrides
@@ -0,0 +1 @@
+gstreamer1.0-plugins-base-dbg: spelling-error-in-readme-debian *
diff --git a/debian/gstreamer1.0-plugins-base-doc.lintian-overrides b/debian/gstreamer1.0-plugins-base-doc.lintian-overrides
new file mode 100644
index 0000000..28a110e
--- /dev/null
+++ b/debian/gstreamer1.0-plugins-base-doc.lintian-overrides
@@ -0,0 +1 @@
+gstreamer1.0-plugins-base-doc: spelling-error-in-readme-debian *
diff --git a/debian/gstreamer1.0-plugins-base.lintian-overrides b/debian/gstreamer1.0-plugins-base.lintian-overrides
new file mode 100644
index 0000000..1d6e6fb
--- /dev/null
+++ b/debian/gstreamer1.0-plugins-base.lintian-overrides
@@ -0,0 +1 @@
+gstreamer1.0-plugins-base: spelling-error-in-readme-debian *
diff --git a/debian/gstreamer1.0-x.lintian-overrides b/debian/gstreamer1.0-x.lintian-overrides
new file mode 100644
index 0000000..ac0bbfc
--- /dev/null
+++ b/debian/gstreamer1.0-x.lintian-overrides
@@ -0,0 +1 @@
+gstreamer1.0-x: spelling-error-in-readme-debian *
diff --git a/debian/libgstreamer-plugins-base-dev.install b/debian/libgstreamer-plugins-base-dev.install
index 1a3578f..e3cd6bd 100644
--- a/debian/libgstreamer-plugins-base-dev.install
+++ b/debian/libgstreamer-plugins-base-dev.install
@@ -1,4 +1,3 @@
 debian/tmp/usr/include/gstreamer-@GST_ABI@/gst/*/*.h
 debian/tmp/usr/lib/*/*.so
 debian/tmp/usr/lib/*/pkgconfig/*.pc
-debian/tmp/usr/share/gir-*
diff --git a/debian/libgstreamer-plugins-base1.0-0.lintian-overrides b/debian/libgstreamer-plugins-base1.0-0.lintian-overrides
new file mode 100644
index 0000000..85d2021
--- /dev/null
+++ b/debian/libgstreamer-plugins-base1.0-0.lintian-overrides
@@ -0,0 +1,2 @@
+libgstreamer-plugins-base1.0-0: package-name-doesnt-match-sonames *
+libgstreamer-plugins-base1.0-0: spelling-error-in-readme-debian *
diff --git a/debian/libgstreamer-plugins-base1.0-dev.lintian-overrides b/debian/libgstreamer-plugins-base1.0-dev.lintian-overrides
new file mode 100644
index 0000000..20f5600
--- /dev/null
+++ b/debian/libgstreamer-plugins-base1.0-dev.lintian-overrides
@@ -0,0 +1 @@
+libgstreamer-plugins-base1.0-dev: spelling-error-in-readme-debian *
diff --git a/debian/patches/0001-mtk.patch b/debian/patches/0001-mtk.patch
new file mode 100644
index 0000000..77d64be
--- /dev/null
+++ b/debian/patches/0001-mtk.patch
@@ -0,0 +1,497 @@
+diff --git a/ext/ogg/gstoggdemux.c b/ext/ogg/gstoggdemux.c
+index 03ac00f4..7003f162 100644
+--- a/ext/ogg/gstoggdemux.c
++++ b/ext/ogg/gstoggdemux.c
+@@ -50,6 +50,9 @@
+ /* we hope we get a granpos within this many bytes off the end */
+ #define DURATION_CHUNK_OFFSET (128*1024)
+ 
++/*search max page count*/
++#define SEARCH_MAX_PAGE   75
++
+ /* An Ogg page can not be larger than 255 segments of 255 bytes, plus
+    26 bytes of header */
+ #define MAX_OGG_PAGE_SIZE (255 * 255 + 26)
+@@ -191,7 +194,9 @@ gst_ogg_pad_init (GstOggPad * pad)
+ 
+   pad->map.granulerate_n = 0;
+   pad->map.granulerate_d = 0;
+-  pad->map.granuleshift = -1;
++  pad->map.granuleshift = 0;
++  pad->map.channel = 0;
++  pad->map.bitspersample = 0;
+ }
+ 
+ static void
+@@ -811,7 +816,8 @@ gst_ogg_demux_chain_peer (GstOggPad * pad, ogg_packet * packet,
+   if (!packet->b_o_s || push_headers) {
+     if (pad->last_ret == GST_FLOW_OK) {
+       GST_LOG_OBJECT (ogg, "Pushing buf %" GST_PTR_FORMAT, buf);
+-      ret = gst_pad_push (GST_PAD_CAST (pad), buf);
++      if (gst_buffer_get_size (buf) > 0)
++        ret = gst_pad_push (GST_PAD_CAST (pad), buf);
+     } else {
+       GST_DEBUG_OBJECT (ogg, "not pushing buffer on error pad");
+       ret = pad->last_ret;
+@@ -2687,6 +2693,7 @@ gst_ogg_demux_get_prev_page (GstOggDemux * ogg, ogg_page * og, gint64 * offset)
+   gint64 begin = ogg->offset;
+   gint64 end = begin;
+   gint64 cur_offset = -1;
++  gint hit_limit_cnt = 0;
+ 
+   GST_LOG_OBJECT (ogg, "getting page before %" G_GINT64_FORMAT, begin);
+ 
+@@ -2717,7 +2724,12 @@ gst_ogg_demux_get_prev_page (GstOggDemux * ogg, ogg_page * og, gint64 * offset)
+       ret = gst_ogg_demux_get_next_page (ogg, og, boundary, &new_offset);
+       /* we hit the upper limit, offset contains the last page start */
+       if (ret == GST_FLOW_LIMIT) {
+-        GST_LOG_OBJECT (ogg, "hit limit");
++        hit_limit_cnt++;
++        GST_INFO_OBJECT (ogg, "hit limit, cnt=%d", hit_limit_cnt);
++        if (hit_limit_cnt >= 3){
++          ret = GST_FLOW_OK;
++          goto beach;
++        }
+         break;
+       }
+       /* something went wrong */
+@@ -2904,8 +2916,12 @@ gst_ogg_demux_activate_chain (GstOggDemux * ogg, GstOggChain * chain,
+     gst_ogg_pad_mark_discont (pad);
+     pad->last_ret = GST_FLOW_OK;
+ 
++    GST_DEBUG_OBJECT (ogg,
++          "serialno %08x time %" GST_TIME_FORMAT,
++          pad->map.serialno, GST_TIME_ARGS (pad->start_time));
++
+     if (pad->map.is_skeleton || pad->map.is_cmml || pad->added
+-        || !pad->map.caps)
++        || !pad->map.caps || (pad->start_time == GST_CLOCK_TIME_NONE))
+       continue;
+ 
+     GST_DEBUG_OBJECT (ogg, "adding pad %" GST_PTR_FORMAT, pad);
+@@ -4008,6 +4024,7 @@ gst_ogg_demux_read_chain (GstOggDemux * ogg, GstOggChain ** res_chain)
+   gint64 offset = ogg->offset;
+   ogg_page og;
+   gboolean done;
++  gint loop_page_cnt = 0;
+   gint i;
+ 
+   GST_LOG_OBJECT (ogg, "reading chain at %" G_GINT64_FORMAT, offset);
+@@ -4131,8 +4148,14 @@ gst_ogg_demux_read_chain (GstOggDemux * ogg, GstOggChain ** res_chain)
+       break;
+     }
+ 
++    if ((loop_page_cnt >= SEARCH_MAX_PAGE) && (done == FALSE)) {
++      done = TRUE;
++      GST_ERROR_OBJECT (ogg, "(loop_page_cnt >= SEARCH_MAX_PAGE) && (done == FALSE)");
++      break;
++    }
+     if (!done) {
+       ret = gst_ogg_demux_get_next_page (ogg, &og, -1, NULL);
++      loop_page_cnt++;
+       if (ret != GST_FLOW_OK)
+         break;
+     }
+@@ -4159,6 +4182,7 @@ gst_ogg_demux_read_end_chain (GstOggDemux * ogg, GstOggChain * chain)
+   gboolean done = FALSE;
+   ogg_page og;
+   gint i;
++  gint hit_limit_count = 0;
+ 
+   while (!done) {
+     begin -= ogg->chunk_size;
+@@ -4173,8 +4197,14 @@ gst_ogg_demux_read_end_chain (GstOggDemux * ogg, GstOggChain * chain)
+     while (ogg->offset < end) {
+       ret = gst_ogg_demux_get_next_page (ogg, &og, end - ogg->offset, NULL);
+ 
+-      if (ret == GST_FLOW_LIMIT)
++      if (ret == GST_FLOW_LIMIT) {
++        hit_limit_count++;
++        GST_INFO_OBJECT (ogg, "hit_limit_count=%d", hit_limit_count);
++        if (hit_limit_count >= 3) {
++          done = TRUE;
++        }
+         break;
++      }
+       if (ret != GST_FLOW_OK)
+         return ret;
+ 
+@@ -4318,6 +4348,12 @@ gst_ogg_demux_find_chains (GstOggDemux * ogg)
+   GstOggChain *chain;
+   GstFlowReturn ret;
+ 
++  /*init og header and body*/
++  og.header_len = 0;
++  og.body_len = 0;
++  og.header = NULL;
++  og.body = NULL;
++
+   /* get peer to figure out length */
+   if ((peer = gst_pad_get_peer (ogg->sinkpad)) == NULL)
+     goto no_peer;
+@@ -4349,7 +4385,20 @@ gst_ogg_demux_find_chains (GstOggDemux * ogg)
+   if (ret != GST_FLOW_OK)
+     goto no_last_page;
+ 
+-  serialno = ogg_page_serialno (&og);
++  GST_DEBUG_OBJECT (ogg, "ogg_page_serialno,og.header_len=%d,og.body_len=%d",og.header_len,og.body_len);
++  if ((og.header_len > 27) && (og.header_len <= (27 + 255))) {
++    serialno = ogg_page_serialno (&og);
++  }
++  else {
++    gint i;
++    for (i = 0; i < chain->streams->len; i++) {
++      GstOggPad *pad = g_array_index (chain->streams, GstOggPad *, i);
++      if (pad != NULL) {
++        serialno = pad->map.serialno;
++        break;
++      }
++    }
++  } 
+ 
+   if (!gst_ogg_chain_has_stream (chain, serialno)) {
+     /* the last page is not in the first stream, this means we should
+diff --git a/ext/ogg/gstoggstream.c b/ext/ogg/gstoggstream.c
+index 8426e46f..2f81bd5b 100644
+--- a/ext/ogg/gstoggstream.c
++++ b/ext/ogg/gstoggstream.c
+@@ -28,6 +28,7 @@
+ 
+ #include <gst/riff/riff-media.h>
+ #include <gst/pbutils/pbutils.h>
++#include <gst/audio/audio.h>
+ 
+ #include <stdlib.h>
+ #include <string.h>
+@@ -1599,8 +1600,13 @@ setup_ogmaudio_mapper (GstOggStream * pad, ogg_packet * packet)
+   GST_DEBUG ("fourcc: %s", fstr);
+ 
+   /* FIXME: Need to do something with the reorder map */
++  gchar *pchar=NULL;
++  guint16 n_fourcc=strtol((const char *)fstr,&pchar,16);
++
++  pad->channel = GST_READ_UINT16_LE (data + 45);
++  pad->bitspersample = GST_READ_UINT32_LE (data + 41);
+   pad->caps =
+-      gst_riff_create_audio_caps (fourcc, NULL, NULL, NULL, NULL, NULL, NULL);
++      gst_riff_create_audio_caps (n_fourcc, NULL, NULL, NULL, NULL, NULL, NULL);
+ 
+   GST_LOG ("sample rate: %d", pad->granulerate_n);
+   if (pad->granulerate_n == 0)
+@@ -1609,6 +1615,15 @@ setup_ogmaudio_mapper (GstOggStream * pad, ogg_packet * packet)
+   if (pad->caps) {
+     gst_caps_set_simple (pad->caps,
+         "rate", G_TYPE_INT, pad->granulerate_n, NULL);
++    gst_caps_set_simple (pad->caps,
++        "channels", G_TYPE_INT, pad->channel, NULL);
++    if (GST_RIFF_WAVE_FORMAT_PCM == n_fourcc) {
++      GstAudioFormat format;
++      gint wd = GST_ROUND_UP_8 (pad->bitspersample);
++      format = gst_audio_format_build_integer (wd != 8, G_LITTLE_ENDIAN, wd, wd);
++      gst_caps_set_simple (pad->caps,
++        "format", G_TYPE_STRING, gst_audio_format_to_string (format), NULL);
++    }
+   } else {
+     pad->caps = gst_caps_new_simple ("audio/x-ogm-unknown",
+         "fourcc", G_TYPE_STRING, fstr,
+diff --git a/ext/ogg/gstoggstream.h b/ext/ogg/gstoggstream.h
+index d49527ff..2822a934 100644
+--- a/ext/ogg/gstoggstream.h
++++ b/ext/ogg/gstoggstream.h
+@@ -111,6 +111,8 @@ struct _GstOggStream
+   GstOggIndex *index;
+   guint64 kp_denom;
+   guint64 idx_bitrate;
++  guint16 channel;
++  guint32 bitspersample;
+ };
+ 
+ 
+diff --git a/gst-libs/gst/audio/gstaudiobasesink.c b/gst-libs/gst/audio/gstaudiobasesink.c
+index 62fab35e..57c97d3f 100644
+--- a/gst-libs/gst/audio/gstaudiobasesink.c
++++ b/gst-libs/gst/audio/gstaudiobasesink.c
+@@ -1777,8 +1777,8 @@ gst_audio_base_sink_get_alignment (GstAudioBaseSink * sink,
+         /* discont candidate */
+         sink->priv->discont_time = time;
+       } else if (time - sink->priv->discont_time >= sink->priv->discont_wait) {
+-        /* discont_wait expired, discontinuity detected */
+-        discont = TRUE;
++        /* discont_wait expired, discontinuity detected, not set discont avoid drop samples*/
++      /* discont = TRUE; */
+         sink->priv->discont_time = -1;
+       }
+     } else {
+diff --git a/gst-libs/gst/audio/gstaudiodecoder.c b/gst-libs/gst/audio/gstaudiodecoder.c
+index e583e2f3..a5a4abdf 100644
+--- a/gst-libs/gst/audio/gstaudiodecoder.c
++++ b/gst-libs/gst/audio/gstaudiodecoder.c
+@@ -486,6 +486,10 @@ gst_audio_decoder_init (GstAudioDecoder * dec, GstAudioDecoderClass * klass)
+   /* init state */
+   dec->priv->ctx.min_latency = 0;
+   dec->priv->ctx.max_latency = 0;
++
++  dec->ts_none = FALSE;
++  dec->sub_ts_none = FALSE;
++
+   gst_audio_decoder_reset (dec, TRUE);
+   GST_DEBUG_OBJECT (dec, "init ok");
+ }
+@@ -1298,6 +1302,10 @@ gst_audio_decoder_finish_frame (GstAudioDecoder * dec, GstBuffer * buf,
+   else
+     ts = GST_CLOCK_TIME_NONE;
+ 
++  if (dec->ts_none && !dec->sub_ts_none) {
++    ts = GST_CLOCK_TIME_NONE;
++  }
++
+   GST_DEBUG_OBJECT (dec, "leading frame ts %" GST_TIME_FORMAT,
+       GST_TIME_ARGS (ts));
+ 
+@@ -1540,6 +1548,12 @@ gst_audio_decoder_push_buffers (GstAudioDecoder * dec, gboolean force)
+       }
+       /* track upstream ts, but do not get stuck if nothing new upstream */
+       ts = gst_adapter_prev_pts (priv->adapter, &distance);
++
++      if (ts <= priv->prev_ts) {
++        dec->ts_none = TRUE;
++        dec->sub_ts_none = TRUE;
++      }
++
+       if (ts != priv->prev_ts || distance <= priv->prev_distance) {
+         priv->prev_ts = ts;
+         priv->prev_distance = distance;
+diff --git a/gst-libs/gst/audio/gstaudiodecoder.h b/gst-libs/gst/audio/gstaudiodecoder.h
+index 71e0ce79..b93cb345 100644
+--- a/gst-libs/gst/audio/gstaudiodecoder.h
++++ b/gst-libs/gst/audio/gstaudiodecoder.h
+@@ -170,6 +170,10 @@ struct _GstAudioDecoder
+   GstSegment      input_segment;
+   GstSegment      output_segment;
+ 
++  /*set ts to GST_CLOCK_TIME_NONE flag*/
++  gboolean ts_none;
++  gboolean sub_ts_none;
++
+   /*< private >*/
+   GstAudioDecoderPrivate *priv;
+ 
+diff --git a/gst-libs/gst/riff/riff-media.c b/gst-libs/gst/riff/riff-media.c
+index a6c2bad2..18dad74b 100644
+--- a/gst-libs/gst/riff/riff-media.c
++++ b/gst-libs/gst/riff/riff-media.c
+@@ -261,6 +261,7 @@ gst_riff_create_video_caps (guint32 codec_fcc,
+     case GST_MAKE_FOURCC ('m', 'p', 'g', '2'):
+     case GST_MAKE_FOURCC ('P', 'I', 'M', '2'):
+     case GST_MAKE_FOURCC ('D', 'V', 'R', ' '):
++    case GST_MAKE_FOURCC ('E', 'M', '2', 'V'):
+     case GST_MAKE_FOURCC (0x02, 0x00, 0x00, 0x10):
+       caps = gst_caps_new_simple ("video/mpeg",
+           "systemstream", G_TYPE_BOOLEAN, FALSE,
+diff --git a/gst-libs/gst/video/gstvideoutilsprivate.c b/gst-libs/gst/video/gstvideoutilsprivate.c
+index e5e7c2dd..cbddaf14 100644
+--- a/gst-libs/gst/video/gstvideoutilsprivate.c
++++ b/gst-libs/gst/video/gstvideoutilsprivate.c
+@@ -131,10 +131,23 @@ __gst_video_element_proxy_getcaps (GstElement * element, GstPad * sinkpad,
+   gst_caps_unref (templ_caps);
+ 
+   if (filter) {
++    GstStructure *filter_st = NULL;
++
+     GST_LOG_OBJECT (element, "intersecting with %" GST_PTR_FORMAT, filter);
+     filter_caps = gst_caps_intersect (fcaps, filter);
+     gst_caps_unref (fcaps);
+     fcaps = filter_caps;
++
++	filter_st = gst_caps_get_structure (filter, 0);
++	if (!gst_structure_has_field (filter_st, "framerate")) {
++	  GstStructure *fcaps_st = NULL;
++
++	  fcaps_st =  gst_caps_get_structure (fcaps, 0);
++	  gst_structure_remove_field (fcaps_st, "framerate");
++	  fcaps_st = NULL;
++	}
++
++	filter_st = NULL;
+   }
+ 
+ done:
+diff --git a/gst-libs/gst/video/video-format.c b/gst-libs/gst/video/video-format.c
+index 97fbc8a9..f5ef9382 100644
+--- a/gst-libs/gst/video/video-format.c
++++ b/gst-libs/gst/video/video-format.c
+@@ -3864,6 +3864,10 @@ static const VideoFormat formats[] = {
+       PSTR244, PLANE011, OFFS001, SUB420, PACK_P010_10LE),
+   MAKE_YUV_FORMAT (IYU2, "raw video", GST_MAKE_FOURCC ('I', 'Y', 'U', '2'),
+       DPTH888, PSTR333, PLANE0, OFFS102, SUB444, PACK_IYU2),
++  MAKE_YUV_FORMAT (MT21, "raw video", GST_MAKE_FOURCC ('M', 'M', '2', '1'),
++    DPTH888, PSTR122, PLANE011, OFFS001, SUB420, PACK_NV12),
++  MAKE_YUV_FORMAT (I422, "raw video", GST_MAKE_FOURCC ('Y', 'M', '1', '6'),
++    DPTH888, PSTR111, PLANE012, OFFS0, SUB422, PACK_420),
+ };
+ 
+ static GstVideoFormat
+@@ -4094,6 +4098,10 @@ gst_video_format_from_fourcc (guint32 fourcc)
+       return GST_VIDEO_FORMAT_IYU1;
+     case GST_MAKE_FOURCC ('A', 'Y', '6', '4'):
+       return GST_VIDEO_FORMAT_AYUV64;
++    case GST_MAKE_FOURCC ('M', 'M', '2', '1'):
++      return GST_VIDEO_FORMAT_MT21;
++    case GST_MAKE_FOURCC ('Y', 'M', '1', '6'):
++      return GST_VIDEO_FORMAT_I422;
+     default:
+       return GST_VIDEO_FORMAT_UNKNOWN;
+   }
+@@ -4115,6 +4123,9 @@ gst_video_format_from_string (const gchar * format)
+ 
+   g_return_val_if_fail (format != NULL, GST_VIDEO_FORMAT_UNKNOWN);
+ 
++  if (strcmp ("MT21", format) == 0)
++    return GST_VIDEO_FORMAT_MT21;
++
+   for (i = 0; i < G_N_ELEMENTS (formats); i++) {
+     if (strcmp (GST_VIDEO_FORMAT_INFO_NAME (&formats[i].info), format) == 0)
+       return GST_VIDEO_FORMAT_INFO_FORMAT (&formats[i].info);
+diff --git a/gst-libs/gst/video/video-format.h b/gst-libs/gst/video/video-format.h
+index e7f83d83..f3e69fac 100644
+--- a/gst-libs/gst/video/video-format.h
++++ b/gst-libs/gst/video/video-format.h
+@@ -164,6 +164,8 @@ typedef enum {
+   GST_VIDEO_FORMAT_P010_10BE,
+   GST_VIDEO_FORMAT_P010_10LE,
+   GST_VIDEO_FORMAT_IYU2,
++  GST_VIDEO_FORMAT_MT21,
++  GST_VIDEO_FORMAT_I422,
+ } GstVideoFormat;
+ 
+ #define GST_VIDEO_MAX_PLANES 4
+diff --git a/gst-libs/gst/video/video-info.c b/gst-libs/gst/video/video-info.c
+index 57b9db7e..af101abe 100644
+--- a/gst-libs/gst/video/video-info.c
++++ b/gst-libs/gst/video/video-info.c
+@@ -700,13 +700,26 @@ fill_planes (GstVideoInfo * info)
+       info->stride[1] = GST_ROUND_UP_4 (GST_ROUND_UP_2 (width) / 2);
+       info->stride[2] = info->stride[1];
+       info->offset[0] = 0;
+-      info->offset[1] = info->stride[0] * GST_ROUND_UP_2 (height);
++      info->offset[1] = GST_ROUND_UP_128 (info->stride[0] * GST_ROUND_UP_2 (height));
+       cr_h = GST_ROUND_UP_2 (height) / 2;
+       if (GST_VIDEO_INFO_IS_INTERLACED (info))
+         cr_h = GST_ROUND_UP_2 (cr_h);
+-      info->offset[2] = info->offset[1] + info->stride[1] * cr_h;
+-      info->size = info->offset[2] + info->stride[2] * cr_h;
++      info->offset[2] = info->offset[1] + GST_ROUND_UP_128 (info->stride[1] * cr_h);
++      info->size = info->offset[2] + GST_ROUND_UP_128 (info->stride[2] * cr_h);
++      break;
++
++    case GST_VIDEO_FORMAT_I422:
++      info->stride[0] = GST_ROUND_UP_4 (width);
++      info->stride[1] = GST_ROUND_UP_4 (GST_ROUND_UP_2 (width) / 2);
++      info->stride[2] = info->stride[1];
++
++      info->offset[0] = 0;
++      info->offset[1] = GST_ROUND_UP_128 (info->stride[0] * GST_ROUND_UP_2 (height));
++      info->offset[2] = info->offset[1] + GST_ROUND_UP_128 (info->stride[1] * GST_ROUND_UP_2 (height));
++
++      info->size = info->stride[0] * GST_ROUND_UP_2 (height) * 2;
+       break;
++
+     case GST_VIDEO_FORMAT_Y41B:
+       info->stride[0] = GST_ROUND_UP_4 (width);
+       info->stride[1] = GST_ROUND_UP_16 (width) / 4;
+@@ -739,6 +752,7 @@ fill_planes (GstVideoInfo * info)
+       break;
+     case GST_VIDEO_FORMAT_NV12:
+     case GST_VIDEO_FORMAT_NV21:
++    case GST_VIDEO_FORMAT_MT21:
+       info->stride[0] = GST_ROUND_UP_4 (width);
+       info->stride[1] = info->stride[0];
+       info->offset[0] = 0;
+diff --git a/gst/playback/gstdecodebin2.c b/gst/playback/gstdecodebin2.c
+index fa5d159e..4f009bec 100644
+--- a/gst/playback/gstdecodebin2.c
++++ b/gst/playback/gstdecodebin2.c
+@@ -238,7 +238,7 @@ enum
+ 
+ /* when playing, keep a max of 2MB of data but try to keep the number of buffers
+  * as low as possible (try to aim for 5 buffers) */
+-#define AUTO_PLAY_SIZE_BYTES        2 * 1024 * 1024
++#define AUTO_PLAY_SIZE_BYTES        10 * 1024 * 1024
+ #define AUTO_PLAY_SIZE_BUFFERS      5
+ #define AUTO_PLAY_SIZE_TIME         0
+ 
+diff --git a/gst/playback/gstplaybin2.c b/gst/playback/gstplaybin2.c
+index 15fea65e..a0a9d063 100644
+--- a/gst/playback/gstplaybin2.c
++++ b/gst/playback/gstplaybin2.c
+@@ -4729,7 +4729,10 @@ autoplug_select_cb (GstElement * decodebin, GstPad * pad,
+                 gst_element_factory_can_src_any_caps (factory, raw_caps)
+                 || gst_element_factory_can_src_any_caps (factory, caps);
+           } else {
+-            compatible = gst_element_factory_can_src_any_caps (factory, caps);
++            if (flags & GST_PLAY_FLAG_NATIVE_VIDEO)
++              compatible = gst_element_factory_can_src_any_caps (factory, raw_caps);
++            else
++              compatible = gst_element_factory_can_src_any_caps (factory, caps);
+           }
+ 
+           gst_object_unref (sinkpad);
+diff --git a/gst/playback/gstplaysink.c b/gst/playback/gstplaysink.c
+index a857d955..e5227593 100644
+--- a/gst/playback/gstplaysink.c
++++ b/gst/playback/gstplaysink.c
+@@ -1923,7 +1923,54 @@ gen_video_chain (GstPlaySink * playsink, gboolean raw, gboolean async)
+     }
+     prev = chain->conv;
+   }
++  else if (playsink->flags & GST_PLAY_FLAG_NATIVE_VIDEO) {
++    GstElement *elem = NULL;
++    GstIterator *iter = NULL;
++    GValue value = { 0 };
++    gboolean done = FALSE;
++    gboolean found_mdp = FALSE;
++
++    iter = gst_bin_iterate_elements (playsink->video_sink);
++    if (iter != NULL) {
++      while (!done) {
++        switch (gst_iterator_next (iter, &value)) {
++          case GST_ITERATOR_OK:
++            elem = (GstElement *) g_value_get_object (&value);
++            GST_DEBUG_OBJECT (playsink, "element->name=%s", GST_ELEMENT_NAME (elem));
++            if (strstr (GST_ELEMENT_NAME (elem), "mtkmdp")) {
++              done = TRUE;
++              found_mdp = TRUE;
++            }
++            /* Iterator increased the element refcount, so unref */
++            g_value_unset (&value);
++            break;
++          default:
++            done = TRUE;
++            break;
++        }
++      }
++      gst_iterator_free (iter);
++    }
+ 
++    if (found_mdp == FALSE) {
++      GST_DEBUG_OBJECT (playsink, "mdp_plugin == NULL");
++      chain->conv = gst_element_factory_make ("mtkmdp", "mtkmdp");
++      if (chain->conv == NULL) {
++        GST_WARNING_OBJECT (playsink, "no mtkmdp plugin");
++      }
++      else {
++        gst_bin_add (bin, chain->conv);
++        if (prev) {
++          if (!gst_element_link_pads_full (prev, "src", chain->conv, "sink",
++                  GST_PAD_LINK_CHECK_TEMPLATE_CAPS))
++            goto link_failed;
++        } else {
++          head = chain->conv;
++        }
++        prev = chain->conv;
++      }
++    }
++  }
+   update_colorbalance (playsink);
+ 
+   if (prev) {
diff --git a/debian/patches/series b/debian/patches/series
index e69de29..5a5022b 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -0,0 +1 @@
+0001-mtk.patch
diff --git a/debian/rules b/debian/rules
index 59c1c5e..4c36952 100755
--- a/debian/rules
+++ b/debian/rules
@@ -115,22 +115,6 @@
 
 maint: debian/control
 
-debian/build-deps: debian/build-deps.in debian/rules
-	cat $< >$@
-
-debian/control:: debian/control.in debian/build-deps debian/mk.control debian/rules debian/changelog force
-	perl debian/mk.control | sed \
-		-e 's/@GST_VERSION@/$(gst_version)/g' \
-		-e 's/@GST_ABI@/$(gst_abi)/g' \
-		-e 's/@GST_PKGNAME@/$(gst_pkgname)/g' \
-		-e 's/@GST_LIB@/$(gst_lib)/g' \
-		-e 's/@GST_LIB_DEV@/$(gst_lib_dev)/g' \
-		-e 's/@GST_LIB_DEV_DEP@/$(gst_lib_dev_dep)/g' \
-		-e 's/@GST_PLUGINS_BASE_LIB@/$(gst_plugins_base_lib)/g' \
-		-e 's/@GST_PLUGINS_BASE_LIB_DEV@/$(gst_plugins_base_lib_dev)/g' \
-		-e 's/@GST_EXTRA_BUILD_DEPENDS@/$(gst_extra_build_depends)/g' \
-		>$@
-
 DEB_CONFIGURE_EXTRA_FLAGS += \
 	--disable-failing-tests \
 	--disable-examples \