annotate find_sub.c @ 5250:e26352c3fa9b

support multiple video header extension chunks
author arpi
date Thu, 21 Mar 2002 20:18:30 +0000
parents 156482788caf
children 86663f1b9b00
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
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 */
156482788caf osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents: 3543
diff changeset
39 vo_osd_changed(1);
156482788caf osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents: 3543
diff changeset
40
1203
5f0d9239c5b2 sub at key=0 fixed
arpi_esp
parents: 584
diff changeset
41 if(key<=0){
5f0d9239c5b2 sub at key=0 fixed
arpi_esp
parents: 584
diff changeset
42 vo_sub=NULL; // no sub here
5f0d9239c5b2 sub at key=0 fixed
arpi_esp
parents: 584
diff changeset
43 return;
5f0d9239c5b2 sub at key=0 fixed
arpi_esp
parents: 584
diff changeset
44 }
584
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
45
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
46 // printf("\r---- sub changed ----\n");
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
47
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
48 // check next sub.
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
49 if(current_sub>=0 && current_sub+1<sub_num){
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
50 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
51 // no sub
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
52 nosub_range_start=subtitles[current_sub].end;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
53 nosub_range_end=subtitles[current_sub+1].start;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
54 vo_sub=NULL;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
55 return;
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 // next sub?
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
58 ++current_sub;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
59 vo_sub=&subtitles[current_sub];
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
60 if(key>=vo_sub->start && key<=vo_sub->end) return; // OK!
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
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
63 // printf("\r---- sub log search... ----\n");
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
64
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
65 // use logarithmic search:
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
66 i=0;j=sub_num-1;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
67 // 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
68 while(j>=i){
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
69 current_sub=(i+j+1)/2;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
70 vo_sub=&subtitles[current_sub];
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
71 if(key<vo_sub->start) j=current_sub-1;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
72 else if(key>vo_sub->end) i=current_sub+1;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
73 else return; // found!
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
74 }
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
75 // if(key>=vo_sub->start && key<=vo_sub->end) return; // OK!
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
76
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
77 // check where are we...
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
78 if(key<vo_sub->start){
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
79 if(current_sub<=0){
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
80 // before the first sub
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
81 nosub_range_start=key-1; // tricky
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
82 nosub_range_end=vo_sub->start;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
83 // printf("FIRST... key=%d end=%d \n",key,vo_sub->start);
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
84 vo_sub=NULL;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
85 return;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
86 }
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
87 --current_sub;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
88 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
89 // no sub
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
90 nosub_range_start=subtitles[current_sub].end;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
91 nosub_range_end=subtitles[current_sub+1].start;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
92 // printf("No sub... 1 \n");
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
93 vo_sub=NULL;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
94 return;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
95 }
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
96 printf("HEH???? ");
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
97 } else {
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
98 if(key<=vo_sub->end) printf("JAJJ! "); else
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
99 if(current_sub+1>=sub_num){
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
100 // at the end?
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
101 nosub_range_start=vo_sub->end;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
102 nosub_range_end=0x7FFFFFFF; // MAXINT
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
103 // printf("END!?\n");
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
104 vo_sub=NULL;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
105 return;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
106 } else
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
107 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
108 // no sub
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
109 nosub_range_start=subtitles[current_sub].end;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
110 nosub_range_end=subtitles[current_sub+1].start;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
111 // printf("No sub... 2 \n");
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
112 vo_sub=NULL;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
113 return;
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
114 }
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
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
117 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
118
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
119 vo_sub=NULL; // no sub here
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
120 }
9bdb59e8887d find_sub() moved out from mplayer.c
arpi_esp
parents:
diff changeset
121
1422
d02e0dcaf077 libvo2 support
arpi
parents: 1203
diff changeset
122 #endif