mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2024-12-24 20:01:42 +00:00
logic to devide time between frames
This commit is contained in:
parent
5371f854fc
commit
0f06f47ab4
52
src/608.c
52
src/608.c
@ -1,5 +1,6 @@
|
||||
#include "ccextractor.h"
|
||||
#include "608_spupng.h"
|
||||
#include "cc_decoders_common.h"
|
||||
|
||||
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
|
||||
@ -477,7 +478,18 @@ struct eia608_screen *get_current_visible_buffer(struct s_context_cc608 *context
|
||||
int write_cc_buffer(struct s_context_cc608 *context)
|
||||
{
|
||||
struct eia608_screen *data;
|
||||
struct cc_subtitle *sub = NULL;
|
||||
int wrote_something=0;
|
||||
LLONG start_time;
|
||||
LLONG end_time;
|
||||
|
||||
if(!context->sub)
|
||||
{
|
||||
sub =
|
||||
context->sub = malloc(sizeof(struct cc_subtitle));
|
||||
}
|
||||
else
|
||||
sub = context->sub;
|
||||
if (ccx_options.screens_to_process!=-1 &&
|
||||
context->screenfuls_counter >= ccx_options.screens_to_process)
|
||||
{
|
||||
@ -490,12 +502,45 @@ int write_cc_buffer(struct s_context_cc608 *context)
|
||||
else
|
||||
data = &context->buffer2;
|
||||
|
||||
if (context->mode == MODE_FAKE_ROLLUP_1 && // Use the actual start of data instead of last buffer change
|
||||
context->ts_start_of_current_line != -1)
|
||||
start_time = context->ts_start_of_current_line;
|
||||
else
|
||||
start_time = context->current_visible_start_ms;
|
||||
|
||||
end_time = get_visible_end() + subs_delay;
|
||||
|
||||
if (!data->empty)
|
||||
{
|
||||
if (context->mode == MODE_FAKE_ROLLUP_1 && // Use the actual start of data instead of last buffer change
|
||||
context->ts_start_of_current_line != -1)
|
||||
context->current_visible_start_ms = context->ts_start_of_current_line;
|
||||
sub->data = (struct eia608_screen *) realloc(sub->data,sub->size + sizeof(*data));
|
||||
|
||||
memcpy(sub->data + sub->size, data, sizeof(*data));
|
||||
sub->size += sizeof(*data);
|
||||
wrote_something = 1;
|
||||
if(start_time < end_time)
|
||||
{
|
||||
int i = 0;
|
||||
int nb_data = sub->size/sizeof(*data);
|
||||
for(i = 0; i < nb_data; i++)
|
||||
{
|
||||
data = sub->data + (i * sizeof(*data) );
|
||||
data->start_time = start_time + ( ( (end_time - start_time)/nb_data ) * i );
|
||||
data->end_time = start_time + ( ( (end_time - start_time)/nb_data ) * (i + 1) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
data = sub->data;
|
||||
data->start_time = 0;
|
||||
data->end_time = 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
for(data = sub->data; sub->size ; sub->size -= sizeof(struct eia608_screen))
|
||||
{
|
||||
if(!data->start_time)
|
||||
break;
|
||||
new_sentence=1;
|
||||
switch (ccx_options.write_format)
|
||||
{
|
||||
@ -528,6 +573,7 @@ int write_cc_buffer(struct s_context_cc608 *context)
|
||||
|
||||
if (ccx_options.gui_mode_reports)
|
||||
write_cc_buffer_to_gui(data, context);
|
||||
data = sub->data + sizeof(struct eia608_screen);
|
||||
}
|
||||
return wrote_something;
|
||||
}
|
||||
|
@ -18,7 +18,9 @@ struct eia608_screen // A CC buffer
|
||||
unsigned char colors[15][33];
|
||||
unsigned char fonts[15][33]; // Extra char at the end for a 0
|
||||
int row_used[15]; // Any data in row?
|
||||
int empty; // Buffer completely empty?
|
||||
int empty; // Buffer completely empty?
|
||||
LLONG start_time;
|
||||
LLONG end_time;
|
||||
};
|
||||
|
||||
struct s_context_cc608
|
||||
@ -44,6 +46,7 @@ struct s_context_cc608
|
||||
long bytes_processed_608; // To be written ONLY by process_608
|
||||
struct ccx_s_write *out;
|
||||
int have_cursor_position;
|
||||
struct cc_subtitle *sub;
|
||||
};
|
||||
|
||||
extern unsigned char *enc_buffer;
|
||||
|
@ -71,7 +71,7 @@ int write_cc_buffer_as_srt(struct eia608_screen *data, struct s_context_cc608 *c
|
||||
unsigned h2,m2,s2,ms2;
|
||||
LLONG ms_start, ms_end;
|
||||
int wrote_something = 0;
|
||||
ms_start = context->current_visible_start_ms;
|
||||
ms_start = data->start_time;
|
||||
|
||||
int prev_line_start=-1, prev_line_end=-1; // Column in which the previous line started and ended, for autodash
|
||||
int prev_line_center1=-1, prev_line_center2=-1; // Center column of previous line text
|
||||
@ -91,7 +91,7 @@ int write_cc_buffer_as_srt(struct eia608_screen *data, struct s_context_cc608 *c
|
||||
if (ms_start<0) // Drop screens that because of subs_delay start too early
|
||||
return 0;
|
||||
|
||||
ms_end=get_visible_end()+subs_delay;
|
||||
ms_end = data->end_time;
|
||||
|
||||
mstotime (ms_start,&h1,&m1,&s1,&ms1);
|
||||
mstotime (ms_end-1,&h2,&m2,&s2,&ms2); // -1 To prevent overlapping with next line.
|
||||
|
10
src/cc_decoders_common.h
Normal file
10
src/cc_decoders_common.h
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef _CC_DECODER_COMMON
|
||||
#define _CC_DECODER_COMMON
|
||||
|
||||
struct cc_subtitle
|
||||
{
|
||||
void *data;
|
||||
size_t size;
|
||||
enum ccx_encoding_type format;
|
||||
};
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user