[FFmpeg-cvslog] libavfilter: Remove DNNReturnType from DNN Module

Shubhanshu Saxena git at videolan.org
Sat Mar 12 09:43:38 EET 2022


ffmpeg | branch: master | Shubhanshu Saxena <shubhanshu.e01 at gmail.com> | Wed Mar  2 23:53:56 2022 +0530| [d0a999a0ab8313fd1b5e9cb09e35fb769fb3e51c] | committer: Guo Yejun

libavfilter: Remove DNNReturnType from DNN Module

This patch removes all occurences of DNNReturnType from the DNN module.
This commit replaces DNN_SUCCESS by 0 (essentially the same), so the
functions with DNNReturnType now return 0 in case of success, the negative
values otherwise.

Signed-off-by: Shubhanshu Saxena <shubhanshu.e01 at gmail.com>
Signed-off-by: Shubhanshu Saxena <shubhanshu.e01 at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d0a999a0ab8313fd1b5e9cb09e35fb769fb3e51c
---

 libavfilter/dnn/dnn_backend_common.c               | 10 ++--
 libavfilter/dnn/dnn_backend_common.h               |  8 ++--
 libavfilter/dnn/dnn_backend_native.c               | 16 +++----
 libavfilter/dnn/dnn_backend_native_layer_avgpool.c |  2 +-
 libavfilter/dnn/dnn_backend_native_layer_conv2d.c  |  4 +-
 libavfilter/dnn/dnn_backend_native_layer_dense.c   |  2 +-
 .../dnn/dnn_backend_native_layer_depth2space.c     |  2 +-
 libavfilter/dnn/dnn_backend_openvino.c             | 48 +++++++++----------
 libavfilter/dnn/dnn_backend_tf.c                   | 56 +++++++++++-----------
 libavfilter/dnn/dnn_io_proc.c                      | 14 +++---
 libavfilter/dnn_interface.h                        |  2 -
 libavfilter/vf_derain.c                            |  2 +-
 libavfilter/vf_dnn_classify.c                      |  4 +-
 libavfilter/vf_dnn_detect.c                        |  4 +-
 libavfilter/vf_dnn_processing.c                    |  8 ++--
 libavfilter/vf_sr.c                                |  4 +-
 16 files changed, 92 insertions(+), 94 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_common.c b/libavfilter/dnn/dnn_backend_common.c
index 64ed441415..91a4a3c4bf 100644
--- a/libavfilter/dnn/dnn_backend_common.c
+++ b/libavfilter/dnn/dnn_backend_common.c
@@ -70,7 +70,7 @@ int ff_dnn_fill_task(TaskItem *task, DNNExecBaseParams *exec_params, void *backe
     task->nb_output = exec_params->nb_output;
     task->output_names = exec_params->output_names;
 
-    return DNN_SUCCESS;
+    return 0;
 }
 
 /**
@@ -82,7 +82,7 @@ static void *async_thread_routine(void *args)
     DNNAsyncExecModule *async_module = args;
     void *request = async_module->args;
 
-    if (async_module->start_inference(request) != DNN_SUCCESS) {
+    if (async_module->start_inference(request) != 0) {
         return DNN_ASYNC_FAIL;
     }
     async_module->callback(request);
@@ -105,7 +105,7 @@ int ff_dnn_async_module_cleanup(DNNAsyncExecModule *async_module)
     async_module->start_inference = NULL;
     async_module->callback = NULL;
     async_module->args = NULL;
-    return DNN_SUCCESS;
+    return 0;
 }
 
 int ff_dnn_start_inference_async(void *ctx, DNNAsyncExecModule *async_module)
@@ -131,12 +131,12 @@ int ff_dnn_start_inference_async(void *ctx, DNNAsyncExecModule *async_module)
     }
 #else
     ret = async_module->start_inference(async_module->args);
-    if (ret != DNN_SUCCESS) {
+    if (ret != 0) {
         return ret;
     }
     async_module->callback(async_module->args);
 #endif
-    return DNN_SUCCESS;
+    return 0;
 }
 
 DNNAsyncStatusType ff_dnn_get_result_common(Queue *task_queue, AVFrame **in, AVFrame **out)
diff --git a/libavfilter/dnn/dnn_backend_common.h b/libavfilter/dnn/dnn_backend_common.h
index fa79caee1f..42c67c7040 100644
--- a/libavfilter/dnn/dnn_backend_common.h
+++ b/libavfilter/dnn/dnn_backend_common.h
@@ -92,7 +92,7 @@ int ff_check_exec_params(void *ctx, DNNBackendType backend, DNNFunctionType func
  * @param async flag for async execution. Must be 0 or 1
  * @param do_ioproc flag for IO processing. Must be 0 or 1
  *
- * @returns DNN_SUCCESS if successful or error code otherwise.
+ * @returns 0 if successful or error code otherwise.
  */
 int ff_dnn_fill_task(TaskItem *task, DNNExecBaseParams *exec_params, void *backend_model, int async, int do_ioproc);
 
