diff --git a/libswscale/graph.c b/libswscale/graph.c index 941ef1cb8a..cd4498c91e 100644 --- a/libswscale/graph.c +++ b/libswscale/graph.c @@ -658,11 +658,20 @@ static int add_convert_pass(SwsGraph *graph, const SwsFormat *src, const SwsFormat *dst, SwsPass *input, SwsPass **output) { + SwsContext *ctx = graph->ctx; int ret; - ret = add_ops_convert_pass(graph, src, dst, input, output); - if (ret == AVERROR(ENOTSUP)) + if (ctx->flags & SWS_UNSTABLE) { + /* Prefer unstable ops backend over legacy backend */ + ret = add_ops_convert_pass(graph, src, dst, input, output); + if (ret == AVERROR(ENOTSUP)) + ret = add_legacy_sws_pass(graph, src, dst, input, output); + } else { + /* Prefer legacy backend for stability reasons */ ret = add_legacy_sws_pass(graph, src, dst, input, output); + if (ret == AVERROR(ENOTSUP)) + ret = add_ops_convert_pass(graph, src, dst, input, output); + } return ret; } diff --git a/libswscale/swscale.h b/libswscale/swscale.h index 8954f1a7d8..9b53ebbdff 100644 --- a/libswscale/swscale.h +++ b/libswscale/swscale.h @@ -180,9 +180,9 @@ typedef enum SwsFlags { SWS_BITEXACT = 1 << 19, /** - * Allow using experimental new code paths. This may be faster, slower, - * or produce different output, with semantics subject to change at any - * point in time. For testing and debugging purposes only. + * Allow/prefer using experimental new code paths. This may be faster, + * slower, or produce different output, with semantics subject to change + * at any point in time. For testing and debugging purposes only. */ SWS_UNSTABLE = 1 << 20,