Indenting sami code

Signed-off-by: Anshul Maheshwari <er.anshul.maheshwari@gmail.com>
This commit is contained in:
Anshul Maheshwari 2015-05-19 10:45:04 +05:30
parent c49db8c083
commit 89459a6c2e

View File

@ -10,13 +10,13 @@ void write_stringz_as_sami(char *string, struct encoder_ctx *context, LLONG ms_s
{ {
int used; int used;
sprintf ((char *) str, sprintf ((char *) str,
"<SYNC start=%llu><P class=\"UNKNOWNCC\">\r\n",(unsigned long long)ms_start); "<SYNC start=%llu><P class=\"UNKNOWNCC\">\r\n",(unsigned long long)ms_start);
if (context->encoding!=CCX_ENC_UNICODE) if (context->encoding != CCX_ENC_UNICODE)
{ {
dbg_print(CCX_DMT_DECODER_608, "\r%s\n", str); dbg_print(CCX_DMT_DECODER_608, "\r%s\n", str);
} }
used = encode_line(context->buffer,(unsigned char *) str); used = encode_line(context->buffer, (unsigned char *) str);
write (context->out->fh, context->buffer, used); write (context->out->fh, context->buffer, used);
int len=strlen (string); int len=strlen (string);
unsigned char *unescaped= (unsigned char *) malloc (len+1); unsigned char *unescaped= (unsigned char *) malloc (len+1);
@ -26,27 +26,27 @@ void write_stringz_as_sami(char *string, struct encoder_ctx *context, LLONG ms_s
int pos_r=0; int pos_r=0;
int pos_w=0; int pos_w=0;
// Scan for \n in the string and replace it with a 0 // Scan for \n in the string and replace it with a 0
while (pos_r<len) while (pos_r < len)
{ {
if (string[pos_r]=='\\' && string[pos_r+1]=='n') if (string[pos_r] == '\\' && string[pos_r+1]=='n')
{ {
unescaped[pos_w]=0; unescaped[pos_w] = 0;
pos_r+=2; pos_r += 2;
} }
else else
{ {
unescaped[pos_w]=string[pos_r]; unescaped[pos_w] = string[pos_r];
pos_r++; pos_r++;
} }
pos_w++; pos_w++;
} }
unescaped[pos_w]=0; unescaped[pos_w] = 0;
// Now read the unescaped string (now several string'z and write them) // Now read the unescaped string (now several string'z and write them)
unsigned char *begin=unescaped; unsigned char *begin = unescaped;
while (begin<unescaped+len) while (begin < unescaped+len)
{ {
unsigned int u = encode_line (el, begin); unsigned int u = encode_line (el, begin);
if (context->encoding!=CCX_ENC_UNICODE) if (context->encoding != CCX_ENC_UNICODE)
{ {
dbg_print(CCX_DMT_DECODER_608, "\r"); dbg_print(CCX_DMT_DECODER_608, "\r");
dbg_print(CCX_DMT_DECODER_608, "%s\n",subline); dbg_print(CCX_DMT_DECODER_608, "%s\n",subline);
@ -55,23 +55,23 @@ void write_stringz_as_sami(char *string, struct encoder_ctx *context, LLONG ms_s
write(context->out->fh, encoded_br, encoded_br_length); write(context->out->fh, encoded_br, encoded_br_length);
write(context->out->fh, encoded_crlf, encoded_crlf_length); write(context->out->fh, encoded_crlf, encoded_crlf_length);
begin+= strlen ((const char *) begin)+1; begin += strlen ((const char *) begin) + 1;
} }
sprintf ((char *) str,"</P></SYNC>\r\n"); sprintf ((char *) str, "</P></SYNC>\r\n");
if (context->encoding!=CCX_ENC_UNICODE) if (context->encoding != CCX_ENC_UNICODE)
{ {
dbg_print(CCX_DMT_DECODER_608, "\r%s\n", str); dbg_print(CCX_DMT_DECODER_608, "\r%s\n", str);
} }
used=encode_line (context->buffer,(unsigned char *) str); used = encode_line (context->buffer,(unsigned char *) str);
write(context->out->fh, context->buffer, used); write(context->out->fh, context->buffer, used);
sprintf ((char *) str, sprintf ((char *) str,
"<SYNC start=%llu><P class=\"UNKNOWNCC\">&nbsp;</P></SYNC>\r\n\r\n", "<SYNC start=%llu><P class=\"UNKNOWNCC\">&nbsp;</P></SYNC>\r\n\r\n",
(unsigned long long)ms_end); (unsigned long long)ms_end);
if (context->encoding!=CCX_ENC_UNICODE) if (context->encoding != CCX_ENC_UNICODE)
{ {
dbg_print(CCX_DMT_DECODER_608, "\r%s\n", str); dbg_print(CCX_DMT_DECODER_608, "\r%s\n", str);
} }
write(context->out->fh, context->buffer, used); write(context->out->fh, context->buffer, used);
free(el); free(el);
free(unescaped); free(unescaped);
@ -149,56 +149,56 @@ int write_cc_buffer_as_sami(struct eia608_screen *data, struct encoder_ctx *cont
{ {
int used; int used;
LLONG startms, endms; LLONG startms, endms;
int wrote_something=0; int wrote_something=0;
startms = data->start_time; startms = data->start_time;
startms+=context->subs_delay; startms+=context->subs_delay;
if (startms<0) // Drop screens that because of subs_delay start too early if (startms<0) // Drop screens that because of subs_delay start too early
return 0; return 0;
endms = data->end_time; endms = data->end_time;
endms--; // To prevent overlapping with next line. endms--; // To prevent overlapping with next line.
sprintf ((char *) str, sprintf ((char *) str,
"<SYNC start=%llu><P class=\"UNKNOWNCC\">\r\n", "<SYNC start=%llu><P class=\"UNKNOWNCC\">\r\n",
(unsigned long long)startms); (unsigned long long)startms);
if (context->encoding!=CCX_ENC_UNICODE) if (context->encoding != CCX_ENC_UNICODE)
{ {
dbg_print(CCX_DMT_DECODER_608, "\r%s\n", str); dbg_print(CCX_DMT_DECODER_608, "\r%s\n", str);
} }
used = encode_line(context->buffer,(unsigned char *) str); used = encode_line(context->buffer,(unsigned char *) str);
write (context->out->fh, context->buffer, used); write (context->out->fh, context->buffer, used);
for (int i=0;i<15;i++) for (int i=0;i<15;i++)
{ {
if (data->row_used[i]) if (data->row_used[i])
{ {
int length = get_decoder_line_encoded (subline, i, data); int length = get_decoder_line_encoded (subline, i, data);
if (context->encoding!=CCX_ENC_UNICODE) if (context->encoding != CCX_ENC_UNICODE)
{ {
dbg_print(CCX_DMT_DECODER_608, "\r"); dbg_print(CCX_DMT_DECODER_608, "\r");
dbg_print(CCX_DMT_DECODER_608, "%s\n",subline); dbg_print(CCX_DMT_DECODER_608, "%s\n",subline);
} }
write (context->out->fh, subline, length); write (context->out->fh, subline, length);
wrote_something=1; wrote_something = 1;
if (i!=14) if (i!=14)
write (context->out->fh, encoded_br, encoded_br_length); write (context->out->fh, encoded_br, encoded_br_length);
write (context->out->fh,encoded_crlf, encoded_crlf_length); write (context->out->fh, encoded_crlf, encoded_crlf_length);
} }
} }
sprintf ((char *) str,"</P></SYNC>\r\n"); sprintf ((char *) str,"</P></SYNC>\r\n");
if (context->encoding!=CCX_ENC_UNICODE) if (context->encoding != CCX_ENC_UNICODE)
{ {
dbg_print(CCX_DMT_DECODER_608, "\r%s\n", str); dbg_print(CCX_DMT_DECODER_608, "\r%s\n", str);
} }
used = encode_line(context->buffer,(unsigned char *) str); used = encode_line(context->buffer,(unsigned char *) str);
write (context->out->fh, context->buffer, used); write (context->out->fh, context->buffer, used);
sprintf ((char *) str, sprintf ((char *) str,
"<SYNC start=%llu><P class=\"UNKNOWNCC\">&nbsp;</P></SYNC>\r\n\r\n", "<SYNC start=%llu><P class=\"UNKNOWNCC\">&nbsp;</P></SYNC>\r\n\r\n",
(unsigned long long)endms); (unsigned long long)endms);
if (context->encoding!=CCX_ENC_UNICODE) if (context->encoding!=CCX_ENC_UNICODE)
{ {
dbg_print(CCX_DMT_DECODER_608, "\r%s\n", str); dbg_print(CCX_DMT_DECODER_608, "\r%s\n", str);
} }
used = encode_line(context->buffer,(unsigned char *) str); used = encode_line(context->buffer,(unsigned char *) str);
write (context->out->fh, context->buffer, used); write (context->out->fh, context->buffer, used);
return wrote_something; return wrote_something;
} }