diff options
author | voroshil <voroshil@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2007-06-10 00:06:12 +0000 |
---|---|---|
committer | voroshil <voroshil@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2007-06-10 00:06:12 +0000 |
commit | 83a2c50ef9ef648b576bf4299765c73212d1f480 (patch) | |
tree | ab09f836c3ca91641c96b0630b2b2f479a3a6c2f /libvo | |
parent | 990b33b1c28d6b604a85e588689ad7fb6de59354 (diff) | |
download | mpv-83a2c50ef9ef648b576bf4299765c73212d1f480.tar.bz2 mpv-83a2c50ef9ef648b576bf4299765c73212d1f480.tar.xz |
Teletext support for tv:// (v4l and v4l2 only)
modified patch from Otvos Attila oattila at chello dot hu
Module uses zvbi library for all low-level VBI operations (like I/O with vbi
device, converting vbi pages into usefull vbi_page stuctures, rendering them
into RGB32 images).
All teletext related stuff (except properties, slave commands and rendering
osd in text mode or RGB32 rendered teletext pages in spu mode) is implemented
in tvi_vbi.c
New properties:
teletext_page - switching between pages
teletext_mode - switch between on/off/opaque/transparent modes
teletext_format - (currently read-only) allows to get format info
(black/white,gray,text)
teletext_half_page - trivial zooming (displaying top/bottom half of teletext
page)
New slave commands:
teletext_add_dec - user interface for jumping to any page by editing page number
interactively
teletext_go_link - goes though links, specified on current page
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@23530 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libvo')
-rw-r--r-- | libvo/sub.c | 130 | ||||
-rw-r--r-- | libvo/sub.h | 10 |
2 files changed, 140 insertions, 0 deletions
diff --git a/libvo/sub.c b/libvo/sub.c index 7a7069d12d..c901e28fe5 100644 --- a/libvo/sub.c +++ b/libvo/sub.c @@ -67,6 +67,10 @@ font_desc_t* vo_font=NULL; font_desc_t* sub_font=NULL; unsigned char* vo_osd_text=NULL; +#ifdef HAVE_TV_TELETEXT +unsigned char* vo_osd_teletex_text=NULL; +int vo_osd_teletext_flip = 0; +#endif int sub_unicode=0; int sub_utf8=0; int sub_pos=100; @@ -229,6 +233,121 @@ inline static void vo_update_nav (mp_osd_obj_t *obj, int dxs, int dys) { } #endif +#ifdef HAVE_TV_TELETEXT +inline static void vo_update_text_teletext(mp_osd_obj_t *obj, int dxs, int dys) +{ + char *p,*pe; + char line[256]; + int h=0,w=0,i,c,w1,font,lines,endline; + int x1,y1,x2,y2; + unsigned char *t; + + obj->flags|=OSDFLAG_CHANGED|OSDFLAG_VISIBLE; + + if (vo_osd_teletex_text==NULL) { + obj->flags&=~OSDFLAG_VISIBLE; + return; + } + p=vo_osd_teletex_text; + lines=0; + endline=0; + do { // calculate teletext size + memset(line,0,sizeof(line)); + if(pe=strchr(p,'\n')) { + if(pe-p>sizeof(line)) + strncpy(line,p,sizeof(line)); + else + strncpy(line,p,pe-p); + } + else + strncpy(line,p,sizeof(line)); + + t=line; + w1=0; + while (*t) { + c = utf8_get_char(&t); + if (!c) c++; // avoid UCS 0 + render_one_glyph(vo_font, c); + w1+=vo_font->width[c]+vo_font->charspace; + } + h+=vo_font->height; + if(w1>w) w=w1; + if(pe) pe++; + p=pe; + lines++; + if(h+vo_font->height*2>dys && endline==0) endline=lines; + } while (pe!=NULL); + h=h+vo_font->height; + w=w-vo_font->charspace; + if (w>dxs){ + // calculate bbox size + x1=0; + x2=dxs; + } + else + { + x1=(dxs-w)/2; + x2=x1+w+1; + } + if (h>dys){ + y1=0; + y2=dys; + } + else { + y1=0; + y2=y1+h+1; + } + obj->bbox.x1 = obj->x = x1; + obj->bbox.y1 = obj->y = y1; + obj->bbox.x2 = x2; + obj->bbox.y2 = y2; + obj->flags |= OSDFLAG_BBOX; + alloc_buf(obj); + p=vo_osd_teletex_text; + h=y1; + if (vo_osd_teletext_flip) + endline=lines-endline; // bottom page + else + endline=0; // top page + lines=0; + do { // show teletext page + memset(line,0,sizeof(line)); + if(pe=strchr(p,'\n')) { + if(pe-p>sizeof(line)) + strncpy(line,p,sizeof(line)); + else + strncpy(line,p,pe-p);} + else + strncpy(line,p,sizeof(line)); + + t=line; + + w1=x1; + if(lines==0 || endline==0 || lines>endline) { + while (*t) { + c = utf8_get_char(&t); + if (!c) c++; // avoid UCS 0 + render_one_glyph(vo_font, c); + if(w1+vo_font->width[c]>=x2) break; + if ((font=vo_font->font[c])>=0) + draw_alpha_buf(obj,w1,h, + 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); + w1+=vo_font->width[c]+vo_font->charspace; + } + h+=vo_font->height; + } + if(pe) pe++; + p=pe; + if(h+vo_font->height*2>dys) pe=NULL; + lines++; + } while (pe!=NULL); +} +#endif + int vo_osd_progbar_type=-1; int vo_osd_progbar_value=100; // 0..256 @@ -859,6 +978,11 @@ int vo_update_osd(int dxs,int dys){ case OSDTYPE_SUBTITLE: vo_update_text_sub(obj,dxs,dys); break; +#ifdef HAVE_TV_TELETEXT + case OSDTYPE_TELETEXT: + vo_update_text_teletext(obj,dxs,dys); + break; +#endif case OSDTYPE_PROGBAR: vo_update_text_progbar(obj,dxs,dys); break; @@ -926,6 +1050,9 @@ void vo_init_osd(void){ #ifdef USE_DVDNAV new_osd_obj(OSDTYPE_DVDNAV); #endif +#if HAVE_TV_TELETEXT + new_osd_obj(OSDTYPE_TELETEXT); +#endif #ifdef HAVE_FREETYPE force_load_font = 1; #endif @@ -964,6 +1091,9 @@ void vo_draw_text(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, #ifdef USE_DVDNAV case OSDTYPE_DVDNAV: #endif +#ifdef HAVE_TV_TELETEXT + case OSDTYPE_TELETEXT: +#endif case OSDTYPE_OSD: case OSDTYPE_SUBTITLE: case OSDTYPE_PROGBAR: diff --git a/libvo/sub.h b/libvo/sub.h index 45d39bbd6b..efc0277ba4 100644 --- a/libvo/sub.h +++ b/libvo/sub.h @@ -2,6 +2,10 @@ #ifndef __MPLAYER_SUB_H #define __MPLAYER_SUB_H +#ifdef HAVE_TV_TELETEXT +#include "libmpcodecs/mp_image.h" +#endif + typedef struct mp_osd_bbox_s { int x1,y1,x2,y2; } mp_osd_bbox_t; @@ -11,6 +15,7 @@ typedef struct mp_osd_bbox_s { #define OSDTYPE_PROGBAR 3 #define OSDTYPE_SPU 4 #define OSDTYPE_DVDNAV 5 +#define OSDTYPE_TELETEXT 6 #define OSDFLAG_VISIBLE 1 #define OSDFLAG_CHANGED 2 @@ -64,6 +69,11 @@ extern subtitle* vo_sub; extern unsigned char* vo_osd_text; +#ifdef HAVE_TV_TELETEXT +extern unsigned char* vo_osd_teletex_text; +extern int vo_osd_teletext_flip; +#endif + extern int vo_osd_progbar_type; extern int vo_osd_progbar_value; // 0..255 |