FFmpeg
dnn_backend_native.c
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 native backend implementation.
24  */
25 
26 #include "dnn_backend_native.h"
27 #include "libavutil/avassert.h"
30 #include "dnn_io_proc.h"
31 #include "dnn_backend_common.h"
32 
33 #define OFFSET(x) offsetof(NativeContext, x)
34 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM
35 static const AVOption dnn_native_options[] = {
36  { "conv2d_threads", "threads num for conv2d layer", OFFSET(options.conv2d_threads), AV_OPT_TYPE_INT, { .i64 = 0 }, INT_MIN, INT_MAX, FLAGS },
37  { NULL },
38 };
39 
40 static const AVClass dnn_native_class = {
41  .class_name = "dnn_native",
42  .item_name = av_default_item_name,
43  .option = dnn_native_options,
44  .version = LIBAVUTIL_VERSION_INT,
45  .category = AV_CLASS_CATEGORY_FILTER,
46 };
47 
48 static DNNReturnType execute_model_native(const DNNModel *model, const char *input_name, AVFrame *in_frame,
49  const char **output_names, uint32_t nb_output, AVFrame *out_frame,
50  int do_ioproc);
51 
52 static DNNReturnType get_input_native(void *model, DNNData *input, const char *input_name)
53 {
54  NativeModel *native_model = model;
55  NativeContext *ctx = &native_model->ctx;
56 
57  for (int i = 0; i < native_model->operands_num; ++i) {
58  DnnOperand *oprd = &native_model->operands[i];
59  if (strcmp(oprd->name, input_name) == 0) {
60  if (oprd->type != DOT_INPUT) {
61  av_log(ctx, AV_LOG_ERROR, "Found \"%s\" in model, but it is not input node\n", input_name);
62  return DNN_ERROR;
63  }
64  input->dt = oprd->data_type;
65  av_assert0(oprd->dims[0] == 1);
66  input->height = oprd->dims[1];
67  input->width = oprd->dims[2];
68  input->channels = oprd->dims[3];
69  return DNN_SUCCESS;
70  }
71  }
72 
73  // do not find the input operand
74  av_log(ctx, AV_LOG_ERROR, "Could not find \"%s\" in model\n", input_name);
75  return DNN_ERROR;
76 }
77 
78 static DNNReturnType get_output_native(void *model, const char *input_name, int input_width, int input_height,
79  const char *output_name, int *output_width, int *output_height)
80 {
82  NativeModel *native_model = model;
83  NativeContext *ctx = &native_model->ctx;
84  AVFrame *in_frame = av_frame_alloc();
85  AVFrame *out_frame = NULL;
86 
87  if (!in_frame) {
88  av_log(ctx, AV_LOG_ERROR, "Could not allocate memory for input frame\n");
89  return DNN_ERROR;
90  }
91 
92  out_frame = av_frame_alloc();
93 
94  if (!out_frame) {
95  av_log(ctx, AV_LOG_ERROR, "Could not allocate memory for output frame\n");
96  av_frame_free(&in_frame);
97  return DNN_ERROR;
98  }
99 
100  in_frame->width = input_width;
101  in_frame->height = input_height;
102 
103  ret = execute_model_native(native_model->model, input_name, in_frame, &output_name, 1, out_frame, 0);
104  *output_width = out_frame->width;
105  *output_height = out_frame->height;
106 
107  av_frame_free(&out_frame);
108  av_frame_free(&in_frame);
109  return ret;
110 }
111 
112 // Loads model and its parameters that are stored in a binary file with following structure:
113 // layers_num,layer_type,layer_parameterss,layer_type,layer_parameters...
114 // For CONV layer: activation_function, input_num, output_num, kernel_size, kernel, biases
115 // For DEPTH_TO_SPACE layer: block_size
116 DNNModel *ff_dnn_load_model_native(const char *model_filename, DNNFunctionType func_type, const char *options, AVFilterContext *filter_ctx)
117 {
118 #define DNN_NATIVE_MAGIC "FFMPEGDNNNATIVE"
119  DNNModel *model = NULL;
120  // sizeof - 1 to skip the terminating '\0' which is not written in the file
121  char buf[sizeof(DNN_NATIVE_MAGIC) - 1];
122  int version, header_size, major_version_expected = 1;
123  NativeModel *native_model = NULL;
124  AVIOContext *model_file_context;
125  int file_size, dnn_size, parsed_size;
126  int32_t layer;
127  DNNLayerType layer_type;
128 
129  if (avio_open(&model_file_context, model_filename, AVIO_FLAG_READ) < 0){
130  return NULL;
131  }
132  file_size = avio_size(model_file_context);
133 
134  model = av_mallocz(sizeof(DNNModel));
135  if (!model){
136  goto fail;
137  }
138 
139  /**
140  * check file header with string and version
141  */
142  if (avio_read(model_file_context, buf, sizeof(buf)) != sizeof(buf) ||
143  memcmp(buf, DNN_NATIVE_MAGIC, sizeof(buf)))
144  goto fail;
145  dnn_size = sizeof(buf);
146 
147  version = (int32_t)avio_rl32(model_file_context);
148  dnn_size += 4;
149  if (version != major_version_expected) {
150  goto fail;
151  }
152 
153  // currently no need to check minor version
154  version = (int32_t)avio_rl32(model_file_context);
155  dnn_size += 4;
156  header_size = dnn_size;
157 
158  native_model = av_mallocz(sizeof(NativeModel));
159  if (!native_model){
160  goto fail;
161  }
162  model->model = native_model;
163 
164  native_model->ctx.class = &dnn_native_class;
165  model->options = options;
166  if (av_opt_set_from_string(&native_model->ctx, model->options, NULL, "=", "&") < 0)
167  goto fail;
168  native_model->model = model;
169 
170 #if !HAVE_PTHREAD_CANCEL
171  if (native_model->ctx.options.conv2d_threads > 1){
172  av_log(&native_model->ctx, AV_LOG_WARNING, "'conv2d_threads' option was set but it is not supported "
173  "on this build (pthread support is required)\n");
174  }
175 #endif
176 
177  avio_seek(model_file_context, file_size - 8, SEEK_SET);
178  native_model->layers_num = (int32_t)avio_rl32(model_file_context);
179  native_model->operands_num = (int32_t)avio_rl32(model_file_context);
180  dnn_size += 8;
181  avio_seek(model_file_context, header_size, SEEK_SET);
182 
183  native_model->layers = av_mallocz(native_model->layers_num * sizeof(Layer));
184  if (!native_model->layers){
185  goto fail;
186  }
187 
188  native_model->operands = av_mallocz(native_model->operands_num * sizeof(DnnOperand));
189  if (!native_model->operands){
190  goto fail;
191  }
192 
193  for (layer = 0; layer < native_model->layers_num; ++layer){
194  layer_type = (int32_t)avio_rl32(model_file_context);
195  dnn_size += 4;
196 
197  if (layer_type >= DLT_COUNT) {
198  goto fail;
199  }
200 
201  native_model->layers[layer].type = layer_type;
202  parsed_size = ff_layer_funcs[layer_type].pf_load(&native_model->layers[layer], model_file_context, file_size, native_model->operands_num);
203  if (!parsed_size) {
204  goto fail;
205  }
206  dnn_size += parsed_size;
207  }
208 
209  for (int32_t i = 0; i < native_model->operands_num; ++i){
210  DnnOperand *oprd;
211  int32_t name_len;
212  int32_t operand_index = (int32_t)avio_rl32(model_file_context);
213  dnn_size += 4;
214 
215  if (operand_index >= native_model->operands_num) {
216  goto fail;
217  }
218 
219  oprd = &native_model->operands[operand_index];
220  name_len = (int32_t)avio_rl32(model_file_context);
221  dnn_size += 4;
222 
223  avio_get_str(model_file_context, name_len, oprd->name, sizeof(oprd->name));
224  dnn_size += name_len;
225 
226  oprd->type = (int32_t)avio_rl32(model_file_context);
227  dnn_size += 4;
228 
229  oprd->data_type = (int32_t)avio_rl32(model_file_context);
230  dnn_size += 4;
231 
232  for (int32_t dim = 0; dim < 4; ++dim) {
233  oprd->dims[dim] = (int32_t)avio_rl32(model_file_context);
234  dnn_size += 4;
235  }
236  if (oprd->type == DOT_INPUT && oprd->dims[0] != 1)
237  goto fail;
238 
239  oprd->isNHWC = 1;
240  }
241 
242  avio_closep(&model_file_context);
243 
244  if (dnn_size != file_size){
245  ff_dnn_free_model_native(&model);
246  return NULL;
247  }
248 
249  model->get_input = &get_input_native;
250  model->get_output = &get_output_native;
251  model->filter_ctx = filter_ctx;
252  model->func_type = func_type;
253 
254  return model;
255 
256 fail:
257  ff_dnn_free_model_native(&model);
258  avio_closep(&model_file_context);
259  return NULL;
260 }
261 
262 static DNNReturnType execute_model_native(const DNNModel *model, const char *input_name, AVFrame *in_frame,
263  const char **output_names, uint32_t nb_output, AVFrame *out_frame,
264  int do_ioproc)
265 {
266  NativeModel *native_model = model->model;
267  NativeContext *ctx = &native_model->ctx;
268  int32_t layer;
270  DnnOperand *oprd = NULL;
271 
272  if (native_model->layers_num <= 0 || native_model->operands_num <= 0) {
273  av_log(ctx, AV_LOG_ERROR, "No operands or layers in model\n");
274  return DNN_ERROR;
275  }
276 
277  for (int i = 0; i < native_model->operands_num; ++i) {
278  oprd = &native_model->operands[i];
279  if (strcmp(oprd->name, input_name) == 0) {
280  if (oprd->type != DOT_INPUT) {
281  av_log(ctx, AV_LOG_ERROR, "Found \"%s\" in model, but it is not input node\n", input_name);
282  return DNN_ERROR;
283  }
284  break;
285  }
286  oprd = NULL;
287  }
288  if (!oprd) {
289  av_log(ctx, AV_LOG_ERROR, "Could not find \"%s\" in model\n", input_name);
290  return DNN_ERROR;
291  }
292 
293  oprd->dims[1] = in_frame->height;
294  oprd->dims[2] = in_frame->width;
295 
296  av_freep(&oprd->data);
298  if (oprd->length <= 0) {
299  av_log(ctx, AV_LOG_ERROR, "The input data length overflow\n");
300  return DNN_ERROR;
301  }
302  oprd->data = av_malloc(oprd->length);
303  if (!oprd->data) {
304  av_log(ctx, AV_LOG_ERROR, "Failed to malloc memory for input data\n");
305  return DNN_ERROR;
306  }
307 
308  input.height = oprd->dims[1];
309  input.width = oprd->dims[2];
310  input.channels = oprd->dims[3];
311  input.data = oprd->data;
312  input.dt = oprd->data_type;
313  if (do_ioproc) {
314  if (native_model->model->frame_pre_proc != NULL) {
315  native_model->model->frame_pre_proc(in_frame, &input, native_model->model->filter_ctx);
316  } else {
317  ff_proc_from_frame_to_dnn(in_frame, &input, ctx);
318  }
319  }
320 
321  if (nb_output != 1) {
322  // currently, the filter does not need multiple outputs,
323  // so we just pending the support until we really need it.
324  avpriv_report_missing_feature(ctx, "multiple outputs");
325  return DNN_ERROR;
326  }
327 
328  for (layer = 0; layer < native_model->layers_num; ++layer){
329  DNNLayerType layer_type = native_model->layers[layer].type;
330  if (ff_layer_funcs[layer_type].pf_exec(native_model->operands,
331  native_model->layers[layer].input_operand_indexes,
332  native_model->layers[layer].output_operand_index,
333  native_model->layers[layer].params,
334  &native_model->ctx) == DNN_ERROR) {
335  av_log(ctx, AV_LOG_ERROR, "Failed to execute model\n");
336  return DNN_ERROR;
337  }
338  }
339 
340  for (uint32_t i = 0; i < nb_output; ++i) {
341  DnnOperand *oprd = NULL;
342  const char *output_name = output_names[i];
343  for (int j = 0; j < native_model->operands_num; ++j) {
344  if (strcmp(native_model->operands[j].name, output_name) == 0) {
345  oprd = &native_model->operands[j];
346  break;
347  }
348  }
349 
350  if (oprd == NULL) {
351  av_log(ctx, AV_LOG_ERROR, "Could not find output in model\n");
352  return DNN_ERROR;
353  }
354 
355  output.data = oprd->data;
356  output.height = oprd->dims[1];
357  output.width = oprd->dims[2];
358  output.channels = oprd->dims[3];
359  output.dt = oprd->data_type;
360 
361  if (do_ioproc) {
362  if (native_model->model->frame_post_proc != NULL) {
363  native_model->model->frame_post_proc(out_frame, &output, native_model->model->filter_ctx);
364  } else {
365  ff_proc_from_dnn_to_frame(out_frame, &output, ctx);
366  }
367  } else {
368  out_frame->width = output.width;
369  out_frame->height = output.height;
370  }
371  }
372 
373  return DNN_SUCCESS;
374 }
375 
377 {
378  NativeModel *native_model = model->model;
379  NativeContext *ctx = &native_model->ctx;
380 
381  if (ff_check_exec_params(ctx, DNN_NATIVE, model->func_type, exec_params) != 0) {
382  return DNN_ERROR;
383  }
384 
385  return execute_model_native(model, exec_params->input_name, exec_params->in_frame,
386  exec_params->output_names, exec_params->nb_output, exec_params->out_frame, 1);
387 }
388 
390 {
391  int32_t result = 1;
392  for (int i = 0; i < 4; ++i)
393  result *= oprd->dims[i];
394 
395  return result;
396 }
397 
399 {
400  // currently, we just support DNN_FLOAT
401  uint64_t len = sizeof(float);
402  for (int i = 0; i < 4; i++) {
403  len *= oprd->dims[i];
404  if (len > INT32_MAX)
405  return 0;
406  }
407  return len;
408 }
409 
411 {
412  NativeModel *native_model;
413  ConvolutionalParams *conv_params;
414  int32_t layer;
415 
416  if (*model)
417  {
418  if ((*model)->model) {
419  native_model = (*model)->model;
420  if (native_model->layers) {
421  for (layer = 0; layer < native_model->layers_num; ++layer){
422  if (native_model->layers[layer].type == DLT_CONV2D){
423  conv_params = (ConvolutionalParams *)native_model->layers[layer].params;
424  av_freep(&conv_params->kernel);
425  av_freep(&conv_params->biases);
426  }
427  av_freep(&native_model->layers[layer].params);
428  }
429  av_freep(&native_model->layers);
430  }
431 
432  if (native_model->operands) {
433  for (uint32_t operand = 0; operand < native_model->operands_num; ++operand)
434  av_freep(&native_model->operands[operand].data);
435  av_freep(&native_model->operands);
436  }
437 
438  av_freep(&native_model);
439  }
440  av_freep(model);
441  }
442 }
DLT_COUNT
@ DLT_COUNT
Definition: dnn_backend_native.h:49
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
filter_ctx
static FilteringContext * filter_ctx
Definition: transcoding.c:49
DnnOperand::isNHWC
int8_t isNHWC
NHWC if 1, otherwise NCHW.
Definition: dnn_backend_native.h:90
DNNFunctionType
DNNFunctionType
Definition: dnn_interface.h:52
output
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce output
Definition: filter_design.txt:225
ff_check_exec_params
int ff_check_exec_params(void *ctx, DNNBackendType backend, DNNFunctionType func_type, DNNExecBaseParams *exec_params)
Definition: dnn_backend_common.c:26
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:112
ConvolutionalParams::kernel
float * kernel
Definition: dnn_backend_native_layer_conv2d.h:33
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:303
AVFrame::width
int width
Definition: frame.h:361
ff_dnn_load_model_native
DNNModel * ff_dnn_load_model_native(const char *model_filename, DNNFunctionType func_type, const char *options, AVFilterContext *filter_ctx)
Definition: dnn_backend_native.c:116
AVOption
AVOption.
Definition: opt.h:247
DNNModel::frame_pre_proc
FramePrePostProc frame_pre_proc
Definition: dnn_interface.h:101
DNNExecBaseParams::input_name
const char * input_name
Definition: dnn_interface.h:68
dnn_backend_native_layers.h
get_input_native
static DNNReturnType get_input_native(void *model, DNNData *input, const char *input_name)
Definition: dnn_backend_native.c:52
dnn_io_proc.h
DNNExecBaseParams::in_frame
AVFrame * in_frame
Definition: dnn_interface.h:71
avio_size
int64_t avio_size(AVIOContext *s)
Get the filesize.
Definition: aviobuf.c:332
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:31
NativeModel::operands
DnnOperand * operands
Definition: dnn_backend_native.h:127
DNNModel::filter_ctx
AVFilterContext * filter_ctx
Definition: dnn_interface.h:90
ff_layer_funcs
const LayerFunc ff_layer_funcs[DLT_COUNT]
Definition: dnn_backend_native_layers.c:32
execute_model_native
static DNNReturnType execute_model_native(const DNNModel *model, const char *input_name, AVFrame *in_frame, const char **output_names, uint32_t nb_output, AVFrame *out_frame, int do_ioproc)
Definition: dnn_backend_native.c:262
ff_proc_from_dnn_to_frame
DNNReturnType ff_proc_from_dnn_to_frame(AVFrame *frame, DNNData *output, void *log_ctx)
Definition: dnn_io_proc.c:27
ff_proc_from_frame_to_dnn
DNNReturnType ff_proc_from_frame_to_dnn(AVFrame *frame, DNNData *input, void *log_ctx)
Definition: dnn_io_proc.c:100
fail
#define fail()
Definition: checkasm.h:136
DNN_SUCCESS
@ DNN_SUCCESS
Definition: dnn_interface.h:33
DNNModel::get_output
DNNReturnType(* get_output)(void *model, const char *input_name, int input_width, int input_height, const char *output_name, int *output_width, int *output_height)
Definition: dnn_interface.h:97
ff_calculate_operand_data_length
int32_t ff_calculate_operand_data_length(const DnnOperand *oprd)
Definition: dnn_backend_native.c:398
DNNLayerType
DNNLayerType
the enum value of DNNLayerType should not be changed, the same values are used in convert_from_tensor...
Definition: dnn_backend_native.h:39
av_frame_alloc
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:99
DnnOperand::type
DNNOperandType type
input/output/intermediate operand of the network
Definition: dnn_backend_native.h:78
avassert.h
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
NativeModel::ctx
NativeContext ctx
Definition: dnn_backend_native.h:123
NativeModel::layers_num
int32_t layers_num
Definition: dnn_backend_native.h:126
OFFSET
#define OFFSET(x)
Definition: dnn_backend_native.c:33
Layer::type
DNNLayerType type
Definition: dnn_backend_native.h:57
DLT_CONV2D
@ DLT_CONV2D
Definition: dnn_backend_native.h:41
DnnOperand::name
char name[128]
to avoid possible memory leak, do not use char *name
Definition: dnn_backend_native.h:95
DnnOperand::data
void * data
data pointer with data length in bytes.
Definition: dnn_backend_native.h:103
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
DNNReturnType
DNNReturnType
Definition: dnn_interface.h:33
DnnOperand::data_type
DNNDataType data_type
support different kinds of data type such as float, half float, int8 etc, first support float now.
Definition: dnn_backend_native.h:84
DNNData
Definition: dnn_interface.h:59
ctx
AVFormatContext * ctx
Definition: movenc.c:48
DNNModel::get_input
DNNReturnType(* get_input)(void *model, DNNData *input, const char *input_name)
Definition: dnn_interface.h:95
ff_dnn_free_model_native
void ff_dnn_free_model_native(DNNModel **model)
Definition: dnn_backend_native.c:410
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
Layer::params
void * params
Definition: dnn_backend_native.h:65
result
and forward the result(frame or status change) to the corresponding input. If nothing is possible
NULL
#define NULL
Definition: coverity.c:32
DNNModel::frame_post_proc
FramePrePostProc frame_post_proc
Definition: dnn_interface.h:104
NativeModel
Definition: dnn_backend_native.h:122
av_opt_set_from_string
int av_opt_set_from_string(void *ctx, const char *opts, const char *const *shorthand, const char *key_val_sep, const char *pairs_sep)
Parse the key-value pairs list in opts.
Definition: opt.c:1559
DnnOperand::dims
int32_t dims[4]
there are two memory layouts, NHWC or NCHW, so we use dims, dims[0] is Number.
Definition: dnn_backend_native.h:73
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:235
dnn_native_options
static const AVOption dnn_native_options[]
Definition: dnn_backend_native.c:35
AV_CLASS_CATEGORY_FILTER
@ AV_CLASS_CATEGORY_FILTER
Definition: log.h:36
DnnOperand::length
int32_t length
Definition: dnn_backend_native.h:104
DOT_INPUT
@ DOT_INPUT
Definition: dnn_backend_native.h:52
NativeModel::model
DNNModel * model
Definition: dnn_backend_native.h:124
options
const OptionDef options[]
avio_rl32
unsigned int avio_rl32(AVIOContext *s)
Definition: aviobuf.c:733
AVIOContext
Bytestream IO Context.
Definition: avio.h:161
Layer::output_operand_index
int32_t output_operand_index
Definition: dnn_backend_native.h:64
NativeContext
Definition: dnn_backend_native.h:116
Layer
Definition: dnn_backend_native.h:56
Layer::input_operand_indexes
int32_t input_operand_indexes[4]
a layer can have multiple inputs and one output.
Definition: dnn_backend_native.h:63
avio_get_str
int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen)
Read a string from pb into buf.
Definition: aviobuf.c:843
NativeModel::layers
Layer * layers
Definition: dnn_backend_native.h:125
DNNModel::func_type
DNNFunctionType func_type
Definition: dnn_interface.h:92
avpriv_report_missing_feature
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
dnn_backend_native_layer_conv2d.h
version
version
Definition: libkvazaar.c:307
dnn_backend_native.h
DNNExecBaseParams::out_frame
AVFrame * out_frame
Definition: dnn_interface.h:72
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
LayerFunc::pf_load
LAYER_LOAD_FUNC pf_load
Definition: dnn_backend_native_layers.h:33
get_output_native
static DNNReturnType get_output_native(void *model, const char *input_name, int input_width, int input_height, const char *output_name, int *output_width, int *output_height)
Definition: dnn_backend_native.c:78
avio_closep
int avio_closep(AVIOContext **s)
Close the resource accessed by the AVIOContext *s, free it and set the pointer pointing to it to NULL...
Definition: aviobuf.c:1175
NativeModel::operands_num
int32_t operands_num
Definition: dnn_backend_native.h:128
i
int i
Definition: input.c:406
NativeContext::options
NativeOptions options
Definition: dnn_backend_native.h:118
DNN_ERROR
@ DNN_ERROR
Definition: dnn_interface.h:33
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:243
len
int len
Definition: vorbis_enc_data.h:426
DNN_NATIVE_MAGIC
#define DNN_NATIVE_MAGIC
dim
int dim
Definition: vorbis_enc_data.h:425
dnn_native_class
static const AVClass dnn_native_class
Definition: dnn_backend_native.c:40
ret
ret
Definition: filter_design.txt:187
avio_seek
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition: aviobuf.c:243
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:71
NativeContext::class
const AVClass * class
Definition: dnn_backend_native.h:117
AVFrame::height
int height
Definition: frame.h:361
ff_dnn_execute_model_native
DNNReturnType ff_dnn_execute_model_native(const DNNModel *model, DNNExecBaseParams *exec_params)
Definition: dnn_backend_native.c:376
NativeOptions::conv2d_threads
uint32_t conv2d_threads
Definition: dnn_backend_native.h:113
DnnOperand
Definition: dnn_backend_native.h:68
dnn_backend_common.h
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:224
avio_read
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition: aviobuf.c:616
ff_calculate_operand_dims_count
int32_t ff_calculate_operand_dims_count(const DnnOperand *oprd)
Definition: dnn_backend_native.c:389
DNNExecBaseParams::output_names
const char ** output_names
Definition: dnn_interface.h:69
avio_open
int avio_open(AVIOContext **s, const char *url, int flags)
Create and initialize a AVIOContext for accessing the resource indicated by url.
Definition: aviobuf.c:1120
AVFilterContext
An instance of a filter.
Definition: avfilter.h:333
DNNModel
Definition: dnn_interface.h:84
AVIO_FLAG_READ
#define AVIO_FLAG_READ
read-only
Definition: avio.h:655
DNN_NATIVE
@ DNN_NATIVE
Definition: dnn_interface.h:35
FLAGS
#define FLAGS
Definition: dnn_backend_native.c:34
DNNModel::options
const char * options
Definition: dnn_interface.h:88
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
int32_t
int32_t
Definition: audioconvert.c:56
DNNExecBaseParams
Definition: dnn_interface.h:67
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
ConvolutionalParams
Definition: dnn_backend_native_layer_conv2d.h:27
DNNExecBaseParams::nb_output
uint32_t nb_output
Definition: dnn_interface.h:70
DNNModel::model
void * model
Definition: dnn_interface.h:86
ConvolutionalParams::biases
float * biases
Definition: dnn_backend_native_layer_conv2d.h:34