1 /**
2  *
3  *  Copyright 2016-2020 Netflix, Inc.
4  *
5  *     Licensed under the BSD+Patent License (the "License");
6  *     you may not use this file except in compliance with the License.
7  *     You may obtain a copy of the License at
8  *
9  *         https://opensource.org/licenses/BSDplusPatent
10  *
11  *     Unless required by applicable law or agreed to in writing, software
12  *     distributed under the License is distributed on an "AS IS" BASIS,
13  *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *     See the License for the specific language governing permissions and
15  *     limitations under the License.
16  *
17  */
18 
19 #ifndef __VMAF_MODEL_H__
20 #define __VMAF_MODEL_H__
21 
22 #include <stdint.h>
23 
24 #include "feature.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 typedef struct VmafModel VmafModel;
31 
32 enum VmafModelFlags {
33     VMAF_MODEL_FLAGS_DEFAULT = 0,
34     VMAF_MODEL_FLAG_DISABLE_CLIP = (1 << 0),
35     VMAF_MODEL_FLAG_ENABLE_TRANSFORM = (1 << 1),
36     VMAF_MODEL_FLAG_DISABLE_TRANSFORM = (1 << 2),
37 };
38 
39 typedef struct VmafModelConfig {
40     const char *name;
41     uint64_t flags;
42 } VmafModelConfig;
43 
44 int vmaf_model_load(VmafModel **model, VmafModelConfig *cfg,
45                     const char *version);
46 
47 int vmaf_model_load_from_path(VmafModel **model, VmafModelConfig *cfg,
48                               const char *path);
49 
50 int vmaf_model_feature_overload(VmafModel *model, const char *feature_name,
51                                 VmafFeatureDictionary *opts_dict);
52 
53 void vmaf_model_destroy(VmafModel *model);
54 
55 typedef struct VmafModelCollection VmafModelCollection;
56 
57 enum VmafModelCollectionScoreType {
58     VMAF_MODEL_COLLECTION_SCORE_UNKNOWN = 0,
59     VMAF_MODEL_COLLECTION_SCORE_BOOTSTRAP,
60 };
61 
62 typedef struct VmafModelCollectionScore {
63     enum VmafModelCollectionScoreType type;
64     struct {
65         double bagging_score;
66         double stddev;
67         struct {
68             struct { double lo, hi; } p95;
69         } ci;
70     } bootstrap;
71 } VmafModelCollectionScore;
72 
73 int vmaf_model_collection_load(VmafModel **model,
74                                VmafModelCollection **model_collection,
75                                VmafModelConfig *cfg,
76                                const char *version);
77 
78 int vmaf_model_collection_load_from_path(VmafModel **model,
79                                          VmafModelCollection **model_collection,
80                                          VmafModelConfig *cfg,
81                                          const char *path);
82 
83 int vmaf_model_collection_feature_overload(VmafModel *model,
84                                            VmafModelCollection **model_collection,
85                                            const char *feature_name,
86                                            VmafFeatureDictionary *opts_dict);
87 
88 void vmaf_model_collection_destroy(VmafModelCollection *model_collection);
89 
90 #ifdef __cplusplus
91 }
92 #endif
93 
94 #endif /* __VMAF_MODEL_H__ */
95