@@ -101,7 +101,7 @@ int ff_dnn_fill_task(TaskItem *task, DNNExecBaseParams *exec_params, void *backe
  *
  * @param async_module pointer to DNNAsyncExecModule module
  *
- * @returns DNN_SUCCESS if successful or error code otherwise.
+ * @returns 0 if successful or error code otherwise.
  */
 int ff_dnn_async_module_cleanup(DNNAsyncExecModule *async_module);
 
@@ -117,7 +117,7 @@ int ff_dnn_async_module_cleanup(DNNAsyncExecModule *async_module);
  * @param ctx pointer to the backend context
  * @param async_module pointer to DNNAsyncExecModule module
  *
- * @returns DNN_SUCCESS on the start of async inference or error code otherwise.
+ * @returns 0 on the start of async inference or error code otherwise.
  */
 int ff_dnn_start_inference_async(void *ctx, DNNAsyncExecModule *async_module);
 
@@ -146,7 +146,7 @@ DNNAsyncStatusType ff_dnn_get_result_common(Queue *task_queue, AVFrame **in, AVF
  * @param input_width width of input frame
  * @param ctx pointer to the backend context
  *
- * @returns DNN_SUCCESS if successful or error code otherwise.
+ * @returns 0 if successful or error code otherwise.
  */
 int ff_dnn_fill_gettingoutput_task(TaskItem *task, DNNExecBaseParams *exec_params, void *backend_model, int input_height, int input_width, void *ctx);
 
diff --git a/libavfilter/dnn/dnn_backend_native.c b/libavfilter/dnn/dnn_backend_native.c
index f29e0e06bd..b53799f04d 100644
--- a/libavfilter/dnn/dnn_backend_native.c
+++ b/libavfilter/dnn/dnn_backend_native.c
@@ -67,7 +67,7 @@ static int extract_lltask_from_task(TaskItem *task, Queue *lltask_queue)
         av_freep(&lltask);
         return AVERROR(ENOMEM);
     }
-    return DNN_SUCCESS;
+    return 0;
 }
 
 static int get_input_native(void *model, DNNData *input, const char *input_name)
@@ -87,7 +87,7 @@ static int get_input_native(void *model, DNNData *input, const char *input_name)
             input->height = oprd->dims[1];
             input->width = oprd->dims[2];
             input->channels = oprd->dims[3];
-            return DNN_SUCCESS;
+            return 0;
         }
     }
 
@@ -112,12 +112,12 @@ static int get_output_native(void *model, const char *input_name, int input_widt
     };
 
     ret = ff_dnn_fill_gettingoutput_task(&task, &exec_params, native_model, input_height, input_width, ctx);
-    if (ret != DNN_SUCCESS) {
+    if (ret != 0) {
         goto err;
     }
 
     ret = extract_lltask_from_task(&task, native_model->lltask_queue);
-    if (ret != DNN_SUCCESS) {
+    if (ret != 0) {
         av_log(ctx, AV_LOG_ERROR, "unable to extract last level task from task.\n");
         goto err;
     }
@@ -387,7 +387,7 @@ static int execute_model_native(Queue *lltask_queue)
                                                  native_model->layers[layer].output_operand_index,
                                                  native_model->layers[layer].params,
                                                  &native_model->ctx);
-        if (ret != DNN_SUCCESS) {
+        if (ret != 0) {
             av_log(ctx, AV_LOG_ERROR, "Failed to execute model\n");
             goto err;
         }
@@ -451,7 +451,7 @@ int ff_dnn_execute_model_native(const DNNModel *model, DNNExecBaseParams *exec_p
     }
 
     ret = ff_dnn_fill_task(task, exec_params, native_model, ctx->options.async, 1);
-    if (ret != DNN_SUCCESS) {
+    if (ret != 0) {
         av_freep(&task);
         return ret;
     }
@@ -463,7 +463,7 @@ int ff_dnn_execute_model_native(const DNNModel *model, DNNExecBaseParams *exec_p
     }
 
     ret = extract_lltask_from_task(task, native_model->lltask_queue);
-    if (ret != DNN_SUCCESS) {
+    if (ret != 0) {
         av_log(ctx, AV_LOG_ERROR, "unable to extract last level task from task.\n");
         return ret;
     }
@@ -477,7 +477,7 @@ int ff_dnn_flush_native(const DNNModel *model)
 
     if (ff_queue_size(native_model->lltask_queue) == 0) {
         // no pending task need to flush
-        return DNN_SUCCESS;
+        return 0;
     }
 
     // for now, use sync node with flush operation
diff --git a/libavfilter/dnn/dnn_backend_native_layer_avgpool.c b/libavfilter/dnn/dnn_backend_native_layer_avgpool.c
index 510a28a8c9..d6fcac8a35 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_avgpool.c
+++ b/libavfilter/dnn/dnn_backend_native_layer_avgpool.c
@@ -143,5 +143,5 @@ int ff_dnn_execute_layer_avg_pool(DnnOperand *operands, const int32_t *input_ope
         }
     }
 
-    return DNN_SUCCESS;
+    return 0;
 }
diff --git a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
index dfa0d1ed36..2ac37d8855 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
+++ b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
@@ -190,7 +190,7 @@ int ff_dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t *input_opera
 #if HAVE_PTHREAD_CANCEL
     int thread_num = (ctx->options.conv2d_threads <= 0 || ctx->options.conv2d_threads > av_cpu_count())
         ? (av_cpu_count() + 1) : (ctx->options.conv2d_threads);
-    int ret = DNN_SUCCESS, thread_stride;
+    int ret = 0, thread_stride;
     ThreadParam *thread_param;
 #else
     ThreadParam thread_param = { 0 };
@@ -260,6 +260,6 @@ int ff_dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t *input_opera
     thread_param.thread_end = height - pad_size;
     dnn_execute_layer_conv2d_thread(&thread_param);
 
-    return DNN_SUCCESS;
+    return 0;
 #endif
 }
diff --git a/libavfilter/dnn/dnn_backend_native_layer_dense.c b/libavfilter/dnn/dnn_backend_native_layer_dense.c
index a22a484464..dff342c1f3 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_dense.c
+++ b/libavfilter/dnn/dnn_backend_native_layer_dense.c
@@ -147,5 +147,5 @@ int ff_dnn_execute_layer_dense(DnnOperand *operands, const int32_t *input_operan
             output += dense_params->output_num;
         }
     }
