[FFmpeg-cvslog] avfilter/dnn_backend_openvino: reduce indentation in free_model_ov

Zhao Zhili git at videolan.org
Fri Sep 15 08:38:29 EEST 2023


ffmpeg | branch: master | Zhao Zhili <zhilizhao at tencent.com> | Sat Sep  2 16:23:54 2023 +0800| [7cb632929614677adf96c75331a4af93b245628c] | committer: Guo Yejun

avfilter/dnn_backend_openvino: reduce indentation in free_model_ov

No functional changes except ensures model isn't null.

Signed-off-by: Zhao Zhili <zhilizhao at tencent.com>

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

 libavfilter/dnn/dnn_backend_openvino.c | 89 ++++++++++++++++++----------------
 1 file changed, 46 insertions(+), 43 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_openvino.c b/libavfilter/dnn/dnn_backend_openvino.c
index 951f179b7c..85db4ecd35 100644
--- a/libavfilter/dnn/dnn_backend_openvino.c
+++ b/libavfilter/dnn/dnn_backend_openvino.c
@@ -463,58 +463,61 @@ static void infer_completion_callback(void *args)
 
 static void dnn_free_model_ov(DNNModel **model)
 {
-    if (*model){
-        OVModel *ov_model = (*model)->model;
-        while (ff_safe_queue_size(ov_model->request_queue) != 0) {
-            OVRequestItem *item = ff_safe_queue_pop_front(ov_model->request_queue);
-            if (item && item->infer_request) {
+    OVModel *ov_model;
+
+    if (!model || !*model)
+        return;
+
+    ov_model = (*model)->model;
+    while (ff_safe_queue_size(ov_model->request_queue) != 0) {
+        OVRequestItem *item = ff_safe_queue_pop_front(ov_model->request_queue);
+        if (item && item->infer_request) {
 #if HAVE_OPENVINO2
-                ov_infer_request_free(item->infer_request);
+            ov_infer_request_free(item->infer_request);
 #else
-                ie_infer_request_free(&item->infer_request);
+            ie_infer_request_free(&item->infer_request);
 #endif
-            }
-            av_freep(&item->lltasks);
-            av_freep(&item);
         }
-        ff_safe_queue_destroy(ov_model->request_queue);
+        av_freep(&item->lltasks);
+        av_freep(&item);
+    }
+    ff_safe_queue_destroy(ov_model->request_queue);
 
-        while (ff_queue_size(ov_model->lltask_queue) != 0) {
-            LastLevelTaskItem *item = ff_queue_pop_front(ov_model->lltask_queue);
-            av_freep(&item);
-        }
-        ff_queue_destroy(ov_model->lltask_queue);
+    while (ff_queue_size(ov_model->lltask_queue) != 0) {
+        LastLevelTaskItem *item = ff_queue_pop_front(ov_model->lltask_queue);
+        av_freep(&item);
+    }
+    ff_queue_destroy(ov_model->lltask_queue);
 
-        while (ff_queue_size(ov_model->task_queue) != 0) {
-            TaskItem *item = ff_queue_pop_front(ov_model->task_queue);
-            av_frame_free(&item->in_frame);
-            av_frame_free(&item->out_frame);
-            av_freep(&item);
-        }
-        ff_queue_destroy(ov_model->task_queue);
+    while (ff_queue_size(ov_model->task_queue) != 0) {
+        TaskItem *item = ff_queue_pop_front(ov_model->task_queue);
+        av_frame_free(&item->in_frame);
+        av_frame_free(&item->out_frame);
+        av_freep(&item);
+    }
+    ff_queue_destroy(ov_model->task_queue);
 #if HAVE_OPENVINO2
-        if (ov_model->preprocess)
-            ov_preprocess_prepostprocessor_free(ov_model->preprocess);
-        if (ov_model->compiled_model)
-            ov_compiled_model_free(ov_model->compiled_model);
-        if (ov_model->ov_model)
-            ov_model_free(ov_model->ov_model);
-        if (ov_model->core)
-            ov_core_free(ov_model->core);
+    if (ov_model->preprocess)
+        ov_preprocess_prepostprocessor_free(ov_model->preprocess);
+    if (ov_model->compiled_model)
+        ov_compiled_model_free(ov_model->compiled_model);
+    if (ov_model->ov_model)
+        ov_model_free(ov_model->ov_model);
+    if (ov_model->core)
+        ov_core_free(ov_model->core);
 #else
-        if (ov_model->exe_network)
-            ie_exec_network_free(&ov_model->exe_network);
-        if (ov_model->network)
-            ie_network_free(&ov_model->network);
-        if (ov_model->core)
-            ie_core_free(&ov_model->core);
-        av_free(ov_model->all_output_names);
-        av_free(ov_model->all_input_names);
+    if (ov_model->exe_network)
+        ie_exec_network_free(&ov_model->exe_network);
+    if (ov_model->network)
+        ie_network_free(&ov_model->network);
+    if (ov_model->core)
+        ie_core_free(&ov_model->core);
+    av_free(ov_model->all_output_names);
+    av_free(ov_model->all_input_names);
 #endif
-        av_opt_free(&ov_model->ctx);
-        av_freep(&ov_model);
-        av_freep(model);
-    }
+    av_opt_free(&ov_model->ctx);
+    av_freep(&ov_model);
+    av_freep(model);
 }
 
 



More information about the ffmpeg-cvslog mailing list