mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-21 22:40:30 +00:00
print rather err msg on wrong unit_evaluate(_dbl) val
Use an user-friendlier error message than assert.
This commit is contained in:
@@ -137,6 +137,9 @@ static struct audio_codec_state *audio_codec_init_real(const char *audio_codec_c
|
||||
audio_codec_direction_t direction, bool silent) {
|
||||
audio_codec_t audio_codec = get_audio_codec(audio_codec_cfg);
|
||||
int bitrate = get_audio_codec_bitrate(audio_codec_cfg);
|
||||
if (bitrate < 0) {
|
||||
return nullptr;
|
||||
}
|
||||
void *state = NULL;
|
||||
const struct audio_compress_info *aci = nullptr;
|
||||
|
||||
@@ -385,7 +388,10 @@ int get_audio_codec_bitrate(const char *audio_codec_cfg)
|
||||
char *val = get_val_from_cfg(audio_codec_cfg, "bitrate=");
|
||||
if (val) {
|
||||
long long ret = unit_evaluate(val);
|
||||
assert(ret > 0 && ret <= INT_MAX);
|
||||
if (ret <= 0 && ret > INT_MAX) {
|
||||
LOG(LOG_LEVEL_ERROR) << "Wrong bitrate: " << val << "\n";
|
||||
return -1;
|
||||
}
|
||||
free(val);
|
||||
return ret;
|
||||
} else {
|
||||
|
||||
@@ -658,7 +658,10 @@ static int parse_fmt(int argc, char **argv, struct cmdline_parameters *parsed)
|
||||
parsed->hosts[host_idx].bitrate = RATE_AUTO;
|
||||
} else {
|
||||
parsed->hosts[host_idx].bitrate = unit_evaluate(argv[i + 1]);
|
||||
assert(parsed->hosts[host_idx].bitrate > 0);
|
||||
if (parsed->hosts[host_idx].bitrate <= 0) {
|
||||
LOG(LOG_LEVEL_FATAL) << MOD_NAME << "Error: wrong bitrate - " << argv[i + 1] << "\n";
|
||||
exit(EXIT_FAIL_USAGE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '4':
|
||||
|
||||
@@ -538,8 +538,12 @@ static bool parse_audio_capture_format(const char *optarg)
|
||||
}
|
||||
audio_capture_bps = bps / 8;
|
||||
} else if (strncmp(item, "sample_rate=", strlen("sample_rate=")) == 0) {
|
||||
long long val = unit_evaluate(item + strlen("sample_rate="));
|
||||
assert(val > 0 && val <= numeric_limits<decltype(audio_capture_sample_rate)>::max());
|
||||
const char *sample_rate_str = item + strlen("sample_rate=");
|
||||
long long val = unit_evaluate(sample_rate_str);
|
||||
if (val <= 0 || val > numeric_limits<decltype(audio_capture_sample_rate)>::max()) {
|
||||
LOG(LOG_LEVEL_ERROR) << "Invalid sample_rate " << sample_rate_str << "!\n";
|
||||
return false;
|
||||
}
|
||||
audio_capture_sample_rate = val;
|
||||
} else {
|
||||
log_msg(LOG_LEVEL_ERROR, "Unkonwn format for --audio-capture-format!\n");
|
||||
|
||||
@@ -290,10 +290,6 @@ static struct module * j2k_compress_init(struct module *parent, const char *c_cf
|
||||
tmp = NULL;
|
||||
if (strncasecmp("rate=", item, strlen("rate=")) == 0) {
|
||||
bitrate = unit_evaluate(item + strlen("rate="));
|
||||
if (bitrate <= 0) {
|
||||
log_msg(LOG_LEVEL_ERROR, "[J2K] Wrong bitrate!\n");
|
||||
return NULL;
|
||||
}
|
||||
} else if (strncasecmp("quality=", item, strlen("quality=")) == 0) {
|
||||
quality = atof(item + strlen("quality="));
|
||||
} else if (strcasecmp("mct", item) == 0 || strcasecmp("nomct", item) == 0) {
|
||||
@@ -311,7 +307,11 @@ static struct module * j2k_compress_init(struct module *parent, const char *c_cf
|
||||
log_msg(LOG_LEVEL_ERROR, "[J2K] Wrong option: %s\n", item);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (bitrate <= 0 || mem_limit <= 0 || tile_limit <= 0) {
|
||||
log_msg(LOG_LEVEL_ERROR, "[J2K] Wrong bitrate, mem_limit or tile_limit!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
s = new state_video_compress_j2k(bitrate, pool_size, mct);
|
||||
|
||||
@@ -406,7 +406,10 @@ static int parse_fmt(struct state_video_compress_libav *s, char *fmt) {
|
||||
} else if(strncasecmp("bpp=", item, strlen("bpp=")) == 0) {
|
||||
char *bpp_str = item + strlen("bpp=");
|
||||
s->requested_bpp = unit_evaluate_dbl(bpp_str);
|
||||
assert(!std::isnan(s->requested_bpp));
|
||||
if (std::isnan(s->requested_bpp)) {
|
||||
LOG(LOG_LEVEL_ERROR) << MOD_NAME "Wrong bitrate: " << bpp_str << "\n";
|
||||
return -1;
|
||||
}
|
||||
} else if(strncasecmp("crf=", item, strlen("crf=")) == 0) {
|
||||
char *crf_str = item + strlen("crf=");
|
||||
s->requested_crf = atof(crf_str);
|
||||
|
||||
Reference in New Issue
Block a user