@ -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 ;