From 0a8467b01fd89b1dffd3c90052e9ffeb72eea6f2 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Thu, 12 Sep 2024 16:01:35 +0200 Subject: [PATCH] vcomp/cmpto_j2k: print opt hint in help + use unit_evaluate_dbl (instead of unit_evaluate) - **also** in decompress --- src/utils/misc.cpp | 2 +- src/video_compress/cmpto_j2k.cpp | 4 +++- src/video_decompress/cmpto_j2k.cpp | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/utils/misc.cpp b/src/utils/misc.cpp index 88ca12ee9..53854e747 100644 --- a/src/utils/misc.cpp +++ b/src/utils/misc.cpp @@ -92,7 +92,7 @@ unit_evaluate(const char *str, const char **endptr) * Converts units in format [.][kMG] to floating point representation. * * @param str string to be parsed, suffix following SI suffix is ignored (as in 1ms or 100MB) - * @param case_sensitive should 'm' be considered as mega + * @param case_sensitive if true 'm' will be considered as milli, otherwise mega * @param endptr if not NULL, point to suffix after parse * @returns positive floating point representation of the string * @returns NAN if error diff --git a/src/video_compress/cmpto_j2k.cpp b/src/video_compress/cmpto_j2k.cpp index 9cf934b5b..9e1bb645b 100644 --- a/src/video_compress/cmpto_j2k.cpp +++ b/src/video_compress/cmpto_j2k.cpp @@ -483,11 +483,13 @@ static void usage() { << " - use CPU for pixfmt conversion (useful if GPU\n\t\tis fully " "occupied by the encoder; an option for decoder exists as " "well)\n"; + color_printf("\nOption prefixes (eg. 'q=' for quality) can be used. SI " + "suffixes are recognized (eg. 'r=7.5M').\n"); } #define ASSIGN_CHECK_VAL(var, str, minval) \ do { \ - long long val = unit_evaluate(str, nullptr); \ + long long val = unit_evaluate_dbl(str, false, nullptr); \ if (val < (minval) || val > UINT_MAX) { \ LOG(LOG_LEVEL_ERROR) \ << "[J2K] Wrong value " << (str) \ diff --git a/src/video_decompress/cmpto_j2k.cpp b/src/video_decompress/cmpto_j2k.cpp index f0c77c7ce..f39ec0d0d 100644 --- a/src/video_decompress/cmpto_j2k.cpp +++ b/src/video_decompress/cmpto_j2k.cpp @@ -242,8 +242,8 @@ static void * j2k_decompress_init(void) auto *s = new state_decompress_j2k(queue_len, encoder_in_frames); if (get_commandline_param("j2k-dec-mem-limit") != nullptr) { - s->req_mem_limit = unit_evaluate( - get_commandline_param("j2k-dec-mem-limit"), nullptr); + s->req_mem_limit = unit_evaluate_dbl( + get_commandline_param("j2k-dec-mem-limit"), false, nullptr); } if (get_commandline_param("j2k-dec-tile-limit") != nullptr) {