diff --git a/src/lib_ccx/ccx_encoders_common.c b/src/lib_ccx/ccx_encoders_common.c index dc71c45a..3e25d1a5 100644 --- a/src/lib_ccx/ccx_encoders_common.c +++ b/src/lib_ccx/ccx_encoders_common.c @@ -95,7 +95,7 @@ static const char *smptett_header = "\n" "
\n"; -static const char *webvtt_header[] = {"WEBVTT","\r\n","\r\n","STYLE","\r\n"}; +static const char *webvtt_header[] = {"WEBVTT","\r\n","\r\n","STYLE","\r\n",NULL}; static const char *simple_xml_header = "\r\n\r\n"; @@ -448,21 +448,17 @@ static int write_subtitle_file_header(struct encoder_ctx *ctx, struct ccx_s_writ ret = write_bom(ctx, out); if (ret < 0) return -1; - for(int i = 0; i < sizeof(webvtt_header)/sizeof(webvtt_header[0]);i++) + for(int i = 0; webvtt_header[i]!=NULL ;i++) { - header_size += strlen(webvtt_header[i]); - if(ccx_options.enc_cfg.line_terminator_lf == 1 && strcmp(webvtt_header[i],"\r\n")==0) - { - header_size--; - } + header_size += strlen(webvtt_header[i]); // Find total size of the header } REQUEST_BUFFER_CAPACITY(ctx, header_size*3); - for(int i = 0; i < sizeof(webvtt_header)/sizeof(webvtt_header[0]);i++) + for(int i = 0; webvtt_header[i]!=NULL;i++) { - if(ccx_options.enc_cfg.line_terminator_lf == 1 && strcmp(webvtt_header[i],"\r\n")==0) + if(ccx_options.enc_cfg.line_terminator_lf == 1 && strcmp(webvtt_header[i],"\r\n")==0) // If -lf parameter passed, write LF instead of CRLF { used = encode_line (ctx, ctx->buffer,(unsigned char *) "\n"); - } + } else { used = encode_line (ctx, ctx->buffer,(unsigned char *) webvtt_header[i]); diff --git a/src/lib_ccx/ccx_encoders_webvtt.c b/src/lib_ccx/ccx_encoders_webvtt.c index 427d4171..00dd825d 100644 --- a/src/lib_ccx/ccx_encoders_webvtt.c +++ b/src/lib_ccx/ccx_encoders_webvtt.c @@ -227,7 +227,7 @@ int write_webvtt_header(struct encoder_ctx *context) write (context->out->fh, outline_css_file, strlen(outline_css_file)); } else { write(context->out->fh, webvtt_inline_css, strlen(webvtt_inline_css)); - if(ccx_options.enc_cfg.line_terminator_lf == 1) + if(ccx_options.enc_cfg.line_terminator_lf == 1) // If -lf parameter is set. { write(context->out->fh, "\n", 1); }