From: Niklas Haas <g...@haasn.dev> Take special care to handle grayscale formats without a colorspace gracefully. --- libswscale/graph.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/libswscale/graph.c b/libswscale/graph.c index fbad1fe8c3..36b74fad0c 100644 --- a/libswscale/graph.c +++ b/libswscale/graph.c @@ -521,8 +521,21 @@ int sws_graph_create(SwsContext *ctx, const SwsFormat *dst, const SwsFormat *src graph->field = field; graph->opts_copy = *ctx; - graph->exec.input.fmt = src->format; - graph->exec.output.fmt = dst->format; + /** + * Grayspace does not really have primaries, so just force the use of + * the equivalent other primary set to avoid a conversion. Technically, + * this does affect the weights used for the Grayscale conversion, but + * in practise, that should give the expected results more often than not. + */ + if (isGray(dst->format)) { + graph->dst.color = graph->src.color; + } else if (isGray(src->format)) { + graph->src.color = graph->dst.color; + } + + graph->incomplete = ff_infer_colors(&graph->src.color, &graph->dst.color); + graph->exec.input.fmt = graph->src.format; + graph->exec.output.fmt = graph->dst.format; ret = avpriv_slicethread_create(&graph->slicethread, (void *) graph, sws_graph_worker, NULL, ctx->threads); -- 2.47.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".