diff --git a/libavcodec/webvttenc.c b/libavcodec/webvttenc.c
index 4369aacb74..39d4f7c28a 100644
|
a
|
b
|
|
| 21 | 21 | */ |
| 22 | 22 | |
| 23 | 23 | #include <stdarg.h> |
| | 24 | #include <strings.h> |
| 24 | 25 | #include "avcodec.h" |
| 25 | 26 | #include "libavutil/avstring.h" |
| 26 | 27 | #include "libavutil/bprint.h" |
| … |
… |
|
| 28 | 29 | #include "ass.h" |
| 29 | 30 | #include "codec_internal.h" |
| 30 | 31 | |
| | 32 | // Unescape what has been escaped in webvtt_event_to_ass |
| | 33 | static const char *webvtt_unescape_ass_chars = "{}"; |
| | 34 | |
| 31 | 35 | #define WEBVTT_STACK_SIZE 64 |
| 32 | 36 | typedef struct { |
| 33 | 37 | AVCodecContext *avctx; |
| … |
… |
static const ASSCodesCallbacks webvtt_callbacks = {
|
| 155 | 159 | .end = webvtt_end_cb, |
| 156 | 160 | }; |
| 157 | 161 | |
| | 162 | static int webvtt_unescape_ass(unsigned char *buf, int buflen) |
| | 163 | { |
| | 164 | unsigned char *pfrom = buf, *pto = buf; |
| | 165 | int count = buflen; |
| | 166 | |
| | 167 | while (count > 0 && *pfrom) { |
| | 168 | if (*pfrom == '\\' && *(pfrom+1) != '\0' && index(webvtt_unescape_ass_chars, *(pfrom+1)) != NULL) { |
| | 169 | ++pfrom; |
| | 170 | --buflen; |
| | 171 | } |
| | 172 | *pto = *pfrom; |
| | 173 | pto++; |
| | 174 | pfrom++; |
| | 175 | --count; |
| | 176 | } |
| | 177 | |
| | 178 | *pto='\0'; |
| | 179 | |
| | 180 | return buflen; |
| | 181 | } |
| | 182 | |
| 158 | 183 | static int webvtt_encode_frame(AVCodecContext *avctx, |
| 159 | 184 | unsigned char *buf, int bufsize, const AVSubtitle *sub) |
| 160 | 185 | { |
| 161 | 186 | WebVTTContext *s = avctx->priv_data; |
| 162 | 187 | ASSDialog *dialog; |
| 163 | | int i; |
| | 188 | int i, ret; |
| 164 | 189 | |
| 165 | 190 | av_bprint_clear(&s->buffer); |
| 166 | 191 | |
| … |
… |
static int webvtt_encode_frame(AVCodecContext *avctx,
|
| 190 | 215 | return AVERROR_BUFFER_TOO_SMALL; |
| 191 | 216 | } |
| 192 | 217 | memcpy(buf, s->buffer.str, s->buffer.len); |
| | 218 | ret = webvtt_unescape_ass(buf, s->buffer.len); |
| 193 | 219 | |
| 194 | | return s->buffer.len; |
| | 220 | return ret; |
| 195 | 221 | } |
| 196 | 222 | |
| 197 | 223 | static int webvtt_encode_close(AVCodecContext *avctx) |