Mercurial > mplayer.hg
annotate find_sub.c @ 6889:a645ecaaa93b
Document change_rectangle
author | kmkaplan |
---|---|
date | Sun, 04 Aug 2002 02:27:25 +0000 |
parents | 86663f1b9b00 |
children | b1397d95471f |
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 | |
2897 | 11 #ifdef USE_LIBVO2 |
12 #include "libvo2/libvo2.h" | |
13 #include "libvo2/sub.h" | |
14 #else | |
584 | 15 #include "libvo/video_out.h" |
2897 | 16 #include "libvo/sub.h" |
17 #endif | |
584 | 18 #include "subreader.h" |
19 | |
20 static int current_sub=0; | |
21 | |
22 //static subtitle* subtitles=NULL; | |
23 static int nosub_range_start=-1; | |
24 static int nosub_range_end=-1; | |
25 | |
26 void find_sub(subtitle* subtitles,int key){ | |
27 int i,j; | |
3543 | 28 |
29 if ( !subtitles ) return; | |
30 | |
584 | 31 if(vo_sub){ |
32 if(key>=vo_sub->start && key<=vo_sub->end) return; // OK! | |
33 } else { | |
34 if(key>nosub_range_start && key<nosub_range_end) return; // OK! | |
35 } | |
36 // sub changed! | |
1203 | 37 |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
3543
diff
changeset
|
38 /* 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
|
39 vo_osd_changed(OSDTYPE_SUBTITLE); |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
3543
diff
changeset
|
40 |
1203 | 41 if(key<=0){ |
42 vo_sub=NULL; // no sub here | |
43 return; | |
44 } | |
584 | 45 |
46 // printf("\r---- sub changed ----\n"); | |
47 | |
48 // check next sub. | |
49 if(current_sub>=0 && current_sub+1<sub_num){ | |
50 if(key>subtitles[current_sub].end && key<subtitles[current_sub+1].start){ | |
51 // no sub | |
52 nosub_range_start=subtitles[current_sub].end; | |
53 nosub_range_end=subtitles[current_sub+1].start; | |
54 vo_sub=NULL; | |
55 return; | |
56 } | |
57 // next sub? | |
58 ++current_sub; | |
59 vo_sub=&subtitles[current_sub]; | |
60 if(key>=vo_sub->start && key<=vo_sub->end) return; // OK! | |
61 } | |
62 | |
63 // printf("\r---- sub log search... ----\n"); | |
64 | |
65 // use logarithmic search: | |
66 i=0;j=sub_num-1; | |
67 // printf("Searching %d in %d..%d\n",key,subtitles[i].start,subtitles[j].end); | |
68 while(j>=i){ | |
69 current_sub=(i+j+1)/2; | |
70 vo_sub=&subtitles[current_sub]; | |
71 if(key<vo_sub->start) j=current_sub-1; | |
72 else if(key>vo_sub->end) i=current_sub+1; | |
73 else return; // found! | |
74 } | |
75 // if(key>=vo_sub->start && key<=vo_sub->end) return; // OK! | |
76 | |
77 // check where are we... | |
78 if(key<vo_sub->start){ | |
79 if(current_sub<=0){ | |
80 // before the first sub | |
81 nosub_range_start=key-1; // tricky | |
82 nosub_range_end=vo_sub->start; | |
83 // printf("FIRST... key=%d end=%d \n",key,vo_sub->start); | |
84 vo_sub=NULL; | |
85 return; | |
86 } | |
87 --current_sub; | |
88 if(key>subtitles[current_sub].end && key<subtitles[current_sub+1].start){ | |
89 // no sub | |
90 nosub_range_start=subtitles[current_sub].end; | |
91 nosub_range_end=subtitles[current_sub+1].start; | |
92 // printf("No sub... 1 \n"); | |
93 vo_sub=NULL; | |
94 return; | |
95 } | |
96 printf("HEH???? "); | |
97 } else { | |
98 if(key<=vo_sub->end) printf("JAJJ! "); else | |
99 if(current_sub+1>=sub_num){ | |
100 // at the end? | |
101 nosub_range_start=vo_sub->end; | |
102 nosub_range_end=0x7FFFFFFF; // MAXINT | |
103 // printf("END!?\n"); | |
104 vo_sub=NULL; | |
105 return; | |
106 } else | |
107 if(key>subtitles[current_sub].end && key<subtitles[current_sub+1].start){ | |
108 // no sub | |
109 nosub_range_start=subtitles[current_sub].end; | |
110 nosub_range_end=subtitles[current_sub+1].start; | |
111 // printf("No sub... 2 \n"); | |
112 vo_sub=NULL; | |
113 return; | |
114 } | |
115 } | |
116 | |
117 printf("SUB ERROR: %d ? %d --- %d [%d] \n",key,(int)vo_sub->start,(int)vo_sub->end,current_sub); | |
118 | |
119 vo_sub=NULL; // no sub here | |
120 } | |
121 | |
1422 | 122 #endif |