assrender: Fix compilation with libass >= 0.9.7 and fix aspect ratio setting
authorSebastian Dröge <sebastian.droege@collabora.co.uk>
Mon, 31 Aug 2009 07:11:34 +0000 (09:11 +0200)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Mon, 31 Aug 2009 07:11:34 +0000 (09:11 +0200)
Fixes bug #575261.

configure.ac
ext/assrender/gstassrender.c
ext/assrender/gstassrender.h

index 6357e4f880c77ba187be5e471a041e71877fe842..e1155e45b146499c99c653be6bc83af9ca8a6926 100644 (file)
@@ -482,7 +482,7 @@ AG_GST_CHECK_FEATURE(ALSA, [alsa plug-ins], gstalsa, [
 dnl *** assrender ***
 translit(dnm, m, l) AM_CONDITIONAL(USE_ASSRENDER, true)
 AG_GST_CHECK_FEATURE(ASSRENDER, [ASS/SSA renderer], assrender, [
-  PKG_CHECK_MODULES(ASSRENDER, libass >= 0.9.4 libass < 0.9.7, [
+  PKG_CHECK_MODULES(ASSRENDER, libass >= 0.9.4, [
     HAVE_ASSRENDER="yes" ], [
     HAVE_ASSRENDER="no"
     AC_MSG_RESULT(no)
index 6dc5dc2cece19238206c73492674b4436ab37d26..a62c4d1b2ec4f80b7c3683a64b0e013c7e273072 100644 (file)
@@ -295,15 +295,29 @@ gst_assrender_setcaps_video (GstPad * pad, GstCaps * caps)
 
   if (gst_structure_get_int (structure, "width", &render->width) &&
       gst_structure_get_int (structure, "height", &render->height)) {
+    gdouble dar;
+
     ret = gst_pad_set_caps (render->srcpad, caps);
     ass_set_frame_size (render->ass_renderer, render->width, render->height);
-    /* FIXME: Does this expect aspect ratio or pixel aspect ratio? */
+
+    dar = (((gdouble) par_n) * ((gdouble) render->width));
+    dar /= (((gdouble) par_d) * ((gdouble) render->height));
+#if !defined(LIBASS_VERSION) || LIBASS_VERSION < 0x00907010
+    ass_set_aspect_ratio (render->ass_renderer, dar);
+#else
     ass_set_aspect_ratio (render->ass_renderer,
-        ((gdouble) par_n) / ((gdouble) par_d));
+        dar, ((gdouble) render->width) / ((gdouble) render->height));
+#endif
     ass_set_font_scale (render->ass_renderer, 1.0);
     ass_set_hinting (render->ass_renderer, ASS_HINTING_NATIVE);
+
+#if !defined(LIBASS_VERSION) || LIBASS_VERSION < 0x00907010
     ass_set_fonts (render->ass_renderer, "Arial", "sans-serif");
     ass_set_fonts (render->ass_renderer, NULL, "Sans");
+#else
+    ass_set_fonts (render->ass_renderer, "Arial", "sans-serif", 1, NULL, 1);
+    ass_set_fonts (render->ass_renderer, NULL, "Sans", 1, NULL, 1);
+#endif
     ass_set_margins (render->ass_renderer, 0, 0, 0, 0);
     ass_set_use_margins (render->ass_renderer, 0);
 
@@ -383,7 +397,7 @@ gst_assrender_chain_video (GstPad * pad, GstBuffer * buffer)
   gint64 start, stop, clip_start = 0, clip_stop = 0;
   double timestamp;
   double step;
-  ass_image_t *ass_image;
+  ASS_Image *ass_image;
 
   render = GST_ASSRENDER (GST_PAD_PARENT (pad));
 
index 28b1e89038fef2b0b5ef0cf686656352afd02b38..39edd0ac58969cae06af8d15e7c530a21f1f3698 100644 (file)
 
 G_BEGIN_DECLS
 
+#if !defined(LIBASS_VERSION) || LIBASS_VERSION < 0x00907010
+#define ASS_Library ass_library_t
+#define ASS_Renderer ass_renderer_t
+#define ASS_Track ass_track_t
+#define ASS_Image ass_image_t
+#endif
+
 #define GST_TYPE_ASSRENDER (gst_assrender_get_type())
 #define GST_ASSRENDER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ASSRENDER,Gstassrender))
 #define GST_ASSRENDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ASSRENDER,GstassrenderClass))
@@ -44,9 +51,9 @@ struct _Gstassrender
 
   gint width, height;
 
-  ass_library_t *ass_library;
-  ass_renderer_t *ass_renderer;
-  ass_track_t *ass_track;
+  ASS_Library *ass_library;
+  ASS_Renderer *ass_renderer;
+  ASS_Track *ass_track;
 
   gboolean renderer_init_ok, track_init_ok, enable, embeddedfonts;
 };