From 05a4f577039a34f9e390b46fe17735e55855b7c2 Mon Sep 17 00:00:00 2001 From: Philip Langdale Date: Mon, 31 Jul 2023 09:29:08 +0800 Subject: [PATCH] output_chain: don't reset autoconvert on changes to unrelated filters This has been a standing behaviour for a long time, but I noticed it while implementing the hw->hw autoconvert functionality. Today, the output_chain will reset the autoconvert state when any output_chain filter sees the input format change. This is wasteful as it leads to the image converter having to be reinitialised each time it happens, so we should only do it when the actual "convert" filter sees the input format change. It doesn't matter if one of the other filters in the chain sees a change (although in practice, a format change will basically always propagate down the chain, so they all see a change at the same time). The practical effect of the old behaviour was that a format change would always lead to the image converter being rebuilt twice - once after the "convert" filter sees the format change, and then again after the "out" filter (the end of the chain) sees the change. In this commit, we check which filter is seeing the change, and only reset the autoconvert state for the "convert" filter itself. --- filters/f_output_chain.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/filters/f_output_chain.c b/filters/f_output_chain.c index b9ee7060cc..2d4dcba417 100644 --- a/filters/f_output_chain.c +++ b/filters/f_output_chain.c @@ -114,7 +114,11 @@ static void check_in_format_change(struct mp_user_filter *u, // But a common case is enabling HW decoding, which // might init some support of them in the VO, and update // the VO's format list. - update_output_caps(p); + // + // But as this is only relevant to the "convert" filter, don't + // do this for the other filters as it is wasted work. + if (strcmp(u->name, "convert") == 0) + update_output_caps(p); p->public.reconfig_happened = true; }