From bd2868746dc67d16d39ee2c56c723ed09473512a Mon Sep 17 00:00:00 2001 From: AlexBratosin2001 Date: Fri, 30 Dec 2016 20:43:42 +0200 Subject: [PATCH] Fixed DVB to SAMI extraction (subtitle overlapping when subtitle had more than 1 line). --- src/lib_ccx/ccx_encoders_sami.c | 39 ++++++++++++++++----------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/src/lib_ccx/ccx_encoders_sami.c b/src/lib_ccx/ccx_encoders_sami.c index 8da4b807..51948261 100644 --- a/src/lib_ccx/ccx_encoders_sami.c +++ b/src/lib_ccx/ccx_encoders_sami.c @@ -123,46 +123,45 @@ int write_cc_bitmap_as_sami(struct cc_subtitle *sub, struct encoder_ctx *context struct cc_bitmap* rect; LLONG ms_start, ms_end; - ms_start = sub->start_time; + ms_start = sub->start_time; ms_end = sub->end_time; if(sub->nb_data == 0 ) return 0; + rect = sub->data; if ( sub->flags & SUB_EOD_MARKER ) context->prev_start = sub->start_time; + char *token = NULL; + char *buf = (char*)context->buffer; + sprintf(buf, + "

\r\n" + , (unsigned long long)ms_start); + write(context->out->fh, buf, strlen(buf)); for (int i = sub->nb_data - 1; i >= 0; i--) { if (rect[i].ocr_text && *(rect[i].ocr_text)) { if (context->prev_start != -1 || !(sub->flags & SUB_EOD_MARKER)) { - char *token = NULL; - char *buf = (char*)context->buffer; - sprintf(buf, - "

\r\n" - , (unsigned long long)ms_start); - write(context->out->fh, buf, strlen(buf)); token = strtok(rect[i].ocr_text, "\r\n"); - while (token) - { - sprintf(buf, "%s", token); - token = strtok(NULL, "\r\n"); - if (token) - strcat(buf, "
\n"); - else - strcat(buf, "\n"); - write(context->out->fh, buf, strlen(buf)); - } - sprintf(buf, - "

 

\r\n\r\n" - , (unsigned long long)ms_end); + sprintf(buf, "%s", token); + token = strtok(NULL, "\r\n"); write(context->out->fh, buf, strlen(buf)); + if (i != 0) + write(context->out->fh, context->encoded_br, context->encoded_br_length); + write(context->out->fh, context->encoded_crlf, context->encoded_crlf_length); } } } + sprintf(buf, "

\r\n"); + write(context->out->fh, buf, strlen(buf)); + sprintf(buf, + "

 

\r\n\r\n" + , (unsigned long long)ms_end); + write(context->out->fh, buf, strlen(buf)); #endif sub->nb_data = 0;