Fixed DVB multiprogram (timing is still broken)

This commit is contained in:
AlexBratosin2001 2017-01-11 22:30:39 +02:00
parent 591d74d0c5
commit ade11eb80f
3 changed files with 33 additions and 28 deletions

View File

@ -976,6 +976,10 @@ int general_loop(struct lib_ccx_ctx *ctx)
data_node = get_data_stream(datalist, cinfo->pid);
}
enc_ctx = update_encoder_list_cinfo(ctx, cinfo);
dec_ctx = update_decoder_list_cinfo(ctx, cinfo);
dec_ctx->dtvcc->encoder = (void *)enc_ctx; //WARN: otherwise cea-708 will not work
if (!set_pts && dec_ctx->codec == CCX_CODEC_TELETEXT) //even if there's no sub data, we still need to set the min_pts
{
if (!got_pts && (ctx->demux_ctx->got_important_streams_min_pts[PRIVATE_STREAM_1] != UINT64_MAX || ctx->demux_ctx->got_important_streams_min_pts[AUDIO] != UINT64_MAX || ctx->demux_ctx->got_important_streams_min_pts[VIDEO] != UINT64_MAX)) //it means we got the first pts for either sub, audio or video :)
@ -1010,20 +1014,18 @@ int general_loop(struct lib_ccx_ctx *ctx)
}
if (enc_ctx)
dec_ctx->timing = enc_ctx->timing;
enc_ctx->timing = dec_ctx->timing;
if(!data_node)
if (!data_node)
continue;
enc_ctx = update_encoder_list_cinfo(ctx, cinfo);
dec_ctx = update_decoder_list_cinfo(ctx, cinfo);
dec_ctx->dtvcc->encoder = (void *)enc_ctx; //WARN: otherwise cea-708 will not work
if(data_node->pts != CCX_NOPTS)
set_current_pts(dec_ctx->timing, data_node->pts);
process_data(enc_ctx, dec_ctx, data_node);
}
if (!data_node)
continue;
}
if (ctx->live_stream)
{

View File

@ -322,15 +322,6 @@ struct lib_cc_decode *update_decoder_list_cinfo(struct lib_ccx_ctx *ctx, struct
if (!dec_ctx)
fatal(EXIT_NOT_ENOUGH_MEMORY, "update_decoder_list_cinfo: Not enough memory allocating dec_ctx (multiprogram == false)\n");
list_add_tail( &(dec_ctx->list), &(ctx->dec_ctx_head) );
//DVB related
dec_ctx->prev = NULL;
dec_ctx->dec_sub.prev = NULL;
if (dec_ctx->codec == CCX_CODEC_DVB)
{
dec_ctx->prev = malloc(sizeof(struct lib_cc_decode));
dec_ctx->dec_sub.prev = malloc(sizeof(struct cc_subtitle));
}
}
}
else
@ -340,6 +331,15 @@ struct lib_cc_decode *update_decoder_list_cinfo(struct lib_ccx_ctx *ctx, struct
fatal(EXIT_NOT_ENOUGH_MEMORY, "update_decoder_list_cinfo: Not enough memory allocating dec_ctx ((multiprogram == true)\n");
list_add_tail( &(dec_ctx->list), &(ctx->dec_ctx_head) );
}
//DVB related
dec_ctx->prev = NULL;
dec_ctx->dec_sub.prev = NULL;
if (dec_ctx->codec == CCX_CODEC_DVB)
{
dec_ctx->prev = malloc(sizeof(struct lib_cc_decode));
dec_ctx->dec_sub.prev = malloc(sizeof(struct cc_subtitle));
}
return dec_ctx;
}
@ -398,17 +398,6 @@ struct encoder_ctx *update_encoder_list_cinfo(struct lib_ccx_ctx *ctx, struct ca
if (!enc_ctx)
return NULL;
list_add_tail( &(enc_ctx->list), &(ctx->enc_ctx_head) );
// DVB related
enc_ctx->prev = NULL;
if (cinfo)
{
if (cinfo->codec == CCX_CODEC_DVB)
{
enc_ctx->write_previous = 0;
enc_ctx->prev = malloc(sizeof(struct encoder_ctx));
}
}
}
}
else
@ -438,6 +427,16 @@ struct encoder_ctx *update_encoder_list_cinfo(struct lib_ccx_ctx *ctx, struct ca
freep(&extension);
freep(&ccx_options.enc_cfg.output_filename);
}
// DVB related
enc_ctx->prev = NULL;
if (cinfo)
{
if (cinfo->codec == CCX_CODEC_DVB)
{
enc_ctx->write_previous = 0;
enc_ctx->prev = malloc(sizeof(struct encoder_ctx));
}
}
freep(&extension);
return enc_ctx;
}

View File

@ -688,14 +688,18 @@ uint64_t get_video_min_pts(struct ccx_demuxer *context)
pts = get_pts(payload.start);
}
if (num_of_remembered_pts >= 1 && payload.has_random_access_indicator)
{
got_pts = 1;
break;
}
if (pts != UINT64_MAX)
{
num_of_remembered_pts++;
pts_array = realloc(pts_array, num_of_remembered_pts * sizeof(uint64_t));
((uint64_t*)pts_array)[num_of_remembered_pts - 1] = pts;
}
if (num_of_remembered_pts >= 1 && payload.has_random_access_indicator)
got_pts = 1;
} while (!got_pts);