diff --git a/src/lib_ccx/lib_ccx.c b/src/lib_ccx/lib_ccx.c index da33d4de..24fc35f6 100644 --- a/src/lib_ccx/lib_ccx.c +++ b/src/lib_ccx/lib_ccx.c @@ -276,6 +276,15 @@ struct lib_cc_decode *update_decoder_list(struct lib_ccx_ctx *ctx) if (!dec_ctx) fatal(EXIT_NOT_ENOUGH_MEMORY, "update_decoder_list: init_cc_decode failed. Not enough memory.\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; } @@ -311,6 +320,15 @@ 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 @@ -320,16 +338,6 @@ 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) ); } - if (cinfo) - { - dec_ctx->prev = NULL; - dec_ctx->dec_sub.prev = NULL; - if (cinfo->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; } @@ -388,6 +396,17 @@ 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 @@ -418,15 +437,6 @@ struct encoder_ctx *update_encoder_list_cinfo(struct lib_ccx_ctx *ctx, struct ca freep(&ccx_options.enc_cfg.output_filename); } freep(&extension); - if (cinfo) - { - enc_ctx->prev = NULL; - if (cinfo->codec == CCX_CODEC_DVB) - { - enc_ctx->write_previous = 0; - enc_ctx->prev = malloc(sizeof(struct encoder_ctx)); - } - } return enc_ctx; }