diff --git a/src/608.c b/src/608.c
index ef3ad154..f926e91f 100644
--- a/src/608.c
+++ b/src/608.c
@@ -1,11 +1,11 @@
#include "ccextractor.h"
#include "608_spupng.h"
-static const int rowdata[] = {11,-1,1,2,3,4,12,13,14,15,5,6,7,8,9,10};
+static const int rowdata[] = {11,-1,1,2,3,4,12,13,14,15,5,6,7,8,9,10};
// Relationship between the first PAC byte and the row number
-int in_xds_mode=0;
+int in_xds_mode=0;
-#define INITIAL_ENC_BUFFER_CAPACITY 2048
+#define INITIAL_ENC_BUFFER_CAPACITY 2048
unsigned char *enc_buffer=NULL; // Generic general purpose buffer
unsigned char str[2048]; // Another generic general purpose buffer
@@ -15,7 +15,7 @@ unsigned enc_buffer_capacity;
LLONG minimum_fts=0; // No screen should start before this FTS
const unsigned char pac2_attribs[][3] = // Color, font, ident
{
- { COL_WHITE, FONT_REGULAR, 0 }, // 0x40 || 0x60
+ { COL_WHITE, FONT_REGULAR, 0 }, // 0x40 || 0x60
{ COL_WHITE, FONT_UNDERLINED, 0 }, // 0x41 || 0x61
{ COL_GREEN, FONT_REGULAR, 0 }, // 0x42 || 0x62
{ COL_GREEN, FONT_UNDERLINED, 0 }, // 0x43 || 0x63
@@ -51,15 +51,15 @@ const unsigned char pac2_attribs[][3] = // Color, font, ident
int general_608_init (void)
{
- enc_buffer=(unsigned char *) malloc (INITIAL_ENC_BUFFER_CAPACITY);
- if (enc_buffer==NULL)
- return -1;
- enc_buffer_capacity=INITIAL_ENC_BUFFER_CAPACITY;
- return 0;
+ enc_buffer=(unsigned char *) malloc (INITIAL_ENC_BUFFER_CAPACITY);
+ if (enc_buffer==NULL)
+ return -1;
+ enc_buffer_capacity=INITIAL_ENC_BUFFER_CAPACITY;
+ return 0;
}
// Preencoded strings
-unsigned char encoded_crlf[16];
+unsigned char encoded_crlf[16];
unsigned int encoded_crlf_length;
unsigned char encoded_br[16];
unsigned int encoded_br_length;
@@ -84,27 +84,27 @@ text-align: center; font-size: 18pt; font-family: arial; font-weight: bold; colo
\n\n\
\n";
-static const char *smptett_header =
+static const char *smptett_header =
"\n\
\n\
\n\n" ;
static const char *command_type[] =
{
- "Unknown",
- "EDM - EraseDisplayedMemory",
- "RCL - ResumeCaptionLoading",
- "EOC - End Of Caption",
- "TO1 - Tab Offset, 1 column",
- "TO2 - Tab Offset, 2 column",
- "TO3 - Tab Offset, 3 column",
- "RU2 - Roll up 2 rows",
- "RU3 - Roll up 3 rows",
- "RU4 - Roll up 4 rows",
- "CR - Carriage Return",
- "ENM - Erase non-displayed memory",
- "BS - Backspace",
- "RTD - Resume Text Display",
+ "Unknown",
+ "EDM - EraseDisplayedMemory",
+ "RCL - ResumeCaptionLoading",
+ "EOC - End Of Caption",
+ "TO1 - Tab Offset, 1 column",
+ "TO2 - Tab Offset, 2 column",
+ "TO3 - Tab Offset, 3 column",
+ "RU2 - Roll up 2 rows",
+ "RU3 - Roll up 3 rows",
+ "RU4 - Roll up 4 rows",
+ "CR - Carriage Return",
+ "ENM - Erase non-displayed memory",
+ "BS - Backspace",
+ "RTD - Resume Text Display",
"AOF - Not Used (Alarm Off)",
"AON - Not Used (Alarm On)",
"DER - Delete to End of Row",
@@ -114,63 +114,64 @@ static const char *command_type[] =
static const char *font_text[]=
{
- "regular",
- "italics",
- "underlined",
- "underlined italics"
+ "regular",
+ "italics",
+ "underlined",
+ "underlined italics"
};
+#if 0
static const char *cc_modes_text[]=
{
- "Pop-Up captions"
+ "Pop-Up captions"
};
-
+#endif
const char *color_text[][2]=
{
- {"white",""},
- {"green",""},
- {"blue",""},
- {"cyan",""},
- {"red",""},
- {"yellow",""},
- {"magenta",""},
- {"userdefined",""},
+ {"blue",""},
+ {"cyan",""},
+ {"red",""},
+ {"yellow",""},
+ {"magenta",""},
+ {"userdefined","characters[i],' ',CC608_SCREEN_WIDTH);
- data->characters[i][CC608_SCREEN_WIDTH]=0;
- memset (data->colors[i],ccx_options.cc608_default_color,CC608_SCREEN_WIDTH+1);
- memset (data->fonts[i],FONT_REGULAR,CC608_SCREEN_WIDTH+1);
- data->row_used[i]=0;
- }
- data->empty=1;
+ for (int i=0;i<15;i++)
+ {
+ memset(data->characters[i],' ',CC608_SCREEN_WIDTH);
+ data->characters[i][CC608_SCREEN_WIDTH]=0;
+ memset (data->colors[i],ccx_options.cc608_default_color,CC608_SCREEN_WIDTH+1);
+ memset (data->fonts[i],FONT_REGULAR,CC608_SCREEN_WIDTH+1);
+ data->row_used[i]=0;
+ }
+ data->empty=1;
}
void init_context_cc608(struct s_context_cc608 *data, int field)
{
- data->cursor_column=0;
- data->cursor_row=0;
- clear_eia608_cc_buffer (&data->buffer1);
- clear_eia608_cc_buffer (&data->buffer2);
- data->visible_buffer=1;
- data->last_c1=0;
- data->last_c2=0;
- data->mode=MODE_POPON;
- // data->current_visible_start_cc=0;
- data->current_visible_start_ms=0;
- data->srt_counter=0;
- data->screenfuls_counter=0;
- data->channel=1;
- data->color=ccx_options.cc608_default_color;
- data->font=FONT_REGULAR;
- data->rollup_base_row=14;
+ data->cursor_column=0;
+ data->cursor_row=0;
+ clear_eia608_cc_buffer (&data->buffer1);
+ clear_eia608_cc_buffer (&data->buffer2);
+ data->visible_buffer=1;
+ data->last_c1=0;
+ data->last_c2=0;
+ data->mode=MODE_POPON;
+ // data->current_visible_start_cc=0;
+ data->current_visible_start_ms=0;
+ data->srt_counter=0;
+ data->screenfuls_counter=0;
+ data->channel=1;
+ data->color=ccx_options.cc608_default_color;
+ data->font=FONT_REGULAR;
+ data->rollup_base_row=14;
data->ts_start_of_current_line=-1;
data->ts_last_char_received=-1;
data->new_channel=1;
@@ -182,37 +183,37 @@ void init_context_cc608(struct s_context_cc608 *data, int field)
struct eia608_screen *get_writing_buffer(struct s_context_cc608 *context)
{
- struct eia608_screen *use_buffer=NULL;
- switch (context->mode)
- {
- case MODE_POPON: // Write on the non-visible buffer
+ struct eia608_screen *use_buffer=NULL;
+ switch (context->mode)
+ {
+ case MODE_POPON: // Write on the non-visible buffer
if (context->visible_buffer == 1)
use_buffer = &context->buffer2;
- else
+ else
use_buffer = &context->buffer1;
- break;
+ break;
case MODE_FAKE_ROLLUP_1: // Write directly to screen
- case MODE_ROLLUP_2:
- case MODE_ROLLUP_3:
- case MODE_ROLLUP_4:
+ case MODE_ROLLUP_2:
+ case MODE_ROLLUP_3:
+ case MODE_ROLLUP_4:
case MODE_PAINTON:
case MODE_TEXT:
// TODO: Fix this. Text uses a different buffer, and contains non-program information.
if (context->visible_buffer == 1)
use_buffer = &context->buffer1;
- else
+ else
use_buffer = &context->buffer2;
- break;
- default:
- fatal (EXIT_BUG_BUG, "Caption mode has an illegal value at get_writing_buffer(), this is a bug.\n");
- }
- return use_buffer;
+ break;
+ default:
+ fatal (EXIT_BUG_BUG, "Caption mode has an illegal value at get_writing_buffer(), this is a bug.\n");
+ }
+ return use_buffer;
}
void delete_to_end_of_row(struct s_context_cc608 *context)
{
if (context->mode != MODE_TEXT)
- {
+ {
struct eia608_screen * use_buffer = get_writing_buffer(context);
for (int i = context->cursor_column; i <= 31; i++)
{
@@ -228,73 +229,73 @@ void delete_to_end_of_row(struct s_context_cc608 *context)
void write_char(const unsigned char c, struct s_context_cc608 *context)
{
if (context->mode != MODE_TEXT)
- {
+ {
struct eia608_screen * use_buffer = get_writing_buffer(context);
- /* printf ("\rWriting char [%c] at %s:%d:%d\n",c,
- use_buffer == &wb->data608->buffer1?"B1":"B2",
- wb->data608->cursor_row,wb->data608->cursor_column); */
+ /* printf ("\rWriting char [%c] at %s:%d:%d\n",c,
+ use_buffer == &wb->data608->buffer1?"B1":"B2",
+ wb->data608->cursor_row,wb->data608->cursor_column); */
use_buffer->characters[context->cursor_row][context->cursor_column] = c;
use_buffer->colors[context->cursor_row][context->cursor_column] = context->color;
use_buffer->fonts[context->cursor_row][context->cursor_column] = context->font;
use_buffer->row_used[context->cursor_row] = 1;
- if (use_buffer->empty)
- {
+ if (use_buffer->empty)
+ {
if (MODE_POPON != context->mode)
context->current_visible_start_ms = get_visible_start();
- }
- use_buffer->empty=0;
+ }
+ use_buffer->empty=0;
if (context->cursor_column<31)
context->cursor_column++;
if (context->ts_start_of_current_line == -1)
context->ts_start_of_current_line = get_fts();
context->ts_last_char_received = get_fts();
- }
+ }
}
/* Handle MID-ROW CODES. */
void handle_text_attr(const unsigned char c1, const unsigned char c2, struct s_context_cc608 *context)
{
- // Handle channel change
+ // Handle channel change
context->channel = context->new_channel;
if (context->channel != ccx_options.cc_channel)
- return;
- dbg_print(CCX_DMT_608, "\r608: text_attr: %02X %02X",c1,c2);
- if ( ((c1!=0x11 && c1!=0x19) ||
- (c2<0x20 || c2>0x2f)))
- {
- dbg_print(CCX_DMT_608, "\rThis is not a text attribute!\n");
- }
- else
- {
- int i = c2-0x20;
+ return;
+ dbg_print(CCX_DMT_608, "\r608: text_attr: %02X %02X",c1,c2);
+ if ( ((c1!=0x11 && c1!=0x19) ||
+ (c2<0x20 || c2>0x2f)))
+ {
+ dbg_print(CCX_DMT_608, "\rThis is not a text attribute!\n");
+ }
+ else
+ {
+ int i = c2-0x20;
context->color = pac2_attribs[i][0];
context->font = pac2_attribs[i][1];
- dbg_print(CCX_DMT_608, " -- Color: %s, font: %s\n",
+ dbg_print(CCX_DMT_608, " -- Color: %s, font: %s\n",
color_text[context->color][0],
font_text[context->font]);
- // Mid-row codes should put a non-transparent space at the current position
- // and advance the cursor
- //so use write_char
+ // Mid-row codes should put a non-transparent space at the current position
+ // and advance the cursor
+ //so use write_char
write_char(0x20, context);
- }
+ }
}
void write_subtitle_file_footer(struct ccx_s_write *out)
{
- switch (ccx_options.write_format)
- {
- case CCX_OF_SAMI:
- sprintf ((char *) str,"\n");
- if (ccx_options.encoding!=CCX_ENC_UNICODE)
- {
- dbg_print(CCX_DMT_608, "\r%s\n", str);
- }
- enc_buffer_used=encode_line (enc_buffer,(unsigned char *) str);
+ switch (ccx_options.write_format)
+ {
+ case CCX_OF_SAMI:
+ sprintf ((char *) str,"\n");
+ if (ccx_options.encoding!=CCX_ENC_UNICODE)
+ {
+ dbg_print(CCX_DMT_608, "\r%s\n", str);
+ }
+ enc_buffer_used=encode_line (enc_buffer,(unsigned char *) str);
write(out->fh, enc_buffer, enc_buffer_used);
- break;
+ break;
case CCX_OF_SMPTETT:
sprintf ((char *) str,"