2 * Copyright (c) 2018 Sergey Lavrushkin
4 * This file is part of FFmpeg.
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.
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.
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
23 * DNN inference engine interface.
26 #ifndef AVFILTER_DNN_INTERFACE_H
27 #define AVFILTER_DNN_INTERFACE_H
31 typedef enum {DNN_SUCCESS, DNN_ERROR} DNNReturnType;
33 typedef enum {DNN_NATIVE, DNN_TF, DNN_OV} DNNBackendType;
35 typedef enum {DNN_FLOAT = 1, DNN_UINT8 = 4} DNNDataType;
37 typedef struct DNNData{
40 int width, height, channels;
43 typedef struct DNNModel{
44 // Stores model that can be different for different backends.
46 // Stores options when the model is executed by the backend
48 // Gets model input information
49 // Just reuse struct DNNData here, actually the DNNData.data field is not needed.
50 DNNReturnType (*get_input)(void *model, DNNData *input, const char *input_name);
51 // Sets model input and output.
52 // Should be called at least once before model execution.
53 DNNReturnType (*set_input)(void *model, DNNData *input, const char *input_name);
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, const char *options);
60 // Executes model with specified input and output. Returns DNN_ERROR otherwise.
61 DNNReturnType (*execute_model)(const DNNModel *model, DNNData *outputs, const char **output_names, uint32_t nb_output);
62 // Frees memory allocated for model.
63 void (*free_model)(DNNModel **model);
66 // Initializes DNNModule depending on chosen backend.
67 DNNModule *ff_get_dnn_module(DNNBackendType backend_type);