From 97863cdaa26c1373767dd74d460cf1a46f248a22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arttu=20Yl=C3=A4-Outinen?= Date: Mon, 31 Oct 2016 11:33:14 +0900 Subject: [PATCH] Fail encoder init when CQM file cannot be opened --- src/encoder.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/encoder.c b/src/encoder.c index 0f5cb9fa..82360680 100644 --- a/src/encoder.c +++ b/src/encoder.c @@ -203,16 +203,18 @@ encoder_control_t* kvz_encoder_control_init(kvz_config *const cfg) { kvz_scalinglist_init(&encoder->scaling_list); // CQM - { - FILE* cqmfile; - cqmfile = cfg->cqmfile ? fopen(cfg->cqmfile, "rb") : NULL; + if (cfg->cqmfile) { + FILE* cqmfile = fopen(cfg->cqmfile, "rb"); if (cqmfile) { kvz_scalinglist_parse(&encoder->scaling_list, cqmfile); fclose(cqmfile); + } else { + fprintf(stderr, "Could not open CQM file.\n"); + goto init_failed; } } kvz_scalinglist_process(&encoder->scaling_list, encoder->bitdepth); - + kvz_encoder_control_input_init(encoder, cfg->width, cfg->height); if (cfg->framerate_num != 0) {