]> git.sesse.net Git - ffmpeg/commitdiff
dnn_interface: add interface to support async execution
authorGuo, Yejun <yejun.guo@intel.com>
Wed, 18 Nov 2020 06:28:06 +0000 (14:28 +0800)
committerGuo, Yejun <yejun.guo@intel.com>
Tue, 29 Dec 2020 01:31:06 +0000 (09:31 +0800)
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
libavfilter/dnn_interface.h

index 7973d3e0172b2a79e2c2d220ba344e51bd6b86e6..f82ab12e9859685dec430e87fa03b9524e55352d 100644 (file)
@@ -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;
     }
index 2f129d535e51501db2beb820249ef81b0fc8ba33..9e54b91d1902e8a725f4ee19e43bca526ca0f9f3 100644 (file)
@@ -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;