mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2026-11-16 17:21:13 +00:00
remove internal use of ccx_decoders_common_settings_t
This commit is contained in:
@@ -116,7 +116,11 @@ void clear_eia608_cc_buffer(ccx_decoder_608_context *context, struct eia608_scre
|
||||
data->empty=1;
|
||||
}
|
||||
|
||||
ccx_decoder_608_context* ccx_decoder_608_init_library(ccx_decoder_608_settings settings, int channel, int field, int trim_subs, enum ccx_encoding_type encoding, int *halt, int cc_to_stdout)
|
||||
ccx_decoder_608_context* ccx_decoder_608_init_library(ccx_decoder_608_settings settings, int channel,
|
||||
int field, int trim_subs,
|
||||
enum ccx_encoding_type encoding, int *halt,
|
||||
int cc_to_stdout, LLONG subs_delay,
|
||||
enum ccx_output_format output_format)
|
||||
{
|
||||
ccx_decoder_608_context *data = NULL;
|
||||
|
||||
@@ -148,6 +152,8 @@ ccx_decoder_608_context* ccx_decoder_608_init_library(ccx_decoder_608_settings s
|
||||
|
||||
data->halt = halt;
|
||||
data->cc_to_stdout = cc_to_stdout;
|
||||
data->subs_delay = subs_delay;
|
||||
data->output_format = output_format;
|
||||
|
||||
data->settings = settings;
|
||||
data->current_color = data->settings.default_color;
|
||||
@@ -294,7 +300,7 @@ int write_cc_buffer(ccx_decoder_608_context *context, struct cc_subtitle *sub)
|
||||
context->current_visible_start_ms = context->ts_start_of_current_line;
|
||||
|
||||
start_time = context->current_visible_start_ms;
|
||||
end_time = get_visible_end() + ccx_decoders_common_settings.subs_delay;
|
||||
end_time = get_visible_end() + context->subs_delay;
|
||||
sub->type = CC_608;
|
||||
data->format = SFORMAT_CC_SCREEN;
|
||||
data->start_time = 0;
|
||||
@@ -350,8 +356,8 @@ int write_cc_line(ccx_decoder_608_context *context, struct cc_subtitle *sub)
|
||||
int ret = 0;
|
||||
data = get_current_visible_buffer(context);
|
||||
|
||||
start_time = context->ts_start_of_current_line + ccx_decoders_common_settings.subs_delay;
|
||||
end_time = get_fts() + ccx_decoders_common_settings.subs_delay;
|
||||
start_time = context->ts_start_of_current_line + context->subs_delay;
|
||||
end_time = get_fts() + context->subs_delay;
|
||||
sub->type = CC_608;
|
||||
data->format = SFORMAT_CC_LINE;
|
||||
data->start_time = 0;
|
||||
@@ -730,7 +736,7 @@ void handle_command(/*const */ unsigned char c1, const unsigned char c2, ccx_dec
|
||||
context->cursor_row++;
|
||||
break;
|
||||
}
|
||||
if (ccx_decoders_common_settings.output_format == CCX_OF_TRANSCRIPT)
|
||||
if (context->output_format == CCX_OF_TRANSCRIPT)
|
||||
{
|
||||
write_cc_line(context,sub);
|
||||
}
|
||||
@@ -741,7 +747,7 @@ void handle_command(/*const */ unsigned char c1, const unsigned char c2, ccx_dec
|
||||
if (changes)
|
||||
{
|
||||
// Only if the roll up would actually cause a line to disappear we write the buffer
|
||||
if (ccx_decoders_common_settings.output_format != CCX_OF_TRANSCRIPT)
|
||||
if (context->output_format != CCX_OF_TRANSCRIPT)
|
||||
{
|
||||
if (write_cc_buffer(context, sub))
|
||||
context->screenfuls_counter++;
|
||||
@@ -761,7 +767,7 @@ void handle_command(/*const */ unsigned char c1, const unsigned char c2, ccx_dec
|
||||
case COM_ERASEDISPLAYEDMEMORY:
|
||||
// Write it to disk before doing this, and make a note of the new
|
||||
// time it became clear.
|
||||
if (ccx_decoders_common_settings.output_format == CCX_OF_TRANSCRIPT &&
|
||||
if (context->output_format == CCX_OF_TRANSCRIPT &&
|
||||
(context->mode == MODE_FAKE_ROLLUP_1 ||
|
||||
context->mode == MODE_ROLLUP_2 ||
|
||||
context->mode == MODE_ROLLUP_3 ||
|
||||
@@ -774,7 +780,7 @@ void handle_command(/*const */ unsigned char c1, const unsigned char c2, ccx_dec
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ccx_decoders_common_settings.output_format == CCX_OF_TRANSCRIPT)
|
||||
if (context->output_format == CCX_OF_TRANSCRIPT)
|
||||
context->ts_start_of_current_line = context->current_visible_start_ms;
|
||||
if (write_cc_buffer(context, sub))
|
||||
context->screenfuls_counter++;
|
||||
|
||||
@@ -56,6 +56,8 @@ typedef struct ccx_decoder_608_context
|
||||
int *halt; // Can be used to halt the feeding of caption data. Set to 1 if screens_to_progress != -1 && screenfuls_counter >= screens_to_process
|
||||
int cc_to_stdout; // If this is set to 1, the stdout will be flushed when data was written to the screen during a process_608 call.
|
||||
struct ccx_decoder_608_report report;
|
||||
LLONG subs_delay; // ms to delay (or advance) subs
|
||||
enum ccx_output_format output_format; // What kind of output format should be used?
|
||||
} ccx_decoder_608_context;
|
||||
|
||||
extern unsigned char *enc_buffer;
|
||||
@@ -118,7 +120,11 @@ enum command_code
|
||||
/*
|
||||
*
|
||||
*/
|
||||
ccx_decoder_608_context* ccx_decoder_608_init_library(ccx_decoder_608_settings settings, int channel, int field, int trim_subs, enum ccx_encoding_type encoding, int *halt, int cc_to_stdout);
|
||||
ccx_decoder_608_context* ccx_decoder_608_init_library(ccx_decoder_608_settings settings, int channel,
|
||||
int field, int trim_subs,
|
||||
enum ccx_encoding_type encoding, int *halt,
|
||||
int cc_to_stdout, LLONG subs_delay,
|
||||
enum ccx_output_format output_format);
|
||||
|
||||
/**
|
||||
* @param data raw cc608 data to be processed
|
||||
|
||||
@@ -121,16 +121,21 @@ void cc708_service_reset(cc708_service_decoder *decoder)
|
||||
decoder->inited=1;
|
||||
}
|
||||
|
||||
void cc708_reset()
|
||||
void cc708_reset(struct lib_cc_decode *ctx)
|
||||
{
|
||||
ccx_common_logging.debug_ftn(CCX_DMT_708, ">>> Entry in cc708_reset()\n");
|
||||
// Clear states of decoders
|
||||
cc708_service_reset(&decoders[0]);
|
||||
cc708_service_reset(&decoders[1]);
|
||||
// Empty packet buffer
|
||||
clear_packet();
|
||||
last_seq=-1;
|
||||
resets_708++;
|
||||
ccx_common_logging.debug_ftn(CCX_DMT_708, ">>> Entry in cc708_reset()\n");
|
||||
|
||||
decoders[0].output_format = ctx->write_format;
|
||||
decoders[1].output_format = ctx->write_format;
|
||||
decoders[0].subs_delay = ctx->subs_delay;
|
||||
decoders[1].subs_delay = ctx->subs_delay;
|
||||
// Clear states of decoders
|
||||
cc708_service_reset(&decoders[0]);
|
||||
cc708_service_reset(&decoders[1]);
|
||||
// Empty packet buffer
|
||||
clear_packet();
|
||||
last_seq=-1;
|
||||
resets_708++;
|
||||
}
|
||||
|
||||
int compWindowsPriorities (const void *a, const void *b)
|
||||
@@ -152,16 +157,16 @@ void clearTV (cc708_service_decoder *decoder, int buffer) // Buffer => 1 or 2
|
||||
|
||||
void printTVtoSRT (cc708_service_decoder *decoder, int which)
|
||||
{
|
||||
if (ccx_decoders_common_settings.output_format == CCX_OF_NULL)
|
||||
if (decoder->output_format == CCX_OF_NULL)
|
||||
return;
|
||||
|
||||
/* tvscreen *tv = (which==1)? &decoder->tv1:&decoder->tv2; */
|
||||
unsigned h1,m1,s1,ms1;
|
||||
unsigned h2,m2,s2,ms2;
|
||||
LLONG ms_start= decoder->current_visible_start_ms;
|
||||
LLONG ms_end = get_visible_end() + ccx_decoders_common_settings.subs_delay;
|
||||
LLONG ms_end = get_visible_end() + decoder->subs_delay;
|
||||
int empty=1;
|
||||
ms_start+= ccx_decoders_common_settings.subs_delay;
|
||||
ms_start+= decoder->subs_delay;
|
||||
if (ms_start<0) // Drop screens that because of subs_delay start too early
|
||||
return;
|
||||
|
||||
@@ -1083,7 +1088,7 @@ void process_service_block (cc708_service_decoder *decoder, unsigned char *data,
|
||||
}
|
||||
|
||||
|
||||
void process_current_packet (void)
|
||||
void process_current_packet (struct lib_cc_decode* ctx)
|
||||
{
|
||||
int seq=(current_packet[0] & 0xC0) >> 6; // Two most significants bits
|
||||
int len=current_packet[0] & 0x3F; // 6 least significants bits
|
||||
@@ -1105,14 +1110,14 @@ void process_current_packet (void)
|
||||
ccx_common_logging.debug_ftn(CCX_DMT_708, "Packet length mismatch (%s%d), first two data bytes %02X %02X, current picture:%s\n",
|
||||
current_packet_length-len>0?"+":"", current_packet_length-len,
|
||||
current_packet[0], current_packet[1], pict_types[current_picture_coding_type]);
|
||||
cc708_reset();
|
||||
cc708_reset(ctx);
|
||||
return;
|
||||
}
|
||||
if (last_seq!=-1 && (last_seq+1)%4!=seq)
|
||||
{
|
||||
ccx_common_logging.debug_ftn(CCX_DMT_708, "Unexpected sequence number, it was [%d] but should have been [%d]\n",
|
||||
seq,(last_seq+1)%4);
|
||||
cc708_reset();
|
||||
cc708_reset(ctx);
|
||||
return;
|
||||
}
|
||||
last_seq=seq;
|
||||
@@ -1170,7 +1175,7 @@ void process_current_packet (void)
|
||||
if (pos!=current_packet+len) // For some reason we didn't parse the whole packet
|
||||
{
|
||||
ccx_common_logging.debug_ftn(CCX_DMT_708, "There was a problem with this packet, reseting\n");
|
||||
cc708_reset();
|
||||
cc708_reset(ctx);
|
||||
}
|
||||
|
||||
if (len<128 && *pos) // Null header is mandatory if there is room
|
||||
@@ -1179,9 +1184,9 @@ void process_current_packet (void)
|
||||
}
|
||||
}
|
||||
|
||||
void do_708 (const unsigned char *data, int datalength)
|
||||
void do_708 (struct lib_cc_decode* ctx, const unsigned char *data, int datalength)
|
||||
{
|
||||
/* Note: The data has this format:
|
||||
/* Note: The data has this format:
|
||||
1 byte for cc_valid
|
||||
1 byte for cc_type
|
||||
2 bytes for the actual data */
|
||||
@@ -1198,7 +1203,7 @@ void do_708 (const unsigned char *data, int datalength)
|
||||
case 2:
|
||||
ccx_common_logging.debug_ftn (CCX_DMT_708, "708: DTVCC Channel Packet Data\n");
|
||||
if (cc_valid==0) // This ends the previous packet
|
||||
process_current_packet();
|
||||
process_current_packet(ctx);
|
||||
else
|
||||
{
|
||||
if (current_packet_length>253)
|
||||
@@ -1214,7 +1219,7 @@ void do_708 (const unsigned char *data, int datalength)
|
||||
break;
|
||||
case 3:
|
||||
ccx_common_logging.debug_ftn (CCX_DMT_708, "708: DTVCC Channel Packet Start\n");
|
||||
process_current_packet();
|
||||
process_current_packet(ctx);
|
||||
if (cc_valid)
|
||||
{
|
||||
if (current_packet_length>127)
|
||||
|
||||
@@ -291,6 +291,8 @@ typedef struct cc708_service_decoder
|
||||
char *filename; // Where we are going to write our output
|
||||
int fh; // Handle to output file. -1 if not yet open
|
||||
int srt_counter;
|
||||
enum ccx_output_format output_format; // What kind of output format should be used?
|
||||
LLONG subs_delay; // ms to delay (or advance) subs
|
||||
}
|
||||
cc708_service_decoder;
|
||||
|
||||
@@ -299,7 +301,7 @@ extern int cea708services[]; // [] -> 1 for services to be processed
|
||||
|
||||
extern int resets_708;
|
||||
|
||||
void do_708 (const unsigned char *data, int datalength);
|
||||
void do_708 (struct lib_cc_decode* ctx, const unsigned char *data, int datalength);
|
||||
|
||||
unsigned char get_internal_from_G0 (unsigned char g0_char);
|
||||
unsigned char get_internal_from_G1 (unsigned char g1_char);
|
||||
|
||||
@@ -19,9 +19,6 @@ unsigned int encoded_crlf_length;
|
||||
unsigned char encoded_br[16];
|
||||
unsigned int encoded_br_length;
|
||||
|
||||
void ccx_decoders_common_settings_init(LLONG subs_delay, enum ccx_output_format output_format){
|
||||
}
|
||||
|
||||
LLONG minimum_fts = 0; // No screen should start before this FTS
|
||||
|
||||
/* This function returns a FTS that is guaranteed to be at least 1 ms later than the end of the previous screen. It shouldn't be needed
|
||||
@@ -253,7 +250,7 @@ int do_cb (struct lib_cc_decode *ctx, unsigned char *cc_block, struct cc_subtitl
|
||||
if (timeok)
|
||||
{
|
||||
if(ctx->write_format!=CCX_OF_RCWT)
|
||||
do_708 ((const unsigned char *) temp, 4);
|
||||
do_708 (ctx,(const unsigned char *) temp, 4);
|
||||
else
|
||||
writercwtdata(ctx, cc_block);
|
||||
}
|
||||
@@ -289,7 +286,9 @@ struct lib_cc_decode* init_cc_decode (struct ccx_decoders_common_settings_t *set
|
||||
ccx_options.trim_subs,
|
||||
ccx_options.encoding,
|
||||
&ctx->processed_enough,
|
||||
setting->cc_to_stdout
|
||||
setting->cc_to_stdout,
|
||||
setting->subs_delay,
|
||||
setting->write_format
|
||||
);
|
||||
ctx->context_cc608_field_2 = ccx_decoder_608_init_library(
|
||||
ccx_options.settings_608,
|
||||
@@ -298,11 +297,14 @@ struct lib_cc_decode* init_cc_decode (struct ccx_decoders_common_settings_t *set
|
||||
ccx_options.trim_subs,
|
||||
ccx_options.encoding,
|
||||
&ctx->processed_enough,
|
||||
setting->cc_to_stdout
|
||||
setting->cc_to_stdout,
|
||||
setting->subs_delay,
|
||||
setting->write_format
|
||||
);
|
||||
|
||||
ctx->fix_padding = setting->fix_padding;
|
||||
ctx->write_format = setting->write_format;
|
||||
ctx->subs_delay = setting->subs_delay;
|
||||
ctx->wbout1 = setting->wbout1;
|
||||
return ctx;
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ struct lib_cc_decode
|
||||
enum ccx_output_format write_format; // 0=Raw, 1=srt, 2=SMI
|
||||
struct ccx_boundary_time extraction_start, extraction_end; // Segment we actually process
|
||||
void *wbout1;
|
||||
LLONG subs_delay; // ms to delay (or advance) subs
|
||||
};
|
||||
extern struct ccx_decoders_common_settings_t ccx_decoders_common_settings;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include "ccx_common_option.h"
|
||||
|
||||
struct ccx_common_logging_t ccx_common_logging;
|
||||
struct ccx_decoders_common_settings_t ccx_decoders_common_settings;
|
||||
static struct ccx_decoders_common_settings_t *init_decoder_setting(
|
||||
struct ccx_s_options *opt)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user