diff options
Diffstat (limited to 'audio')
-rw-r--r-- | audio/chmap_sel.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/audio/chmap_sel.c b/audio/chmap_sel.c index 8ddb7131e7..fa1941e6f6 100644 --- a/audio/chmap_sel.c +++ b/audio/chmap_sel.c @@ -274,19 +274,25 @@ static bool mp_chmap_is_better(struct mp_chmap *req, struct mp_chmap *old, if (new_lost_r != old_lost_r) return new_lost_r < old_lost_r; + struct mp_chmap old_p = *old, new_p = *new; + mp_chmap_remove_na(&old_p); + mp_chmap_remove_na(&new_p); + + // If the situation is equal with replaced speakers, but the replacement is + // perfect for only one of them, let the better one win. This prefers + // inexact equivalents over exact supersets. + bool perfect_r_new = !new_lost_r && new_p.num <= old_p.num; + bool perfect_r_old = !old_lost_r && old_p.num <= new_p.num; + if (perfect_r_new != perfect_r_old) + return perfect_r_new; + int old_lost = mp_chmap_diffn(req, old); int new_lost = mp_chmap_diffn(req, new); - - // If the situation is equal with replaced speakers, but one of them loses - // less if no replacements are performed, pick the better one, even if it - // means an upmix. This prefers exact supersets over inexact equivalents. + // If the situation is equal with replaced speakers, pick the better one, + // even if it means an upmix. if (new_lost != old_lost) return new_lost < old_lost; - struct mp_chmap old_p = *old, new_p = *new; - mp_chmap_remove_na(&old_p); - mp_chmap_remove_na(&new_p); - // Some kind of upmix. If it's perfect, prefer the smaller one. Even if not, // both have equal loss, so also prefer the smaller one. // Drop padding channels (NA) for the sake of this check, as the number of |