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 
35 typedef enum {DNN_FLOAT = 1, DNN_UINT8 = 4} DNNDataType;
36 
37 typedef struct DNNData{
38  void *data;
41 } DNNData;
42 
43 typedef struct DNNModel{
44  // Stores model that can be different for different backends.
45  void *model;
46  // Gets model input information
47  // Just reuse struct DNNData here, actually the DNNData.data field is not needed.
48  DNNReturnType (*get_input)(void *model, DNNData *input, const char *input_name);
49  // Sets model input and output.
50  // Should be called at least once before model execution.
51  DNNReturnType (*set_input_output)(void *model, DNNData *input, const char *input_name, const char **output_names, uint32_t nb_output);
52 } DNNModel;
53 
54 // Stores pointers to functions for loading, executing, freeing DNN models for one of the backends.
55 typedef struct DNNModule{
56  // Loads model and parameters from given file. Returns NULL if it is not possible.
57  DNNModel *(*load_model)(const char *model_filename);
58  // Executes model with specified input and output. Returns DNN_ERROR otherwise.
59  DNNReturnType (*execute_model)(const DNNModel *model, DNNData *outputs, uint32_t nb_output);
60  // Frees memory allocated for model.
61  void (*free_model)(DNNModel **model);
62 } DNNModule;
63 
64 // Initializes DNNModule depending on chosen backend.
66 
67 #endif
void * model
Definition: dnn_interface.h:45
int channels
Definition: dnn_interface.h:40
static int get_input(AVFrame *frame, int frame_num)
Definition: filter_audio.c:242
DNNBackendType
Definition: dnn_interface.h:33
DNNDataType
Definition: dnn_interface.h:35
int height
Definition: dnn_interface.h:40
void * data
Definition: dnn_interface.h:38
typedef void(APIENTRY *FF_PFNGLACTIVETEXTUREPROC)(GLenum texture)
DNNReturnType
Definition: dnn_interface.h:31
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
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
DNNModule * ff_get_dnn_module(DNNBackendType backend_type)
Definition: dnn_interface.c:31
DNNDataType dt
Definition: dnn_interface.h:39