--- libavcodec/samidec.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/libavcodec/samidec.c b/libavcodec/samidec.c index 95f35ab..8dd2749 100644 --- a/libavcodec/samidec.c +++ b/libavcodec/samidec.c @@ -46,6 +46,7 @@ static int sami_paragraph_to_ass(AVCodecContext *avctx, const char *src) char *p = dupsrc; AVBPrint *dst_content = &sami->encoded_content; AVBPrint *dst_source = &sami->encoded_source; + int got_content = 0; av_bprint_clear(&sami->encoded_content); av_bprint_clear(&sami->content); @@ -76,17 +77,18 @@ static int sami_paragraph_to_ass(AVCodecContext *avctx, const char *src) av_bprint_clear(dst); } - /* if empty event -> skip subtitle */ - while (av_isspace(*p)) + while (av_isspace(*p) || (!strncmp(p, " ", 6) && (p += 5))) p++; - if (!strncmp(p, " ", 6)) { - ret = -1; - goto end; - } /* extract the text, stripping most of the tags */ while (*p) { if (*p == '<') { + if (!av_strncasecmp(p, "</P>", 4)) { + p += 4; + while (av_isspace(*p)) + p++; + continue; + } if (!av_strncasecmp(p, "<P", 2) && (p[2] == '>' || av_isspace(p[2]))) break; } @@ -107,9 +109,15 @@ static int sami_paragraph_to_ass(AVCodecContext *avctx, const char *src) av_bprint_chars(dst, ' ', 1); prev_chr_is_space = av_isspace(*p); p++; + got_content = 1; } } + if (!got_content) { + ret = -1; + goto end; + } + av_bprint_clear(&sami->full); if (sami->source.len) { ff_htmlmarkup_to_ass(avctx, dst_source, sami->source.str); -- 2.6.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel