mirror of
https://github.com/mpv-player/mpv
synced 2025-01-31 04:02:06 +00:00
Bounding box and partial update patch for vob/dvdsub by Hephooey.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@6191 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
76c15cc6cd
commit
73a97eb400
22
libvo/sub.c
22
libvo/sub.c
@ -320,6 +320,22 @@ inline static void vo_update_text_sub(mp_osd_obj_t* obj,int dxs,int dys){
|
||||
|
||||
}
|
||||
|
||||
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 @@ int vo_update_osd(int dxs,int dys){
|
||||
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 @@ void vo_draw_text(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h,
|
||||
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);
|
||||
|
@ -2960,8 +2960,9 @@ if(vo_config_count && vo_spudec) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
34
spudec.c
34
spudec.c
@ -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 @@ typedef struct {
|
||||
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 @@ static void spudec_decode(spudec_handle_t *this, unsigned int pts100)
|
||||
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 @@ void spudec_draw(void *this, void (*draw_alpha)(int x0,int y0, int w,int h, unsi
|
||||
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 @@ void spudec_draw_scaled(void *me, unsigned int dxs, unsigned int dys, void (*dra
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user