1 /*
2 * SSA/ASS demuxer
3 * Copyright (c) 2008 Michael Niedermayer
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
27
31
33 {
34 const char *header= "[Script Info]";
35
36 if( !memcmp(p->
buf , header, strlen(header))
37 || !memcmp(p->
buf+3, header, strlen(header)))
39
40 return 0;
41 }
42
44 {
47 return 0;
48 }
49
51 {
53 int hh1, mm1, ss1, ms1;
54 int hh2, mm2, ss2, ms2;
55
56 if (sscanf(p, "%*[^,],%d:%d:%d%*c%d,%d:%d:%d%*c%d",
57 &hh1, &mm1, &ss1, &ms1,
58 &hh2, &mm2, &ss2, &ms2) == 8) {
59 end = (hh2*3600LL + mm2*60LL + ss2) * 100LL + ms2;
60 *start = (hh1*3600LL + mm1*60LL + ss1) * 100LL + ms1;
61 *duration = end - *start;
62 return 0;
63 }
64 return -1;
65 }
66
68 {
70
72 for (;;) {
74 if (!c)
75 break;
77 if (c == '\n')
78 break;
79 }
80 return pos;
81 }
82
84 {
87 int header_remaining, res = 0;
89
91 if (!st)
96
97 header_remaining= INT_MAX;
98
101
102 for (;;) {
104
105 if (!line.str[0]) // EOF
106 break;
107
108 if (!memcmp(line.str, "[Events]", 8))
109 header_remaining= 2;
110 else if (line.str[0]=='[')
111 header_remaining= INT_MAX;
112
113 if (header_remaining) {
115 header_remaining--;
116 } else {
120
121 if (
read_ts(line.str, &ts_start, &duration) < 0)
122 continue;
124 if (!sub) {
127 }
131 }
132 }
133
135
137 if (res < 0)
139
141
143 return res;
144 }
145
147 {
150 }
151
153 int64_t min_ts, int64_t ts, int64_t max_ts,
int flags)
154 {
157 min_ts, ts, max_ts, flags);
158 }
159
169 };