1 /*
2 * 3GPP TS 26.245 Timed Text decoder
3 * Copyright (c) 2012 Philip Langdale <philipl@overt.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
28
29 static int text_to_ass(AVBPrint *
buf,
const char *text,
const char *text_end)
30 {
31 while (text < text_end) {
32 switch (*text) {
33 case '\r':
34 break;
35 case '\n':
37 break;
38 default:
40 break;
41 }
42 text++;
43 }
44
45 return 0;
46 }
47
49 /*
50 * TODO: Handle the default text style.
51 * NB: Most players ignore styles completely, with the result that
52 * it's very common to find files where the default style is broken
53 * and respecting it results in a worse experience than ignoring it.
54 */
56 }
57
60 {
62 int ret, ts_start, ts_end;
64 const char *ptr = avpkt->
data;
66
67 if (!ptr || avpkt->
size < 2)
69
70 /*
71 * A packet of size two with value zero is an empty subtitle
72 * used to mark the end of the previous non-empty subtitle.
73 * We can just drop them here as we have duration information
74 * already. If the value is non-zero, then it's technically a
75 * bad packet.
76 */
79
80 /*
81 * The first two bytes of the packet are the length of the text string
82 * In complex cases, there are style descriptors appended to the string
83 * so we can't just assume the packet size is the string size.
84 */
86 ptr += 2;
87
92 avctx->time_base,
94
95 // Note that the spec recommends lines be no longer than 2048 characters.
102 *got_sub_ptr = sub->num_rects > 0;
103 return avpkt->size;
104 }
105
113 };