summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-04-27 23:21:14 +0200
committerwm4 <wm4@nowhere>2015-04-27 23:21:58 +0200
commitd3c7fd9d7c971086a3d6fde5f6f1bc4ef0b2e904 (patch)
tree24354c73f60d9461211664f2a9e1c888b1043448
parent570f4b136f43c60a16a433715768828a864f0e0a (diff)
downloadmpv-d3c7fd9d7c971086a3d6fde5f6f1bc4ef0b2e904.tar.bz2
mpv-d3c7fd9d7c971086a3d6fde5f6f1bc4ef0b2e904.tar.xz
audio: avoid downmixing in a certain special-case
As indicated by the added test. In this case, fallback and downmix have the same score, but fallback happens to give better results. So prefer fallback over downmix. (This is probably not a correct solution.)
-rw-r--r--audio/chmap_sel.c6
-rw-r--r--test/chmap_sel.c17
2 files changed, 20 insertions, 3 deletions
diff --git a/audio/chmap_sel.c b/audio/chmap_sel.c
index 515190e14d..b99f7bd834 100644
--- a/audio/chmap_sel.c
+++ b/audio/chmap_sel.c
@@ -200,8 +200,8 @@ bool mp_chmap_sel_adjust(const struct mp_chmap_sel *s, struct mp_chmap *map)
}
#define UPMIX_IDX 0
-#define DOWNMIX_IDX 1
-#define FALLBACK_IDX 2
+#define FALLBACK_IDX 1
+#define DOWNMIX_IDX 2
static bool test_fallbacks(struct mp_chmap *a, struct mp_chmap *b,
int best_diffs[2], struct mp_chmap best[2])
@@ -278,7 +278,7 @@ bool mp_chmap_sel_fallback(const struct mp_chmap_sel *s, struct mp_chmap *map)
}
}
- for (int i = UPMIX_IDX; i < MP_ARRAY_SIZE(best); i++) {
+ for (int i = 0; i < MP_ARRAY_SIZE(best); i++) {
if (best_diffs[i] < INT_MAX) {
*map = best[i];
return true;
diff --git a/test/chmap_sel.c b/test/chmap_sel.c
index c315d2f9a1..a1eae0b6b3 100644
--- a/test/chmap_sel.c
+++ b/test/chmap_sel.c
@@ -145,6 +145,22 @@ static void test_mp_chmap_sel_fallback_stereo_to_stereo(void **state) {
assert_string_equal(mp_chmap_to_str(&c), "stereo");
}
+static void test_mp_chmap_sel_fallback_no_downmix(void **state) {
+ struct mp_chmap a;
+ struct mp_chmap b;
+ struct mp_chmap c;
+ struct mp_chmap_sel s = {0};
+
+ mp_chmap_from_str(&a, bstr0("stereo"));
+ mp_chmap_from_str(&b, bstr0("7.1(rear)"));
+ mp_chmap_from_str(&c, bstr0("5.1(side)"));
+
+ mp_chmap_sel_add_map(&s, &a);
+ mp_chmap_sel_add_map(&s, &b);
+ assert_true(mp_chmap_sel_fallback(&s, &c));
+ assert_string_equal(mp_chmap_to_str(&c), "7.1(rear)");
+}
+
int main(void) {
const UnitTest tests[] = {
unit_test(test_mp_chmap_sel_fallback_upmix),
@@ -157,6 +173,7 @@ int main(void) {
unit_test(test_mp_chmap_sel_fallback_works_on_alsa_chmaps),
unit_test(test_mp_chmap_sel_fallback_mono_to_stereo),
unit_test(test_mp_chmap_sel_fallback_stereo_to_stereo),
+ unit_test(test_mp_chmap_sel_fallback_no_downmix),
};
return run_tests(tests);
}