From ade11eb80fda6dd39c79064914f17068ae37bca3 Mon Sep 17 00:00:00 2001 From: AlexBratosin2001 Date: Wed, 11 Jan 2017 22:30:39 +0200 Subject: [PATCH] Fixed DVB multiprogram (timing is still broken) --- src/lib_ccx/general_loop.c | 14 ++++++++------ src/lib_ccx/lib_ccx.c | 39 +++++++++++++++++++------------------- src/lib_ccx/ts_functions.c | 8 ++++++-- 3 files changed, 33 insertions(+), 28 deletions(-) diff --git a/src/lib_ccx/general_loop.c b/src/lib_ccx/general_loop.c index 74594689..16db8a29 100644 --- a/src/lib_ccx/general_loop.c +++ b/src/lib_ccx/general_loop.c @@ -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) { diff --git a/src/lib_ccx/lib_ccx.c b/src/lib_ccx/lib_ccx.c index 4e52305e..42c12f59 100644 --- a/src/lib_ccx/lib_ccx.c +++ b/src/lib_ccx/lib_ccx.c @@ -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; } diff --git a/src/lib_ccx/ts_functions.c b/src/lib_ccx/ts_functions.c index bb77d845..11a8f2e8 100644 --- a/src/lib_ccx/ts_functions.c +++ b/src/lib_ccx/ts_functions.c @@ -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);