Repository navigation
Conversation
lusoris
force-pushed
the
fix/cli-model-path-drive-letter
branch
3 times, most recently
from
October 2, 2026 18:43
0a20183 to
27236ff
Compare
parse_model_config() splits the --model argument on every ':', so a Windows path such as path=C:\models\vmaf_v0.6.1.json or path=C:/models/vmaf_v0.6.1.json was cut at the drive letter and failed with 'Problem parsing model, bad option string "\models\...".' Split with a small helper, next_option(), that does not end the option at a colon which follows '=' and a single letter and is followed by '\' or '/'. An option key never starts with a path separator, so a one-letter value followed by another option (name=a:path=/x) still splits, and every string that parsed before parses the same way. Add cli_parse tests: drive-letter path alone, with options before and after it, forward and back slash, one-letter values that must still split, and existing option strings.
lusoris
force-pushed
the
fix/cli-model-path-drive-letter
branch
from
October 7, 2026 10:03
27236ff to
c743d9f
Compare
Author
|
Rebased onto acdd937; the new head is c743d9f. libvmaf/tools/cli_parse.c merged cleanly. The conflict was in libvmaf/test/test_cli_parse.c, where the per-input colorimetry tests were added; the new tests are placed after upstream's tests and the colorimetry tests are unchanged, including the ones under VMAF_BUILT_IN_MODELS. Release build with checkasm: all 27 meson tests pass, and test_cli_parse runs 19 tests (upstream's 15 and this PR's 4), all passing. ASan/UBSan build: 23 pass and 4 fail (test_predict, checkasm, test_read_pictures_convert, test_pic_preallocation); the same 4 fail on unpatched master acdd937. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
vmaf --model path=C:\dir\model.jsonandpath=C:/dir/model.jsonfail because the colon after the drive letter is taken as an option separator. This keeps that colon inside the path. Addresses #761.Cause
parse_model_config()inlibvmaf/tools/cli_parse.csplits the--modelargument withstrsep(&optarg_copy, ":"). The colon of a drive letter therefore ends thepath=option, and the rest of the path is parsed as a new option. Forward slashes make no difference.Reproducer
Master
6ec23e8f2(reproduced there; the code is unchanged in 9e48141), release build. The parse step does not depend on the file existing, and on Linux a directory namedC:is legal, so the same path form can be loaded for real:-margumentpath=C:/models/vmaf_v0.6.1.jsonProblem parsing model, bad option string "/models/vmaf_v0.6.1.json"., exit 1vmafmean 82.564227 (first 3 frames of src01), exit 0path=C:/models/vmaf_v0.6.1.json:name=xxname=a:path=C:/models/vmaf_v0.6.1.jsonapath=C:\models\vmaf_v0.6.1.jsonbad option string "\models\vmaf_v0.6.1.json"could not read model from path: "C:\models\vmaf_v0.6.1.json"(the full string reaches the loader)Fix
A small helper,
next_option(), replaces thatstrsep()call. It ends an option at the next colon, except a colon that follows=plus a single letter and is followed by\or/: that one is the drive-letter colon of the value and stays in it.Strings that parsed before parse the same way: an option key never starts with
/or\, so a one-letter value followed by the next option (name=a:path=/x.json,path=m:name=b) still splits. Only a string that previously failed to parse changes meaning.Not covered: a drive-relative path (
path=C:model.json, no separator after the colon) still splits at the colon, andparse_feature_config()uses the samestrsep()for--featureoption strings and is left alone (a path option of a feature such ascambi'sheatmaps_pathwould meet the same problem on Windows). This PR is limited to--model.Tests
Four cases added to
libvmaf/test/test_cli_parse.c, which callcli_parse()with--modeland checkpath,name, flags and overloads:C:\...,C:/..., lowercased:\...,Z:/...;name=,disable_clip,enable_transform, a feature overloadvif.vif_enhn_gain_limit=1.5);name=a:path=/tmp/vmaf.json,path=m:name=b:disable_clip;version=...:name=...:disable_clip:enable_transform,path=model/vmaf_v0.6.1.json:name=rel,path=/opt/vmaf/model.json.On master's
cli_parse.cthe new tests fail:test_model_path_drive_letterexits through the usage error above. With this changetest_cli_parsepasses 11/11, also under ASan/UBSan with leak detection.Validation
x86-64 Linux, GCC 16.2.1, on master
9e48141b. Rebased on master 9e48141 (2026-10-02).meson test(-Denable_float=true -Denable_checkasm=true): 25/25 on master, 25/25 here.-Db_sanitize=address,undefined -Db_lto=falsebuild: 22 pass and 3 fail on master, 22 pass and 3 fail here;test_predictandtest_pic_preallocationfail on LeakSanitizer reports andcheckasmaborts on aheap-buffer-overflowinadm_dwt2_16(integer_adm.c:2603on master), on both, and this change does not touch them.Not tested: Windows itself. I have not run
vmaf.exeor a Windows build. The parse logic is plain C on the argument string and was exercised on Linux only, with theC:directory above and the unit tests, which feed the same strings throughcli_parse().The workflow run on this PR needs a maintainer's approval.