From 5e734593c0c97a8f3929f1cf5634642590c70b11 Mon Sep 17 00:00:00 2001 From: Ari Koivula Date: Thu, 21 Jan 2016 15:08:34 +0200 Subject: [PATCH] Add psnr argument to CLI To disable calculation of PSNR for frames, printing 0.0dB instead. --- README.md | 1 + configure.ac | 6 ++++-- src/cli.c | 3 +++ src/config.c | 3 +++ src/encmain.c | 4 +++- src/kvazaar.h | 5 ++++- 6 files changed, 18 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index bb339305..9e9710bc 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,7 @@ http://ultravideo.cs.tut.fi/#encoder for more information. --preset : Use preset. This will override previous options. ultrafast, superfast,veryfast, faster, fast, medium, slow, slower, veryslow, placebo + --no-psnr : Don't calculate PSNR for frames Video Usability Information: --sar : Specify Sample Aspect Ratio diff --git a/configure.ac b/configure.ac index e80542a9..bcf015a3 100644 --- a/configure.ac +++ b/configure.ac @@ -14,14 +14,16 @@ AC_CONFIG_SRCDIR([src/encmain.c]) # - Increment when ABI changes, meaning lib users need to be recompiled. # - ABI changes when anything existing gets modified, including sizes of structs. # minor: -# - Increment when only API changes. Because the function pointers are in a struct, that means basically never? +# - Increment when only API changes in a backwards compatible way without breaking ABI. +# - We count adding parameters to bottom of kvz_config as ABI compatible, because user +# shouldn't copy that struct or care about it's size. # - If not sure, increment major instead. # release: # - Increment when making new releases and major or minor was not changed since last release. # # Here is a somewhat sane guide to lib versioning: http://apr.apache.org/versioning.html ver_major=3 -ver_minor=0 +ver_minor=1 ver_release=0 # not used, but it prevents configure from adding a lot of defines to the CFLAGS diff --git a/src/cli.c b/src/cli.c index 755e2c55..7ff081ee 100644 --- a/src/cli.c +++ b/src/cli.c @@ -97,6 +97,8 @@ static const struct option long_options[] = { { "preset", required_argument, NULL, 0 }, { "mv-rdo", no_argument, NULL, 0 }, { "no-mv-rdo", no_argument, NULL, 0 }, + { "psnr", no_argument, NULL, 0 }, + { "no-psnr", no_argument, NULL, 0 }, {0, 0, 0, 0} }; @@ -337,6 +339,7 @@ void print_help(void) " --preset : Use preset\n" " ultrafast, superfast,veryfast, faster,\n" " fast, medium, slow, slower, veryslow, placebo\n" + " --no-psnr : Don't calculate PSNR for frames\n" "\n" " Video Usability Information:\n" " --sar : Specify Sample Aspect Ratio\n" diff --git a/src/config.c b/src/config.c index c37a44ad..a1965833 100644 --- a/src/config.c +++ b/src/config.c @@ -100,6 +100,7 @@ int kvz_config_init(kvz_config *cfg) cfg->pu_depth_intra.max = 4; // 0-4 cfg->add_encoder_info = true; + cfg->calc_psnr = true; return 1; } @@ -756,6 +757,8 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value) } else if OPT("mv-rdo") cfg->mv_rdo = atobool(value); + else if OPT("psnr") + cfg->calc_psnr = (bool)atobool(value); else return 0; #undef OPT diff --git a/src/encmain.c b/src/encmain.c index 16a214c4..39fdfa88 100644 --- a/src/encmain.c +++ b/src/encmain.c @@ -298,7 +298,9 @@ int main(int argc, char *argv[]) // Compute and print stats. double frame_psnr[3] = { 0.0, 0.0, 0.0 }; - compute_psnr(img_src, img_rec, frame_psnr); + if (encoder->cfg->calc_psnr) { + compute_psnr(img_src, img_rec, frame_psnr); + } if (recout) { // Since chunks_out was not NULL, img_rec should have been set. diff --git a/src/kvazaar.h b/src/kvazaar.h index 144a1e72..052952d4 100644 --- a/src/kvazaar.h +++ b/src/kvazaar.h @@ -108,7 +108,9 @@ typedef struct kvz_gop_config { /** * \brief Struct which contains all configuration data * - * Function config_alloc in kvz_api must be used for allocation. + * Functions config_alloc, config_init and config_destroy must be used to + * maintain ABI compatibility. Do not copy this struct, as the size might + * change. */ typedef struct kvz_config { @@ -190,6 +192,7 @@ typedef struct kvz_config int32_t target_bitrate; int8_t mv_rdo; /*!< \brief MV RDO calculation in search (0: estimation, 1: RDO). */ + int8_t calc_psnr; /*!< \since 3.1.0 \brief Print PSNR in CLI. */ } kvz_config; /**