[Xfce4-commits] <parole:master> Use pixel aspect ratio hint when calculating the best video size
Ali Abdallah
aliov at xfce.org
Fri Aug 14 19:02:04 CEST 2009
Updating branch refs/heads/master
to e38cf75dd31b46408b84db8c866210267047a16e (commit)
from 4f75f4ebb05786b9bc51132e85b937e75b502b01 (commit)
commit e38cf75dd31b46408b84db8c866210267047a16e
Author: Ali Abdallah <aliov at xfce.org>
Date: Fri Aug 14 18:48:13 2009 +0200
Use pixel aspect ratio hint when calculating the best video size
TODO | 2 -
parole/parole-gst.c | 21 ++++++++++++-------
parole/parole-stream.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 62 insertions(+), 11 deletions(-)
diff --git a/TODO b/TODO
index b40b356..0b4dcff 100644
--- a/TODO
+++ b/TODO
@@ -3,8 +3,6 @@
* Handle missing gstreamer plugins.
* Support scale ratio view.
* Support some playlist title entity.
-* Use pixel-aspect-ratio info when calculating the
- aspect ratio.
* ...
=== Plugins ===
diff --git a/parole/parole-gst.c b/parole/parole-gst.c
index c2a6068..8090572 100644
--- a/parole/parole-gst.c
+++ b/parole/parole-gst.c
@@ -257,11 +257,14 @@ parole_gst_get_video_output_size (ParoleGst *gst, gint *ret_w, gint *ret_h)
guint video_w, video_h;
guint video_par_n, video_par_d;
guint dar_n, dar_d;
+ guint disp_par_n, disp_par_d;
g_object_get (G_OBJECT (gst->priv->stream),
"has-video", &has_video,
"video-width", &video_w,
"video-height", &video_h,
+ "disp-par-n", &disp_par_n,
+ "disp-par-d", &disp_par_d,
NULL);
if ( has_video )
@@ -299,7 +302,7 @@ parole_gst_get_video_output_size (ParoleGst *gst, gint *ret_w, gint *ret_h)
if ( gst_video_calculate_display_ratio (&dar_n, &dar_d,
video_w, video_h,
video_par_n, video_par_d,
- 1, 1) )
+ disp_par_n, disp_par_d) )
{
if (video_w % dar_n == 0)
{
@@ -311,7 +314,7 @@ parole_gst_get_video_output_size (ParoleGst *gst, gint *ret_w, gint *ret_h)
*ret_w = (guint) gst_util_uint64_scale (video_h, dar_n, dar_d);
*ret_h = video_w;
}
- TRACE ("Got best video size %dx%d\n", *ret_w, *ret_h);
+ TRACE ("Got best video size %dx%d fraction, %d/%d\n", *ret_w, *ret_h, disp_par_n, disp_par_d);
}
}
}
@@ -691,8 +694,8 @@ parole_gst_get_pad_capabilities (GObject *object, GParamSpec *pspec, ParoleGst *
GstStructure *st;
gint width;
gint height;
- gint num;
- gint den;
+ guint num;
+ guint den;
const GValue *value;
pad = GST_PAD (object);
@@ -715,13 +718,15 @@ parole_gst_get_pad_capabilities (GObject *object, GParamSpec *pspec, ParoleGst *
if ( ( value = gst_structure_get_value (st, "pixel-aspect-ratio")) )
{
- num = gst_value_get_fraction_numerator (value),
- den = gst_value_get_fraction_denominator (value);
- TRACE ("FIXME: Use these values num=%d den=%d \n", num, den);
+ num = (guint) gst_value_get_fraction_numerator (value),
+ den = (guint) gst_value_get_fraction_denominator (value);
+ g_object_set (G_OBJECT (gst->priv->stream),
+ "disp-par-n", num,
+ "disp-par-d", den,
+ NULL);
}
parole_gst_get_video_output_size (gst, &width, &height);
-
parole_gst_size_allocate (GTK_WIDGET (gst), >K_WIDGET (gst)->allocation);
}
}
diff --git a/parole/parole-stream.c b/parole/parole-stream.c
index eda3f0b..a98b645 100644
--- a/parole/parole-stream.c
+++ b/parole/parole-stream.c
@@ -60,7 +60,9 @@ struct _ParoleStreamPrivate
gint video_h;
gint64 absolute_duration;
guint tracks;
- guint track;
+ guint track;
+ guint disp_par_n;
+ guint disp_par_d;
gchar *title;
gchar *artist;
gchar *year;
@@ -79,6 +81,8 @@ enum
PROP_HAS_AUDIO,
PROP_HAS_VIDEO,
PROP_SEEKABLE,
+ PROP_DISP_PAR_N,
+ PROP_DISP_PAR_D,
PROP_TRACKS,
PROP_TRACK,
PROP_TAG_AVAILABLE,
@@ -156,6 +160,12 @@ static void parole_stream_set_property (GObject *object,
case PROP_SEEKABLE:
PAROLE_STREAM_GET_PRIVATE (stream)->seekable = g_value_get_boolean (value);
break;
+ case PROP_DISP_PAR_D:
+ PAROLE_STREAM_GET_PRIVATE (stream)->disp_par_d = g_value_get_uint (value);
+ break;
+ case PROP_DISP_PAR_N:
+ PAROLE_STREAM_GET_PRIVATE (stream)->disp_par_n = g_value_get_uint (value);
+ break;
case PROP_TRACKS:
PAROLE_STREAM_GET_PRIVATE (stream)->tracks = g_value_get_uint (value);
break;
@@ -226,6 +236,12 @@ static void parole_stream_get_property (GObject *object,
case PROP_SEEKABLE:
g_value_set_boolean (value, PAROLE_STREAM_GET_PRIVATE (stream)->seekable);
break;
+ case PROP_DISP_PAR_D:
+ g_value_set_uint (value, PAROLE_STREAM_GET_PRIVATE (stream)->disp_par_d);
+ break;
+ case PROP_DISP_PAR_N:
+ g_value_set_uint (value, PAROLE_STREAM_GET_PRIVATE (stream)->disp_par_n);
+ break;
case PROP_DURATION:
g_value_set_double (value, PAROLE_STREAM_GET_PRIVATE (stream)->duration);
break;
@@ -420,6 +436,36 @@ parole_stream_class_init (ParoleStreamClass *klass)
G_PARAM_READWRITE));
/**
+ * ParoleStream:disp-par-n:
+ *
+ *
+ *
+ * Since: 0.2
+ **/
+ g_object_class_install_property (object_class,
+ PROP_DISP_PAR_N,
+ g_param_spec_uint ("disp-par-n",
+ NULL, NULL,
+ 1, G_MAXUINT,
+ 1,
+ G_PARAM_READWRITE));
+
+ /**
+ * ParoleStream:disp-par-n:
+ *
+ *
+ *
+ * Since: 0.2
+ **/
+ g_object_class_install_property (object_class,
+ PROP_DISP_PAR_D,
+ g_param_spec_uint ("disp-par-d",
+ NULL, NULL,
+ 1, G_MAXUINT,
+ 1,
+ G_PARAM_READWRITE));
+
+ /**
* ParoleStream:video-width:
*
*
@@ -584,6 +630,8 @@ void parole_stream_init_properties (ParoleStream *stream)
priv->video_w = 0;
priv->tracks = 1;
priv->track = 1;
+ priv->disp_par_n = 1;
+ priv->disp_par_d = 1;
PAROLE_STREAM_FREE_STR_PROP (priv->title);
PAROLE_STREAM_FREE_STR_PROP (priv->uri);
More information about the Xfce4-commits
mailing list