[MPlayer-cvslog] r23152 - in trunk: DOCS/man/en/mplayer.1 cfg-common.h libass/ass.h libass/ass_font.c libass/ass_font.h libass/ass_mp.c libass/ass_mp.h libass/ass_render.c libmpcodecs/vf_ass.c libmpcodecs/vf_vo.c libmpcodecs/vfcap.h libvo/vo_gl.c

eugeni subversion at mplayerhq.hu
Fri Apr 27 16:25:36 CEST 2007


Author: eugeni
Date: Fri Apr 27 16:25:36 2007
New Revision: 23152

Log:
Add -ass-hinting option for setting font hinting method.
It is possible to separately configure hinting for scaled and unscaled osd.
The default is native hinter for unscaled osd (only vo_gl at this point),
no hinting for vf_ass.


Modified:
   trunk/cfg-common.h
   trunk/libass/ass.h
   trunk/libass/ass_font.c
   trunk/libass/ass_font.h
   trunk/libass/ass_mp.c
   trunk/libass/ass_mp.h
   trunk/libass/ass_render.c
   trunk/libmpcodecs/vf_ass.c
   trunk/libmpcodecs/vf_vo.c
   trunk/libmpcodecs/vfcap.h
   trunk/libvo/vo_gl.c

Changes in other areas also in this revision:
Modified:
   trunk/DOCS/man/en/mplayer.1

Modified: trunk/cfg-common.h
==============================================================================
--- trunk/cfg-common.h	(original)
+++ trunk/cfg-common.h	Fri Apr 27 16:25:36 2007
@@ -322,6 +322,7 @@
 	{"ass-color", &ass_color, CONF_TYPE_STRING, 0, 0, 0, NULL},
 	{"ass-border-color", &ass_border_color, CONF_TYPE_STRING, 0, 0, 0, NULL},
 	{"ass-styles", &ass_styles_file, CONF_TYPE_STRING, 0, 0, 0, NULL},
+	{"ass-hinting", &ass_hinting, CONF_TYPE_INT, CONF_RANGE, 0, 7, NULL},
 #endif
 #ifdef HAVE_FONTCONFIG
 	{"fontconfig", &font_fontconfig, CONF_TYPE_FLAG, 0, 0, 1, NULL},

Modified: trunk/libass/ass.h
==============================================================================
--- trunk/libass/ass.h	(original)
+++ trunk/libass/ass.h	Fri Apr 27 16:25:36 2007
@@ -37,6 +37,13 @@ typedef struct ass_image_s {
 	struct ass_image_s* next; // linked list
 } ass_image_t;
 
+/// Hinting type
+typedef enum {ASS_HINTING_NONE = 0,
+	      ASS_HINTING_LIGHT,
+	      ASS_HINTING_NORMAL,
+	      ASS_HINTING_NATIVE
+} ass_hinting_t;
+
 /**
  * \brief initialize the library
  * \return library handle or NULL if failed
@@ -77,6 +84,7 @@ void ass_set_margins(ass_renderer_t* pri
 void ass_set_use_margins(ass_renderer_t* priv, int use);
 void ass_set_aspect_ratio(ass_renderer_t* priv, double ar);
 void ass_set_font_scale(ass_renderer_t* priv, double font_scale);
+void ass_set_hinting(ass_renderer_t* priv, ass_hinting_t ht);
 
 /**
  * \brief set font lookup defaults

Modified: trunk/libass/ass_font.c
==============================================================================
--- trunk/libass/ass_font.c	(original)
+++ trunk/libass/ass_font.c	Fri Apr 27 16:25:36 2007
@@ -229,13 +229,14 @@ void ass_font_get_asc_desc(ass_font_t* f
  * \brief Get a glyph
  * \param ch character code
  **/
