Index: libvo/sub.h
===================================================================
--- libvo/sub.h	(revision 31760)
+++ libvo/sub.h	(working copy)
@@ -29,6 +29,7 @@
 #define OSDTYPE_SPU 4
 #define OSDTYPE_DVDNAV 5
 #define OSDTYPE_TELETEXT 6
+#define OSDTYPE_OSDTIME 7
 
 #define OSDFLAG_VISIBLE 1
 #define OSDFLAG_CHANGED 2
@@ -58,6 +59,9 @@
 	struct {
 	    int elems;
 	} progbar;
+	struct {
+	    int align;
+	} osdtime;
     } params;
     int stride;
 
@@ -123,7 +127,18 @@
 extern int spu_alignment;
 extern int spu_aamode;
 extern float spu_gaussvar;
+extern char *osdtime;
+extern int osdtimevmargin;
+extern int osdtimehmargin;
 
+#define OSDTIME_ALIGN_BOTTOMLEFT 0
+#define OSDTIME_ALIGN_BOTTOMCENTER 1
+#define OSDTIME_ALIGN_BOTTOMRIGHT 2
+#define OSDTIME_ALIGN_TOPLEFT 3
+#define OSDTIME_ALIGN_TOPCENTER 4
+#define OSDTIME_ALIGN_TOPRIGHT 5
+#define OSDTIME_ALIGN_MAX 6
+
 void vo_draw_text(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride));
 void vo_draw_text_ext(int dxs, int dys, int left_border, int top_border,
                       int right_border, int bottom_border, int orig_w, int orig_h,
@@ -135,6 +150,7 @@
 int vo_osd_changed(int new_value);
 int vo_osd_check_range_update(int,int,int,int);
 void free_osd_list(void);
+int vo_osdtime(void);
 
 extern int vo_osd_changed_flag;
 
Index: libvo/sub.c
===================================================================
--- libvo/sub.c	(revision 31760)
+++ libvo/sub.c	(working copy)
@@ -103,6 +103,15 @@
 #ifdef CONFIG_DVDNAV
 static nav_highlight_t nav_hl;
 #endif
+#ifdef CONFIG_OSDTIME
+#include <time.h>
+#endif
+char* osdtime=NULL;
+int osdtimealign=0;
+char* osdtimeformat=NULL;
+char* osdtimetext[OSDTIME_ALIGN_MAX];
+int osdtimevmargin=10;
+int osdtimehmargin=10;
 
 // return the real height of a char:
 static inline int get_height(int c,int h){
@@ -1039,6 +1048,129 @@
 
 }
 
+inline static void vo_render_osdtime(mp_osd_obj_t* obj, int dxs, int dys,
+                                     char *text, int align)
+{
+    unsigned char *cp = text;
+    int x[25], w=0, y=0;
+    int font, c;
+    int dx=0, dy=0, l=0;
+
+    if (!text || strlen(text)==0) {
+        obj->flags &= ~OSDFLAG_VISIBLE;
+        return;
+    }
+    x[l] = 0;
+    while (*cp) {
+        c = *cp++;
+        if (c=='\n') {
+            x[l] -= vo_font->charspace;
+            w = FFMAX(w,x[l]);
+            l++;
+            if (l>25) break;
+            x[l] = 0;
+        } else {
+            render_one_glyph(vo_font,c);
+            x[l] += vo_font->width[c]+vo_font->charspace;
+            y = get_height(c,y);
+        }
+    }
+    x[l] -= vo_font->charspace;
+    w = FFMAX(w,x[l]);
+    l++;
+    if (w>dxs || y*l>dys) {
+        obj->flags&=~OSDFLAG_VISIBLE;
+        return;
+    }
+    obj->bbox.x1 = obj->x = 0;
+    obj->bbox.y1 = obj->y = 0;
+    obj->bbox.x2 = obj->bbox.x1+w;
+    obj->bbox.y2 = obj->bbox.y1+y*l;
+    switch (align) {
+    case OSDTIME_ALIGN_BOTTOMCENTER:
+        dy = dys-y*l-osdtimehmargin;
+        dx = (dxs-w-osdtimevmargin)/2;
+        break;
+    case OSDTIME_ALIGN_BOTTOMRIGHT:
+        dy = dys-y*l-osdtimehmargin;
+        dx = dxs-w-osdtimevmargin;
+        break;
+    case OSDTIME_ALIGN_TOPLEFT:
+        dy = osdtimehmargin;
+        dx = osdtimevmargin;
+        break;
+    case OSDTIME_ALIGN_TOPCENTER:
+        dy = osdtimehmargin;
+        dx = (dxs-w-osdtimevmargin)/2;
+        break;
+    case OSDTIME_ALIGN_TOPRIGHT:
+        dy = osdtimehmargin;
+        dx = dxs-w-osdtimevmargin;
+        break;
+    case OSDTIME_ALIGN_BOTTOMLEFT:
+    default:
+        dy = dys-y*l-osdtimehmargin;
+        dx = osdtimevmargin;
+        break;
+    }
+    for (c=0; c<l; c++)
+        switch (align) {
+        case OSDTIME_ALIGN_BOTTOMCENTER:
+        case OSDTIME_ALIGN_TOPCENTER:
+            x[c] = (w-x[c])/2;
+            break;
+        case OSDTIME_ALIGN_BOTTOMRIGHT:
+        case OSDTIME_ALIGN_TOPRIGHT:
+            x[c] = w-x[c];
+            break;
+        case OSDTIME_ALIGN_BOTTOMLEFT:
+        case OSDTIME_ALIGN_TOPLEFT:
+        default:
+            x[c] = 0;
+        }
+    obj->x += dx;
+    obj->bbox.x1 += dx;
+    obj->bbox.x2 += dx;
+    obj->y += dy;
+    obj->bbox.y1 += dy;
+    obj->bbox.y2 += dy;
+    obj->flags |= OSDFLAG_BBOX;
+
+    alloc_buf(obj);
+
+    cp = text;
+    l = 0;
+    w = obj->x + x[l];
+    while (*cp){
+        c =* cp++;
+        if (c=='\n') {
+            l++;
+            if (l>25) break;
+            w = obj->x + x[l];
+            obj->y += y;
+        } else {
+            if ((font=vo_font->font[c])>=0)
+                draw_alpha_buf(obj, w, obj->y,
+                               vo_font->width[c],
+                               vo_font->pic_a[font]->h,
+                               vo_font->pic_b[font]->bmp+vo_font->start[c],
+                               vo_font->pic_a[font]->bmp+vo_font->start[c],
+                               vo_font->pic_a[font]->w);
+        w += vo_font->width[c]+vo_font->charspace;
+        }
+    }
+    obj->flags |= OSDFLAG_CHANGED|OSDFLAG_VISIBLE;
+}
+
+inline static void vo_update_osdtime(mp_osd_obj_t* obj, int dxs, int dys)
+{
+    if (obj->params.osdtime.align<0 ||
+        obj->params.osdtime.align>=OSDTIME_ALIGN_MAX)
+        return;
+    vo_render_osdtime(obj, dxs, dys, osdtimetext[obj->params.osdtime.align],
+                      obj->params.osdtime.align);
+}
+
 inline static void vo_update_spudec_sub(mp_osd_obj_t* obj, int dxs, int dys)
 {
   unsigned int bbox[4];
@@ -1078,6 +1210,8 @@
 
 void free_osd_list(void){
     mp_osd_obj_t* obj=vo_osd_list;
+    int i;
+
     while(obj){
 	mp_osd_obj_t* next=obj->next;
 	if (obj->alpha_buffer) free(obj->alpha_buffer);
@@ -1085,6 +1219,14 @@
 	free(obj);
 	obj=next;
     }
+#ifdef CONFIG_OSDTIME
+    for (i=0;i<OSDTIME_ALIGN_MAX;i++) {
+        if (osdtimetext[i])
+            free(osdtimetext[i]);
+        osdtimetext[i] = NULL;
+    }
+    osdtimeformat=NULL;
+#endif
     vo_osd_list=NULL;
 }
 
@@ -1157,6 +1299,11 @@
 	case OSDTYPE_TELETEXT:
 	    vo_update_text_teletext(obj,dxs,dys);
 	    break;
+#ifdef CONFIG_OSDTIME
+	case OSDTYPE_OSDTIME:
+	    vo_update_osdtime(obj,dxs,dys);
+	    break;
+#endif
 	case OSDTYPE_PROGBAR:
 	    vo_update_text_progbar(obj,dxs,dys);
 	    break;
@@ -1215,6 +1362,9 @@
 }
 
 void vo_init_osd(void){
+    mp_osd_obj_t* obj;
+    int i=0;
+
     if(!draw_alpha_init_flag){
 	draw_alpha_init_flag=1;
 	vo_draw_alpha_init();
@@ -1229,6 +1379,12 @@
     new_osd_obj(OSDTYPE_DVDNAV);
 #endif
     new_osd_obj(OSDTYPE_TELETEXT);
+#if CONFIG_OSDTIME
+    for (i=0;i<OSDTIME_ALIGN_MAX;i++) {
+        obj = new_osd_obj(OSDTYPE_OSDTIME);
+        obj->params.osdtime.align = i;
+    }
+#endif
 #ifdef CONFIG_FREETYPE
     force_load_font = 1;
 #endif
@@ -1269,6 +1425,9 @@
 #ifdef CONFIG_DVDNAV
         case OSDTYPE_DVDNAV:
 #endif
+#ifdef CONFIG_OSDTIME
+        case OSDTYPE_OSDTIME:
+#endif
 	case OSDTYPE_TELETEXT:
 	case OSDTYPE_OSD:
 	case OSDTYPE_SUBTITLE:
@@ -1322,3 +1481,109 @@
     }
     return 0;
 }
+
+static char *strstrfirst(char *text, char **findlist) {
+    char *p, *pn;
+
+    p=strchr(text,'\t');
+    while ((*findlist)) {
+        pn=strstr(text,*findlist);
+        if (!p || (pn && p>pn)) p=pn;
+        findlist++;
+    }
+    return p;
+}
+
+
+#ifdef CONFIG_OSDTIME
+int vo_osdtime(void) {
+    char *p, *pt, text[256];
+    char c;
+    time_t ttime;
+    struct tm *ptm;
+    int i, halign, valign, nonewline=0;
+    char *findlist[] = {"\\t","\\n","\\r","\\_",NULL};
+    static struct osdtimealign_cmd_s {
+        char *cmd;
+        int align;
+    } const osdtimealign_cmd[] = {
+        {"_",   OSDTIME_ALIGN_BOTTOMLEFT},
+        {"b_",  OSDTIME_ALIGN_BOTTOMLEFT},
+        {"t_",  OSDTIME_ALIGN_TOPLEFT},
+        {"bl_", OSDTIME_ALIGN_BOTTOMLEFT},
+        {"bc_", OSDTIME_ALIGN_BOTTOMCENTER},
+        {"br_", OSDTIME_ALIGN_BOTTOMRIGHT},
+        {"tl_", OSDTIME_ALIGN_TOPLEFT},
+        {"tc_", OSDTIME_ALIGN_TOPCENTER},
+        {"tr_", OSDTIME_ALIGN_TOPRIGHT},
+        {NULL,0}};
+
+    if (!osdtime)
+        return 0;
+    if (!osdtimeformat) {
+        for (i=0;i<OSDTIME_ALIGN_MAX;i++)
+            osdtimetext[i] = calloc(1,256);
+        osdtimeformat = osdtime;
+        osdtimealign = 0;
+        for (i=0;osdtimealign_cmd[i].cmd;i++)
+            if (!(strncasecmp(osdtime,osdtimealign_cmd[i].cmd,
+                strlen(osdtimealign_cmd[i].cmd)))) {
+                osdtimealign = osdtimealign_cmd[i].align;
+                osdtimeformat += strlen(osdtimealign_cmd[i].cmd);
+                break;
+            }
+    }
+
+    for (i=0;i<OSDTIME_ALIGN_MAX;i++)
+        memset(osdtimetext[i],0,256);
+    ttime = time(NULL);
+    ptm = localtime(&ttime);
+    strftime(text,sizeof(text),osdtimeformat,ptm);
+    halign = 0;
+    valign = osdtimealign;
+    if (valign>2) {
+        valign -= 3;
+        halign = 1;
+    }
+    pt = text;
+    while ((p=strstrfirst(pt,findlist))) {
+        if (*p=='\t') {
+            *p++ = 0;
+            c = 't';
+        } else {
+            *p++ = 0;
+            c = *p++;
+        }
+        if (strlen(osdtimetext[valign+halign*3])>0 &&
+            strlen(pt)>0 && !nonewline)
+            strncat(osdtimetext[valign+halign*3],"\n",256);
+        strncat(osdtimetext[valign+halign*3],pt,256);
+        nonewline = 0;
+        if (c=='_') {
+            strncat(osdtimetext[valign+halign*3]," ",256);
+            nonewline = 1;
+        }
+        switch (c) {
+        case 't' :
+            valign++;
+            if (valign>2)
+                valign=0;
+            break;
+        case 'n' :
+            halign = 1-halign;
+        case 'r' :
+            halign = 1-halign;
+            valign = osdtimealign;
+            if(valign>2)
+                valign-=3;
+            break;
+        }
+        pt = p;
+    }
+    if (strlen(osdtimetext[valign+halign*3])>0 &&
+        strlen(pt)>0 && !nonewline)
+        strncat(osdtimetext[valign+halign*3],"\n",256);
+    strncat(osdtimetext[valign+halign*3],pt,256);
+    return 1;
+}
+#endif
Index: configure
===================================================================
--- configure	(revision 31760)
+++ configure	(working copy)
@@ -294,6 +294,7 @@
   --enable-menu          enable OSD menu (not DVD menu) [disabled]
   --disable-sortsub      disable subtitle sorting [enabled]
   --enable-fribidi       enable the FriBiDi libs [autodetect]
+  --disable-osdtime      disable OSD time, date and info text support [autodetect]
   --disable-enca         disable ENCA charset oracle library [autodetect]
   --disable-maemo        disable maemo specific features [autodetect]
   --enable-macosx-finder enable Mac OS X Finder invocation parameter
@@ -787,6 +788,7 @@
 _ass=auto
 ass_internal=no
 _rpath=no
+_osdtime=auto
 _asmalign_pot=auto
 _stream_cache=yes
 _priority=no
@@ -1299,6 +1301,8 @@
   --disable-ass-internal) ass_internal=no  ;;
   --enable-rpath)       _rpath=yes      ;;
   --disable-rpath)      _rpath=no       ;;
