summaryrefslogtreecommitdiffstats
path: root/audio/chmap_sel.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-04-28 22:01:55 +0200
committerwm4 <wm4@nowhere>2015-04-28 22:01:55 +0200
commitc4aa13615501189c55c23448d436074e5f92c8cc (patch)
tree7efeb6460590e3c77a030f51f36424d646102bfb /audio/chmap_sel.c
parent2fcf0e6183d569d61f904980c782f80cc50394ad (diff)
downloadmpv-c4aa13615501189c55c23448d436074e5f92c8cc.tar.bz2
mpv-c4aa13615501189c55c23448d436074e5f92c8cc.tar.xz
audio: separate fallbacks for upmix and downmix cases
We always want to prefer upmix to downmix, as long as it makes sense. Even if the upmix is not "perfect" (not just adding channels), we want to prefer the upmix. Cleanup for commit d3c7fd9d.
Diffstat (limited to 'audio/chmap_sel.c')
-rw-r--r--audio/chmap_sel.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/audio/chmap_sel.c b/audio/chmap_sel.c
index b99f7bd834..272e3e4baf 100644
--- a/audio/chmap_sel.c
+++ b/audio/chmap_sel.c
@@ -199,12 +199,16 @@ bool mp_chmap_sel_adjust(const struct mp_chmap_sel *s, struct mp_chmap *map)
return false;
}
-#define UPMIX_IDX 0
-#define FALLBACK_IDX 1
-#define DOWNMIX_IDX 2
+enum {
+ UPMIX_IDX,
+ FALLBACK_UPMIX_IDX,
+ DOWNMIX_IDX,
+ FALLBACK_DOWNMIX_IDX,
+ REMIX_COUNT
+};
static bool test_fallbacks(struct mp_chmap *a, struct mp_chmap *b,
- int best_diffs[2], struct mp_chmap best[2])
+ int best_diffs[], struct mp_chmap best[])
{
struct mp_chmap diff1, diff2;
@@ -222,15 +226,15 @@ static bool test_fallbacks(struct mp_chmap *a, struct mp_chmap *b,
return true;
}
- if (diff1.num > 0 && best_diffs[FALLBACK_IDX] > diff1.num) {
- best[FALLBACK_IDX] = *a;
- best_diffs[FALLBACK_IDX] = diff1.num;
+ if (diff1.num > 0 && best_diffs[FALLBACK_UPMIX_IDX] > diff1.num) {
+ best[FALLBACK_UPMIX_IDX] = *a;
+ best_diffs[FALLBACK_UPMIX_IDX] = diff1.num;
return true;
}
- if (diff2.num > 0 && best_diffs[FALLBACK_IDX] > diff2.num) {
- best[FALLBACK_IDX] = *a;
- best_diffs[FALLBACK_IDX] = diff2.num;
+ if (diff2.num > 0 && best_diffs[FALLBACK_DOWNMIX_IDX] > diff2.num) {
+ best[FALLBACK_DOWNMIX_IDX] = *a;
+ best_diffs[FALLBACK_DOWNMIX_IDX] = diff2.num;
return true;
}
@@ -255,8 +259,10 @@ bool mp_chmap_sel_fallback(const struct mp_chmap_sel *s, struct mp_chmap *map)
return true;
}
- int best_diffs[] = { INT_MAX, INT_MAX, INT_MAX };
- struct mp_chmap best[] = { {0}, {0}, {0} };
+ struct mp_chmap best[REMIX_COUNT] = {{0}};
+ int best_diffs[REMIX_COUNT];
+ for (int n = 0; n < REMIX_COUNT; n++)
+ best_diffs[n] = INT_MAX;
for (int n = 0; n < s->num_chmaps; n++) {
struct mp_chmap e = s->chmaps[n];