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

Confusion on usage of vmaf_model_colllection_load #1276

Open
ThatNerdUKnow opened this issue Dec 5, 2023 · 1 comment
Open

Confusion on usage of vmaf_model_colllection_load #1276

ThatNerdUKnow opened this issue Dec 5, 2023 · 1 comment

Comments

@ThatNerdUKnow
Copy link

ThatNerdUKnow commented Dec 5, 2023

I was reading model.h and came across this function and I'm confused as to why it requires a pointer to a VmafModel as well as a VmafModelCollection. I did some more looking and from what I can tell the very first model in the model collection gets put into **model while the rest of the models go into **model_collection. What are we supposed to do with **model? and why doesn't the first model in the model collection json file get added to the model collection struct?

model.h

int vmaf_model_collection_load(VmafModel **model,
                               VmafModelCollection **model_collection,
                               VmafModelConfig *cfg,
                               const char *version);

read_json_model.c

function model_collection_parse
here's where I found where **model and **model_collection are being set

unsigned i = 0;
    while (json_peek(s) != JSON_OBJECT_END && !json_get_error(s)) {
        if (json_next(s) != JSON_STRING)
            return -EINVAL;

        const char *key = json_get_string(s, NULL);
        snprintf(generated_key, generated_key_sz, "%d", i);

        if (!strcmp(key, generated_key)) {
            VmafModel *m;
            err = vmaf_read_json_model(&m, &c, s);
            if (err) return err;

            if (i == 0) {
                 // First iteration of this loop. *model is set to m
                 // m is never added to the model collection on the first loop... why?
                *model = m; 
                c.name = cfg_name;
            } else {
                err = vmaf_model_collection_append(model_collection, m);
                if (err) return err;
            }

            sprintf((char*)c.name, "%s_%04d", name, ++i);
            continue;
        }

libvmaf.h

here's where we use our model collection. What are we supposed to be doing with the VmafModel pointer returned by vmaf_model_collection_load?

/**
 * Register feature extractors required by a specific `VmafModelCollection`
 * Like `vmaf_use_features_from_model()`, this function may be called
 * multiple times using different model collections.
 *
 * @param vmaf             The VMAF context allocated with `vmaf_init()`.
 *
 * @param model_collection Opaque model collection context.
 *
 *
 * @return 0 on success, or < 0 (a negative errno code) on error.
 */
int vmaf_use_features_from_model_collection(VmafContext *vmaf,
                                            VmafModelCollection *model_collection);
@nilfm
Copy link
Contributor

nilfm commented Dec 11, 2023

cc: @kylophone, is there a reason for this?

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