+  --enable-osdtime)     _osdtime=yes    ;;
+  --disable-osdtime)    _osdtime=no     ;;
 
   --enable-fribidi)     _fribidi=yes    ;;
   --disable-fribidi)    _fribidi=no     ;;
@@ -4010,6 +4014,26 @@
 echores "$_glob"
 
 
+echocheck "osdtime"
+if test "$_osdtime" = auto ; then
+  cat > $TMPC << EOF
+#include <time.h>
+int main(void) {
+time_t ttime; struct tm *ptm; char txt[64];
+ttime=time(NULL); ptm=localtime(&ttime); strftime(txt,64,"%Y",ptm);
+return 0; }
+EOF
+  _osdtime=no
+  cc_check && _osdtime=yes
+fi
+if test "$_osdtime" = yes ; then
+  def_osdtime='#define CONFIG_OSDTIME 1'
+else
+  def_osdtime='#undef CONFIG_OSDTIME'
+fi
+echores "$_osdtime"
+
+
 echocheck "setenv()"
 cat > $TMPC << EOF
 #include <stdlib.h>
@@ -8886,7 +8910,7 @@
 #define HAVE_LIMITS_H 1
 /* libdvdcss + libfaad2 */
 #define HAVE_UNISTD_H 1
-/* libfaad2 + libdvdread */
+/1* libfaad2 + libdvdread */
 #define STDC_HEADERS 1
 #define HAVE_MEMCPY 1
 /* libfaad2 */
