Merge pull request #1246 from anshul1912/master

put check for DVB duration with pagetimeout
This commit is contained in:
Anshul Maheshwari
2020-03-30 22:35:04 +05:30
committed by GitHub
3 changed files with 18 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
0.89 (TBD)
-----------------
- Fix: Timing in DVB, sub duration check for timeout.
- New: Added support for SCC and CCD encoder formats
- New: Added support to output captions to MCC file (#733).
- New: Add support for censoring words ("Kid Friendly") (#1139)

View File

@@ -58,7 +58,9 @@ struct cc_subtitle
/** Encoding type of Text, must be ignored in case of subtype as bitmap or cc_screen*/
enum ccx_encoding_type enc_type;
/* set only when all the data is to be displayed at same time */
/* set only when all the data is to be displayed at same time
* Unit is of time is ms
*/
LLONG start_time;
LLONG end_time;
@@ -74,6 +76,9 @@ struct cc_subtitle
char mode[5];
char info[4];
/** Used for DVB end time in ms */
int time_out;
struct cc_subtitle *next;
struct cc_subtitle *prev;
};

View File

@@ -178,7 +178,8 @@ typedef struct DVBSubContext
int ancillary_id;
int lang_index;
int version;
int time_out;
/* Store time in ms */
LLONG time_out;
#ifdef ENABLE_OCR
void *ocr_ctx;
#endif
@@ -1375,8 +1376,8 @@ static void dvbsub_parse_page_segment(void *dvb_ctx, const uint8_t *buf,
{
return;
}
ctx->time_out = timeout;
/* Convert time from second to ms */
ctx->time_out = timeout * 1000;
ctx->version = version;
if (page_state == 1 || page_state == 2)
@@ -1678,13 +1679,18 @@ void dvbsub_handle_display_segment(struct encoder_ctx *enc_ctx,
struct lib_cc_decode *dec_ctx,
struct cc_subtitle *sub)
{
DVBSubContext *ctx = (DVBSubContext *)dec_ctx->private_data;
if (!enc_ctx)
return;
if (enc_ctx->write_previous) //this condition is used for the first subtitle - write_previous will be 0 first so we don't encode a non-existing previous sub
{
enc_ctx->prev->last_string = NULL; // Reset last recognized sub text
sub->prev->end_time = (dec_ctx->timing->current_pts - dec_ctx->timing->min_pts) / (MPEG_CLOCK_FREQ / 1000); //we set the end time of the previous sub the current pts
encode_sub(enc_ctx->prev, sub->prev); //we encode it
if (sub->prev->time_out < sub->prev->end_time - sub->prev->start_time)
{
sub->prev->end_time = sub->prev->start_time + sub->prev->time_out;
}
encode_sub(enc_ctx->prev, sub->prev); //we encode it
enc_ctx->last_string = enc_ctx->prev->last_string; // Update last recognized string (used in Matroska)
enc_ctx->prev->last_string = NULL;
@@ -1712,6 +1718,7 @@ void dvbsub_handle_display_segment(struct encoder_ctx *enc_ctx,
memcpy(dec_ctx->prev->private_data, dec_ctx->private_data, sizeof(struct DVBSubContext));
/* copy previous subtitle */
free_subtitle(sub->prev);
sub->time_out = ctx->time_out;
sub->prev = NULL;
sub->prev = copy_subtitle(sub);
sub->prev->start_time = (dec_ctx->timing->current_pts - dec_ctx->timing->min_pts) / (MPEG_CLOCK_FREQ / 1000); //we set the start time of the previous sub the current pts