... | ... |
@@ -499,6 +499,7 @@ OBJS-$(CONFIG_SVQ1_ENCODER) += svq1enc.o svq1.o \ |
499 | 499 |
h263.o ituh263enc.o |
500 | 500 |
OBJS-$(CONFIG_SVQ3_DECODER) += svq3.o svq13.o mpegutils.o |
501 | 501 |
OBJS-$(CONFIG_TEXT_DECODER) += textdec.o ass.o |
502 |
+OBJS-$(CONFIG_TEXT_ENCODER) += srtenc.o ass_split.o |
|
502 | 503 |
OBJS-$(CONFIG_TAK_DECODER) += takdec.o tak.o takdsp.o |
503 | 504 |
OBJS-$(CONFIG_TARGA_DECODER) += targa.o |
504 | 505 |
OBJS-$(CONFIG_TARGA_ENCODER) += targaenc.o rle.o |
... | ... |
@@ -550,7 +550,7 @@ void avcodec_register_all(void) |
550 | 550 |
REGISTER_ENCDEC (SUBRIP, subrip); |
551 | 551 |
REGISTER_DECODER(SUBVIEWER, subviewer); |
552 | 552 |
REGISTER_DECODER(SUBVIEWER1, subviewer1); |
553 |
- REGISTER_DECODER(TEXT, text); |
|
553 |
+ REGISTER_ENCDEC (TEXT, text); |
|
554 | 554 |
REGISTER_DECODER(VPLAYER, vplayer); |
555 | 555 |
REGISTER_ENCDEC (WEBVTT, webvtt); |
556 | 556 |
REGISTER_ENCDEC (XSUB, xsub); |
... | ... |
@@ -221,8 +221,14 @@ static const ASSCodesCallbacks srt_callbacks = { |
221 | 221 |
.end = srt_end_cb, |
222 | 222 |
}; |
223 | 223 |
|
224 |
-static int srt_encode_frame(AVCodecContext *avctx, |
|
225 |
- unsigned char *buf, int bufsize, const AVSubtitle *sub) |
|
224 |
+static const ASSCodesCallbacks text_callbacks = { |
|
225 |
+ .text = srt_text_cb, |
|
226 |
+ .new_line = srt_new_line_cb, |
|
227 |
+}; |
|
228 |
+ |
|
229 |
+static int encode_frame(AVCodecContext *avctx, |
|
230 |
+ unsigned char *buf, int bufsize, const AVSubtitle *sub, |
|
231 |
+ const ASSCodesCallbacks *cb) |
|
226 | 232 |
{ |
227 | 233 |
SRTContext *s = avctx->priv_data; |
228 | 234 |
ASSDialog *dialog; |
... | ... |
@@ -241,7 +247,7 @@ static int srt_encode_frame(AVCodecContext *avctx, |
241 | 241 |
for (; dialog && num--; dialog++) { |
242 | 242 |
s->alignment_applied = 0; |
243 | 243 |
srt_style_apply(s, dialog->style); |
244 |
- ff_ass_split_override_codes(&srt_callbacks, s, dialog->text); |
|
244 |
+ ff_ass_split_override_codes(cb, s, dialog->text); |
|
245 | 245 |
} |
246 | 246 |
} |
247 | 247 |
|
... | ... |
@@ -259,6 +265,18 @@ static int srt_encode_frame(AVCodecContext *avctx, |
259 | 259 |
return s->buffer.len; |
260 | 260 |
} |
261 | 261 |
|
262 |
+static int srt_encode_frame(AVCodecContext *avctx, |
|
263 |
+ unsigned char *buf, int bufsize, const AVSubtitle *sub) |
|
264 |
+{ |
|
265 |
+ return encode_frame(avctx, buf, bufsize, sub, &srt_callbacks); |
|
266 |
+} |
|
267 |
+ |
|
268 |
+static int text_encode_frame(AVCodecContext *avctx, |
|
269 |
+ unsigned char *buf, int bufsize, const AVSubtitle *sub) |
|
270 |
+{ |
|
271 |
+ return encode_frame(avctx, buf, bufsize, sub, &text_callbacks); |
|
272 |
+} |
|
273 |
+ |
|
262 | 274 |
static int srt_encode_close(AVCodecContext *avctx) |
263 | 275 |
{ |
264 | 276 |
SRTContext *s = avctx->priv_data; |
... | ... |
@@ -293,3 +311,16 @@ AVCodec ff_subrip_encoder = { |
293 | 293 |
.close = srt_encode_close, |
294 | 294 |
}; |
295 | 295 |
#endif |
296 |
+ |
|
297 |
+#if CONFIG_TEXT_ENCODER |
|
298 |
+AVCodec ff_text_encoder = { |
|
299 |
+ .name = "text", |
|
300 |
+ .long_name = NULL_IF_CONFIG_SMALL("Raw text subtitle"), |
|
301 |
+ .type = AVMEDIA_TYPE_SUBTITLE, |
|
302 |
+ .id = AV_CODEC_ID_TEXT, |
|
303 |
+ .priv_data_size = sizeof(SRTContext), |
|
304 |
+ .init = srt_encode_init, |
|
305 |
+ .encode_sub = text_encode_frame, |
|
306 |
+ .close = srt_encode_close, |
|
307 |
+}; |
|
308 |
+#endif |
... | ... |
@@ -29,7 +29,7 @@ |
29 | 29 |
#include "libavutil/version.h" |
30 | 30 |
|
31 | 31 |
#define LIBAVCODEC_VERSION_MAJOR 57 |
32 |
-#define LIBAVCODEC_VERSION_MINOR 18 |
|
32 |
+#define LIBAVCODEC_VERSION_MINOR 19 |
|
33 | 33 |
#define LIBAVCODEC_VERSION_MICRO 100 |
34 | 34 |
|
35 | 35 |
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |
... | ... |
@@ -76,6 +76,9 @@ fate-sub-webvtt2: CMD = fmtstdout ass -i $(TARGET_SAMPLES)/sub/WebVTT_extended_t |
76 | 76 |
FATE_SUBTITLES-$(call ALLYES, SRT_DEMUXER SUBRIP_DECODER WEBVTT_ENCODER WEBVTT_MUXER) += fate-sub-webvttenc |
77 | 77 |
fate-sub-webvttenc: CMD = fmtstdout webvtt -i $(TARGET_SAMPLES)/sub/SubRip_capability_tester.srt |
78 | 78 |
|
79 |
+FATE_SUBTITLES-$(call ALLYES, SRT_DEMUXER SUBRIP_DECODER TEXT_ENCODER SRT_MUXER) += fate-sub-textenc |
|
80 |
+fate-sub-textenc: CMD = fmtstdout srt -i $(TARGET_SAMPLES)/sub/SubRip_capability_tester.srt -c:s text |
|
81 |
+ |
|
79 | 82 |
FATE_SUBTITLES_ASS-$(call ALLYES, MICRODVD_DEMUXER MICRODVD_DECODER ICONV) += fate-sub-charenc |
80 | 83 |
fate-sub-charenc: CMD = fmtstdout ass -sub_charenc cp1251 -i $(TARGET_SAMPLES)/sub/cp1251-subtitles.sub |
81 | 84 |
|
82 | 85 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,213 @@ |
0 |
+1 |
|
1 |
+00:00:00,000 --> 00:00:00,000 |
|
2 |
+Don't show this text it may be used to insert hidden data |
|
3 |
+ |
|
4 |
+2 |
|
5 |
+00:00:01,500 --> 00:00:04,500 |
|
6 |
+SubRip subtitles capability tester 1.3o by ale5000 |
|
7 |
+Use VLC 1.1 or higher as reference for most things and MPC Home Cinema for others |
|
8 |
+This text should be blue |
|
9 |
+This text should be red |
|
10 |
+This text should be black |
|
11 |
+If you see this with the normal font, the player don't (fully) support font face |
|
12 |
+ |
|
13 |
+3 |
|
14 |
+00:00:04,500 --> 00:00:04,500 |
|
15 |
+Hidden |
|
16 |
+ |
|
17 |
+4 |
|
18 |
+00:00:04,501 --> 00:00:07,501 |
|
19 |
+This text should be small |
|
20 |
+This text should be normal |
|
21 |
+This text should be big |
|
22 |
+ |
|
23 |
+5 |
|
24 |
+00:00:07,501 --> 00:00:11,501 |
|
25 |
+This should be an E with an accent: È |
|
26 |
+日本語 |
|
27 |
+This text should be bold, italics and underline |
|
28 |
+This text should be small and green |
|
29 |
+This text should be small and red |
|
30 |
+This text should be big and brown |
|
31 |
+ |
|
32 |
+6 |
|
33 |
+00:00:11,501 --> 00:00:14,501 |
|
34 |
+This line should be bold |
|
35 |
+This line should be italics |
|
36 |
+This line should be underline |
|
37 |
+This line should be strikethrough |
|
38 |
+Both lines |
|
39 |
+should be underline |
|
40 |
+ |
|
41 |
+7 |
|
42 |
+00:00:14,501 --> 00:00:17,501 |
|
43 |
+> |
|
44 |
+It would be a good thing to |
|
45 |
+hide invalid html tags that are closed and show the text in them |
|
46 |
+<invalid_tag_unclosed>but show un-closed invalid html tags |
|
47 |
+Show not opened tags</invalid_tag_not_opened> |
|
48 |
+< |
|
49 |
+ |
|
50 |
+8 |
|
51 |
+00:00:17,501 --> 00:00:20,501 |
|
52 |
+and also |
|
53 |
+hide invalid html tags with parameters that are closed and show the text in them |
|
54 |
+<invalid_tag_uc par=5>but show un-closed invalid html tags |
|
55 |
+This text should be showed underlined without problems also: 2<3,5>1,4<6 |
|
56 |
+This shouldn't be underlined |
|
57 |
+ |
|
58 |
+9 |
|
59 |
+00:00:20,501 --> 00:00:21,501 |
|
60 |
+This text should be in the normal position... |
|
61 |
+ |
|
62 |
+10 |
|
63 |
+00:00:21,501 --> 00:00:22,501 |
|
64 |
+This text should NOT be in the normal position |
|
65 |
+ |
|
66 |
+11 |
|
67 |
+00:00:22,501 --> 00:00:24,501 |
|
68 |
+Implementation is the same of the ASS tag |
|
69 |
+This text should be at the |
|
70 |
+top and horizontally centered |
|
71 |
+ |
|
72 |
+12 |
|
73 |
+00:00:22,501 --> 00:00:24,501 |
|
74 |
+This text should be at the |
|
75 |
+middle and horizontally centered |
|
76 |
+ |
|
77 |
+13 |
|
78 |
+00:00:22,501 --> 00:00:24,501 |
|
79 |
+This text should be at the |
|
80 |
+bottom and horizontally centered |
|
81 |
+ |
|
82 |
+14 |
|
83 |
+00:00:24,501 --> 00:00:26,501 |
|
84 |
+This text should be at the |
|
85 |
+top and horizontally at the left |
|
86 |
+ |
|
87 |
+15 |
|
88 |
+00:00:24,501 --> 00:00:26,501 |
|
89 |
+This text should be at the |
|
90 |
+middle and horizontally at the left |
|
91 |
+(The second position must be ignored) |
|
92 |
+ |
|
93 |
+16 |
|
94 |
+00:00:24,501 --> 00:00:26,501 |
|
95 |
+This text should be at the |
|
96 |
+bottom and horizontally at the left |
|
97 |
+ |
|
98 |
+17 |
|
99 |
+00:00:26,501 --> 00:00:28,501 |
|
100 |
+This text should be at the |
|
101 |
+top and horizontally at the right |
|
102 |
+ |
|
103 |
+18 |
|
104 |
+00:00:26,501 --> 00:00:28,501 |
|
105 |
+This text should be at the |
|
106 |
+middle and horizontally at the right |
|
107 |
+ |
|
108 |
+19 |
|
109 |
+00:00:26,501 --> 00:00:28,501 |
|
110 |
+This text should be at the |
|
111 |
+bottom and horizontally at the right |
|
112 |
+ |
|
113 |
+20 |
|
114 |
+00:00:28,501 --> 00:00:31,501 |
|
115 |
+This could be the most difficult thing to implement |
|
116 |
+ |
|
117 |
+21 |
|
118 |
+00:00:31,501 --> 00:00:50,501 |
|
119 |
+First text |
|
120 |
+ |
|
121 |
+22 |
|
122 |
+00:00:33,500 --> 00:00:35,500 |
|
123 |
+Second, it shouldn't overlap first |
|
124 |
+ |
|
125 |
+23 |
|
126 |
+00:00:35,501 --> 00:00:37,501 |
|
127 |
+Third, it should replace second |
|
128 |
+ |
|
129 |
+24 |
|
130 |
+00:00:36,501 --> 00:00:50,501 |
|
131 |
+Fourth, it shouldn't overlap first and third |
|
132 |
+ |
|
133 |
+25 |
|
134 |
+00:00:40,501 --> 00:00:45,501 |
|
135 |
+Fifth, it should replace third |
|
136 |
+ |
|
137 |
+26 |
|
138 |
+00:00:45,501 --> 00:00:50,501 |
|
139 |
+Sixth, it shouldn't be |
|
140 |
+showed overlapped |
|
141 |
+ |
|
142 |
+27 |
|
143 |
+00:00:50,501 --> 00:00:52,501 |
|
144 |
+TEXT 1 (bottom) |
|
145 |
+ |
|
146 |
+28 |
|
147 |
+00:00:50,501 --> 00:00:52,501 |
|
148 |
+text 2 |
|
149 |
+ |
|
150 |
+29 |
|
151 |
+00:00:52,501 --> 00:00:54,501 |
|
152 |
+Hide these tags: |
|
153 |
+also hide these tags: |
|
154 |
+but show this: {normal text} |
|
155 |
+ |
|
156 |
+30 |
|
157 |
+00:00:54,501 --> 00:01:00,501 |
|
158 |
+ |
|
159 |
+\ N is a forced line break |
|
160 |
+\ h is a hard space |
|
161 |
+Normal spaces at the start and at the end of the line are trimmed while hard spaces are not trimmed. |
|
162 |
+The\hline\hwill\hnever\hbreak\hautomatically\hright\hbefore\hor\hafter\ha\hhard\hspace.\h:-D |
|
163 |
+ |
|
164 |
+31 |
|
165 |
+00:00:54,501 --> 00:00:56,501 |
|
166 |
+ |
|
167 |
+\h\h\h\h\hA (05 hard spaces followed by a letter) |
|
168 |
+A (Normal spaces followed by a letter) |
|
169 |
+A (No hard spaces followed by a letter) |
|
170 |
+ |
|
171 |
+32 |
|
172 |
+00:00:56,501 --> 00:00:58,501 |
|
173 |
+\h\h\h\h\hA (05 hard spaces followed by a letter) |
|
174 |
+A (Normal spaces followed by a letter) |
|
175 |
+A (No hard spaces followed by a letter) |
|
176 |
+Show this: \TEST and this: \-) |
|
177 |
+ |
|
178 |
+33 |
|
179 |
+00:00:58,501 --> 00:01:00,501 |
|
180 |
+ |
|
181 |
+A letter followed by 05 hard spaces: A\h\h\h\h\h |
|
182 |
+A letter followed by normal spaces: A |
|
183 |
+A letter followed by no hard spaces: A |
|
184 |
+05 hard spaces between letters: A\h\h\h\h\hA |
|
185 |
+5 normal spaces between letters: A A |
|
186 |
+ |
|
187 |
+^--Forced line break |
|
188 |
+ |
|
189 |
+34 |
|
190 |
+00:01:00,501 --> 00:01:02,501 |
|
191 |
+Both line should be strikethrough, |
|
192 |
+yes. |
|
193 |
+Correctly closed tags |
|
194 |
+should be hidden. |
|
195 |
+ |
|
196 |
+35 |
|
197 |
+00:01:02,501 --> 00:01:04,501 |
|
198 |
+It shouldn't be strikethrough, |
|
199 |
+not opened tag showed as text.</s> |
|
200 |
+Not opened tag showed as text.</xxxxx> |
|
201 |
+ |
|
202 |
+36 |
|
203 |
+00:01:04,501 --> 00:01:06,501 |
|
204 |
+Three lines should be strikethrough, |
|
205 |
+yes. |
|
206 |
+<yyyy>Not closed tags showed as text |
|
207 |
+ |
|
208 |
+37 |
|
209 |
+00:01:06,501 --> 00:01:08,501 |
|
210 |
+Both line should be strikethrough but |
|
211 |
+the wrong closing tag should be showed</b> |
|
212 |
+ |