@@ -8926,6 +8950,7 @@
 $def_map_memalign
 $def_memalign
 $def_nanosleep
+$def_osdtime
 $def_posix_select
 $def_select
 $def_setenv
Index: DOCS/man/en/mplayer.1
===================================================================
--- DOCS/man/en/mplayer.1	(revision 31760)
+++ DOCS/man/en/mplayer.1	(working copy)
@@ -2383,6 +2383,105 @@
 .PD 1
 .
 .TP
+.B \-osdtime "[t|b[l|c|r]]\_<format string>"
+MPlayer has an onscreen display (OSD) for date, time and info text.
+.br
+.PD 1
+.RSs
+.IP "Alignment:"
+.RE
+.PD 0
+.RSs
+.IPs \_
+bottom-left (default)
+.IPs b\_
+bottom-left
+.IPs t\_
+top-left
+.IPs bl\_
+bottom-left
+.IPs bc\_
+bottom-center
+.IPs br\_
+bottom-right
+.IPs tl\_
+top-left
+.IPs tc\_
+top-center
+.IPs tr\_
+top-right
+.RE
+.PD 1
+.RSs
+.IP "Format\ string:"
+.RE
+.PD 0
+.RSs
+.IPs "\e\e"
+\'\\\'
+.IPs "\e""
+\'"'
+.IPs "\e_"
+\' \' (space)
+.IPs "\et"
+switch horizontal alignment: left -> center -> right -> left ...
+.IPs "\er"
+switch vertical alignment: top -> bottom -> top ... (restore vertical alignment)
+.IPs "\en"
+New line (restore vertical alignment)
+.IPs "%Y"
+Year (4 digit)
+.IPs "%m"
+Month (decimal number)
+.IPs "%d"
+Day (decimal number)
+.IPs "%H"
+Hour (24h)
+.IPs "%M"
+Minutes
+.IPs "%S"
+Second
+.IPs "other format: see man strftime"
+.RE
+.PD 1
+.Rss
+.IP
+.I EXAMPLE:
+.br
+"bl_%Y.%m.%d\\tCam\\\_1\\t%H:%M:%S"
+.br
+|2008.01.01\ ...\ Cam\ 1\ ...\ 12:21:30|
+.br
+
+.br
+"bc_Cam\\\_1\\t%Y.%m.%d\\n\\t%H:%M:%S"
+.br
+|\ ...\ \ \ \ \ \ \ ...\ 2008.01.01|
+.br
+|\ ...\ Cam\ 1\ ...\ \ \ 12:21:30|
+.br
+
+.br
+"tl_%Y.%m.%d\\r%H:%M:%S"
+.br
+|2008.01.01\ ...
+.br
+|...
+.br
+|12:21:30\ ...
+
+.RE
+.PD 1
+.
+.TP
+.B \-osdtime-hmargin "<0-100>"
+Set horizontal (left and right) margin in pixels (default: 10).
+.
+.TP
+.B \-osdtime-vmargin "<0-100>"
+Set vertical (top and bottom) margin in pixels (default: 10).
+.
+.TP
 .B \-overlapsub
 Allows the next subtitle to be displayed while the current one is
 still visible (default is to enable the support only for specific
Index: mplayer.c
===================================================================
--- mplayer.c	(revision 31760)
+++ mplayer.c	(working copy)
@@ -1645,6 +1645,13 @@
     }
 }
 
