annotate find_sub.c @ 4217:2b141fcd69dd

Patch by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>: - detect the Alpha CPU type: default ("ev56") won't work with older Alphas, and gcc can take advantage of newer ones that way.
author pl
date Thu, 17 Jan 2002 09:32:22 +0000
parents 5a11cbf8791f
children 156482788caf
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
2897
283eab7c4c8e Added proper #include's for libvo2
mswitch
parents: 1422
diff changeset
11 #ifdef USE_LIBVO2
283eab7c4c8e Added proper #include's for libvo2
mswitch
parents: 1422
diff changeset
12 #include "libvo2/libvo2.h"
283eab7c4c8e Added proper #include's for libvo2
mswitch
parents: 1422
diff changeset
13 #include "libvo2/sub.h"
283eab7c4c8e Added proper #include's for libvo2
mswitch
parents: 1422
diff changeset
14 #else
584
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
15 #include "libvo/video_out.h"
2897
283eab7c4c8e Added proper #include's for libvo2
mswitch
parents: 1422
diff changeset
16 #include "libvo/sub.h"
283eab7c4c8e Added proper #include's for libvo2
mswitch
parents: 1422
diff changeset
17 #endif
584
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
18 #include "subreader.h"
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
19
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
20 static int current_sub=0;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
21
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
22 //static subtitle* subtitles=NULL;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
23 static int nosub_range_start=-1;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
24 static int nosub_range_end=-1;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
25
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
26 void find_sub(subtitle* subtitles,int key){
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
27 int i,j;
3543
5a11cbf8791f some small sub bug fix
pontscho
parents: 2897
diff changeset
28
5a11cbf8791f some small sub bug fix
pontscho
parents: 2897
diff changeset
29 if ( !subtitles ) return;
5a11cbf8791f some small sub bug fix
pontscho
parents: 2897
diff changeset
30
584
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
31 if(vo_sub){
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
32 if(key>=vo_sub->start && key<=vo_sub->end) return; // OK!
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
33 } else {
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
34 if(key>nosub_range_start && key<nosub_range_end) return; // OK!
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
35 }
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
36 // sub changed!
1203
5f0d9239c5b2 sub at key=0 fixed
arpi_esp
parents: 584
diff changeset
37
5f0d9239c5b2 sub at key=0 fixed
arpi_esp
parents: 584
diff changeset
38 if(key<=0){
5f0d9239c5b2 sub at key=0 fixed
arpi_esp
parents: 584
diff changeset
39 vo_sub=NULL; // no sub here
5f0d9239c5b2 sub at key=0 fixed
arpi_esp
parents: 584
diff changeset
40 return;
5f0d9239c5b2 sub at key=0 fixed
arpi_esp
parents: 584
diff changeset
41 }
584
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 // printf("\r---- sub changed ----\n");
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
44
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
45 // check next sub.
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
46 if(current_sub>=0 && current_sub+1<sub_num){
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
47 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
48 // no sub
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
49 nosub_range_start=subtitles[current_sub].end;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
50 nosub_range_end=subtitles[current_sub+1].start;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
51 vo_sub=NULL;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
52 return;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
53 }
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
54 // next sub?
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
55 ++current_sub;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
56 vo_sub=&subtitles[current_sub];
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
57 if(key>=vo_sub->start && key<=vo_sub->end) return; // OK!
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
58 }
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 // printf("\r---- sub log search... ----\n");
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
61
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
62 // use logarithmic search:
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
63 i=0;j=sub_num-1;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
64 // 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
65 while(j>=i){
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
66 current_sub=(i+j+1)/2;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
67 vo_sub=&subtitles[current_sub];
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
68 if(key<vo_sub->start) j=current_sub-1;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
69 else if(key>vo_sub->end) i=current_sub+1;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
70 else return; // found!
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 // if(key>=vo_sub->start && key<=vo_sub->end) return; // OK!
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
73
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
74 // check where are we...
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
75 if(key<vo_sub->start){
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
76 if(current_sub<=0){
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
77 // before the first sub
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
78 nosub_range_start=key-1; // tricky
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
79 nosub_range_end=vo_sub->start;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
80 // printf("FIRST... key=%d end=%d \n",key,vo_sub->start);
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
81 vo_sub=NULL;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
82 return;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
83 }
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
84 --current_sub;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
85 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
86 // no sub
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
87 nosub_range_start=subtitles[current_sub].end;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
88 nosub_range_end=subtitles[current_sub+1].start;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
89 // printf("No sub... 1 \n");
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
90 vo_sub=NULL;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
91 return;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
92 }
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
93 printf("HEH???? ");
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
94 } else {
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
95 if(key<=vo_sub->end) printf("JAJJ! "); else
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
96 if(current_sub+1>=sub_num){
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
97 // at the end?
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
98 nosub_range_start=vo_sub->end;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
99 nosub_range_end=0x7FFFFFFF; // MAXINT
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
100 // printf("END!?\n");
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
101 vo_sub=NULL;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
102 return;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
103 } else
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
104 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
105 // no sub
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
106 nosub_range_start=subtitles[current_sub].end;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
107 nosub_range_end=subtitles[current_sub+1].start;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
108 // printf("No sub... 2 \n");
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
109 vo_sub=NULL;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
110 return;
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 }
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 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
115
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
116 vo_sub=NULL; // no sub here
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
117 }
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
118
1422
d02e0dcaf077 libvo2 support
arpi
parents: 1203
diff changeset
119 #endif