# HG changeset patch # User pontscho # Date 1030024718 0 # Node ID b395b124095420a058fd9f30a2f35bd94f70b9ca # Parent e0255720a67ca98255b966f65a6ddbae57911c63 fix dxr3 subtitle handling and add some optimizations diff -r e0255720a67c -r b395b1240954 libvo/sub.c --- a/libvo/sub.c Thu Aug 22 08:05:27 2002 +0000 +++ b/libvo/sub.c Thu Aug 22 13:58:38 2002 +0000 @@ -367,7 +367,7 @@ extern void vo_draw_alpha_init(); -static mp_osd_obj_t* vo_osd_list=NULL; + mp_osd_obj_t* vo_osd_list=NULL; mp_osd_obj_t* new_osd_obj(int type){ mp_osd_obj_t* osd=malloc(sizeof(mp_osd_obj_t)); diff -r e0255720a67c -r b395b1240954 libvo/vo_dxr3.c --- a/libvo/vo_dxr3.c Thu Aug 22 08:05:27 2002 +0000 +++ b/libvo/vo_dxr3.c Thu Aug 22 13:58:38 2002 +0000 @@ -99,6 +99,7 @@ #include "aspect.h" #include "cpudetect.h" #include "spuenc.h" +#include "sub.h" #define SPU_SUPPORT @@ -132,6 +133,7 @@ static int osdpicbuf_h; static int disposd = 0; static encodedata *spued; +static encodedata *prebuf; #endif /* Static variable used in ioctl's */ @@ -318,13 +320,24 @@ ioctl(fd_control, EM8300_IOCTL_SET_ASPECTRATIO, &ioval); #ifdef SPU_SUPPORT - osdpicbuf = malloc(s_width * s_height); + s_width*=2; + s_height*=2; + + osdpicbuf = calloc( 1,s_width * s_height); if (osdpicbuf == NULL) { printf("vo_dxr3: out of mem\n"); return -1; } spued = (encodedata *) malloc(sizeof(encodedata)); if (spued == NULL) { + free( osdpicbuf ); + printf("vo_dxr3:out of mem\n"); + return -1; + } + prebuf = (encodedata *) malloc(sizeof(encodedata)); + if (prebuf == NULL) { + free( osdpicbuf ); + free( spued ); printf("vo_dxr3:out of mem\n"); return -1; } @@ -332,6 +345,10 @@ osd_h = s_height; osdpicbuf_w = s_width; osdpicbuf_h = s_height; + + prebuf->count=0; + pixbuf_encode_rle( 0,0,osdpicbuf_w,osdpicbuf_h - 1,osdpicbuf,osdpicbuf_w,prebuf ); + #endif return 0; @@ -345,38 +362,71 @@ static void draw_alpha(int x, int y, int w, int h, unsigned char* src, unsigned char *srca, int srcstride) { #ifdef SPU_SUPPORT - int lx, ly, bx; unsigned char *buf = &osdpicbuf[(y * osdpicbuf_w) + x]; - for (ly = 0; ly < h - 1; ly++) { - for(lx = 0; lx < w; lx++) { - if ((srca[(ly * srcstride) + lx] != 0) && (src[(ly * srcstride) + lx] != 0)) { - if(src[(ly * srcstride) + lx] >= 128) { - buf[ly * osdpicbuf_w + lx] = 3; - } - } - } + int by = 0; + register int lx, ly; + register int stride = 0; + + for (ly = 0; ly < h - 1; ly++) + { + for(lx = 0; lx < w; lx++ ) + if ( ( srca[stride + lx] )&&( src[stride + lx] >= 128 ) ) buf[by + lx] = 3; + by+=osdpicbuf_w; + stride+=srcstride; } pixbuf_encode_rle(x, y, osdpicbuf_w, osdpicbuf_h - 1, osdpicbuf, osdpicbuf_w, spued); #endif } +extern int vo_osd_changed_flag; +extern mp_osd_obj_t* vo_osd_list; + static void draw_osd(void) { #ifdef SPU_SUPPORT - if ((disposd % 15) == 0) { - vo_draw_text(osd_w, osd_h, draw_alpha); - memset(osdpicbuf, 0, s_width * s_height); + static int cleared = 0; + int changed = 0; + + if ((disposd % 15) == 0) + { + { + mp_osd_obj_t* obj = vo_osd_list; + vo_update_osd( osd_w,osd_h ); + while( obj ) + { + if ( obj->flags & OSDFLAG_VISIBLE ) { changed=1; break; } + obj=obj->next; + } + } + if ( changed ) + { + vo_draw_text(osd_w, osd_h, draw_alpha); + memset(osdpicbuf, 0, s_width * s_height); + cleared=0; + } + else + { + if ( !cleared ) + { + spued->count=prebuf->count; + memcpy( spued->data,prebuf->data,DATASIZE ); + cleared=1; + } + } + /* could stand some check here to see if the subpic hasn't changed * as if it hasn't and we re-send it it will "blink" as the last one * is turned off, and the new one (same one) is turned on */ /* Subpics are not stable yet =( - expect lockups if you enable + expect lockups if you enable */ +#if 1 if (!noprebuf) { ioctl(fd_spu, EM8300_IOCTL_SPU_SETPTS, &vo_pts); } - write(fd_spu, spued->data, spued->count);*/ + write(fd_spu, spued->data, spued->count); +#endif } disposd++; #endif