Add psnr argument to CLI

To disable calculation of PSNR for frames, printing 0.0dB instead.
This commit is contained in:
Ari Koivula 2016-01-21 15:08:34 +02:00
parent ff3dea7385
commit 5e734593c0
6 changed files with 18 additions and 4 deletions

View file

@ -79,6 +79,7 @@ http://ultravideo.cs.tut.fi/#encoder for more information.
--preset <string> : 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 <width:height> : Specify Sample Aspect Ratio

View file

@ -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

View file

@ -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 <string> : 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 <width:height> : Specify Sample Aspect Ratio\n"

View file

@ -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

View file

@ -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.

View file

@ -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;
/**