1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-24 15:52:25 +00:00

chmap: use av_popcount64()

Saves us some code, and also happens to fix #1968.
This commit is contained in:
wm4 2015-05-21 20:37:17 +02:00
parent 292266f268
commit 7412995c94

View File

@ -18,6 +18,8 @@
#include <stdlib.h>
#include <assert.h>
#include <libavutil/common.h>
#include "common/common.h"
#include "common/msg.h"
#include "chmap.h"
@ -395,20 +397,12 @@ void mp_chmap_get_reorder(int src[MP_NUM_CHANNELS], const struct mp_chmap *from,
assert(src[n] < 0 || (to->speaker[n] == from->speaker[src[n]]));
}
static int popcount64(uint64_t bits)
{
int r = 0;
for (int n = 0; n < 64; n++)
r += !!(bits & (1ULL << n));
return r;
}
// Return the number of channels only in a.
int mp_chmap_diffn(const struct mp_chmap *a, const struct mp_chmap *b)
{
uint64_t a_mask = mp_chmap_to_lavc_unchecked(a);
uint64_t b_mask = mp_chmap_to_lavc_unchecked(b);
return popcount64((a_mask ^ b_mask) & a_mask);
return av_popcount64((a_mask ^ b_mask) & a_mask);
}
// Returns something like "fl-fr-fc". If there's a standard layout in lavc