1 /*
2 * Copyright (c) 2014 Eejya Singh
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 /**
22 * @file
23 * STL subtitles format demuxer
24 * @see https://documentation.apple.com/en/dvdstudiopro/usermanual/index.html#chapter=19%26section=13%26tasks=true
25 */
26
32
36
38 {
40 const unsigned char *ptr = p->
buf;
41
43 ptr += 3; /* skip UTF-8 BOM */
44
45 while (*ptr == '\r' || *ptr == '\n' || *ptr == '$' || !strncmp(ptr, "//" , 2))
47
48 if (sscanf(ptr,
"%*d:%*d:%*d:%*d , %*d:%*d:%*d:%*d , %c", &
c) == 1)
50
51 return 0;
52 }
53
55 {
56 int hh1, mm1, ss1, ms1;
57 int hh2, mm2, ss2, ms2;
59
60 if (sscanf(*buf, "%2d:%2d:%2d:%2d , %2d:%2d:%2d:%2d , %n",
61 &hh1, &mm1, &ss1, &ms1,
62 &hh2, &mm2, &ss2, &ms2, &
len) >= 8 &&
len > 0) {
63 int64_t start = (hh1*3600LL + mm1*60LL + ss1) * 100LL + ms1;
64 int64_t end = (hh2*3600LL + mm2*60LL + ss2) * 100LL + ms2;
67 return start;
68 }
70 }
71
73 {
76
77 if (!st)
82
88 int64_t pts_start;
90
92 break;
93
96
103 sub->pts = pts_start;
105 }
106 }
108 return 0;
109 }
110
118 .extensions = "stl",
122 };