libvmaf
Loading...
Searching...
No Matches
libvmaf.h File Reference
#include <stdint.h>
#include <stdio.h>
#include "libvmaf/model.h"
#include "libvmaf/picture.h"
#include "libvmaf/feature.h"
Include dependency graph for libvmaf.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  VmafConfiguration
 Configuration needed to initialize a VmafContext. More...
struct  VmafPictureConfiguration

Typedefs

typedef struct VmafContext VmafContext

Enumerations

enum  VmafLogLevel {
  VMAF_LOG_LEVEL_NONE = 0 , VMAF_LOG_LEVEL_ERROR , VMAF_LOG_LEVEL_WARNING , VMAF_LOG_LEVEL_INFO ,
  VMAF_LOG_LEVEL_DEBUG
}
enum  VmafOutputFormat {
  VMAF_OUTPUT_FORMAT_NONE = 0 , VMAF_OUTPUT_FORMAT_XML , VMAF_OUTPUT_FORMAT_JSON , VMAF_OUTPUT_FORMAT_CSV ,
  VMAF_OUTPUT_FORMAT_SUB
}
enum  VmafPoolingMethod {
  VMAF_POOL_METHOD_UNKNOWN = 0 , VMAF_POOL_METHOD_MIN , VMAF_POOL_METHOD_MAX , VMAF_POOL_METHOD_MEAN ,
  VMAF_POOL_METHOD_HARMONIC_MEAN , VMAF_POOL_METHOD_NB
}

Functions

int vmaf_init (VmafContext **vmaf, VmafConfiguration cfg)
int vmaf_use_features_from_model (VmafContext *vmaf, VmafModel *model)
int vmaf_use_features_from_model_collection (VmafContext *vmaf, VmafModelCollection *model_collection)
int vmaf_use_feature (VmafContext *vmaf, const char *feature_name, VmafFeatureDictionary *opts_dict)
int vmaf_import_feature_score (VmafContext *vmaf, const char *feature_name, double value, unsigned index)
int vmaf_read_pictures (VmafContext *vmaf, VmafPicture *ref, VmafPicture *dist, unsigned index)
int vmaf_score_at_index (VmafContext *vmaf, VmafModel *model, double *score, unsigned index)
int vmaf_score_at_index_model_collection (VmafContext *vmaf, VmafModelCollection *model_collection, VmafModelCollectionScore *score, unsigned index)
int vmaf_feature_score_at_index (VmafContext *vmaf, const char *feature_name, double *score, unsigned index)
int vmaf_score_pooled (VmafContext *vmaf, VmafModel *model, enum VmafPoolingMethod pool_method, double *score, unsigned index_low, unsigned index_high)
int vmaf_score_pooled_model_collection (VmafContext *vmaf, VmafModelCollection *model_collection, enum VmafPoolingMethod pool_method, VmafModelCollectionScore *score, unsigned index_low, unsigned index_high)
int vmaf_feature_score_pooled (VmafContext *vmaf, const char *feature_name, enum VmafPoolingMethod pool_method, double *score, unsigned index_low, unsigned index_high)
int vmaf_preallocate_pictures (VmafContext *vmaf, VmafPictureConfiguration cfg)
int vmaf_fetch_preallocated_picture (VmafContext *vmaf, VmafPicture *pic)
int vmaf_close (VmafContext *vmaf)
int vmaf_write_output (VmafContext *vmaf, const char *output_path, enum VmafOutputFormat fmt)
const char * vmaf_version (void)

Typedef Documentation

◆ VmafContext

typedef struct VmafContext VmafContext

Enumeration Type Documentation

◆ VmafLogLevel

Copyright 2016-2020 Netflix, Inc.

Licensed under the BSD+Patent License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://opensource.org/licenses/BSDplusPatent

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Enumerator
VMAF_LOG_LEVEL_NONE 
VMAF_LOG_LEVEL_ERROR 
VMAF_LOG_LEVEL_WARNING 
VMAF_LOG_LEVEL_INFO 
VMAF_LOG_LEVEL_DEBUG 

◆ VmafOutputFormat

Enumerator
VMAF_OUTPUT_FORMAT_NONE 
VMAF_OUTPUT_FORMAT_XML 
VMAF_OUTPUT_FORMAT_JSON 
VMAF_OUTPUT_FORMAT_CSV 
VMAF_OUTPUT_FORMAT_SUB 

◆ VmafPoolingMethod

Enumerator
VMAF_POOL_METHOD_UNKNOWN 
VMAF_POOL_METHOD_MIN 
VMAF_POOL_METHOD_MAX 
VMAF_POOL_METHOD_MEAN 
VMAF_POOL_METHOD_HARMONIC_MEAN 
VMAF_POOL_METHOD_NB 

Function Documentation

◆ vmaf_close()

int vmaf_close ( VmafContext * vmaf)

Close a VMAF instance and free all associated memory.

Parameters
vmafThe VMAF instance to close.
Returns
0 on success, or < 0 (a negative errno code) on error.

◆ vmaf_feature_score_at_index()

int vmaf_feature_score_at_index ( VmafContext * vmaf,
const char * feature_name,
double * score,
unsigned index )

Fetch feature score at specific index.

Parameters
vmafThe VMAF context allocated with vmaf_init().
feature_nameName of the feature to fetch.
indexPicture index.
scoreScore.
Returns
0 on success, or < 0 (a negative errno code) on error.

◆ vmaf_feature_score_pooled()

int vmaf_feature_score_pooled ( VmafContext * vmaf,
const char * feature_name,
enum VmafPoolingMethod pool_method,
double * score,
unsigned index_low,
unsigned index_high )

Pooled feature score for a specific interval.

Parameters
vmafThe VMAF context allocated with vmaf_init().
feature_nameName of the feature to fetch.
pool_methodTemporal pooling method to use.
scorePooled score.
index_lowLow picture index of pooling interval.
index_highHigh picture index of pooling interval.
Returns
0 on success, or < 0 (a negative errno code) on error.

◆ vmaf_fetch_preallocated_picture()

int vmaf_fetch_preallocated_picture ( VmafContext * vmaf,
VmafPicture * pic )

Fetch a preallocated picture from the picture pool. The picture must be returned to the pool via vmaf_picture_unref() when done. Pictures automatically return to the pool when their reference count reaches zero.

Parameters
vmafVMAF context initialized with vmaf_preallocate_pictures().
picOutput picture from the pool.
Returns
0 on success, or < 0 (a negative errno code) on error.

◆ vmaf_import_feature_score()

int vmaf_import_feature_score ( VmafContext * vmaf,
const char * feature_name,
double value,
unsigned index )

Import an external feature score. Useful when pre-computed feature scores are available. Also useful in the case where there is no libvmaf feature extractor implementation for a required feature.

Parameters
vmafThe VMAF context allocated with vmaf_init().
feature_nameName of feature.
valueScore.
indexPicture index.
Returns
0 on success, or < 0 (a negative errno code) on error.

◆ vmaf_init()

int vmaf_init ( VmafContext ** vmaf,
VmafConfiguration cfg )

Allocate and open a VMAF instance.

Parameters
vmafThe VMAF instance to open. To be used in further libvmaf api calls. $vmaf will be set to the allocated context. Context should be cleaned up with vmaf_close() when finished.
cfgConfiguration parameters.
Returns
0 on success, or < 0 (a negative errno code) on error.

◆ vmaf_preallocate_pictures()

int vmaf_preallocate_pictures ( VmafContext * vmaf,
VmafPictureConfiguration cfg )

Preallocate pictures for use with multi-threaded feature extraction. Pictures are allocated once and automatically returned to the pool when fully unref'd, avoiding repeated allocation/deallocation overhead.

Parameters
vmafVMAF context allocated with vmaf_init().
cfgPicture configuration including dimensions and pool size.
Returns
0 on success, or < 0 (a negative errno code) on error.

◆ vmaf_read_pictures()

int vmaf_read_pictures ( VmafContext * vmaf,
VmafPicture * ref,
VmafPicture * dist,
unsigned index )

Read a pair of pictures and queue them for eventual feature extraction. This should be called after feature extractors are registered via vmaf_use_features_from_model() and/or vmaf_use_feature(). VmafContext will take ownership of both VmafPictures (ref and dist) and vmaf_picture_unref().

When you're done reading pictures call this function again with both ref and dist set to NULL to flush all feature extractors.

Parameters
vmafThe VMAF context allocated with vmaf_init().
refReference picture.
distDistorted picture.
indexPicture index.
Returns
0 on success, or < 0 (a negative errno code) on error.

◆ vmaf_score_at_index()

int vmaf_score_at_index ( VmafContext * vmaf,
VmafModel * model,
double * score,
unsigned index )

Predict VMAF score at specific index.

Parameters
vmafThe VMAF context allocated with vmaf_init().
modelOpaque model context.
indexPicture index.
scorePredicted score.
Returns
0 on success, or < 0 (a negative errno code) on error.

◆ vmaf_score_at_index_model_collection()

int vmaf_score_at_index_model_collection ( VmafContext * vmaf,
VmafModelCollection * model_collection,
VmafModelCollectionScore * score,
unsigned index )

Predict VMAF score at specific index, using a model collection.

Parameters
vmafThe VMAF context allocated with vmaf_init().
model_collectionOpaque model collection context.
indexPicture index.
scorePredicted score.
Returns
0 on success, or < 0 (a negative errno code) on error.

◆ vmaf_score_pooled()

int vmaf_score_pooled ( VmafContext * vmaf,
VmafModel * model,
enum VmafPoolingMethod pool_method,
double * score,
unsigned index_low,
unsigned index_high )

Pooled VMAF score for a specific interval.

Parameters
vmafThe VMAF context allocated with vmaf_init().
modelOpaque model context.
pool_methodTemporal pooling method to use.
scorePooled score.
index_lowLow picture index of pooling interval.
index_highHigh picture index of pooling interval.
Returns
0 on success, or < 0 (a negative errno code) on error.

◆ vmaf_score_pooled_model_collection()

int vmaf_score_pooled_model_collection ( VmafContext * vmaf,
VmafModelCollection * model_collection,
enum VmafPoolingMethod pool_method,
VmafModelCollectionScore * score,
unsigned index_low,
unsigned index_high )

Pooled VMAF score for a specific interval, using a model collection.

Parameters
vmafThe VMAF context allocated with vmaf_init().
model_collectionOpaque model collection context.
pool_methodTemporal pooling method to use.
scorePooled score.
index_lowLow picture index of pooling interval.
index_highHigh picture index of pooling interval.
Returns
0 on success, or < 0 (a negative errno code) on error.

◆ vmaf_use_feature()

int vmaf_use_feature ( VmafContext * vmaf,
const char * feature_name,
VmafFeatureDictionary * opts_dict )

Register specific feature extractor. Useful when a specific/additional feature is required, usually one which is not already provided by a model via vmaf_use_features_from_model(). This may be called multiple times. VmafContext will take ownership of the VmafFeatureDictionary (opts_dict). Use vmaf_feature_dictionary_free() only in the case of failure.

Parameters
vmafThe VMAF context allocated with vmaf_init().
feature_nameName of feature.
opts_dictFeature extractor options set via vmaf_feature_dictionary_set(). If no special options are required this parameter can be set to NULL.
Returns
0 on success, or < 0 (a negative errno code) on error.

◆ vmaf_use_features_from_model()

int vmaf_use_features_from_model ( VmafContext * vmaf,
VmafModel * model )

Register feature extractors required by a specific VmafModel. This may be called multiple times using different models. In this case, the registered feature extractors will form a set, and any features required by multiple models will only be extracted once.

Parameters
vmafThe VMAF context allocated with vmaf_init().
modelOpaque model context.
Returns
0 on success, or < 0 (a negative errno code) on error.

◆ vmaf_use_features_from_model_collection()

int vmaf_use_features_from_model_collection ( VmafContext * vmaf,
VmafModelCollection * model_collection )

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.

Parameters
vmafThe VMAF context allocated with vmaf_init().
model_collectionOpaque model collection context.
Returns
0 on success, or < 0 (a negative errno code) on error.

◆ vmaf_version()

const char * vmaf_version ( void )

Get libvmaf version.

◆ vmaf_write_output()

int vmaf_write_output ( VmafContext * vmaf,
const char * output_path,
enum VmafOutputFormat fmt )

Write VMAF stats to an output file.

Parameters
vmafThe VMAF context allocated with vmaf_init().
output_pathOutput file path.
fmtOutput file format. See enum VmafOutputFormat for options.
Returns
0 on success, or < 0 (a negative errno code) on error.