Index: libvo/sub.h
===================================================================
--- libvo/sub.h	(revision 28082)
+++ libvo/sub.h	(working copy)
@@ -12,6 +12,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
@@ -41,6 +42,9 @@
 	struct {
 	    int elems;
 	} progbar;
+	struct {
+	    int align;
+	} osdtime;
     } params;
     int stride;
 
@@ -112,7 +116,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
+
 //extern void vo_draw_text_osd(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride));
 //extern void vo_draw_text_progbar(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride));
 //extern void vo_draw_text_sub(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride));
@@ -124,6 +139,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 28082)
+++ libvo/sub.c	(working copy)
@@ -92,6 +92,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){
@@ -1011,6 +1020,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];
@@ -1050,6 +1182,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);
@@ -1057,6 +1191,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;
 }
 
@@ -1128,6 +1270,11 @@
 	    vo_update_text_teletext(obj,dxs,dys);
 	    break;
 #endif
+#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;
@@ -1182,6 +1329,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();
@@ -1198,6 +1348,12 @@
 #if CONFIG_TV_TELETEXT
     new_osd_obj(OSDTYPE_TELETEXT);
 #endif
+#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
@@ -1239,6 +1395,9 @@
 #ifdef CONFIG_TV_TELETEXT
 	case OSDTYPE_TELETEXT:
 #endif
+#ifdef CONFIG_OSDTIME
+        case OSDTYPE_OSDTIME:
+#endif
 	case OSDTYPE_OSD:
 	case OSDTYPE_SUBTITLE:
 	case OSDTYPE_PROGBAR:
@@ -1287,3 +1446,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 28082)
+++ configure	(working copy)
@@ -268,6 +268,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-macosx       disable Mac OS X specific features [autodetect]
   --disable-maemo        disable maemo specific features [autodetect]
@@ -714,6 +715,7 @@
 _w32threads=auto
 _ass=auto
 _rpath=no
+_osdtime=auto
 _asmalign_pot=auto
 _stream_cache=yes
 _def_stream_cache="#define CONFIG_STREAM_CACHE 1"
@@ -1200,6 +1202,8 @@
   --disable-ass)        _ass=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     ;;
@@ -3532,6 +3536,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>
@@ -8236,6 +8260,7 @@
 $_def_memalign
 $_def_memalign_hack
 $_def_nanosleep
+$_def_osdtime
 $_def_posix_select
 $_def_round
 $_def_roundf
Index: DOCS/man/en/mplayer.1
===================================================================
--- DOCS/man/en/mplayer.1	(revision 28082)
+++ DOCS/man/en/mplayer.1	(working copy)
@@ -2303,6 +2303,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 28082)
+++ mplayer.c	(working copy)
@@ -1571,6 +1571,13 @@
     }
 }
 
+#ifdef CONFIG_OSDTIME
+void update_osdtime() {
+    if(vo_osdtime())
+        vo_osd_changed(OSDTYPE_OSDTIME);
+}
+#endif
+
 ///@}
 // OSDMsgStack
 
@@ -1760,6 +1767,9 @@
 	    update_subtitles(sh_video, 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;
@@ -2280,6 +2290,9 @@
 	update_subtitles(sh_video, 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-opts.h
===================================================================
--- cfg-common-opts.h	(revision 28082)
+++ cfg-common-opts.h	(working copy)
@@ -342,5 +342,13 @@
 	{"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
 #endif /* MPLAYER_CFG_COMMON_OPTS_H */
Index: mencoder.c
===================================================================
--- mencoder.c	(revision 28082)
+++ mencoder.c	(working copy)
@@ -1510,6 +1510,11 @@
 #endif
     update_subtitles(sh_video, 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
