diff mbox series

[FFmpeg-devel,5/8] dnn_interface: add interface to support async execution

Message ID 20201222074613.6357-1-yejun.guo@intel.com
State Accepted
Commit 39f5cb4bd1bbb12632baac24dd7b9bb5a68bef8d
Headers show
Series [FFmpeg-devel,1/8] vf_dnn_processing.c: replace filter_frame with activate func
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Guo, Yejun Dec. 22, 2020, 7:46 a.m. UTC
Signed-off-by: Xie, Lin <lin.xie@intel.com>
Signed-off-by: Wu Zhiwen <zhiwen.wu@intel.com>
Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
---
 libavfilter/dnn/dnn_interface.c |  2 +-
 libavfilter/dnn_interface.h     | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavfilter/dnn/dnn_interface.c b/libavfilter/dnn/dnn_interface.c
index 7973d3e017..f82ab12e98 100644
--- a/libavfilter/dnn/dnn_interface.c
+++ b/libavfilter/dnn/dnn_interface.c
@@ -33,7 +33,7 @@  DNNModule *ff_get_dnn_module(DNNBackendType backend_type)
 {
     DNNModule *dnn_module;
 
-    dnn_module = av_malloc(sizeof(DNNModule));
+    dnn_module = av_mallocz(sizeof(DNNModule));
     if(!dnn_module){
         return NULL;
     }
diff --git a/libavfilter/dnn_interface.h b/libavfilter/dnn_interface.h
index 2f129d535e..9e54b91d19 100644
--- a/libavfilter/dnn_interface.h
+++ b/libavfilter/dnn_interface.h
@@ -35,6 +35,13 @@  typedef enum {DNN_NATIVE, DNN_TF, DNN_OV} DNNBackendType;
 
 typedef enum {DNN_FLOAT = 1, DNN_UINT8 = 4} DNNDataType;
 
+typedef enum {
+    DAST_FAIL,              // something wrong
+    DAST_EMPTY_QUEUE,       // no more inference result to get
+    DAST_NOT_READY,         // all queued inferences are not finished
+    DAST_SUCCESS            // got a result frame successfully
+} DNNAsyncStatusType;
+
 typedef struct DNNData{
     void *data;
     DNNDataType dt;
@@ -69,6 +76,11 @@  typedef struct DNNModule{
     // Executes model with specified input and output. Returns DNN_ERROR otherwise.
     DNNReturnType (*execute_model)(const DNNModel *model, const char *input_name, AVFrame *in_frame,
                                    const char **output_names, uint32_t nb_output, AVFrame *out_frame);
+    // Executes model with specified input and output asynchronously. Returns DNN_ERROR otherwise.
+    DNNReturnType (*execute_model_async)(const DNNModel *model, const char *input_name, AVFrame *in_frame,
+                                         const char **output_names, uint32_t nb_output, AVFrame *out_frame);
+    // Retrieve inference result.
+    DNNAsyncStatusType (*get_async_result)(const DNNModel *model, AVFrame **out);
     // Frees memory allocated for model.
     void (*free_model)(DNNModel **model);
 } DNNModule;