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 * Implements DNN module initialization with specified backend.
24 */
25
26 #include "../dnn_interface.h"
30
32
36
37 #define OFFSET(x) offsetof(DnnContext, x)
38 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM
40 {"model", "path to model file",
42 {"input", "input name of the model",
44 {"output", "output name of the model",
46 {"backend_configs", "backend configs (deprecated)",
48 {"options", "backend configs (deprecated)",
50 {"nireq", "number of request",
52 {"async", "use DNN async inference",
54 {"device", "device to run model",
57 };
58
60
63 union {
66 };
68
70 {0, .
class = &dnn_base_class},
71 // Must keep the same order as in DNNOptions, so offset value in incremental order
72 #if CONFIG_LIBTENSORFLOW
74 #endif
75 #if CONFIG_LIBOPENVINO
77 #endif
78 #if CONFIG_LIBTORCH
80 #endif
81 };
82
84 {
88 }
89
91 "Module backend_type %d is not supported or enabled.\n",
92 backend_type);
94 }
95
97 {
101 }
102 }
103
105 size_t pre_offset;
106
107 if (!prev) {
109 return obj;
110 }
111
112 pre_offset = (char *)prev - (char *)obj;
117 return ptr;
118 }
119 }
120
122 }
123
125 {
129
130 if (!(module->
type & backend_mask))
131 continue;
132 }
133
134 *iter = (
void *)(
i + 1);
136 }
137
139 }
140