parse_bitrate: use map for special vals

This commit is contained in:
Martin Pulec
2022-07-18 15:34:27 +02:00
parent f42cafcedf
commit 03f70eadef

View File

@@ -503,8 +503,13 @@ static void *capture_thread(void *arg)
}
static bool parse_bitrate(char *optarg, long long int *bitrate) {
if (strcmp(optarg, "auto") == 0) {
*bitrate = RATE_AUTO;
map<const char *, long long int> bitrate_spec_map = {
{ "auto", RATE_AUTO },
{ "unlimited", RATE_UNLIMITED },
};
if (auto it = bitrate_spec_map.find(optarg); it != bitrate_spec_map.end()) {
*bitrate = it->second;
return true;
}
if (strcmp(optarg, "help") == 0) {
@@ -519,10 +524,6 @@ static bool parse_bitrate(char *optarg, long long int *bitrate) {
"\n";
return true;
}
if (strcmp(optarg, "unlimited") == 0) {
*bitrate = RATE_UNLIMITED;
return true;
}
bool force = false, fixed = false;
for (int i = 0; i < 2; ++i) {
if (optarg[strlen(optarg) - 1] == '!' ||