-    return DNN_SUCCESS;
+    return 0;
 }
diff --git a/libavfilter/dnn/dnn_backend_native_layer_depth2space.c b/libavfilter/dnn/dnn_backend_native_layer_depth2space.c
index 82b1a52be2..358ac3bcaa 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_depth2space.c
+++ b/libavfilter/dnn/dnn_backend_native_layer_depth2space.c
@@ -98,5 +98,5 @@ int ff_dnn_execute_layer_depth2space(DnnOperand *operands, const int32_t *input_
         }
         output += output_linesize;
     }
-    return DNN_SUCCESS;
+    return 0;
 }
diff --git a/libavfilter/dnn/dnn_backend_openvino.c b/libavfilter/dnn/dnn_backend_openvino.c
index 2f140e996b..cf012aca4c 100644
--- a/libavfilter/dnn/dnn_backend_openvino.c
+++ b/libavfilter/dnn/dnn_backend_openvino.c
@@ -191,7 +191,7 @@ static int fill_model_input_ov(OVModel *ov_model, OVRequestItem *request)
     }
     ie_blob_free(&input_blob);
 
-    return DNN_SUCCESS;
+    return 0;
 }
 
 static void infer_completion_callback(void *args)
@@ -303,7 +303,7 @@ static void infer_completion_callback(void *args)
 
 static int init_model_ov(OVModel *ov_model, const char *input_name, const char *output_name)
 {
-    int ret = DNN_SUCCESS;
+    int ret = 0;
     OVContext *ctx = &ov_model->ctx;
     IEStatusCode status;
     ie_available_devices_t a_dev;
@@ -433,7 +433,7 @@ static int init_model_ov(OVModel *ov_model, const char *input_name, const char *
         goto err;
     }
 
-    return DNN_SUCCESS;
+    return 0;
 
 err:
     ff_dnn_free_model_ov(&ov_model->model);
@@ -444,7 +444,7 @@ static int execute_model_ov(OVRequestItem *request, Queue *inferenceq)
 {
     IEStatusCode status;
     LastLevelTaskItem *lltask;
-    int ret = DNN_SUCCESS;
+    int ret = 0;
     TaskItem *task;
     OVContext *ctx;
     OVModel *ov_model;
@@ -452,7 +452,7 @@ static int execute_model_ov(OVRequestItem *request, Queue *inferenceq)
     if (ff_queue_size(inferenceq) == 0) {
         ie_infer_request_free(&request->infer_request);
         av_freep(&request);
-        return DNN_SUCCESS;
+        return 0;
     }
 
     lltask = ff_queue_peek_front(inferenceq);
@@ -462,7 +462,7 @@ static int execute_model_ov(OVRequestItem *request, Queue *inferenceq)
 
     if (task->async) {
         ret = fill_model_input_ov(ov_model, request);
-        if (ret != DNN_SUCCESS) {
+        if (ret != 0) {
             goto err;
         }
         status = ie_infer_set_completion_callback(request->infer_request, &request->callback);
@@ -477,10 +477,10 @@ static int execute_model_ov(OVRequestItem *request, Queue *inferenceq)
             ret = DNN_GENERIC_ERROR;
             goto err;
         }
-        return DNN_SUCCESS;
+        return 0;
     } else {
         ret = fill_model_input_ov(ov_model, request);
-        if (ret != DNN_SUCCESS) {
+        if (ret != 0) {
             goto err;
         }
         status = ie_infer_request_infer(request->infer_request);
@@ -490,7 +490,7 @@ static int execute_model_ov(OVRequestItem *request, Queue *inferenceq)
             goto err;
         }
         infer_completion_callback(request);
-        return (task->inference_done == task->inference_todo) ? DNN_SUCCESS : DNN_GENERIC_ERROR;
+        return (task->inference_done == task->inference_todo) ? 0 : DNN_GENERIC_ERROR;
     }
 err:
     if (ff_safe_queue_push_back(ov_model->request_queue, request) < 0) {
@@ -537,7 +537,7 @@ static int get_input_ov(void *model, DNNData *input, const char *input_name)
             input->height   = input_resizable ? -1 : dims.dims[2];
             input->width    = input_resizable ? -1 : dims.dims[3];
             input->dt       = precision_to_datatype(precision);
-            return DNN_SUCCESS;
+            return 0;
         } else {
             //incorrect input name
             APPEND_STRING(all_input_names, model_input_name)
@@ -604,7 +604,7 @@ static int extract_lltask_from_task(DNNFunctionType func_type, TaskItem *task, Q
             av_freep(&lltask);
             return AVERROR(ENOMEM);
         }
-        return DNN_SUCCESS;
+        return 0;
     }
     case DFT_ANALYTICS_CLASSIFY:
     {
@@ -617,7 +617,7 @@ static int extract_lltask_from_task(DNNFunctionType func_type, TaskItem *task, Q
         task->inference_done = 0;
 
         if (!contain_valid_detection_bbox(frame)) {
-            return DNN_SUCCESS;
+            return 0;
         }
 
         sd = av_frame_get_side_data(frame, AV_FRAME_DATA_DETECTION_BBOXES);
@@ -645,7 +645,7 @@ static int extract_lltask_from_task(DNNFunctionType func_type, TaskItem *task, Q
                 return AVERROR(ENOMEM);
             }
         }
-        return DNN_SUCCESS;
+        return 0;
     }
     default:
         av_assert0(!"should not reach here");
@@ -690,19 +690,19 @@ static int get_output_ov(void *model, const char *input_name, int input_width, i
 
     if (!ov_model->exe_network) {
         ret = init_model_ov(ov_model, input_name, output_name);
-        if (ret != DNN_SUCCESS) {
+        if (ret != 0) {
             av_log(ctx, AV_LOG_ERROR, "Failed init OpenVINO exectuable network or inference request\n");
             return ret;
         }
     }
 
     ret = ff_dnn_fill_gettingoutput_task(&task, &exec_params, ov_model, input_height, input_width, ctx);
-    if (ret != DNN_SUCCESS) {
+    if (ret != 0) {
         goto err;
     }
 
     ret = extract_lltask_from_task(ov_model->model->func_type, &task, ov_model->lltask_queue, NULL);
-    if (ret != DNN_SUCCESS) {
+    if (ret != 0) {
         av_log(ctx, AV_LOG_ERROR, "unable to extract inference from task.\n");
         goto err;
     }
@@ -795,7 +795,7 @@ int ff_dnn_execute_model_ov(const DNNModel *model, DNNExecBaseParams *exec_param
 
     if (!ov_model->exe_network) {
         ret = init_model_ov(ov_model, exec_params->input_name, exec_params->output_names[0]);
-        if (ret != DNN_SUCCESS) {
+        if (ret != 0) {
             av_log(ctx, AV_LOG_ERROR, "Failed init OpenVINO exectuable network or inference request\n");
             return ret;
         }
@@ -808,7 +808,7 @@ int ff_dnn_execute_model_ov(const DNNModel *model, DNNExecBaseParams *exec_param
     }
 
     ret = ff_dnn_fill_task(task, exec_params, ov_model, ctx->options.async, 1);
-    if (ret != DNN_SUCCESS) {
+    if (ret != 0) {
         av_freep(&task);
         return ret;
     }
@@ -820,7 +820,7 @@ int ff_dnn_execute_model_ov(const DNNModel *model, DNNExecBaseParams *exec_param
     }
 
     ret = extract_lltask_from_task(model->func_type, task, ov_model->lltask_queue, exec_params);
-    if (ret != DNN_SUCCESS) {
+    if (ret != 0) {
         av_log(ctx, AV_LOG_ERROR, "unable to extract inference from task.\n");
         return ret;
     }
@@ -834,12 +834,12 @@ int ff_dnn_execute_model_ov(const DNNModel *model, DNNExecBaseParams *exec_param
             }
 
             ret = execute_model_ov(request, ov_model->lltask_queue);
-            if (ret != DNN_SUCCESS) {
+            if (ret != 0) {
                 return ret;
             }
         }
 
-        return DNN_SUCCESS;
+        return 0;
     }
     else {
         if (model->func_type == DFT_ANALYTICS_CLASSIFY) {
@@ -879,7 +879,7 @@ int ff_dnn_flush_ov(const DNNModel *model)
 
     if (ff_queue_size(ov_model->lltask_queue) == 0) {
         // no pending task need to flush
-        return DNN_SUCCESS;
+        return 0;
     }
 
     request = ff_safe_queue_pop_front(ov_model->request_queue);
@@ -889,7 +889,7 @@ int ff_dnn_flush_ov(const DNNModel *model)
     }
 
     ret = fill_model_input_ov(ov_model, request);
-    if (ret != DNN_SUCCESS) {
+    if (ret != 0) {
         av_log(ctx, AV_LOG_ERROR, "Failed to fill model input.\n");
         return ret;
     }
@@ -904,7 +904,7 @@ int ff_dnn_flush_ov(const DNNModel *model)
         return DNN_GENERIC_ERROR;
     }
 
-    return DNN_SUCCESS;
+    return 0;
 }
 
 void ff_dnn_free_model_ov(DNNModel **model)
diff --git a/libavfilter/dnn/dnn_backend_tf.c b/libavfilter/dnn/dnn_backend_tf.c
index cede1286c3..3b5084b67b 100644
--- a/libavfilter/dnn/dnn_backend_tf.c
+++ b/libavfilter/dnn/dnn_backend_tf.c
@@ -151,7 +151,7 @@ static TFInferRequest *tf_create_inference_request(void)
  * Start synchronous inference for the TensorFlow model.
  *
  * @param request pointer to the TFRequestItem for inference
- * @retval DNN_SUCCESS if execution is successful
+ * @retval 0 if execution is successful
  * @retval AVERROR(EINVAL) if request is NULL
  * @retval DNN_GENERIC_ERROR if execution fails
  */
@@ -181,7 +181,7 @@ static int tf_start_inference(void *args)
         }
         return DNN_GENERIC_ERROR;
     }
-    return DNN_SUCCESS;
+    return 0;
 }
 
 /**
@@ -220,7 +220,7 @@ static int extract_lltask_from_task(TaskItem *task, Queue *lltask_queue)
         av_freep(&lltask);
         return AVERROR(ENOMEM);
     }
-    return DNN_SUCCESS;
+    return 0;
 }
 
 static TF_Buffer *read_graph(const char *model_filename)
@@ -311,7 +311,7 @@ static int get_input_tf(void *model, DNNData *input, const char *input_name)
     input->width = dims[2];
     input->channels = dims[3];
 
-    return DNN_SUCCESS;
+    return 0;
 }
 
 static int get_output_tf(void *model, const char *input_name, int input_width, int input_height,
@@ -331,12 +331,12 @@ static int get_output_tf(void *model, const char *input_name, int input_width, i
     };
 
     ret = ff_dnn_fill_gettingoutput_task(&task, &exec_params, tf_model, input_height, input_width, ctx);
-    if (ret != DNN_SUCCESS) {
+    if (ret != 0) {
         goto err;
     }
 
     ret = extract_lltask_from_task(&task, tf_model->lltask_queue);
-    if (ret != DNN_SUCCESS) {
+    if (ret != 0) {
         av_log(ctx, AV_LOG_ERROR, "unable to extract inference from task.\n");
         goto err;
     }
@@ -487,7 +487,7 @@ static int load_tf_model(TFModel *tf_model, const char *model_filename)
         }
     }
 
-    return DNN_SUCCESS;
+    return 0;
 }
 
 #define NAME_BUFFER_SIZE 256
@@ -606,7 +606,7 @@ static int add_conv_layer(TFModel *tf_model, TF_Operation *transpose_op, TF_Oper
         goto err;
     }
 
-    return DNN_SUCCESS;
+    return 0;
 err:
     TF_DeleteTensor(kernel_tensor);
     TF_DeleteTensor(biases_tensor);
@@ -635,7 +635,7 @@ static int add_depth_to_space_layer(TFModel *tf_model, TF_Operation **cur_op,
         return DNN_GENERIC_ERROR;
     }
 
-    return DNN_SUCCESS;
+    return 0;
 }
 
 static int add_pad_layer(TFModel *tf_model, TF_Operation **cur_op,
@@ -693,7 +693,7 @@ static int add_pad_layer(TFModel *tf_model, TF_Operation **cur_op,
         return DNN_GENERIC_ERROR;
     }
 
-    return DNN_SUCCESS;
+    return 0;
 }
 
 static int add_maximum_layer(TFModel *tf_model, TF_Operation **cur_op,
@@ -742,7 +742,7 @@ static int add_maximum_layer(TFModel *tf_model, TF_Operation **cur_op,
         return DNN_GENERIC_ERROR;
     }
 
-    return DNN_SUCCESS;
+    return 0;
 }
 
 static int load_native_model(TFModel *tf_model, const char *model_filename)
@@ -808,7 +808,7 @@ static int load_native_model(TFModel *tf_model, const char *model_filename)
     for (layer = 0; layer < native_model->layers_num; ++layer){
         switch (native_model->layers[layer].type){
         case DLT_INPUT:
-            layer_add_res = DNN_SUCCESS;
+            layer_add_res = 0;
             break;
         case DLT_CONV2D:
             layer_add_res = add_conv_layer(tf_model, transpose_op, &op,
@@ -830,7 +830,7 @@ static int load_native_model(TFModel *tf_model, const char *model_filename)
             CLEANUP_ON_ERROR(tf_model);
         }
 
-        if (layer_add_res != DNN_SUCCESS){
+        if (layer_add_res != 0){
             CLEANUP_ON_ERROR(tf_model);
         }
     }
@@ -846,7 +846,7 @@ static int load_native_model(TFModel *tf_model, const char *model_filename)
 
     ff_dnn_free_model_native(&model);
 
-    return DNN_SUCCESS;
+    return 0;
 }
 
 DNNModel *ff_dnn_load_model_tf(const char *model_filename, DNNFunctionType func_type, const char *options, AVFilterContext *filter_ctx)
@@ -876,8 +876,8 @@ DNNModel *ff_dnn_load_model_tf(const char *model_filename, DNNFunctionType func_
         goto err;
     }
 
-    if (load_tf_model(tf_model, model_filename) != DNN_SUCCESS){
-        if (load_native_model(tf_model, model_filename) != DNN_SUCCESS){
+    if (load_tf_model(tf_model, model_filename) != 0){
+        if (load_native_model(tf_model, model_filename) != 0){
             goto err;
         }
     }
@@ -958,7 +958,7 @@ static int fill_model_input_tf(TFModel *tf_model, TFRequestItem *request) {
     request->lltask = lltask;
 
     ret = get_input_tf(tf_model, &input, task->input_name);
-    if (ret != DNN_SUCCESS) {
+    if (ret != 0) {
         goto err;
     }
 
@@ -1032,7 +1032,7 @@ static int fill_model_input_tf(TFModel *tf_model, TFRequestItem *request) {
         infer_request->tf_outputs[i].index = 0;
     }
 
-    return DNN_SUCCESS;
+    return 0;
 err:
     tf_free_request(infer_request);
     return ret;
@@ -1106,7 +1106,7 @@ static int execute_model_tf(TFRequestItem *request, Queue *lltask_queue)
 
     if (ff_queue_size(lltask_queue) == 0) {
         destroy_request_item(&request);
-        return DNN_SUCCESS;
+        return 0;
     }
 
     lltask = ff_queue_peek_front(lltask_queue);
@@ -1115,23 +1115,23 @@ static int execute_model_tf(TFRequestItem *request, Queue *lltask_queue)
     ctx = &tf_model->ctx;
 
     ret = fill_model_input_tf(tf_model, request);
-    if (ret != DNN_SUCCESS) {
+    if (ret != 0) {
         goto err;
     }
 
     if (task->async) {
-        if (ff_dnn_start_inference_async(ctx, &request->exec_module) != DNN_SUCCESS) {
+        if (ff_dnn_start_inference_async(ctx, &request->exec_module) != 0) {
             goto err;
         }
-        return DNN_SUCCESS;
+        return 0;
     }
     else {
         ret = tf_start_inference(request);
-        if (ret != DNN_SUCCESS) {
+        if (ret != 0) {
             goto err;
         }
         infer_completion_callback(request);
-        return (task->inference_done == task->inference_todo) ? DNN_SUCCESS : DNN_GENERIC_ERROR;
+        return (task->inference_done == task->inference_todo) ? 0 : DNN_GENERIC_ERROR;
     }
 err:
     tf_free_request(request->infer_request);
@@ -1161,7 +1161,7 @@ int ff_dnn_execute_model_tf(const DNNModel *model, DNNExecBaseParams *exec_param
     }
 
     ret = ff_dnn_fill_task(task, exec_params, tf_model, ctx->options.async, 1);
-    if (ret != DNN_SUCCESS) {
+    if (ret != 0) {
         av_freep(&task);
         return ret;
     }
@@ -1173,7 +1173,7 @@ int ff_dnn_execute_model_tf(const DNNModel *model, DNNExecBaseParams *exec_param
     }
 
     ret = extract_lltask_from_task(task, tf_model->lltask_queue);
-    if (ret != DNN_SUCCESS) {
+    if (ret != 0) {
         av_log(ctx, AV_LOG_ERROR, "unable to extract last level task from task.\n");
         return ret;
     }
@@ -1201,7 +1201,7 @@ int ff_dnn_flush_tf(const DNNModel *model)
 
     if (ff_queue_size(tf_model->lltask_queue) == 0) {
         // no pending task need to flush
-        return DNN_SUCCESS;
+        return 0;
     }
 
     request = ff_safe_queue_pop_front(tf_model->request_queue);
@@ -1211,7 +1211,7 @@ int ff_dnn_flush_tf(const DNNModel *model)
     }
 
     ret = fill_model_input_tf(tf_model, request);
-    if (ret != DNN_SUCCESS) {
+    if (ret != 0) {
         av_log(ctx, AV_LOG_ERROR, "Failed to fill model input.\n");
         if (ff_safe_queue_push_back(tf_model->request_queue, request) < 0) {
             destroy_request_item(&request);
diff --git a/libavfilter/dnn/dnn_io_proc.c b/libavfilter/dnn/dnn_io_proc.c
index 36cc051e5e..7961bf6b95 100644
--- a/libavfilter/dnn/dnn_io_proc.c
+++ b/libavfilter/dnn/dnn_io_proc.c
@@ -57,12 +57,12 @@ int ff_proc_from_dnn_to_frame(AVFrame *frame, DNNData *output, void *log_ctx)
                            (const int[4]){frame->width * 3 * sizeof(float), 0, 0, 0}, 0, frame->height,
                            (uint8_t * const*)frame->data, frame->linesize);
         sws_freeContext(sws_ctx);
-        return DNN_SUCCESS;
+        return 0;
     case AV_PIX_FMT_GRAYF32:
         av_image_copy_plane(frame->data[0], frame->linesize[0],
                             output->data, bytewidth,
                             bytewidth, frame->height);
-        return DNN_SUCCESS;
+        return 0;
     case AV_PIX_FMT_YUV420P:
     case AV_PIX_FMT_YUV422P:
     case AV_PIX_FMT_YUV444P:
@@ -88,13 +88,13 @@ int ff_proc_from_dnn_to_frame(AVFrame *frame, DNNData *output, void *log_ctx)
                            (const int[4]){frame->width * sizeof(float), 0, 0, 0}, 0, frame->height,
                            (uint8_t * const*)frame->data, frame->linesize);
         sws_freeContext(sws_ctx);
-        return DNN_SUCCESS;
+        return 0;
     default:
         avpriv_report_missing_feature(log_ctx, "%s", av_get_pix_fmt_name(frame->format));
         return AVERROR(ENOSYS);
     }
 
-    return DNN_SUCCESS;
+    return 0;
 }
 
 int ff_proc_from_frame_to_dnn(AVFrame *frame, DNNData *input, void *log_ctx)
@@ -169,7 +169,7 @@ int ff_proc_from_frame_to_dnn(AVFrame *frame, DNNData *input, void *log_ctx)
         return AVERROR(ENOSYS);
     }
 
-    return DNN_SUCCESS;
+    return 0;
 }
 
 static enum AVPixelFormat get_pixel_format(DNNData *data)
@@ -197,7 +197,7 @@ int ff_frame_to_dnn_classify(AVFrame *frame, DNNData *input, uint32_t bbox_index
     uint8_t *bbox_data[4];
     struct SwsContext *sws_ctx;
     int linesizes[4];
-    int ret = DNN_SUCCESS;
+    int ret = 0;
     enum AVPixelFormat fmt;
     int left, top, width, height;
     const AVDetectionBBoxHeader *header;
@@ -255,7 +255,7 @@ int ff_frame_to_dnn_detect(AVFrame *frame, DNNData *input, void *log_ctx)
 {
     struct SwsContext *sws_ctx;
     int linesizes[4];
-    int ret = DNN_SUCCESS;
+    int ret = 0;
     enum AVPixelFormat fmt = get_pixel_format(input);
     sws_ctx = sws_getContext(frame->width, frame->height, frame->format,
                              input->width, input->height, fmt,
diff --git a/libavfilter/dnn_interface.h b/libavfilter/dnn_interface.h
index 06e71f7946..ef8d7ae66f 100644
--- a/libavfilter/dnn_interface.h
+++ b/libavfilter/dnn_interface.h
@@ -32,8 +32,6 @@
 
 #define DNN_GENERIC_ERROR FFERRTAG('D','N','N','!')
 
-typedef enum {DNN_SUCCESS, DNN_ERROR} DNNReturnType;
-
 typedef enum {DNN_NATIVE, DNN_TF, DNN_OV} DNNBackendType;
 
 typedef enum {DNN_FLOAT = 1, DNN_UINT8 = 4} DNNDataType;
diff --git a/libavfilter/vf_derain.c b/libavfilter/vf_derain.c
index 6758cc05d2..86e9eb8752 100644
--- a/libavfilter/vf_derain.c
+++ b/libavfilter/vf_derain.c
@@ -74,7 +74,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     av_frame_copy_props(out, in);
 
     dnn_result = ff_dnn_execute_model(&dr_context->dnnctx, in, out);
-    if (dnn_result != DNN_SUCCESS){
+    if (dnn_result != 0){
         av_log(ctx, AV_LOG_ERROR, "failed to execute model\n");
         av_frame_free(&in);
         return dnn_result;
diff --git a/libavfilter/vf_dnn_classify.c b/libavfilter/vf_dnn_classify.c
index 5c6942d86a..c612ba8e80 100644
--- a/libavfilter/vf_dnn_classify.c
+++ b/libavfilter/vf_dnn_classify.c
@@ -213,7 +213,7 @@ static int dnn_classify_flush_frame(AVFilterLink *outlink, int64_t pts, int64_t
     DNNAsyncStatusType async_state;
 
     ret = ff_dnn_flush(&ctx->dnnctx);
-    if (ret != DNN_SUCCESS) {
+    if (ret != 0) {
         return -1;
     }
 
@@ -253,7 +253,7 @@ static int dnn_classify_activate(AVFilterContext *filter_ctx)
         if (ret < 0)
             return ret;
         if (ret > 0) {
-            if (ff_dnn_execute_model_classification(&ctx->dnnctx, in, NULL, ctx->target) != DNN_SUCCESS) {
+            if (ff_dnn_execute_model_classification(&ctx->dnnctx, in, NULL, ctx->target) != 0) {
                 return AVERROR(EIO);
             }
         }
diff --git a/libavfilter/vf_dnn_detect.c b/libavfilter/vf_dnn_detect.c
index 51f8b430df..dd4507250f 100644
--- a/libavfilter/vf_dnn_detect.c
+++ b/libavfilter/vf_dnn_detect.c
@@ -356,7 +356,7 @@ static int dnn_detect_flush_frame(AVFilterLink *outlink, int64_t pts, int64_t *o
     DNNAsyncStatusType async_state;
 
     ret = ff_dnn_flush(&ctx->dnnctx);
-    if (ret != DNN_SUCCESS) {
+    if (ret != 0) {
         return -1;
     }
 
@@ -396,7 +396,7 @@ static int dnn_detect_activate(AVFilterContext *filter_ctx)
         if (ret < 0)
             return ret;
         if (ret > 0) {
-            if (ff_dnn_execute_model(&ctx->dnnctx, in, NULL) != DNN_SUCCESS) {
+            if (ff_dnn_execute_model(&ctx->dnnctx, in, NULL) != 0) {
                 return AVERROR(EIO);
             }
         }
diff --git a/libavfilter/vf_dnn_processing.c b/libavfilter/vf_dnn_processing.c
index 4a1ff5898f..cac096a19f 100644
--- a/libavfilter/vf_dnn_processing.c
+++ b/libavfilter/vf_dnn_processing.c
@@ -139,7 +139,7 @@ static int config_input(AVFilterLink *inlink)
     int check;
 
     result = ff_dnn_get_input(&ctx->dnnctx, &model_input);
-    if (result != DNN_SUCCESS) {
+    if (result != 0) {
         av_log(ctx, AV_LOG_ERROR, "could not get input from the model\n");
         return result;
     }
@@ -199,7 +199,7 @@ static int config_output(AVFilterLink *outlink)
 
     // have a try run in case that the dnn model resize the frame
     result = ff_dnn_get_output(&ctx->dnnctx, inlink->w, inlink->h, &outlink->w, &outlink->h);
-    if (result != DNN_SUCCESS) {
+    if (result != 0) {
         av_log(ctx, AV_LOG_ERROR, "could not get output from the model\n");
         return result;
     }
@@ -247,7 +247,7 @@ static int flush_frame(AVFilterLink *outlink, int64_t pts, int64_t *out_pts)
     DNNAsyncStatusType async_state;
 
     ret = ff_dnn_flush(&ctx->dnnctx);
-    if (ret != DNN_SUCCESS) {
+    if (ret != 0) {
         return -1;
     }
 
@@ -296,7 +296,7 @@ static int activate(AVFilterContext *filter_ctx)
                 return AVERROR(ENOMEM);
             }
             av_frame_copy_props(out, in);
-            if (ff_dnn_execute_model(&ctx->dnnctx, in, out) != DNN_SUCCESS) {
+            if (ff_dnn_execute_model(&ctx->dnnctx, in, out) != 0) {
                 return AVERROR(EIO);
             }
         }
diff --git a/libavfilter/vf_sr.c b/libavfilter/vf_sr.c
index 02d9452681..0890c8ba18 100644
--- a/libavfilter/vf_sr.c
+++ b/libavfilter/vf_sr.c
@@ -82,7 +82,7 @@ static int config_output(AVFilterLink *outlink)
 
     // have a try run in case that the dnn model resize the frame
     result = ff_dnn_get_output(&ctx->dnnctx, inlink->w, inlink->h, &out_width, &out_height);
-    if (result != DNN_SUCCESS) {
+    if (result != 0) {
         av_log(ctx, AV_LOG_ERROR, "could not get output from the model\n");
         return result;
     }
@@ -139,7 +139,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
         dnn_result = ff_dnn_execute_model(&ctx->dnnctx, in, out);
     }
 
-    if (dnn_result != DNN_SUCCESS){
+    if (dnn_result != 0){
         av_log(ctx, AV_LOG_ERROR, "failed to execute loaded model\n");
         av_frame_free(&in);
         av_frame_free(&out);



More information about the ffmpeg-cvslog mailing list