This commit removes the unused sync mode specific code from the DNN filters since the sync and async mode are now unified from the filters' perspective.
Unified · Split
| @@ -353,63 +353,6 @@ static int dnn_detect_query_formats(AVFilterContext *context) · 352 unmodified lines | ||
| 353 | 353 | return ff_set_common_formats_from_list(context, pix_fmts); |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | −static int dnn_detect_filter_frame(AVFilterLink *inlink, AVFrame *in) | |
| 357 | −{ | |
| 358 | − AVFilterContext *context = inlink->dst; | |
| 359 | − AVFilterLink *outlink = context->outputs[0]; | |
| 360 | − DnnDetectContext *ctx = context->priv; | |
| 361 | − DNNReturnType dnn_result; | |
| 362 | − | |
| 363 | − dnn_result = ff_dnn_execute_model(&ctx->dnnctx, in, in); | |
| 364 | − if (dnn_result != DNN_SUCCESS){ | |
| 365 | − av_log(ctx, AV_LOG_ERROR, "failed to execute model\n"); | |
| 366 | − av_frame_free(&in); | |
| 367 | − return AVERROR(EIO); | |
| 368 | − } | |
| 369 | − | |
| 370 | − return ff_filter_frame(outlink, in); | |
| 371 | −} | |
| 372 | − | |
| 373 | −static int dnn_detect_activate_sync(AVFilterContext *filter_ctx) | |
| 374 | −{ | |
| 375 | − AVFilterLink *inlink = filter_ctx->inputs[0]; | |
| 376 | − AVFilterLink *outlink = filter_ctx->outputs[0]; | |
| 377 | − AVFrame *in = NULL; | |
| 378 | − int64_t pts; | |
| 379 | − int ret, status; | |
| 380 | − int got_frame = 0; | |
| 381 | − | |
| 382 | − FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink); | |
| 383 | − | |
| 384 | − do { | |
| 385 | − // drain all input frames | |
| 386 | − ret = ff_inlink_consume_frame(inlink, &in); | |
| 387 | − if (ret < 0) | |
| 388 | − return ret; | |
| 389 | − if (ret > 0) { | |
| 390 | − ret = dnn_detect_filter_frame(inlink, in); | |
| 391 | − if (ret < 0) | |
| 392 | − return ret; | |
| 393 | − got_frame = 1; | |
| 394 | − } | |
| 395 | − } while (ret > 0); | |
| 396 | − | |
| 397 | − // if frame got, schedule to next filter | |
| 398 | − if (got_frame) | |
| 399 | − return 0; | |
| 400 | − | |
| 401 | − if (ff_inlink_acknowledge_status(inlink, &status, &pts)) { | |
| 402 | − if (status == AVERROR_EOF) { | |
| 403 | − ff_outlink_set_status(outlink, status, pts); | |
| 404 | − return ret; | |
| 405 | − } | |
| 406 | − } | |
| 407 | − | |
| 408 | − FF_FILTER_FORWARD_WANTED(outlink, inlink); | |
| 409 | − | |
| 410 | − return FFERROR_NOT_READY; | |
| 411 | −} | |
| 412 | − | |
| 413 | 356 | static int dnn_detect_flush_frame(AVFilterLink *outlink, int64_t pts, int64_t *out_pts) |
| 414 | 357 | { |
| 415 | 358 | DnnDetectContext *ctx = outlink->src->priv; |
| @@ -438,7 +381,7 @@ static int dnn_detect_flush_frame(AVFilterLink *outlink, int64_t pts, int64_t *o · 22 unmodified lines | ||
| 438 | 381 | return 0; |
| 439 | 382 | } |
| 440 | 383 | |
| 441 | −static int dnn_detect_activate_async(AVFilterContext *filter_ctx) | |
| 384 | +static int dnn_detect_activate(AVFilterContext *filter_ctx) | |
| 442 | 385 | { |
| 443 | 386 | AVFilterLink *inlink = filter_ctx->inputs[0]; |
| 444 | 387 | AVFilterLink *outlink = filter_ctx->outputs[0]; |
| @@ -494,16 +437,6 @@ static int dnn_detect_activate_async(AVFilterContext *filter_ctx) · 49 unmodified lines | ||
| 494 | 437 | return 0; |
| 495 | 438 | } |
| 496 | 439 | |
| 497 | −static av_unused int dnn_detect_activate(AVFilterContext *filter_ctx) | |
| 498 | −{ | |
| 499 | − DnnDetectContext *ctx = filter_ctx->priv; | |
| 500 | − | |
| 501 | − if (ctx->dnnctx.async) | |
| 502 | − return dnn_detect_activate_async(filter_ctx); | |
| 503 | − else | |
| 504 | − return dnn_detect_activate_sync(filter_ctx); | |
| 505 | −} | |
| 506 | − | |
| 507 | 440 | static av_cold void dnn_detect_uninit(AVFilterContext *context) |
| 508 | 441 | { |
| 509 | 442 | DnnDetectContext *ctx = context->priv; |
| @@ -535,5 +468,5 @@ const AVFilter ff_vf_dnn_detect = { · 25 unmodified lines | ||
| 535 | 468 | FILTER_INPUTS(dnn_detect_inputs), |
| 536 | 469 | FILTER_OUTPUTS(dnn_detect_outputs), |
| 537 | 470 | .priv_class = &dnn_detect_class, |
| 538 | − .activate = dnn_detect_activate_async, | |
| 471 | + .activate = dnn_detect_activate, | |
| 539 | 472 | }; |
| @@ -244,76 +244,6 @@ static int copy_uv_planes(DnnProcessingContext *ctx, AVFrame *out, const AVFrame · 243 unmodified lines | ||
| 244 | 244 | return 0; |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | −static int filter_frame(AVFilterLink *inlink, AVFrame *in) | |
| 248 | −{ | |
| 249 | − AVFilterContext *context = inlink->dst; | |
| 250 | − AVFilterLink *outlink = context->outputs[0]; | |
| 251 | − DnnProcessingContext *ctx = context->priv; | |
| 252 | − DNNReturnType dnn_result; | |
| 253 | − AVFrame *out; | |
| 254 | − | |
| 255 | − out = ff_get_video_buffer(outlink, outlink->w, outlink->h); | |
| 256 | − if (!out) { | |
| 257 | − av_frame_free(&in); | |
| 258 | − return AVERROR(ENOMEM); | |
| 259 | − } | |
| 260 | − av_frame_copy_props(out, in); | |
| 261 | − | |
| 262 | − dnn_result = ff_dnn_execute_model(&ctx->dnnctx, in, out); | |
| 263 | − if (dnn_result != DNN_SUCCESS){ | |
| 264 | − av_log(ctx, AV_LOG_ERROR, "failed to execute model\n"); | |
| 265 | − av_frame_free(&in); | |
| 266 | − av_frame_free(&out); | |
| 267 | − return AVERROR(EIO); | |
| 268 | − } | |
| 269 | − | |
| 270 | − if (isPlanarYUV(in->format)) | |
| 271 | − copy_uv_planes(ctx, out, in); | |
| 272 | − | |
| 273 | − av_frame_free(&in); | |
| 274 | − return ff_filter_frame(outlink, out); | |
| 275 | −} | |
| 276 | − | |
| 277 | −static int activate_sync(AVFilterContext *filter_ctx) | |
| 278 | −{ | |
| 279 | − AVFilterLink *inlink = filter_ctx->inputs[0]; | |
| 280 | − AVFilterLink *outlink = filter_ctx->outputs[0]; | |
| 281 | − AVFrame *in = NULL; | |
| 282 | − int64_t pts; | |
| 283 | − int ret, status; | |
| 284 | − int got_frame = 0; | |
| 285 | − | |
| 286 | − FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink); | |
| 287 | − | |
| 288 | − do { | |
| 289 | − // drain all input frames | |
| 290 | − ret = ff_inlink_consume_frame(inlink, &in); | |
| 291 | − if (ret < 0) | |
| 292 | − return ret; | |
| 293 | − if (ret > 0) { | |
| 294 | − ret = filter_frame(inlink, in); | |
| 295 | − if (ret < 0) | |
| 296 | − return ret; | |
| 297 | − got_frame = 1; | |
| 298 | − } | |
| 299 | − } while (ret > 0); | |
| 300 | − | |
| 301 | − // if frame got, schedule to next filter | |
| 302 | − if (got_frame) | |
| 303 | − return 0; | |
| 304 | − | |
| 305 | − if (ff_inlink_acknowledge_status(inlink, &status, &pts)) { | |
| 306 | − if (status == AVERROR_EOF) { | |
| 307 | − ff_outlink_set_status(outlink, status, pts); | |
| 308 | − return ret; | |
| 309 | − } | |
| 310 | − } | |
| 311 | − | |
| 312 | − FF_FILTER_FORWARD_WANTED(outlink, inlink); | |
| 313 | − | |
| 314 | − return FFERROR_NOT_READY; | |
| 315 | −} | |
| 316 | − | |
| 317 | 247 | static int flush_frame(AVFilterLink *outlink, int64_t pts, int64_t *out_pts) |
| 318 | 248 | { |
| 319 | 249 | DnnProcessingContext *ctx = outlink->src->priv; |
| @@ -345,7 +275,7 @@ static int flush_frame(AVFilterLink *outlink, int64_t pts, int64_t *out_pts) · 25 unmodified lines | ||
| 345 | 275 | return 0; |
| 346 | 276 | } |
| 347 | 277 | |
| 348 | −static int activate_async(AVFilterContext *filter_ctx) | |
| 278 | +static int activate(AVFilterContext *filter_ctx) | |
| 349 | 279 | { |
| 350 | 280 | AVFilterLink *inlink = filter_ctx->inputs[0]; |
| 351 | 281 | AVFilterLink *outlink = filter_ctx->outputs[0]; |
| @@ -410,16 +340,6 @@ static int activate_async(AVFilterContext *filter_ctx) · 58 unmodified lines | ||
| 410 | 340 | return 0; |
| 411 | 341 | } |
| 412 | 342 | |
| 413 | −static av_unused int activate(AVFilterContext *filter_ctx) | |
| 414 | −{ | |
| 415 | − DnnProcessingContext *ctx = filter_ctx->priv; | |
| 416 | − | |
| 417 | − if (ctx->dnnctx.async) | |
| 418 | − return activate_async(filter_ctx); | |
| 419 | − else | |
| 420 | − return activate_sync(filter_ctx); | |
| 421 | −} | |
| 422 | − | |
| 423 | 343 | static av_cold void uninit(AVFilterContext *ctx) |
| 424 | 344 | { |
| 425 | 345 | DnnProcessingContext *context = ctx->priv; |
| @@ -454,5 +374,5 @@ const AVFilter ff_vf_dnn_processing = { · 28 unmodified lines | ||
| 454 | 374 | FILTER_INPUTS(dnn_processing_inputs), |
| 455 | 375 | FILTER_OUTPUTS(dnn_processing_outputs), |
| 456 | 376 | .priv_class = &dnn_processing_class, |
| 457 | − .activate = activate_async, | |
| 377 | + .activate = activate, | |
| 458 | 378 | }; |