Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kylophone committed Jul 25, 2024
1 parent 7394c78 commit 0c680f1
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 29 deletions.
58 changes: 31 additions & 27 deletions libvmaf/src/feature/feature_collector.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,36 +347,40 @@ int vmaf_feature_collector_append(VmafFeatureCollector *feature_collector,

VmafCallbackItem *metadata_iter = feature_collector->metadata ?
feature_collector->metadata->head : NULL;
while(metadata_iter)
{
VmafPredictModel *model_iter = feature_collector->models;
while (model_iter)
{
VmafModel *model = model_iter->model;
pthread_mutex_unlock(&(feature_collector->lock));
res = vmaf_feature_collector_get_score(feature_collector, model->name,
&score, picture_index);
pthread_mutex_lock(&(feature_collector->lock));
if (!res) {
model_iter = model_iter->next;
continue;
}
pthread_mutex_unlock(&(feature_collector->lock));
res = vmaf_predict_score_at_index(model, feature_collector, picture_index,
&score, true, true, 0);
pthread_mutex_lock(&(feature_collector->lock));
if (res) goto unlock;

VmafMetadata data = {
.feature_name = model->name,
while (metadata_iter) {
VmafPredictModel *model_iter = feature_collector->models;
while (model_iter) {
VmafModel *model = model_iter->model;

pthread_mutex_unlock(&(feature_collector->lock));
res = vmaf_feature_collector_get_score(feature_collector,
metadata_iter->metadata_cfg.feature_name,
&score, picture_index);
pthread_mutex_lock(&(feature_collector->lock));

if (!res) {
model_iter = model_iter->next;
continue;
}

pthread_mutex_unlock(&(feature_collector->lock));
res = vmaf_predict_score_at_index(model, feature_collector,
picture_index, &score, true, true, 0);
pthread_mutex_lock(&(feature_collector->lock));

if (res) goto unlock;

VmafMetadata data = {
.feature_name = metadata_iter->metadata_cfg.feature_name,
.picture_index = picture_index,
.score = score,
};
};

metadata_iter->metadata_cfg.callback(metadata_iter->metadata_cfg.data, &data);
model_iter = model_iter->next;
}

metadata_iter->metadata_cfg.callback(metadata_iter->metadata_cfg.data, &data);
model_iter = model_iter->next;
}
metadata_iter = metadata_iter->next;
metadata_iter = metadata_iter->next;
}

unlock:
Expand Down
16 changes: 14 additions & 2 deletions libvmaf/tools/vmaf.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,23 @@ int main(int argc, char *argv[])
return -1;
}

VmafMetadataConfiguration metadata_cfg = {
VmafMetadataConfiguration metadata_cfg_1 = {
.feature_name = "vmaf",
.callback = &my_callback,
};

err = vmaf_register_metadata_callback(vmaf, metadata_cfg);
err = vmaf_register_metadata_callback(vmaf, metadata_cfg_1);
if (err) {
fprintf(stderr, "problem during vmaf_register_metadata_callback\n");
return -1;
}

VmafMetadataConfiguration metadata_cfg_2 = {
.feature_name = "psnr",
.callback = &my_callback,
};

err = vmaf_register_metadata_callback(vmaf, metadata_cfg_2);
if (err) {
fprintf(stderr, "problem during vmaf_register_metadata_callback\n");
return -1;
Expand Down

0 comments on commit 0c680f1

Please sign in to comment.