1 /*
2 * SubRip subtitle demuxer
3 * Copyright (c) 2010 Aurelien Jacobs <aurel@gnuage.org>
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
28 typedef struct {
31
33 {
34 const unsigned char *ptr = p->
buf;
36
38 ptr += 3; /* skip UTF-8 BOM */
39
40 for (i=0; i<2; i++) {
41 if ((num == i || num + 1 == i)
42 && sscanf(ptr, "%*d:%*2d:%*2d%*1[,.]%*3d --> %*d:%*2d:%*2d%*1[,.]%3d", &v) == 1)
44 num = atoi(ptr);
45 ptr += strcspn(ptr, "\n") + 1;
46 }
47 return 0;
48 }
49
52 {
53 int i;
54
55 for (i=0; i<2; i++) {
56 int hh1, mm1, ss1, ms1;
57 int hh2, mm2, ss2, ms2;
58 if (sscanf(*buf, "%d:%2d:%2d%*1[,.]%3d --> %d:%2d:%2d%*1[,.]%3d"
59 "%*[ ]X1:%u X2:%u Y1:%u Y2:%u",
60 &hh1, &mm1, &ss1, &ms1,
61 &hh2, &mm2, &ss2, &ms2,
62 x1, x2, y1, y2) >= 8) {
63 int64_t
start = (hh1*3600LL + mm1*60LL + ss1) * 1000LL + ms1;
64 int64_t
end = (hh2*3600LL + mm2*60LL + ss2) * 1000LL + ms2;
65 *duration = end -
start;
66 *buf += strcspn(*buf, "\n");
69 }
70 *buf += strcspn(*buf, "\n");
72 }
74 }
75
77 {
82
83 if (!st)
88
90
93
94 if (buf.len) {
96 int64_t pts;
98 const char *ptr = buf.str;
99 int32_t x1 = -1, y1 = -1, x2 = -1, y2 = -1;
101
102 pts =
get_pts(&ptr, &duration, &x1, &y1, &x2, &y2);
104 int len = buf.len - (ptr - buf.str);
105 if (len <= 0)
106 continue;
108 if (!sub) {
111 }
115 if (x1 != -1) {
117 if (p) {
122 }
123 }
124 }
125 }
126 }
127
129
133 }
134
136 {
139 }
140
142 int64_t min_ts, int64_t ts, int64_t max_ts,
int flags)
143 {
146 min_ts, ts, max_ts, flags);
147 }
148
150 {
153 return 0;
154 }
155
165 };