From 63625b011141970aca4cd5b8804254a4fcf54844 Mon Sep 17 00:00:00 2001
From: Vineeth T M <vineeth.tm@samsung.com>
Date: Tue, 16 Sep 2014 16:46:07 +0530
Subject: [PATCH] gdkpixbufdec: modify wrong packetized mode logic

packetized mode is being set when framerate is being set
which is not correct. Changing the same by checking the
input segement format. If input segment is in TIME it is
Packetized, and if it is in BYTES it is not.

https://bugzilla.gnome.org/show_bug.cgi?id=736252
---
 ext/gdk_pixbuf/gstgdkpixbufdec.c | 13 ++++++++++---
 ext/gdk_pixbuf/gstgdkpixbufdec.h |  8 +++-----
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/ext/gdk_pixbuf/gstgdkpixbufdec.c b/ext/gdk_pixbuf/gstgdkpixbufdec.c
index eb56d77c..3e1a611 100644
--- a/ext/gdk_pixbuf/gstgdkpixbufdec.c
+++ b/ext/gdk_pixbuf/gstgdkpixbufdec.c
@@ -215,6 +215,7 @@ gst_gdk_pixbuf_dec_init (GstGdkPixbufDec * filter)
 
   filter->last_timestamp = GST_CLOCK_TIME_NONE;
   filter->pixbuf_loader = NULL;
+  filter->packetized = FALSE;
 }
 
 static gboolean
@@ -427,6 +428,14 @@ gst_gdk_pixbuf_dec_sink_event (GstPad * pad, GstObject * parent,
       pixbuf->pending_events = NULL;
       /* Fall through */
     case GST_EVENT_SEGMENT:
+    {
+      const GstSegment *segment;
+      gst_event_parse_segment (event, &segment);
+      if (segment->format == GST_FORMAT_BYTES)
+        pixbuf->packetized = FALSE;
+      else
+        pixbuf->packetized = TRUE;
+    }
       if (pixbuf->pixbuf_loader != NULL) {
         gdk_pixbuf_loader_close (pixbuf->pixbuf_loader, NULL);
         g_object_unref (G_OBJECT (pixbuf->pixbuf_loader));
@@ -482,9 +491,7 @@ gst_gdk_pixbuf_dec_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
           &error))
     goto error;
 
-  /* packetised mode? *//* FIXME: shouln't this be fps_d != 0, since 0/1
-   * might be packetised mode but variable framerate */
-  if (filter->in_fps_n != 0) {
+  if (filter->packetized == TRUE) {
     gdk_pixbuf_loader_close (filter->pixbuf_loader, NULL);
     ret = gst_gdk_pixbuf_dec_flush (filter);
     g_object_unref (filter->pixbuf_loader);
diff --git a/ext/gdk_pixbuf/gstgdkpixbufdec.h b/ext/gdk_pixbuf/gstgdkpixbufdec.h
index 832a30b..c5f1789 100644
--- a/ext/gdk_pixbuf/gstgdkpixbufdec.h
+++ b/ext/gdk_pixbuf/gstgdkpixbufdec.h
@@ -26,7 +26,6 @@
 #include <gdk-pixbuf/gdk-pixbuf.h>
 
 G_BEGIN_DECLS
-
 #define GST_TYPE_GDK_PIXBUF_DEC			\
   (gst_gdk_pixbuf_dec_get_type())
 #define GST_GDK_PIXBUF_DEC(obj)						\
@@ -37,8 +36,7 @@ G_BEGIN_DECLS
   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GDK_PIXBUF_DEC))
 #define GST_IS_GDK_PIXBUF_DEC_CLASS(klass)				\
   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GDK_PIXBUF_DEC))
-
-typedef struct _GstGdkPixbufDec      GstGdkPixbufDec;
+typedef struct _GstGdkPixbufDec GstGdkPixbufDec;
 typedef struct _GstGdkPixbufDecClass GstGdkPixbufDecClass;
 
 struct _GstGdkPixbufDec
@@ -47,7 +45,7 @@ struct _GstGdkPixbufDec
 
   GstPad *sinkpad, *srcpad;
 
-  GstClockTime    last_timestamp;
+  GstClockTime last_timestamp;
   GdkPixbufLoader *pixbuf_loader;
 
   gint in_fps_n, in_fps_d;
@@ -55,6 +53,7 @@ struct _GstGdkPixbufDec
   GstVideoInfo info;
   GstBufferPool *pool;
   GList *pending_events;
+  gboolean packetized;
 };
 
 struct _GstGdkPixbufDecClass
@@ -65,5 +64,4 @@ struct _GstGdkPixbufDecClass
 GType gst_gdk_pixbuf_dec_get_type (void);
 
 G_END_DECLS
-
 #endif /* __GST_GDK_PIXBUF_DEC_H__ */
-- 
1.9.1

