mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2025-01-13 13:40:54 +00:00
[FIX] EIA-608 screen clearing fix (#1203)
* eia608: Re-use constant rather than hard-coding length in arrays Hard-coding them is less clear and more prone to breakage. * eia608: Add and use constant for max number of rows Hard-coding it everywhere is unclear and prone to breakage. * eia608: Initialize colors and fonts properly with a loop memset is for single-byte types; an enum is defined to be the size of an int, so using memset to fill an array of enum values is incorrect. Fix it by using a simple loop to fill the elements, as there is no memset-like function for arbitrary item lengths in C. GCC warns: src/lib_ccx/ccx_decoders_608.c: In function ‘clear_eia608_cc_buffer’: src/lib_ccx/ccx_decoders_608.c:111:3: warning: ‘memset’ used with length equal to number of elements without multiplication by element size [-Wmemset-elt-size] 111 | memset(data->colors[i], context->settings->default_color, CCX_DECODER_608_SCREEN_WIDTH + 1); | ^~~~~~ src/lib_ccx/ccx_decoders_608.c:112:3: warning: ‘memset’ used with length equal to number of elements without multiplication by element size [-Wmemset-elt-size] 112 | memset(data->fonts[i], FONT_REGULAR, CCX_DECODER_608_SCREEN_WIDTH + 1); | ^~~~~~
This commit is contained in:
parent
2281051d3d
commit
a0b4e389f9
@ -104,12 +104,17 @@ const char *color_text[MAX_COLOR][2]=
|
||||
|
||||
void clear_eia608_cc_buffer(ccx_decoder_608_context *context, struct eia608_screen *data)
|
||||
{
|
||||
for (int i = 0;i<15;i++)
|
||||
for (int i = 0;i<CCX_DECODER_608_SCREEN_ROWS;i++)
|
||||
{
|
||||
memset(data->characters[i], ' ', CCX_DECODER_608_SCREEN_WIDTH);
|
||||
data->characters[i][CCX_DECODER_608_SCREEN_WIDTH] = 0;
|
||||
memset(data->colors[i], context->settings->default_color, CCX_DECODER_608_SCREEN_WIDTH + 1);
|
||||
memset(data->fonts[i], FONT_REGULAR, CCX_DECODER_608_SCREEN_WIDTH + 1);
|
||||
|
||||
for (int j = 0; j < CCX_DECODER_608_SCREEN_WIDTH + 1; j++)
|
||||
{
|
||||
data->colors[i][j] = context->settings->default_color;
|
||||
data->fonts[i][j] = FONT_REGULAR;
|
||||
}
|
||||
|
||||
data->row_used[i]=0;
|
||||
}
|
||||
data->empty=1;
|
||||
@ -379,7 +384,7 @@ int write_cc_line(ccx_decoder_608_context *context, struct cc_subtitle *sub)
|
||||
sub->datatype = CC_DATATYPE_GENERIC;
|
||||
sub->nb_data++;
|
||||
|
||||
for(i = 0; i < 15; i++)
|
||||
for(i = 0; i < CCX_DECODER_608_SCREEN_ROWS; i++)
|
||||
{
|
||||
if(i == context->cursor_row)
|
||||
data->row_used[i] = 1;
|
||||
@ -446,7 +451,7 @@ int check_roll_up(ccx_decoder_608_context *context)
|
||||
if (use_buffer->row_used[0]) // If top line is used it will go off the screen no matter what
|
||||
return 1;
|
||||
int rows_orig=0; // Number of rows in use right now
|
||||
for (int i=0;i<15;i++)
|
||||
for (int i=0;i<CCX_DECODER_608_SCREEN_ROWS;i++)
|
||||
{
|
||||
if (use_buffer->row_used[i])
|
||||
{
|
||||
@ -500,7 +505,7 @@ int roll_up(ccx_decoder_608_context *context)
|
||||
int firstrow=-1, lastrow=-1;
|
||||
// Look for the last line used
|
||||
int rows_orig=0; // Number of rows in use right now
|
||||
for (int i=0;i<15;i++)
|
||||
for (int i=0;i<CCX_DECODER_608_SCREEN_ROWS;i++)
|
||||
{
|
||||
if (use_buffer->row_used[i])
|
||||
{
|
||||
@ -543,7 +548,7 @@ int roll_up(ccx_decoder_608_context *context)
|
||||
|
||||
// Sanity check
|
||||
int rows_now=0;
|
||||
for (int i=0;i<15;i++)
|
||||
for (int i=0;i<CCX_DECODER_608_SCREEN_ROWS;i++)
|
||||
if (use_buffer->row_used[i])
|
||||
rows_now++;
|
||||
if (rows_now>keep_lines)
|
||||
@ -732,7 +737,7 @@ void handle_command(unsigned char c1, const unsigned char c2, ccx_decoder_608_co
|
||||
if (context->mode == MODE_POPON) // CFS: Not sure about this. Is there a valid reason for CR in popup?
|
||||
{
|
||||
context->cursor_column = 0;
|
||||
if (context->cursor_row<15)
|
||||
if (context->cursor_row<CCX_DECODER_608_SCREEN_ROWS)
|
||||
context->cursor_row++;
|
||||
break;
|
||||
}
|
||||
@ -939,7 +944,7 @@ void handle_pac(unsigned char c1, unsigned char c2, ccx_decoder_608_context *con
|
||||
buffer around instead) but it's better than leaving old characters in the buffer */
|
||||
struct eia608_screen *use_buffer = get_writing_buffer(context); // &wb->data608->buffer1;
|
||||
|
||||
for (int j=row;j<15;j++)
|
||||
for (int j=row;j<CCX_DECODER_608_SCREEN_ROWS;j++)
|
||||
{
|
||||
if (use_buffer->row_used[j])
|
||||
{
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "list.h"
|
||||
#include "ccx_decoders_708.h"
|
||||
// Define max width in characters/columns on the screen
|
||||
#define CCX_DECODER_608_SCREEN_ROWS 15
|
||||
#define CCX_DECODER_608_SCREEN_WIDTH 32
|
||||
#define MAXBFRAMES 50
|
||||
#define SORTBUF (2*MAXBFRAMES+1)
|
||||
@ -84,10 +85,10 @@ struct eia608_screen // A CC buffer
|
||||
{
|
||||
/** format of data inside this structure */
|
||||
enum ccx_eia608_format format;
|
||||
unsigned char characters[15][33];
|
||||
enum ccx_decoder_608_color_code colors[15][33];
|
||||
enum font_bits fonts[15][33]; // Extra char at the end for a 0
|
||||
int row_used[15]; // Any data in row?
|
||||
unsigned char characters[CCX_DECODER_608_SCREEN_ROWS][CCX_DECODER_608_SCREEN_WIDTH + 1];
|
||||
enum ccx_decoder_608_color_code colors[CCX_DECODER_608_SCREEN_ROWS][CCX_DECODER_608_SCREEN_WIDTH + 1];
|
||||
enum font_bits fonts[CCX_DECODER_608_SCREEN_ROWS][CCX_DECODER_608_SCREEN_WIDTH + 1]; // Extra char at the end for a 0
|
||||
int row_used[CCX_DECODER_608_SCREEN_ROWS]; // Any data in row?
|
||||
int empty; // Buffer completely empty?
|
||||
/** start time of this CC buffer */
|
||||
LLONG start_time;
|
||||
|
Loading…
Reference in New Issue
Block a user