annotate find_sub.c @ 7623:eea9475cb37f

typo (found by alex)
author michael
date Sun, 06 Oct 2002 16:50:35 +0000
parents b1397d95471f
children 423a19edc0a4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
584
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
1 //**************************************************************************//
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
2 // .SUB
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
3 //**************************************************************************//
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
4
1422
d02e0dcaf077 libvo2 support
arpi
parents: 1203
diff changeset
5 #include "config.h"
d02e0dcaf077 libvo2 support
arpi
parents: 1203
diff changeset
6
d02e0dcaf077 libvo2 support
arpi
parents: 1203
diff changeset
7 #ifdef USE_OSD
d02e0dcaf077 libvo2 support
arpi
parents: 1203
diff changeset
8
584
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
9 #include <stdio.h>
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
10
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
11 #include "libvo/video_out.h"
2897
283eab7c4c8e Added proper #include's for libvo2
mswitch
parents: 1422
diff changeset
12 #include "libvo/sub.h"
584
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
13 #include "subreader.h"
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
14
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
15 static int current_sub=0;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
16
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
17 //static subtitle* subtitles=NULL;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
18 static int nosub_range_start=-1;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
19 static int nosub_range_end=-1;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
20
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
21 void find_sub(subtitle* subtitles,int key){
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
22 int i,j;
3543
5a11cbf8791f some small sub bug fix
pontscho
parents: 2897
diff changeset
23
5a11cbf8791f some small sub bug fix
pontscho
parents: 2897
diff changeset
24 if ( !subtitles ) return;
5a11cbf8791f some small sub bug fix
pontscho
parents: 2897
diff changeset
25
584
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
26 if(vo_sub){
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
27 if(key>=vo_sub->start && key<=vo_sub->end) return; // OK!
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
28 } else {
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
29 if(key>nosub_range_start && key<nosub_range_end) return; // OK!
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
30 }
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
31 // sub changed!
1203
5f0d9239c5b2 sub at key=0 fixed
arpi_esp
parents: 584
diff changeset
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
5f0d9239c5b2 sub at key=0 fixed
arpi_esp
parents: 584
diff changeset
36 if(key<=0){
5f0d9239c5b2 sub at key=0 fixed
arpi_esp
parents: 584
diff changeset
37 vo_sub=NULL; // no sub here
5f0d9239c5b2 sub at key=0 fixed
arpi_esp
parents: 584
diff changeset
38 return;
5f0d9239c5b2 sub at key=0 fixed
arpi_esp
parents: 584
diff changeset
39 }
584
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
40
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
41 // printf("\r---- sub changed ----\n");
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
42
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
43 // check next sub.
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
44 if(current_sub>=0 && current_sub+1<sub_num){
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
45 if(key>subtitles[current_sub].end && key<subtitles[current_sub+1].start){
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
46 // no sub
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
47 nosub_range_start=subtitles[current_sub].end;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
48 nosub_range_end=subtitles[current_sub+1].start;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
49 vo_sub=NULL;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
50 return;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
51 }
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
52 // next sub?
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
53 ++current_sub;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
54 vo_sub=&subtitles[current_sub];
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
55 if(key>=vo_sub->start && key<=vo_sub->end) return; // OK!
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
56 }
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
57
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
58 // printf("\r---- sub log search... ----\n");
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
59
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
60 // use logarithmic search:
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
61 i=0;j=sub_num-1;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
62 // printf("Searching %d in %d..%d\n",key,subtitles[i].start,subtitles[j].end);
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
63 while(j>=i){
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
64 current_sub=(i+j+1)/2;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
65 vo_sub=&subtitles[current_sub];
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
66 if(key<vo_sub->start) j=current_sub-1;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
67 else if(key>vo_sub->end) i=current_sub+1;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
68 else return; // found!
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
69 }
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
70 // if(key>=vo_sub->start && key<=vo_sub->end) return; // OK!
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
71
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
72 // check where are we...
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
73 if(key<vo_sub->start){
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
74 if(current_sub<=0){
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
75 // before the first sub
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
76 nosub_range_start=key-1; // tricky
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
77 nosub_range_end=vo_sub->start;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
78 // printf("FIRST... key=%d end=%d \n",key,vo_sub->start);
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
79 vo_sub=NULL;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
80 return;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
81 }
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
82 --current_sub;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
83 if(key>subtitles[current_sub].end && key<subtitles[current_sub+1].start){
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
84 // no sub
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
85 nosub_range_start=subtitles[current_sub].end;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
86 nosub_range_end=subtitles[current_sub+1].start;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
87 // printf("No sub... 1 \n");
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
88 vo_sub=NULL;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
89 return;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
90 }
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
91 printf("HEH???? ");
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
92 } else {
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
93 if(key<=vo_sub->end) printf("JAJJ! "); else
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
94 if(current_sub+1>=sub_num){
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
95 // at the end?
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
96 nosub_range_start=vo_sub->end;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
97 nosub_range_end=0x7FFFFFFF; // MAXINT
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
98 // printf("END!?\n");
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
99 vo_sub=NULL;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
100 return;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
101 } else
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
102 if(key>subtitles[current_sub].end && key<subtitles[current_sub+1].start){
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
103 // no sub
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
104 nosub_range_start=subtitles[current_sub].end;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
105 nosub_range_end=subtitles[current_sub+1].start;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
106 // printf("No sub... 2 \n");
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
107 vo_sub=NULL;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
108 return;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
109 }
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
110 }
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
111
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
112 printf("SUB ERROR: %d ? %d --- %d [%d] \n",key,(int)vo_sub->start,(int)vo_sub->end,current_sub);
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
113
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
114 vo_sub=NULL; // no sub here
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
115 }
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
116
1422
d02e0dcaf077 libvo2 support
arpi
parents: 1203
diff changeset
117 #endif