1 /*
2 * SSA/ASS encoder
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
22 #include <string.h>
23
30
32 int id;
///< current event id, ReadOrder field
34
36 {
43 return 0;
44 }
45
47 unsigned char *
buf,
int bufsize,
49 {
51 int i,
len, total_len = 0;
52
54 char ass_line[2048];
55 const char *ass = sub->
rects[i]->
ass;
56
59 return -1;
60 }
61
62 if (strncmp(ass, "Dialogue: ", 10)) {
64 " does not look like a SSA markup\n", ass);
66 }
67
69 long int layer;
70 char *p;
71
72 if (i > 0) {
74 "ASS rectangle field.\n");
76 }
77
78 ass += 10; // skip "Dialogue: "
79 /* parse Layer field. If it's a Marked field, the content
80 * will be "Marked=N" instead of the layer num, so we will
81 * have layer=0, which is fine. */
82 layer = strtol(ass, &p, 10);
83
84 #define SKIP_ENTRY(ptr) do { \
85 char *sep = strchr(ptr, ','); \
86 if (sep) \
87 ptr = sep + 1; \
88 } while (0)
89
93 snprintf(ass_line,
sizeof(ass_line),
"%d,%ld,%s", ++s->
id, layer, p);
94 ass_line[strcspn(ass_line, "\r\n")] = 0;
95 ass = ass_line;
96 }
97 len =
av_strlcpy(buf+total_len, ass, bufsize-total_len);
98
99 if (len > bufsize-total_len-1) {
101 return -1;
102 }
103
105 }
106
107 return total_len;
108 }
109
110 #if CONFIG_SSA_ENCODER
119 };
120 #endif
121
122 #if CONFIG_ASS_ENCODER
131 };
132 #endif