-FT_Glyph ass_font_get_glyph(void* fontconfig_priv, ass_font_t* font, uint32_t ch)
+FT_Glyph ass_font_get_glyph(void* fontconfig_priv, ass_font_t* font, uint32_t ch, ass_hinting_t hinting)
 {
 	int error;
 	int index = 0;
 	int i;
 	FT_Glyph glyph;
 	FT_Face face = 0;
+	int flags = 0;
 
 	if (ch < 0x20)
 		return 0;
@@ -264,7 +265,14 @@ FT_Glyph ass_font_get_glyph(void* fontco
 	}
 #endif
 
-	error = FT_Load_Glyph(face, index, FT_LOAD_NO_BITMAP );
+	switch (hinting) {
+	case ASS_HINTING_NONE: flags = FT_LOAD_NO_HINTING; break;
+	case ASS_HINTING_LIGHT: flags = FT_LOAD_FORCE_AUTOHINT | FT_LOAD_TARGET_LIGHT; break;
+	case ASS_HINTING_NORMAL: flags = FT_LOAD_FORCE_AUTOHINT; break;
+	case ASS_HINTING_NATIVE: flags = 0; break;
+	}
+	
+	error = FT_Load_Glyph(face, index, FT_LOAD_NO_BITMAP | flags);
 	if (error) {
 		mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_ErrorLoadingGlyph);
 		return 0;

Modified: trunk/libass/ass_font.h
==============================================================================
--- trunk/libass/ass_font.h	(original)
+++ trunk/libass/ass_font.h	Fri Apr 27 16:25:36 2007
@@ -50,7 +50,7 @@ ass_font_t* ass_font_new(ass_library_t* 
 void ass_font_set_transform(ass_font_t* font, FT_Matrix* m, FT_Vector* v);
 void ass_font_set_size(ass_font_t* font, int size);
 void ass_font_get_asc_desc(ass_font_t* font, uint32_t ch, int* asc, int* desc);
-FT_Glyph ass_font_get_glyph(void* fontconfig_priv, ass_font_t* font, uint32_t ch);
+FT_Glyph ass_font_get_glyph(void* fontconfig_priv, ass_font_t* font, uint32_t ch, ass_hinting_t hinting);
 FT_Vector ass_font_get_kerning(ass_font_t* font, uint32_t c1, uint32_t c2);
 void ass_font_free(ass_font_t* font);
 

Modified: trunk/libass/ass_mp.c
==============================================================================
--- trunk/libass/ass_mp.c	(original)
+++ trunk/libass/ass_mp.c	Fri Apr 27 16:25:36 2007
@@ -50,6 +50,7 @@ int ass_use_margins = 0;
 char* ass_color = NULL;
 char* ass_border_color = NULL;
 char* ass_styles_file = NULL;
+int ass_hinting = ASS_HINTING_NATIVE + 4; // native hinting for unscaled osd
 
 #ifdef HAVE_FONTCONFIG
 extern int font_fontconfig;
@@ -218,11 +219,17 @@ ass_track_t* ass_read_subdata(ass_librar
 
 char *get_path(char *);
 
-void ass_configure(ass_renderer_t* priv, int w, int h) {
+void ass_configure(ass_renderer_t* priv, int w, int h, int unscaled) {
+	int hinting;
 	ass_set_frame_size(priv, w, h);
 	ass_set_margins(priv, ass_top_margin, ass_bottom_margin, 0, 0);
 	ass_set_use_margins(priv, ass_use_margins);
 	ass_set_font_scale(priv, ass_font_scale);
+	if (!unscaled && (ass_hinting & 4))
+		hinting = 0;
+	else
+		hinting = ass_hinting & 3;
+	ass_set_hinting(priv, hinting);
 }
 
 void ass_configure_fonts(ass_renderer_t* priv) {

Modified: trunk/libass/ass_mp.h
==============================================================================
--- trunk/libass/ass_mp.h	(original)
+++ trunk/libass/ass_mp.h	Fri Apr 27 16:25:36 2007
@@ -35,12 +35,13 @@ extern int ass_use_margins;
 extern char* ass_color;
 extern char* ass_border_color;
 extern char* ass_styles_file;
+extern int ass_hinting;
 
 ass_track_t* ass_default_track(ass_library_t* library);
 int ass_process_subtitle(ass_track_t* track, subtitle* sub);
 ass_track_t* ass_read_subdata(ass_library_t* library, sub_data* subdata, double fps);
 
-void ass_configure(ass_renderer_t* priv, int w, int h);
+void ass_configure(ass_renderer_t* priv, int w, int h, int hinting);
 void ass_configure_fonts(ass_renderer_t* priv);
 ass_library_t* ass_init(void);
 

Modified: trunk/libass/ass_render.c
==============================================================================
--- trunk/libass/ass_render.c	(original)
+++ trunk/libass/ass_render.c	Fri Apr 27 16:25:36 2007
@@ -56,6 +56,7 @@ typedef struct ass_settings_s {
 	int use_margins; // 0 - place all subtitles inside original frame
 	                 // 1 - use margins for placing toptitles and subtitles
 	double aspect; // frame aspect ratio, d_width / d_height.
+	ass_hinting_t hinting;
 
 	char* default_font;
 	char* default_family;
@@ -1249,7 +1250,7 @@ static void get_outline_glyph(int symbol
 		info->advance.y = val->advance.y;
 	} else {
 		glyph_hash_val_t v;
-		info->glyph = ass_font_get_glyph(frame_context.ass_priv->fontconfig_priv, render_context.font, symbol);
+		info->glyph = ass_font_get_glyph(frame_context.ass_priv->fontconfig_priv, render_context.font, symbol, global_settings->hinting);
 		if (!info->glyph)
 			return;
 		info->advance.x = d16_to_d6(info->glyph->advance.x);
@@ -2049,6 +2050,14 @@ void ass_set_font_scale(ass_renderer_t* 
 	}
 }
 
+void ass_set_hinting(ass_renderer_t* priv, ass_hinting_t ht)
+{
+	if (priv->settings.hinting != ht) {
+		priv->settings.hinting = ht;
+		ass_reconfigure(priv);
+	}
+}
+
 int ass_set_fonts(ass_renderer_t* priv, const char* default_font, const char* default_family)
 {
 	if (priv->settings.default_font)

Modified: trunk/libmpcodecs/vf_ass.c
==============================================================================
--- trunk/libmpcodecs/vf_ass.c	(original)
+++ trunk/libmpcodecs/vf_ass.c	Fri Apr 27 16:25:36 2007
@@ -92,7 +92,7 @@ static int config(struct vf_instance_s* 
 	vf->priv->dirty_rows = malloc(vf->priv->outh);
 	
 	if (vf->priv->ass_priv) {
-		ass_configure(vf->priv->ass_priv, vf->priv->outw, vf->priv->outh);
+		ass_configure(vf->priv->ass_priv, vf->priv->outw, vf->priv->outh, 0);
 		ass_set_aspect_ratio(vf->priv->ass_priv, ((double)d_width) / d_height);
 	}
 

Modified: trunk/libmpcodecs/vf_vo.c
==============================================================================
--- trunk/libmpcodecs/vf_vo.c	(original)
+++ trunk/libmpcodecs/vf_vo.c	Fri Apr 27 16:25:36 2007
@@ -60,14 +60,14 @@ static int config(struct vf_instance_s* 
   }
 
     // save vo's stride capability for the wanted colorspace:
-    vf->default_caps=query_format(vf,outfmt) & VFCAP_ACCEPT_STRIDE;
+    vf->default_caps=query_format(vf,outfmt);
 
     if(config_video_out(video_out,width,height,d_width,d_height,flags,"MPlayer",outfmt))
 	return 0;
 
 #ifdef USE_ASS
     if (vf->priv->ass_priv)
-	ass_configure(vf->priv->ass_priv, width, height);
+	ass_configure(vf->priv->ass_priv, width, height, !!(vf->default_caps & VFCAP_EOSD_UNSCALED));
 #endif
 
     ++vo_config_count;

Modified: trunk/libmpcodecs/vfcap.h
==============================================================================
--- trunk/libmpcodecs/vfcap.h	(original)
+++ trunk/libmpcodecs/vfcap.h	Fri Apr 27 16:25:36 2007
@@ -28,4 +28,5 @@
 #define VFCAP_CONSTANT 0x1000
 // filter can draw EOSD
 #define VFCAP_EOSD 0x2000
-
+// filter will draw EOSD at screen resolution (without scaling)
+#define VFCAP_EOSD_UNSCALED 0x4000

Modified: trunk/libvo/vo_gl.c
==============================================================================
--- trunk/libvo/vo_gl.c	(original)
+++ trunk/libvo/vo_gl.c	Fri Apr 27 16:25:36 2007
@@ -792,7 +792,7 @@ query_format(uint32_t format)
                VFCAP_FLIP |
                VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN | VFCAP_ACCEPT_STRIDE;
     if (use_osd)
-      caps |= VFCAP_OSD | VFCAP_EOSD;
+      caps |= VFCAP_OSD | VFCAP_EOSD | VFCAP_EOSD_UNSCALED;
     if ((format == IMGFMT_RGB24) || (format == IMGFMT_RGBA))
         return caps;
     if (use_yuv && format == IMGFMT_YV12)



More information about the MPlayer-cvslog mailing list