Signed-off-by: Ting Fu
---
libavfilter/dnn/dnn_backend_native.c | 112 +--
libavfilter/dnn/dnn_backend_native.h | 4 +-
libavfilter/dnn/dnn_backend_tf.c | 24 +++---
3 files changed, 70 insertions(+), 70 deletions(-)
diff --git a/libavfilter/dnn/dnn_backend_native.c
b/libavfilter/dnn/dnn_backend_native.c
index adc652a2c4..0be9c0b53c 100644
--- a/libavfilter/dnn/dnn_backend_native.c
+++ b/libavfilter/dnn/dnn_backend_native.c
@@ -30,10 +30,10 @@
static DNNReturnType get_input_native(void *model, DNNData *input, const char
*input_name)
{
-ConvolutionalNetwork *network = (ConvolutionalNetwork *)model;
+NativeModel *native_model = (NativeModel *)model;
-for (int i = 0; i < network->operands_num; ++i) {
-DnnOperand *oprd = &network->operands[i];
+for (int i = 0; i < native_model->operands_num; ++i) {
+DnnOperand *oprd = &native_model->operands[i];
if (strcmp(oprd->name, input_name) == 0) {
if (oprd->type != DOT_INPUT)
return DNN_ERROR;
@@ -52,15 +52,15 @@ static DNNReturnType get_input_native(void *model, DNNData
*input, const char *i
static DNNReturnType set_input_output_native(void *model, DNNData *input,
const char *input_name, const char **output_names, uint32_t nb_output)
{
-ConvolutionalNetwork *network = (ConvolutionalNetwork *)model;
+NativeModel *native_model = (NativeModel *)model;
DnnOperand *oprd = NULL;
-if (network->layers_num <= 0 || network->operands_num <= 0)
+if (native_model->layers_num <= 0 || native_model->operands_num <= 0)
return DNN_ERROR;
/* inputs */
-for (int i = 0; i < network->operands_num; ++i) {
-oprd = &network->operands[i];
+for (int i = 0; i < native_model->operands_num; ++i) {
+oprd = &native_model->operands[i];
if (strcmp(oprd->name, input_name) == 0) {
if (oprd->type != DOT_INPUT)
return DNN_ERROR;
@@ -88,24 +88,24 @@ static DNNReturnType set_input_output_native(void *model,
DNNData *input, const
input->data = oprd->data;
/* outputs */
-network->nb_output = 0;
-av_freep(&network->output_indexes);
-network->output_indexes = av_mallocz_array(nb_output,
sizeof(*network->output_indexes));
-if (!network->output_indexes)
+native_model->nb_output = 0;
+av_freep(&native_model->output_indexes);
+native_model->output_indexes = av_mallocz_array(nb_output,
sizeof(*native_model->output_indexes));
+if (!native_model->output_indexes)
return DNN_ERROR;
for (uint32_t i = 0; i < nb_output; ++i) {
const char *output_name = output_names[i];
-for (int j = 0; j < network->operands_num; ++j) {
-oprd = &network->operands[j];
+for (int j = 0; j < native_model->operands_num; ++j) {
+oprd = &native_model->operands[j];
if (strcmp(oprd->name, output_name) == 0) {
-network->output_indexes[network->nb_output++] = j;
+native_model->output_indexes[native_model->nb_output++] = j;
break;
}
}
}
-if (network->nb_output != nb_output)
+if (native_model->nb_output != nb_output)
return DNN_ERROR;
return DNN_SUCCESS;
@@ -122,7 +122,7 @@ DNNModel *ff_dnn_load_model_native(const char
*model_filename, const char *optio
char *buf;
size_t size;
int version, header_size, major_version_expected = 1;
-ConvolutionalNetwork *network = NULL;
+NativeModel *native_model = NULL;
AVIOContext *model_file_context;
int file_size, dnn_size, parsed_size;
int32_t layer;
@@ -167,29 +167,29 @@ DNNModel *ff_dnn_load_model_native(const char
*model_filename, const char *optio
dnn_size += 4;
header_size = dnn_size;
-network = av_mallocz(sizeof(ConvolutionalNetwork));
-if (!network){
+native_model = av_mallocz(sizeof(NativeModel));
+if (!native_model){
goto fail;
}
-model->model = (void *)network;
+model->model = (void *)native_model;
avio_seek(model_file_context, file_size - 8, SEEK_SET);
-network->layers_num = (int32_t)avio_rl32(model_file_context);
-network->operands_num = (int32_t)avio_rl32(model_file_context);
+native_model->layers_num = (int32_t)avio_rl32(model_file_context);
+native_model->operands_num = (int32_t)avio_rl32(model_file_context);
dnn_size += 8;
avio_seek(model_file_context, header_size, SEEK_SET);
-network->layers = av_mallocz(network->layers_num * sizeof(Layer));
-if (!network->layers){
+native_model->layers = av_mallocz(native_model->layers_num *
sizeof(Layer));
+if (!native_model->layers){
goto fail;
}
-network->operands = av_mallocz(network->operands_num * sizeof(DnnOperand));
-if (!network->operands){
+native_model->operands = av_mallocz(native_model->operands_num *
sizeof(DnnOperand));
+if (!native_model->o