diff options
author | Yayoi <yayoi.ukai@gmail.com> | 2015-08-30 07:24:48 -0700 |
---|---|---|
committer | Clément Bœsch <u@pkh.me> | 2015-09-06 13:29:28 +0200 |
commit | 87f90be4f2a6c68f334cfc89493b0e410eb2afde (patch) | |
tree | a62ceaea6b4cc2f99fa9b1a265f976a6020e8628 /libavcodec/samidec.c | |
parent | 1bb8a53f080e8bec821f9cf86a5ee524a58a927a (diff) | |
download | ffmpeg-87f90be4f2a6c68f334cfc89493b0e410eb2afde.tar.gz |
avcodec/samidec: use ff_htmlmarkup_to_ass()
Signed-off-by: Clément Bœsch <u@pkh.me>
Diffstat (limited to 'libavcodec/samidec.c')
-rw-r--r-- | libavcodec/samidec.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/libavcodec/samidec.c b/libavcodec/samidec.c index 47850e2126..e87d9dd1ab 100644 --- a/libavcodec/samidec.c +++ b/libavcodec/samidec.c @@ -27,10 +27,13 @@ #include "ass.h" #include "libavutil/avstring.h" #include "libavutil/bprint.h" +#include "htmlsubtitles.h" typedef struct { AVBPrint source; AVBPrint content; + AVBPrint encoded_source; + AVBPrint encoded_content; AVBPrint full; } SAMIContext; @@ -41,8 +44,12 @@ static int sami_paragraph_to_ass(AVCodecContext *avctx, const char *src) char *tag = NULL; char *dupsrc = av_strdup(src); char *p = dupsrc; + AVBPrint *dst_content = &sami->encoded_content; + AVBPrint *dst_source = &sami->encoded_source; + av_bprint_clear(&sami->encoded_content); av_bprint_clear(&sami->content); + av_bprint_clear(&sami->encoded_source); for (;;) { char *saveptr = NULL; int prev_chr_is_space = 0; @@ -82,7 +89,8 @@ static int sami_paragraph_to_ass(AVCodecContext *avctx, const char *src) if (*p == '<') { if (!av_strncasecmp(p, "<P", 2) && (p[2] == '>' || av_isspace(p[2]))) break; - if (!av_strncasecmp(p, "<BR", 3)) + } + if (!av_strncasecmp(p, "<BR", 3)) { av_bprintf(dst, "\\N"); p++; while (*p && *p != '>') @@ -103,9 +111,12 @@ static int sami_paragraph_to_ass(AVCodecContext *avctx, const char *src) } av_bprint_clear(&sami->full); - if (sami->source.len) - av_bprintf(&sami->full, "{\\i1}%s{\\i0}\\N", sami->source.str); - av_bprintf(&sami->full, "%s", sami->content.str); + if (sami->source.len) { + ff_htmlmarkup_to_ass(avctx, dst_source, sami->source.str); + av_bprintf(&sami->full, "{\\i1}%s{\\i0}\\N", sami->encoded_source.str); + } + ff_htmlmarkup_to_ass(avctx, dst_content, sami->content.str); + av_bprintf(&sami->full, "%s", sami->encoded_content.str); end: av_free(dupsrc); @@ -136,6 +147,8 @@ static av_cold int sami_init(AVCodecContext *avctx) SAMIContext *sami = avctx->priv_data; av_bprint_init(&sami->source, 0, 2048); av_bprint_init(&sami->content, 0, 2048); + av_bprint_init(&sami->encoded_source, 0, 2048); + av_bprint_init(&sami->encoded_content, 0, 2048); av_bprint_init(&sami->full, 0, 2048); return ff_ass_subtitle_header_default(avctx); } @@ -145,6 +158,8 @@ static av_cold int sami_close(AVCodecContext *avctx) SAMIContext *sami = avctx->priv_data; av_bprint_finalize(&sami->source, NULL); av_bprint_finalize(&sami->content, NULL); + av_bprint_finalize(&sami->encoded_source, NULL); + av_bprint_finalize(&sami->encoded_content, NULL); av_bprint_finalize(&sami->full, NULL); return 0; } |