Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Libvmaf Feature request: List of built in models #1128

Open
ThatNerdUKnow opened this issue Nov 30, 2022 · 6 comments
Open

Libvmaf Feature request: List of built in models #1128

ThatNerdUKnow opened this issue Nov 30, 2022 · 6 comments

Comments

@ThatNerdUKnow
Copy link

Hey I'm trying to write a rust wrapper library around libvmaf and I'm stuck on the implementation of VmafModel It seems that I can pass the name of the model into the "version" param of vmaf_model_load but there doesn't seem to be any variable or function I can use to get a list of valid strings that I can pass to this param. I can see that in model.c there seems to be a list of models that are imported alongisde their respective data in a variable called built_in_models which is an array of VmafBuiltInModel Neither VmafBuiltInModel nor built_in_models are exposed in the headers of the library, meaning that my bindgen script can't create definitions for them automatically. The alternative is that I would have to manually keep a list of what models that vmaf includes in my wrapper library which seems fragile

@ThatNerdUKnow
Copy link
Author

Here's the list of built in models i'm referring to in libvmaf/src/model.c

static const VmafBuiltInModel built_in_models[] = {
#if VMAF_BUILT_IN_MODELS
#if VMAF_FLOAT_FEATURES
    {
        .version = "vmaf_float_v0.6.1",
        .data = &src_vmaf_float_v0_6_1_json,
        .data_len = &src_vmaf_float_v0_6_1_json_len,
    },
    {
        .version = "vmaf_float_b_v0.6.3",
        .data = &src_vmaf_float_b_v0_6_3_json,
        .data_len = &src_vmaf_float_b_v0_6_3_json_len,
    },
    {
        .version = "vmaf_float_v0.6.1neg",
        .data = &src_vmaf_float_v0_6_1neg_json,
        .data_len = &src_vmaf_float_v0_6_1neg_json_len,
    },
    {
        .version = "vmaf_float_4k_v0.6.1",
        .data = &src_vmaf_float_4k_v0_6_1_json,
        .data_len = &src_vmaf_float_4k_v0_6_1_json_len,
    },
#endif
    {
        .version = "vmaf_v0.6.1",
        .data = &src_vmaf_v0_6_1_json,
        .data_len = &src_vmaf_v0_6_1_json_len,
    },
    {
        .version = "vmaf_b_v0.6.3",
        .data = &src_vmaf_b_v0_6_3_json,
        .data_len = &src_vmaf_b_v0_6_3_json_len,
    },
    {
        .version = "vmaf_v0.6.1neg",
        .data = &src_vmaf_v0_6_1neg_json,
        .data_len = &src_vmaf_v0_6_1neg_json_len,
    },
    {
        .version = "vmaf_4k_v0.6.1",
        .data = &src_vmaf_4k_v0_6_1_json,
        .data_len = &src_vmaf_4k_v0_6_1_json_len,
    },
#endif
    { 0 }
};

You may not want to expose this struct directly, but a function that returns an array of strings containing the "version" field of these structs would be nice

@kylophone
Copy link
Collaborator

Yes, we would need to add a public API for that. I would be open to adding, I think it would be useful.

@ThatNerdUKnow
Copy link
Author

Should I create a PR?

@kylophone
Copy link
Collaborator

Should I create a PR?

Yes, feel free to give it a shot. I would prefer an iterator function to scan through them. See this one from FFmpeg for inspiration: https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/codec_desc.h#L109-L116

@ThatNerdUKnow
Copy link
Author

Cool, I'll give it a try

@ThatNerdUKnow
Copy link
Author

Wrote an implementation based on avcodec_descriptor_next from avcodec.
23138fd
Any guidance on unit testing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants