FFmpeg
dnn_interface.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 Sergey Lavrushkin
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 /**
22  * @file
23  * DNN inference engine interface.
24  */
25 
26 #ifndef AVFILTER_DNN_INTERFACE_H
27 #define AVFILTER_DNN_INTERFACE_H
28 
29 #include <stdint.h>
30 
32 
34 
36 
37 typedef struct DNNInputData{
38  void *data;
41 } DNNInputData;
42 
43 typedef struct DNNData{
44  float *data;
46 } DNNData;
47 
48 typedef struct DNNModel{
49  // Stores model that can be different for different backends.
50  void *model;
51  // Sets model input and output.
52  // Should be called at least once before model execution.
53  DNNReturnType (*set_input_output)(void *model, DNNInputData *input, const char *input_name, const char **output_names, uint32_t nb_output);
54 } DNNModel;
55 
56 // Stores pointers to functions for loading, executing, freeing DNN models for one of the backends.
57 typedef struct DNNModule{
58  // Loads model and parameters from given file. Returns NULL if it is not possible.
59  DNNModel *(*load_model)(const char *model_filename);
60  // Executes model with specified input and output. Returns DNN_ERROR otherwise.
61  DNNReturnType (*execute_model)(const DNNModel *model, DNNData *outputs, uint32_t nb_output);
62  // Frees memory allocated for model.
63  void (*free_model)(DNNModel **model);
64 } DNNModule;
65 
66 // Initializes DNNModule depending on chosen backend.
68 
69 #endif
DNNModule::execute_model
DNNReturnType(* execute_model)(const DNNModel *model, DNNData *outputs, uint32_t nb_output)
Definition: dnn_interface.h:61
DNNInputData::data
void * data
Definition: dnn_interface.h:38
DNNInputData::width
int width
Definition: dnn_interface.h:40
DNNInputData::channels
int channels
Definition: dnn_interface.h:40
DNNModel::set_input_output
DNNReturnType(* set_input_output)(void *model, DNNInputData *input, const char *input_name, const char **output_names, uint32_t nb_output)
Definition: dnn_interface.h:53
DNNData::height
int height
Definition: dnn_interface.h:45
DNN_SUCCESS
@ DNN_SUCCESS
Definition: dnn_interface.h:31
DNN_TF
@ DNN_TF
Definition: dnn_interface.h:33
DNNInputData
Definition: dnn_interface.h:37
DNNReturnType
DNNReturnType
Definition: dnn_interface.h:31
DNNData
Definition: dnn_interface.h:43
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
ff_get_dnn_module
DNNModule * ff_get_dnn_module(DNNBackendType backend_type)
Definition: dnn_interface.c:31
DNNBackendType
DNNBackendType
Definition: dnn_interface.h:33
DNNDataType
DNNDataType
Definition: dnn_interface.h:35
DNN_FLOAT
@ DNN_FLOAT
Definition: dnn_interface.h:35
input
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some input
Definition: filter_design.txt:172
DNN_ERROR
@ DNN_ERROR
Definition: dnn_interface.h:31
DNN_UINT8
@ DNN_UINT8
Definition: dnn_interface.h:35
DNNModule::free_model
void(* free_model)(DNNModel **model)
Definition: dnn_interface.h:63
DNNModel
Definition: dnn_interface.h:48
DNNData::channels
int channels
Definition: dnn_interface.h:45
DNN_NATIVE
@ DNN_NATIVE
Definition: dnn_interface.h:33
DNNData::width
int width
Definition: dnn_interface.h:45
DNNInputData::dt
DNNDataType dt
Definition: dnn_interface.h:39
DNNData::data
float * data
Definition: dnn_interface.h:44
DNNModule
Definition: dnn_interface.h:57
DNNModel::model
void * model
Definition: dnn_interface.h:50
DNNInputData::height
int height
Definition: dnn_interface.h:40