From: Shubhanshu Saxena <shubhanshu.e01@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Shubhanshu Saxena <shubhanshu.e01@gmail.com>
Subject: [FFmpeg-devel] [PATCH V2 7/8] lavfi/dnn_backend_common: Return specific error codes
Date: Wed, 2 Mar 2022 23:35:55 +0530
Message-ID: <20220302180556.19865-7-shubhanshu.e01@gmail.com> (raw)
In-Reply-To: <20220302180556.19865-1-shubhanshu.e01@gmail.com>
Switch to returning specific error codes or DNN_GENERIC_ERROR
when an error is encountered in the common DNN backend functions.
Signed-off-by: Shubhanshu Saxena <shubhanshu.e01@gmail.com>
---
libavfilter/dnn/dnn_backend_common.c | 35 ++++++++++++++--------------
libavfilter/dnn/dnn_backend_common.h | 22 +++++++----------
2 files changed, 27 insertions(+), 30 deletions(-)
diff --git a/libavfilter/dnn/dnn_backend_common.c b/libavfilter/dnn/dnn_backend_common.c
index 6a9c4cc87f..64ed441415 100644
--- a/libavfilter/dnn/dnn_backend_common.c
+++ b/libavfilter/dnn/dnn_backend_common.c
@@ -47,19 +47,19 @@ int ff_check_exec_params(void *ctx, DNNBackendType backend, DNNFunctionType func
// currently, the filter does not need multiple outputs,
// so we just pending the support until we really need it.
avpriv_report_missing_feature(ctx, "multiple outputs");
- return AVERROR(EINVAL);
+ return AVERROR(ENOSYS);
}
return 0;
}
-DNNReturnType ff_dnn_fill_task(TaskItem *task, DNNExecBaseParams *exec_params, void *backend_model, int async, int do_ioproc) {
+int ff_dnn_fill_task(TaskItem *task, DNNExecBaseParams *exec_params, void *backend_model, int async, int do_ioproc) {
if (task == NULL || exec_params == NULL || backend_model == NULL)
- return DNN_ERROR;
+ return AVERROR(EINVAL);
if (do_ioproc != 0 && do_ioproc != 1)
- return DNN_ERROR;
+ return AVERROR(EINVAL);
if (async != 0 && async != 1)
- return DNN_ERROR;
+ return AVERROR(EINVAL);
task->do_ioproc = do_ioproc;
task->async = async;
@@ -89,17 +89,17 @@ static void *async_thread_routine(void *args)
return DNN_ASYNC_SUCCESS;
}
-DNNReturnType ff_dnn_async_module_cleanup(DNNAsyncExecModule *async_module)
+int ff_dnn_async_module_cleanup(DNNAsyncExecModule *async_module)
{
void *status = 0;
if (!async_module) {
- return DNN_ERROR;
+ return AVERROR(EINVAL);
}
#if HAVE_PTHREAD_CANCEL
pthread_join(async_module->thread_id, &status);
if (status == DNN_ASYNC_FAIL) {
av_log(NULL, AV_LOG_ERROR, "Last Inference Failed.\n");
- return DNN_ERROR;
+ return DNN_GENERIC_ERROR;
}
#endif
async_module->start_inference = NULL;
@@ -108,30 +108,31 @@ DNNReturnType ff_dnn_async_module_cleanup(DNNAsyncExecModule *async_module)
return DNN_SUCCESS;
}
-DNNReturnType ff_dnn_start_inference_async(void *ctx, DNNAsyncExecModule *async_module)
+int ff_dnn_start_inference_async(void *ctx, DNNAsyncExecModule *async_module)
{
int ret;
void *status = 0;
if (!async_module) {
av_log(ctx, AV_LOG_ERROR, "async_module is null when starting async inference.\n");
- return DNN_ERROR;
+ return AVERROR(EINVAL);
}
#if HAVE_PTHREAD_CANCEL
pthread_join(async_module->thread_id, &status);
if (status == DNN_ASYNC_FAIL) {
av_log(ctx, AV_LOG_ERROR, "Unable to start inference as previous inference failed.\n");
- return DNN_ERROR;
+ return DNN_GENERIC_ERROR;
}
ret = pthread_create(&async_module->thread_id, NULL, async_thread_routine, async_module);
if (ret != 0) {
av_log(ctx, AV_LOG_ERROR, "Unable to start async inference.\n");
- return DNN_ERROR;
+ return ret;
}
#else
- if (async_module->start_inference(async_module->args) != DNN_SUCCESS) {
- return DNN_ERROR;
+ ret = async_module->start_inference(async_module->args);
+ if (ret != DNN_SUCCESS) {
+ return ret;
}
async_module->callback(async_module->args);
#endif
@@ -158,7 +159,7 @@ DNNAsyncStatusType ff_dnn_get_result_common(Queue *task_queue, AVFrame **in, AVF
return DAST_SUCCESS;
}
-DNNReturnType ff_dnn_fill_gettingoutput_task(TaskItem *task, DNNExecBaseParams *exec_params, void *backend_model, int input_height, int input_width, void *ctx)
+int ff_dnn_fill_gettingoutput_task(TaskItem *task, DNNExecBaseParams *exec_params, void *backend_model, int input_height, int input_width, void *ctx)
{
AVFrame *in_frame = NULL;
AVFrame *out_frame = NULL;
@@ -166,14 +167,14 @@ DNNReturnType ff_dnn_fill_gettingoutput_task(TaskItem *task, DNNExecBaseParams *
in_frame = av_frame_alloc();
if (!in_frame) {
av_log(ctx, AV_LOG_ERROR, "Failed to allocate memory for input frame\n");
- return DNN_ERROR;
+ return AVERROR(ENOMEM);
}
out_frame = av_frame_alloc();
if (!out_frame) {
av_frame_free(&in_frame);
av_log(ctx, AV_LOG_ERROR, "Failed to allocate memory for output frame\n");
- return DNN_ERROR;
+ return AVERROR(ENOMEM);
}
in_frame->width = input_width;
diff --git a/libavfilter/dnn/dnn_backend_common.h b/libavfilter/dnn/dnn_backend_common.h
index 6b6a5e21ae..fa79caee1f 100644
--- a/libavfilter/dnn/dnn_backend_common.h
+++ b/libavfilter/dnn/dnn_backend_common.h
@@ -60,7 +60,7 @@ typedef struct DNNAsyncExecModule {
* Synchronous inference function for the backend
* with corresponding request item as the argument.
*/
- DNNReturnType (*start_inference)(void *request);
+ int (*start_inference)(void *request);
/**
* Completion Callback for the backend.
@@ -92,20 +92,18 @@ 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
*
- * @retval DNN_SUCCESS if successful
- * @retval DNN_ERROR if flags are invalid or any parameter is NULL
+ * @returns DNN_SUCCESS if successful or error code otherwise.
*/
-DNNReturnType ff_dnn_fill_task(TaskItem *task, DNNExecBaseParams *exec_params, void *backend_model, int async, int do_ioproc);
+int ff_dnn_fill_task(TaskItem *task, DNNExecBaseParams *exec_params, void *backend_model, int async, int do_ioproc);
/**
* Join the Async Execution thread and set module pointers to NULL.
*
* @param async_module pointer to DNNAsyncExecModule module
*
- * @retval DNN_SUCCESS if successful
- * @retval DNN_ERROR if async_module is NULL
+ * @returns DNN_SUCCESS if successful or error code otherwise.
*/
-DNNReturnType ff_dnn_async_module_cleanup(DNNAsyncExecModule *async_module);
+int ff_dnn_async_module_cleanup(DNNAsyncExecModule *async_module);
/**
* Start asynchronous inference routine for the TensorFlow
@@ -119,10 +117,9 @@ DNNReturnType ff_dnn_async_module_cleanup(DNNAsyncExecModule *async_module);
* @param ctx pointer to the backend context
* @param async_module pointer to DNNAsyncExecModule module
*
- * @retval DNN_SUCCESS on the start of async inference.
- * @retval DNN_ERROR in case async inference cannot be started
+ * @returns DNN_SUCCESS on the start of async inference or error code otherwise.
*/
-DNNReturnType ff_dnn_start_inference_async(void *ctx, DNNAsyncExecModule *async_module);
+int ff_dnn_start_inference_async(void *ctx, DNNAsyncExecModule *async_module);
/**
* Extract input and output frame from the Task Queue after
@@ -149,9 +146,8 @@ 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
*
- * @retval DNN_SUCCESS if successful
- * @retval DNN_ERROR if allocation fails
+ * @returns DNN_SUCCESS if successful or error code otherwise.
*/
-DNNReturnType ff_dnn_fill_gettingoutput_task(TaskItem *task, DNNExecBaseParams *exec_params, void *backend_model, int input_height, int input_width, void *ctx);
+int ff_dnn_fill_gettingoutput_task(TaskItem *task, DNNExecBaseParams *exec_params, void *backend_model, int input_height, int input_width, void *ctx);
#endif
--
2.32.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2022-03-02 18:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-02 18:05 [FFmpeg-devel] [PATCH V2 1/8] libavfilter: Prepare to handle specific error codes in DNN Filters Shubhanshu Saxena
2022-03-02 18:05 ` [FFmpeg-devel] [PATCH V2 2/8] lavfi/dnn: Error Specificity in Native Backend Layers Shubhanshu Saxena
2022-03-02 18:05 ` [FFmpeg-devel] [PATCH V2 3/8] lavfi/dnn_io_proc: Return Specific Error Codes Shubhanshu Saxena
2022-03-02 18:05 ` [FFmpeg-devel] [PATCH V2 4/8] lavfi/dnn_backend_openvino: " Shubhanshu Saxena
2022-03-02 18:05 ` [FFmpeg-devel] [PATCH V2 5/8] lavfi/dnn_backend_tf: " Shubhanshu Saxena
2022-03-02 18:05 ` [FFmpeg-devel] [PATCH V2 6/8] lavfi/dnn_backend_native: " Shubhanshu Saxena
2022-03-02 18:05 ` Shubhanshu Saxena [this message]
2022-03-02 18:05 ` [FFmpeg-devel] [PATCH V2 8/8] libavfilter: Remove DNNReturnType from DNN Module Shubhanshu Saxena
2022-03-08 14:18 ` Guo, Yejun
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220302180556.19865-7-shubhanshu.e01@gmail.com \
--to=shubhanshu.e01@gmail.com \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git