summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-01-04 19:17:18 +0100
committerwm4 <wm4@nowhere>2016-01-04 19:17:56 +0100
commitdac5b598f57daba6d863d4439b67c0455e644d8d (patch)
tree2e5a6c523ced9c54b97f4fa3324efe2ff9987845 /audio
parentcb8b0cc329fa8db3590682afc8c25bb00666843c (diff)
downloadmpv-dac5b598f57daba6d863d4439b67c0455e644d8d.tar.bz2
mpv-dac5b598f57daba6d863d4439b67c0455e644d8d.tar.xz
chmap_sel: prefer inexact equivalents over perfect upmix
Given 5.1(side), this lets it pick 5.1 from [5.1, 7.1]. Which was probably the original intention of this replacement stuff. Until now, the opposite was done in some cases. Keep the old heuristic if the replacement is not perfect. This would mean that a subset of the channel layout is an inexact equivalent, but not all of it. (My conclusion is that audio output APIs should be designed to simply take any channel layout, like the PulseAudio API does.)
Diffstat (limited to 'audio')
-rw-r--r--audio/chmap_sel.c22
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