@@ -122,3 +122,23 @@ DNNReturnType ff_dnn_start_inference_async(void *ctx, DNNAsyncExecModule *async_
#endif
return DNN_SUCCESS;
}
+
+DNNAsyncStatusType ff_dnn_get_async_result_common(Queue *task_queue, AVFrame **in, AVFrame **out)
+{
+ TaskItem *task = ff_queue_peek_front(task_queue);
+
+ if (!task) {
+ return DAST_EMPTY_QUEUE;
+ }
+
+ if (task->inference_done != task->inference_todo) {
+ return DAST_NOT_READY;
+ }
+
+ *in = task->in_frame;
+ *out = task->out_frame;
+ ff_queue_pop_front(task_queue);
+ av_freep(&task);
+
+ return DAST_SUCCESS;
+}
@@ -24,6 +24,7 @@
#ifndef AVFILTER_DNN_DNN_BACKEND_COMMON_H
#define AVFILTER_DNN_DNN_BACKEND_COMMON_H
+#include "queue.h"
#include "../dnn_interface.h"
#include "libavutil/thread.h"
@@ -122,4 +123,18 @@ DNNReturnType ff_dnn_async_module_cleanup(DNNAsyncExecModule *async_module);
*/
DNNReturnType ff_dnn_start_inference_async(void *ctx, DNNAsyncExecModule *async_module);
+/**
+ * Extract input and output frame from the Task Queue after
+ * asynchronous inference.
+ *
+ * @param task_queue pointer to the task queue of the backend
+ * @param in double pointer to the input frame
+ * @param out double pointer to the output frame
+ *
+ * @retval DAST_EMPTY_QUEUE if task queue is empty
+ * @retval DAST_NOT_READY if inference not completed yet.
+ * @retval DAST_SUCCESS if result successfully extracted
+ */
+DNNAsyncStatusType ff_dnn_get_async_result_common(Queue *task_queue, AVFrame **in, AVFrame **out);
+
#endif
@@ -32,7 +32,6 @@
#include "libavutil/avstring.h"
#include "libavutil/detection_bbox.h"
#include "../internal.h"
-#include "queue.h"
#include "safe_queue.h"
#include <c_api/ie_c_api.h>
#include "dnn_backend_common.h"
@@ -883,22 +882,7 @@ DNNReturnType ff_dnn_execute_model_async_ov(const DNNModel *model, DNNExecBasePa
DNNAsyncStatusType ff_dnn_get_async_result_ov(const DNNModel *model, AVFrame **in, AVFrame **out)
{
OVModel *ov_model = model->model;
- TaskItem *task = ff_queue_peek_front(ov_model->task_queue);
-
- if (!task) {
- return DAST_EMPTY_QUEUE;
- }
-
- if (task->inference_done != task->inference_todo) {
- return DAST_NOT_READY;
- }
-
- *in = task->in_frame;
- *out = task->out_frame;
- ff_queue_pop_front(ov_model->task_queue);
- av_freep(&task);
-
- return DAST_SUCCESS;
+ return ff_dnn_get_async_result_common(ov_model->task_queue, in, out);
}
DNNReturnType ff_dnn_flush_ov(const DNNModel *model)
@@ -18,6 +18,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <stddef.h>
#ifndef AVFILTER_DNN_QUEUE_H
#define AVFILTER_DNN_QUEUE_H
This commits refactors the get async result function for common use in all three backends. Signed-off-by: Shubhanshu Saxena <shubhanshu.e01@gmail.com> --- libavfilter/dnn/dnn_backend_common.c | 20 ++++++++++++++++++++ libavfilter/dnn/dnn_backend_common.h | 15 +++++++++++++++ libavfilter/dnn/dnn_backend_openvino.c | 18 +----------------- libavfilter/dnn/queue.h | 1 + 4 files changed, 37 insertions(+), 17 deletions(-)