Mercurial > mplayer.hg
changeset 6190:bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
author | atmos4 |
---|---|
date | Sat, 25 May 2002 17:40:40 +0000 |
parents | 838380d56166 |
children | 26a980dbc9a5 |
files | libvo/sub.c mplayer.c spudec.c |
diffstat | 3 files changed, 55 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/libvo/sub.c Sat May 25 13:30:54 2002 +0000 +++ b/libvo/sub.c Sat May 25 17:40:40 2002 +0000 @@ -320,6 +320,22 @@ } +inline static void vo_update_spudec_sub(mp_osd_obj_t* obj, int dxs, int dys) +{ + unsigned int bbox[4]; + int i; + spudec_calc_bbox(vo_spudec, dxs, dys, bbox); + obj->bbox.x1 = bbox[0]; + obj->bbox.x2 = bbox[1]; + obj->bbox.y1 = bbox[2]; + obj->bbox.y2 = bbox[3]; + obj->flags |= OSDFLAG_BBOX; +} + +inline static void vo_draw_spudec_sub(mp_osd_obj_t* obj, void (*draw_alpha)(int x0, int y0, int w, int h, unsigned char* src, unsigned char* srca, int stride)) +{ + spudec_draw_scaled(vo_spudec, obj->dxs, obj->dys, draw_alpha); +} inline static void vo_draw_text_sub(mp_osd_obj_t* obj,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)){ int i,j,c,x,l,font; int y=obj->y; @@ -385,8 +401,10 @@ vo_update_text_progbar(obj,dxs,dys); break; case OSDTYPE_SPU: - if(vo_spudec && spudec_visible(vo_spudec)) + if(vo_spudec && spudec_visible(vo_spudec)){ + vo_update_spudec_sub(obj, dxs, dys); obj->flags|=OSDFLAG_VISIBLE|OSDFLAG_CHANGED; + } else obj->flags&=~OSDFLAG_VISIBLE; break; @@ -473,7 +491,7 @@ vo_osd_changed_flag=obj->flags&OSDFLAG_CHANGED; // temp hack switch(obj->type){ case OSDTYPE_SPU: - spudec_draw_scaled(vo_spudec, dxs, dys, draw_alpha); // FIXME + vo_draw_spudec_sub(obj, draw_alpha); // FIXME break; case OSDTYPE_OSD: vo_draw_text_osd(obj,draw_alpha);
--- a/mplayer.c Sat May 25 13:30:54 2002 +0000 +++ b/mplayer.c Sat May 25 17:40:40 2002 +0000 @@ -2960,8 +2960,9 @@ spudec_assemble(vo_spudec,packet,len,timestamp); } - /* Don't know how to detect wether the sub has changed or not */ - vo_osd_changed(OSDTYPE_SPU); + /* detect wether the sub has changed or not */ + if(spudec_changed(vo_spudec)) + vo_osd_changed(OSDTYPE_SPU); current_module=NULL; }
--- a/spudec.c Sat May 25 13:30:54 2002 +0000 +++ b/spudec.c Sat May 25 17:40:40 2002 +0000 @@ -3,7 +3,7 @@ 1: aproximate 2: full (slowest, best looking) */ -#define ANTIALIASING_ALGORITHM 1 +#define ANTIALIASING_ALGORITHM 2 /* SPUdec.c Skeleton of function spudec_process_controll() is from xine sources. @@ -69,6 +69,7 @@ vo_functions_t *hw_spu; } spudec_handle_t; +static int spu_changed = 0; static inline unsigned int get_be16(const unsigned char *p) { @@ -347,8 +348,14 @@ spudec_process_control(this, pts100); spudec_process_data(this); } + spu_changed = 1; } +int spudec_changed(void * this) +{ + spudec_handle_t * spu = (spudec_handle_t*)this; + return (spu_changed|(spu->now_pts > spu->end_pts)); +} void spudec_assemble(void *this, unsigned char *packet, unsigned int len, unsigned int pts100) { @@ -445,6 +452,27 @@ spu->image, spu->aimage, spu->stride); } +void spudec_calc_bbox(void *me, unsigned int dxs, unsigned int dys, unsigned int* bbox) +{ + spudec_handle_t *spu; + spu = (spudec_handle_t *)me; + if (spu->orig_frame_width == 0 || spu->orig_frame_height == 0 + || (spu->orig_frame_width == dxs && spu->orig_frame_height == dys)) { + bbox[0] = spu->start_col; + bbox[1] = spu->start_col + spu->width; + bbox[2] = spu->start_row; + bbox[3] = spu->start_row + spu->height; + } + else if (spu->scaled_frame_width != dxs || spu->scaled_frame_height != dys) { + unsigned int scalex = 0x100 * dxs / spu->orig_frame_width; + unsigned int scaley = 0x100 * dys / spu->orig_frame_height; + bbox[0] = spu->start_col * scalex / 0x100; + bbox[1] = spu->start_col * scalex / 0x100 + spu->width * scalex / 0x100; + bbox[2] = spu->start_row * scaley / 0x100; + bbox[3] = spu->start_row * scaley / 0x100 + spu->height * scaley / 0x100; + } +} + /* transform mplayer's alpha value into an opacity value that is linear */ static inline int canon_alpha(int alpha) { @@ -718,9 +746,11 @@ spu->scaled_frame_height = dys; } } - if (spu->scaled_image) + if (spu->scaled_image){ draw_alpha(spu->scaled_start_col, spu->scaled_start_row, spu->scaled_width, spu->scaled_height, spu->scaled_image, spu->scaled_aimage, spu->scaled_stride); + spu_changed = 0; + } } } else