It prevents the filter of running in case such option is missing, failing early, during init() instead of simply logging an error during runtime.
Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -173,11 +173,6 @@ static int dnn_detect_parse_yolo_output(AVFrame *frame, DNNData *output, int out · 172 unmodified lines | ||
| 173 | 173 | return AVERROR(EINVAL); |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | − if (!anchors) { | |
| 177 | − av_log(filter_ctx, AV_LOG_ERROR, "anchors is not set\n"); | |
| 178 | − return AVERROR(EINVAL); | |
| 179 | − } | |
| 180 | − | |
| 181 | 176 | if (output[output_index].dims[1] * output[output_index].dims[2] * |
| 182 | 177 | output[output_index].dims[3] % (box_size * cell_w * cell_h)) { |
| 183 | 178 | av_log(filter_ctx, AV_LOG_ERROR, "wrong cell_w, cell_h or nb_classes\n"); |
| @@ -656,6 +651,14 @@ static av_cold int dnn_detect_init(AVFilterContext *context) · 472 unmodified lines | ||
| 656 | 651 | DnnDetectContext *ctx = context->priv; |
| 657 | 652 | DnnContext *dnn_ctx = &ctx->dnnctx; |
| 658 | 653 | int ret; |
| 654 | + int using_yolo = (ctx->model_type == DDMT_YOLOV3 || | |
| 655 | + ctx->model_type == DDMT_YOLOV4 || | |
| 656 | + ctx->model_type == DDMT_YOLOV1V2); | |
| 657 | + | |
| 658 | + if (using_yolo && !ctx->anchors) { | |
| 659 | + av_log(ctx, AV_LOG_ERROR, "anchors is not set while being required for YOLO models\n"); | |
| 660 | + return AVERROR(EINVAL); | |
| 661 | + } | |
| 659 | 662 | |
| 660 | 663 | ret = ff_dnn_init(&ctx->dnnctx, DFT_ANALYTICS_DETECT, context); |
| 661 | 664 | if (ret < 0) |