Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions libvmaf/include/libvmaf/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ int vmaf_model_collection_feature_overload(VmafModel *model,

void vmaf_model_collection_destroy(VmafModelCollection *model_collection);

/// @brief Iterate through all built in vmaf model versions
/// @param prev previous model. NULL to get the first model
/// @param name OUT var - name of next model. If last model, this function does not modify name
/// @return next model or NULL after the last model
const void* vmaf_model_version_next(const void* prev, const char** version);

#ifdef __cplusplus
}
#endif
Expand Down
14 changes: 14 additions & 0 deletions libvmaf/src/model.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,3 +322,17 @@ int vmaf_model_collection_feature_overload(VmafModel *model,
return err;
}

const void* vmaf_model_version_next(const void* prev, const char** version){
VmafBuiltInModel* prev_model = prev;
VmafBuiltInModel* out_model = NULL;
if (!prev_model){
out_model = &built_in_models[0];
}
if(prev_model - built_in_models < BUILT_IN_MODEL_CNT){
out_model = prev_model + 1;
}
if (version && out_model){
*version = out_model->version;
}
return out_model;
}
12 changes: 12 additions & 0 deletions libvmaf/test/test_model.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,17 @@ static char *test_model_set_flags()
return NULL;
}


static char* test_version_next(){
void* next = NULL;
char* version = NULL;
while(next = vmaf_model_version_next(next, &version)){
VmafBuiltInModel* m = next;
mu_assert("Model versions must match",m->version == version);
}
return NULL;
}

char *run_tests()
{
mu_run_test(test_json_model);
Expand All @@ -382,5 +393,6 @@ char *run_tests()
mu_run_test(test_model_check_default_behavior_set_flags);
mu_run_test(test_model_set_flags);
mu_run_test(test_model_feature);
mu_run_test(test_version_next);
return NULL;
}