Mercurial > mplayer.hg
annotate find_sub.c @ 7773:e7dd97c4c840
rgb1/rgb4 support
author | arpi |
---|---|
date | Thu, 17 Oct 2002 00:27:27 +0000 |
parents | b1397d95471f |
children | 423a19edc0a4 |
rev | line source |
---|---|
584 | 1 //**************************************************************************// |
2 // .SUB | |
3 //**************************************************************************// | |
4 | |
1422 | 5 #include "config.h" |
6 | |
7 #ifdef USE_OSD | |
8 | |
584 | 9 #include <stdio.h> |
10 | |
11 #include "libvo/video_out.h" | |
2897 | 12 #include "libvo/sub.h" |
584 | 13 #include "subreader.h" |
14 | |
15 static int current_sub=0; | |
16 | |
17 //static subtitle* subtitles=NULL; | |
18 static int nosub_range_start=-1; | |
19 static int nosub_range_end=-1; | |
20 | |
21 void find_sub(subtitle* subtitles,int key){ | |
22 int i,j; | |
3543 | 23 |
24 if ( !subtitles ) return; | |
25 | |
584 | 26 if(vo_sub){ |
27 if(key>=vo_sub->start && key<=vo_sub->end) return; // OK! | |
28 } else { | |
29 if(key>nosub_range_start && key<nosub_range_end) return; // OK! | |
30 } | |
31 // sub changed! | |
1203 | 32 |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
3543
diff
changeset
|
33 /* Tell the OSD subsystem that the OSD contents will change soon */ |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
4807
diff
changeset
|
34 vo_osd_changed(OSDTYPE_SUBTITLE); |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
3543
diff
changeset
|
35 |
1203 | 36 if(key<=0){ |
37 vo_sub=NULL; // no sub here | |
38 return; | |
39 } | |
584 | 40 |
41 // printf("\r---- sub changed ----\n"); | |
42 | |
43 // check next sub. | |
44 if(current_sub>=0 && current_sub+1<sub_num){ | |
45 if(key>subtitles[current_sub].end && key<subtitles[current_sub+1].start){ | |
46 // no sub | |
47 nosub_range_start=subtitles[current_sub].end; | |
48 nosub_range_end=subtitles[current_sub+1].start; | |
49 vo_sub=NULL; | |
50 return; | |
51 } | |
52 // next sub? | |
53 ++current_sub; | |
54 vo_sub=&subtitles[current_sub]; | |
55 if(key>=vo_sub->start && key<=vo_sub->end) return; // OK! | |
56 } | |
57 | |
58 // printf("\r---- sub log search... ----\n"); | |
59 | |
60 // use logarithmic search: | |
61 i=0;j=sub_num-1; | |
62 // printf("Searching %d in %d..%d\n",key,subtitles[i].start,subtitles[j].end); | |
63 while(j>=i){ | |
64 current_sub=(i+j+1)/2; | |
65 vo_sub=&subtitles[current_sub]; | |
66 if(key<vo_sub->start) j=current_sub-1; | |
67 else if(key>vo_sub->end) i=current_sub+1; | |
68 else return; // found! | |
69 } | |
70 // if(key>=vo_sub->start && key<=vo_sub->end) return; // OK! | |
71 | |
72 // check where are we... | |
73 if(key<vo_sub->start){ | |
74 if(current_sub<=0){ | |
75 // before the first sub | |
76 nosub_range_start=key-1; // tricky | |
77 nosub_range_end=vo_sub->start; | |
78 // printf("FIRST... key=%d end=%d \n",key,vo_sub->start); | |
79 vo_sub=NULL; | |
80 return; | |
81 } | |
82 --current_sub; | |
83 if(key>subtitles[current_sub].end && key<subtitles[current_sub+1].start){ | |
84 // no sub | |
85 nosub_range_start=subtitles[current_sub].end; | |
86 nosub_range_end=subtitles[current_sub+1].start; | |
87 // printf("No sub... 1 \n"); | |
88 vo_sub=NULL; | |
89 return; | |
90 } | |
91 printf("HEH???? "); | |
92 } else { | |
93 if(key<=vo_sub->end) printf("JAJJ! "); else | |
94 if(current_sub+1>=sub_num){ | |
95 // at the end? | |
96 nosub_range_start=vo_sub->end; | |
97 nosub_range_end=0x7FFFFFFF; // MAXINT | |
98 // printf("END!?\n"); | |
99 vo_sub=NULL; | |
100 return; | |
101 } else | |
102 if(key>subtitles[current_sub].end && key<subtitles[current_sub+1].start){ | |
103 // no sub | |
104 nosub_range_start=subtitles[current_sub].end; | |
105 nosub_range_end=subtitles[current_sub+1].start; | |
106 // printf("No sub... 2 \n"); | |
107 vo_sub=NULL; | |
108 return; | |
109 } | |
110 } | |
111 | |
112 printf("SUB ERROR: %d ? %d --- %d [%d] \n",key,(int)vo_sub->start,(int)vo_sub->end,current_sub); | |
113 | |
114 vo_sub=NULL; // no sub here | |
115 } | |
116 | |
1422 | 117 #endif |