# HG changeset patch # User arpi_esp # Date 987466136 0 # Node ID 1a2c4f3e7a1047c583255d1a937c09a38a211d52 # Parent 6e8a887c99cdc4b6e52312f62243cff055d1248d sub control optimized diff -r 6e8a887c99cd -r 1a2c4f3e7a10 mplayer.c --- a/mplayer.c Mon Apr 16 22:27:32 2001 +0000 +++ b/mplayer.c Tue Apr 17 00:08:56 2001 +0000 @@ -94,26 +94,91 @@ static current_sub=0; static subtitle* subtitles=NULL; +static int nosub_range_start=-1; +static int nosub_range_end=-1; -void find_sub(unsigned long key){ +void find_sub(int key){ int i,j; - if(current_sub<0 || current_sub>=sub_num) current_sub=0; - vo_sub=&subtitles[current_sub]; - if(key>=vo_sub->start && key<=vo_sub->end) return; // OK! + if(vo_sub){ + if(key>=vo_sub->start && key<=vo_sub->end) return; // OK! + } else { + if(key>nosub_range_start && key=0 && current_sub+1subtitles[current_sub].end && key=vo_sub->start && key<=vo_sub->end) return; // OK! + } + +// printf("\r---- sub log search... ----\n"); + // use logarithmic search: i=0;j=sub_num-1; // printf("Searching %d in %d..%d\n",key,subtitles[i].start,subtitles[j].end); while(j>=i){ current_sub=(i+j+1)/2; - if(keysubtitles[current_sub].end) - i=current_sub+1; - else break; // found! + vo_sub=&subtitles[current_sub]; + if(keystart) j=current_sub-1; + else if(key>vo_sub->end) i=current_sub+1; + else return; // found! } - vo_sub=&subtitles[current_sub]; - if(key>=vo_sub->start && key<=vo_sub->end) return; // OK! +// if(key>=vo_sub->start && key<=vo_sub->end) return; // OK! + + // check where are we... + if(keystart){ + if(current_sub<=0){ + // before the first sub + nosub_range_start=key-1; // tricky + nosub_range_end=vo_sub->start; +// printf("FIRST... key=%d end=%d \n",key,vo_sub->start); + vo_sub=NULL; + return; + } + --current_sub; + if(key>subtitles[current_sub].end && keyend) printf("JAJJ! "); else + if(current_sub+1>=sub_num){ + // at the end? + nosub_range_start=vo_sub->end; + nosub_range_end=0x7FFFFFFF; // MAXINT +// printf("END!?\n"); + vo_sub=NULL; + return; + } else + if(key>subtitles[current_sub].end && keystart,vo_sub->end,current_sub); + vo_sub=NULL; // no sub here } @@ -1919,7 +1984,9 @@ // find sub if(subtitles){ if(sub_fps==0) sub_fps=sh_video->fps; + current_module="find_sub"; find_sub(sub_uses_time?(100*(v_pts+sub_delay)):((v_pts+sub_delay)*sub_fps)); // FIXME! frame counter... + current_module=NULL; } }