[gst-cvs] gst-plugins-bad: winks: provide guessed pixel-aspect-ratio in caps

Ole Andre Vadla Ravnaas oleavr at kemper.freedesktop.org
Thu Oct 28 08:09:56 PDT 2010


Module: gst-plugins-bad
Branch: master
Commit: a54972f8069a324beffde0087a9f4a099def122f
URL:    http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/commit/?id=a54972f8069a324beffde0087a9f4a099def122f

Author: Knut Inge Hvidsten <knut.inge.hvidsten at tandberg.com>
Date:   Mon Aug 31 19:25:02 2009 +0200

winks: provide guessed pixel-aspect-ratio in caps

---

 sys/winks/ksvideohelpers.c |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/sys/winks/ksvideohelpers.c b/sys/winks/ksvideohelpers.c
index bc51f50..419f266 100644
--- a/sys/winks/ksvideohelpers.c
+++ b/sys/winks/ksvideohelpers.c
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2007 Haakon Sporsheim <hakon.sporsheim at tandberg.com>
  *               2008 Ole André Vadla Ravnås <ole.andre.ravnas at tandberg.com>
+ *               2009 Knut Inge Hvidsten <knut.inge.hvidsten at tandberg.com>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -155,6 +156,28 @@ ks_video_format_to_structure (GUID subtype_guid, GUID format_guid)
   return structure;
 }
 
+static void
+guess_aspect (gint width, gint height, gint * par_width, gint * par_height)
+{
+  /*
+   * As we dont have access to the actual pixel aspect, we will try to do a
+   * best-effort guess. The guess is based on most sensors being either 4/3
+   * or 16/9, and most pixel aspects being close to 1/1.
+   */
+  if ((width == 768) && (height == 448)) {      /* special case for w448p */
+    *par_width = 28;
+    *par_height = 27;
+  } else {
+    if (((float) width / (float) height) < 1.2778) {
+      *par_width = 12;
+      *par_height = 11;
+    } else {
+      *par_width = 1;
+      *par_height = 1;
+    }
+  }
+}
+
 static gboolean
 ks_video_append_video_stream_cfg_fields (GstStructure * structure,
     const KS_VIDEO_STREAM_CONFIG_CAPS * vscc)
@@ -194,6 +217,16 @@ ks_video_append_video_stream_cfg_fields (GstStructure * structure,
         (gint) (10000000 / vscc->MinFrameInterval), 1, NULL);
   }
 
+  {
+    gint par_width, par_height;
+
+    guess_aspect (vscc->MaxOutputSize.cx, vscc->MaxOutputSize.cy,
+        &par_width, &par_height);
+
+    gst_structure_set (structure,
+        "pixel-aspect-ratio", GST_TYPE_FRACTION, par_width, par_height, NULL);
+  }
+
   return TRUE;
 }
 





More information about the Gstreamer-commits mailing list