+#ifdef CONFIG_OSDTIME
+void update_osdtime() {
+    if(vo_osdtime())
+        vo_osd_changed(OSDTYPE_OSDTIME);
+}
+#endif
+
 ///@}
 // OSDMsgStack
 
@@ -1831,6 +1838,9 @@
 	    update_subtitles(sh_video, sh_video->pts, mpctx->d_sub, 0);
 	    update_teletext(sh_video, mpctx->demuxer, 0);
 	    update_osd_msg();
+#ifdef CONFIG_OSDTIME
+            update_osdtime();
+#endif
 	    current_module = "filter video";
 	    if (filter_video(sh_video, decoded_frame, sh_video->pts))
 		break;
@@ -2411,6 +2421,9 @@
 	update_subtitles(sh_video, sh_video->pts, mpctx->d_sub, 0);
 	update_teletext(sh_video, mpctx->demuxer, 0);
 	update_osd_msg();
+#ifdef CONFIG_OSDTIME
+        update_osdtime();
+#endif
 	current_module = "decode_video";
 #ifdef CONFIG_DVDNAV
 	decoded_frame = mp_dvdnav_restore_smpi(&in_size,&start,decoded_frame);
Index: cfg-common.h
===================================================================
--- cfg-common.h	(revision 31760)
+++ cfg-common.h	(working copy)
@@ -642,6 +642,15 @@
     {"fontconfig", "MPlayer was compiled without fontconfig support.\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
     {"nofontconfig", "MPlayer was compiled without fontconfig support.\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
 #endif /* CONFIG_FONTCONFIG */
+#ifdef CONFIG_OSDTIME
+    {"osdtime", &osdtime, CONF_TYPE_STRING, 0,0,0, NULL},
+    {"osdtime-vmargin", &osdtimevmargin, CONF_TYPE_INT, CONF_RANGE,0,100, NULL},
+    {"osdtime-hmargin", &osdtimehmargin, CONF_TYPE_INT, CONF_RANGE,0,100, NULL},
+#else
+    {"osdtime", "MPlayer was compiled without OSD time support.\n", CONF_TYPE_PRINT, CONF_NOCFG,0,0, NULL},
+    {"osdtime-vmargin", "MPlayer was compiled without OSD time support.\n", CONF_TYPE_PRINT, CONF_NOCFG,0,0, NULL},
+    {"osdtime-hmargin", "MPlayer was compiled without OSD time support.\n", CONF_TYPE_PRINT, CONF_NOCFG,0,0, NULL},
+#endif
     {NULL, NULL, 0, 0, 0, 0, NULL}
 };
 
Index: mencoder.c
===================================================================
--- mencoder.c	(revision 31760)
+++ mencoder.c	(working copy)
@@ -1668,6 +1668,11 @@
 #endif
     update_subtitles(sh_video, sh_video->pts, d_dvdsub, 0);
 
+#ifdef CONFIG_OSDTIME
+    if(vo_osdtime())
+        vo_osd_changed(OSDTYPE_OSDTIME);
+#endif
+
  frame_data = (s_frame_data){ .start = NULL, .in_size = 0, .frame_time = 0., .already_read = 0 };
 
 #if 0
