This commit prepares the filter side to handle specific error codes from the DNN backends instead of current DNN_ERROR.
Unified · Split
| @@ -106,18 +106,18 @@ int ff_dnn_set_classify_post_proc(DnnContext *ctx, ClassifyPostProc post_proc) · 105 unmodified lines | ||
| 106 | 106 | return 0; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | −DNNReturnType ff_dnn_get_input(DnnContext *ctx, DNNData *input) | |
| 109 | +int ff_dnn_get_input(DnnContext *ctx, DNNData *input) | |
| 110 | 110 | { |
| 111 | 111 | return ctx->model->get_input(ctx->model->model, input, ctx->model_inputname); |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | −DNNReturnType ff_dnn_get_output(DnnContext *ctx, int input_width, int input_height, int *output_width, int *output_height) | |
| 114 | +int ff_dnn_get_output(DnnContext *ctx, int input_width, int input_height, int *output_width, int *output_height) | |
| 115 | 115 | { |
| 116 | 116 | return ctx->model->get_output(ctx->model->model, ctx->model_inputname, input_width, input_height, |
| 117 | 117 | (const char *)ctx->model_outputnames[0], output_width, output_height); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | −DNNReturnType ff_dnn_execute_model(DnnContext *ctx, AVFrame *in_frame, AVFrame *out_frame) | |
| 120 | +int ff_dnn_execute_model(DnnContext *ctx, AVFrame *in_frame, AVFrame *out_frame) | |
| 121 | 121 | { |
| 122 | 122 | DNNExecBaseParams exec_params = { |
| 123 | 123 | .input_name = ctx->model_inputname, |
| @@ -129,7 +129,7 @@ DNNReturnType ff_dnn_execute_model(DnnContext *ctx, AVFrame *in_frame, AVFrame * · 5 unmodified lines | ||
| 129 | 129 | return (ctx->dnn_module->execute_model)(ctx->model, &exec_params); |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | −DNNReturnType ff_dnn_execute_model_classification(DnnContext *ctx, AVFrame *in_frame, AVFrame *out_frame, const char *target) | |
| 132 | +int ff_dnn_execute_model_classification(DnnContext *ctx, AVFrame *in_frame, AVFrame *out_frame, const char *target) | |
| 133 | 133 | { |
| 134 | 134 | DNNExecClassificationParams class_params = { |
| 135 | 135 | { |
| @@ -149,7 +149,7 @@ DNNAsyncStatusType ff_dnn_get_result(DnnContext *ctx, AVFrame **in_frame, AVFram · 13 unmodified lines | ||
| 149 | 149 | return (ctx->dnn_module->get_result)(ctx->model, in_frame, out_frame); |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | −DNNReturnType ff_dnn_flush(DnnContext *ctx) | |
| 152 | +int ff_dnn_flush(DnnContext *ctx) | |
| 153 | 153 | { |
| 154 | 154 | return (ctx->dnn_module->flush)(ctx->model); |
| 155 | 155 | } |
| @@ -53,12 +53,12 @@ int ff_dnn_init(DnnContext *ctx, DNNFunctionType func_type, AVFilterContext *fil · 52 unmodified lines | ||
| 53 | 53 | int ff_dnn_set_frame_proc(DnnContext *ctx, FramePrePostProc pre_proc, FramePrePostProc post_proc); |
| 54 | 54 | int ff_dnn_set_detect_post_proc(DnnContext *ctx, DetectPostProc post_proc); |
| 55 | 55 | int ff_dnn_set_classify_post_proc(DnnContext *ctx, ClassifyPostProc post_proc); |
| 56 | −DNNReturnType ff_dnn_get_input(DnnContext *ctx, DNNData *input); | |
| 57 | −DNNReturnType ff_dnn_get_output(DnnContext *ctx, int input_width, int input_height, int *output_width, int *output_height); | |
| 58 | −DNNReturnType ff_dnn_execute_model(DnnContext *ctx, AVFrame *in_frame, AVFrame *out_frame); | |
| 59 | −DNNReturnType ff_dnn_execute_model_classification(DnnContext *ctx, AVFrame *in_frame, AVFrame *out_frame, const char *target); | |
| 56 | +int ff_dnn_get_input(DnnContext *ctx, DNNData *input); | |
| 57 | +int ff_dnn_get_output(DnnContext *ctx, int input_width, int input_height, int *output_width, int *output_height); | |
| 58 | +int ff_dnn_execute_model(DnnContext *ctx, AVFrame *in_frame, AVFrame *out_frame); | |
| 59 | +int ff_dnn_execute_model_classification(DnnContext *ctx, AVFrame *in_frame, AVFrame *out_frame, const char *target); | |
| 60 | 60 | DNNAsyncStatusType ff_dnn_get_result(DnnContext *ctx, AVFrame **in_frame, AVFrame **out_frame); |
| 61 | −DNNReturnType ff_dnn_flush(DnnContext *ctx); | |
| 61 | +int ff_dnn_flush(DnnContext *ctx); | |
| 62 | 62 | void ff_dnn_uninit(DnnContext *ctx); |
| 63 | 63 | |
| 64 | 64 | #endif |
| @@ -62,7 +62,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 61 unmodified lines | ||
| 62 | 62 | AVFilterContext *ctx = inlink->dst; |
| 63 | 63 | AVFilterLink *outlink = ctx->outputs[0]; |
| 64 | 64 | DRContext *dr_context = ctx->priv; |
| 65 | − DNNReturnType dnn_result; | |
| 65 | + int dnn_result; | |
| 66 | 66 | AVFrame *out; |
| 67 | 67 | |
| 68 | 68 | out = ff_get_video_buffer(outlink, outlink->w, outlink->h); |
| @@ -77,7 +77,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 8 unmodified lines | ||
| 77 | 77 | if (dnn_result != DNN_SUCCESS){ |
| 78 | 78 | av_log(ctx, AV_LOG_ERROR, "failed to execute model\n"); |
| 79 | 79 | av_frame_free(&in); |
| 80 | − return AVERROR(EIO); | |
| 80 | + return dnn_result; | |
| 81 | 81 | } |
| 82 | 82 | do { |
| 83 | 83 | async_state = ff_dnn_get_result(&dr_context->dnnctx, &in, &out); |
| @@ -134,14 +134,14 @@ static int config_input(AVFilterLink *inlink) · 133 unmodified lines | ||
| 134 | 134 | { |
| 135 | 135 | AVFilterContext *context = inlink->dst; |
| 136 | 136 | DnnProcessingContext *ctx = context->priv; |
| 137 | − DNNReturnType result; | |
| 137 | + int result; | |
| 138 | 138 | DNNData model_input; |
| 139 | 139 | int check; |
| 140 | 140 | |
| 141 | 141 | result = ff_dnn_get_input(&ctx->dnnctx, &model_input); |
| 142 | 142 | if (result != DNN_SUCCESS) { |
| 143 | 143 | av_log(ctx, AV_LOG_ERROR, "could not get input from the model\n"); |
| 144 | − return AVERROR(EIO); | |
| 144 | + return result; | |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | check = check_modelinput_inlink(&model_input, inlink); |
| @@ -194,14 +194,14 @@ static int config_output(AVFilterLink *outlink) · 46 unmodified lines | ||
| 194 | 194 | { |
| 195 | 195 | AVFilterContext *context = outlink->src; |
| 196 | 196 | DnnProcessingContext *ctx = context->priv; |
| 197 | − DNNReturnType result; | |
| 197 | + int result; | |
| 198 | 198 | AVFilterLink *inlink = context->inputs[0]; |
| 199 | 199 | |
| 200 | 200 | // have a try run in case that the dnn model resize the frame |
| 201 | 201 | result = ff_dnn_get_output(&ctx->dnnctx, inlink->w, inlink->h, &outlink->w, &outlink->h); |
| 202 | 202 | if (result != DNN_SUCCESS) { |
| 203 | 203 | av_log(ctx, AV_LOG_ERROR, "could not get output from the model\n"); |
| 204 | − return AVERROR(EIO); | |
| 204 | + return result; | |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | prepare_uv_scale(outlink); |
| @@ -76,7 +76,7 @@ static int config_output(AVFilterLink *outlink) · 75 unmodified lines | ||
| 76 | 76 | { |
| 77 | 77 | AVFilterContext *context = outlink->src; |
| 78 | 78 | SRContext *ctx = context->priv; |
| 79 | − DNNReturnType result; | |
| 79 | + int result; | |
| 80 | 80 | AVFilterLink *inlink = context->inputs[0]; |
| 81 | 81 | int out_width, out_height; |
| 82 | 82 | |
| @@ -84,7 +84,7 @@ static int config_output(AVFilterLink *outlink) · 1 unmodified line | ||
| 84 | 84 | result = ff_dnn_get_output(&ctx->dnnctx, inlink->w, inlink->h, &out_width, &out_height); |
| 85 | 85 | if (result != DNN_SUCCESS) { |
| 86 | 86 | av_log(ctx, AV_LOG_ERROR, "could not get output from the model\n"); |
| 87 | − return AVERROR(EIO); | |
| 87 | + return result; | |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | if (inlink->w != out_width || inlink->h != out_height) { |
| @@ -121,7 +121,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 30 unmodified lines | ||
| 121 | 121 | SRContext *ctx = context->priv; |
| 122 | 122 | AVFilterLink *outlink = context->outputs[0]; |
| 123 | 123 | AVFrame *out = ff_get_video_buffer(outlink, outlink->w, outlink->h); |
| 124 | − DNNReturnType dnn_result; | |
| 124 | + int dnn_result; | |
| 125 | 125 | |
| 126 | 126 | if (!out){ |
| 127 | 127 | av_log(context, AV_LOG_ERROR, "could not allocate memory for output frame\n"); |
| @@ -143,7 +143,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 15 unmodified lines | ||
| 143 | 143 | av_log(ctx, AV_LOG_ERROR, "failed to execute loaded model\n"); |
| 144 | 144 | av_frame_free(&in); |
| 145 | 145 | av_frame_free(&out); |
| 146 | − return AVERROR(EIO); | |
| 146 | + return dnn_result; | |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | do { |