Go to the documentation of this file.
37 if (strcmp(oprd->
name, input_name) == 0) {
64 if (strcmp(oprd->
name, input_name) == 0) {
97 for (uint32_t
i = 0;
i < nb_output; ++
i) {
98 const char *output_name = output_names[
i];
101 if (strcmp(oprd->
name, output_name) == 0) {
121 char header_expected[] =
"FFMPEGDNNNATIVE";
124 int version, header_size, major_version_expected = 1;
127 int file_size, dnn_size, parsed_size;
134 file_size =
avio_size(model_file_context);
144 size =
sizeof(header_expected);
153 if (strncmp(buf, header_expected,
size) != 0) {
161 if (
version != major_version_expected) {
168 header_size = dnn_size;
174 model->
model = (
void *)network;
176 avio_seek(model_file_context, file_size - 8, SEEK_SET);
180 avio_seek(model_file_context, header_size, SEEK_SET);
192 for (layer = 0; layer < network->
layers_num; ++layer){
205 dnn_size += parsed_size;
218 oprd = &network->
operands[operand_index];
223 dnn_size += name_len;
241 if (dnn_size != file_size){
268 for (layer = 0; layer < network->
layers_num; ++layer){
276 for (uint32_t
i = 0;
i < nb; ++
i) {
291 for (
int i = 0;
i < 4; ++
i)
300 uint64_t
len =
sizeof(float);
301 for (
int i = 0;
i < 4;
i++) {
317 if ((*model)->model) {
320 for (layer = 0; layer < network->
layers_num; ++layer){
332 for (uint32_t operand = 0; operand < network->
operands_num; ++operand)
int32_t calculate_operand_data_length(const DnnOperand *oprd)
int8_t isNHWC
NHWC if 1, otherwise NCHW.
LayerFunc layer_funcs[DLT_COUNT]
void * av_mallocz_array(size_t nmemb, size_t size)
static DNNReturnType get_input_native(void *model, DNNData *input, const char *input_name)
int64_t avio_size(AVIOContext *s)
Get the filesize.
DNNLayerType
the enum value of DNNLayerType should not be changed, the same values are used in convert_from_tensor...
DNNOperandType type
input/output/intermediate operand of the network
DNNModel * ff_dnn_load_model_native(const char *model_filename)
char name[128]
to avoid possible memory leak, do not use char *name
void * data
data pointer with data length in bytes.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
DNNDataType data_type
support different kinds of data type such as float, half float, int8 etc, first support float now.
static const AVFilterPad outputs[]
DNNReturnType(* get_input)(void *model, DNNData *input, const char *input_name)
void ff_dnn_free_model_native(DNNModel **model)
and forward the result(frame or status change) to the corresponding input. If nothing is possible
int32_t dims[4]
there are two memory layouts, NHWC or NCHW, so we use dims, dims[0] is Number.
unsigned int avio_rl32(AVIOContext *s)
int32_t output_operand_index
int32_t input_operand_indexes[4]
a layer can have multiple inputs and one output.
DNNReturnType ff_dnn_execute_model_native(const DNNModel *model, DNNData *outputs, uint32_t nb_output)
int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen)
Read a string from pb into buf.
int32_t calculate_operand_dims_count(const DnnOperand *oprd)
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
int avio_closep(AVIOContext **s)
Close the resource accessed by the AVIOContext *s, free it and set the pointer pointing to it to NULL...
#define i(width, name, range_min, range_max)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
static DNNReturnType set_input_output_native(void *model, DNNData *input, const char *input_name, const char **output_names, uint32_t nb_output)
DNNReturnType(* set_input_output)(void *model, DNNData *input, const char *input_name, const char **output_names, uint32_t nb_output)
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
int avio_open(AVIOContext **s, const char *url, int flags)
Create and initialize a AVIOContext for accessing the resource indicated by url.
#define AVIO_FLAG_READ
read-only